Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLTableNode.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 __vtkMRMLTableNode_h
24 #define __vtkMRMLTableNode_h
25 
26 #include <string>
27 #include <vector>
28 
29 #include "vtkMRMLStorableNode.h"
30 
31 // MRML Includes
32 class vtkMRMLStorageNode;
33 
34 // VTK Includes
35 class vtkTable;
36 
44 class VTK_MRML_EXPORT vtkMRMLTableNode : public vtkMRMLStorableNode
45 {
46 public:
48 
49 public:
50  static vtkMRMLTableNode *New();
52 
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
55  //----------------------------------------------------------------
57  //----------------------------------------------------------------
58 
59  vtkMRMLNode* CreateNodeInstance() override;
60 
63  void ReadXMLAttributes( const char** atts) override;
64 
67  void WriteXML(ostream& of, int indent) override;
68 
72 
75  const char* GetNodeTagName() override { return "Table"; }
76 
79  void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override;
80 
81  //----------------------------------------------------------------
83  //----------------------------------------------------------------
84  virtual void SetAndObserveTable(vtkTable* table);
85  vtkGetObjectMacro(Table, vtkTable);
86 
103  virtual void SetAndObserveSchema(vtkTable* schema);
104  vtkGetObjectMacro(Schema, vtkTable);
105 
108  vtkGetMacro(Locked, bool);
109  vtkSetMacro(Locked, bool);
110 
112  vtkGetMacro(UseFirstColumnAsRowHeader, bool);
113  vtkSetMacro(UseFirstColumnAsRowHeader, bool);
114 
117  vtkGetMacro(UseColumnNameAsColumnHeader, bool);
118  vtkSetMacro(UseColumnNameAsColumnHeader, bool);
119 
123 
132  vtkAbstractArray* AddColumn(vtkAbstractArray* column = nullptr);
133 
139  bool RenameColumn(int columnIndex, const char* newName);
140 
144  bool RemoveColumn(int columnIndex);
145 
149  bool RemoveAllColumns();
150 
154  int AddEmptyRow();
155 
159  bool RemoveRow(int rowIndex);
160 
164  std::string GetCellText(int rowIndex, int columnIndex);
165 
172  bool SetCellText(int rowIndex, int columnIndex, const char* text);
173 
177  int GetColumnIndex(const char* columnName);
178  int GetColumnIndex(const std::string &columnName);
179 
183  int GetColumnIndex(vtkAbstractArray* column);
184 
188  std::string GetColumnName(int columnIndex);
189 
192  int GetNumberOfRows();
193 
196  int GetNumberOfColumns();
197 
200  void SetColumnNullValue(const std::string& columnName, const std::string& nullValue);
201  std::string GetColumnNullValue(const std::string& columnName);
202 
207  void SetColumnLongName(const std::string& columnName, const std::string& description);
208  std::string GetColumnLongName(const std::string& columnName);
209 
212  void SetColumnDescription(const std::string& columnName, const std::string& description);
213  std::string GetColumnDescription(const std::string& columnName);
214 
217  void SetColumnUnitLabel(const std::string& columnName, const std::string& unitLabel);
218  std::string GetColumnUnitLabel(const std::string& columnName);
219 
224  std::string GetColumnProperty(const std::string& columnName, const std::string& propertyName);
225  std::string GetColumnProperty(int columnIndex, const std::string& propertyName);
226 
230  void GetAllColumnPropertyNames(vtkStringArray* propertyNames);
231 
237  void SetColumnProperty(const std::string& columnName, const std::string& propertyName, const std::string& propertyValue);
238  void SetColumnProperty(int columnIndex, const std::string& propertyName, const std::string& propertyValue);
239 
244  void RemoveColumnProperty(const std::string& propertyName);
245 
248  void CopyAllColumnProperties(const std::string& sourceColumnName, const std::string& targetColumnName);
249 
253  void RemoveAllColumnProperties(const std::string& columnName);
254  void RemoveAllColumnProperties(int columnIndex);
255 
258  int GetColumnValueTypeFromSchema(const std::string& columnName);
259 
262  vtkIdType InsertNextBlankRowWithNullValues(vtkTable* table);
263 
266  int GetColumnType(const std::string& columnName);
267 
273  bool SetColumnType(const std::string& columnName, int typeId);
274 
283  bool SetDefaultColumnType(const std::string& type, const std::string& nullValue="");
284 
286  static const char* GetDefaultColumnName();
287 
289  static int GetValueTypeFromString(std::string valueTypeStr);
290 
292  static std::string GetValueTypeAsString(int valueType);
293 
295  bool SetComponentNames(const std::string& columnName, const std::vector<std::string>& componentNames);
296 
298  std::vector<std::string> GetComponentNames(const std::string& columnName);
299 
302  std::vector<std::string> GetComponentNamesFromSchema(const std::string& columnName);
303 
305  static std::vector<std::string> GetComponentNamesFromArray(vtkAbstractArray* array);
306 
308  static const std::vector<std::string> GetComponentNamesFromString(const std::string& componentNameString);
309 
311  static std::string GetComponentNamesAsString(const std::vector<std::string>& componentNames);
312 
313  //----------------------------------------------------------------
315  //----------------------------------------------------------------
316  protected:
318  ~vtkMRMLTableNode() override;
320  void operator=(const vtkMRMLTableNode&);
321 
322  protected:
323 
325  std::string GetColumnPropertyInternal(const std::string& columnName, const std::string& propertyName);
326 
328  void SetColumnPropertyInternal(const std::string& columnName, const std::string& propertyName, const std::string& propertyValue);
329 
330  vtkIdType GetPropertyRowIndex(const std::string& columnName);
331 
332  //----------------------------------------------------------------
334  //----------------------------------------------------------------
335 
336  vtkTable* Table;
337  bool Locked;
340 
341  vtkTable* Schema;
342 
343 };
344 
345 #endif
vtkTable * Table
Data.
virtual vtkMRMLStorageNode * CreateDefaultStorageNode()
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
MRML node to represent a 3D surface model.
A superclass for other storage nodes.
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
alternative method to propagate events generated in Storage nodes
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
vtkMRMLCopyContentMacro(vtkMRMLStorableNode)
MRML node to represent a table object.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
void operator=(const vtkMRMLStorableNode &)
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
void PrintSelf(ostream &os, vtkIndent indent) override