bool TestPlotWithArea::DoTest() { Plot *plot; plot = new Plot(); Area *area = new Area2D(); Box *box1, *box2; box1 = new Box(plot); box2 = new Box(plot); Series *series; series = new Series2D("Series"); DataTyped<int> *xdata; xdata = new DataTyped<int>(); series->SetData(xdata, AXIS_X); area->AddSeries(series); plot->AddArea(area); delete box1; delete plot; return true; }
bool TestSeries2DwithData::DoTest() { Series *serie; serie = new Series2D("new series"); DataNoType *xdata, *ydata; xdata = new DataTyped<double>(100, "x-data"); ydata = new DataTyped<double>(100, "y-data"); serie->SetData(xdata, AXIS_X); serie->SetData(ydata, AXIS_Y); //delete ydata; delete xdata; delete serie; return true; }
// plot a new curve, if a figure of the specified figure name already exists, // the curve will be plot on that figure; if not, a new figure will be created. void PlotManager::Plot(const string figure_name, const float *p, int count, int step, int R, int G, int B) { if (count < 1) return; if (step <= 0) step = 1; // copy data and create a series format. float *data_copy = new float[count]; for (int i = 0; i < count; i++) *(data_copy + i) = *(p + step * i); Series s; s.SetData(count, data_copy); if ((R > 0) || (G > 0) || (B > 0)) s.SetColor(R, G, B, false); // search the named window and create one if none was found active_figure = FindFigure(figure_name); if ( active_figure == NULL) { Figure new_figure(figure_name); figure_list.push_back(new_figure); active_figure = FindFigure(figure_name); if (active_figure == NULL) exit(-1); } active_series = active_figure->Add(s); active_figure->Show(); }