ModelRightMenu.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 _MODELRIGHTMENU_HH_
18 #define _MODELRIGHTMENU_HH_
19 
20 #include <map>
21 #include <vector>
22 #include <string>
23 
25 #include "gazebo/gui/qt.h"
27 #include "gazebo/msgs/msgs.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace gui
34  {
35  class ViewState;
36 
39  class GZ_GUI_VISIBLE ModelRightMenu : public QObject
40  {
41  Q_OBJECT
42 
46  public: enum EntityTypes {
52  LINK
53  };
54 
56  public: ModelRightMenu();
57 
59  public: virtual ~ModelRightMenu();
60 
63  public: bool Init();
64 
70  public: void Run(const std::string &_entityName, const QPoint &_pt,
71  EntityTypes _type = MODEL);
72 
74  private slots: void OnMoveTo();
75 
77  private slots: void OnFollow();
78 
80  private slots: void OnEdit();
81 
83  private slots: void OnApplyWrench();
84 
87  private slots: void OnDelete(const std::string &_name="");
88 
90  // private slots: void OnSnapBelow();
91 
92  // private slots: void OnSkeleton();
93 
97  private: bool OnKeyRelease(const common::KeyEvent &_event);
98 
101  private: void OnRequest(ConstRequestPtr &_msg);
102 
105  private: void OnWindowMode(const std::string &_mode);
106 
108  private: transport::NodePtr node;
109 
111  private: transport::SubscriberPtr requestSub;
112 
114  private: std::string entityName;
115 
117  private: QAction *moveToAct;
118 
120  private: QAction *followAct;
121 
123  private: QAction *editAct;
124 
126  private: QAction *applyWrenchAct;
127 
129  private: std::vector<event::ConnectionPtr> connections;
130 
132  private: std::string windowMode;
133 
136  // private: QAction *snapBelowAct;
137  // private: QAction *skeletonAct;
138 
140  private: std::vector<ViewState*> viewStates;
141 
142  // The view state class is a friend for convenience
143  private: friend class ViewState;
144  };
145 
149  class GZ_GUI_VISIBLE ViewState : public QObject
150  {
151  Q_OBJECT
152 
157  public: ViewState(ModelRightMenu *_parent,
158  const std::string &_checkRequest,
159  const std::string &_uncheckRequest);
160 
162  public: std::map<std::string, bool> modelStates;
163 
165  public: QAction *action;
166 
168  public: bool globalEnable;
169 
172 
174  public: std::string checkRequest;
175 
177  public: std::string uncheckRequest;
178 
180  public slots: void Callback();
181  };
182  }
183 }
184 #endif
Displays a menu when the right mouse button has been pressed.
Definition: ModelRightMenu.hh:39
std::map< std::string, bool > modelStates
State of all the models for this view.
Definition: ModelRightMenu.hh:162
EntityTypes
Unique identifiers for the type of entity this menu is attached to.
Definition: ModelRightMenu.hh:46
Forward declarations for the common classes.
Definition: Animation.hh:33
Light.
Definition: ModelRightMenu.hh:50
Generic description of a keyboard event.
Definition: KeyEvent.hh:32
Forward declarations for transport.
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
ModelRightMenu * parent
Pointer to the ModelRightMenu.
Definition: ModelRightMenu.hh:171
std::string checkRequest
Name of the request to send when checked.
Definition: ModelRightMenu.hh:174
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
std::string uncheckRequest
Name of the request to send when unchecked.
Definition: ModelRightMenu.hh:177
A class for managing view visualization states.
Definition: ModelRightMenu.hh:149
QAction * action
Action for this view.
Definition: ModelRightMenu.hh:165
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Model.
Definition: ModelRightMenu.hh:48
bool globalEnable
True if the view visualization is enabled globally.
Definition: ModelRightMenu.hh:168