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

Last change on this file since 85 was 15, checked in by Bayard Gildas, 8 years ago

sources reformatted with flair-format-dir script

File size: 2.2 KB
RevLine 
[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: 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
[15]22namespace flair {
23namespace gui {
[2]24
[15]25DoubleSpinBox::DoubleSpinBox(const LayoutPosition *position, string name,
26 double min, double max, double step, int 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;
[2]35
[15]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);
[2]42
[15]43 SendXml();
[2]44}
45
[15]46DoubleSpinBox::DoubleSpinBox(const LayoutPosition *position, string name,
47 string suffix, double min, double max, double step,
48 int 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;
[2]56
[15]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);
[2]64
[15]65 SendXml();
[2]66}
67
[15]68DoubleSpinBox::~DoubleSpinBox() {}
[2]69
[15]70double DoubleSpinBox::Value(void) const {
71 double tmp;
[2]72
[15]73 GetMutex();
74 tmp = box_value;
75 ReleaseMutex();
[2]76
[15]77 return tmp;
[2]78}
79
[15]80void DoubleSpinBox::XmlEvent(void) {
81 GetMutex();
82 if (GetPersistentXmlProp("value", box_value))
83 SetValueChanged();
84 ReleaseMutex();
[2]85}
86
87} // end namespace gui
88} // end namespace flair
Note: See TracBrowser for help on using the repository browser.