vtkCSVExporter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkCSVExporter.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
49 #ifndef vtkCSVExporter_h
50 #define vtkCSVExporter_h
51 
52 #include "vtkObject.h"
53 #include "vtkPVVTKExtensionsFiltersRenderingModule.h" // needed for export macro
54 
55 #include <string> // needed for std::string
56 
57 class vtkAbstractArray;
58 class vtkDataArray;
59 class vtkFieldData;
60 
62 {
63 public:
64  static vtkCSVExporter* New();
65  vtkTypeMacro(vtkCSVExporter, vtkObject);
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
69 
72  vtkSetStringMacro(FileName);
73  vtkGetStringMacro(FileName);
75 
77 
80  vtkSetStringMacro(FieldDelimiter);
81  vtkGetStringMacro(FieldDelimiter);
83 
85  {
87  STREAM_COLUMNS
88  };
89 
91 
97  vtkSetMacro(Formatting, int);
98  vtkGetMacro(Formatting, int);
100 
102 
108  vtkSetMacro(Precision, int);
109  vtkGetMacro(Precision, int);
111 
113 
117  void SetColumnLabel(const char* name, const char* label);
118  void ClearColumnLabels();
119  const char* GetColumnLabel(const char* name);
121 
125  bool Open(ExporterModes mode = STREAM_ROWS);
126 
131  void Close();
132 
137  void Abort();
138 
140 
145  void WriteHeader(vtkFieldData*);
146  void WriteData(vtkFieldData*);
148 
156  void AddColumn(
157  vtkAbstractArray* yarray, const char* yarrayname = nullptr, vtkDataArray* xarray = nullptr);
158 
160 
163  vtkSetMacro(WriteToOutputString, bool);
164  vtkGetMacro(WriteToOutputString, bool);
165  vtkBooleanMacro(WriteToOutputString, bool);
167 
173  std::string GetOutputString();
174 
175 protected:
176  vtkCSVExporter();
177  ~vtkCSVExporter() override;
178 
179  char* FileName = nullptr;
180  char* FieldDelimiter = nullptr;
181  std::ostream* OutputStream = nullptr;
182  ExporterModes Mode = STREAM_ROWS;
183 
184  bool WriteToOutputString = false;
185  std::string OutputString;
186 
188  int Precision = 6;
189 
190 private:
191  vtkCSVExporter(const vtkCSVExporter&) = delete;
192  void operator=(const vtkCSVExporter&) = delete;
193 
194  class vtkInternals;
195  vtkInternals* Internals;
196 };
197 
198 #endif
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
#define VTKPVVTKEXTENSIONSFILTERSRENDERING_EXPORT
exporter used by certain views to export data as CSV.
static vtkObject * New()
void operator=(const vtkObjectBase &)
std::string OutputString