Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSlicerSceneViewsModuleLogic.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 This file was originally developed by Daniel Haehn, UPenn
17 and was partially funded by NIH grant 3P41RR013218-12S1
18
19==============================================================================*/
20
21#ifndef vtkSlicerSceneViewsModuleLogic_h
22#define vtkSlicerSceneViewsModuleLogic_h
23
24// SlicerLogic includes
25#include "vtkSlicerBaseLogic.h"
26
27// MRMLLogic includes
29
30#include "vtkSlicerSceneViewsModuleLogicExport.h"
31// #include "qSlicerSceneViewsModuleExport.h"
32
34
35// MRML includes
39class vtkMRMLTextNode;
41
42// VTK includes
43class vtkImageData;
44
45// STD includes
46#include <string>
47
48class VTK_SLICER_SCENEVIEWS_MODULE_LOGIC_EXPORT vtkSlicerSceneViewsModuleLogic : public vtkSlicerModuleLogic
49{
50public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
56 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
57
59 void RegisterNodes() override;
60
62 void CreateSceneView(std::string name,
63 std::string description = "",
64 int screenshotType = ScreenShotType3D,
65 vtkImageData* screenshot = nullptr,
66 bool saveDisplayNodes = true,
67 bool saveViewNodes = true,
68 vtkMRMLSequenceBrowserNode* sequenceBrowser = nullptr);
69 void CreateSceneView(vtkCollection* savedNodes,
70 std::string name,
71 std::string description = "",
72 int screenshotType = ScreenShotType3D,
73 vtkImageData* screenshot = nullptr,
74 vtkMRMLSequenceBrowserNode* sequenceBrowser = nullptr);
75 void CreateSceneView(std::vector<vtkMRMLNode*> savedNodes,
76 std::string name,
77 std::string description = "",
78 int screenshotType = ScreenShotType3D,
79 vtkImageData* screenshot = nullptr,
80 vtkMRMLSequenceBrowserNode* sequenceBrowser = nullptr);
81
83 int GetSceneViewIndexByName(std::string name);
84
86 void ModifyNthSceneView(int sceneViewIndex, std::string name, std::string, int screenshotType, vtkImageData* screenshot);
87
89
91 void UpdateNthSceneView(int sceneViewIndex, bool updateExistingNodes = true, bool saveDisplayNodes = true, bool saveViewNodes = true);
92 void UpdateNthSceneView(int sceneViewIndex, vtkCollection* savedNodes, bool updateExistingNodes = true);
93 void UpdateNthSceneView(int sceneViewIndex, std::vector<vtkMRMLNode*> savedNodes, bool updateExistingNodes = true);
95
97 int SceneViewIndexToSequenceBrowserIndex(int sceneViewIndex);
98
100
101 void SetNthSceneViewName(int index, std::string name);
102 std::string GetNthSceneViewName(int index);
104
107
109
110 void SetNthSceneViewDescription(int index, std::string description);
111 std::string GetNthSceneViewDescription(int index);
113
115
116 void SetNthSceneViewScreenshotType(int index, int type);
119
121
122 void SetNthSceneViewScreenshot(int index, vtkImageData* screenshot);
123 vtkImageData* GetNthSceneViewScreenshot(int index);
125
127
128 bool RestoreSceneView(int sceneViewIndex);
129 bool RestoreSceneView(std::string sceneViewName);
131
133 std::string MoveSceneViewUp(std::string id);
134
136 std::string MoveSceneViewDown(std::string id);
137
139 bool RemoveSceneView(int index);
140
142 // Attributes and values for marking sequence browsers as scene views.
143 static const char* GetSceneViewNodeAttributeName();
144 static const char* GetSceneViewNodeAttributeValue();
146
148 // Attributes on the screenshot node which contain scene view names, descriptions and screenshot types.
149 static const char* GetSceneViewNameAttributeName();
153
154 // Reference role for screenshot volume node.
156
157 // Returns the sequence browser used to record the scene views. If not found and addMissingNode is true,
158 // then it will be created.
160
161 // Returns the sequence browser for the Nth scene view.
163
164 // Initialize a new scene view sequence browser node.
166
168 enum
169 {
175 };
176
177 enum
178 {
180 };
181
183
184 std::string GetScreenShotTypeAsString(int type);
185 int GetScreenShotTypeFromString(const std::string& type);
187
189
192
194 void GetDisplayNodes(std::vector<vtkMRMLNode*>& displayNodes);
195
197 void GetViewNodes(std::vector<vtkMRMLNode*>& viewNodes);
198
199 void GetDisplayNodeClasses(std::vector<std::string>& displayNodeTypes);
200 std::vector<std::string> GetDisplayNodeClasses();
201
202 void GetViewNodeClasses(std::vector<std::string>& viewNodeTypes);
203 std::vector<std::string> GetViewNodeClasses();
204
205protected:
207
209
211 void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
212 void OnMRMLSceneEndImport() override;
213 void OnMRMLSceneEndRestore() override;
214 void OnMRMLSceneEndClose() override;
215
217 void OnMRMLNodeModified(vtkMRMLNode* node) override;
218
221
224
227
230
232 // Set/Get an attribute on the data node for the Nth scene view.
233 void SetNthNodeAttribute(vtkMRMLNode* proxyTextNode, int index, std::string attributeName, std::string text);
234 std::string GetNthNodeAttribute(vtkMRMLNode* proxyTextNode, int index, std::string attributeName);
236
237protected:
240
243
246
247private:
248 std::string m_StringHolder;
249
250private:
252 void operator=(const vtkSlicerSceneViewsModuleLogic&) = delete;
253};
254
255#endif
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node for representing a sequence of MRML nodes.
MRML node for representing a volume (image stack).
void RegisterNodes() override
Register MRML Node classes to Scene. Gets called automatically when the MRMLScene is attached to this...
std::string GetNthSceneViewDescription(int index)
std::string GetNthNodeAttribute(vtkMRMLNode *proxyTextNode, int index, std::string attributeName)
bool IsSceneViewNode(vtkMRMLNode *node)
Returns true if the node is a scene view node.
void CreateSceneView(std::vector< vtkMRMLNode * > savedNodes, std::string name, std::string description="", int screenshotType=ScreenShotType3D, vtkImageData *screenshot=nullptr, vtkMRMLSequenceBrowserNode *sequenceBrowser=nullptr)
vtkMRMLSequenceNode * GetOrAddSceneViewSequenceNode(vtkMRMLSequenceBrowserNode *sequenceBrowser, vtkMRMLNode *proxyNode)
Returns the sequence node for a given proxy node. Will create a new vtkMRMLSequenceNode if none exist...
void SetNthSceneViewName(int index, std::string name)
Set/Get the name of an existing sceneView.
bool RestoreSceneView(int sceneViewIndex)
Restore a sceneView.
void GetViewNodes(std::vector< vtkMRMLNode * > &viewNodes)
Add all view-related nodes to the vector.
bool RemoveSceneView(int index)
Remove a sceneView.
void CreateSceneView(vtkCollection *savedNodes, std::string name, std::string description="", int screenshotType=ScreenShotType3D, vtkImageData *screenshot=nullptr, vtkMRMLSequenceBrowserNode *sequenceBrowser=nullptr)
void OnMRMLSceneEndImport() override
~vtkSlicerSceneViewsModuleLogic() override
vtkMRMLSequenceBrowserNode * GetSceneViewSequenceBrowserNode(bool addMissingNode)
int GetNthSceneViewScreenshotType(int index)
vtkMRMLSequenceBrowserNode * ConvertSceneViewNodeToSequenceBrowserNode(vtkMRMLSceneViewNode *sceneView, vtkMRMLSequenceBrowserNode *sequenceBrowserNode)
Convert the specified vtkMRMLSceneViewNode to use sequences.
void CreateSceneView(std::string name, std::string description="", int screenshotType=ScreenShotType3D, vtkImageData *screenshot=nullptr, bool saveDisplayNodes=true, bool saveViewNodes=true, vtkMRMLSequenceBrowserNode *sequenceBrowser=nullptr)
Create a sceneView..
void OnMRMLNodeModified(vtkMRMLNode *node) override
Called when a scene view sequence browser node is modified.
static const char * GetSceneViewNodeAttributeName()
static const char * GetSceneViewScreenshotReferenceRole()
void ModifyNthSceneView(int sceneViewIndex, std::string name, std::string, int screenshotType, vtkImageData *screenshot)
Modify the metadata of an existing sceneView.
std::string MoveSceneViewDown(std::string id)
Move sceneView up.
void OnMRMLSceneNodeAdded(vtkMRMLNode *node) override
Called when MRMLScene events are invoked.
vtkImageData * GetNthSceneViewScreenshot(int index)
static const char * GetSceneViewNameAttributeName()
std::vector< std::string > GetViewNodeClasses()
static const char * GetSceneViewDescriptionAttributeName()
void UpdateNthSceneView(int sceneViewIndex, bool updateExistingNodes=true, bool saveDisplayNodes=true, bool saveViewNodes=true)
static vtkSlicerSceneViewsModuleLogic * New()
vtkMRMLVolumeNode * GetNthSceneViewScreenshotDataNode(int index)
Return the screenshot data node in the Nth scene view index.
void ConvertSceneViewNodesToSequenceBrowserNodes(vtkMRMLScene *scene)
Convert all existing vtkMRMLSceneViewNode in the scene to use Sequences.
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
Initialize listening to MRML events.
static const char * GetSceneViewNodeAttributeValue()
int SceneViewIndexToSequenceBrowserIndex(int sceneViewIndex)
Convert the index of the scene view to the corresponding value index of the sequence browser that hol...
std::string GetScreenShotTypeAsString(int type)
Convert string to/from scene view enum type.
void SetNthSceneViewScreenshot(int index, vtkImageData *screenshot)
Set/Get the screenshot of an existing sceneView.
void SetNthSceneViewScreenshotType(int index, int type)
Set/Get the screenshot type of an existing sceneView.
std::string GetNthSceneViewName(int index)
static const char * GetSceneViewScreenshotTypeAttributeName()
int GetScreenShotTypeFromString(const std::string &type)
void GetDisplayNodes(std::vector< vtkMRMLNode * > &displayNodes)
Add all display-related nodes to the vector.
int GetNumberOfSceneViews()
Get the number of sceneViews.
vtkMRMLVolumeNode * GetSceneViewScreenshotProxyNode(vtkMRMLSequenceBrowserNode *sequenceBrowser=nullptr)
Returns the proxy node containing the scene view screenshot.
vtkMRMLSequenceBrowserNode * GetNthSceneViewSequenceBrowserNode(int index)
void GetDisplayNodeClasses(std::vector< std::string > &displayNodeTypes)
vtkMRMLSequenceBrowserNode * AddNewSceneViewSequenceBrowserNode()
void SetNthNodeAttribute(vtkMRMLNode *proxyTextNode, int index, std::string attributeName, std::string text)
vtkMRMLNode * GetNthSceneViewDataNode(int index, vtkMRMLNode *proxyNode)
Return the data node for the specified proxy node in the Nth scene view index.
void PrintSelf(ostream &os, vtkIndent indent) override
void UpdateNthSceneView(int sceneViewIndex, vtkCollection *savedNodes, bool updateExistingNodes=true)
vtkMRMLVolumeNode * GetNthSceneViewScreenshotProxyNode(int index)
Returns the proxy node in the scene for the Nth scene view.
std::string MoveSceneViewUp(std::string id)
Move sceneView up.
void SetNthSceneViewDescription(int index, std::string description)
Set/Get the description of an existing sceneView.
void OnMRMLSceneEndRestore() override
void UpdateNthSceneView(int sceneViewIndex, std::vector< vtkMRMLNode * > savedNodes, bool updateExistingNodes=true)
bool RestoreSceneView(std::string sceneViewName)
void GetViewNodeClasses(std::vector< std::string > &viewNodeTypes)
int GetSceneViewIndexByName(std::string name)
Returns the index for a scene view with the given name. If no matching scene view is found,...
std::vector< std::string > GetDisplayNodeClasses()
void OnMRMLSceneEndClose() override