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 
95  private: bool OnKeyRelease(const common::KeyEvent &_event);
96 
99  private: void OnRequest(ConstRequestPtr &_msg);
100 
103  private: void OnWindowMode(const std::string &_mode);
104 
106  private: transport::NodePtr node;
107 
109  private: transport::SubscriberPtr requestSub;
110 
112  private: std::string entityName;
113 
115  private: QAction *moveToAct;
116 
118  private: QAction *followAct;
119 
121  private: QAction *editAct;
122 
124  private: QAction *applyWrenchAct;
125 
127  private: std::vector<event::ConnectionPtr> connections;
128 
130  private: std::string windowMode;
131 
134  // private: QAction *snapBelowAct;
135 
137  private: std::vector<ViewState*> viewStates;
138 
139  // The view state class is a friend for convenience
140  private: friend class ViewState;
141  };
142 
146  class GZ_GUI_VISIBLE ViewState : public QObject
147  {
148  Q_OBJECT
149 
154  public: ViewState(ModelRightMenu *_parent,
155  const std::string &_checkRequest,
156  const std::string &_uncheckRequest);
157 
159  public: std::map<std::string, bool> modelStates;
160 
162  public: QAction *action;
163 
165  public: bool globalEnable;
166 
169 
171  public: std::string checkRequest;
172 
174  public: std::string uncheckRequest;
175 
177  public slots: void Callback();
178  };
179  }
180 }
181 #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:159
EntityTypes
Unique identifiers for the type of entity this menu is attached to.
Definition: ModelRightMenu.hh:46
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:168
std::string checkRequest
Name of the request to send when checked.
Definition: ModelRightMenu.hh:171
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
std::string uncheckRequest
Name of the request to send when unchecked.
Definition: ModelRightMenu.hh:174
A class for managing view visualization states.
Definition: ModelRightMenu.hh:146
QAction * action
Action for this view.
Definition: ModelRightMenu.hh:162
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:165