Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLTableStorageNode.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Portions (c) Copyright 2015 Brigham and Women's Hospital (BWH) All Rights Reserved.
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 Andras Lasso (PerkLab, Queen's
17  University) and Kevin Wang (Princess Margaret Hospital, Toronto) and was
18  supported through OCAIRO and the Applied Cancer Research Unit program of
19  Cancer Care Ontario.
20 
21 ==============================================================================*/
22 
23 #ifndef __vtkMRMLTableStorageNode_h
24 #define __vtkMRMLTableStorageNode_h
25 
26 #include "vtkMRMLStorageNode.h"
27 
28 class vtkMRMLTableNode;
29 class vtkTable;
30 
44 class VTK_MRML_EXPORT vtkMRMLTableStorageNode : public vtkMRMLStorageNode
45 {
46 public:
47  static vtkMRMLTableStorageNode *New();
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
51  vtkMRMLNode* CreateNodeInstance() override;
52 
54  const char* GetNodeTagName() override {return "TableStorage";}
55 
57  bool CanReadInReferenceNode(vtkMRMLNode *refNode) override;
58 
60  virtual void SetSchemaFileName(const char* schemaFileName);
61  virtual std::string GetSchemaFileName();
62 
64  std::string FindSchemaFileName(const char* fileName);
65 
68  vtkSetMacro(AutoFindSchema, bool);
69  vtkGetMacro(AutoFindSchema, bool);
70  vtkBooleanMacro(AutoFindSchema, bool);
71 
72 protected:
74  ~vtkMRMLTableStorageNode() override;
77 
79  void InitializeSupportedReadFileTypes() override;
80 
82  void InitializeSupportedWriteFileTypes() override;
83 
85  int ReadDataInternal(vtkMRMLNode *refNode) override;
86 
88  int WriteDataInternal(vtkMRMLNode *refNode) override;
89 
90  std::string GenerateSchemaFileName(const char* fileName);
91 
92  virtual std::string GetFieldDelimiterCharacters(std::string filename);
93 
94  // Struct for managing column information
96  {
97  std::string ColumnName;
98  std::vector<vtkAbstractArray*> RawComponentArrays;
99  int ScalarType = VTK_STRING;
100  std::vector<std::string> ComponentNames;
101  std::string NullValueString;
102  };
103  using ColumnInfo = struct StructColumnInfo;
104 
108  std::vector<ColumnInfo> GetColumnInfo(vtkMRMLTableNode* tableNode, vtkTable* rawTable);
109 
111  void FillDataFromStringArray(vtkStringArray* stringComponentArray, vtkDataArray* dataArray, std::string nullValueString="");
112 
115  void AddColumnToTable(vtkTable* table, ColumnInfo columnInfo);
116 
117  bool ReadSchema(std::string filename, vtkMRMLTableNode* tableNode);
118  bool ReadTable(std::string filename, vtkMRMLTableNode* tableNode);
119 
120  bool WriteTable(std::string filename, vtkMRMLTableNode* tableNode);
121  bool WriteSchema(std::string filename, vtkMRMLTableNode* tableNode);
122 
124 };
125 
126 #endif
vtkMRMLNode * CreateNodeInstance() override=0
Create instance of the default node. Like New only virtual.
virtual int ReadDataInternal(vtkMRMLNode *refNode)
virtual void InitializeSupportedReadFileTypes()
void operator=(const vtkMRMLStorageNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
A superclass for other storage nodes.
virtual void InitializeSupportedWriteFileTypes()
std::vector< vtkAbstractArray * > RawComponentArrays
MRML node to represent a table object.
virtual int WriteDataInternal(vtkMRMLNode *refNode)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
const char * GetNodeTagName() override
Get node XML tag name (like Storage, Model)
virtual bool CanReadInReferenceNode(vtkMRMLNode *refNode)=0
MRML node for handling Table node storage.