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

A widget that displays diagrams of SMTK resources. More...

#include <qtDiagram.h>

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

Classes

class  Internal
 

Public Slots

void enableNodes (bool shouldEnable)
 Enable (or disable if shouldEnable is false) node interactivity.
 
void enableNodeSelection (bool shouldEnable)
 Enable (or disable if shouldEnable is false) node selectability.
 
void enableArcSelection (bool shouldEnable)
 Enable (or disable if shouldEnable is false) arc selection.
 
virtual void requestModeChange (smtk::string::Token mode)
 Request a change in the user-interaction mode.
 
virtual void toggleSidebar (bool showSidebar)
 Open/close the sidebar used to display information about nodes/arcs in the diagram.
 
virtual bool updateSMTKSelection ()
 Called when the scene's Qt selection changes. More...
 
virtual void updateQtSelection ()
 Called the SMTK's application-wide selection changes. More...
 
- Public Slots inherited from smtk::extension::qtBaseView
virtual void updateUI ()
 Have the view update its contents. More...
 
virtual void childrenResized ()
 
virtual void showAdvanceLevelOverlay (bool val)
 
virtual void showAdvanceLevel (int)
 Have the view update its contents based on a new advance level.
 
virtual void enableShowBy (int)
 
virtual void onInfo ()
 Display view information (i.e., help text)
 
virtual void onShowCategory ()
 

Signals

void modeChanged (smtk::string::Token nextMode)
 Emitted by modeChangeRequested when the mode is actually changed (and not when unchanged).
 
- Signals inherited from smtk::extension::qtBaseView
void aboutToDestroy ()
 
void modified ()
 

Public Member Functions

 smtkTypenameMacro (smtk::extension::qtDiagram)
 
 smtkSuperclassMacro (smtk::extension::qtBaseView)
 
 qtDiagram (const smtk::view::Information &info)
 
qtDiagramScenediagramScene () const
 
qtDiagramViewdiagramWidget () const
 
qtDiagramLegendlegend () const
 Return the legend widget held in the sidebar().
 
QFrame * topFrame () const
 Return the top frame of the central area of the diagram.
 
qtBaseNodefindNode (const smtk::common::UUID &nodeId) const
 Provide the scene with a way to identify graphical items. More...
 
bool addNode (qtBaseNode *node, bool enforceInteractionMode=true)
 Insert a node into the diagram's reverse-lookup map.
 
bool removeNode (qtBaseNode *node)
 Remove a node from the diagram. More...
 
bool removeNodeIndex (const smtk::common::UUID &nodeId)
 Remove a node index from the diagram's maps.
 
bool addArc (qtBaseArc *arc, bool enforceSelectionMode=true)
 Insert an arc into the diagram's nodal lookup maps. More...
 
bool removeArc (qtBaseArc *arc)
 Remove an arc from the diagram's lookup maps. More...
 
std::unordered_set< qtBaseArc * > arcsOfNode (qtBaseNode *node)
 Return a set of all the arcs incident to/from the node.
 
const std::unordered_map< qtBaseNode *, std::unordered_map< smtk::string::Token, std::unordered_set< qtBaseArc * > > > * arcsFromNode (qtBaseNode *node) const
 Return the set of all arcs outgoing from the node, indexed by the destination node. More...
 
std::unordered_set< qtBaseNode * > predecessorsOf (qtBaseNode *successor) const
 Reverse arc lookup (i.e., find predecessor nodes attached to a given successor).
 
const std::unordered_map< smtk::string::Token, std::unordered_set< qtBaseArc * > > * findArcs (qtBaseNode *source, qtBaseNode *target) const
 Find arcs connecting an (ordered) pair of nodes. More...
 
smtk::string::Token mode () const
 Report the current user interaction mode. More...
 
smtk::string::Token defaultMode () const
 Return the default mode for the editor. More...
 
qtDiagramViewModemodeObject () const
 Return the object managing the current mode. More...
 
const std::unordered_map< smtk::string::Token, std::shared_ptr< qtDiagramViewMode > > & modes () const
 Return the map from mode names to modes.
 
QToolBar * tools () const
 Return a toolbar to which modes can add actions/widgets. More...
 
smtk::common::Managers::Ptr managers () const
 Return the application state (smtk::common::Managers) object this editor was configured with.
 
const std::unordered_map< smtk::string::Token, std::shared_ptr< qtDiagramGenerator > > & generators () const
 Return the generators used to maintain the content of this diagram indexed by the name of the diagram content.
 
void includeInView (const QRectF &inclusion, int priority=0)
 Methods intended for diagram generators. More...
 
bool nodesEnabled () const
 True when nodes are enabled (i.e., users may interact with them) and false otherwise.
 
bool nodeSelectionEnabled () const
 True when nodes are selectable (i.e., users may select them) and false otherwise.
 
bool arcSelectionEnabled () const
 True when arcs are selectable and false otherwise.
 
QWidget * sidebar () const
 Return the sidebar widget. More...
 
QRectF visibleBounds () const
 Return the bounding rect of visible nodes and arcs in the scene. More...
 
bool configure (const nlohmann::json &data)
 
nlohmann::json configuration () const
 
- Public Member Functions inherited from smtk::extension::qtBaseView
 smtkTypenameMacro (qtBaseView)
 
 qtBaseView (const smtk::view::Information &info)
 
const smtk::view::ConfigurationPtrconfiguration () const
 
QWidget * widget () const
 
QWidget * parentWidget () const
 
qtUIManageruiManager () const
 
const smtk::view::Informationinformation () const
 Return the view's specification (its configuration plus environment information).
 
virtual int advanceLevel () const
 
virtual bool categoryEnabled () const
 
virtual std::string currentCategory () const
 
virtual void setInitialCategory ()
 When category filtering is requested to be either on by default or is requested to be on permanently, we need to have a mechanism to force the views to display info based on the initial category. More...
 
bool isTopLevel () const
 
virtual bool isEmpty () const
 Return true if the view does not contain any information to display. More...
 
virtual bool isValid () const
 Return true if the view's contents are valid.
 
- Public Member Functions inherited from smtk::view::BaseView
 smtkTypenameMacroBase (BaseView)
 
virtual std::size_t index () const
 index is a compile-time intrinsic of the derived view; as such, it cannot be set.
 

Static Public Member Functions

static qtBaseViewcreateViewWidget (const smtk::view::Information &info)
 
static std::shared_ptr< smtk::view::ConfigurationdefaultConfiguration ()
 The default configuration for the view.
 
- Static Public Member Functions inherited from smtk::extension::qtBaseView
static bool validateInformation (const smtk::view::Information &info)
 

Protected Slots

void modeChangeRequested (QAction *modeAction)
 Invoked when a user clicks on a title-bar button to change modes.
 
void onNodeGeometryChanged ()
 Invoked when a user moves a node.
 

Protected Attributes

Internalm_p
 
- Protected Attributes inherited from smtk::extension::qtBaseView
QWidget * Widget
 
bool m_isTopLevel
 
bool m_useSelectionManager
 
smtk::view::Information m_viewInfo
 
QPointer< qtViewInfoDialogm_infoDialog
 
bool m_advOverlayVisible
 

Properties

smtk::string::Token mode
 

Additional Inherited Members

- Protected Member Functions inherited from smtk::extension::qtBaseView
virtual void buildUI ()
 Creates the UI related to the view and properly assigns it to the parent widget.
 
virtual void createWidget ()
 Creates the main QT Widget that is associated with a View. More...
 
virtual void makeTopLevel ()
 Adds properties associated with respects to a top level view.
 
virtual void setInfoToBeDisplayed ()
 Set the information to be displayed in the ViewInfoDialog.
 

Detailed Description

A widget that displays diagrams of SMTK resources.

The purpose of this class is to (1) implement a qtBaseView which provides a QGraphicsView/QGraphicsScene canvas and (2) act as a clearing house for objects that manage items in the scene which correspond to persistent objects.

It owns

The diagram is assumed to consist of (1) nodes (which inherit qtBaseNode), (2) arcs connecting nodes (which inherit qtBaseArc), and (3) any other QGraphicsItem objects inserted by qtDiagramGenerator (but these must be managed by the generator; the diagram will not provide facilities to manage them).

Member Function Documentation

◆ addArc()

bool smtk::extension::qtDiagram::addArc ( qtBaseArc arc,
bool  enforceSelectionMode = true 
)

Insert an arc into the diagram's nodal lookup maps.

The arc must be non-null and have non-null endpoint-nodes.

◆ arcsFromNode()

const std::unordered_map< qtBaseNode *, std::unordered_map< smtk::string::Token, std::unordered_set< qtBaseArc * > > > * smtk::extension::qtDiagram::arcsFromNode ( qtBaseNode node) const

Return the set of all arcs outgoing from the node, indexed by the destination node.

Contrast this method (which only returns outgoing arcs) to the arcsOfNode() method that returns both outgoing and incoming arcs. This method is faster than arcsOfNode().

◆ configuration()

nlohmann::json smtk::extension::qtDiagram::configuration ( ) const

Set and get the current configuration of the view.

This includes, for example, the location of persistent objects in the scene and items in the scene that do not correspond to a persistent object but which should nonetheless persist across file load/save.

◆ configure()

bool smtk::extension::qtDiagram::configure ( const nlohmann::json &  data)

Set and get the current configuration of the view.

This includes, for example, the location of persistent objects in the scene and items in the scene that do not correspond to a persistent object but which should nonetheless persist across file load/save.

◆ defaultMode()

smtk::string::Token smtk::extension::qtDiagram::defaultMode ( ) const

Return the default mode for the editor.

If a non-default mode wishes to allow users to "escape" from the mode (usually via the Escape key), they can request a change to this mode. The "connect" and "disconnect" modes currently use this method.

◆ findArcs()

const std::unordered_map< smtk::string::Token, std::unordered_set< qtBaseArc * > > * smtk::extension::qtDiagram::findArcs ( qtBaseNode source,
qtBaseNode target 
) const

Find arcs connecting an (ordered) pair of nodes.

All arcs are considered directional and must have been created in the same source to target order as you provide nodes to this method.

If you do not know the proper node order, make two calls to this method and examine both returned sets.

This method simply calls arcsFromNode() and searches the result.

◆ findNode()

qtBaseNode * smtk::extension::qtDiagram::findNode ( const smtk::common::UUID nodeId) const

Provide the scene with a way to identify graphical items.

Many items in the scene correspond to persistent objects and thus use their object's UUID. Others generate their own UUID.

Note that generators should only insert nodes into this map that they wish other generators to reference (since only one object can exist in the map for a given UUID). It is possible for a multiple objects to represent the same UUID, but they cannot all be indexed by the diagram.

◆ includeInView()

void smtk::extension::qtDiagram::includeInView ( const QRectF &  inclusion,
int  priority = 0 
)

Methods intended for diagram generators.

Hint to the diagram that the given rectangle (in scene coordinates) should be made visible in the view.

Generally, the diagram will respond by taking the union of all rectangles provided by its generators and ensuring the result is visible. It will not zoom in but will zoom out if the resulting rectangle is not completely contained in the diagramWidget()'s active viewport.

This method should be called by generators within their updateSceneArcs/Nodes() methods. After the diagram has invoked this method on all its generators, it will determine whether to make changes to the viewport.

If different generators provide different priority values, the diagram will prefer the generator(s) whose priority is the highest.

◆ mode()

smtk::string::Token smtk::extension::qtDiagram::mode ( ) const

Report the current user interaction mode.

This will be one of: "pan", "select", "connect", or "disconnect"; but the list may be extended in the future.

◆ modeObject()

qtDiagramViewMode * smtk::extension::qtDiagram::modeObject ( ) const

Return the object managing the current mode.

See also
mode

◆ removeArc()

bool smtk::extension::qtDiagram::removeArc ( qtBaseArc arc)

Remove an arc from the diagram's lookup maps.

This requires the arc to have been properly indexed in order to be removed. If removing the arc causes empty entries in either the forward or reverse index, these are removed.

◆ removeNode()

bool smtk::extension::qtDiagram::removeNode ( qtBaseNode node)

Remove a node from the diagram.

This will also remove all arcs attached to the node as well as it's children.

◆ sidebar()

QWidget * smtk::extension::qtDiagram::sidebar ( ) const

Return the sidebar widget.

This method is exposed so that diagram generators can add widgets to the sidebar.

◆ tools()

QToolBar * smtk::extension::qtDiagram::tools ( ) const

Return a toolbar to which modes can add actions/widgets.

Any actions a mode adds to the toolbar should be deleted or hidden when switching away from the mode.

◆ updateQtSelection

void smtk::extension::qtDiagram::updateQtSelection ( )
virtualslot

Called the SMTK's application-wide selection changes.

This is used to update the diagram's selection to match any persistent objects represented as nodes or arcs in the graph.

Note that this method will always overwrite the Qt selection; it does not verify whether the change to the SMTK selection was caused by this object. (That check is performed before this method is invoked.)

◆ updateSMTKSelection

bool smtk::extension::qtDiagram::updateSMTKSelection ( )
virtualslot

Called when the scene's Qt selection changes.

This is used to send the relevant portion of the Qt selection to SMTK. It returns true when the SMTK selection was modified and false otherwise.

◆ visibleBounds()

QRectF smtk::extension::qtDiagram::visibleBounds ( ) const

Return the bounding rect of visible nodes and arcs in the scene.

This only includes nodes and arcs, not other QGraphicsItems.


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