VTKFIG
0.25.0
Easy VTK based in situ visualization
|
Go to the documentation of this file.
6 #ifndef VTKFIG_XYPLOT_H
7 #define VTKFIG_XYPLOT_H
9 #include <vtkDoubleArray.h>
10 #include <vtkXYPlotActor.h>
11 #include <vtkRectilinearGrid.h>
12 #include <vtkPointData.h>
13 #include <vtkXYPlotWidget.h>
14 #include <vtkLegendBoxActor.h>
37 static std::shared_ptr<XYPlot>
New();
143 template<
typename V>
void AddPlot(
const V &x,
const V &y);
161 void ServerMPSend(vtkSmartPointer<internals::Communicator> communicator)
override final;
164 void ClientMPReceive(vtkSmartPointer<internals::Communicator> communicator)
override final;
167 void RTBuildAllVTKPipelines(vtkSmartPointer<vtkRenderer> renderer)
override final;
170 void RTPreRender()
override final;
173 static std::map<std::string,int> marker_types;
185 vtkSmartPointer<vtkXYPlotActor> XYPlotActor;
190 vtkSmartPointer<vtkLegendBoxActor> LegendActor;
194 static const int desclen=32;
195 std::string title=
"";
196 std::string ytitle=
"y";
197 std::string xtitle=
"x";
203 vtkSmartPointer<vtkDoubleArray> X;
204 vtkSmartPointer<vtkDoubleArray> Y;
205 vtkSmartPointer<vtkRectilinearGrid> curve;
209 int GetDataSetNumber(){
return ds_num;}
210 void SetYLine(
double xrange[2],
double y);
211 void SetXLine(
double yrange[2],
double x);
212 GridLine(vtkSmartPointer<vtkXYPlotActor> plot,
int & ds_num,
double rgb[3]);
216 std::vector<GridLine> XGridLines;
219 std::vector<GridLine> YGridLines;
224 vtkSmartPointer<vtkRectilinearGrid> curve;
227 vtkSmartPointer<vtkDoubleArray> X;
228 vtkSmartPointer<vtkDoubleArray> Y;
231 int GetDataSetNumber();
232 PlotData(vtkSmartPointer<vtkXYPlotActor> plot,
int & ds_num);
237 std::vector<PlotData> AllPlotData;
244 char xlabel_format[desclen]=
"%8.2e";
245 char ylabel_format[desclen]=
"%8.2e";
247 double grid_rgb[3]={0.8,0.8,0.8};
249 double marker_size=1;
251 double axes_rgb[3]={0,0,0};
252 bool legend_show=
true;
253 double legend_posx=0.8;
254 double legend_posy=0.7;
257 bool adjust_labels=
false;
259 double dynXMin=1.0e100;
260 double dynXMax=-1.0e100;
261 double dynYMin=1.0e100;
262 double dynYMax=-1.0e100;
263 double fixXMin=1.0e100;
264 double fixXMax=-1.0e100;
265 double fixYMin=1.0e100;
266 double fixYMax=-1.0e100;
275 char line_type[desclen]={
'-',0};
276 char marker_type[desclen]={0};
277 char legend[desclen]={0};
278 double line_rgb[3]={0,0,0};
284 std::vector<PlotInfo> AllPlotInfo;
288 PlotInfo NextPlotInfo;
295 void XYPlot::AddPlot(
const V &x,
const V &y)
298 while (num_plots>=AllPlotData.size())
300 AllPlotData.emplace_back(XYPlotActor,num_curves);
302 auto plot=AllPlotData[num_plots];
305 assert(x.size()==y.size());
307 plot.X->SetNumberOfTuples(N);
308 plot.Y->SetNumberOfTuples(N);
311 double xmax=-1.0e100;
313 double ymax=-1.0e100;
316 for (
int i=0; i<N; i++)
318 plot.X->InsertTuple1(i,x[i]);
319 plot.Y->InsertTuple1(i,y[i]);
321 ymin=std::min(ymin,y[i]);
322 xmax=std::max(xmax,x[i]);
323 ymax=std::max(ymax,y[i]);
326 PlotState.dynXMin=std::min(
xmin,PlotState.dynXMin);
327 PlotState.dynXMax=std::max(xmax,PlotState.dynXMax);
328 PlotState.dynYMin=std::min(ymin,PlotState.dynYMin);
329 PlotState.dynYMax=std::max(ymax,PlotState.dynYMax);
void ShowGrid(bool b)
Show grid lines in the plot ?
void SetPlotLineType(const std::string type)
Set the line type of the next plot.
void SetXAxisLabelFormat(const std::string fmt)
Set the format string for x axis labels.
void SetPlotLegend(const std::string legend)
Set the information for the legend entry for the next plot.
void SetLineWidth(double w)
Set the width of all lines in the plot.
void SetPlotMarkerType(const std::string type)
Set marker type.
void AdjustLabels(bool b)
Adjust labels to "nice values" ?
void SetNumberOfYLabels(int n)
Set the number of y axis labels.
void ShowLegend(bool b)
Show a legend box ?
void AddPlot(const V &x, const V &y)
Add a pair of x/y data to the figure.
Definition: vtkfigXYPlot.h:295
void SetAxesColor(double r, double g, double b)
Set the color of the axes.
void SetYAxisLabelFormat(const std::string fmt)
Set the format string for y axis labels.
void SetMarkerSize(double s)
Set the size of all markers in the plot.
void SetLegendPosition(double x, double y)
Set the position of the legend box.
void SetYTitle(const std::string t)
Set the title of the y axis.
void SetNumberOfXLabels(int n)
Set the number of x axis labels.
void SetYRange(double y0, double y1)
Set the range of the y values.
virtual std::string SubClassName() override final
Get subclass name (for s-c communication, should be replaced by tag.
XY Function plot.
Definition: vtkfigXYPlot.h:30
void SetXRange(double x0, double x1)
Set the range of the x values.
void SetPlotColor(double r, double g, double b)
Set the color of the next plot.
void SetXTitle(const std::string t)
Set the title of the x axis.
void SetLegendSize(double w, double h)
Set the size of the legend box.
void SetTitle(const std::string t)
Set the title of the plot.
void SetGridColor(double r, double g, double b)
Set the color of the grid lines.
static std::shared_ptr< XYPlot > New()
Smartpointer construtor.
void Clear()
Remove all data from plot.