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

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

flaircore

File size: 2.1 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
23{
24namespace gui
25{
26
27DoubleSpinBox::DoubleSpinBox(const LayoutPosition* position,string name,double min,double max,double step,int decimals,double default_value):Box(position,name,"DoubleSpinBox")
28{
29    //update value from xml file
30    if(default_value<min) default_value=min;
31    if(default_value>max) default_value=max;
32    box_value=default_value;
33
34    SetVolatileXmlProp("min",min);
35    SetVolatileXmlProp("max",max);
36    SetVolatileXmlProp("step",step);
37    SetVolatileXmlProp("decimals",decimals);
38    GetPersistentXmlProp("value",box_value);
39    SetPersistentXmlProp("value",box_value);
40
41    SendXml();
42}
43
44DoubleSpinBox::DoubleSpinBox(const LayoutPosition* position,string name,string suffix,double min,double max,double step,int decimals,double default_value):Box(position,name,"DoubleSpinBox")
45{
46    //update value from xml file
47    if(default_value<min) default_value=min;
48    if(default_value>max) default_value=max;
49    box_value=default_value;
50
51    SetVolatileXmlProp("suffix",suffix);
52    SetVolatileXmlProp("min",min);
53    SetVolatileXmlProp("max",max);
54    SetVolatileXmlProp("step",step);
55    SetVolatileXmlProp("decimals",decimals);
56    GetPersistentXmlProp("value",box_value);
57    SetPersistentXmlProp("value",box_value);
58
59    SendXml();
60}
61
62DoubleSpinBox::~DoubleSpinBox()
63{
64
65}
66
67double DoubleSpinBox::Value(void) const
68{
69    double tmp;
70
71    GetMutex();
72    tmp=box_value;
73    ReleaseMutex();
74
75    return tmp;
76}
77
78void DoubleSpinBox::XmlEvent(void)
79{
80    GetMutex();
81    if(GetPersistentXmlProp("value",box_value)) SetValueChanged();
82    ReleaseMutex();
83}
84
85} // end namespace gui
86} // end namespace flair
Note: See TracBrowser for help on using the repository browser.