Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
33
34// VTK Includes
35class vtkTable;
36
44class VTK_MRML_EXPORT vtkMRMLTableNode : public vtkMRMLStorableNode
45{
46public:
48
49public:
52
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
55 //----------------------------------------------------------------
57 //----------------------------------------------------------------
58
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
150
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
193
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:
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
Abstract Superclass for all specific types of MRML nodes.
MRML node to represent a 3D surface model.
A superclass for other storage nodes.
MRML node to represent a table object.
virtual void SetAndObserveSchema(vtkTable *schema)
void ReadXMLAttributes(const char **atts) override
Set node attributes.
bool SetComponentNames(const std::string &columnName, const std::vector< std::string > &componentNames)
Set the component names for the specified column.
void CopyAllColumnProperties(const std::string &sourceColumnName, const std::string &targetColumnName)
Copy all properties from one column to another.
void SetColumnDescription(const std::string &columnName, const std::string &description)
Set human-readable description of a column.
std::string GetColumnUnitLabel(const std::string &columnName)
std::string GetColumnProperty(const std::string &columnName, const std::string &propertyName)
int GetColumnValueTypeFromSchema(const std::string &columnName)
vtkMRMLCopyContentMacro(vtkMRMLTableNode)
vtkIdType GetPropertyRowIndex(const std::string &columnName)
void GetAllColumnPropertyNames(vtkStringArray *propertyNames)
bool SetCellText(int rowIndex, int columnIndex, const char *text)
std::string GetColumnNullValue(const std::string &columnName)
static std::vector< std::string > GetComponentNamesFromArray(vtkAbstractArray *array)
Get component names from a vtkAbstractArray as a vector of string.
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Method to propagate events generated in mrml.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
vtkMRMLTableNode(const vtkMRMLTableNode &)
bool SetDefaultColumnType(const std::string &type, const std::string &nullValue="")
static int GetValueTypeFromString(std::string valueTypeStr)
Get value type id from string (inverse of vtkImageScalarTypeNameMacro)
~vtkMRMLTableNode() override
virtual void SetAndObserveTable(vtkTable *table)
Get and Set Macros.
void SetColumnNullValue(const std::string &columnName, const std::string &nullValue)
Set null value for blank rows and missing values.
int GetColumnIndex(vtkAbstractArray *column)
int GetNumberOfColumns()
Convenience method for getting number of columns in the table.
std::string GetColumnName(int columnIndex)
std::vector< std::string > GetComponentNamesFromSchema(const std::string &columnName)
std::string GetColumnDescription(const std::string &columnName)
static vtkMRMLTableNode * New()
Data types supported by the table. Used in qMRMLTableModel for visualization.
vtkIdType InsertNextBlankRowWithNullValues(vtkTable *table)
void SetColumnUnitLabel(const std::string &columnName, const std::string &unitLabel)
Set measurement unit for the data stored in the selected column.
std::vector< std::string > GetComponentNames(const std::string &columnName)
Get the vector of component names from the.
void SetColumnLongName(const std::string &columnName, const std::string &description)
std::string GetColumnLongName(const std::string &columnName)
std::string GetColumnPropertyInternal(const std::string &columnName, const std::string &propertyName)
Get column property, even for reserved properties.
int GetColumnIndex(const char *columnName)
bool SetColumnType(const std::string &columnName, int typeId)
vtkAbstractArray * AddColumn(vtkAbstractArray *column=nullptr)
static const char * GetDefaultColumnName()
Name of the column that stores default properties that are used when a new column is created.
vtkMRMLNode * CreateNodeInstance() override
Standard methods for MRML nodes.
bool RenameColumn(int columnIndex, const char *newName)
void RemoveAllColumnProperties(const std::string &columnName)
static std::string GetValueTypeAsString(int valueType)
Get value type id from string (uses vtkImageScalarTypeNameMacro)
void SetColumnProperty(const std::string &columnName, const std::string &propertyName, const std::string &propertyValue)
int GetColumnType(const std::string &columnName)
void RemoveAllColumnProperties(int columnIndex)
void SetColumnProperty(int columnIndex, const std::string &propertyName, const std::string &propertyValue)
static const std::vector< std::string > GetComponentNamesFromString(const std::string &componentNameString)
Convert the vector of component names from a string of component names separated with the '|' charact...
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
int GetColumnIndex(const std::string &columnName)
int GetNumberOfRows()
Convenience method for getting number of rows in the table.
bool RemoveRow(int rowIndex)
void operator=(const vtkMRMLTableNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
vtkTable * Table
Data.
static std::string GetComponentNamesAsString(const std::vector< std::string > &componentNames)
Convert the component names as a string of component names separated with the '|' character.
vtkMRMLTableNode()
Constructor and destructor.
void SetColumnPropertyInternal(const std::string &columnName, const std::string &propertyName, const std::string &propertyValue)
Set column property, even for reserved properties.
bool RemoveColumn(int columnIndex)
std::string GetCellText(int rowIndex, int columnIndex)
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
void RemoveColumnProperty(const std::string &propertyName)
std::string GetColumnProperty(int columnIndex, const std::string &propertyName)
bool RemoveAllColumns()