00001 /******************************************************************** 00002 Description: FrontEnd using Qt libraries 00003 part of the 3Dsia project 00004 created: StonedBones, 17.2.2000 00005 00006 History: 00007 date, name, changes, in funtion 00008 ??0200 "Tommy" created source 00009 170200 StonedBones integrated it in CVS-tree 00010 180200 StonedBones various changes, now works 00011 00012 ********************************************************************/ 00013 00014 #include "qtFront.h" 00015 00016 #include "qtFrontEnd.h" 00017 #include "../../../common/buffer.h" 00018 00019 #include <qapp.h> 00020 #include <string.h> 00021 00022 int myUsers; 00023 int myMatrices; 00024 Buffer* myStr; 00025 00026 bool usersChanged; 00027 bool matricesChanged; 00028 bool strChanged; 00029 00030 00031 /*................................................................... 00032 Description: Constructor 00033 Args: int argc, char** argv: arguments from 'main' 00034 Returns: <none> 00035 Created: "Tommy", ??.2.2000 00036 [ToDo:] 00037 [Comments:] 00038 Changes: 00039 - 18.2.2000, StonedBones: added global variables and their initializations 00040 -------------------------------------------------------------------*/ 00041 00042 QtFrontEnd::QtFrontEnd (int argc, char** argv) : FrontEnd (argc, argv) { 00043 this->argc=argc; 00044 this->argv=argv; 00045 00046 myUsers = 0; 00047 myMatrices = 0; 00048 00049 usersChanged = false; 00050 matricesChanged = false; 00051 strChanged = false; 00052 00053 myUsers = 0; 00054 myMatrices = 0; 00055 myStr = new Buffer (); 00056 }; 00057 00058 /*................................................................... 00059 Description: the secret constructor... workaround for Qt (see Skelleton) 00060 Args: <none> 00061 Returns: <none> 00062 Created: "Tommy", ??.2.2000 00063 [ToDo:] 00064 [Comments:] 00065 Changes: 00066 - 18.2.2000, StonedBones: added timer for updates 00067 -------------------------------------------------------------------*/ 00068 00069 void QtFrontEnd::init () { 00070 QApplication* qapp; 00071 qapp = new QApplication (argc, argv); 00072 00073 s=new qtFront(); 00074 qapp->setMainWidget(s); 00075 s->show(); 00076 00077 frontUpdate = new FrontUpdate (s, s); 00078 00079 timer = new QTimer (); 00080 QObject::connect (timer, SIGNAL (timeout ()), frontUpdate, SLOT (update ())); 00081 QObject::connect (frontUpdate, SIGNAL (sigUpdate ()), frontUpdate, SLOT (update ())); 00082 timer->start (100, FALSE); 00083 00084 qapp->exec (); 00085 00086 exit (0); 00087 }; 00088 00089 /*................................................................... 00090 Description: Destructor 00091 Args: <none> 00092 Returns: <none> 00093 Created: "Tommy", ??.2.2000 00094 [ToDo:] 00095 [Comments:] 00096 Changes: 00097 -------------------------------------------------------------------*/ 00098 00099 QtFrontEnd::~QtFrontEnd () { 00100 }; 00101 00102 /*................................................................... 00103 Description: update function; not needed for this frontend 00104 Args: <none> 00105 Returns: <none> 00106 Created: "Tommy", ??.2.2000 00107 [ToDo:] 00108 [Comments:] 00109 Changes: 00110 -------------------------------------------------------------------*/ 00111 00112 void QtFrontEnd::update () { 00113 }; 00114 00115 00116 /*................................................................... 00117 Description: displays users currently logged in 00118 Args: int users: guess what :-) 00119 Returns: <none> 00120 Created: "Tommy", ??.2.2000 00121 [ToDo:] 00122 [Comments:] 00123 Changes: 00124 - 18.2.2000, StonedBones: function rewritten 00125 -------------------------------------------------------------------*/ 00126 00127 void QtFrontEnd::displayUsers (int users) { 00128 myUsers = users; 00129 usersChanged = true; 00130 }; 00131 00132 /*................................................................... 00133 Description: display open matrices 00134 Args: int matrices: open matrices 00135 Returns: <none> 00136 Created: "Tommy", ??.2.2000 00137 [ToDo:] 00138 [Comments:] 00139 Changes: 00140 - 18.2.2000, StonedBones: function rewritten 00141 -------------------------------------------------------------------*/ 00142 00143 void QtFrontEnd::displayMatrices (int matrices) { 00144 myMatrices = matrices; 00145 matricesChanged = true; 00146 }; 00147 00148 /*................................................................... 00149 Description: displays debug messages 00150 Args: char* msg: message 00151 Returns: <none> 00152 Created: "Tommy", ??.2.2000 00153 [ToDo:] 00154 [Comments:] 00155 Changes: 00156 - 18.2.2000, StonedBones: function rewritten 00157 -------------------------------------------------------------------*/ 00158 00159 void QtFrontEnd::displayDebugMessage (const char* msg) { 00160 packet tmp; 00161 strcpy (tmp.data, msg); 00162 00163 myStr->write (&tmp); 00164 00165 strChanged = true; 00166 }; 00167 00168 00169 00170 00171 /*................................................................... 00172 Description: constructor for Qt-workaround-object (multi-threading problems) 00173 Args: qtFront* myFront: the actual frontend; QObject* parent: for Qt 00174 Returns: <none> 00175 Created: StonedBones, 18.2.2000 00176 [ToDo:] 00177 [Comments:] 00178 Changes: 00179 -------------------------------------------------------------------*/ 00180 00181 FrontUpdate::FrontUpdate (qtFront* myFront, QObject* parent) : QObject (parent, "frontEndUpdate") { 00182 theFront = myFront; 00183 }; 00184 00185 /*................................................................... 00186 Description: destructor for helper-class 00187 Args: <none> 00188 Returns: <none> 00189 Created: StonedBones, 18.2.2000 00190 [ToDo:] 00191 [Comments:] 00192 Changes: 00193 -------------------------------------------------------------------*/ 00194 00195 FrontUpdate::~FrontUpdate () { 00196 }; 00197 00198 /*................................................................... 00199 Description: the update slot (updates the GUI if needed) 00200 Args: <none> 00201 Returns: <none> 00202 Created: StonedBones, 18.2.2000 00203 [ToDo:] 00204 [Comments:] 00205 Changes: 00206 -------------------------------------------------------------------*/ 00207 00208 void FrontUpdate::update () { 00209 if (usersChanged) { 00210 theFront->LCDusers->display (myUsers); 00211 usersChanged = false; 00212 }; 00213 00214 if (matricesChanged) { 00215 theFront->LCDmatrices->display (myMatrices); 00216 matricesChanged = false; 00217 }; 00218 00219 if (strChanged) { 00220 while (!myStr->isEmpty ()) { 00221 theFront->debugMsgWin->insertLine (myStr->read ()->data); 00222 }; 00223 strChanged = false; 00224 }; 00225 }; 00226