Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLSequenceBrowserNode.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 Csaba Pinter, PerkLab, Queen's University
17 and was supported through the Applied Cancer Research Unit program of Cancer Care
18 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
19
20==============================================================================*/
21
22#ifndef __vtkMRMLSequenceBrowserNode_h
23#define __vtkMRMLSequenceBrowserNode_h
24
25#include "vtkSlicerSequencesModuleMRMLExport.h"
26
27// MRML includes
28#include <vtkMRML.h>
29#include <vtkMRMLNode.h>
30#include <vtkNew.h>
31
32// STD includes
33#include <set>
34#include <map>
35
36class vtkCollection;
38class vtkIntArray;
39
40class VTK_SLICER_SEQUENCES_MODULE_MRML_EXPORT vtkMRMLSequenceBrowserNode : public vtkMRMLNode
41{
42public:
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
48 enum
49 {
50 ProxyNodeModifiedEvent = 21001,
51 IndexDisplayFormatModifiedEvent
52 };
53
55 // Enum is used so that in the future more modes can be added (e.g., fixed frame rate,
56 // fixed frame rate matching playback frame rate, etc).
58 {
59 SamplingAll = 0,
61 NumberOfRecordingSamplingModes // this line must be the last one
62 };
63
66 {
67 IndexDisplayAsIndex = 0,
69 NumberOfIndexDisplayModes // this line must be the last one
70 };
71
74
76 void ReadXMLAttributes( const char** atts) override;
77
79 void WriteXML(ostream& of, int indent) override;
80
82 void Copy(vtkMRMLNode *node) override;
83
85 const char* GetNodeTagName() override {return "SequenceBrowser";};
86
89 std::string SetAndObserveMasterSequenceNodeID(const char *sequenceNodeID);
92
94 std::string AddSynchronizedSequenceNode(const char* synchronizedSequenceNodeId);
95
97 std::string AddSynchronizedSequenceNodeID(const char* synchronizedSequenceNodeId);
98
100 std::string AddSynchronizedSequenceNode(vtkMRMLSequenceNode* synchronizedSequenceNode);
101
103 void RemoveSynchronizedSequenceNode(const char* nodeId);
104
107
109 void GetSynchronizedSequenceNodes(std::vector< vtkMRMLSequenceNode* > &synchronizedDataNodes, bool includeMasterNode=false);
110 void GetSynchronizedSequenceNodes(vtkCollection* synchronizedDataNodes, bool includeMasterNode=false);
111
113 int GetNumberOfSynchronizedSequenceNodes(bool includeMasterNode = false);
114
116 bool IsSynchronizedSequenceNode(const char* sequenceNodeId, bool includeMasterNode = false);
117
119 bool IsSynchronizedSequenceNodeID(const char* sequenceNodeId, bool includeMasterNode = false);
120 bool IsSynchronizedSequenceNode(vtkMRMLSequenceNode* sequenceNode, bool includeMasterNode = false);
121
123 vtkGetMacro(PlaybackActive, bool);
124 vtkSetMacro(PlaybackActive, bool);
125 vtkBooleanMacro(PlaybackActive, bool);
126
128 vtkGetMacro(PlaybackRateFps, double);
129 vtkSetMacro(PlaybackRateFps, double);
130
132 vtkGetMacro(PlaybackItemSkippingEnabled, bool);
133 vtkSetMacro(PlaybackItemSkippingEnabled, bool);
134 vtkBooleanMacro(PlaybackItemSkippingEnabled, bool);
135
137 vtkGetMacro(PlaybackLooped, bool);
138 vtkSetMacro(PlaybackLooped, bool);
139 vtkBooleanMacro(PlaybackLooped, bool);
140
142 vtkGetMacro(SelectedItemNumber, int);
143 vtkSetMacro(SelectedItemNumber, int);
144
146 vtkGetMacro(RecordingActive, bool);
147 void SetRecordingActive(bool recording);
148 vtkBooleanMacro(RecordingActive, bool);
149
151 vtkGetMacro(RecordMasterOnly, bool);
152 vtkSetMacro(RecordMasterOnly, bool);
153 vtkBooleanMacro(RecordMasterOnly, bool);
154
156 vtkSetMacro(RecordingSamplingMode, int);
157 void SetRecordingSamplingModeFromString(const char *recordingSamplingModeString);
159 vtkGetMacro(RecordingSamplingMode, int);
160 virtual std::string GetRecordingSamplingModeAsString();
161
163 static std::string GetRecordingSamplingModeAsString(int recordingSamplingMode);
164 static int GetRecordingSamplingModeFromString(const std::string &recordingSamplingModeString);
165
167 vtkSetMacro(IndexDisplayMode, int);
168 void SetIndexDisplayModeFromString(const char *indexDisplayModeString);
170 vtkGetMacro(IndexDisplayMode, int);
171 virtual std::string GetIndexDisplayModeAsString();
172
174 void SetIndexDisplayFormat(std::string displayFormat);
176 vtkGetMacro(IndexDisplayFormat, std::string);
177
179 static std::string GetIndexDisplayModeAsString(int indexDisplayMode);
180 static int GetIndexDisplayModeFromString(const std::string &indexDisplayModeString);
181
183 int SelectNextItem(int selectionIncrement=1);
184
187
190
193
195 vtkMRMLNode* AddProxyNode(vtkMRMLNode* sourceProxyNode, vtkMRMLSequenceNode* sequenceNode, bool copy=true);
196
199
202 {
203 static bool warningLogged = false;
204 if (!warningLogged)
205 {
206 vtkWarningMacro("vtkMRMLSequenceBrowserNode::GetVirtualOutputDataNode is deprecated, use vtkMRMLSequenceBrowserNode::GetProxyNode method instead");
207 warningLogged = true;
208 }
209 return this->GetProxyNode(sequenceNode);
210 }
211
213 void SetOverwriteTargetNodeName(bool overwrite)
214 {
215 static bool warningLogged = false;
216 if (!warningLogged)
217 {
218 vtkWarningMacro("vtkMRMLSequenceBrowserNode::SetOverwriteTargetNodeName is deprecated,"
219 << " use vtkMRMLSequenceBrowserNode::SetOverwriteProxyName method instead");
220 warningLogged = true;
221 }
222 this->SetOverwriteProxyName(nullptr, overwrite);
223 }
224
226 void SetDeepCopyVirtualNodes(bool deepcopy)
227 {
228 static bool warningLogged = false;
229 if (!warningLogged)
230 {
231 vtkWarningMacro("vtkMRMLSequenceBrowserNode::SetDeepCopyVirtualNodes is deprecated, use vtkMRMLSequenceBrowserNode::SetSaveChanges method instead");
232 warningLogged = true;
233 }
234 this->SetSaveChanges(nullptr, !deepcopy);
235 }
236
239
240 void GetAllProxyNodes(std::vector< vtkMRMLNode* > &nodes);
241 void GetAllProxyNodes(vtkCollection* nodes);
242
243
245 void GetAllVirtualOutputDataNodes(vtkCollection* nodes)
246 {
247 static bool warningLogged = false;
248 if (!warningLogged)
249 {
250 vtkWarningMacro("vtkMRMLSequenceBrowserNode::GetAllVirtualOutputDataNodes is deprecated,"
251 << " use vtkMRMLSequenceBrowserNode::GetAllProxyNodes method instead");
252 warningLogged = true;
253 }
254 this->GetAllProxyNodes(nodes);
255 }
256
258 bool IsProxyNode(const char* nodeId);
259
261 bool IsProxyNodeID(const char* nodeId);
262
263 // TODO: Should these methods be protected? Probably the "world" shouldn't need to know about the postfixes.
264 void RemoveProxyNode(const std::string& postfix);
265
267
270
273 bool GetPlayback(vtkMRMLSequenceNode* sequenceNode);
282
284 void SetRecording(vtkMRMLSequenceNode* sequenceNode, bool recording);
285 void SetPlayback(vtkMRMLSequenceNode* sequenceNode, bool playback);
286 void SetOverwriteProxyName(vtkMRMLSequenceNode* sequenceNode, bool overwrite);
287 void SetSaveChanges(vtkMRMLSequenceNode* sequenceNode, bool save);
288
290 void ProcessMRMLEvents( vtkObject *caller, unsigned long event, void *callData ) override;
291
293 virtual void SaveProxyNodesState();
294
297 std::string GetFormattedIndexValue(int index);
298
302 static bool ValidateFormatString(std::string& validatedFormat, std::string& prefix, std::string& suffix,
303 const std::string& requestedFormat, const std::string& typeString);
304
305protected:
310
314
316 void OnNodeReferenceAdded(vtkMRMLNodeReference* nodeReference) override;
317
319 void OnNodeReferenceRemoved(vtkMRMLNodeReference* nodeReference) override;
320
323 std::string GetSynchronizationPostfixFromSequenceID(const char* sequenceNodeID);
324
325protected:
326 bool PlaybackActive{false};
327 double PlaybackRateFps{10.0};
328 bool PlaybackItemSkippingEnabled{true};
329 bool PlaybackLooped{true};
330 int SelectedItemNumber{-1};
331
332 bool RecordingActive{false};
333 double RecordingTimeOffsetSec; // difference between universal time and index value
335 bool RecordMasterOnly{false};
339
340 // Unique postfixes for storing references to sequence nodes, proxy nodes, and properties
341 // For example, a sequence node reference role name is SEQUENCE_NODE_REFERENCE_ROLE_BASE+synchronizationPostfix
342 std::vector< std::string > SynchronizationPostfixes;
343
344 // Counter that is used for generating the unique (only for this class) proxy node postfix strings
345 int LastPostfixIndex{0};
346
347private:
348 struct SynchronizationProperties;
349 std::map< std::string, SynchronizationProperties* > SynchronizationPropertiesMap;
350 SynchronizationProperties* GetSynchronizationPropertiesForSequence(vtkMRMLSequenceNode* sequenceNode);
351 SynchronizationProperties* GetSynchronizationPropertiesForPostfix(const std::string& rolePostfix);
352};
353
354#endif
Class to hold information about a node reference.
Abstract Superclass for all specific types of MRML nodes.
void ReadXMLAttributes(const char **atts) override
Set node attributes from name/value pairs.
void GetSynchronizedSequenceNodes(std::vector< vtkMRMLSequenceNode * > &synchronizedDataNodes, bool includeMasterNode=false)
Returns all synchronized sequence nodes (does not include the master sequence node)
void RemoveAllSequenceNodes()
Remove all sequence nodes (including the master sequence node)
virtual std::string GetIndexDisplayModeAsString()
std::string AddSynchronizedSequenceNodeID(const char *synchronizedSequenceNodeId)
Adds a node for synchronized browsing. Returns the new proxy node postfix.
void SetRecordingActive(bool recording)
bool GetOverwriteProxyName(vtkMRMLSequenceNode *sequenceNode)
Overwrite proxy node name with name automatically generated from sequence base name and current item ...
void GetAllProxyNodes(std::vector< vtkMRMLNode * > &nodes)
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void OnNodeReferenceRemoved(vtkMRMLNodeReference *nodeReference) override
Called whenever a node reference is removed.
const char * GetNodeTagName() override
Get unique node XML tag name (like Volume, Model)
std::string AddSynchronizedSequenceNode(vtkMRMLSequenceNode *synchronizedSequenceNode)
Adds a node for synchronized browsing. Returns the new proxy node postfix.
vtkMRMLSequenceBrowserNode(const vtkMRMLSequenceBrowserNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
void Copy(vtkMRMLNode *node) override
Copy the node's attributes to this object.
vtkMRMLNode * CreateNodeInstance() override
Create instance of a GAD node.
std::string GetSynchronizationPostfixFromSequenceID(const char *sequenceNodeID)
std::vector< std::string > SynchronizationPostfixes
void SetRecording(vtkMRMLSequenceNode *sequenceNode, bool recording)
Set the synchronization properties for the given sequence/proxy tuple.
void SetDeepCopyVirtualNodes(bool deepcopy)
Deprecated method!
void SetIndexDisplayModeFromString(const char *indexDisplayModeString)
bool IsSynchronizedSequenceNode(const char *sequenceNodeId, bool includeMasterNode=false)
Deprecated. Use IsSynchronizedSequenceNodeID instead.
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Process MRML node events for recording of the proxy nodes.
void GetAllVirtualOutputDataNodes(vtkCollection *nodes)
Deprecated method!
int SelectLastItem()
Selects last sequence item for display, returns current selected item number.
virtual std::string GetRecordingSamplingModeAsString()
void GetSynchronizedSequenceNodes(vtkCollection *synchronizedDataNodes, bool includeMasterNode=false)
void OnNodeReferenceAdded(vtkMRMLNodeReference *nodeReference) override
Called whenever a new node reference is added.
void SetOverwriteProxyName(vtkMRMLSequenceNode *sequenceNode, bool overwrite)
static std::string GetRecordingSamplingModeAsString(int recordingSamplingMode)
Helper functions for converting between string and code representation of recording sampling modes.
vtkMRMLNode * GetVirtualOutputDataNode(vtkMRMLSequenceNode *sequenceNode)
Deprecated method!
std::string GetFormattedIndexValue(int index)
int SelectNextItem(int selectionIncrement=1)
Selects the next sequence item for display, returns current selected item number.
bool GetSaveChanges(vtkMRMLSequenceNode *sequenceNode)
int GetNumberOfItems()
Returns number of items in the sequence (number of data nodes in master sequence node)
bool GetRecording(vtkMRMLSequenceNode *sequenceNode)
Get the synchronization properties for the given sequence/proxy tuple.
bool IsProxyNodeID(const char *nodeId)
Returns true if the nodeId belongs to a proxy node managed by this browser node.
vtkMRMLNode * GetProxyNode(vtkMRMLSequenceNode *sequenceNode)
Get proxy corresponding to a sequence node.
bool IsProxyNode(const char *nodeId)
Deprecated. Use IsProxyNodeID instead.
void SetPlayback(vtkMRMLSequenceNode *sequenceNode, bool playback)
void operator=(const vtkMRMLSequenceBrowserNode &)
vtkMRMLSequenceNode * GetSequenceNode(vtkMRMLNode *proxyNode)
Get sequence node corresponding to a proxy node.
std::string AddSynchronizedSequenceNode(const char *synchronizedSequenceNodeId)
Deprecated. Use AddSynchronizedSequenceNodeID instead.
bool IsAnySequenceNodeRecording()
Returns true if any of the sequence node is allowed to record.
void SetSaveChanges(vtkMRMLSequenceNode *sequenceNode, bool save)
bool GetPlayback(vtkMRMLSequenceNode *sequenceNode)
int GetNumberOfSynchronizedSequenceNodes(bool includeMasterNode=false)
Returns number of synchronized sequence nodes.
void GetAllProxyNodes(vtkCollection *nodes)
void RemoveSynchronizedSequenceNode(const char *nodeId)
Removes a node from synchronized browsing.
static vtkMRMLSequenceBrowserNode * New()
static int GetRecordingSamplingModeFromString(const std::string &recordingSamplingModeString)
bool IsSynchronizedSequenceNodeID(const char *sequenceNodeId, bool includeMasterNode=false)
Returns true if the node is selected for synchronized browsing.
std::string GetSynchronizationPostfixFromSequence(vtkMRMLSequenceNode *sequenceNode)
void SetIndexDisplayFormat(std::string displayFormat)
Set format of index value display (used if index type is numeric)
IndexDisplayModeType
Modes displaying index for the user.
void RemoveProxyNode(const std::string &postfix)
static int GetIndexDisplayModeFromString(const std::string &indexDisplayModeString)
~vtkMRMLSequenceBrowserNode() override
void SetRecordingSamplingModeFromString(const char *recordingSamplingModeString)
static std::string GetIndexDisplayModeAsString(int indexDisplayMode)
Helper functions for converting between string and code representation of index display modes.
bool IsSynchronizedSequenceNode(vtkMRMLSequenceNode *sequenceNode, bool includeMasterNode=false)
void SetOverwriteTargetNodeName(bool overwrite)
Deprecated method!
vtkMRMLSequenceNode * GetMasterSequenceNode()
Get the sequence data node.
std::string SetAndObserveMasterSequenceNodeID(const char *sequenceNodeID)
virtual void SaveProxyNodesState()
Save state of all proxy nodes that recording is enabled for.
std::string GenerateSynchronizationPostfix()
vtkMRMLNode * AddProxyNode(vtkMRMLNode *sourceProxyNode, vtkMRMLSequenceNode *sequenceNode, bool copy=true)
Adds proxy nodes from another scene (typically from the main scene). The data node is optionally copi...
int SelectFirstItem()
Selects first sequence item for display, returns current selected item number.
RecordingSamplingModeType
Modes for determining recording frame rate.
static bool ValidateFormatString(std::string &validatedFormat, std::string &prefix, std::string &suffix, const std::string &requestedFormat, const std::string &typeString)
MRML node for representing a sequence of MRML nodes.