CGraphicsConnectorItem.h
Go to the documentation of this file.
1 #ifndef icmpstr_CGraphicsConnectorItem_included
2 #define icmpstr_CGraphicsConnectorItem_included
3 
4 
5 // Qt includes
6 #include <QtCore/QObject>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QGraphicsItem>
9 #else
10 #include <QtGui/QGraphicsItem>
11 #endif
12 
13 // ACF-Solutions includes
14 #include "icmpstr/ISceneProvider.h"
15 
16 
17 namespace icmpstr
18 {
19 
20 
21 class CComponentSceneItem;
22 class CRegistryElementShape;
23 
24 
26  public QObject,
27  public QGraphicsItem
28 {
29  Q_OBJECT
30 
31 public:
32  typedef QGraphicsItem BaseClass;
33 
35  {
36  CF_FACTORY = 0x0001,
37  CF_EMBEDDED =0x0002
38  };
39 
41  {
42  GP_RADIUS = 4,
44  GP_OFFSET = 12
45  };
46 
48  const icmpstr::ISceneProvider& sceneProvider,
49  int connectFlags = 0,
50  QGraphicsItem* parent = NULL);
51 
52  void InitEnds(CRegistryElementShape* sourceShapePtr, CRegistryElementShape* destShapePtr);
53 
54  // reimplemented (QGraphicsItem)
55  virtual int type() const;
56  virtual QPainterPath shape() const;
57  virtual bool contains(const QPointF& point) const;
58 
59 protected:
60  void Adjust();
61 
62  // reimplemented (QGraphicsItem)
63  virtual QRectF boundingRect() const;
64  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
65 
66 protected Q_SLOTS:
67  void OnSourceRectMoved(const QRectF& rect);
68  void OnDestRectMoved(const QRectF& rect);
69  void OnSourceSelected(bool state);
70  void OnDestSelected(bool state);
71 
72 private:
73  const icmpstr::ISceneProvider& m_sceneProvider;
74 
75  int m_connectFlags;
76 
77  QPolygonF m_connectionLine;
78  QPointF m_touchPoint;
79 
80  QRectF m_sourceRect;
81  QRectF m_destRect;
82  bool m_isSourceSelected;
83  bool m_isDestSelected;
84 };
85 
86 
87 } // namespace icmpstr
88 
89 
90 #endif // !icmpstr_CGraphicsConnectorItem_included
91 
92 
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
virtual QPainterPath shape() const
virtual bool contains(const QPointF &point) const
virtual int type() const
void OnDestRectMoved(const QRectF &rect)
Interface for GUI objects managing scene.
Visualization of geometrical registry elements.
void InitEnds(CRegistryElementShape *sourceShapePtr, CRegistryElementShape *destShapePtr)
virtual QRectF boundingRect() const
void OnSourceRectMoved(const QRectF &rect)
CGraphicsConnectorItem(const icmpstr::ISceneProvider &sceneProvider, int connectFlags=0, QGraphicsItem *parent=NULL)
void OnSourceSelected(bool state)

© 2007-2011 Witold Gantzke and Kirill Lepskiy