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 |
|
---|
23 | using std::string;
|
---|
24 |
|
---|
25 | namespace flair { namespace gui {
|
---|
26 |
|
---|
27 | DataPlot2D::DataPlot2D(const LayoutPosition* position,string name,string x_name,float xmin,float xmax,string y_name,float ymin,float ymax):DataPlot(position,name,"DataPlot2D") {
|
---|
28 | SetVolatileXmlProp("xmin",xmin);
|
---|
29 | SetVolatileXmlProp("xmax",xmax);
|
---|
30 | SetVolatileXmlProp("ymin",ymin);
|
---|
31 | SetVolatileXmlProp("ymax",ymax);
|
---|
32 | SetVolatileXmlProp("x_name",x_name);
|
---|
33 | SetVolatileXmlProp("y_name",y_name);
|
---|
34 | SendXml();
|
---|
35 | }
|
---|
36 |
|
---|
37 | DataPlot2D::~DataPlot2D() {}
|
---|
38 |
|
---|
39 | void DataPlot2D::AddCurve(const core::IODataElement* x_element,const core::IODataElement* y_element,Color_t color,string curve_name) {
|
---|
40 | uint8_t r,g,b;
|
---|
41 | RGBFromColor(color,r,g,b);
|
---|
42 | AddCurve(x_element,y_element,r,g,b,curve_name);
|
---|
43 | }
|
---|
44 |
|
---|
45 | void DataPlot2D::AddCurve(const core::IODataElement* x_element,const core::IODataElement* y_element,uint8_t r,uint8_t g,uint8_t b,string curve_name) {
|
---|
46 | if(typeid(x_element->GetDataType())!=typeid(y_element->GetDataType())) {
|
---|
47 | Err("x_element type is different from y_element type (%i-%i)\n",x_element->GetDataType().GetDescription().c_str(),y_element->GetDataType().GetDescription().c_str());
|
---|
48 | //gerer erreur
|
---|
49 | return;
|
---|
50 | }
|
---|
51 |
|
---|
52 | if(curve_name!="") {
|
---|
53 | SetVolatileXmlProp("curve",curve_name);
|
---|
54 | } else {
|
---|
55 | SetVolatileXmlProp("curve",x_element->Parent()->ObjectName() + "\\" +x_element->ObjectName()+ "\\" +y_element->ObjectName());
|
---|
56 | }
|
---|
57 | SetVolatileXmlProp("type",x_element->GetDataType().GetDescription());
|
---|
58 | SetVolatileXmlProp("r",r);
|
---|
59 | SetVolatileXmlProp("g",g);
|
---|
60 | SetVolatileXmlProp("b",b);
|
---|
61 |
|
---|
62 | SendXml();
|
---|
63 |
|
---|
64 | //save data information
|
---|
65 | AddDataToSend(x_element);
|
---|
66 | AddDataToSend(y_element);
|
---|
67 | }
|
---|
68 |
|
---|
69 | } // end namespace gui
|
---|
70 | } // end namespace flair
|
---|