![]() |
RTXI 1.3
|
00001 /* 00002 Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 */ 00018 00019 #ifndef DEFAULT_GUI_MODEL_H 00020 #define DEFAULT_GUI_MODEL_H 00021 00022 #include <event.h> 00023 #include <map> 00024 #include <mutex.h> 00025 #include <plugin.h> 00026 #include <qlineedit.h> 00027 #include <rt.h> 00028 #include <workspace.h> 00029 00030 class QLabel; 00031 class QPushButton; 00032 00033 class DefaultGUILineEdit : public QLineEdit { 00034 00035 Q_OBJECT 00036 00037 public: 00038 00039 DefaultGUILineEdit(QWidget *); 00040 ~DefaultGUILineEdit(void); 00041 00042 void blacken(void); 00043 00044 public slots: 00045 00046 void redden(void); 00047 00048 }; // class DefaultGUILineEdit 00049 00053 class DefaultGUIModel : public QWidget, public RT::Thread, public Plugin::Object, public Workspace::Instance, public Event::Handler 00054 { 00055 00056 Q_OBJECT 00057 00058 public: 00059 00065 static const IO::flags_t INPUT = Workspace::INPUT; 00071 static const IO::flags_t OUTPUT = Workspace::OUTPUT; 00077 static const IO::flags_t PARAMETER = Workspace::PARAMETER; 00083 static const IO::flags_t STATE = Workspace::STATE; 00089 static const IO::flags_t EVENT = Workspace::EVENT; 00095 static const IO::flags_t COMMENT = Workspace::COMMENT; 00099 static const IO::flags_t DOUBLE = Workspace::COMMENT<<1; 00103 static const IO::flags_t INTEGER = Workspace::COMMENT<<2; 00107 static const IO::flags_t UINTEGER = Workspace::COMMENT<<3; 00108 00115 typedef Workspace::variable_t variable_t; 00116 00122 enum update_flags_t { 00123 INIT, 00124 MODIFY, 00125 PERIOD, 00126 PAUSE, 00127 UNPAUSE, 00128 EXIT, 00129 }; 00130 00138 DefaultGUIModel(std::string name,variable_t *variables,size_t size); 00139 virtual ~DefaultGUIModel(void); 00140 00148 virtual void update(update_flags_t flag); 00149 00158 void 00159 createGUI(DefaultGUIModel::variable_t *var, int size); 00160 00161 QPushButton *pauseButton; 00162 struct param_t { 00163 QLabel *label; 00164 DefaultGUILineEdit *edit; 00165 IO::flags_t type; 00166 size_t index; 00167 QString *str_value; 00168 }; 00169 std::map<QString,param_t> parameter; 00170 00171 00172 public slots: 00173 00177 void exit(void); 00183 void refresh(void); 00189 void modify(void); 00193 void pause(bool); 00194 00195 protected: 00196 00204 QString getParameter(const QString &name); 00213 void setParameter(const QString &name,double value); 00220 void setParameter(const QString &name,const QString value); 00224 QString getComment(const QString &name); 00228 void setComment(const QString &name,const QString comment); 00229 00239 void setState(const QString &name,double &ref); 00249 void setEvent(const QString &name,double &ref); 00250 00251 private: 00252 00253 void doDeferred(const Settings::Object::State &); 00254 void doLoad(const Settings::Object::State &); 00255 void doSave(Settings::Object::State &) const; 00256 00257 void receiveEvent(const Event::Object *); 00258 00259 bool periodEventPaused; 00260 mutable QString junk; 00261 00262 std::string myname; 00263 00264 }; // class DefaultGUIModel 00265 00266 #endif // DEFUALT_GUI_MODEL_H