Slicer  4.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLStorageNode.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkMRMLStorageNode.h,v $
10  Date: $Date: 2006/03/19 17:12:29 $
11  Version: $Revision: 1.3 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkMRMLStorageNode_h
16 #define __vtkMRMLStorageNode_h
17 
18 // MRML includes
19 #include "vtkMRMLNode.h"
20 #include "vtkCommand.h"
23 
24 class vtkURIHandler;
25 
26 // VTK includes
27 class vtkStringArray;
28 
29 // STD includes
30 #include <vector>
31 
35 class VTK_MRML_EXPORT vtkMRMLStorageNode : public vtkMRMLNode
36 {
37 public:
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
41  vtkMRMLNode* CreateNodeInstance() override = 0;
42 
45  virtual vtkMRMLStorableNode* GetStorableNode();
46 
49  void ReadXMLAttributes( const char** atts) override;
50 
60  virtual int ReadData(vtkMRMLNode *refNode, bool temporaryFile = false);
61 
66  virtual int WriteData(vtkMRMLNode *refNode);
67 
70  void WriteXML(ostream& of, int indent) override;
71 
74  void Copy(vtkMRMLNode *node) override;
75 
78  const char* GetNodeTagName() override = 0;
79 
82  vtkSetStringMacro(FileName);
83  vtkGetStringMacro(FileName);
84 
90  virtual std::string GetSupportedFileExtension(const char* fileName = nullptr, bool includeReadable = true, bool includeWriteable = true);
91 
94  const char *GetNthFileName(int n) const;
95 
98  vtkBooleanMacro(UseCompression, int);
99  vtkGetMacro(UseCompression, int);
100  vtkSetMacro(UseCompression, int);
101 
104  vtkSetStringMacro(URI);
105  vtkGetStringMacro(URI);
106 
107  vtkGetObjectMacro (URIHandler, vtkURIHandler);
108  virtual void SetURIHandler(vtkURIHandler* uriHandler);
109 
112  void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData ) override;
113 
125  enum
126  {
133  SkippedNoData
134  };
135 
137  vtkGetMacro(ReadState,int);
138  vtkSetMacro(ReadState,int);
139  void SetReadStatePending() { this->SetReadState(this->Pending); };
140  void SetReadStateIdle() { this->SetReadState(this->Idle); };
141  void SetReadStateScheduled() { this->SetReadState(this->Scheduled); };
142  void SetReadStateTransferring() { this->SetReadState(this->Transferring); };
143  void SetReadStateTransferDone() { this->SetReadState(this->TransferDone); };
144  void SetReadStateCancelled() { this->SetReadState(this->Cancelled); };
145  void SetReadStateSkippedNoData() { this->SetReadState(this->SkippedNoData); };
146  const char *GetStateAsString(int state);
147  const char *GetReadStateAsString() { return this->GetStateAsString(this->ReadState); };
148 
151  vtkGetMacro(WriteState,int);
152  vtkSetMacro(WriteState,int);
153  void SetWriteStatePending() { this->SetWriteState(this->Pending); };
154  void SetWriteStateIdle() { this->SetWriteState(this->Idle); };
155  void SetWriteStateScheduled() { this->SetWriteState(this->Scheduled); };
156  void SetWriteStateTransferring() { this->SetWriteState(this->Transferring); };
157  void SetWriteStateTransferDone() { this->SetWriteState(this->TransferDone); };
158  void SetWriteStateCancelled() { this->SetWriteState(this->Cancelled); };
159  void SetWriteStateSkippedNoData() { this->SetWriteState(this->SkippedNoData); };
160  const char *GetWriteStateAsString() { return this->GetStateAsString(this->WriteState); };
161 
165  std::string GetFullNameFromFileName();
166  std::string GetFullNameFromNthFileName(int n);
167 
179  virtual int SupportedFileType(const char *fileName);
180 
184  virtual vtkStringArray* GetSupportedReadFileTypes();
185 
189  virtual vtkStringArray* GetSupportedWriteFileTypes();
190 
196  virtual void GetFileExtensionsFromFileTypes(vtkStringArray* inputFileTypes, vtkStringArray* outputFileExtensions);
197 
200  vtkSetStringMacro(WriteFileFormat);
201  vtkGetStringMacro(WriteFileFormat);
202 
205  unsigned int AddFileName (const char *fileName);
208  void ResetFileNameList();
209 
213  {
214  return (int)this->FileNameList.size();
215  };
216 
220  int FileNameIsInList(const char *fileName);
221 
224  unsigned int AddURI(const char *uri);
225 
228  const char *GetNthURI(int n);
229 
232  void ResetURIList();
233 
237  {
238  return (int)this->URIList.size();
239  }
240 
243  void SetDataDirectory(const char* dataDirName);
246  void SetURIPrefix(const char *uriPrefix);
247 
250  virtual const char* GetDefaultWriteFileExtension();
251 
256  virtual void SetDefaultWriteFileExtension(const char* ext);
257 
260  void ResetNthFileName(int n, const char *fileName);
263  void ResetNthURI(int n, const char *uri);
264 
269  int IsFilePathRelative(const char * filepath);
270 
275  const char *GetAbsoluteFilePath(const char *inputPath);
276 
279  vtkSetStringMacro(TempFileName);
280  vtkGetStringMacro(TempFileName);
281 
285  void InvalidateFile();
286 
289  vtkTimeStamp GetStoredTime();
290 
297  virtual bool CanReadInReferenceNode(vtkMRMLNode* refNode) = 0;
303  virtual bool CanWriteFromReferenceNode(vtkMRMLNode* refNode);
304 
309  virtual void ConfigureForDataExchange() {};
310 
313  static std::string GetLowercaseExtensionFromFileName(const std::string& filename);
314 
317  std::string GetFileNameWithoutExtension(const char* fileName = nullptr);
318 
320  vtkSetMacro(CompressionParameter, std::string);
321  vtkGetMacro(CompressionParameter, std::string);
322 
324  virtual std::vector<std::string> GetCompressionPresetDisplayNames();
325 
327  virtual std::string GetCompressionParameterFromDisplayName(const std::string& name);
328 
330  virtual std::string GetDisplayNameFromCompressionParameter(const std::string& preset);
331 
333  virtual int GetNumberOfCompressionPresets();
334 
338  {
339  CompressionPreset() = default;
340 
341  CompressionPreset(const std::string &parameter, const std::string &name)
342  : CompressionParameter(parameter)
343  , DisplayName(name)
344  {
345  }
346 
347  std::string CompressionParameter;
348  std::string DisplayName;
349  };
350 
352  virtual const std::vector<CompressionPreset> GetCompressionPresets();
353 
360  enum
361  {
362  CoordinateSystemRAS = 0,
363  RAS = 0,
364  CoordinateSystemLPS = 1,
365  LPS = 1,
366  CoordinateSystemType_Last
367  };
368 
371  static const char *GetCoordinateSystemTypeAsString(int id);
372  static int GetCoordinateSystemTypeFromString(const char *name);
373 
374  const vtkMRMLMessageCollection *GetUserMessages() const { return this->UserMessages; }
375  vtkMRMLMessageCollection *GetUserMessages() { return this->UserMessages; }
376 
377 protected:
379  ~vtkMRMLStorageNode() override;
381  void operator=(const vtkMRMLStorageNode&);
382 
386  virtual int ReadDataInternal(vtkMRMLNode* refNode);
387 
391  virtual int WriteDataInternal(vtkMRMLNode* refNode);
392 
396  void StageReadData ( vtkMRMLNode *refNode );
397 
401  void StageWriteData ( vtkMRMLNode *refNode );
402 
403  char *FileName;
405  char *URI;
410  std::string CompressionParameter;
411  std::vector<CompressionPreset> CompressionPresets;
412 
415  std::vector<std::string> FileNameList;
418  std::vector<std::string> URIList;
420  vtkStringArray* SupportedReadFileTypes;
421 
424  vtkStringArray* SupportedWriteFileTypes;
426 
429  virtual void InitializeSupportedReadFileTypes();
433  virtual void InitializeSupportedWriteFileTypes();
438  virtual void UpdateCompressionPresets();
439 
444  vtkTimeStamp* StoredTime;
445 
446  vtkWeakPointer<vtkMRMLStorableNode> LastFoundStorableNode;
447 
448  // Record warnings and errors associated with this
449  // vtkMRMLStorableNode.
451 };
452 
453 #endif
const vtkMRMLMessageCollection * GetUserMessages() const
vtkWeakPointer< vtkMRMLStorableNode > LastFoundStorableNode
std::vector< std::string > FileNameList
An array of file names, should contain the FileName but may not
vtkMRMLMessageCollection * GetUserMessages()
virtual void ConfigureForDataExchange()
std::string CompressionParameter
int GetNumberOfFileNames() const
See how many file names were generated during ExecuteInformation
vtkMRMLMessageCollection * UserMessages
virtual void ReadXMLAttributes(const char **atts)
void operator=(const vtkMRMLNode &)
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData)
Propagate events generated in mrml.
vtkStringArray * SupportedReadFileTypes
List of supported extensions to read in.
virtual void Copy(vtkMRMLNode *node)
Copy node contents from another node of the same type. Does not copy node ID and Scene. Performs deep copy - an independent copy is created from all data, including bulk data.
MRML node to represent a 3D surface model.
vtkStringArray * SupportedWriteFileTypes
A superclass for other storage nodes.
virtual void WriteXML(ostream &of, int indent)
vtkURIHandler * URIHandler
std::string DefaultWriteFileExtension
List of supported extensions to write in.
const char * GetWriteStateAsString()
vtkTimeStamp * StoredTime
std::vector< std::string > URIList
An array of URI&#39;s, should contain the URI but may not
void PrintSelf(ostream &os, vtkIndent indent) override
CompressionPreset(const std::string &parameter, const std::string &name)
virtual const char * GetNodeTagName()=0
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
std::vector< CompressionPreset > CompressionPresets
const char * GetReadStateAsString()
int GetNumberOfURIs()
Return how many uri names this storage node holds in it&#39;s list