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

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)
 Open the file and set mode in which the exporter is operating. More...
 
void Close ()
 Closes the file cleanly. More...
 
void Abort ()
 Same as Close except deletes the file, if created. More...
 
void AddColumn (vtkAbstractArray *yarray, const char *yarrayname=NULL, vtkDataArray *xarray=NULL)
 In STREAM_COLUMNS mode, use this method to add a column (yarray). More...
 
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 *)
 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 *)
 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 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 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 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 61 of file vtkCSVExporter.h.

Member Typedef Documentation

◆ Superclass

Definition at line 65 of file vtkCSVExporter.h.

Member Enumeration Documentation

◆ ExporterModes

Enumerator
STREAM_ROWS 
STREAM_COLUMNS 

Definition at line 84 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

◆ IsTypeOf()

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

◆ IsA()

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

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

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

◆ PrintSelf()

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

Reimplemented from vtkObject.

◆ 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)

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

◆ Close()

void vtkCSVExporter::Close ( )

Closes the file cleanly.

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

◆ Abort()

void vtkCSVExporter::Abort ( )

Same as Close except deletes the file, if created.

This is useful to interrupt the exporting on failure.

◆ WriteHeader()

void vtkCSVExporter::WriteHeader ( vtkFieldData )

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.

◆ WriteData()

void vtkCSVExporter::WriteData ( vtkFieldData )

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.

◆ AddColumn()

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

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 NULL, 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.

◆ 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 179 of file vtkCSVExporter.h.

◆ FieldDelimiter

char* vtkCSVExporter::FieldDelimiter = nullptr
protected

Definition at line 180 of file vtkCSVExporter.h.

◆ OutputStream

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

Definition at line 181 of file vtkCSVExporter.h.

◆ Mode

ExporterModes vtkCSVExporter::Mode = STREAM_ROWS
protected

Definition at line 182 of file vtkCSVExporter.h.

◆ WriteToOutputString

bool vtkCSVExporter::WriteToOutputString = false
protected

Definition at line 184 of file vtkCSVExporter.h.

◆ OutputString

std::string vtkCSVExporter::OutputString
protected

Definition at line 185 of file vtkCSVExporter.h.

◆ Formatting

int vtkCSVExporter::Formatting
protected

Definition at line 187 of file vtkCSVExporter.h.

◆ Precision

int vtkCSVExporter::Precision = 6
protected

Definition at line 188 of file vtkCSVExporter.h.


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