CViewLayer.h
Go to the documentation of this file.
1 #ifndef iview_CLayerBase_included
2 #define iview_CLayerBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/QMap>
7 
8 // ACF includes
9 #include <iview/IViewLayer.h>
10 #include <iview/IShape.h>
11 
12 
13 namespace iview
14 {
15 
16 
21 class CViewLayer: virtual public IViewLayer
22 {
23 public:
24  typedef QList<IShape*> Shapes;
25 
26  CViewLayer();
27  virtual ~CViewLayer();
28 
29  Shapes GetAllShapes() const;
30 
31  // reimplemented (iview::IViewLayer)
32  virtual void OnConnectView(IShapeView* viewPtr);
33  virtual void OnDisconnectView(IShapeView* viewPtr);
34  virtual IShapeView* GetViewPtr() const;
35  virtual bool IsShapeConnected(IShape* shapePtr);
36  virtual bool ConnectShape(IShape* shapePtr);
37  virtual int GetShapesCount() const;
38  virtual void UpdateAllShapes(const istd::IChangeable::ChangeSet& changeSet);
39  virtual void DisconnectAllShapes();
40  virtual void DrawShapes(QPainter& drawContext);
41  virtual bool IsVisible() const;
42  virtual void SetVisible(bool state = true);
43 
44  // reimplemented (iview::IDisplay)
45  virtual IDisplay* GetParentDisplayPtr() const;
46  virtual const CScreenTransform& GetTransform() const;
47  virtual i2d::CRect GetBoundingBox() const;
48  virtual i2d::CRect GetClientRect() const;
49  virtual const IColorSchema& GetColorSchema() const;
50  virtual void OnAreaInvalidated(const i2d::CRect& prevArea, const i2d::CRect& newArea);
51 
52  // reimplemented (iview::IShapeObserver)
53  virtual void OnChangeShape(IShape* shapePtr);
54  virtual bool DisconnectShape(IShape* shapePtr);
55 
56  // reimplemented (iview::ITouchable)
57  virtual TouchState IsTouched(istd::CIndex2d position) const;
58  virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const;
59 
60 protected:
61  typedef QMap<IShape*, i2d::CRect> ShapeMap;
62 
67  bool OnChangeShapeElement(ShapeMap::Iterator elementIter);
68 
73  void DisconnectShapeElement(ShapeMap& map, ShapeMap::iterator iter);
74 
75  void InvalidateBoundingBox();
77  void SetBoundingBoxValid() const;
78 
86  virtual i2d::CRect CalcBoundingBox() const;
87 
89 
90 private:
91  IShapeView* m_viewPtr;
92  bool m_isVisible;
93 
94  mutable i2d::CRect m_boundingBox;
95  mutable bool m_isBoundingBoxValid;
96 };
97 
98 
99 // inline methods
100 
101 inline bool CViewLayer::IsVisible() const
102 {
103  return m_isVisible;
104 }
105 
106 
107 } // namespace iview
108 
109 
110 #endif // !iview_CLayerBase_included
111 
112 
Interface for a logical layer in the console view.
Definition: IViewLayer.h:24
virtual IDisplay * GetParentDisplayPtr() const
Get parent object of this display.
virtual void UpdateAllShapes(const istd::IChangeable::ChangeSet &changeSet)
Send update to all shapes after view changes.
bool OnChangeShapeElement(ShapeMap::Iterator elementIter)
QMap< IShape *, i2d::CRect > ShapeMap
Definition: CViewLayer.h:61
virtual void OnDisconnectView(IShapeView *viewPtr)
Called before layer is disconnected from view.
virtual void DisconnectAllShapes()
Disconnect all shapes from this layer.
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
Common interface for a general shape view implementations.
Definition: IShapeView.h:24
virtual TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
i2d::CRect & GetBoundingBoxRef() const
virtual const IColorSchema & GetColorSchema() const
Get color schema.
Shapes GetAllShapes() const
virtual void OnChangeShape(IShape *shapePtr)
Invalidate a shape.
ShapeMap m_shapes
Definition: CViewLayer.h:88
void SetBoundingBoxValid() const
virtual bool IsShapeConnected(IShape *shapePtr)
Check, if the shape is connected to the layer.
Common interface for all display console shapes.
Definition: IShape.h:27
virtual void OnConnectView(IShapeView *viewPtr)
Called after layer is connected to view.
virtual i2d::CRect GetBoundingBox() const
Get bounding box of all object in this display.
virtual bool ConnectShape(IShape *shapePtr)
Connect shape object to view.
virtual i2d::CRect GetClientRect() const
Get bounding box of client area.
virtual const CScreenTransform & GetTransform() const
Return a screen transformation.
TouchState
Enumeration for possible shape touch states.
Definition: ITouchable.h:24
virtual bool IsVisible() const
Check, if this layer is visible.
Definition: CViewLayer.h:101
virtual i2d::CRect RecalcAllShapes(const istd::IChangeable::ChangeSet &changeSet)
Recalculate all shapes after view changes.
virtual int GetShapesCount() const
Get count of all shapes on this layer.
virtual void DrawShapes(QPainter &drawContext)
Draw all shapes using specified draw context.
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual void OnAreaInvalidated(const i2d::CRect &prevArea, const i2d::CRect &newArea)
Invalidate display area.
Defines set of standard pens, brushes and simple management of unions.
Definition: IColorSchema.h:28
virtual void SetVisible(bool state=true)
Make this layer visible.
QList< IShape * > Shapes
Definition: CViewLayer.h:24
void DisconnectShapeElement(ShapeMap &map, ShapeMap::iterator iter)
virtual bool DisconnectShape(IShape *shapePtr)
Disconnect shape object from view.
void InvalidateBoundingBox()
virtual ~CViewLayer()
virtual i2d::CRect CalcBoundingBox() const
Calculate bounding box for all shapes.
Standard implementation of view layer.
Definition: CViewLayer.h:21
virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const
Get description to shape at specified position.
virtual IShapeView * GetViewPtr() const
Get parent view of this layer.

© 2007-2017 Witold Gantzke and Kirill Lepskiy