vtkCSVExporter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
37 #ifndef vtkCSVExporter_h
38 #define vtkCSVExporter_h
39 
41 #include "vtkPVVTKExtensionsFiltersRenderingModule.h" // needed for export macro
42 
43 #include <string> // needed for std::string
44 
45 class vtkAbstractArray;
46 class vtkDataArray;
47 class vtkFieldData;
48 
50 {
51 public:
52  static vtkCSVExporter* New();
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
57 
60  vtkSetStringMacro(FileName);
61  vtkGetStringMacro(FileName);
63 
65 
68  vtkSetStringMacro(FieldDelimiter);
69  vtkGetStringMacro(FieldDelimiter);
71 
73 
79  vtkSetMacro(Formatting, int);
80  vtkGetMacro(Formatting, int);
82 
84 
90  vtkSetMacro(Precision, int);
91  vtkGetMacro(Precision, int);
93 
95 
99  void SetColumnLabel(const char* name, const char* label);
100  void ClearColumnLabels();
101  const char* GetColumnLabel(const char* name);
103 
107  bool Open(ExporterModes mode = STREAM_ROWS) override;
108 
113  void Close() override;
114 
119  void Abort() override;
120 
122 
127  void WriteHeader(vtkFieldData*) override;
128  void WriteData(vtkFieldData*) override;
130 
138  void AddColumn(vtkAbstractArray* yarray, const char* yarrayname = nullptr,
139  vtkDataArray* xarray = nullptr) override;
140 
141  // CVS writer does not support adding the style yet;
142  void AddStyle(vtkPlot* vtkNotUsed(plot), const char* vtkNotUsed(plotName)) override{};
143 
144  void SetGlobalStyle(vtkChart* vtkNotUsed(chart)) override{};
146 
148 
151  vtkSetMacro(WriteToOutputString, bool);
152  vtkGetMacro(WriteToOutputString, bool);
153  vtkBooleanMacro(WriteToOutputString, bool);
155 
161  std::string GetOutputString();
162 
163 protected:
164  vtkCSVExporter();
165  ~vtkCSVExporter() override;
166 
167  char* FileName = nullptr;
168  char* FieldDelimiter = nullptr;
169  std::ostream* OutputStream = nullptr;
171 
172  bool WriteToOutputString = false;
173  std::string OutputString;
174 
176  int Precision = 6;
177 
178 private:
179  vtkCSVExporter(const vtkCSVExporter&) = delete;
180  void operator=(const vtkCSVExporter&) = delete;
181 
182  class vtkInternals;
183  vtkInternals* Internals;
184 };
185 
186 #endif
void AddStyle(vtkPlot *vtkNotUsed(plot), const char *vtkNotUsed(plotName)) override
virtual void WriteHeader(vtkFieldData *)=0
In STREAM_ROWS mode, use these methods to write column headers once using WriteHeader and then use Wr...
virtual void WriteData(vtkFieldData *)=0
In STREAM_ROWS mode, use these methods to write column headers once using WriteHeader and then use Wr...
virtual void Abort()=0
Same as Close except deletes the file, if created.
#define VTKPVVTKEXTENSIONSFILTERSRENDERING_EXPORT
void SetGlobalStyle(vtkChart *vtkNotUsed(chart)) override
static vtkAbstractChartExporter * New()
virtual bool Open(ExporterModes mode=STREAM_ROWS)=0
Open the file and set mode in which the exporter is operating.
virtual void Close()=0
Closes the file cleanly.
exporter used by certain views to export data as CSV.
exporter used by certain views to export data into a file or stream.
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void AddColumn(vtkAbstractArray *yarray, const char *yarrayname=nullptr, vtkDataArray *xarray=nullptr)=0
In STREAM_COLUMNS mode, use this method to add a column (yarray).
std::string OutputString