Envision
A visual programming IDE for object-oriented languages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
Visualization::ViewItem Class Reference

The ViewItem class represents the visualization of an entire view within a single item. More...

Inheritance diagram for Visualization::ViewItem:
Core::Reflect< Base >

Classes

struct  ArrowToAdd
 

Public Types

typedef DeclarativeItemBaseStyle StyleType
 

Public Member Functions

 ViewItem (Item *parent, QString name={}, StyleType *style=itemStyles().get())
 
void addArrow (Model::Node *from, Model::Node *to, QString layer, ViewItemNode *fromParent=nullptr, ViewItemNode *toParent=nullptr)
 Adds an arrow from the first to the second node on the given arrow layer. More...
 
virtual QList< Visualization::VisualizationAddOn * > addOns () override
 
void addSpacing (MajorMinorIndex index, Model::Node *spacingTarget, ViewItemNode *spacingParent)
 Adds a spacing node at the given position, using the given target and parent to determine the spacing. More...
 
QList< Model::Node * > allNodes () const
 Returns all nodes in the grid in list form. More...
 
QStringList arrowLayers () const
 Returns the names of all the available arrow layers. More...
 
QList< QPair< Item *, Item * > > arrowsForLayer (QString layer)
 Returns the items for which an arrow should be drawn in the given arrow layer. More...
 
virtual void determineChildren () override
 
void fromJson (QJsonDocument json)
 
QString fullLayerName (const QString &localLayer) const
 Returns the full layer name of the local arrow layer, as used in the overlay which exists in the scene itself. More...
 
virtual Visualization::InteractionHandlerhandler () const override
 
void insertMajor (int major)
 Insert an empty major element into the grid of nodes. More...
 
ViewItemNodeinsertNode (Model::Node *node, MajorMinorIndex pos={}, int purpose=-1)
 Insert the given node into the grid at the given position, rendering it with the given purpose. More...
 
GridLayouter::MajorAxis majorAxis () const
 
const QString & name () const
 
Model::NodenodeAt (MajorMinorIndex index) const
 Returns the node at the given position. More...
 
MajorMinorIndex positionOfItem (Item *item) const
 Returns the position of the given item's node in the grid, or (-1, -1) if the item has no node, or the node is not part of the grid. More...
 
MajorMinorIndex positionOfNode (Model::Node *node) const
 Returns the position of the given node in the grid, or (-1, -1) if it doesn't exist. More...
 
void removeNode (Model::Node *node)
 Remove the given node from the view (this does not delete the node from the model) More...
 
void setArrowStyle (QString layer, QString styleName)
 
void setMajorAxis (GridLayouter::MajorAxis majorAxis)
 
void setName (const QString &name)
 Sets the name to the given name. More...
 
virtual void setStyle (const Visualization::ItemStyle *itemStyle) override
 
void setZoomLabelsEnabled (bool zoomLabelsEnabled)
 
const StyleTypestyle () const
 
QJsonDocument toJson () const
 
virtual void updateGeometry (int availableWidth, int availableHeight) override
 
bool zoomLabelsEnabled ()
 

Static Public Member Functions

static void addAddOn (Visualization::VisualizationAddOn *addOn)
 
static Visualization::InteractionHandlerdefaultClassHandler ()
 
static void initializeForms ()
 
static bool isValidName (const QString &name)
 Returns whether this is a valid name for a ViewItem. More...
 
static Visualization::StyleSet< ViewItem > & itemStyles ()
 
static int publicInterfacePurpose ()
 The purpose to use when rendering only the public interface of an item. More...
 
static bool removeAddOn (Visualization::VisualizationAddOn *addOn)
 
static void setDefaultClassHandler (Visualization::InteractionHandler *handler)
 

Private Member Functions

void addArrowLayer (QString layer, bool enabled=true)
 
void arrowFromJson (QJsonObject json)
 
QJsonObject arrowToJson (QPair< Item *, Item * > arrow, QString layer) const
 
void cleanupRemovedItem (Item *item)
 Notify the view about an item being removed externally (e.g. More...
 
void cleanupRemovedNode (Model::Node *node)
 
void ensureMajorExists (int major)
 
void ensurePositionExists (MajorMinorIndex index)
 
void insertViewItemNode (ViewItemNode *node, MajorMinorIndex index)
 
QVector< QVector< Model::Node * > > nodesGetter ()
 
template<typename NodeType >
QList< NodeType * > referencesOfType () const
 
void removeArrowsForItem (Item *parent)
 

Static Private Member Functions

static QList< Visualization::VisualizationAddOn * > & staticAddOns ()
 

Private Attributes

QHash< QString, QList< QPair< Item *, Item * > > > arrows_
 
QList< ArrowToAddarrowsToAdd_
 
QHash< QString, QString > arrowStyles_
 
QStringList disabledArrowLayers_
 
GridLayouter::MajorAxis majorAxis_ {GridLayouter::ColumnMajor}
 
QString name_
 
QVector< QVector< Model::Node * > > nodes_
 
bool zoomLabelsEnabled_ {true}
 

Static Private Attributes

static Visualization::InteractionHandlerdefaultClassHandler_ = nullptr
 

Friends

class ViewItemManager
 

Additional Inherited Members

- Protected Types inherited from Core::Reflect< Base >
using Super = Reflect< Base >
 

Detailed Description

The ViewItem class represents the visualization of an entire view within a single item.

All items in a view should be added and removed via this ViewItem class. Each Scene object contains a list of ViewItem objects which can be used for that. Using this, it is possible to control what is shown on the screen.

Member Typedef Documentation

◆ StyleType

Constructor & Destructor Documentation

◆ ViewItem()

Visualization::ViewItem::ViewItem ( Item parent,
QString  name = {},
StyleType style = itemStyles().get() 
)

Member Function Documentation

◆ addAddOn()

void Visualization::ViewItem::addAddOn ( Visualization::VisualizationAddOn addOn)
static

◆ addArrow()

void Visualization::ViewItem::addArrow ( Model::Node from,
Model::Node to,
QString  layer,
ViewItemNode fromParent = nullptr,
ViewItemNode toParent = nullptr 
)

Adds an arrow from the first to the second node on the given arrow layer.

If fromParent and toParent are set, only one arrow will be drawn. Otherwise, an arrow will be drawn between any two instances of the given nodes.

◆ addArrowLayer()

void Visualization::ViewItem::addArrowLayer ( QString  layer,
bool  enabled = true 
)
private

◆ addOns()

QList< Visualization::VisualizationAddOn * > Visualization::ViewItem::addOns ( )
overridevirtual

◆ addSpacing()

void Visualization::ViewItem::addSpacing ( MajorMinorIndex  index,
Model::Node spacingTarget,
ViewItemNode spacingParent 
)

Adds a spacing node at the given position, using the given target and parent to determine the spacing.

◆ allNodes()

QList< Model::Node * > Visualization::ViewItem::allNodes ( ) const

Returns all nodes in the grid in list form.

◆ arrowFromJson()

void Visualization::ViewItem::arrowFromJson ( QJsonObject  json)
private

◆ arrowLayers()

QStringList Visualization::ViewItem::arrowLayers ( ) const

Returns the names of all the available arrow layers.

◆ arrowsForLayer()

QList< QPair< Item *, Item * > > Visualization::ViewItem::arrowsForLayer ( QString  layer)

Returns the items for which an arrow should be drawn in the given arrow layer.

◆ arrowToJson()

QJsonObject Visualization::ViewItem::arrowToJson ( QPair< Item *, Item * >  arrow,
QString  layer 
) const
private

◆ cleanupRemovedItem()

void Visualization::ViewItem::cleanupRemovedItem ( Item item)
private

Notify the view about an item being removed externally (e.g.

by deleting its node).

◆ cleanupRemovedNode()

void Visualization::ViewItem::cleanupRemovedNode ( Model::Node node)
private

◆ defaultClassHandler()

static Visualization::InteractionHandler* Visualization::ViewItem::defaultClassHandler ( )
inlinestatic

◆ determineChildren()

void Visualization::ViewItem::determineChildren ( )
overridevirtual

◆ ensureMajorExists()

void Visualization::ViewItem::ensureMajorExists ( int  major)
private

◆ ensurePositionExists()

void Visualization::ViewItem::ensurePositionExists ( MajorMinorIndex  index)
private

◆ fromJson()

void Visualization::ViewItem::fromJson ( QJsonDocument  json)

◆ fullLayerName()

QString Visualization::ViewItem::fullLayerName ( const QString &  localLayer) const
inline

Returns the full layer name of the local arrow layer, as used in the overlay which exists in the scene itself.

◆ handler()

Visualization::InteractionHandler * Visualization::ViewItem::handler ( ) const
overridevirtual

◆ initializeForms()

void Visualization::ViewItem::initializeForms ( )
static

◆ insertMajor()

void Visualization::ViewItem::insertMajor ( int  major)

Insert an empty major element into the grid of nodes.

◆ insertNode()

ViewItemNode * Visualization::ViewItem::insertNode ( Model::Node node,
MajorMinorIndex  pos = {},
int  purpose = -1 
)

Insert the given node into the grid at the given position, rendering it with the given purpose.

◆ insertViewItemNode()

void Visualization::ViewItem::insertViewItemNode ( ViewItemNode node,
MajorMinorIndex  index 
)
private

◆ isValidName()

bool Visualization::ViewItem::isValidName ( const QString &  name)
static

Returns whether this is a valid name for a ViewItem.

◆ itemStyles()

Visualization::StyleSet< ViewItem > & Visualization::ViewItem::itemStyles ( )
static

◆ majorAxis()

GridLayouter::MajorAxis Visualization::ViewItem::majorAxis ( ) const
inline

◆ name()

const QString & Visualization::ViewItem::name ( ) const
inline

◆ nodeAt()

Model::Node * Visualization::ViewItem::nodeAt ( MajorMinorIndex  index) const

Returns the node at the given position.

If the position is invalid, returns nullptr.

◆ nodesGetter()

QVector< QVector< Model::Node * > > Visualization::ViewItem::nodesGetter ( )
private

◆ positionOfItem()

MajorMinorIndex Visualization::ViewItem::positionOfItem ( Item item) const

Returns the position of the given item's node in the grid, or (-1, -1) if the item has no node, or the node is not part of the grid.

◆ positionOfNode()

MajorMinorIndex Visualization::ViewItem::positionOfNode ( Model::Node node) const

Returns the position of the given node in the grid, or (-1, -1) if it doesn't exist.

◆ publicInterfacePurpose()

int Visualization::ViewItem::publicInterfacePurpose ( )
static

The purpose to use when rendering only the public interface of an item.

◆ referencesOfType()

template<typename NodeType >
QList< NodeType * > Visualization::ViewItem::referencesOfType
inlineprivate

◆ removeAddOn()

bool Visualization::ViewItem::removeAddOn ( Visualization::VisualizationAddOn addOn)
static

◆ removeArrowsForItem()

void Visualization::ViewItem::removeArrowsForItem ( Item parent)
private

◆ removeNode()

void Visualization::ViewItem::removeNode ( Model::Node node)

Remove the given node from the view (this does not delete the node from the model)

◆ setArrowStyle()

void Visualization::ViewItem::setArrowStyle ( QString  layer,
QString  styleName 
)

◆ setDefaultClassHandler()

static void Visualization::ViewItem::setDefaultClassHandler ( Visualization::InteractionHandler handler)
inlinestatic

◆ setMajorAxis()

void Visualization::ViewItem::setMajorAxis ( GridLayouter::MajorAxis  majorAxis)

◆ setName()

void Visualization::ViewItem::setName ( const QString &  name)

Sets the name to the given name.

Ensure that isValidName(name) holds.

◆ setStyle()

void Visualization::ViewItem::setStyle ( const Visualization::ItemStyle itemStyle)
overridevirtual

◆ setZoomLabelsEnabled()

void Visualization::ViewItem::setZoomLabelsEnabled ( bool  zoomLabelsEnabled)
inline

◆ staticAddOns()

QList< Visualization::VisualizationAddOn * > & Visualization::ViewItem::staticAddOns ( )
staticprivate

◆ style()

const StyleType* Visualization::ViewItem::style ( ) const
inline

◆ toJson()

QJsonDocument Visualization::ViewItem::toJson ( ) const

◆ updateGeometry()

void Visualization::ViewItem::updateGeometry ( int  availableWidth,
int  availableHeight 
)
overridevirtual

◆ zoomLabelsEnabled()

bool Visualization::ViewItem::zoomLabelsEnabled ( )
inline

Friends And Related Function Documentation

◆ ViewItemManager

friend class ViewItemManager
friend

Member Data Documentation

◆ arrows_

QHash<QString, QList<QPair<Item*, Item*> > > Visualization::ViewItem::arrows_
private

◆ arrowsToAdd_

QList<ArrowToAdd> Visualization::ViewItem::arrowsToAdd_
private

◆ arrowStyles_

QHash<QString, QString> Visualization::ViewItem::arrowStyles_
private

◆ defaultClassHandler_

Visualization::InteractionHandler * Visualization::ViewItem::defaultClassHandler_ = nullptr
staticprivate

◆ disabledArrowLayers_

QStringList Visualization::ViewItem::disabledArrowLayers_
private

◆ majorAxis_

GridLayouter::MajorAxis Visualization::ViewItem::majorAxis_ {GridLayouter::ColumnMajor}
private

◆ name_

QString Visualization::ViewItem::name_
private

◆ nodes_

QVector<QVector<Model::Node*> > Visualization::ViewItem::nodes_
private

◆ zoomLabelsEnabled_

bool Visualization::ViewItem::zoomLabelsEnabled_ {true}
private