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