source: flair-src/trunk/lib/FlairCore/src/UsSensorPlot.cpp @ 221

Last change on this file since 221 was 221, checked in by Sanahuja Guillaume, 3 years ago

add us plot

File size: 1.9 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:    2018/02/21
6//  filename:   UsSensorPlot.cpp
7//
8//  author:     Guillaume Sanahuja
9//              Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11//  version:    $Id: $
12//
13//  purpose:    Class displaying a plot for raw us sensor
14//
15//
16/*********************************************************************/
17
18#include "UsSensorPlot.h"
19#include "LayoutPosition.h"
20#include "Matrix.h"
21
22using std::string;
23using namespace flair::core;
24
25namespace flair {
26namespace gui {
27
28UsSensorPlot::UsSensorPlot(const LayoutPosition *position, string name,
29                       string y_name,float ymin, float ymax,const Matrix *datas,const Matrix *peakInfos)
30    : DataPlot(position, name, "UsSensorPlot") {
31  int nbSamples;
32  if(datas->Cols()==1) {
33    nbSamples=datas->Rows();
34  } else if(datas->Rows()==1) {
35    nbSamples=datas->Cols();
36  } else {
37    nbSamples=0;
38    Err("matrix must be 1D\n");
39  }
40 
41  if(peakInfos->Cols()!=4 || peakInfos->Rows()!=1) {
42    Err("peakInfos matrix must be 1*4 (first start,first end, second start,second end)\n");
43  }
44 
45  if(peakInfos->GetDataType().GetElementDataType().GetDescription()!="uint16_t") {
46    Err("peakInfos matrix must be 1of type uint16_t\n");
47  }
48   
49  this->datas = datas;
50  this->peakInfos = peakInfos;
51 
52  SetVolatileXmlProp("ymin", ymin);
53  SetVolatileXmlProp("ymax", ymax);
54  SetVolatileXmlProp("y_name", y_name);
55  SetVolatileXmlProp("samples", nbSamples);
56  SetVolatileXmlProp("type", datas->GetDataType().GetElementDataType().GetDescription());
57  SendXml();
58
59  SetSendSize(datas->GetDataType().GetSize()+peakInfos->GetDataType().GetSize());
60}
61
62UsSensorPlot::~UsSensorPlot() {}
63
64void UsSensorPlot::CopyDatas(char *buf) const {
65  datas->CopyDatas(buf);
66  peakInfos->CopyDatas(buf+datas->GetDataType().GetSize());
67}
68
69} // end namespace gui
70} // end namespace flair
Note: See TracBrowser for help on using the repository browser.