OpenWalnut  1.5.0dev
WPropertyDoubleWidget.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WPROPERTYDOUBLEWIDGET_H
26 #define WPROPERTYDOUBLEWIDGET_H
27 
28 #include <string>
29 
30 #include <QLineEdit>
31 #include <QSlider>
32 #include <QHBoxLayout>
33 #include <QToolButton>
34 
35 #include "../guiElements/WQtIntervalEdit.h"
36 #include "../guiElements/WScaleLabel.h"
37 
38 #include "WPropertyWidget.h"
39 
40 /**
41  * Implements a property widget for WPropDouble.
42  */
44 {
45  Q_OBJECT
46 public:
47  /**
48  * Constructor. Creates a new widget appropriate for the specified property.
49  *
50  * \param property the property to handle
51  * \param parent the parent widget.
52  * \param propertyGrid the grid used to layout the labels and property widgets
53  */
54  WPropertyDoubleWidget( WPropDouble property, QGridLayout* propertyGrid, QWidget* parent = 0 );
55 
56  /**
57  * Destructor.
58  */
59  virtual ~WPropertyDoubleWidget();
60 
61 protected:
62  /**
63  * Called whenever the widget should update.
64  */
65  virtual void update();
66 
67  /**
68  * The property represented by this widget.
69  */
70  WPropDouble m_integralProperty;
71 
72  /**
73  * The slider allowing modification of the integer value
74  */
75  QSlider m_slider;
76 
77  /**
78  * The edit field showing the value of the slider
79  */
80  QLineEdit m_edit;
81 
82  /**
83  * Layout used to position the label and the checkbox
84  */
85  QHBoxLayout m_layout;
86 
87  /**
88  * Layout used to combine the property widgets with the WQtIntervalEdit.
89  */
90  QVBoxLayout m_vLayout;
91 
92  /**
93  * Converts a given value to a slider value between m_min and m_max.
94  *
95  * \param value the value.
96  *
97  * \return the percentage.
98  */
99  int toSliderValue( double value );
100 
101  /**
102  * Converts the given slider value to the real double value using m_min and m_max.
103  *
104  * \param perc the percentage.
105  *
106  * \return the real double value.
107  */
108  double fromSliderValue( int perc );
109 
110  /**
111  * The current minimum value.
112  */
113  double m_min;
114 
115  /**
116  * The current maximum value.
117  */
118  double m_max;
119 
120  /**
121  * Used to show the property as text.
122  */
124 
125  /**
126  * The layout used for the pure output (information properties)
127  */
128  QHBoxLayout m_infoLayout;
129 
130  /**
131  * The edit for the interval.
132  */
134 
135  /**
136  * Resolution of the slider.
137  */
138  static int SliderResolution;
139 
140 private:
141 public slots:
142 
143  /**
144  * Called whenever the slider changes
145  *
146  * \param value the new value
147  */
148  void sliderChanged( int value );
149 
150  /**
151  * Called whenever the edit field changes
152  */
153  void editChanged();
154 
155  /**
156  * Called when the text in m_edit changes.
157  *
158  * \param text
159  */
160  void textEdited( const QString& text );
161 
162  /**
163  * Called whenever the interval edit changes.
164  */
165  void minMaxUpdated();
166 };
167 
168 #endif // WPROPERTYDOUBLEWIDGET_H
169 
Implements a property widget for WPropDouble.
QLineEdit m_edit
The edit field showing the value of the slider.
WQtIntervalEdit< double, double > m_intervalEdit
The edit for the interval.
int toSliderValue(double value)
Converts a given value to a slider value between m_min and m_max.
QHBoxLayout m_layout
Layout used to position the label and the checkbox.
QSlider m_slider
The slider allowing modification of the integer value.
void textEdited(const QString &text)
Called when the text in m_edit changes.
void minMaxUpdated()
Called whenever the interval edit changes.
void editChanged()
Called whenever the edit field changes.
static int SliderResolution
Resolution of the slider.
double fromSliderValue(int perc)
Converts the given slider value to the real double value using m_min and m_max.
WPropDouble m_integralProperty
The property represented by this widget.
double m_min
The current minimum value.
QHBoxLayout m_infoLayout
The layout used for the pure output (information properties)
QVBoxLayout m_vLayout
Layout used to combine the property widgets with the WQtIntervalEdit.
WPropertyDoubleWidget(WPropDouble property, QGridLayout *propertyGrid, QWidget *parent=0)
Constructor.
WScaleLabel m_asText
Used to show the property as text.
void sliderChanged(int value)
Called whenever the slider changes.
double m_max
The current maximum value.
virtual ~WPropertyDoubleWidget()
Destructor.
virtual void update()
Called whenever the widget should update.
Class building the base for all widgets representing properties.
Special Label that can shrink and expand in a layout.
Definition: WScaleLabel.h:37