GrabberHandle.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 
18 #ifndef _GAZEBO_GUI_GRABBER_HANDLE_HH_
19 #define _GAZEBO_GUI_GRABBER_HANDLE_HH_
20 
21 #include <vector>
22 #include <memory>
23 
24 #include <ignition/math/Vector2.hh>
25 
26 #include "gazebo/gui/qt.h"
27 
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace common
33  {
34  class Color;
35  }
36 
37  namespace gui
38  {
39  // Forward declare private data class.
40  class GrabberHandlePrivate;
41 
42  class GZ_GUI_VISIBLE GrabberHandle : public QGraphicsItem
43  {
47  public: GrabberHandle(QGraphicsItem *_parent = 0, int index = 0);
48 
50  public: virtual ~GrabberHandle();
51 
54  public: int Index() const;
55 
58  public: int MouseState() const;
59 
62  public: ignition::math::Vector2d CenterPoint() const;
63 
66  public: double MouseDownX() const;
67 
70  public: double MouseDownY() const;
73  public: double Width() const;
74 
77  public: double Height() const;
78 
81  public: common::Color Color() const;
82 
85  public: void SetMouseState(int _state);
86 
89  public: void SetMouseDownX(double _x);
90 
93  public: void SetMouseDownY(double _y);
94 
97  public: void SetWidth(double _width);
98 
101  public: void SetHeight(double _height);
102 
105  public: void SetColor(const common::Color &_color);
106 
109  public: void SetBorderColor(const common::Color &_borderColor);
110 
113  public: virtual QRectF boundingRect() const;
114 
117  public: std::vector<GrabberHandle *> LinkedGrabbers() const;
118 
121  public: void PushLinkedGrabber(GrabberHandle *_grabber);
122 
125  public: void EraseLinkedGrabber(GrabberHandle *_grabber);
126 
131  private: virtual void paint(QPainter *_painter,
132  const QStyleOptionGraphicsItem *_option, QWidget *_widget);
133 
136  protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *_event);
137 
140  protected: void hoverLeaveEvent(QGraphicsSceneHoverEvent *_event);
141 
144  protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *_event);
145 
148  protected: void mousePressEvent(QGraphicsSceneMouseEvent *_event);
149 
152  protected: void mouseReleaseEvent(QGraphicsSceneMouseEvent *_event);
153 
156  protected: void mousePressEvent(QGraphicsSceneDragDropEvent *_event);
157 
160  protected: void mouseMoveEvent(QGraphicsSceneDragDropEvent *_event);
161 
164  private: std::unique_ptr<GrabberHandlePrivate> dataPtr;
165  };
167  }
168 }
169 
170 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Defines a color.
Definition: Color.hh:36
Definition: GrabberHandle.hh:42