Slicer  4.10
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  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 
294  //----------------------------------------------------------------
296  //----------------------------------------------------------------
297  protected:
299  ~vtkMRMLTableNode();
301  void operator=(const vtkMRMLTableNode&);
302 
303  protected:
304 
306  std::string GetColumnPropertyInternal(const std::string& columnName, const std::string& propertyName);
307 
309  void SetColumnPropertyInternal(const std::string& columnName, const std::string& propertyName, const std::string& propertyValue);
310 
311  vtkIdType GetPropertyRowIndex(const std::string& columnName);
312 
313  //----------------------------------------------------------------
315  //----------------------------------------------------------------
316 
317  vtkTable* Table;
318  bool Locked;
319  bool UseColumnNameAsColumnHeader;
320  bool UseFirstColumnAsRowHeader;
321 
322  vtkTable* Schema;
323 
324 };
325 
326 #endif
virtual vtkMRMLStorageNode * CreateDefaultStorageNode()
LRU Cache.
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 superclass 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:138