ApplyWrenchDialog.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_GUI_APPLYWRENCHDIALOG_HH_
18 #define GAZEBO_GUI_APPLYWRENCHDIALOG_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <ignition/math/Vector3.hh>
23 
25 #include "gazebo/gui/qt.h"
26 
27 namespace gazebo
28 {
29  namespace gui
30  {
31  class ApplyWrenchDialogPrivate;
32 
35 
38  class GZ_GUI_VISIBLE ApplyWrenchDialog : public QDialog
39  {
40  Q_OBJECT
41 
44  public: enum Mode
45  {
47  NONE = 0,
49  FORCE = 1,
51  TORQUE = 2
52  };
53 
56  public: ApplyWrenchDialog(QWidget *_parent = 0);
57 
59  public: ~ApplyWrenchDialog();
60 
66  public: void Init(const std::string &_modelName,
67  const std::string &_linkName);
68 
70  public: void Fini();
71 
74  public: Mode GetMode() const;
75 
79  private: bool SetModel(const std::string &_modelName);
80 
84  private: bool SetLink(const std::string &_linkName);
85 
88  private slots: void SetLink(const QString _linkName);
89 
91  private slots: void OnApplyAll();
92 
94  private slots: void OnApplyForce();
95 
97  private slots: void OnApplyTorque();
98 
100  private slots: void OnCancel();
101 
104  private slots: void ToggleComRadio(bool _checked);
105 
108  private slots: void OnForcePosChanged(double _value);
109 
112  private slots: void OnForceMagChanged(double _magnitude);
113 
116  private slots: void OnForceChanged(double _value);
117 
119  private slots: void OnForceClear();
120 
123  private slots: void OnTorqueMagChanged(double _magnitude);
124 
127  private slots: void OnTorqueChanged(double _value);
128 
130  private slots: void OnTorqueClear();
131 
133  private slots: void OnManipulation();
134 
139  private slots: bool eventFilter(QObject *_object, QEvent *_event);
140 
143  private slots: void changeEvent(QEvent *_event);
144 
149  private: void SetSpinValue(QDoubleSpinBox *_spin, const double _value);
150 
153  private: void SetForcePos(const ignition::math::Vector3d &_forcePos);
154 
158  private: void SetForce(const ignition::math::Vector3d &_force,
159  const bool _rotatedByMouse = false);
160 
164  private: void SetTorque(const ignition::math::Vector3d &_torque,
165  const bool _rotatedByMouse = false);
166 
169  private: void OnPreRender();
170 
172  private: void AttachVisuals();
173 
176  private: void SetCoM(const ignition::math::Vector3d &_com);
177 
181  private: bool OnMousePress(const common::MouseEvent &_event);
182 
186  private: bool OnMouseRelease(const common::MouseEvent &_event);
187 
191  private: bool OnMouseMove(const common::MouseEvent &_event);
192 
195  private: void SetMode(Mode _mode);
196 
200  private: void NewForceDirection(const ignition::math::Vector3d &_dir);
201 
205  private: void NewTorqueDirection(const ignition::math::Vector3d &_dir);
206 
210  private: void SetActive(bool _active);
211 
213  private: void ActivateWindow();
214 
217  private: std::unique_ptr<ApplyWrenchDialogPrivate> dataPtr;
218  };
220  }
221 }
222 
223 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:35
Forward declarations for the common classes.
Definition: Animation.hh:33
Mode
Definition: ApplyWrenchDialog.hh:44
Dialog for applying force and torque to a model.
Definition: ApplyWrenchDialog.hh:38
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.