Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Attributes
qMRMLNodeFactory Class Reference

#include <Libs/MRML/Widgets/qMRMLNodeFactory.h>

Inheritance diagram for qMRMLNodeFactory:
Inheritance graph
[legend]
Collaboration diagram for qMRMLNodeFactory:
Collaboration graph
[legend]

Public Types

typedef QHash< QString, QString > AttributeType
 Convenient typedef. More...
 
typedef QObject Superclass
 Constructors. More...
 

Public Slots

void setMRMLScene (vtkMRMLScene *mrmlScene)
 
Set MRML scene More...
 

Signals

void nodeAdded (vtkMRMLNode *node)
 
void nodeInitialized (vtkMRMLNode *node)
 
void nodeInstantiated (vtkMRMLNode *node)
 

Public Member Functions

Q_INVOKABLE void addAttribute (const QString &attributeName, const QString &attributeValue)
 
Q_INVOKABLE QString attribute (const QString &attributeName) const
 
Q_INVOKABLE QString baseName (const QString &className) const
 
Q_INVOKABLE vtkMRMLNodecreateNode (const QString &className)
 
vtkMRMLScenemrmlScene () const
 
 qMRMLNodeFactory (QObject *parent=nullptr)
 
Q_INVOKABLE void removeAttribute (const QString &attributeName)
 
Q_INVOKABLE void setBaseName (const QString &className, const QString &baseName)
 Base name used to generate a name for create node. More...
 
 ~qMRMLNodeFactory () override
 

Static Public Member Functions

static vtkMRMLNodecreateNode (vtkMRMLScene *scene, const QString &className, const AttributeType &attributes=AttributeType())
 
Convenient method allowing to create a new node and add it to the scene More...
 

Protected Attributes

QScopedPointer< qMRMLNodeFactoryPrivate > d_ptr
 

Detailed Description

Node factory that can be used by qMRML widgets to easily create nodes If you want more control over the node creation, you can add attributes, specify a base node name or connect to signals to customize the node

Definition at line 40 of file qMRMLNodeFactory.h.

Member Typedef Documentation

◆ AttributeType

typedef QHash<QString,QString> qMRMLNodeFactory::AttributeType

Convenient typedef.

Definition at line 46 of file qMRMLNodeFactory.h.

◆ Superclass

Constructors.

Definition at line 49 of file qMRMLNodeFactory.h.

Constructor & Destructor Documentation

◆ qMRMLNodeFactory()

qMRMLNodeFactory::qMRMLNodeFactory ( QObject *  parent = nullptr)
explicit

◆ ~qMRMLNodeFactory()

qMRMLNodeFactory::~qMRMLNodeFactory ( )
override

Member Function Documentation

◆ addAttribute()

Q_INVOKABLE void qMRMLNodeFactory::addAttribute ( const QString &  attributeName,
const QString &  attributeValue 
)

Add attribute that will be passed to any new created node. TODO: Support attributes for more than 1 node class Note: If an attribute already exist, it's value will be overwritten.

◆ attribute()

Q_INVOKABLE QString qMRMLNodeFactory::attribute ( const QString &  attributeName) const

◆ baseName()

Q_INVOKABLE QString qMRMLNodeFactory::baseName ( const QString &  className) const

◆ createNode() [1/2]

Q_INVOKABLE vtkMRMLNode* qMRMLNodeFactory::createNode ( const QString &  className)

Create and add a node given its className to the scene associated with the factory. The function will fire the signals: nodeInstantiated(vtkMRMLNode*), nodeInitialized(vtkMRMLNode*), nodeAdded(vtkMRMLNode*) on that order. It allows the user to add custom steps by connecting slots to the emitted signals. No-op if the scene is 0 or if className is empty/null. However, if className is not empty but invalid (not an existing node), an assert throws an exception. Note: The attributes will be applied to the node before being added into the scene. The scene takes the ownership of the node and is responsible to delete it If the node is a singleton that already exists in the scene, the existing node is returned.

See also
vtkMRMLScene::AddNode

◆ createNode() [2/2]

static vtkMRMLNode* qMRMLNodeFactory::createNode ( vtkMRMLScene scene,
const QString &  className,
const AttributeType attributes = AttributeType() 
)
static


Convenient method allowing to create a new node and add it to the scene

◆ mrmlScene()

vtkMRMLScene* qMRMLNodeFactory::mrmlScene ( ) const

Get MRML scene. By default, there is no scene.

◆ nodeAdded

void qMRMLNodeFactory::nodeAdded ( vtkMRMLNode node)
signal

Fired at the end when the node is added into the scene. It is emitted even if the node has been added to the scene by a custom slot connected to nodeInitialized(vtkMRMLNode*)

◆ nodeInitialized

void qMRMLNodeFactory::nodeInitialized ( vtkMRMLNode node)
signal

Eventually fired by the function createNode You can add the node into the scene directly here. If no slot adds the node into the scene(node->GetScene() == 0), then the node factory takes care of adding the node into the scene (default behavior).

◆ nodeInstantiated

void qMRMLNodeFactory::nodeInstantiated ( vtkMRMLNode node)
signal

Fired right after the instantiation of the node (before any initialization) Connecting to the following signal allows a custom node creation

◆ removeAttribute()

Q_INVOKABLE void qMRMLNodeFactory::removeAttribute ( const QString &  attributeName)

◆ setBaseName()

Q_INVOKABLE void qMRMLNodeFactory::setBaseName ( const QString &  className,
const QString &  baseName 
)

Base name used to generate a name for create node.

◆ setMRMLScene

void qMRMLNodeFactory::setMRMLScene ( vtkMRMLScene mrmlScene)
slot


Set MRML scene

Member Data Documentation

◆ d_ptr

QScopedPointer<qMRMLNodeFactoryPrivate> qMRMLNodeFactory::d_ptr
protected

Definition at line 114 of file qMRMLNodeFactory.h.


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