Slicer 5.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
24class vtkURIHandler;
25
26// VTK includes
27class vtkStringArray;
28
29// STD includes
30#include <vector>
31
35class VTK_MRML_EXPORT vtkMRMLStorageNode : public vtkMRMLNode
36{
37public:
39 void PrintSelf(ostream& os, vtkIndent indent) override;
40
42
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 void SetFileName(const std::string& fileName) { this->SetFileName(fileName.c_str()); };
86
92 virtual std::string GetSupportedFileExtension(const char* fileName = nullptr, bool includeReadable = true, bool includeWriteable = true);
93
96 const char* GetNthFileName(int n) const;
97
100 vtkBooleanMacro(UseCompression, int);
101 vtkGetMacro(UseCompression, int);
102 vtkSetMacro(UseCompression, int);
103
106 vtkSetStringMacro(URI);
107 vtkGetStringMacro(URI);
108
109 vtkGetObjectMacro(URIHandler, vtkURIHandler);
110 virtual void SetURIHandler(vtkURIHandler* uriHandler);
111
114 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
115
127 enum
128 {
136 };
137
139
140 vtkGetMacro(ReadState, int);
141 vtkSetMacro(ReadState, int);
142 void SetReadStatePending() { this->SetReadState(this->Pending); };
143 void SetReadStateIdle() { this->SetReadState(this->Idle); };
149 const char* GetStateAsString(int state);
150 const char* GetReadStateAsString() { return this->GetStateAsString(this->ReadState); };
152
154
156 vtkGetMacro(WriteState, int);
157 void SetWriteState(int writeState);
159 void SetWriteStateIdle() { this->SetWriteState(this->Idle); };
165 const char* GetWriteStateAsString() { return this->GetStateAsString(this->WriteState); };
167
172 std::string GetFullNameFromNthFileName(int n);
173
185 virtual int SupportedFileType(const char* fileName);
186 int SupportedFileType(const std::string& fileName) { return this->SupportedFileType(fileName.c_str()); }
190 virtual vtkStringArray* GetSupportedReadFileTypes();
191
195 virtual vtkStringArray* GetSupportedWriteFileTypes();
196
202 virtual void GetFileExtensionsFromFileTypes(vtkStringArray* inputFileTypes, vtkStringArray* outputFileExtensions);
203
205
207 virtual void SetWriteFileFormat(const char* writeFileFormat);
208 vtkGetStringMacro(WriteFileFormat);
210
213 unsigned int AddFileName(const char* fileName);
214 unsigned int AddFileName(const std::string& fileName) { return this->AddFileName(fileName.c_str()); };
215
219
222 int GetNumberOfFileNames() const { return (int)this->FileNameList.size(); };
223
227 int FileNameIsInList(const char* fileName);
228
231 unsigned int AddURI(const char* uri);
232
235 const char* GetNthURI(int n);
236
240
243 int GetNumberOfURIs() { return (int)this->URIList.size(); }
244
247 void SetDataDirectory(const char* dataDirName);
250 void SetURIPrefix(const char* uriPrefix);
251
255 virtual const char* GetDefaultWriteFileExtension();
256
261 virtual void SetDefaultWriteFileExtension(const char* ext);
262
265 void ResetNthFileName(int n, const char* fileName);
268 void ResetNthURI(int n, const char* uri);
269
274 int IsFilePathRelative(const char* filepath);
275
280 const char* GetAbsoluteFilePath(const char* inputPath);
281
284 vtkSetStringMacro(TempFileName);
285 vtkGetStringMacro(TempFileName);
286
291
294 vtkTimeStamp GetStoredTime();
295
302 virtual bool CanReadInReferenceNode(vtkMRMLNode* refNode) = 0;
309
314 virtual void ConfigureForDataExchange() {};
315
318 static std::string GetLowercaseExtensionFromFileName(const std::string& filename);
319
322 std::string GetFileNameWithoutExtension(const char* fileName = nullptr);
323 std::string GetFileNameWithoutExtension(const std::string& fileName) { return GetFileNameWithoutExtension(fileName.c_str()); }
324
326 vtkSetMacro(CompressionParameter, std::string);
327 vtkGetMacro(CompressionParameter, std::string);
328
330 virtual std::vector<std::string> GetCompressionPresetDisplayNames();
331
333 virtual std::string GetCompressionParameterFromDisplayName(const std::string& name);
334
336 virtual std::string GetDisplayNameFromCompressionParameter(const std::string& preset);
337
340
344 {
345 CompressionPreset() = default;
346
347 CompressionPreset(const std::string& parameter, const std::string& name)
348 : CompressionParameter(parameter)
349 , DisplayName(name)
350 {
351 }
352
354 std::string DisplayName;
355 };
356
358 virtual const std::vector<CompressionPreset> GetCompressionPresets();
359
366 enum
367 {
369 RAS = 0,
371 LPS = 1,
373 };
374
377 static const char* GetCoordinateSystemTypeAsString(int id);
378 static int GetCoordinateSystemTypeFromString(const char* name);
379
382
384
391 static std::string ClampFileName(const std::string& filename, int extensionLength, int maxFileNameLength, int hashLength = 4);
393
408
409protected:
414
418 virtual int ReadDataInternal(vtkMRMLNode* refNode);
419
423 virtual int WriteDataInternal(vtkMRMLNode* refNode);
424
429
434
435 char* FileName;
437 char* URI;
443 std::vector<CompressionPreset> CompressionPresets;
444
447 std::vector<std::string> FileNameList;
450 std::vector<std::string> URIList;
452 vtkStringArray* SupportedReadFileTypes;
453
456 vtkStringArray* SupportedWriteFileTypes;
458
471
476 vtkTimeStamp* StoredTime;
477
478 vtkWeakPointer<vtkMRMLStorableNode> LastFoundStorableNode;
479
480 // Record warnings and errors associated with this
481 // vtkMRMLStorableNode.
483};
484
485#endif
MRML node to represent a 3D surface model.
static const char * GetCoordinateSystemTypeAsString(int id)
Convert between coordinate system ID and name.
vtkStringArray * SupportedWriteFileTypes
void Copy(vtkMRMLNode *node) override
Copy the node's attributes to this object.
const char * GetNodeTagName() override=0
Get node XML tag name (like Storage, Model)
const char * GetNthURI(int n)
Get the nth URI from the list of URI's.
virtual int WriteData(vtkMRMLNode *refNode)
void ResetNthFileName(int n, const char *fileName)
Set the nth file in FileNameList, checks that it is already defined.
virtual std::string GetSupportedFileExtension(const char *fileName=nullptr, bool includeReadable=true, bool includeWriteable=true)
void SetURIPrefix(const char *uriPrefix)
Set a new URI base for all URI's.
vtkMRMLMessageCollection * GetUserMessages()
virtual vtkStringArray * GetSupportedWriteFileTypes()
virtual void SetWriteFileFormat(const char *writeFileFormat)
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file.
virtual void UpdateCompressionPresets()
void ResetURIList()
Clear the array of URIs.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
virtual int GetNumberOfCompressionPresets()
Get the number of compression presets.
std::vector< std::string > URIList
An array of URI's, should contain the URI but may not.
static std::string GetLowercaseExtensionFromFileName(const std::string &filename)
virtual void SetURIHandler(vtkURIHandler *uriHandler)
~vtkMRMLStorageNode() override
std::string GetFileNameWithoutExtension(const char *fileName=nullptr)
virtual int ReadDataInternal(vtkMRMLNode *refNode)
vtkTimeStamp * StoredTime
unsigned int AddFileName(const std::string &fileName)
const char * GetNthFileName(int n) const
return the nth file name, null if doesn't exist
virtual std::string GetDisplayNameFromCompressionParameter(const std::string &preset)
Returns the name of the specified preset.
unsigned int AddURI(const char *uri)
Add in another URI to the list of URI's.
std::string CompressionParameter
virtual vtkStringArray * GetSupportedReadFileTypes()
void PrintSelf(ostream &os, vtkIndent indent) override
virtual int WriteDataInternal(vtkMRMLNode *refNode)
const vtkMRMLMessageCollection * GetUserMessages() const
std::vector< CompressionPreset > CompressionPresets
virtual void ConfigureForDataExchange()
std::string GetFullNameFromFileName()
vtkMRMLMessageCollection * UserMessages
const char * GetStateAsString(int state)
vtkTimeStamp GetStoredTime()
virtual std::vector< std::string > GetCompressionPresetDisplayNames()
Returns a list of displayable names of the supported compression presets.
vtkMRMLStorageNode(const vtkMRMLStorageNode &)
vtkStringArray * SupportedReadFileTypes
List of supported extensions to read in.
unsigned int AddFileName(const char *fileName)
Add in another file name to the list of file names.
std::vector< std::string > FileNameList
An array of file names, should contain the FileName but may not.
vtkWeakPointer< vtkMRMLStorableNode > LastFoundStorableNode
std::string GetFileNameWithoutExtension(const std::string &fileName)
int FileNameIsInList(const char *fileName)
void ResetNthURI(int n, const char *uri)
Set the nth URI in URIList, checks that it is already defined.
void SetWriteState(int writeState)
std::string GetFullNameFromNthFileName(int n)
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Propagate Progress Event generated in ReadData.
virtual int SupportedFileType(const char *fileName)
int GetNumberOfFileNames() const
See how many file names were generated during ExecuteInformation.
virtual bool CanWriteFromReferenceNode(vtkMRMLNode *refNode)
virtual void InitializeSupportedWriteFileTypes()
const char * GetWriteStateAsString()
static std::string ClampFileName(const std::string &filename, int extensionLength, int maxFileNameLength, int hashLength=4)
void ResetFileNameList()
Clear the array of file names.
virtual vtkMRMLStorableNode * GetStorableNode()
std::string DefaultWriteFileExtension
List of supported extensions to write in.
void SetFileName(const std::string &fileName)
virtual std::string GetCompressionParameterFromDisplayName(const std::string &name)
Returns a string representing the specified preset.
vtkURIHandler * URIHandler
void SetDataDirectory(const char *dataDirName)
Set a new data directory for all files.
const char * GetReadStateAsString()
vtkMRMLNode * CreateNodeInstance() override=0
Create instance of the default node. Like New only virtual.
virtual const char * GetDefaultWriteFileExtension()
static int GetCoordinateSystemTypeFromString(const char *name)
virtual const std::vector< CompressionPreset > GetCompressionPresets()
Get a list of all supported compression presets.
int GetNumberOfURIs()
Return how many URI names this storage node holds in it's list.
int SupportedFileType(const std::string &fileName)
virtual void GetFileExtensionsFromFileTypes(vtkStringArray *inputFileTypes, vtkStringArray *outputFileExtensions)
int IsFilePathRelative(const char *filepath)
@ RAS
for backward compatibility
@ LPS
for backward compatibility
virtual void SetReadState(int)
void StageWriteData(vtkMRMLNode *refNode)
virtual bool CanReadInReferenceNode(vtkMRMLNode *refNode)=0
void operator=(const vtkMRMLStorageNode &)
virtual void InitializeSupportedReadFileTypes()
void StageReadData(vtkMRMLNode *refNode)
virtual void SetDefaultWriteFileExtension(const char *ext)
virtual int ReadData(vtkMRMLNode *refNode, bool temporaryFile=false)
const char * GetAbsoluteFilePath(const char *inputPath)
CompressionPreset(const std::string &parameter, const std::string &name)