ConnectorGraphicsItem.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/ConnectorGraphicsItem.h
22 
23  \brief A GraphicItem to represents connector between two Tasks parameters (hot points).
24 */
25 
26 #ifndef __TERRALIB_PROCESS_QT_INTERNAL_CONNECTORGRAPHICSITEM_H
27 #define __TERRALIB_PROCESS_QT_INTERNAL_CONNECTORGRAPHICSITEM_H
28 
29 #include "../../Config.h"
30 
31 // Qt Includes
32 #include <QColor>
33 #include <QGraphicsObject>
34 #include <QPointF>
35 
36 namespace te
37 {
38  namespace process
39  {
40  namespace qt
41  {
42  class HotPointGraphicsItem;
43  class TaskGraphicsItem;
44 
45  /*!
46  \class ConnectorGraphicsItem
47 
48  \brief A GraphicItem to represents connector between two Tasks parameters (hot points).
49 
50  */
51  class TEPROCESSEXPORT ConnectorGraphicsItem : public QGraphicsObject
52  {
53  public:
54 
55  /*!
56  \brief Default constructor.
57 
58  \param taskFrom QGraophicsItem that represents FROM task
59 
60  \param hotPointFrom QGraphicsItem that represents FROM hotpoint
61 
62  \param taskTo QGraophicsItem that represents TO task
63 
64  \param hotPointTo QGraphicsItem that represents TO hotpoint
65  */
66  ConnectorGraphicsItem(const std::string& connectorId, TaskGraphicsItem* taskFrom, HotPointGraphicsItem* hotPointFrom, TaskGraphicsItem* taskTo, HotPointGraphicsItem* hotPointTo);
67 
68  /*! \brief Virtual destructor. */
70 
71  /*! \brief Get function to access connector internal pointer. */
72  const std::string getConnectorId() const;
73 
74  /*! \brief Get function to notify that the connector was removed. */
75  void removed();
76 
77  public:
78 
79  /*!
80  \brief Virtual function that defines the outer bounds of the item as a rectangle.
81 
82  \return QRectF for this item.
83  */
84  virtual QRectF boundingRect() const;
85 
86  /*!
87  \brief Function used to draw the process item.
88 
89  \param painter Qt Painter used to draw the process item.
90 
91  \param option Qt style options used to draw the process item.
92  */
93  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr);
94 
95  protected:
96 
97  /*!
98  \brief Function used to get the hot points position in scene coordinate and create a QPainterPath
99 
100  \return a valid QPainterPath if connector hotpoints was defined
101  */
102  QPainterPath getConnectorPainterPath() const;
103 
104  QPainterPath getConnectorArrowPainterPath() const;
105 
106  protected:
107 
108  std::string m_connectorId; //!< TerraLib connector object id
109 
110  TaskGraphicsItem* m_taskFrom; //!< QGraphicsItem that represents FROM Task
111  HotPointGraphicsItem* m_hotPointFrom; //!< QGraphicsItem that represents FROM HotPoint
112 
113  TaskGraphicsItem* m_taskTo; //!< QGraphicsItem that represents TO Task
114  HotPointGraphicsItem* m_hotPointTo; //!< QGraphicsItem that represents TO HotPoint
115  };
116  }
117  }
118 }
119 
120 #endif // __TERRALIB_PROCESS_QT_INTERNAL_CONNECTORGRAPHICSITEM_H
A GraphicItem to represents connector between two Tasks parameters (hot points).
TaskGraphicsItem * m_taskFrom
QGraphicsItem that represents FROM Task.
ConnectorGraphicsItem(const std::string &connectorId, TaskGraphicsItem *taskFrom, HotPointGraphicsItem *hotPointFrom, TaskGraphicsItem *taskTo, HotPointGraphicsItem *hotPointTo)
Default constructor.
void removed()
Get function to notify that the connector was removed.
virtual QRectF boundingRect() const
Virtual function that defines the outer bounds of the item as a rectangle.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)
Function used to draw the process item.
HotPointGraphicsItem * m_hotPointFrom
QGraphicsItem that represents FROM HotPoint.
QPainterPath getConnectorPainterPath() const
Function used to get the hot points position in scene coordinate and create a QPainterPath.
HotPointGraphicsItem * m_hotPointTo
QGraphicsItem that represents TO HotPoint.
std::string m_connectorId
TerraLib connector object id.
QPainterPath getConnectorArrowPainterPath() const
~ConnectorGraphicsItem()
Virtual destructor.
TaskGraphicsItem * m_taskTo
QGraphicsItem that represents TO Task.
const std::string getConnectorId() const
Get function to access connector internal pointer.
A GraphicItem to represents Task parameters as hot point.
A GraphicItem to represents a Task Process Builder item.
TerraLib.
#define TEPROCESSEXPORT
Definition: Config.h:47