source: flair-src/trunk/lib/FlairCore/src/DoubleSpinBox.cpp@ 440

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

prepare for graphs buffering

File size: 2.3 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: 2011/10/07
6// filename: DoubleSpinBox.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class displaying a QDoubleSpinBox on the ground station
14//
15//
16/*********************************************************************/
17
18#include "DoubleSpinBox.h"
19
20using std::string;
21
22namespace flair {
23namespace gui {
24
25DoubleSpinBox::DoubleSpinBox(const LayoutPosition *position, string name,
26 double min, double max, double step, uint16_t decimals,
27 double default_value)
28 : Box(position, name, "DoubleSpinBox") {
29 // update value from xml file
30 if (default_value < min)
31 default_value = min;
32 if (default_value > max)
33 default_value = max;
34 box_value = default_value;
35
36 SetVolatileXmlProp("min", min);
37 SetVolatileXmlProp("max", max);
38 SetVolatileXmlProp("step", step);
39 SetVolatileXmlProp("decimals", decimals);
40 GetPersistentXmlProp("value", box_value);
41 SetPersistentXmlProp("value", box_value);
42
43 SendXml();
44}
45
46DoubleSpinBox::DoubleSpinBox(const LayoutPosition *position, string name,
47 string suffix, double min, double max, double step,
48 uint16_t decimals, double default_value)
49 : Box(position, name, "DoubleSpinBox") {
50 // update value from xml file
51 if (default_value < min)
52 default_value = min;
53 if (default_value > max)
54 default_value = max;
55 box_value = default_value;
56
57 SetVolatileXmlProp("suffix", suffix);
58 SetVolatileXmlProp("min", min);
59 SetVolatileXmlProp("max", max);
60 SetVolatileXmlProp("step", step);
61 SetVolatileXmlProp("decimals", decimals);
62 GetPersistentXmlProp("value", box_value);
63 SetPersistentXmlProp("value", box_value);
64
65 SendXml();
66}
67
68DoubleSpinBox::~DoubleSpinBox() {}
69
70double DoubleSpinBox::Value(void) const {
71 double tmp;
72
73 GetMutex();
74 tmp = box_value;
75 ReleaseMutex();
76
77 return tmp;
78}
79
80void DoubleSpinBox::XmlEvent(void) {
81 GetMutex();
82 if (GetPersistentXmlProp("value", box_value))
83 SetValueChanged();
84 ReleaseMutex();
85}
86
87} // end namespace gui
88} // end namespace flair
Note: See TracBrowser for help on using the repository browser.