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"
26 #include "gazebo/msgs/msgs.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace gui
33  {
34  class ViewState;
35 
38  class GAZEBO_VISIBLE ModelRightMenu : public QObject
39  {
40  Q_OBJECT
41 
43  public: ModelRightMenu();
44 
46  public: virtual ~ModelRightMenu();
47 
52  public: void Run(const std::string &_modelName, const QPoint &_pt);
53 
55  private slots: void OnMoveTo();
56 
58  private slots: void OnFollow();
59 
62  private slots: void OnDelete(const std::string &_name="");
63 
65  // private slots: void OnSnapBelow();
66 
67  // private slots: void OnSkeleton();
68 
72  private: bool OnKeyRelease(const common::KeyEvent &_event);
73 
76  private: void OnRequest(ConstRequestPtr &_msg);
77 
79  private: transport::NodePtr node;
80 
82  private: transport::SubscriberPtr requestSub;
83 
85  private: std::string modelName;
86 
88  private: QAction *moveToAct;
89 
91  private: QAction *followAct;
92 
95  // private: QAction *snapBelowAct;
96  // private: QAction *skeletonAct;
97 
99  private: std::vector<ViewState*> viewStates;
100 
101  // The view state class is a friend for convenience
102  private: friend class ViewState;
103 
107  public: bool Init();
108  };
109 
113  class GAZEBO_VISIBLE ViewState : public QObject
114  {
115  Q_OBJECT
116 
121  public: ViewState(ModelRightMenu *_parent,
122  const std::string &_checkRequest,
123  const std::string &_uncheckRequest);
124 
126  public: std::map<std::string, bool> modelStates;
127 
129  public: QAction *action;
130 
132  public: bool globalEnable;
133 
136 
138  public: std::string checkRequest;
139 
141  public: std::string uncheckRequest;
142 
144  public slots: void Callback();
145  };
146  }
147 }
148 #endif
Displays a menu when the right mouse button has been pressed.
Definition: ModelRightMenu.hh:38
bool globalEnable
True if the view visualization is enabled globally.
Definition: ModelRightMenu.hh:132
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
Generic description of a keyboard event.
Definition: KeyEvent.hh:32
Forward declarations for transport.
ModelRightMenu * parent
Pointer to the ModelRightMenu.
Definition: ModelRightMenu.hh:135
std::string uncheckRequest
Name of the request to send when unchecked.
Definition: ModelRightMenu.hh:141
std::string checkRequest
Name of the request to send when checked.
Definition: ModelRightMenu.hh:138
std::map< std::string, bool > modelStates
State of all the models for this view.
Definition: ModelRightMenu.hh:126
A class for managing view visualization states.
Definition: ModelRightMenu.hh:113
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:48
QAction * action
Action for this view.
Definition: ModelRightMenu.hh:129