Gazebo Sim

API Reference

7.7.0
EntityContextMenuPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 
18 #ifndef GZ_GUI_PLUGINS_ENTITY_CONTEXT_MENU_HH_
19 #define GZ_GUI_PLUGINS_ENTITY_CONTEXT_MENU_HH_
20 
21 #include <memory>
22 
23 #include <gz/common/MouseEvent.hh>
24 
25 #include <gz/gui/Plugin.hh>
26 
27 #include <gz/rendering/Camera.hh>
28 
29 namespace gz
30 {
31 namespace sim
32 {
33  class EntityContextMenuPrivate;
34 
37  class EntityContextMenu : public gz::gui::Plugin
38  {
39  Q_OBJECT
40 
42  public: EntityContextMenu();
43 
45  public: ~EntityContextMenu() override;
46 
47  // Documentation inherited
48  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
49 
50  // Documentation inherited
51  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
52 
56  };
57 
58  class EntityContextMenuHandler : public QObject
59  {
60  Q_OBJECT
61 
63  public: EntityContextMenuHandler();
64 
68  public: void HandleMouseContextMenu(const common::MouseEvent &_mouseEvent,
69  const rendering::CameraPtr &_camera);
70 
75  signals: void ContextMenuRequested(
76  QString _entity, int _mouseX, int _mouseY);
77  };
78 
80  class EntityContextMenuItem : public QQuickItem
81  {
82  Q_OBJECT
83 
86  public: explicit EntityContextMenuItem(QQuickItem *_parent = nullptr);
87 
90  public: void SetEntityContextMenuHandler(
91  const EntityContextMenuHandler &_entityContextMenuHandler);
92 
99  signals: void openContextMenu(QString _entity, int _mouseX, int _mouseY); // NOLINT
100 
105  public slots: void OnContextMenuRequested(
106  QString _entity, int _mouseX, int _mouseY);
107  };
108 }
109 }
110 
111 #endif