AbstractGraphicsItem.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20  /*!
21  \file terralib/process/qt/AbstractGraphicsItem.h
22 
23  \brief An Abstract graphicItem to represents a process Builder item.
24  */
25 
26 #ifndef __TERRALIB_PROCESS_QT_INTERNAL_ABSTRACTGRAPHICSITEM_H
27 #define __TERRALIB_PROCESS_QT_INTERNAL_ABSTRACTGRAPHICSITEM_H
28 
29 #include "../../Config.h"
30 
31 #include "HotPointGraphicsItem.h"
32 
33  // Qt Includes
34 #include <QBrush>
35 #include <QFont>
36 #include <QGraphicsObject>
37 #include <QPainterPath>
38 #include <QPen>
39 
40 namespace te
41 {
42  namespace process
43  {
44  namespace qt
45  {
46  /*!
47  \class AbstractGraphicsItem
48 
49  \brief An Abstract graphicItem to represents a process Builder item.
50 
51  */
52  class TEPROCESSEXPORT AbstractGraphicsItem : public QGraphicsObject
53  {
54  public:
55 
56  /*! \brief Default constructor. */
58 
59  /*! \brief Virtual destructor. */
61 
62  protected:
63 
64  /*!
65  \brief Virtual function used to notify when user clicks over a hotpoint.
66 
67  \param hotpoint Pointer to the hotpoint pressed.
68  */
69  virtual void hotPointPressed(HotPointGraphicsItem* hotpoint) = 0;
70 
71  protected:
72 
73  /*!
74  \brief Virtual function that defines the outer bounds of the item as a rectangle.
75 
76  \return QRectF for this item.
77  */
78  virtual QRectF boundingRect() const = 0;
79 
80  /*!
81  \brief Function used to draw the process item.
82 
83  \param painter Qt Painter used to draw the process item.
84 
85  \param option Qt style options used to draw the process item.
86  */
87  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr);
88 
89  /*!
90  \brief Receive hover enter events for this item. The default implementation calls update().
91 
92  \param event Qt event.
93  */
94  void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
95 
96  /*!
97  \brief Receive hover move events for this item. The default implementation does nothing.
98 
99  \param event Qt event.
100  */
101  void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
102 
103  /*!
104  \brief Receive hover leave events for this item. The default implementation calls update().
105 
106  \param event Qt event.
107  */
108  void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
109 
110  /*!
111  \brief Receive mouse press events for this item.
112 
113  \param event Qt event.
114  */
115  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
116 
117  /*!
118  \brief Receive mouse move events for this item.
119 
120  \param event Qt event.
121  */
122  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
123 
124  /*!
125  \brief Receive mouse release events for this item.
126 
127  \param event Qt event.
128  */
129  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
130 
131  public:
132 
133  QPen getPen();
134 
135  QBrush getBrush();
136 
137  QFont getFont();
138 
139  void setPenColor(QColor color);
140 
141  void setPenWidth(int width);
142 
143  void setPenStyle(Qt::PenStyle style);
144 
145  void setBrushColor(QColor color);
146 
147  void setBrushStyle(Qt::BrushStyle style);
148 
149  void setFont(QFont font);
150 
151  protected:
152 
153  /*!
154  \brief Function used to get hotpoint given a item position.
155 
156  \Return Pointer to the hotpoint if in this position has a hotpoint and nullptr in other case.
157  */
158  HotPointGraphicsItem* getHotPoint(const QPointF& pos);
159 
160  protected:
161 
162  QPainterPath m_path; //!< Paintr path that represents this item.
163 
164  std::vector<HotPointGraphicsItem*> m_hotPoints; //!< List of all hotpoints for this item.
165 
166  bool m_drawHotPoints; //!< Flag used to indicate if the hot points has to be painted.
167 
168  protected:
169 
170  QPen m_pen;
171  QBrush m_brush;
172  QFont m_font;
173  };
174  }
175  }
176 }
177 
178 #endif // __TERRALIB_PROCESS_QT_INTERNAL_PROCESSSQUAREGRAPHICSITEM_H
An Abstract graphicItem to represents a process Builder item.
void setPenStyle(Qt::PenStyle style)
void setBrushStyle(Qt::BrushStyle style)
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Receive mouse press events for this item.
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
Receive hover move events for this item. The default implementation does nothing.
virtual ~AbstractGraphicsItem()
Virtual destructor.
QPainterPath m_path
Paintr path that represents this item.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)
Function used to draw the process item.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Receive mouse release events for this item.
virtual QRectF boundingRect() const =0
Virtual function that defines the outer bounds of the item as a rectangle.
virtual void hotPointPressed(HotPointGraphicsItem *hotpoint)=0
Virtual function used to notify when user clicks over a hotpoint.
AbstractGraphicsItem()
Default constructor.
std::vector< HotPointGraphicsItem * > m_hotPoints
List of all hotpoints for this item.
HotPointGraphicsItem * getHotPoint(const QPointF &pos)
Function used to get hotpoint given a item position.
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
Receive hover leave events for this item. The default implementation calls update().
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Receive mouse move events for this item.
bool m_drawHotPoints
Flag used to indicate if the hot points has to be painted.
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
Receive hover enter events for this item. The default implementation calls update().
A GraphicItem to represents Task parameters as hot point.
TerraLib.
#define TEPROCESSEXPORT
Definition: Config.h:47