All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LineSegmentItem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _LINE_SEGMENT_ITEM_HH_
19 #define _LINE_SEGMENT_ITEM_HH_
20 
21 #include "gazebo/gui/qt.h"
22 #include "gazebo/util/system.hh"
23 
24 namespace gazebo
25 {
26  namespace gui
27  {
28  class EditorItem;
29 
32 
36  : public EditorItem, public QGraphicsLineItem
37  {
41  public: LineSegmentItem(QGraphicsItem *_parent = 0, int _index = 0);
42 
44  public: ~LineSegmentItem();
45 
49  public: void SetLine(const QPointF &_start, const QPointF &_end);
50 
53  public: void SetStartPoint(const QPointF &_start);
54 
57  public: void SetEndPoint(const QPointF &_end);
58 
61  public: int GetIndex() const;
62 
63  // Documentation Inherited
64  public: QVector3D GetSize() const;
65 
66  // Documentation Inherited
67  public: QVector3D GetScenePosition() const;
68 
69  // Documentation Inherited
70  public: double GetSceneRotation() const;
71 
74  public: void SetMouseState(int _state);
75 
77  public: int GetMouseState() const;
78 
81  public: double GetMouseDownX() const;
82 
85  public: double GetMouseDownY() const;
86 
89  public: void SetMouseDownX(double _x);
90 
93  public: void SetMouseDownY(double _y);
94 
96  public: void Update();
97 
101  private: QVariant itemChange(GraphicsItemChange _change,
102  const QVariant &_value);
103 
106  private: void hoverEnterEvent(QGraphicsSceneHoverEvent *_event);
107 
110  private: void hoverMoveEvent(QGraphicsSceneHoverEvent *_event);
111 
114  private: void hoverLeaveEvent(QGraphicsSceneHoverEvent *_event);
115 
118  private: void mouseMoveEvent(QGraphicsSceneMouseEvent *_event);
119 
122  private: void mousePressEvent(QGraphicsSceneMouseEvent *_event);
123 
126  private: void mouseReleaseEvent(QGraphicsSceneMouseEvent *_event);
127 
130  private: void mousePressEvent(QGraphicsSceneDragDropEvent *_event);
131 
134  private: void mouseMoveEvent(QGraphicsSceneDragDropEvent *_event);
135 
140  private: void paint(QPainter *_painter,
141  const QStyleOptionGraphicsItem *_option, QWidget *_widget);
142 
144  private: void LineChanged();
145 
147  private: int index;
148 
150  private: QPointF start;
151 
153  private: QPointF end;
154 
156  private: int mouseButtonState;
157 
159  private: double mouseDownX;
160 
162  private: double mouseDownY;
163  };
165  }
166 }
167 
168 #endif
Base class of an item in the editor.
Definition: EditorItem.hh:34
2D line segment.
Definition: LineSegmentItem.hh:35
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48