1 #include <vtkProperty2D.h>     2 #include <vtkTextProperty.h>     3 #include <vtkAxisActor2D.h>     4 #include <vtkLegendBoxActor.h>    13     this->
XYPlotActor=vtkSmartPointer<vtkXYPlotActor>::New();
    14     this->
LegendActor=vtkSmartPointer<vtkLegendBoxActor>::New();
    21     return std::make_shared<XYPlot>(); 
    27     return std::string(
"XYPlot");
   187     XYPlotActor->GetPositionCoordinate()->SetValue(0.0, 0.0, 0);
   188     XYPlotActor->GetPosition2Coordinate()->SetValue(1.0, 1.0, 0);
   254       this->
LegendActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
   255       this->
LegendActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
   256       this->
LegendActor->GetPosition2Coordinate()->SetReferenceCoordinate( NULL );
   267       auto text_prop = 
LegendActor->GetEntryTextProperty();
   268       text_prop->ItalicOff();
   269       text_prop->SetFontFamilyToArial();
   270       text_prop->SetFontSize(fs);
   283     X->InsertTuple1(0,xrange[0]);
   284     Y->InsertTuple1(0,y);
   286     X->InsertTuple1(1,xrange[1]);
   287     Y->InsertTuple1(1,y);
   291     X->InsertTuple1(0,x);
   292     Y->InsertTuple1(0,yrange[0]);
   294     X->InsertTuple1(1,x);
   295     Y->InsertTuple1(1,yrange[1]);
   302     X=vtkSmartPointer<vtkDoubleArray>::New();
   303     Y=vtkSmartPointer<vtkDoubleArray>::New();
   304     X->SetNumberOfTuples(2);
   305     Y->SetNumberOfTuples(2);
   306     curve=vtkSmartPointer<vtkRectilinearGrid>::New();
   307     curve->SetXCoordinates(
X);
   308     curve->GetPointData()->SetScalars(
Y);
   309     curve->SetDimensions(2, 1, 1);
   310     plot->AddDataSetInput(
curve);
   311     plot->SetPlotColor(ds_num, rgb);
   312     plot->SetPlotLines(ds_num, 1);
   313     plot->SetPlotPoints(ds_num,0);
   329       XYPlotActor->GetProperty()->SetLineStipplePattern(0xf0f0);
   330       XYPlotActor->GetProperty()->SetLineStippleRepeatFactor(5);
   335         XYPlotActor->GetXAxisActor2D()->GetAdjustedRange(xrange);
   336         XYPlotActor->GetYAxisActor2D()->GetAdjustedRange(yrange);
   337         mynxlabels=
XYPlotActor->GetXAxisActor2D()->GetAdjustedNumberOfLabels();
   338         mynylabels=
XYPlotActor->GetYAxisActor2D()->GetAdjustedNumberOfLabels();
   354       for (
int i=
XGridLines.size();i<mynxlabels; i++)
   357       for (
int i=
YGridLines.size();i<mynylabels; i++)
   361       double dx=0.999999*(xrange[1]-xrange[0])/(mynxlabels-1);
   362       double x=xrange[0]+dx;
   363       for (
int i=1;i<mynxlabels;i++,x+=dx)
   368       for (
int i=mynxlabels;i<
XGridLines.size();i++)
   374       double dy=0.9999999*(yrange[1]-yrange[0])/(mynylabels-1);
   375       double y=yrange[0]+dy;
   376       for (
int i=1;i<mynylabels;i++,y+=dy)
   381       for (
int i=mynylabels;i<
XGridLines.size();i++)
   394       {
"filled triangle",5},
   414     curve->SetDimensions(
X->GetNumberOfTuples(), 1, 1);
   425     X=vtkSmartPointer<vtkDoubleArray>::New();
   426     Y=vtkSmartPointer<vtkDoubleArray>::New();
   427     curve=vtkSmartPointer<vtkRectilinearGrid>::New();
   428     curve->SetXCoordinates(
X);
   429     curve->GetPointData()->SetScalars(
Y);
   430     plot->AddDataSetInput(
curve);
   455       || line_type == 
"none"   456       || line_type == 
"off"   466       throw std::runtime_error(
"Unknown line type: "+line_type);
   467     XYPlotActor->SetPlotLines(plot.GetDataSetNumber(), plot_lines);
   469     int plot_points = -1;
   473       || marker_type == 
"none"   474       || marker_type == 
"off"   478       XYPlotActor->SetPlotGlyphType(plot.GetDataSetNumber(), 1);
   487       throw std::runtime_error(
"Unknown marker type: "+marker_type);
   489     XYPlotActor->SetPlotPoints(plot.GetDataSetNumber(), plot_points);
   533       for (
int iplot=0;iplot<
num_plots;iplot++)
   551     communicator->SendString(
title);
   552     communicator->SendString(
xtitle);
   553     communicator->SendString(
ytitle);
   561     communicator->SendCharBuffer((
char*)
AllPlotInfo.data(),ndata);
   567       communicator->Send(plot.X,1,1);
   568       communicator->Send(plot.Y,1,1);
   575     communicator->ReceiveString(
title);
   576     communicator->ReceiveString(
xtitle);
   577     communicator->ReceiveString(
ytitle);
   582     communicator->ReceiveInt(np);
   583     communicator->ReceiveInt(npi);
   584     std::vector<PlotInfo> NewPlotInfo(npi);
   585     char *data=(
char*)NewPlotInfo.data();
   587     communicator->ReceiveCharBuffer(data,ndata);
   590     for (
int i=0;i<np;i++)
   599       communicator->Receive(plot.X,1,1);
   600       communicator->Receive(plot.Y,1,1);
 std::vector< PlotInfo > AllPlotInfo
Vector holding all plot info. 
 
void SetPlotMarkerType(const std::string type)
Set marker type. 
 
std::vector< GridLine > YGridLines
vector holding grid lines 
 
void SetXRange(double x0, double x1)
Set the range of the x values. 
 
void SetYTitle(const std::string t)
Set the title of the y axis. 
 
void ClientMTReceive(vtkSmartPointer< internals::Communicator > communicator) override final
Server-Client receive. 
 
void ShowLegend(bool b)
Show a legend box ? 
 
void SetPlotColor(double r, double g, double b)
Set the color of the next plot. 
 
vtkSmartPointer< vtkRectilinearGrid > curve
 
void SetGridColor(double r, double g, double b)
Set the color of the grid lines. 
 
static std::map< std::string, int > marker_types
Possible types of plot markers. 
 
void SetXLine(double yrange[2], double x)
 
vtkSmartPointer< vtkDoubleArray > X
 
int GetDataSetNumber()
Return dataset number in XYPLotActor. 
 
virtual std::string SubClassName() override final
Get subclass name (for s-c communication, should be replaced by tag. 
 
void SetXTitle(const std::string t)
Set the title of the x axis. 
 
void SetPlotLegend(const std::string legend)
Set the information for the legend entry for the next plot. 
 
void AddPlot()
Internal addplot after plot data have been filled. 
 
void SetNumberOfXLabels(int n)
Set the number of x axis labels. 
 
static std::shared_ptr< XYPlot > New()
 
struct vtkfig::XYPlot::@4 PlotState
General state of the XYPlot. 
 
vtkSmartPointer< vtkXYPlotActor > XYPlotActor
The main graphics actor. 
 
void FixSize()
Fix curve size to X size. 
 
void RTPreRender() override final
Pre render actions. 
 
char marker_type[desclen]
 
PlotInfo NextPlotInfo
"finite state machine" struture accumulating repective info for next plot 
 
void ServerRTSend(vtkSmartPointer< internals::Communicator > communicator) override final
Server-Client send. 
 
PlotData(vtkSmartPointer< vtkXYPlotActor > plot, int &ds_num)
 
void SetTitle(const std::string t)
Set the title of the plot. 
 
vtkSmartPointer< vtkRectilinearGrid > curve
 
void AdjustLabels(bool b)
Adjust labels to "nice values" ? 
 
vtkSmartPointer< vtkLegendBoxActor > LegendActor
We create our own legend box. 
 
void SetNumberOfYLabels(int n)
Set the number of y axis labels. 
 
int num_curves
Number of all curves including grid lines. 
 
void SetXAxisLabelFormat(const std::string fmt)
Set the format string for x axis labels. 
 
void RTBuildAllVTKPipelines(vtkSmartPointer< vtkRenderer > renderer) override final
Build vtk. 
 
void SetPlotLineType(const std::string type)
Set the line type of the next plot. 
 
vtkSmartPointer< vtkDoubleArray > X
 
void SetLegendPosition(double x, double y)
Set the position of the legend box. 
 
std::vector< GridLine > XGridLines
vector holding grid lines 
 
size_t num_plots
Number of "real" plots. 
 
void SetLegendSize(double w, double h)
Set the size of the legend box. 
 
vtkSmartPointer< vtkDoubleArray > Y
 
void SetMarkerSize(double s)
Set the size of all markers in the plot. 
 
void SetAxesColor(double r, double g, double b)
Set the color of the axes. 
 
void SetLineWidth(double w)
Set the width of all lines in the plot. 
 
Info for particular plot lne. 
 
void ShowGrid(bool b)
Show grid lines in the plot ? 
 
void SetYLine(double xrange[2], double y)
 
void SetYAxisLabelFormat(const std::string fmt)
Set the format string for y axis labels. 
 
std::vector< PlotData > AllPlotData
vector holding data of all plots 
 
void PlotGrid()
Plot the label grid. 
 
void SetYRange(double y0, double y1)
Set the range of the y values. 
 
GridLine(vtkSmartPointer< vtkXYPlotActor > plot, int &ds_num, double rgb[3])
 
vtkSmartPointer< vtkDoubleArray > Y
 
static const int desclen
Fixed length string size. 
 
void Clear()
Remove all data from plot.