OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
GraphicsItemDesignerItemBase.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OToolkit header
10
11// OpenTwin header
15
16// Qt header
17#include <QtCore/qlist.h>
18#include <QtCore/qpoint.h>
19
20namespace ot {
21 class GraphicsItem;
22 class GraphicsItemCfg;
23}
24
27public:
28 enum class DesignerItemFlag {
31 };
33
36
38 void addControlPoint(const QPointF& _pt);
39
41 void setControlPoints(const QList<QPointF>& _points);
42
45 void updateControlPoints(const QList<QPointF>& _points) { m_controlPoints = _points; };
46
48 const QList<QPointF>& getControlPoints(void) const { return m_controlPoints; };
49
52 void setLastPos(const QPointF& _pos) { m_lastPos = _pos; };
53
57 const QPointF& getLastPos(void) const { return m_lastPos; };
58
59 void setDesignerItemFlag(DesignerItemFlag _flag, bool _active = true) { m_designerItemFlags.setFlag(_flag, _active); };
60 void setDesignerItemFlags(const DesignerItemFlags& _flags) { m_designerItemFlags = _flags; };
61 const DesignerItemFlags& getDesignerItemFlags(void) const { return m_designerItemFlags; };
62
66 void graphicsItemWasMoved(const QPointF& _newPos);
67
68 // ###########################################################################################################################################################################################################################################################################################################################
69
70 // Virtual methods
71
74 virtual bool isDesignedItemCompleted(void) const = 0;
75
79 virtual bool isDesignedItemValid(void) const = 0;
80
83
85 virtual QString getDefaultItemName(void) const = 0;
86
89
91 virtual void makeItemTransparent(void) {};
92
93 virtual void setupDesignerItemFromConfig(const ot::GraphicsItemCfg* _config) = 0;
94
95 // ###########################################################################################################################################################################################################################################################################################################################
96
97 // Protected base class methods
98
99protected:
101 virtual void controlPointsChanged(void) = 0;
102
104 virtual void fillPropertyGrid(void) override = 0;
105
106 virtual void propertyChanged(const ot::Property* _property) override = 0;
107 virtual void propertyDeleteRequested(const ot::Property* _property) override = 0;
108
109 void initializeBaseData(const QList<QPointF>& _controlPoints, const QPointF& _pos);
110
114
117 bool basePropertyChanged(const ot::Property* _property);
118
121 bool basePropertyDeleteRequested(const ot::Property* _property);
122
123private:
124 QPointF m_lastPos;
125 QList<QPointF> m_controlPoints;
126 DesignerItemFlags m_designerItemFlags;
127
128};
129
#define OT_ADD_FLAG_FUNCTIONS(___enumName)
Will add the default bitwise operations for the provided private 32/64 bit bitfield....
Definition Flags.h:129
This file contains defines that may be used simplyfy class creation.
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
Definition GraphicsItemDesignerItemBase.h:25
bool basePropertyDeleteRequested(const ot::Property *_property)
Handles base properties. Returns true if the requested property was handled.
Definition GraphicsItemDesignerItemBase.cpp:290
virtual ~GraphicsItemDesignerItemBase()
Definition GraphicsItemDesignerItemBase.cpp:19
virtual void setupDesignerItemFromConfig(const ot::GraphicsItemCfg *_config)=0
virtual void fillPropertyGrid(void) override=0
Is called when the property grid needs to be filled.
void setLastPos(const QPointF &_pos)
Sets the last position.
Definition GraphicsItemDesignerItemBase.h:52
virtual ot::TreeWidgetItemInfo createNavigationInformation(void)=0
Creates the navigation information for this item and its childs.
const QList< QPointF > & getControlPoints(void) const
Returns a list containing the currently set control points.
Definition GraphicsItemDesignerItemBase.h:48
void setDesignerItemFlag(DesignerItemFlag _flag, bool _active=true)
Definition GraphicsItemDesignerItemBase.h:59
virtual void propertyDeleteRequested(const ot::Property *_property) override=0
void updateControlPoints(const QList< QPointF > &_points)
Replaces the current list of control points. This method does not call controlPointsChanged().
Definition GraphicsItemDesignerItemBase.h:45
virtual QString getDefaultItemName(void) const =0
Returns the default item name.
void initializeBaseData(const QList< QPointF > &_controlPoints, const QPointF &_pos)
Definition GraphicsItemDesignerItemBase.cpp:51
GraphicsItemDesignerItemBase()
Definition GraphicsItemDesignerItemBase.cpp:13
virtual bool isDesignedItemValid(void) const =0
Returns true if the current item is valid. A valid item has all required control points set (e....
virtual void propertyChanged(const ot::Property *_property) override=0
bool basePropertyChanged(const ot::Property *_property)
Handles base properties. Returns true if the changed property was handled.
Definition GraphicsItemDesignerItemBase.cpp:113
virtual void makeItemTransparent(void)
Will make the item transparent.
Definition GraphicsItemDesignerItemBase.h:91
void setControlPoints(const QList< QPointF > &_points)
Sets the current list of control points and calls controlPointsChanged().
Definition GraphicsItemDesignerItemBase.cpp:28
virtual ot::GraphicsItem * getGraphicsItem(void)=0
Returns the actual GraphicsItem.
void fillBasePropertyGrid(ot::PropertyGridCfg &_config)
Adds the default properties. Creates the "General" and "Transform" groups.
Definition GraphicsItemDesignerItemBase.cpp:56
const DesignerItemFlags & getDesignerItemFlags(void) const
Definition GraphicsItemDesignerItemBase.h:61
ot::Flags< DesignerItemFlag > DesignerItemFlags
Definition GraphicsItemDesignerItemBase.h:32
void addControlPoint(const QPointF &_pt)
\breif Adds the provided control point and calls controlPointsChanged().
Definition GraphicsItemDesignerItemBase.cpp:23
DesignerItemFlag
Definition GraphicsItemDesignerItemBase.h:28
virtual void controlPointsChanged(void)=0
Is called whenever the control points have changed (except when calling updateControlPoints()).
virtual bool isDesignedItemCompleted(void) const =0
Returns true if the current item is completed. A completed item has all required control points set (...
void setDesignerItemFlags(const DesignerItemFlags &_flags)
Definition GraphicsItemDesignerItemBase.h:60
void graphicsItemWasMoved(const QPointF &_newPos)
Will move all control points by the move delta (lastPos - newPos). The method will set the last pos a...
Definition GraphicsItemDesignerItemBase.cpp:33
const QPointF & getLastPos(void) const
Returns the last position. The last position ist the last position of this graphics item....
Definition GraphicsItemDesignerItemBase.h:57
The GraphicsItemDesignerPropertyHandler is used to receive property grid notifications and requests.
Definition GraphicsItemDesignerPropertyHandler.h:39
The Flags class is a wrapper around a enum that allows bitwise operations (flags)....
Definition Flags.h:214
void setFlag(T _flag)
Set the provided flag.
Definition Flags.h:257
The GraphicsItemCfg is the base class for all graphics item configurations.
Definition GraphicsItemCfg.h:33
Base class for all OpenTwin GraphicsItems GraphicsItems should be created by the GraphicsFactory and ...
Definition GraphicsItem.h:35
Definition PropertyGridCfg.h:21
The Property class is used as a base class for all Properties that can be displayed and modified in t...
Definition Property.h:21
Definition TreeWidgetItemInfo.h:17
Definition Connector.h:8