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

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 6 years ago

flaircore

File size: 2.3 KB
RevLine 
[2]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 { namespace gui {
26
27DataPlot2D::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
37DataPlot2D::~DataPlot2D() {}
38
39void 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
45void 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
Note: See TracBrowser for help on using the repository browser.