OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::GraphicsItemCfg Class Referenceabstract

The GraphicsItemCfg is the base class for all graphics item configurations. More...

#include "GraphicsItemCfg.h"

Inheritance diagram for ot::GraphicsItemCfg:
ot::Serializable ot::GraphicsArcItemCfg ot::GraphicsEllipseItemCfg ot::GraphicsGroupItemCfg ot::GraphicsImageItemCfg ot::GraphicsInvisibleItemCfg ot::GraphicsItemFileCfg ot::GraphicsLayoutItemCfg ot::GraphicsLineItemCfg ot::GraphicsPolygonItemCfg ot::GraphicsRectangularItemCfg ot::GraphicsShapeItemCfg ot::GraphicsStackItemCfg ot::GraphicsTextItemCfg ot::GraphicsTriangleItemCfg

Public Types

enum  GraphicsItemFlag {
  NoFlags = 0x0000 , ItemIsMoveable = 0x0001 , ItemIsSelectable = 0x0002 , ItemIsConnectable = 0x0004 ,
  ItemSnapsToGridTopLeft = 0x0010 , ItemSnapsToGridCenter = 0x0020 , ItemForwardsTooltip = 0x0100 , ItemUserTransformEnabled = 0x0200 ,
  ItemIgnoresParentTransform = 0x0400 , ItemHandlesState = 0x1000 , ItemForwardsState = 0x2000
}
 GraphicsItemFlag. More...
 
typedef Flags< GraphicsItemFlagGraphicsItemFlags
 

Public Member Functions

 GraphicsItemCfg ()
 GraphicsItemFlags.
 
virtual ~GraphicsItemCfg ()
 
virtual std::string getFactoryKey (void) const =0
 Returns the unique GraphicsItemCfg type name that is used in the GraphicsItemCfgFactory.
 
virtual GraphicsItemCfgcreateCopy (void) const =0
 Creates a copy of this item.
 
virtual void addToJsonObject (JsonValue &_object, JsonAllocator &_allocator) const override
 Add the object contents to the provided JSON object.
 
virtual void setFromJsonObject (const ConstJsonObject &_object) override
 Will set the object contents from the provided JSON object.
 
void setName (const std::string &_name)
 Set item name.
 
const std::string & getName (void) const
 Item name.
 
void setTitle (const std::string &_title)
 Set item title The item title will be displayed to the user when needed.
 
const std::string & getTitle (void) const
 Item title The item title will be displayed to the user when needed.
 
void setToolTip (const std::string &_toolTip)
 Set ToolTip.
 
const std::string & getToolTip (void) const
 ToolTip that will be displayed to the user when he hovers over the item. If the root item in a graphics item hierarchy has a tool tip set, child items may be enabled to forward the tooltip request (see GraphicsItemFlags)
 
void setPosition (double _x, double _y)
 Set item position If the item is the root item, the position is the scene position. If the item is a child item, the position is the local position (default: 0.0; 0.0).
 
void setPosition (const Point2DD &_pos)
 Set item position If the item is the root item, the position is the scene position. If the item is a child item, the position is the local position (default: 0.0; 0.0).
 
const Point2DDgetPosition (void) const
 Item position If the item is the root item, the position is the scene position. If the item is a child item, the position is the local position (default: 0.0; 0.0).
 
void setAdditionalTriggerDistance (double _d)
 
void setAdditionalTriggerDistance (double _left, double _top, double _right, double _bottom)
 
void setAdditionalTriggerDistance (const MarginsD &_d)
 Sets the additional trigger distance. The additional trigger distance will expand/shrink the imaginary bounding rect of the item when checking for mouse press, mouse hover, and other events.
 
const MarginsDgetAdditionalTriggerDistance (void) const
 
void setMinimumSize (double _width, double _height)
 Sets the item minimum size.
 
void setMinimumSize (const Size2DD &_size)
 Sets the item minimum size.
 
const Size2DDgetMinimumSize (void) const
 Item minimum size. If the graphics item is resized (e.g. via layout) then it may not shrink below the minimum size.
 
void setMaximumSize (double _width, double _height)
 Sets the item maximum size.
 
void setMaximumSize (const Size2DD &_size)
 Sets the item maximum size.
 
const Size2DDgetMaximumSize (void) const
 Item maximum size. If the graphics item is resized (e.g. via layout) then it may not brow above the maximum size.
 
void setFixedSize (double _width, double _height)
 Sets the items minimum and maximum size.
 
void setFixedSize (const Size2DD &_size)
 Sets the items minimum and maximum size.
 
void setMargins (double _left, double _top, double _right, double _bottom)
 Set item margins.
 
void setMargins (const MarginsD &_margins)
 Set item margins.
 
const MarginsDgetMargins (void) const
 Item margins.
 
void setGraphicsItemFlag (GraphicsItemFlag _flag, bool _active=true)
 
void setGraphicsItemFlags (const GraphicsItemFlags &_flags)
 
const GraphicsItemFlagsgetGraphicsItemFlags (void) const
 
void setAlignment (Alignment _align)
 Set the item alignment.
 
Alignment getAlignment (void) const
 Current item alignment. The alignment only has an effect if the item is nested.
 
void setUid (const UID &_uid)
 Set item UID.
 
const ot::UIDgetUid (void) const
 Item UID. The item UID is used to uniquely identify an item in a GraphicsScene. The must never exist two items with the same UID.
 
void setSizePolicy (SizePolicy _policy)
 Set item size policy.
 
SizePolicy getSizePolicy (void) const
 Current item size policy. The item size policy is used for nested items.
 
void setConnectionDirection (ConnectionDirection _direction)
 Set the item connection direction.
 
ConnectionDirection getConnectionDirection (void) const
 Current item connection direction. This has only an effect if GraphicsItemFlag::ItemIsConnectable is set.
 
void addStringMapEntry (const std::string &_key, const std::string &_value)
 Adds the provided entry to the string map. If an entry for the same key already exists it will be replaced.
 
void setStringMap (const std::map< std::string, std::string > &_map)
 Sets the string map.
 
const std::map< std::string, std::string > & getStringMap (void) const
 The string map may be used to reference a value via a key in a complex graphics item. For example a text item with enabled reference mode will use the string map to set its text when created in the frontend.
 
std::string getStringForKey (const std::string &_key) const
 Returns the string set for the given key in the string map. Returns the string "#<_key>" if the value was not found.
 
void setTransform (const Transform &_transform)
 Set the item transform.
 
const TransformgetTransform (void) const
 Get the item transform.
 
virtual void copyConfigDataToItem (GraphicsItemCfg *_target) const
 Will copy the current config to the provided item configuration. This method may be called when creating a graphics item copy.
 
- Public Member Functions inherited from ot::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
virtual void addToJsonObject (ot::JsonValue &_object, ot::JsonAllocator &_allocator) const =0
 Add the object contents to the provided JSON object.
 

Detailed Description

The GraphicsItemCfg is the base class for all graphics item configurations.

Member Typedef Documentation

◆ GraphicsItemFlags

Member Enumeration Documentation

◆ GraphicsItemFlag

GraphicsItemFlag.

Enumerator
NoFlags 
ItemIsMoveable 

No item flags.

ItemIsSelectable 

Item may be used by the user. If the item has a parent, the item may be moved inside of the parent item.

ItemIsConnectable 
ItemSnapsToGridTopLeft 

Item can be used as source or destination of a conncetion.

ItemSnapsToGridCenter 

Item snaps to grid on the top left corner of the bounding rect.

ItemForwardsTooltip 

Item snaps to grid at the center of the bounding rect (will be ignored if ItemSnapsToGridTopLeft is set).

If the user hovers over this item and no tooltip is set, the tooltip request will be forwarded to the parent item.

Note
If this flag is not set this item also wont forward tooltip requests from child items.
ItemUserTransformEnabled 

User transform and transform shortcuts are enabled for this item. The user can rotate and flip the item by using the shortcuts or actions.

ItemIgnoresParentTransform 

Item transformations to the parent item will not affect this item. If the item is located in a group for example, any transformations to the group won't affect this item. The item will apply the inverse transformation to keep its transformation.

ItemHandlesState 

Item receives state changes. The item will paint its border and/or background differently if the item is selected or is hovered by the user. A StyleRefPainter2D will be used for painting the state.

See also
enum class ot::ColorStyleValueEntry
ItemForwardsState 

Item forwards state changes to child items. If the root item is a container item (e.g. GraphicsGroupItem) it have this flag set in order to forward the state change to its child items.

Constructor & Destructor Documentation

◆ GraphicsItemCfg()

ot::GraphicsItemCfg::GraphicsItemCfg ( )

GraphicsItemFlags.

◆ ~GraphicsItemCfg()

ot::GraphicsItemCfg::~GraphicsItemCfg ( )
virtual

Member Function Documentation

◆ addStringMapEntry()

void ot::GraphicsItemCfg::addStringMapEntry ( const std::string & _key,
const std::string & _value )
inline

Adds the provided entry to the string map. If an entry for the same key already exists it will be replaced.

See also
getStringMap

◆ addToJsonObject()

void ot::GraphicsItemCfg::addToJsonObject ( JsonValue & _object,
JsonAllocator & _allocator ) const
overridevirtual

◆ copyConfigDataToItem()

void ot::GraphicsItemCfg::copyConfigDataToItem ( GraphicsItemCfg * _target) const
virtual

Will copy the current config to the provided item configuration. This method may be called when creating a graphics item copy.

Parameters
_targetItem to copy the data to.

◆ createCopy()

◆ getAdditionalTriggerDistance()

const MarginsD & ot::GraphicsItemCfg::getAdditionalTriggerDistance ( void ) const
inline

◆ getAlignment()

Alignment ot::GraphicsItemCfg::getAlignment ( void ) const
inline

Current item alignment. The alignment only has an effect if the item is nested.

◆ getConnectionDirection()

ConnectionDirection ot::GraphicsItemCfg::getConnectionDirection ( void ) const
inline

Current item connection direction. This has only an effect if GraphicsItemFlag::ItemIsConnectable is set.

See also
ot::ConnectionDirection

◆ getFactoryKey()

◆ getGraphicsItemFlags()

const GraphicsItemFlags & ot::GraphicsItemCfg::getGraphicsItemFlags ( void ) const
inline

◆ getMargins()

const MarginsD & ot::GraphicsItemCfg::getMargins ( void ) const
inline

Item margins.

◆ getMaximumSize()

const Size2DD & ot::GraphicsItemCfg::getMaximumSize ( void ) const
inline

Item maximum size. If the graphics item is resized (e.g. via layout) then it may not brow above the maximum size.

◆ getMinimumSize()

const Size2DD & ot::GraphicsItemCfg::getMinimumSize ( void ) const
inline

Item minimum size. If the graphics item is resized (e.g. via layout) then it may not shrink below the minimum size.

◆ getName()

const std::string & ot::GraphicsItemCfg::getName ( void ) const
inline

Item name.

◆ getPosition()

const Point2DD & ot::GraphicsItemCfg::getPosition ( void ) const
inline

Item position If the item is the root item, the position is the scene position. If the item is a child item, the position is the local position (default: 0.0; 0.0).

◆ getSizePolicy()

SizePolicy ot::GraphicsItemCfg::getSizePolicy ( void ) const
inline

Current item size policy. The item size policy is used for nested items.

See also
ot::SizePolicy

◆ getStringForKey()

std::string ot::GraphicsItemCfg::getStringForKey ( const std::string & _key) const

Returns the string set for the given key in the string map. Returns the string "#<_key>" if the value was not found.

See also
getStringMap

◆ getStringMap()

const std::map< std::string, std::string > & ot::GraphicsItemCfg::getStringMap ( void ) const
inline

The string map may be used to reference a value via a key in a complex graphics item. For example a text item with enabled reference mode will use the string map to set its text when created in the frontend.

Warning
The string map must be set for the root item only. Child items will be ignored.

◆ getTitle()

const std::string & ot::GraphicsItemCfg::getTitle ( void ) const
inline

Item title The item title will be displayed to the user when needed.

◆ getToolTip()

const std::string & ot::GraphicsItemCfg::getToolTip ( void ) const
inline

ToolTip that will be displayed to the user when he hovers over the item. If the root item in a graphics item hierarchy has a tool tip set, child items may be enabled to forward the tooltip request (see GraphicsItemFlags)

◆ getTransform()

const Transform & ot::GraphicsItemCfg::getTransform ( void ) const
inline

Get the item transform.

◆ getUid()

const ot::UID & ot::GraphicsItemCfg::getUid ( void ) const
inline

Item UID. The item UID is used to uniquely identify an item in a GraphicsScene. The must never exist two items with the same UID.

◆ setAdditionalTriggerDistance() [1/3]

void ot::GraphicsItemCfg::setAdditionalTriggerDistance ( const MarginsD & _d)
inline

Sets the additional trigger distance. The additional trigger distance will expand/shrink the imaginary bounding rect of the item when checking for mouse press, mouse hover, and other events.

◆ setAdditionalTriggerDistance() [2/3]

void ot::GraphicsItemCfg::setAdditionalTriggerDistance ( double _d)
inline
See also
setAdditionalTriggerDistance(const MarginsD& _d)
Parameters
_dDistance in all directions.

◆ setAdditionalTriggerDistance() [3/3]

void ot::GraphicsItemCfg::setAdditionalTriggerDistance ( double _left,
double _top,
double _right,
double _bottom )
inline

◆ setAlignment()

void ot::GraphicsItemCfg::setAlignment ( Alignment _align)
inline

Set the item alignment.

See also
getAlignment.

◆ setConnectionDirection()

void ot::GraphicsItemCfg::setConnectionDirection ( ConnectionDirection _direction)
inline

Set the item connection direction.

See also
getConnectionDirection(void)

◆ setFixedSize() [1/2]

void ot::GraphicsItemCfg::setFixedSize ( const Size2DD & _size)

Sets the items minimum and maximum size.

See also
getMaximumSize
getMinimumSize

◆ setFixedSize() [2/2]

void ot::GraphicsItemCfg::setFixedSize ( double _width,
double _height )
inline

Sets the items minimum and maximum size.

See also
getMaximumSize
getMinimumSize

◆ setFromJsonObject()

void ot::GraphicsItemCfg::setFromJsonObject ( const ConstJsonObject & _object)
overridevirtual

Will set the object contents from the provided JSON object.

Parameters
_objectThe JSON object containing the information
Exceptions
Willthrow an exception if the provided object is not valid (members missing or invalid types)

Implements ot::Serializable.

Reimplemented in ot::GraphicsArcItemCfg, ot::GraphicsBoxLayoutItemCfg, ot::GraphicsEllipseItemCfg, ot::GraphicsGridLayoutItemCfg, ot::GraphicsGroupItemCfg, ot::GraphicsImageItemCfg, ot::GraphicsInvisibleItemCfg, ot::GraphicsItemFileCfg, ot::GraphicsLayoutItemCfg, ot::GraphicsLineItemCfg, ot::GraphicsPolygonItemCfg, ot::GraphicsRectangularItemCfg, ot::GraphicsShapeItemCfg, ot::GraphicsStackItemCfg, ot::GraphicsTextItemCfg, and ot::GraphicsTriangleItemCfg.

◆ setGraphicsItemFlag()

void ot::GraphicsItemCfg::setGraphicsItemFlag ( GraphicsItemFlag _flag,
bool _active = true )
inline

◆ setGraphicsItemFlags()

void ot::GraphicsItemCfg::setGraphicsItemFlags ( const GraphicsItemFlags & _flags)
inline

◆ setMargins() [1/2]

void ot::GraphicsItemCfg::setMargins ( const MarginsD & _margins)
inline

Set item margins.

Parameters
_marginsMargins to set

◆ setMargins() [2/2]

void ot::GraphicsItemCfg::setMargins ( double _left,
double _top,
double _right,
double _bottom )
inline

Set item margins.

Parameters
_topTop margin
_rightRight margin
_bottomBottom margin
_leftLeft margin

◆ setMaximumSize() [1/2]

void ot::GraphicsItemCfg::setMaximumSize ( const Size2DD & _size)
inline

Sets the item maximum size.

See also
getMaximumSize

◆ setMaximumSize() [2/2]

void ot::GraphicsItemCfg::setMaximumSize ( double _width,
double _height )
inline

Sets the item maximum size.

See also
getMaximumSize

◆ setMinimumSize() [1/2]

void ot::GraphicsItemCfg::setMinimumSize ( const Size2DD & _size)
inline

Sets the item minimum size.

See also
getMinimumSize

◆ setMinimumSize() [2/2]

void ot::GraphicsItemCfg::setMinimumSize ( double _width,
double _height )
inline

Sets the item minimum size.

See also
getMinimumSize

◆ setName()

void ot::GraphicsItemCfg::setName ( const std::string & _name)
inline

Set item name.

◆ setPosition() [1/2]

void ot::GraphicsItemCfg::setPosition ( const Point2DD & _pos)
inline

Set item position If the item is the root item, the position is the scene position. If the item is a child item, the position is the local position (default: 0.0; 0.0).

Parameters
_posItem position

◆ setPosition() [2/2]

void ot::GraphicsItemCfg::setPosition ( double _x,
double _y )
inline

Set item position If the item is the root item, the position is the scene position. If the item is a child item, the position is the local position (default: 0.0; 0.0).

Parameters
_xX position
_yY position

◆ setSizePolicy()

void ot::GraphicsItemCfg::setSizePolicy ( SizePolicy _policy)
inline

Set item size policy.

See also
getSizePolicy.

◆ setStringMap()

void ot::GraphicsItemCfg::setStringMap ( const std::map< std::string, std::string > & _map)
inline

Sets the string map.

See also
getStringMap

◆ setTitle()

void ot::GraphicsItemCfg::setTitle ( const std::string & _title)
inline

Set item title The item title will be displayed to the user when needed.

◆ setToolTip()

void ot::GraphicsItemCfg::setToolTip ( const std::string & _toolTip)
inline

Set ToolTip.

See also
getToolTip

◆ setTransform()

void ot::GraphicsItemCfg::setTransform ( const Transform & _transform)
inline

Set the item transform.

◆ setUid()

void ot::GraphicsItemCfg::setUid ( const UID & _uid)
inline

Set item UID.

See also
getUid

The documentation for this class was generated from the following files: