Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vtkCSVExporter Class Reference

exporter used by certain views to export data as CSV. More...

#include <vtkCSVExporter.h>

Inheritance diagram for vtkCSVExporter:
Inheritance graph
[legend]
Collaboration diagram for vtkCSVExporter:
Collaboration graph
[legend]

Public Types

typedef vtkAbstractChartExporter Superclass
 
- Public Types inherited from vtkAbstractChartExporter
enum  ExporterModes { STREAM_ROWS, STREAM_COLUMNS }
 
typedef vtkObject Superclass
 

Public Member Functions

virtual const char * GetClassName ()
 
virtual int IsA (const char *type)
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
bool Open (ExporterModes mode=STREAM_ROWS) override
 Open the file and set mode in which the exporter is operating. More...
 
void Close () override
 Closes the file cleanly. More...
 
void Abort () override
 Same as Close except deletes the file, if created. More...
 
void AddColumn (vtkAbstractArray *yarray, const char *yarrayname=nullptr, vtkDataArray *xarray=nullptr) override
 In STREAM_COLUMNS mode, use this method to add a column (yarray). More...
 
void AddStyle (vtkPlot *vtkNotUsed(plot), const char *vtkNotUsed(plotName)) override
 
void SetGlobalStyle (vtkChart *vtkNotUsed(chart)) override
 
std::string GetOutputString ()
 Get the exported data as string. More...
 
virtual void SetFileName (const char *)
 Get/Set the filename for the file. More...
 
virtual char * GetFileName ()
 Get/Set the filename for the file. More...
 
virtual void SetFieldDelimiter (const char *)
 Get/Set the delimiter use to separate fields ("," by default.) More...
 
virtual char * GetFieldDelimiter ()
 Get/Set the delimiter use to separate fields ("," by default.) More...
 
virtual void SetFormatting (int)
 Set a formatting to use when writing real numbers (aka floating-point numbers) to csv. More...
 
virtual int GetFormatting ()
 Set a formatting to use when writing real numbers (aka floating-point numbers) to csv. More...
 
virtual void SetPrecision (int)
 Set a precision to use when writing real numbers (aka floating-point numbers) to csv. More...
 
virtual int GetPrecision ()
 Set a precision to use when writing real numbers (aka floating-point numbers) to csv. More...
 
void SetColumnLabel (const char *name, const char *label)
 In STREAM_ROWS mode, this API can be used to change columns labels when exporting. More...
 
void ClearColumnLabels ()
 In STREAM_ROWS mode, this API can be used to change columns labels when exporting. More...
 
const char * GetColumnLabel (const char *name)
 In STREAM_ROWS mode, this API can be used to change columns labels when exporting. More...
 
void WriteHeader (vtkFieldData *) override
 In STREAM_ROWS mode, use these methods to write column headers once using WriteHeader and then use WriteData as many times as needed to write out rows. More...
 
void WriteData (vtkFieldData *) override
 In STREAM_ROWS mode, use these methods to write column headers once using WriteHeader and then use WriteData as many times as needed to write out rows. More...
 
virtual void SetWriteToOutputString (bool)
 Whether to output to a string instead of to a file, which is the default. More...
 
virtual bool GetWriteToOutputString ()
 Whether to output to a string instead of to a file, which is the default. More...
 
virtual void WriteToOutputStringOn ()
 Whether to output to a string instead of to a file, which is the default. More...
 
virtual void WriteToOutputStringOff ()
 Whether to output to a string instead of to a file, which is the default. More...
 
- Public Member Functions inherited from vtkAbstractChartExporter
virtual void AddStyle (vtkPlot *plot, const char *plotName)=0
 Attach information about the style of the plot (color,line type, marker type etc. More...
 
virtual void SetGlobalStyle (vtkChart *chart)=0
 Set Global style elements like graph and axis titles. More...
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 
virtual void DebugOff ()
 
bool GetDebug ()
 
void SetDebug (bool debugFlag)
 
virtual void Modified ()
 
virtual vtkMTimeType GetMTime ()
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
int HasObserver (unsigned long event)
 
int HasObserver (const char *event)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
int HasObserver (unsigned long event, vtkCommand *)
 
int HasObserver (const char *event, vtkCommand *)
 
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
int InvokeEvent (unsigned long event, void *callData)
 
int InvokeEvent (const char *event, void *callData)
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
int HasObserver (unsigned long event, vtkCommand *)
 
int HasObserver (const char *event, vtkCommand *)
 
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
int InvokeEvent (unsigned long event, void *callData)
 
int InvokeEvent (const char *event, void *callData)
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 
virtual void Delete ()
 
virtual void FastDelete ()
 
void Print (ostream &os)
 
virtual void Register (vtkObjectBase *o)
 
virtual void UnRegister (vtkObjectBase *o)
 
void SetReferenceCount (int)
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
int GetReferenceCount ()
 
void PrintRevisions (ostream &)
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
int GetReferenceCount ()
 
void PrintRevisions (ostream &)
 

Static Public Member Functions

static vtkCSVExporterNew ()
 
static int IsTypeOf (const char *type)
 
static vtkCSVExporterSafeDownCast (vtkObject *o)
 
- Static Public Member Functions inherited from vtkAbstractChartExporter
static vtkAbstractChartExporterNew ()
 
static int IsTypeOf (const char *type)
 
static vtkAbstractChartExporterSafeDownCast (vtkObject *o)
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 
static void BreakOnError ()
 
static void SetGlobalWarningDisplay (int val)
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
static void SetGlobalWarningDisplay (int val)
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 
static vtkObjectBaseNew ()
 
static vtkObjectBaseNew ()
 

Protected Member Functions

 vtkCSVExporter ()
 
 ~vtkCSVExporter () override
 
- Protected Member Functions inherited from vtkAbstractChartExporter
 vtkAbstractChartExporter ()
 
 ~vtkAbstractChartExporter () override
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
virtual ~vtkObject ()
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) VTK_OVERRIDE
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) VTK_OVERRIDE
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
 
void InternalReleaseFocus ()
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
 
void InternalReleaseFocus ()
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Protected Attributes

char * FileName = nullptr
 
char * FieldDelimiter = nullptr
 
std::ostream * OutputStream = nullptr
 
ExporterModes Mode = STREAM_ROWS
 
bool WriteToOutputString = false
 
std::string OutputString
 
int Formatting
 
int Precision = 6
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
vtkAtomicInt32 ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

exporter used by certain views to export data as CSV.

vtkCSVExporter can be used to generate comma-separated files. Unlike vtkCSVWriter, this class can generate a single CSV from multiple array collections. This avoids the need to generate of single large appended table. The multiple arrays together represent the complete tabular data that gets exported. The table can be split column-wise or row-wise between multiple arrays. The vtkCSVExporter provides two sets of APIs to handle the two cases. They cannot be mixed.

When exporting array instances split by columns, i.e. each array will have exactly same number of rows but different columns that are to be concatenated together, use the STREAM_COLUMNS mode. To use this mode, start writing by using vtkCSVExporter::Open(vtkCSVExporter::STREAM_COLUMNS) and then add each column using vtkCSVExporter::AddColumn. Finally, complete the export can generate the output using vtkCSVExporter::Close.

When exporting arrays that are split by rows, use the STREAM_ROWS mode. The arrays are provided as a part of vtkFieldData (or subclass). To begin exporting in this mode, use vtkCSVExporter::Open(vtkCSVExporter::STREAM_ROWS). Write the header using vtkCSVExporter::WriteHeader(vtkFieldData*) and the pass rows in order by using vtkCSVExporter::WriteData(vtkFieldData*) multiple times. Finally, close usingvtkCSVExporter::Close`.

In STREAM_ROWS mode, the exporter supports invalid / empty cells. When writing each column in WriteData call, for each column-name an vtkUnsignedCharArray with the name __vtkValidMask__{COLUMN_NAME} is looked up. If found, it's value is used to determine if that cell is to written out or not.

Definition at line 49 of file vtkCSVExporter.h.

Member Typedef Documentation

◆ Superclass

Definition at line 53 of file vtkCSVExporter.h.

Constructor & Destructor Documentation

◆ vtkCSVExporter()

vtkCSVExporter::vtkCSVExporter ( )
protected

◆ ~vtkCSVExporter()

vtkCSVExporter::~vtkCSVExporter ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkCSVExporter* vtkCSVExporter::New ( )
static

◆ GetClassName()

virtual const char* vtkCSVExporter::GetClassName ( )
virtual

Reimplemented from vtkAbstractChartExporter.

◆ IsTypeOf()

static int vtkCSVExporter::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual int vtkCSVExporter::IsA ( const char *  type)
virtual

Reimplemented from vtkAbstractChartExporter.

◆ SafeDownCast()

static vtkCSVExporter* vtkCSVExporter::SafeDownCast ( vtkObject o)
static

◆ PrintSelf()

void vtkCSVExporter::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Reimplemented from vtkAbstractChartExporter.

◆ SetFileName()

virtual void vtkCSVExporter::SetFileName ( const char *  )
virtual

Get/Set the filename for the file.

◆ GetFileName()

virtual char* vtkCSVExporter::GetFileName ( )
virtual

Get/Set the filename for the file.

◆ SetFieldDelimiter()

virtual void vtkCSVExporter::SetFieldDelimiter ( const char *  )
virtual

Get/Set the delimiter use to separate fields ("," by default.)

◆ GetFieldDelimiter()

virtual char* vtkCSVExporter::GetFieldDelimiter ( )
virtual

Get/Set the delimiter use to separate fields ("," by default.)

◆ SetFormatting()

virtual void vtkCSVExporter::SetFormatting ( int  )
virtual

Set a formatting to use when writing real numbers (aka floating-point numbers) to csv.

See the std::fixed doc for more info. Default is vtkVariant::DEFAULT_FORMATTING

◆ GetFormatting()

virtual int vtkCSVExporter::GetFormatting ( )
virtual

Set a formatting to use when writing real numbers (aka floating-point numbers) to csv.

See the std::fixed doc for more info. Default is vtkVariant::DEFAULT_FORMATTING

◆ SetPrecision()

virtual void vtkCSVExporter::SetPrecision ( int  )
virtual

Set a precision to use when writing real numbers (aka floating-point numbers) to csv.

See the std::setprecision doc for more info. Default is 6

◆ GetPrecision()

virtual int vtkCSVExporter::GetPrecision ( )
virtual

Set a precision to use when writing real numbers (aka floating-point numbers) to csv.

See the std::setprecision doc for more info. Default is 6

◆ SetColumnLabel()

void vtkCSVExporter::SetColumnLabel ( const char *  name,
const char *  label 
)

In STREAM_ROWS mode, this API can be used to change columns labels when exporting.

◆ ClearColumnLabels()

void vtkCSVExporter::ClearColumnLabels ( )

In STREAM_ROWS mode, this API can be used to change columns labels when exporting.

◆ GetColumnLabel()

const char* vtkCSVExporter::GetColumnLabel ( const char *  name)

In STREAM_ROWS mode, this API can be used to change columns labels when exporting.

◆ Open()

bool vtkCSVExporter::Open ( ExporterModes  mode = STREAM_ROWS)
overridevirtual

Open the file and set mode in which the exporter is operating.

Implements vtkAbstractChartExporter.

◆ Close()

void vtkCSVExporter::Close ( )
overridevirtual

Closes the file cleanly.

Call this at the end to close the file and dump out any cached data.

Implements vtkAbstractChartExporter.

◆ Abort()

void vtkCSVExporter::Abort ( )
overridevirtual

Same as Close except deletes the file, if created.

This is useful to interrupt the exporting on failure.

Implements vtkAbstractChartExporter.

◆ WriteHeader()

void vtkCSVExporter::WriteHeader ( vtkFieldData )
overridevirtual

In STREAM_ROWS mode, use these methods to write column headers once using WriteHeader and then use WriteData as many times as needed to write out rows.

Implements vtkAbstractChartExporter.

◆ WriteData()

void vtkCSVExporter::WriteData ( vtkFieldData )
overridevirtual

In STREAM_ROWS mode, use these methods to write column headers once using WriteHeader and then use WriteData as many times as needed to write out rows.

Implements vtkAbstractChartExporter.

◆ AddColumn()

void vtkCSVExporter::AddColumn ( vtkAbstractArray yarray,
const char *  yarrayname = nullptr,
vtkDataArray xarray = nullptr 
)
overridevirtual

In STREAM_COLUMNS mode, use this method to add a column (yarray).

One can assign it a name different the the name of the array using yarrayname. If xarray is not nullptr, then is used as the row-id. This makes it possible to add multiple columns with varying number of samples. The final output will have empty cells for missing values.

Implements vtkAbstractChartExporter.

◆ AddStyle()

void vtkCSVExporter::AddStyle ( vtkPlot vtkNotUsedplot,
const char *  vtkNotUsedplotName 
)
inlineoverride

Definition at line 142 of file vtkCSVExporter.h.

◆ SetGlobalStyle()

void vtkCSVExporter::SetGlobalStyle ( vtkChart vtkNotUsedchart)
inlineoverride

Definition at line 144 of file vtkCSVExporter.h.

◆ SetWriteToOutputString()

virtual void vtkCSVExporter::SetWriteToOutputString ( bool  )
virtual

Whether to output to a string instead of to a file, which is the default.

◆ GetWriteToOutputString()

virtual bool vtkCSVExporter::GetWriteToOutputString ( )
virtual

Whether to output to a string instead of to a file, which is the default.

◆ WriteToOutputStringOn()

virtual void vtkCSVExporter::WriteToOutputStringOn ( )
virtual

Whether to output to a string instead of to a file, which is the default.

◆ WriteToOutputStringOff()

virtual void vtkCSVExporter::WriteToOutputStringOff ( )
virtual

Whether to output to a string instead of to a file, which is the default.

◆ GetOutputString()

std::string vtkCSVExporter::GetOutputString ( )

Get the exported data as string.

If WriteToOutputString is OFF, returned string is empty. If Close() was not called, returned string is empty.

Member Data Documentation

◆ FileName

char* vtkCSVExporter::FileName = nullptr
protected

Definition at line 167 of file vtkCSVExporter.h.

◆ FieldDelimiter

char* vtkCSVExporter::FieldDelimiter = nullptr
protected

Definition at line 168 of file vtkCSVExporter.h.

◆ OutputStream

std::ostream* vtkCSVExporter::OutputStream = nullptr
protected

Definition at line 169 of file vtkCSVExporter.h.

◆ Mode

ExporterModes vtkCSVExporter::Mode = STREAM_ROWS
protected

Definition at line 170 of file vtkCSVExporter.h.

◆ WriteToOutputString

bool vtkCSVExporter::WriteToOutputString = false
protected

Definition at line 172 of file vtkCSVExporter.h.

◆ OutputString

std::string vtkCSVExporter::OutputString
protected

Definition at line 173 of file vtkCSVExporter.h.

◆ Formatting

int vtkCSVExporter::Formatting
protected

Definition at line 175 of file vtkCSVExporter.h.

◆ Precision

int vtkCSVExporter::Precision = 6
protected

Definition at line 176 of file vtkCSVExporter.h.


The documentation for this class was generated from the following file: