OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::GraphicsStackItem Class Reference

The GraphicsStackItem is used adjust the size of child items marked as slave occording to the naster item sizes. The graphics stack item will calculate the child item size whenever a master item chaged its size. The GraphicsStackItemCfg is used to configure the GraphicsStackItem. More...

#include "GraphicsStackItem.h"

Inheritance diagram for ot::GraphicsStackItem:
ot::GraphicsItem ot::GraphicsElement ot::VersionGraphItem

Classes

struct  GraphicsStackItemEntry
 The GraphicsStackItemEntry holds a GraphicsItem aswell as the information if this item is a master or a slave. More...
 

Public Member Functions

 GraphicsStackItem ()
 Default constructor.
 
virtual ~GraphicsStackItem ()
 Destructor.
 
virtual bool setupFromConfig (const GraphicsItemCfg *_cfg) override
 Will setup the item from the provided configuration and store a copy. The previously stored configuration will be destroyed. Default 0.
 
virtual void removeAllConnections (void) override
 Removes all connections to or from this item.
 
virtual void prepareGraphicsItemGeometryChange (void) override
 Calls QGraphicsLayoutItem::prepareGeometryChange().
 
virtual void callPaint (QPainter *_painter, const QStyleOptionGraphicsItem *_opt, QWidget *_widget) override
 Calls QGraphicsItem::paint().
 
virtual void graphicsItemEventHandler (ot::GraphicsItem *_sender, GraphicsItemEvent _event) override
 Will be called when this item was registered as an event handler and the child raised an event.
 
virtual void setGraphicsItemRequestedSize (const QSizeF &_size) override
 
virtual QSizeF graphicsItemSizeHint (Qt::SizeHint _hint, const QSizeF &_constrains) const
 Calls QGraphicsLayoutItem::sizeHint().
 
virtual QGraphicsLayoutItem * getQGraphicsLayoutItem (void) override
 Returns the QGraphicsLayoutItem.
 
virtual QGraphicsItem * getQGraphicsItem (void) override
 Returns the QGraphicsItem.
 
virtual const QGraphicsItem * getQGraphicsItem (void) const override
 Returns the const QGraphicsItem.
 
virtual ot::GraphicsItemfindItem (const std::string &_itemName) override
 Will return any child item that matches the _itemName.
 
virtual void finalizeGraphicsItem (void) override
 Will be called after setupFromConfig (i.e. if the item is completely created). Here the item structure is complete and the item may adjust settings that depend on parent items (e.g. Text reference for GraphicsTextItem). Container items must override this method to forward the call to their child items.
 
virtual std::list< GraphicsElement * > getAllGraphicsElements (void) override
 Returns all graphics elements nested in this element. The result contains this element and all of its childs.
 
virtual std::list< GraphicsElement * > getAllDirectChildElements (void) override
 
virtual void paint (QPainter *_painter, const QStyleOptionGraphicsItem *_opt, QWidget *_widget) override
 
virtual QRectF boundingRect (void) const override
 
virtual QVariant itemChange (QGraphicsItem::GraphicsItemChange _change, const QVariant &_value) override
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *_event) override
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *_event) override
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *_event) override
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *_event) override
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *_event) override
 
virtual QSizeF sizeHint (Qt::SizeHint _hint, const QSizeF &_constrains) const override
 
virtual void setGeometry (const QRectF &rect) override
 
void addItem (ot::GraphicsItem *_item, bool _isMaster, bool _isSlave)
 
virtual double getMaxAdditionalTriggerDistance (void) const override
 Returns the maximum trigger distance in any direction of this item and its childs.
 
void clear (void)
 
- Public Member Functions inherited from ot::GraphicsItem
 GraphicsItem (GraphicsItemCfg *_configuration)
 Constructor.
 
virtual ~GraphicsItem ()
 Destructor.
 
virtual void graphicsItemFlagsChanged (const GraphicsItemCfg::GraphicsItemFlags &_flags)
 Will be called whenever the GraphicsItem flags have changed.
 
virtual void graphicsItemConfigurationChanged (const GraphicsItemCfg *_config)
 Will be called whenever the GraphicsItem configuration has changed.
 
virtual bool graphicsItemRequiresHover (void) const
 
void handleMousePressEvent (QGraphicsSceneMouseEvent *_event)
 
bool handleMouseMoveEvent (QGraphicsSceneMouseEvent *_event)
 General event handler for mouse move events.
 
void handleMouseReleaseEvent (QGraphicsSceneMouseEvent *_event)
 
void handleHoverEnterEvent (QGraphicsSceneHoverEvent *_event)
 
void handleToolTip (QGraphicsSceneHoverEvent *_event)
 
void handleHoverLeaveEvent (QGraphicsSceneHoverEvent *_event)
 
QSizeF handleGetGraphicsItemSizeHint (Qt::SizeHint _hint, const QSizeF &_sizeHint) const
 Will expand the size according to the margins.
 
QRectF handleGetGraphicsItemBoundingRect (const QRectF &_rect) const
 Calculates the actual bounding rect including margins and requested size.
 
void handleItemChange (QGraphicsItem::GraphicsItemChange _change, const QVariant &_value)
 Handles general item updates. The selected state will be forwarded to the GraphicsHighlightItem. Position updates will update the connections and call GraphicsItem::graphicsItemEventHandler() with GraphicsItem::ItemMoved.
 
void handleSetItemGeometry (const QRectF &_geom)
 
void raiseEvent (ot::GraphicsItem::GraphicsItemEvent _event)
 
virtual qreal calculateShortestDistanceToPoint (const QPointF &_pt) const override
 Calculates and returns the shortest distance to the given point. Returns -1 if the distance is invalid (e.g. maximum distance exceeded).
 
QRectF calculatePaintArea (const QSizeF &_innerSize)
 Calculates the draw rect for the item The inner rect takes into account the item geometry, alignment, margins and the actual inner size.
 
virtual GraphicsScenegetGraphicsScene (void) const override
 Returns the GraphicsScene this item is placed at.
 
GraphicsItemgetRootItem (void)
 
const GraphicsItemgetRootItem (void) const
 
void setConfiguration (GraphicsItemCfg *_config)
 Replaces the current configuration with the configuration prvided. The item takes ownership of the configuration.
 
const GraphicsItemCfg *const getConfiguration (void) const
 Returns the current configuration.
 
void setGraphicsItemPos (const QPointF &_pos)
 This function will update the position in the configuration and call QGraphicsItem::setPos.
 
void setGraphicsItemPos (const Point2DD &_pos)
 This function will update the position in the configuration and call QGraphicsItem::setPos.
 
const Point2DDgetGraphicsItemPos (void) const
 Returns the current position set in the configuration.
 
virtual void setParentGraphicsItem (GraphicsItem *_itm)
 
GraphicsItemgetParentGraphicsItem (void) const
 
void setGraphicsItemFlag (ot::GraphicsItemCfg::GraphicsItemFlag _flag, bool _active=true)
 Sets the provided flag.
 
void setGraphicsItemFlags (ot::GraphicsItemCfg::GraphicsItemFlags _flags)
 Replaces the flags with the flags provided.
 
const GraphicsItemCfg::GraphicsItemFlagsgetGraphicsItemFlags (void) const
 Returns the current GraphicsItemFlags set.
 
void setGraphicsItemUid (const ot::UID &_uid)
 Sets the GraphicsItem UID.
 
const ot::UIDgetGraphicsItemUid (void) const
 
virtual void setGraphicsItemName (const std::string &_name)
 
const std::string & getGraphicsItemName (void) const
 
void setGraphicsItemToolTip (const std::string &_toolTip)
 
const std::string & getGraphicsItemToolTip (void) const
 
void setAdditionalTriggerDistance (const ot::MarginsD &_distance)
 
const ot::MarginsDgetAdditionalTriggerDistance (void) const
 
void setGraphicsItemMinimumSize (double _width, double _height)
 
void setGraphicsItemMinimumSize (const QSizeF &_size)
 
QSizeF getGraphicsItemMinimumSize (void) const
 
void setGraphicsItemMaximumSize (double _width, double _height)
 
void setGraphicsItemMaximumSize (const QSizeF &_size)
 
QSizeF getGraphicsItemMaximumSize (void) const
 
void setGraphicsItemSizePolicy (ot::SizePolicy _policy)
 
ot::SizePolicy getGraphicsItemSizePolicy (void) const
 
void setGraphicsItemAlignment (ot::Alignment _align)
 
ot::Alignment getGraphicsItemAlignment (void) const
 
void setGraphicsItemMargins (const ot::MarginsD &_margins)
 
const ot::MarginsDgetGraphicsItemMargins (void) const
 
void setConnectionDirection (ot::ConnectionDirection _direction)
 
ot::ConnectionDirection getConnectionDirection (void) const
 
void setStringMap (const std::map< std::string, std::string > &_map)
 
const std::map< std::string, std::string > & getStringMap (void) const
 
void setGraphicsItemTransform (const Transform &_transform)
 
const TransformgetGraphicsItemTransform (void) const
 
void setForwardSizeChanges (bool _forward)
 
bool getForwardSizeChanges (void) const
 
void storeConnection (GraphicsConnectionItem *_connection)
 
void forgetConnection (GraphicsConnectionItem *_connection)
 Removes the collection from the list (item will not be destroyed)
 
void addGraphicsItemEventHandler (ot::GraphicsItem *_handler)
 
void removeGraphicsItemEventHandler (ot::GraphicsItem *_handler)
 
QSizeF applyGraphicsItemMargins (const QSizeF &_size) const
 
QSizeF removeGraphicsItemMargins (const QSizeF &_size) const
 
const QSizeF & graphicsItemRequestedSize (void) const
 
std::list< ot::GraphicsConnectionCfggetConnectionCfgs ()
 
void setGraphicsItemSelected (bool _selected)
 
bool getGraphicsItemSelected (void) const
 
void setBlockFlagNotifications (bool _block)
 
bool getBlockFlagNotifications (void) const
 If enabled the item will not call graphicsItemFlagsChanged() when the flags have changed.
 
void setBlockConfigurationNotifications (bool _block)
 
bool getBlockConfigurationNotifications (void) const
 If enabled the item will not call graphicsItemConfigurationChanged() when the flags have changed.
 
void setCurrentPosAsMoveStart (void)
 Sets the current item position as move start point.
 
void notifyMoveIfRequired (void)
 Notifies the view if the items current position changed relative to the move start point.
 
void parentItemTransformChanged (const QTransform &_parentTransform)
 
QRectF getTriggerBoundingRect (void) const
 Returns the bounding rect in scene coordinates which was expanded by the additional trigger distance according to the config.
 
- Public Member Functions inherited from ot::GraphicsElement
 GraphicsElement ()
 
virtual ~GraphicsElement ()
 
virtual void setGraphicsScene (GraphicsScene *_scene)
 Set the GraphicsScene this element is placed at.
 
void setGraphicsElementState (GraphicsElementState _state, bool _active=true)
 Sets the provided state flag.
 
void setGraphicsElementStateFlags (const GraphicsElementStateFlags &_state)
 Replaces the flags with the flags provided.
 
const GraphicsElementStateFlagsgetGraphicsElementState (void) const
 Returns the current GraphicsItemStateFlags set.
 

Protected Member Functions

virtual void graphicsElementStateChanged (const GraphicsElementStateFlags &_state) override
 
virtual void notifyChildsAboutTransformChange (const QTransform &_newTransform) override
 
- Protected Member Functions inherited from ot::GraphicsItem
template<class T >
T * getItemConfiguration (void)
 Returns the configuration for the current item. The configuration may be modified. The function will cast the current configuration to the type provided. The method will return 0 if the cast failed.
 
template<class T >
const T * getItemConfiguration (void) const
 Returns the configuration for the current item. The configuration may be modified. The function will cast the current configuration to the type provided. The method will return 0 if the cast failed.
 
virtual void applyGraphicsItemTransform (void)
 

Additional Inherited Members

- Public Types inherited from ot::GraphicsItem
enum  GraphicsItemEvent { ItemMoved , ItemResized }
 The GraphicsItemEvent is used to describe the type of an event that occured. More...
 
- Public Types inherited from ot::GraphicsElement
enum  GraphicsElementState { NoState = 0x00 , HoverState = 0x01 , SelectedState = 0x02 }
 The GraphicsElementState is used to describe the current state of a GraphicsElement. More...
 
typedef Flags< GraphicsElementStateGraphicsElementStateFlags
 
- Static Public Member Functions inherited from ot::GraphicsItem
static Painter2DcreateSelectionBorderPainter (void)
 Creates a StyleRefPainter2D painter referencing ot::ColorStyleValueEntry::GraphicsItemSelectionBorder. The caller takes ownership of the painter.
 
static Painter2DcreateHoverBorderPainter (void)
 Creates a StyleRefPainter2D painter referencing ot::ColorStyleValueEntry::GraphicsItemHoverBorder. The caller takes ownership of the painter.
 

Detailed Description

The GraphicsStackItem is used adjust the size of child items marked as slave occording to the naster item sizes. The graphics stack item will calculate the child item size whenever a master item chaged its size. The GraphicsStackItemCfg is used to configure the GraphicsStackItem.

Constructor & Destructor Documentation

◆ GraphicsStackItem()

ot::GraphicsStackItem::GraphicsStackItem ( )

Default constructor.

◆ ~GraphicsStackItem()

ot::GraphicsStackItem::~GraphicsStackItem ( )
virtual

Destructor.

Member Function Documentation

◆ addItem()

void ot::GraphicsStackItem::addItem ( ot::GraphicsItem * _item,
bool _isMaster,
bool _isSlave )

◆ boundingRect()

QRectF ot::GraphicsStackItem::boundingRect ( void ) const
overridevirtual

◆ callPaint()

void ot::GraphicsStackItem::callPaint ( QPainter * _painter,
const QStyleOptionGraphicsItem * _opt,
QWidget * _widget )
overridevirtual

Calls QGraphicsItem::paint().

Implements ot::GraphicsItem.

◆ clear()

void ot::GraphicsStackItem::clear ( void )

◆ finalizeGraphicsItem()

void ot::GraphicsStackItem::finalizeGraphicsItem ( void )
overridevirtual

Will be called after setupFromConfig (i.e. if the item is completely created). Here the item structure is complete and the item may adjust settings that depend on parent items (e.g. Text reference for GraphicsTextItem). Container items must override this method to forward the call to their child items.

Reimplemented from ot::GraphicsItem.

◆ findItem()

ot::GraphicsItem * ot::GraphicsStackItem::findItem ( const std::string & _itemName)
overridevirtual

Will return any child item that matches the _itemName.

Parameters
_itemNameThe name of the item to find.

Reimplemented from ot::GraphicsItem.

◆ getAllDirectChildElements()

std::list< ot::GraphicsElement * > ot::GraphicsStackItem::getAllDirectChildElements ( void )
overridevirtual

Reimplemented from ot::GraphicsElement.

◆ getAllGraphicsElements()

std::list< ot::GraphicsElement * > ot::GraphicsStackItem::getAllGraphicsElements ( void )
overridevirtual

Returns all graphics elements nested in this element. The result contains this element and all of its childs.

Reimplemented from ot::GraphicsElement.

◆ getMaxAdditionalTriggerDistance()

double ot::GraphicsStackItem::getMaxAdditionalTriggerDistance ( void ) const
overridevirtual

Returns the maximum trigger distance in any direction of this item and its childs.

Reimplemented from ot::GraphicsItem.

◆ getQGraphicsItem() [1/2]

virtual const QGraphicsItem * ot::GraphicsStackItem::getQGraphicsItem ( void ) const
inlineoverridevirtual

Returns the const QGraphicsItem.

Implements ot::GraphicsElement.

◆ getQGraphicsItem() [2/2]

virtual QGraphicsItem * ot::GraphicsStackItem::getQGraphicsItem ( void )
inlineoverridevirtual

Returns the QGraphicsItem.

Implements ot::GraphicsElement.

◆ getQGraphicsLayoutItem()

virtual QGraphicsLayoutItem * ot::GraphicsStackItem::getQGraphicsLayoutItem ( void )
inlineoverridevirtual

Returns the QGraphicsLayoutItem.

Implements ot::GraphicsItem.

◆ graphicsElementStateChanged()

void ot::GraphicsStackItem::graphicsElementStateChanged ( const GraphicsElementStateFlags & _state)
overrideprotectedvirtual

Reimplemented from ot::GraphicsItem.

◆ graphicsItemEventHandler()

void ot::GraphicsStackItem::graphicsItemEventHandler ( ot::GraphicsItem * _sender,
GraphicsItemEvent _event )
overridevirtual

Will be called when this item was registered as an event handler and the child raised an event.

Reimplemented from ot::GraphicsItem.

◆ graphicsItemSizeHint()

QSizeF ot::GraphicsStackItem::graphicsItemSizeHint ( Qt::SizeHint _hint,
const QSizeF & _constrains ) const
virtual

Calls QGraphicsLayoutItem::sizeHint().

Implements ot::GraphicsItem.

◆ hoverEnterEvent()

void ot::GraphicsStackItem::hoverEnterEvent ( QGraphicsSceneHoverEvent * _event)
overridevirtual

◆ hoverLeaveEvent()

void ot::GraphicsStackItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent * _event)
overridevirtual

◆ itemChange()

QVariant ot::GraphicsStackItem::itemChange ( QGraphicsItem::GraphicsItemChange _change,
const QVariant & _value )
overridevirtual

◆ mouseMoveEvent()

void ot::GraphicsStackItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * _event)
overridevirtual

◆ mousePressEvent()

void ot::GraphicsStackItem::mousePressEvent ( QGraphicsSceneMouseEvent * _event)
overridevirtual

◆ mouseReleaseEvent()

void ot::GraphicsStackItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * _event)
overridevirtual

◆ notifyChildsAboutTransformChange()

void ot::GraphicsStackItem::notifyChildsAboutTransformChange ( const QTransform & _newTransform)
overrideprotectedvirtual

Reimplemented from ot::GraphicsItem.

◆ paint()

void ot::GraphicsStackItem::paint ( QPainter * _painter,
const QStyleOptionGraphicsItem * _opt,
QWidget * _widget )
overridevirtual

◆ prepareGraphicsItemGeometryChange()

void ot::GraphicsStackItem::prepareGraphicsItemGeometryChange ( void )
overridevirtual

Calls QGraphicsLayoutItem::prepareGeometryChange().

Implements ot::GraphicsItem.

◆ removeAllConnections()

void ot::GraphicsStackItem::removeAllConnections ( void )
overridevirtual

Removes all connections to or from this item.

Reimplemented from ot::GraphicsItem.

◆ setGeometry()

void ot::GraphicsStackItem::setGeometry ( const QRectF & rect)
overridevirtual

◆ setGraphicsItemRequestedSize()

void ot::GraphicsStackItem::setGraphicsItemRequestedSize ( const QSizeF & _size)
overridevirtual

Reimplemented from ot::GraphicsItem.

◆ setupFromConfig()

bool ot::GraphicsStackItem::setupFromConfig ( const GraphicsItemCfg * _cfg)
overridevirtual

Will setup the item from the provided configuration and store a copy. The previously stored configuration will be destroyed. Default 0.

Parameters
_cfgGraphicsItem configuration (Copy will be stored).

Reimplemented from ot::GraphicsItem.

◆ sizeHint()

QSizeF ot::GraphicsStackItem::sizeHint ( Qt::SizeHint _hint,
const QSizeF & _constrains ) const
overridevirtual

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