SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Slots | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
smtk::extension::qtDiagramScene Class Reference

A QGraphicsScene that holds QGraphicsItems for diagrams. More...

#include <qtDiagramScene.h>

Inheritance diagram for smtk::extension::qtDiagramScene:
[legend]
Collaboration diagram for smtk::extension::qtDiagramScene:
[legend]

Public Types

using Superclass = QGraphicsScene
 

Public Slots

bool computeLayout (const std::unordered_set< qtBaseNode * > &nodes, const std::unordered_set< qtBaseArc * > &arcs)
 Compute a layout of the nodes and arcs passed into this method. More...
 
virtual void alignHorizontal (const std::unordered_set< qtBaseNode * > &nodeSet, int alignment)
 These methods are called with +1, 0, or -1 from the above methods (alignLeft/HCenterRight and alignTop/VCenter/Bottom). More...
 
virtual void alignVertical (const std::unordered_set< qtBaseNode * > &nodeSet, int alignment)
 
virtual void distributeHorizontal (const std::unordered_set< qtBaseNode * > &nodeSet, smtk::string::Token distribution)
 Call these methods with distribution set to "centers" or "gaps" to redistribute nodes horizontally or vertically. More...
 
virtual void distributeVertical (const std::unordered_set< qtBaseNode * > &nodeSet, smtk::string::Token distribution)
 

Public Member Functions

 qtDiagramScene (qtDiagram *)
 
void setConfiguration (qtDiagramViewConfiguration *config)
 Set/get the view configuration object passed to us from the parent widget.
 
qtDiagramViewConfigurationconfiguration () const
 
qtDiagramdiagram ()
 Return the parent diagram.
 
std::unordered_set< qtBaseNode * > nodesOfSelection () const
 

Protected Member Functions

void drawBackground (QPainter *painter, const QRectF &rect) override
 Draw a cross-hatched grid for the background.
 

Static Protected Member Functions

static QPointF snapToGrid (const qreal &x, const qreal &y, const qreal &resolution=1.0)
 Snaps the given x and y coordinate to the next available top left grid point. More...
 

Protected Attributes

qtDiagramViewConfigurationm_config { nullptr }
 
qtDiagramm_diagram { nullptr }
 

Detailed Description

A QGraphicsScene that holds QGraphicsItems for diagrams.

Diagrams are node+arc schematic figures whose items are maintained by qtDiagramGenerator instances.

Member Function Documentation

◆ alignHorizontal

void smtk::extension::qtDiagramScene::alignHorizontal ( const std::unordered_set< qtBaseNode * > &  nodeSet,
int  alignment 
)
virtualslot

These methods are called with +1, 0, or -1 from the above methods (alignLeft/HCenterRight and alignTop/VCenter/Bottom).

Call these methods with aignment set to +1, 0, or -1 to align nodes horizontally or vertically.

When called with +1, nodes are aligned to their right-/top-most edges. When called with 0, nodes are aligned to their centers. When called with -1, nodes are aligned to their left-/bottom-most edges.

◆ computeLayout

bool smtk::extension::qtDiagramScene::computeLayout ( const std::unordered_set< qtBaseNode * > &  nodes,
const std::unordered_set< qtBaseArc * > &  arcs 
)
slot

Compute a layout of the nodes and arcs passed into this method.

This uses graphviz to perform the layout and returns true on success.

◆ distributeHorizontal

void smtk::extension::qtDiagramScene::distributeHorizontal ( const std::unordered_set< qtBaseNode * > &  nodeSet,
smtk::string::Token  distribution 
)
virtualslot

Call these methods with distribution set to "centers" or "gaps" to redistribute nodes horizontally or vertically.

When called with "centers", node center points are evenly distributed. When called with "gaps", the space between nodes is evenly distributed.

◆ snapToGrid()

QPointF smtk::extension::qtDiagramScene::snapToGrid ( const qreal &  x,
const qreal &  y,
const qreal &  resolution = 1.0 
)
staticprotected

Snaps the given x and y coordinate to the next available top left grid point.

Optionally, the grid can be scaled with the resolution parameter.


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