VTKFIG  0.20.20181114
Easy VTK based in situ visualization
int main ( void  )

Definition at line 14 of file example-chartxy.cxx.

15 {
16  size_t nspin=vtkfig::NSpin();
17  auto frame=vtkfig::Frame::New();
18  frame->SetLayout(0,0);
19 
20 
21  const int NN = 100;
22  const double t_low = 0;
23  const double t_upp = 5;
24  const double dt = (t_upp-t_low)/(NN-1);
25 
26 
27  std::vector<double> x1(NN);
28  std::vector<double> y1(NN);
29  std::vector<double> x2(NN);
30  std::vector<double> y2(NN);
31 
32 
33 
34 
35  std::string title;
36 
37  double tt=0;
38  size_t ii=0;
39 
40  double t0=(double)clock()/(double)CLOCKS_PER_SEC;
41  double i0=ii;
42  auto chartxy=vtkfig::ChartXY::New();
43 
44  frame->AddFigure(chartxy);
45 
46  while (ii<nspin)
47  {
48  double t = tt;
49 
50 
51  for (int i=0; i<NN; i++)
52  {
53  x1[i] = cos(t)*t;
54  y1[i] = sin(t);
55  x2[i] = sin(t)*t+1;
56  y2[i] = cos(t)*(0.1-t);
57  t+=dt;
58  }
59 
60  char titlebuf[20];
61 
62  snprintf(titlebuf,20,"frame %lu",ii++);
63  chartxy->Clear();
64  chartxy->Title(titlebuf);
65  chartxy->LineColorRGB(0,0,1);
66  chartxy->LineType("-");
67  chartxy->AddPlot(x1, y1);
68  chartxy->LineColorRGB(1,0,0);
69  chartxy->LineType(".-");
70  chartxy->AddPlot(x2, y2);
71 
72 
73 // frame->Interact();
74  frame->Show();
75 
76  if (ii==3)
77  frame->WritePNG("example-chartxy.png");
78 
79  double t1=(double)clock()/(double)CLOCKS_PER_SEC;
80  double i1=ii;
81  if (t1-t0>4.0)
82  {
83  printf("Frame rate: %.2f fps\n",(double)(i1-i0)/4.0);
84  fflush(stdout);
85  t0=(double)clock()/(double)CLOCKS_PER_SEC;
86  i0=ii;
87  }
88  tt+=0.1;
89  }
90 
91 }
size_t NSpin()
Definition: vtkfigTools.cxx:13
static std::shared_ptr< Frame > New()
Create frame with multiple subframes.
Definition: vtkfigFrame.h:54
static std::shared_ptr< Figure > New()
Construct smartpointer to empty figure.
Definition: vtkfigFigure.h:61

+ Here is the call graph for this function: