OpenWalnut  1.5.0dev
WPropertyPositionWidget.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 WPROPERTYPOSITIONWIDGET_H
26 #define WPROPERTYPOSITIONWIDGET_H
27 
28 #include <string>
29 
30 #include <QLineEdit>
31 #include <QSlider>
32 #include <QHBoxLayout>
33 
34 #include "../guiElements/WScaleLabel.h"
35 
36 #include "WPropertyWidget.h"
37 
38 /**
39  * Implements a property widget for WPropDouble.
40  */
42 {
43  Q_OBJECT
44 public:
45  /**
46  * Constructor. Creates a new widget appropriate for the specified property.
47  *
48  * \param property the property to handle
49  * \param parent the parent widget.
50  * \param propertyGrid the grid used to layout the labels and property widgets
51  */
52  WPropertyPositionWidget( WPropPosition property, QGridLayout* propertyGrid, QWidget* parent = 0 );
53 
54  /**
55  * Destructor.
56  */
57  virtual ~WPropertyPositionWidget();
58 
59 protected:
60  /**
61  * Called whenever the widget should update.
62  */
63  virtual void update();
64 
65  /**
66  * The integer property represented by this widget.
67  */
68  WPropPosition m_posProperty;
69 
70  /**
71  * The edit field showing the value of the slider
72  */
73  QLineEdit m_editX;
74 
75  /**
76  * The edit field showing the value of the slider
77  */
78  QLineEdit m_editY;
79 
80  /**
81  * The edit field showing the value of the slider
82  */
83  QLineEdit m_editZ;
84 
85  /**
86  * Layout used to position the label and the widgets
87  */
88  QHBoxLayout m_layout;
89 
90  /**
91  * Used to show the property as text.
92  */
94 
95  /**
96  * The layout used for the pure output (information properties)
97  */
98  QHBoxLayout m_infoLayout;
99 
100  /**
101  * Updates the property using the edit X Y and Z widgets.
102  *
103  * \param validateOnly true if the prop should not really be set. Just validated.
104  */
105  void setPropertyFromWidgets( bool validateOnly = false );
106 
107 private:
108  /**
109  * Helper function converting a position into a nice formatted string.
110  *
111  * \param value the value to convert
112  *
113  * \return a string containing the position in a nicely formatted way.
114  */
115  std::string toString( const WPosition& value );
116 
117  /**
118  * Helper function converting a double into a nice formatted string.
119  *
120  * \param value the value to convert
121  *
122  * \return a string containing the double in a nicely formatted way.
123  */
124  std::string toString( double value );
125 
126 public slots:
127 
128  /**
129  * Called whenever the edit field changes
130  */
131  void editChanged();
132 
133  /**
134  * Called when the text in m_edit changes.
135  *
136  * \param text
137  */
138  void textEdited( const QString& text );
139 };
140 
141 #endif // WPROPERTYPOSITIONWIDGET_H
142 
This only is a 3d double vector.
Implements a property widget for WPropDouble.
virtual void update()
Called whenever the widget should update.
std::string toString(const WPosition &value)
Helper function converting a position into a nice formatted string.
WScaleLabel m_asText
Used to show the property as text.
void setPropertyFromWidgets(bool validateOnly=false)
Updates the property using the edit X Y and Z widgets.
QHBoxLayout m_infoLayout
The layout used for the pure output (information properties)
void textEdited(const QString &text)
Called when the text in m_edit changes.
virtual ~WPropertyPositionWidget()
Destructor.
QLineEdit m_editY
The edit field showing the value of the slider.
WPropertyPositionWidget(WPropPosition property, QGridLayout *propertyGrid, QWidget *parent=0)
Constructor.
WPropPosition m_posProperty
The integer property represented by this widget.
QLineEdit m_editX
The edit field showing the value of the slider.
void editChanged()
Called whenever the edit field changes.
QLineEdit m_editZ
The edit field showing the value of the slider.
QHBoxLayout m_layout
Layout used to position the label and the widgets.
Class building the base for all widgets representing properties.
Special Label that can shrink and expand in a layout.
Definition: WScaleLabel.h:37