Slicer  4.8
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) VTK_OVERRIDE;
54 
55  //----------------------------------------------------------------
57  //----------------------------------------------------------------
58 
59  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
60 
63  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
64 
67  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
68 
71  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
72 
75  virtual const char* GetNodeTagName() VTK_OVERRIDE { return "Table"; }
76 
79  virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) VTK_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 
122  virtual vtkMRMLStorageNode* CreateDefaultStorageNode() VTK_OVERRIDE;
123 
132  vtkAbstractArray* AddColumn(vtkAbstractArray* column = 0);
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 
182  int GetColumnIndex(vtkAbstractArray* column);
183 
187  std::string GetColumnName(int columnIndex);
188 
191  int GetNumberOfRows();
192 
195  int GetNumberOfColumns();
196 
199  void SetColumnNullValue(const std::string& columnName, const std::string& nullValue);
200  std::string GetColumnNullValue(const std::string& columnName);
201 
206  void SetColumnLongName(const std::string& columnName, const std::string& description);
207  std::string GetColumnLongName(const std::string& columnName);
208 
211  void SetColumnDescription(const std::string& columnName, const std::string& description);
212  std::string GetColumnDescription(const std::string& columnName);
213 
216  void SetColumnUnitLabel(const std::string& columnName, const std::string& unitLabel);
217  std::string GetColumnUnitLabel(const std::string& columnName);
218 
223  std::string GetColumnProperty(const std::string& columnName, const std::string& propertyName);
224  std::string GetColumnProperty(int columnIndex, const std::string& propertyName);
225 
229  void GetAllColumnPropertyNames(vtkStringArray* propertyNames);
230 
236  void SetColumnProperty(const std::string& columnName, const std::string& propertyName, const std::string& propertyValue);
237  void SetColumnProperty(int columnIndex, const std::string& propertyName, const std::string& propertyValue);
238 
243  void RemoveColumnProperty(const std::string& propertyName);
244 
247  void CopyAllColumnProperties(const std::string& sourceColumnName, const std::string& targetColumnName);
248 
252  void RemoveAllColumnProperties(const std::string& columnName);
253  void RemoveAllColumnProperties(int columnIndex);
254 
257  int GetColumnValueTypeFromSchema(const std::string& columnName);
258 
261  vtkIdType InsertNextBlankRowWithNullValues(vtkTable* table);
262 
265  int GetColumnType(const std::string& columnName);
266 
272  bool SetColumnType(const std::string& columnName, int typeId);
273 
282  bool SetDefaultColumnType(const std::string& type, const std::string& nullValue="");
283 
285  static const char* GetDefaultColumnName();
286 
288  static int GetValueTypeFromString(std::string valueTypeStr);
289 
291  static std::string GetValueTypeAsString(int valueType);
292 
293  //----------------------------------------------------------------
295  //----------------------------------------------------------------
296  protected:
298  ~vtkMRMLTableNode();
300  void operator=(const vtkMRMLTableNode&);
301 
302  protected:
303 
305  std::string GetColumnPropertyInternal(const std::string& columnName, const std::string& propertyName);
306 
308  void SetColumnPropertyInternal(const std::string& columnName, const std::string& propertyName, const std::string& propertyValue);
309 
310  vtkIdType GetPropertyRowIndex(const std::string& columnName);
311 
312  //----------------------------------------------------------------
314  //----------------------------------------------------------------
315 
316  vtkTable* Table;
317  bool Locked;
320 
321  vtkTable* Schema;
322 
323 };
324 
325 #endif
vtkTable * Table
Data.
virtual vtkMRMLStorageNode * CreateDefaultStorageNode()
virtual void ProcessMRMLEvents(vtkObject *, unsigned long, void *) VTK_OVERRIDE
alternative method to propagate events generated in Storage nodes
virtual vtkMRMLNode * CreateNodeInstance() VTK_OVERRIDE=0
MRMLNode methods.
MRML node to represent a 3D surface model.
A supercalss for other storage nodes.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
MRML node to represent a table object.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
void operator=(const vtkMRMLStorableNode &)