Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLNodeFactory.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware Inc.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16==============================================================================*/
17
18#ifndef __vtkMRMLNodeFactory_h
19#define __vtkMRMLNodeFactory_h
20
21// MRML includes
22#include "vtkMRML.h"
23
24// VTK includes
25#include <vtkCommand.h>
26#include <vtkObject.h>
27
28// STD includes
29#include <map>
30#include <string>
31#include <vector>
32
33class vtkMRMLNode;
34
44class VTK_MRML_EXPORT vtkMRMLNodeFactory : public vtkObject
45{
46public:
48 vtkTypeMacro(vtkMRMLNodeFactory, vtkObject);
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
51 enum
52 {
54 NodeClassRegisteredEvent = vtkCommand::UserEvent + 1
55 };
56
59
63 void RegisterNodeClass(vtkMRMLNode* node, const char* tagName);
64
67
69 void RegisterAbstractNodeClass(const std::string& className, const std::string& typeDisplayName);
70
74
77 vtkMRMLNode* CreateNodeByClass(const char* className);
78
81 const char* GetClassNameByTag(const char* tagName);
82
85 const char* GetTagByClassName(const char* className);
86
88 std::string GetTypeDisplayNameByClassName(const std::string& className);
89
95 bool IsNodeClassRegistered(const std::string& className);
96
103
104protected:
108 void operator=(const vtkMRMLNodeFactory&) = delete;
109
110 std::vector<vtkMRMLNode*> RegisteredNodeClasses;
111 std::vector<std::string> RegisteredNodeTags;
112 std::map<std::string, std::string> RegisteredAbstractNodeClassTypeDisplayNames; // map class name to type display name
113};
114
115#endif
void CopyRegisteredNodeClasses(vtkMRMLNodeFactory *sourceFactory)
void RegisterNodeClass(vtkMRMLNode *node)
Register a node class with the node's GetNodeTagName() as tag.
void RegisterAbstractNodeClass(const std::string &className, const std::string &typeDisplayName)
Register type display name of an abstract node class (e.g., "Volume"), for node selectors.
std::string GetNthRegisteredAbstractNodeTypeDisplayName(int n)
Get the type display name of the nth registered abstract node class.
int GetNumberOfRegisteredAbstractNodeClasses()
Get the number of registered abstract node classes.
std::map< std::string, std::string > RegisteredAbstractNodeClassTypeDisplayNames
void RegisterCoreNodeClasses()
Register the built-in node classes of the MRML core library.
void PrintSelf(ostream &os, vtkIndent indent) override
vtkMRMLNode * GetNthRegisteredNodeClass(int n)
Get the prototype of the nth registered node class. Returns nullptr if n is out of range.
std::vector< std::string > RegisteredNodeTags
~vtkMRMLNodeFactory() override
std::vector< vtkMRMLNode * > RegisteredNodeClasses
vtkMRMLNodeFactory(const vtkMRMLNodeFactory &)=delete
std::string GetNthRegisteredAbstractNodeClassName(int n)
Get the class name of the nth registered abstract node class.
int GetNumberOfRegisteredNodeClasses()
Get the number of registered node classes.
bool IsNodeClassRegistered(const std::string &className)
Return true if className is a registered node class.
static vtkMRMLNodeFactory * New()
@ NodeClassRegisteredEvent
Invoked when a node class or an abstract node class is registered.
const char * GetClassNameByTag(const char *tagName)
std::string GetTypeDisplayNameByClassName(const std::string &className)
Get the type name shown in the GUI. Returns empty string if the class is not registered.
const char * GetTagByClassName(const char *className)
void operator=(const vtkMRMLNodeFactory &)=delete
void RegisterNodeClass(vtkMRMLNode *node, const char *tagName)
vtkMRMLNode * CreateNodeByClass(const char *className)
Abstract Superclass for all specific types of MRML nodes.