ModelRightMenu.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-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 _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 GAZEBO_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 
66  public: void Run(const std::string &_entityName, const QPoint &_pt,
67  EntityTypes _type = MODEL);
68 
70  private slots: void OnMoveTo();
71 
73  private slots: void OnFollow();
74 
76  private slots: void OnEdit();
77 
79  private slots: void OnApplyWrench();
80 
83  private slots: void OnDelete(const std::string &_name="");
84 
86  // private slots: void OnSnapBelow();
87 
88  // private slots: void OnSkeleton();
89 
93  private: bool OnKeyRelease(const common::KeyEvent &_event);
94 
97  private: void OnRequest(ConstRequestPtr &_msg);
98 
100  private: transport::NodePtr node;
101 
103  private: transport::SubscriberPtr requestSub;
104 
106  private: std::string entityName;
107 
109  private: QAction *moveToAct;
110 
112  private: QAction *followAct;
113 
115  private: QAction *editAct;
116 
118  private: QAction *applyWrenchAct;
119 
122  // private: QAction *snapBelowAct;
123  // private: QAction *skeletonAct;
124 
126  private: std::vector<ViewState*> viewStates;
127 
128  // The view state class is a friend for convenience
129  private: friend class ViewState;
130 
134  public: bool Init();
135  };
136 
140  class GAZEBO_VISIBLE ViewState : public QObject
141  {
142  Q_OBJECT
143 
148  public: ViewState(ModelRightMenu *_parent,
149  const std::string &_checkRequest,
150  const std::string &_uncheckRequest);
151 
153  public: std::map<std::string, bool> modelStates;
154 
156  public: QAction *action;
157 
159  public: bool globalEnable;
160 
163 
165  public: std::string checkRequest;
166 
168  public: std::string uncheckRequest;
169 
171  public slots: void Callback();
172  };
173  }
174 }
175 #endif
Displays a menu when the right mouse button has been pressed.
Definition: ModelRightMenu.hh:39
bool globalEnable
True if the view visualization is enabled globally.
Definition: ModelRightMenu.hh:159
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
EntityTypes
Unique identifiers for the type of entity this menu is attached to.
Definition: ModelRightMenu.hh:46
Model.
Definition: ModelRightMenu.hh:48
Generic description of a keyboard event.
Definition: KeyEvent.hh:32
Forward declarations for transport.
ModelRightMenu * parent
Pointer to the ModelRightMenu.
Definition: ModelRightMenu.hh:162
std::string uncheckRequest
Name of the request to send when unchecked.
Definition: ModelRightMenu.hh:168
std::string checkRequest
Name of the request to send when checked.
Definition: ModelRightMenu.hh:165
Light.
Definition: ModelRightMenu.hh:50
std::map< std::string, bool > modelStates
State of all the models for this view.
Definition: ModelRightMenu.hh:153
A class for managing view visualization states.
Definition: ModelRightMenu.hh:140
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:66
QAction * action
Action for this view.
Definition: ModelRightMenu.hh:156