Slicer  5.0
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 
67  virtual int WriteData(vtkMRMLNode *refNode);
68 
71  void WriteXML(ostream& of, int indent) override;
72 
75  void Copy(vtkMRMLNode *node) override;
76 
79  const char* GetNodeTagName() override = 0;
80 
83  vtkSetStringMacro(FileName);
84  vtkGetStringMacro(FileName);
85 
91  virtual std::string GetSupportedFileExtension(const char* fileName = nullptr, bool includeReadable = true, bool includeWriteable = true);
92 
95  const char *GetNthFileName(int n) const;
96 
99  vtkBooleanMacro(UseCompression, int);
100  vtkGetMacro(UseCompression, int);
101  vtkSetMacro(UseCompression, int);
102 
105  vtkSetStringMacro(URI);
106  vtkGetStringMacro(URI);
107 
108  vtkGetObjectMacro (URIHandler, vtkURIHandler);
109  virtual void SetURIHandler(vtkURIHandler* uriHandler);
110 
113  void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData ) override;
114 
126  enum
127  {
134  SkippedNoData
135  };
136 
138  vtkGetMacro(ReadState,int);
139  vtkSetMacro(ReadState,int);
140  void SetReadStatePending() { this->SetReadState(this->Pending); };
141  void SetReadStateIdle() { this->SetReadState(this->Idle); };
142  void SetReadStateScheduled() { this->SetReadState(this->Scheduled); };
143  void SetReadStateTransferring() { this->SetReadState(this->Transferring); };
144  void SetReadStateTransferDone() { this->SetReadState(this->TransferDone); };
145  void SetReadStateCancelled() { this->SetReadState(this->Cancelled); };
146  void SetReadStateSkippedNoData() { this->SetReadState(this->SkippedNoData); };
147  const char *GetStateAsString(int state);
148  const char *GetReadStateAsString() { return this->GetStateAsString(this->ReadState); };
149 
152  vtkGetMacro(WriteState,int);
153  vtkSetMacro(WriteState,int);
154  void SetWriteStatePending() { this->SetWriteState(this->Pending); };
155  void SetWriteStateIdle() { this->SetWriteState(this->Idle); };
156  void SetWriteStateScheduled() { this->SetWriteState(this->Scheduled); };
157  void SetWriteStateTransferring() { this->SetWriteState(this->Transferring); };
158  void SetWriteStateTransferDone() { this->SetWriteState(this->TransferDone); };
159  void SetWriteStateCancelled() { this->SetWriteState(this->Cancelled); };
160  void SetWriteStateSkippedNoData() { this->SetWriteState(this->SkippedNoData); };
161  const char *GetWriteStateAsString() { return this->GetStateAsString(this->WriteState); };
162 
166  std::string GetFullNameFromFileName();
167  std::string GetFullNameFromNthFileName(int n);
168 
180  virtual int SupportedFileType(const char *fileName);
181 
185  virtual vtkStringArray* GetSupportedReadFileTypes();
186 
190  virtual vtkStringArray* GetSupportedWriteFileTypes();
191 
197  virtual void GetFileExtensionsFromFileTypes(vtkStringArray* inputFileTypes, vtkStringArray* outputFileExtensions);
198 
201  vtkSetStringMacro(WriteFileFormat);
202  vtkGetStringMacro(WriteFileFormat);
203 
206  unsigned int AddFileName (const char *fileName);
209  void ResetFileNameList();
210 
214  {
215  return (int)this->FileNameList.size();
216  };
217 
221  int FileNameIsInList(const char *fileName);
222 
225  unsigned int AddURI(const char *uri);
226 
229  const char *GetNthURI(int n);
230 
233  void ResetURIList();
234 
238  {
239  return (int)this->URIList.size();
240  }
241 
244  void SetDataDirectory(const char* dataDirName);
247  void SetURIPrefix(const char *uriPrefix);
248 
251  virtual const char* GetDefaultWriteFileExtension();
252 
257  virtual void SetDefaultWriteFileExtension(const char* ext);
258 
261  void ResetNthFileName(int n, const char *fileName);
264  void ResetNthURI(int n, const char *uri);
265 
270  int IsFilePathRelative(const char * filepath);
271 
276  const char *GetAbsoluteFilePath(const char *inputPath);
277 
280  vtkSetStringMacro(TempFileName);
281  vtkGetStringMacro(TempFileName);
282 
286  void InvalidateFile();
287 
290  vtkTimeStamp GetStoredTime();
291 
298  virtual bool CanReadInReferenceNode(vtkMRMLNode* refNode) = 0;
304  virtual bool CanWriteFromReferenceNode(vtkMRMLNode* refNode);
305 
310  virtual void ConfigureForDataExchange() {};
311 
314  static std::string GetLowercaseExtensionFromFileName(const std::string& filename);
315 
318  std::string GetFileNameWithoutExtension(const char* fileName = nullptr);
319 
321  vtkSetMacro(CompressionParameter, std::string);
322  vtkGetMacro(CompressionParameter, std::string);
323 
325  virtual std::vector<std::string> GetCompressionPresetDisplayNames();
326 
328  virtual std::string GetCompressionParameterFromDisplayName(const std::string& name);
329 
331  virtual std::string GetDisplayNameFromCompressionParameter(const std::string& preset);
332 
334  virtual int GetNumberOfCompressionPresets();
335 
339  {
340  CompressionPreset() = default;
341 
342  CompressionPreset(const std::string &parameter, const std::string &name)
343  : CompressionParameter(parameter)
344  , DisplayName(name)
345  {
346  }
347 
348  std::string CompressionParameter;
349  std::string DisplayName;
350  };
351 
353  virtual const std::vector<CompressionPreset> GetCompressionPresets();
354 
361  enum
362  {
363  CoordinateSystemRAS = 0,
364  RAS = 0,
365  CoordinateSystemLPS = 1,
366  LPS = 1,
367  CoordinateSystemType_Last
368  };
369 
372  static const char *GetCoordinateSystemTypeAsString(int id);
373  static int GetCoordinateSystemTypeFromString(const char *name);
374 
375  const vtkMRMLMessageCollection *GetUserMessages() const { return this->UserMessages; }
376  vtkMRMLMessageCollection *GetUserMessages() { return this->UserMessages; }
377 
378 protected:
380  ~vtkMRMLStorageNode() override;
382  void operator=(const vtkMRMLStorageNode&);
383 
387  virtual int ReadDataInternal(vtkMRMLNode* refNode);
388 
392  virtual int WriteDataInternal(vtkMRMLNode* refNode);
393 
397  void StageReadData ( vtkMRMLNode *refNode );
398 
402  void StageWriteData ( vtkMRMLNode *refNode );
403 
404  char *FileName;
406  char *URI;
411  std::string CompressionParameter;
412  std::vector<CompressionPreset> CompressionPresets;
413 
416  std::vector<std::string> FileNameList;
419  std::vector<std::string> URIList;
421  vtkStringArray* SupportedReadFileTypes;
422 
425  vtkStringArray* SupportedWriteFileTypes;
427 
430  virtual void InitializeSupportedReadFileTypes();
434  virtual void InitializeSupportedWriteFileTypes();
439  virtual void UpdateCompressionPresets();
440 
445  vtkTimeStamp* StoredTime;
446 
447  vtkWeakPointer<vtkMRMLStorableNode> LastFoundStorableNode;
448 
449  // Record warnings and errors associated with this
450  // vtkMRMLStorableNode.
452 };
453 
454 #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