SegmentItem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-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_BUILDING_SEGMENTITEM_HH_
19 #define _GAZEBO_GUI_BUILDING_SEGMENTITEM_HH_
20 
21 #include <memory>
22 #include <vector>
23 
24 #include "gazebo/gui/qt.h"
26 
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace gui
32  {
33  class GrabberHandle;
34 
35  // Forward declare private data.
36  class SegmentItemPrivate;
37 
40 
44  : public EditorItem, public QGraphicsLineItem
45  {
48  public: SegmentItem(QGraphicsItem *_parent = 0);
49 
51  public: ~SegmentItem();
52 
56  public: void SetLine(const QPointF &_start, const QPointF &_end);
57 
60  public: void SetStartPoint(const QPointF &_start);
61 
64  public: QPointF GetStartPoint() const;
65 
68  public: void SetEndPoint(const QPointF &_end);
69 
72  public: QPointF GetEndPoint() const;
73 
76  public: void SetThickness(double _thickness);
77 
80  public: double GetThickness() const;
81 
84  public: double GetScale() const;
85 
88  public: void SetScale(double _scale);
89 
92  public: void SetColor(QColor _color);
93 
96  public: void ShowHandles(bool _show);
97 
99  public: void SegmentChanged();
100 
101  // Documentation Inherited
102  public: QVector3D GetSize() const;
103 
104  // Documentation Inherited
105  public: QVector3D GetScenePosition() const;
106 
107  // Documentation Inherited
108  public: double GetSceneRotation() const;
109 
112  public: std::vector<GrabberHandle *>Grabbers() const;
113 
115  protected: virtual void SegmentUpdated();
116 
120  protected: void UpdateLinkedGrabbers(GrabberHandle *_grabber,
121  const QPointF &_pos);
122 
127  private: bool sceneEventFilter(QGraphicsItem *watched,
128  QEvent *_event);
129 
134  private: bool GrabberEventFilter(GrabberHandle *_grabber,
135  QEvent *_event);
136 
139  private: void hoverEnterEvent(QGraphicsSceneHoverEvent *_event);
140 
143  private: void hoverMoveEvent(QGraphicsSceneHoverEvent *_event);
144 
147  private: void hoverLeaveEvent(QGraphicsSceneHoverEvent *_event);
148 
151  private: void mouseMoveEvent(QGraphicsSceneMouseEvent *_event);
152 
155  private: void mousePressEvent(QGraphicsSceneMouseEvent *_event);
156 
159  private: void mouseReleaseEvent(QGraphicsSceneMouseEvent *_event);
160 
165  private: void paint(QPainter *_painter,
166  const QStyleOptionGraphicsItem *_option, QWidget *_widget);
167 
169  public: static const double SnapAngle;
170 
172  public: static const double SnapLength;
173 
176  protected: std::vector<GrabberHandle *> grabbers;
177 
180  private: std::unique_ptr<SegmentItemPrivate> dataPtr;
181  };
183  }
184 }
185 
186 #endif
Base class of an item in the editor.
Definition: EditorItem.hh:40
#define GZ_GUI_VISIBLE
Definition: system.hh:284
static const double SnapLength
Length to snap in meters.
Definition: SegmentItem.hh:172
2D line segment.
Definition: SegmentItem.hh:43
std::vector< GrabberHandle * > grabbers
A list of grabber handles for this item.
Definition: SegmentItem.hh:176
static const double SnapAngle
Angle to snap in degrees.
Definition: SegmentItem.hh:169
Definition: GrabberHandle.hh:42