HyperspaceExplorer 0.7.1
ParameterInput.h
00001 /*
00002 Hyperspace Explorer - visualizing higher-dimensional geometry
00003 Copyright (C) 2010  Lene Preuss <lene.preuss@gmail.com>
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License along
00016 with this program; if not, write to the Free Software Foundation, Inc.,
00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 
00021 #ifndef UI_DIALOGSPARAMETERINPUT_H
00022 #define UI_DIALOGSPARAMETERINPUT_H
00023 
00024 #include <QWidget>
00025 #include <QtGui/QLineEdit>
00026 #include <QtGui/QSpinBox>
00027 
00028 #include "FunctionParameter.h"
00029 #include "RotationControl.h"
00030 #include "Rotation.h"
00031 
00032 namespace UI {
00033 
00034     namespace Dialogs {
00035 
00037 
00042         class ParameterInput {
00043             public:
00045                 virtual QString value() const = 0;
00047 
00050                 virtual void setValue(const QString &newValue) = 0;
00051         };
00052 
00054         class ParameterLineEdit: public ParameterInput, public QLineEdit {
00055             public:
00056 
00058                 ParameterLineEdit(QWidget *parent = 0): QLineEdit(parent) { }
00059 
00060                 virtual QString value() const { return QLineEdit::text(); }
00061                 virtual void setValue(const QString &s) { QLineEdit::setText(s); }
00062         };
00063 
00065         class ParameterSpinBox: public ParameterInput, public QSpinBox {
00066             public:
00067 
00069                 ParameterSpinBox(QWidget *parent = 0): QSpinBox(parent) { }
00070 
00071                 virtual QString value() const {
00072                     return QString::number(QSpinBox::value());
00073                 }
00074                 virtual void setValue(const QString &s) {
00075                     QSpinBox::setValue(s.toInt());
00076                 }
00077         };
00078 
00080         class ParameterDoubleSpinBox: public ParameterInput, public QDoubleSpinBox {
00081             public:
00082 
00084                 ParameterDoubleSpinBox(QWidget *parent = 0): QDoubleSpinBox(parent) { }
00085 
00086                 virtual QString value() const {
00087                     return QString::number(QDoubleSpinBox::value());
00088                 }
00089                 virtual void setValue(const QString &s) {
00090                     QDoubleSpinBox::setValue(s.toDouble());
00091                 }
00092         };
00093 
00095         class ParameterRotationControl: public ParameterInput, public RotationControl {
00096             public:
00097 
00099                 ParameterRotationControl(VecMath::RotationBase *rot,
00100                                          QWidget *parent = 0):
00101                     RotationControl(rot, parent) { }
00102 
00104                 virtual QString value() const {
00105                     throw NotYetImplementedException(
00106                             "ParameterRotationControl::value()");
00107                     return QString();
00108 //                    return QString::number(RotationControl::value());
00109                 }
00110 
00112                 virtual void setValue(const QString &) {
00113                     throw NotYetImplementedException(
00114                             "ParameterRotationControl::setValue()");
00115 //                    RotationControl::setValue(s.toDouble());
00116                 }
00117         };
00118 
00120         class ParameterInputFactory {
00121             public:
00122                 static ParameterInput *create(const FunctionParameter &,
00123                                               QWidget * = 0);
00124         };
00125 
00126     }
00127 
00128 }
00129 
00130 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:16 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo