SegmentItem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-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 
18 #ifndef _SEGMENT_ITEM_HH_
19 #define _SEGMENT_ITEM_HH_
20 
21 #include <vector>
22 #include "gazebo/gui/qt.h"
24 #include "gazebo/util/system.hh"
25 
26 namespace gazebo
27 {
28  namespace gui
29  {
30  class GrabberHandle;
31  class EditorItem;
32 
35 
39  : public EditorItem, public QGraphicsLineItem
40  {
43  public: SegmentItem(QGraphicsItem *_parent = 0);
44 
46  public: ~SegmentItem();
47 
51  public: void SetLine(const QPointF &_start, const QPointF &_end);
52 
55  public: void SetStartPoint(const QPointF &_start);
56 
59  public: QPointF GetStartPoint() const;
60 
63  public: void SetEndPoint(const QPointF &_end);
64 
67  public: QPointF GetEndPoint() const;
68 
71  public: void SetThickness(double _thickness);
72 
75  public: double GetThickness() const;
76 
79  public: double GetScale() const;
80 
83  public: void SetScale(double _scale);
84 
87  public: void SetColor(QColor _color);
88 
91  public: void ShowHandles(bool _show);
92 
94  public: void SegmentChanged();
95 
96  // Documentation Inherited
97  public: QVector3D GetSize() const;
98 
99  // Documentation Inherited
100  public: QVector3D GetScenePosition() const;
101 
102  // Documentation Inherited
103  public: double GetSceneRotation() const;
104 
106  protected: virtual void SegmentUpdated();
107 
111  protected: void UpdateLinkedGrabbers(GrabberHandle *_grabber,
112  const QPointF &_pos);
113 
118  private: bool sceneEventFilter(QGraphicsItem *watched,
119  QEvent *_event);
120 
125  private: bool GrabberEventFilter(GrabberHandle *_grabber,
126  QEvent *_event);
127 
130  private: void hoverEnterEvent(QGraphicsSceneHoverEvent *_event);
131 
134  private: void hoverMoveEvent(QGraphicsSceneHoverEvent *_event);
135 
138  private: void hoverLeaveEvent(QGraphicsSceneHoverEvent *_event);
139 
142  private: void mouseMoveEvent(QGraphicsSceneMouseEvent *_event);
143 
146  private: void mousePressEvent(QGraphicsSceneMouseEvent *_event);
147 
150  private: void mouseReleaseEvent(QGraphicsSceneMouseEvent *_event);
151 
156  private: void paint(QPainter *_painter,
157  const QStyleOptionGraphicsItem *_option, QWidget *_widget);
158 
161  public: std::vector<GrabberHandle *> grabbers;
162 
164  public: static const double SnapAngle;
165 
167  public: static const double SnapLength;
168 
170  private: QPointF start;
171 
173  private: QPointF end;
174 
176  private: QPointF segmentMouseMove;
177 
179  private: double thickness;
180 
182  private: double grabberWidth;
183 
185  private: double grabberHeight;
186  };
188  }
189 }
190 
191 #endif
Base class of an item in the editor.
Definition: EditorItem.hh:34
static const double SnapLength
Length to snap in meters.
Definition: SegmentItem.hh:167
2D line segment.
Definition: SegmentItem.hh:38
std::vector< GrabberHandle * > grabbers
A list of grabber handles for this item.
Definition: SegmentItem.hh:161
static const double SnapAngle
Angle to snap in degrees.
Definition: SegmentItem.hh:164
Definition: GrabberHandle.hh:29
#define GZ_GUI_BUILDING_VISIBLE
Definition: system.hh:393