[2] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 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 |
|
---|
[15] | 25 | namespace flair {
|
---|
| 26 | namespace gui {
|
---|
[2] | 27 |
|
---|
[15] | 28 | DataPlot2D::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();
|
---|
[2] | 39 | }
|
---|
| 40 |
|
---|
| 41 | DataPlot2D::~DataPlot2D() {}
|
---|
| 42 |
|
---|
[15] | 43 | void 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);
|
---|
[2] | 49 | }
|
---|
| 50 |
|
---|
[15] | 51 | void 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 | }
|
---|
[2] | 61 |
|
---|
[15] | 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);
|
---|
[2] | 73 |
|
---|
[15] | 74 | SendXml();
|
---|
[2] | 75 |
|
---|
[15] | 76 | // save data information
|
---|
| 77 | AddDataToSend(x_element);
|
---|
| 78 | AddDataToSend(y_element);
|
---|
[2] | 79 | }
|
---|
| 80 |
|
---|
| 81 | } // end namespace gui
|
---|
| 82 | } // end namespace flair
|
---|