CShapeBase.h
Go to the documentation of this file.
1 #ifndef iview_CShapeBase_included
2 #define iview_CShapeBase_included
3 
4 
5 // ACF includes
8 #include <iview/IShape.h>
9 #include <iview/IDisplay.h>
10 #include <iview/CScreenTransform.h>
11 
12 namespace iview
13 {
14 
15 
16 class IColorSchema;
17 
18 
19 class CShapeBase:
21  virtual public IShape
22 {
23 public:
25 
30  {
35 
40 
45  };
46 
47  CShapeBase();
48  CShapeBase(const CShapeBase& shape);
49  virtual ~CShapeBase();
50 
55  virtual bool AssignToLayer(int layerType);
56 
57  virtual void Invalidate();
58 
63 
69 
75 
76  // reimplemented (iview::IShape)
77  virtual int GetLayerType() const;
78  virtual i2d::CRect GetBoundingBox() const;
79  virtual void SetVisible(bool state = true);
80  virtual const IColorSchema* GetUserColorSchema() const;
81  virtual void SetUserColorSchema(const IColorSchema* schemaPtr);
82  virtual void SetDefaultDescription(const QString& description);
83 
84  // reimplemented (iview::IVisualizable)
85  virtual bool IsVisible() const;
86  virtual bool IsDisplayAccepted(const IDisplay& display) const;
87  virtual void OnConnectDisplay(IDisplay* displayPtr);
88  virtual void OnDisconnectDisplay(IDisplay* displayPtr);
89  virtual bool OnDisplayChange(const istd::IChangeable::ChangeSet& changeSet);
90 
91  // reimplemented (iview::ITouchable)
92  virtual ITouchable::TouchState IsTouched(istd::CIndex2d position) const;
93  virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const;
94 
95  // reimplemented (imod::IObserver)
96  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
97  virtual bool OnModelDetached(imod::IModel* modelPtr);
98  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
99 
100 protected:
104  i2d::CVector2d GetScreenPosition(const i2d::CVector2d& logPosition) const;
108  i2d::CVector2d GetLogPosition(const i2d::CVector2d& screenPosition) const;
112  double GetLocalLineWidth(const i2d::CVector2d& screenPosition) const;
113 
118  virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet& changeSet);
119 
126  virtual void InvalidateBoundingBox();
127 
131  bool IsDisplayConnected() const;
132 
137  const IColorSchema& GetColorSchema() const;
138 
143  i2d::CRect GetClientRect() const;
144 
145  bool IsBoundingBoxValid() const;
146 
147  void DisconnectDisplay();
148 
149  virtual const iview::CScreenTransform& GetViewToScreenTransform() const;
150 
151  // abstract methods
156  virtual i2d::CRect CalcBoundingBox() const = 0;
157 
158 private:
163  class CalibrationObserver: public imod::TSingleModelObserverBase<i2d::ICalibration2d>
164  {
165  public:
166  explicit CalibrationObserver(CShapeBase* parentPtr);
167 
168  // reimplemented (imod::CSingleModelObserverBase)
169  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
170 
171  private:
172  CShapeBase* m_parentPtr;
173  };
174 
175  IDisplay* m_displayPtr;
176 
177  // calibration management
178  CalibrationObserver m_calibrationObserver;
179 
180  // display meta information
181  const IColorSchema* m_userColorSchemaPtr;
182 
183  // managemant of bounding box
184  mutable bool m_isBoundingBoxValid;
185  mutable i2d::CRect m_boundingBox;
186 
187  // attributes
188  bool m_isVisible;
189  int m_layerType;
190  ShapeTransformMode m_shapeTransformMode;
191 
192  QString m_defaultDescription;
193 };
194 
195 
196 } // namespace iview
197 
198 
199 #endif // !iview_CShapeBase_included
200 
201 
Basic implementation for a single model observer.
i2d::CRect GetClientRect() const
Get display client rectangle.
View transformation will be ignored, shape transformation will be used.
Definition: CShapeBase.h:39
bool IsDisplayConnected() const
Check if display is connected.
void DisconnectDisplay()
virtual ~CShapeBase()
virtual void SetUserColorSchema(const IColorSchema *schemaPtr)
Set color schema to draw shape.
virtual const iview::CScreenTransform & GetViewToScreenTransform() const
virtual void OnDisconnectDisplay(IDisplay *displayPtr)
Called after display is disconnected.
i2d::CVector2d GetLogPosition(const i2d::CVector2d &screenPosition) const
Get logical position based on screen position.
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
virtual bool AssignToLayer(int layerType)
Assign this shape to same layer.
Basic implementation for a single model observer with binding to concrete data object interface...
virtual void OnConnectDisplay(IDisplay *displayPtr)
Called after display is connected.
Both transformation will be used, shape transformation will be used as local transformation.
Definition: CShapeBase.h:44
void SetTransformMode(ShapeTransformMode mode)
Set shape transformation mode.
virtual void SetVisible(bool state=true)
Make shape to be visible or not.
ShapeTransformMode
Describe how shape tranformation is interpreted.
Definition: CShapeBase.h:29
imod::CSingleModelObserverBase BaseClass
Definition: CShapeBase.h:24
virtual ITouchable::TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
const IColorSchema & GetColorSchema() const
Get color schema for this shape.
virtual bool IsDisplayAccepted(const IDisplay &display) const
Check if this object can be connected to this display.
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
virtual i2d::CRect CalcBoundingBox() const =0
Calculate bounding box.
Common interface for all display console shapes.
Definition: IShape.h:27
virtual void InvalidateBoundingBox()
Invalidate bounding box.
virtual const IColorSchema * GetUserColorSchema() const
Get color schema from view or user defined.
iview::IDisplay * GetDisplayPtr() const
Get access to currently connected display.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
TouchState
Enumeration for possible shape touch states.
Definition: ITouchable.h:24
Shape transformation will be ignored, view transformation will be used.
Definition: CShapeBase.h:34
virtual bool IsVisible() const
Check, if this object is visible.
virtual bool OnModelDetached(imod::IModel *modelPtr)
This call back function will be called, if an observable object is about to be detached.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
virtual i2d::CRect GetBoundingBox() const
Return bounding box in client window coordinates.
Set of change flags (its IDs).
Definition: IChangeable.h:30
Defines set of standard pens, brushes and simple management of unions.
Definition: IColorSchema.h:28
i2d::CVector2d GetScreenPosition(const i2d::CVector2d &logPosition) const
Get screen position based on logical position.
ShapeTransformMode GetTransformMode() const
Get shape transformation mode.
virtual bool OnDisplayChange(const istd::IChangeable::ChangeSet &changeSet)
It informs about changes in display.
virtual void Invalidate()
virtual int GetLayerType() const
Get layer type of this shape object.
bool IsBoundingBoxValid() const
virtual void SetDefaultDescription(const QString &description)
Set default description will be used to display on console.
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
This call back function will be called, if an observable object is about to be attached.
double GetLocalLineWidth(const i2d::CVector2d &screenPosition) const
Get line with (in logical coordinates) for single screen position.
virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const
Get description to shape at specified position.

© 2007-2017 Witold Gantzke and Kirill Lepskiy