VTK  9.3.20240417
vtkTable.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
155 #ifndef vtkTable_h
156 #define vtkTable_h
157 
158 #include "vtkCommonDataModelModule.h" // For export macro
159 #include "vtkDataObject.h"
160 
161 VTK_ABI_NAMESPACE_BEGIN
162 class vtkAbstractArray;
164 class vtkVariant;
165 class vtkVariantArray;
166 
167 class VTKCOMMONDATAMODEL_EXPORT vtkTable : public vtkDataObject
168 {
169 public:
170  static vtkTable* New();
172  vtkTypeMacro(vtkTable, vtkDataObject);
173  void PrintSelf(ostream& os, vtkIndent indent) override;
174 
181  void Dump(unsigned int colWidth = 16, int rowLimit = -1);
182 
186  int GetDataObjectType() override { return VTK_TABLE; }
187 
195  unsigned long GetActualMemorySize() override;
196 
198 
201  vtkGetObjectMacro(RowData, vtkDataSetAttributes);
204 
205  //
206  // Row functions
207  //
208 
213 
220 
224  void SqueezeRows();
225 
231 
235  void GetRow(vtkIdType row, vtkVariantArray* values);
236 
240  void SetRow(vtkIdType row, vtkVariantArray* values);
241 
245  void InsertRow(vtkIdType row);
246 
251 
255  vtkIdType InsertNextBlankRow(double default_num_val = 0.0);
256 
262 
266  void RemoveRow(vtkIdType row);
267 
272 
278 
279  //
280  // Column functions
281  //
282 
287 
288  // Get the name of a column of the table.
289  const char* GetColumnName(vtkIdType col);
290 
295 
301 
306 
311 
316 
320  void RemoveColumnByName(const char* name);
321 
326 
331 
332  //
333  // Table single entry functions
334  //
335 
343 
347  vtkVariant GetValueByName(vtkIdType row, const char* col);
348 
353 
357  void SetValueByName(vtkIdType row, const char* col, vtkVariant value);
358 
362  void Initialize() override;
363 
365 
369  static vtkTable* GetData(vtkInformationVector* v, int i = 0);
371 
373 
376  void ShallowCopy(vtkDataObject* src) override;
377  void DeepCopy(vtkDataObject* src) override;
379 
387 
392 
393 protected:
395  ~vtkTable() override;
396 
401 
406 
412  void MoveRowData(vtkIdType first, vtkIdType last, vtkIdType delta);
413 
414 private:
415  vtkTable(const vtkTable&) = delete;
416  void operator=(const vtkTable&) = delete;
417 };
418 
419 VTK_ABI_NAMESPACE_END
420 #endif
Abstract superclass for all arrays.
general representation of visualization data
represent and manipulate attribute data in a dataset
represent and manipulate fields of data
Definition: vtkFieldData.h:162
a simple class to control print indentation
Definition: vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:168
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkVariantArray * GetRow(vtkIdType row)
Get a row of the table as a vtkVariantArray which has one entry for each column.
static vtkTable * New()
static vtkTable * GetData(vtkInformationVector *v, int i=0)
Retrieve the table from vtkInformation.
vtkDataSetAttributes * RowData
Holds the column data of the table.
Definition: vtkTable.h:400
virtual void SetRowData(vtkDataSetAttributes *data)
Get/Set the main data (columns) of the table.
void AddColumn(vtkAbstractArray *arr)
Add a column to the table.
vtkIdType GetNumberOfElements(int type) override
Get the number of elements for a specific attribute type (ROW, etc.).
~vtkTable() override
void InsertColumn(vtkAbstractArray *arr, vtkIdType index)
Insert a column into the table at given column index.
void MoveRowData(vtkIdType first, vtkIdType last, vtkIdType delta)
Move the content of the rows, starting first row and including last row.
vtkIdType GetColumnIndex(const char *name)
Get the column index for a name.
void RemoveRow(vtkIdType row)
Delete a single row from the table.
void InsertRow(vtkIdType row)
Insert a single row at the index.
vtkAbstractArray * GetColumnByName(const char *name)
Get a column of the table by its name.
void DeepCopy(vtkDataObject *src) override
Shallow/deep copy the data from src into this object.
vtkVariant GetValueByName(vtkIdType row, const char *col)
Retrieve a value in the table by row index and column name as a variant.
vtkIdType InsertNextRow(vtkVariantArray *values)
Insert a row at the end of the tablespecified by a vtkVariantArray.
vtkAbstractArray * GetColumn(vtkIdType col)
Get a column of the table by its column index.
vtkIdType GetNumberOfRows()
Get the number of rows in the table.
void SqueezeRows()
Release previously allocated and now unused memory after performing resizing operations.
void Dump(unsigned int colWidth=16, int rowLimit=-1)
Dump table contents.
vtkIdType GetNumberOfColumns()
Get the number of columns in the table.
void SetRow(vtkIdType row, vtkVariantArray *values)
Set a row of the table with a vtkVariantArray which has one entry for each column.
void ShallowCopy(vtkDataObject *src) override
Shallow/deep copy the data from src into this object.
vtkVariant GetValue(vtkIdType row, vtkIdType col)
Retrieve a value in the table by row and column index as a variant.
void RemoveRows(vtkIdType row, vtkIdType n)
Delete n rows from the table, starting at row.
vtkFieldData * GetAttributesAsFieldData(int type) override
Returns the attributes of the data object as a vtkFieldData.
static vtkTable * ExtendedNew()
void GetRow(vtkIdType row, vtkVariantArray *values)
Get a row of the table as a vtkVariantArray which has one entry for each column.
void RemoveAllColumns()
Remove all columns from the table.
void RemoveColumnByName(const char *name)
Remove a column from the table by its name.
vtkVariantArray * RowArray
Holds row information returned by GetRow().
Definition: vtkTable.h:405
const char * GetColumnName(vtkIdType col)
void SetValue(vtkIdType row, vtkIdType col, vtkVariant value)
Set a value in the table by row and column index as a variant.
void SetNumberOfRows(vtkIdType)
Set the number of rows in the table.
void RemoveAllRows()
Delete all rows from the table.
void InsertRows(vtkIdType row, vtkIdType n)
Insert n rows before row.
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkTable.h:186
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Initialize() override
Initialize to an empty table.
static vtkTable * GetData(vtkInformation *info)
Retrieve the table from vtkInformation.
vtkIdType InsertNextBlankRow(double default_num_val=0.0)
Insert a blank row at the end of the table.
void SetValueByName(vtkIdType row, const char *col, vtkVariant value)
Set a value in the table by row index and column name as a variant.
void RemoveColumn(vtkIdType col)
Remove a column from the table by its column index.
An array holding vtkVariants.
A type representing the union of many types.
Definition: vtkVariant.h:162
@ info
Definition: vtkX3D.h:376
@ value
Definition: vtkX3D.h:220
@ type
Definition: vtkX3D.h:516
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
@ data
Definition: vtkX3D.h:315
int vtkIdType
Definition: vtkType.h:315
#define VTK_TABLE
Definition: vtkType.h:84