source: flair-src/trunk/lib/FlairCore/src/DataPlot2D.cpp@ 39

Last change on this file since 39 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 2.5 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2013/04/08
6// filename: DataPlot2D.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class displaying a 2D plot on the ground station
14//
15//
16/*********************************************************************/
17
18#include "DataPlot2D.h"
19#include "LayoutPosition.h"
20#include "IODataElement.h"
21#include <typeinfo>
22
23using std::string;
24
25namespace flair {
26namespace gui {
27
28DataPlot2D::DataPlot2D(const LayoutPosition *position, string name,
29 string x_name, float xmin, float xmax, string y_name,
30 float ymin, float ymax)
31 : DataPlot(position, name, "DataPlot2D") {
32 SetVolatileXmlProp("xmin", xmin);
33 SetVolatileXmlProp("xmax", xmax);
34 SetVolatileXmlProp("ymin", ymin);
35 SetVolatileXmlProp("ymax", ymax);
36 SetVolatileXmlProp("x_name", x_name);
37 SetVolatileXmlProp("y_name", y_name);
38 SendXml();
39}
40
41DataPlot2D::~DataPlot2D() {}
42
43void DataPlot2D::AddCurve(const core::IODataElement *x_element,
44 const core::IODataElement *y_element, Color_t color,
45 string curve_name) {
46 uint8_t r, g, b;
47 RGBFromColor(color, r, g, b);
48 AddCurve(x_element, y_element, r, g, b, curve_name);
49}
50
51void DataPlot2D::AddCurve(const core::IODataElement *x_element,
52 const core::IODataElement *y_element, uint8_t r,
53 uint8_t g, uint8_t b, string curve_name) {
54 if (typeid(x_element->GetDataType()) != typeid(y_element->GetDataType())) {
55 Err("x_element type is different from y_element type (%i-%i)\n",
56 x_element->GetDataType().GetDescription().c_str(),
57 y_element->GetDataType().GetDescription().c_str());
58 // gerer erreur
59 return;
60 }
61
62 if (curve_name != "") {
63 SetVolatileXmlProp("curve", curve_name);
64 } else {
65 SetVolatileXmlProp("curve", x_element->Parent()->ObjectName() + "\\" +
66 x_element->ObjectName() + "\\" +
67 y_element->ObjectName());
68 }
69 SetVolatileXmlProp("type", x_element->GetDataType().GetDescription());
70 SetVolatileXmlProp("r", r);
71 SetVolatileXmlProp("g", g);
72 SetVolatileXmlProp("b", b);
73
74 SendXml();
75
76 // save data information
77 AddDataToSend(x_element);
78 AddDataToSend(y_element);
79}
80
81} // end namespace gui
82} // end namespace flair
Note: See TracBrowser for help on using the repository browser.