[484] | 1 | // TODO ! |
---|
| 2 | |
---|
[481] | 3 | // |
---|
| 4 | // ******************************************************************** |
---|
| 5 | // * License and Disclaimer * |
---|
| 6 | // * * |
---|
| 7 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 8 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 9 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 10 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 11 | // * include a list of copyright holders. * |
---|
| 12 | // * * |
---|
| 13 | // * Neither the authors of this software system, nor their employing * |
---|
| 14 | // * institutes,nor the agencies providing financial support for this * |
---|
| 15 | // * work make any representation or warranty, express or implied, * |
---|
| 16 | // * regarding this software system or assume any liability for its * |
---|
| 17 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 18 | // * for the full disclaimer and the limitation of liability. * |
---|
| 19 | // * * |
---|
| 20 | // * This code implementation is the result of the scientific and * |
---|
| 21 | // * technical work of the GEANT4 collaboration. * |
---|
| 22 | // * By using, copying, modifying or distributing the software (or * |
---|
| 23 | // * any work based on the software) you agree to acknowledge its * |
---|
| 24 | // * use in resulting scientific publications, and indicate your * |
---|
| 25 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 26 | // ******************************************************************** |
---|
| 27 | // |
---|
| 28 | // |
---|
[484] | 29 | // $Id: G4UIQt.cc,v 1.14 2007/05/29 11:09:49 $ |
---|
[481] | 30 | // GEANT4 tag $Name: geant4-08-01 $ |
---|
| 31 | // |
---|
[484] | 32 | // L. Garnier |
---|
[481] | 33 | |
---|
| 34 | //#define DEBUG |
---|
| 35 | |
---|
| 36 | #ifdef G4UI_BUILD_QT_SESSION |
---|
| 37 | |
---|
| 38 | #include "G4Types.hh" |
---|
| 39 | |
---|
| 40 | #include <string.h> |
---|
| 41 | |
---|
| 42 | #include "G4UIQt.hh" |
---|
| 43 | #include "G4UImanager.hh" |
---|
| 44 | #include "G4StateManager.hh" |
---|
| 45 | #include "G4UIcommandTree.hh" |
---|
| 46 | #include "G4UIcommandStatus.hh" |
---|
| 47 | |
---|
| 48 | #include "G4Qt.hh" |
---|
| 49 | |
---|
| 50 | #include <QtGui/qapplication.h> |
---|
| 51 | #include <QtGui/qwidget.h> |
---|
[487] | 52 | #include <QtGui/qmenu.h> |
---|
| 53 | #include <QtGui/qmenubar.h> |
---|
| 54 | #include <QtGui/qboxlayout.h> |
---|
[488] | 55 | #include <QtGui/qpushbutton.h> |
---|
| 56 | #include <QtGui/qlabel.h> |
---|
[495] | 57 | #include <QtGui/qsplitter.h> |
---|
[496] | 58 | #include <QtGui/qlistview.h> // en test |
---|
| 59 | #include <QtGui/qtreeview.h> // en test |
---|
[481] | 60 | |
---|
| 61 | #include <stdlib.h> |
---|
| 62 | |
---|
| 63 | static G4bool ConvertStringToInt(const char*,int&); |
---|
| 64 | //static void ExecuteChangeSizeFunction(Widget); |
---|
| 65 | |
---|
| 66 | static G4bool exitSession = true; |
---|
| 67 | static G4bool exitPause = true; |
---|
| 68 | static G4bool exitHelp = true; |
---|
| 69 | /***************************************************************************/ |
---|
| 70 | /** |
---|
| 71 | Build a Qt window with a menubar, output area and promt area |
---|
| 72 | +-----------------------+ |
---|
| 73 | |exit menu| | |
---|
| 74 | | | |
---|
| 75 | | +-------------------+ | |
---|
| 76 | | | | | |
---|
| 77 | | | Output area | | |
---|
| 78 | | | | | |
---|
| 79 | | +-------------------+ | |
---|
[488] | 80 | | | clear | | |
---|
[481] | 81 | | +-------------------+ | |
---|
[494] | 82 | | | promt history | | |
---|
| 83 | | +-------------------+ | |
---|
| 84 | | +-------------------+ | |
---|
[481] | 85 | | |> promt area | | |
---|
| 86 | | +-------------------+ | |
---|
[484] | 87 | +-----------------------+ |
---|
[481] | 88 | */ |
---|
| 89 | |
---|
| 90 | G4UIQt::G4UIQt ( |
---|
| 91 | int argc, |
---|
| 92 | char** argv |
---|
| 93 | ) |
---|
| 94 | /***************************************************************************/ |
---|
| 95 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 96 | { |
---|
[496] | 97 | G4Qt* interactorManager = G4Qt::getInstance (); |
---|
[484] | 98 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP |
---|
| 99 | if(UI!=NULL) UI->SetSession(this); // TO KEEP |
---|
[481] | 100 | |
---|
[494] | 101 | fMainWindow = new QMainWindow(); |
---|
| 102 | fMainWindow->setWindowTitle( "G4UI Session" ); |
---|
[496] | 103 | |
---|
[495] | 104 | QWidget* central = new QWidget(); |
---|
| 105 | |
---|
[496] | 106 | /* |
---|
| 107 | QSplitter *splitter = new QSplitter(Qt::Vertical,central); |
---|
| 108 | splitter->setMaximumSize(800,800); |
---|
| 109 | QListView *listview = new QListView; |
---|
| 110 | listview->setMaximumSize(800,800); |
---|
| 111 | QTreeView *treeview = new QTreeView; |
---|
| 112 | treeview->setMaximumSize(800,800); |
---|
| 113 | */ |
---|
| 114 | QTextEdit *textedit = new QTextEdit; |
---|
| 115 | // textedit->setMaximumSize(800,800); |
---|
[490] | 116 | QPushButton *clearButton = new QPushButton("clear"); |
---|
[496] | 117 | |
---|
| 118 | QVBoxLayout *layout = new QVBoxLayout; |
---|
| 119 | layout->addWidget(textedit); |
---|
| 120 | layout->addWidget(clearButton); |
---|
| 121 | central->setLayout(layout); |
---|
| 122 | /* |
---|
| 123 | QSizePolicy *test = new QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); |
---|
| 124 | if (splitter->sizePolicy().horizontalPolicy () == test->horizontalPolicy () ) { |
---|
| 125 | printf ("splitter H is fixed\n"); |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | printf("list SP H: %d\n",listview->sizePolicy().horizontalPolicy ()); |
---|
| 129 | printf("list SP V: %d\n",listview->sizePolicy().verticalPolicy ()); |
---|
| 130 | printf("tree SP H: %d\n",treeview->sizePolicy().horizontalPolicy ()); |
---|
| 131 | printf("tree SP V: %d\n",treeview->sizePolicy().verticalPolicy ()); |
---|
| 132 | printf("text SP H: %d\n",textedit->sizePolicy().horizontalPolicy ()); |
---|
| 133 | printf("text SP V: %d\n",textedit->sizePolicy().verticalPolicy ()); |
---|
| 134 | |
---|
| 135 | splitter->addWidget(listview); |
---|
| 136 | splitter->addWidget(treeview); |
---|
| 137 | splitter->addWidget(textedit); |
---|
| 138 | */ |
---|
| 139 | fMainWindow->setCentralWidget(central); |
---|
[481] | 140 | |
---|
[496] | 141 | ////////////// |
---|
| 142 | // fMainWindow->resize(600,400); |
---|
| 143 | // QWidget* central = new QWidget(); |
---|
| 144 | // QWidget* topWidget = new QWidget(); |
---|
| 145 | // QWidget* bottomWidget = new QWidget(); |
---|
| 146 | // QVBoxLayout* vBox1 = new QVBoxLayout(topWidget); |
---|
| 147 | // QVBoxLayout* vBox2 = new QVBoxLayout(bottomWidget); |
---|
[494] | 148 | |
---|
[496] | 149 | // QSplitter *splitter = new QSplitter(Qt::Vertical); |
---|
| 150 | // fTextArea = new QTextEdit(); |
---|
| 151 | // fCommandHistoryArea = new QTextEdit(); |
---|
| 152 | // fCommandLabel = new QLabel(); |
---|
[490] | 153 | |
---|
[496] | 154 | // QPushButton *clearButton = new QPushButton("clear"); |
---|
| 155 | // connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback())); |
---|
[494] | 156 | |
---|
[496] | 157 | // fTextArea->setReadOnly(true); |
---|
| 158 | // fCommandHistoryArea->setReadOnly(true); |
---|
[490] | 159 | |
---|
[496] | 160 | // // QMenu *menuFile = new QMenu("File"); |
---|
| 161 | // // fMainWindow->menuBar()->addMenu(menuFile); |
---|
[495] | 162 | |
---|
[496] | 163 | // fCommandArea = new QLineEdit(); |
---|
| 164 | // connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback())); |
---|
[495] | 165 | |
---|
[496] | 166 | // vBox1->addWidget(fTextArea); |
---|
| 167 | // vBox1->addWidget(clearButton); |
---|
| 168 | // vBox1->setStretchFactor(fTextArea,1); |
---|
[495] | 169 | |
---|
[496] | 170 | // vBox2->addWidget(fCommandHistoryArea); |
---|
| 171 | // vBox2->addWidget(fCommandLabel); |
---|
| 172 | // vBox2->addWidget(fCommandArea); |
---|
| 173 | // vBox2->setStretchFactor(fCommandHistoryArea,1); |
---|
[495] | 174 | |
---|
[496] | 175 | // splitter->addWidget(topWidget); |
---|
| 176 | // splitter->addWidget(bottomWidget); |
---|
| 177 | |
---|
| 178 | // fMainWindow->setCentralWidget(central); |
---|
| 179 | //////////////// |
---|
| 180 | |
---|
[484] | 181 | // QMainWindow top = (QMainWindow)interactorManager->GetMainInteractor(); |
---|
[481] | 182 | |
---|
| 183 | // if(getenv("XENVIRONMENT")==NULL) { |
---|
| 184 | // XrmDatabase database = XrmGetDatabase(XtDisplay(top)); |
---|
| 185 | // if(database!=NULL) { |
---|
| 186 | // XrmPutLineResource(&database,"*topShadowColor:white"); |
---|
| 187 | // XrmPutLineResource(&database,"*bottomShadowColor:black"); |
---|
| 188 | // XrmPutLineResource(&database,"*foreground:black"); |
---|
| 189 | // XrmPutLineResource(&database,"*background:lightgrey"); |
---|
| 190 | // XrmPutLineResource(&database,"*borderColor:lightgrey"); |
---|
| 191 | // XrmPutLineResource(&database,"*fontList:-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"); |
---|
| 192 | // XrmPutLineResource(&database,"*text.background:white"); |
---|
| 193 | // XrmPutLineResource(&database,"*text.fontList:*courier*-r-*--14-*"); |
---|
| 194 | // XrmPutLineResource(&database,"*text.maxLength:8000"); |
---|
| 195 | // } |
---|
| 196 | // } |
---|
| 197 | |
---|
| 198 | // Arg args[9]; |
---|
| 199 | // XtSetArg(args[0],XmNkeyboardFocusPolicy,XmPOINTER); // For completion. |
---|
| 200 | // shell = XtAppCreateShell ("G4UIXm","G4UIXm", |
---|
| 201 | // topLevelShellWidgetClass,XtDisplay(top), |
---|
| 202 | // args,1); |
---|
| 203 | // form = XmCreateForm (shell,(char*)"form",NULL,0); |
---|
| 204 | // XtManageChild (form); |
---|
| 205 | |
---|
| 206 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM); |
---|
| 207 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 208 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 209 | // menuBar = XmCreateMenuBar (form,(char*)"menuBar",args,3); |
---|
| 210 | |
---|
| 211 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE); |
---|
| 212 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 213 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 214 | // XtSetArg(args[3],XmNbottomAttachment ,XmATTACH_FORM); |
---|
| 215 | // command = XmCreateCommand (form,(char*)"command",args,4); |
---|
| 216 | // XtManageChild (command); |
---|
| 217 | |
---|
| 218 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE); |
---|
| 219 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 220 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 221 | // XtSetArg(args[3],XmNbottomAttachment,XmATTACH_WIDGET); |
---|
| 222 | // XtSetArg(args[4],XmNbottomWidget ,command); |
---|
| 223 | // XmString cps = XmStringLtoRCreate((char*)"Clear",XmSTRING_DEFAULT_CHARSET); |
---|
| 224 | // XtSetArg (args[5],XmNlabelString,cps); |
---|
| 225 | // Widget clearButton = XmCreatePushButton(form,(char*)"clearButton",args,6); |
---|
| 226 | // XmStringFree (cps); |
---|
| 227 | // XtManageChild (clearButton); |
---|
| 228 | |
---|
| 229 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_WIDGET); |
---|
| 230 | // XtSetArg(args[1],XmNtopWidget ,menuBar); |
---|
| 231 | // XtSetArg(args[2],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 232 | // XtSetArg(args[3],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 233 | // XtSetArg(args[4],XmNbottomAttachment,XmATTACH_WIDGET); |
---|
| 234 | // XtSetArg(args[5],XmNbottomWidget ,clearButton); |
---|
| 235 | // XtSetArg(args[6],XmNeditMode ,XmMULTI_LINE_EDIT); |
---|
| 236 | // XtSetArg(args[7],XmNrows ,12); |
---|
| 237 | // XtSetArg(args[8],XmNcolumns ,80); |
---|
[484] | 238 | // text = XmCreateSGcrolledText (form,(char*)"text",args,9); |
---|
[481] | 239 | // XtManageChild (text); |
---|
| 240 | |
---|
| 241 | // XtAddCallback(clearButton,XmNactivateCallback, |
---|
| 242 | // clearButtonCallback,(XtPointer)text); |
---|
| 243 | // XtAddCallback(command,XmNcommandEnteredCallback, |
---|
| 244 | // commandEnteredCallback,(XtPointer)this); |
---|
| 245 | |
---|
| 246 | // Widget commandText = XmCommandGetChild(command,XmDIALOG_COMMAND_TEXT); |
---|
| 247 | // XtAddEventHandler(commandText,KeyPressMask,False,keyHandler,(XtPointer)this); |
---|
| 248 | |
---|
| 249 | // XtRealizeWidget(shell); |
---|
| 250 | // XtMapWidget(shell); |
---|
| 251 | |
---|
[484] | 252 | if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP |
---|
[481] | 253 | } |
---|
| 254 | /***************************************************************************/ |
---|
| 255 | G4UIQt::~G4UIQt( |
---|
| 256 | ) |
---|
| 257 | /***************************************************************************/ |
---|
| 258 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 259 | { |
---|
[484] | 260 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP |
---|
| 261 | if(UI!=NULL) { // TO KEEP |
---|
| 262 | UI->SetSession(NULL); // TO KEEP |
---|
| 263 | UI->SetCoutDestination(NULL); // TO KEEP |
---|
[481] | 264 | } |
---|
[484] | 265 | |
---|
| 266 | |
---|
[494] | 267 | if (fMainWindow!=NULL) |
---|
| 268 | delete fMainWindow; |
---|
[481] | 269 | } |
---|
| 270 | /***************************************************************************/ |
---|
| 271 | /* |
---|
| 272 | Start the Qt main loop |
---|
| 273 | */ |
---|
| 274 | G4UIsession* G4UIQt::SessionStart ( |
---|
| 275 | ) |
---|
| 276 | /***************************************************************************/ |
---|
| 277 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 278 | { |
---|
[484] | 279 | |
---|
[496] | 280 | G4Qt* interactorManager = G4Qt::getInstance (); |
---|
[494] | 281 | fMainWindow->show(); |
---|
| 282 | Prompt("session"); |
---|
| 283 | exitSession = false; |
---|
[481] | 284 | |
---|
[496] | 285 | |
---|
| 286 | printf("disable secondary loop\n"); |
---|
| 287 | interactorManager->DisableSecondaryLoop (); // TO KEEP |
---|
| 288 | ((QApplication*)interactorManager->GetMainInteractor())->exec(); |
---|
| 289 | // on ne passe pas le dessous ? FIXME ???? |
---|
| 290 | |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | |
---|
| 295 | |
---|
[484] | 296 | // void* event; // TO KEEP |
---|
| 297 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
| 298 | // interactorManager->DispatchEvent(event); // TO KEEP |
---|
| 299 | // if(exitSession==true) break; // TO KEEP |
---|
| 300 | // } // TO KEEP |
---|
[496] | 301 | interactorManager->EnableSecondaryLoop (); // TO KEEP |
---|
| 302 | printf("enable secondary loop\n"); |
---|
[484] | 303 | return this; // TO KEEP |
---|
[481] | 304 | } |
---|
| 305 | /***************************************************************************/ |
---|
[494] | 306 | |
---|
[481] | 307 | /** |
---|
| 308 | Display the prompt in the prompt area |
---|
| 309 | */ |
---|
| 310 | void G4UIQt::Prompt ( |
---|
| 311 | G4String aPrompt |
---|
| 312 | ) |
---|
| 313 | /***************************************************************************/ |
---|
| 314 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 315 | { |
---|
[496] | 316 | // fCommandLabel->setText((char*)aPrompt.data()); |
---|
[481] | 317 | } |
---|
| 318 | /***************************************************************************/ |
---|
| 319 | void G4UIQt::SessionTerminate ( |
---|
| 320 | ) |
---|
| 321 | /***************************************************************************/ |
---|
| 322 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 323 | { |
---|
| 324 | } |
---|
| 325 | /***************************************************************************/ |
---|
| 326 | void G4UIQt::PauseSessionStart ( |
---|
| 327 | G4String a_state |
---|
| 328 | ) |
---|
| 329 | /***************************************************************************/ |
---|
| 330 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 331 | { |
---|
[484] | 332 | if(a_state=="G4_pause> ") { // TO KEEP |
---|
| 333 | SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP |
---|
| 334 | } // TO KEEP |
---|
[481] | 335 | |
---|
[484] | 336 | if(a_state=="EndOfEvent") { // TO KEEP |
---|
[481] | 337 | // Picking with feed back in event data Done here !!! |
---|
[484] | 338 | SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP |
---|
| 339 | } // TO KEEP |
---|
[481] | 340 | } |
---|
| 341 | /***************************************************************************/ |
---|
[484] | 342 | void G4UIQt::SecondaryLoop ( |
---|
[481] | 343 | G4String a_prompt |
---|
| 344 | ) |
---|
| 345 | /***************************************************************************/ |
---|
| 346 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 347 | { |
---|
[484] | 348 | G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? |
---|
| 349 | Prompt(a_prompt); // TO KEEP |
---|
| 350 | exitPause = false; // TO KEEP |
---|
| 351 | void* event; // TO KEEP |
---|
| 352 | while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
| 353 | interactorManager->DispatchEvent(event); // TO KEEP |
---|
| 354 | if(exitPause==true) break; // TO KEEP |
---|
| 355 | } // TO KEEP |
---|
| 356 | Prompt("session"); // TO KEEP |
---|
[481] | 357 | } |
---|
| 358 | /***************************************************************************/ |
---|
| 359 | /** |
---|
| 360 | Receive a cout from Geant4. We have to display it in the cout zone |
---|
| 361 | */ |
---|
[484] | 362 | G4int G4UIQt::ReceiveG4cout ( |
---|
[481] | 363 | G4String a_string |
---|
| 364 | ) |
---|
| 365 | /***************************************************************************/ |
---|
| 366 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 367 | { |
---|
[496] | 368 | // fTextArea->append((char*)a_string.data()); |
---|
[495] | 369 | return 0; |
---|
[481] | 370 | } |
---|
| 371 | /***************************************************************************/ |
---|
| 372 | /** |
---|
| 373 | Receive a cerr from Geant4. We have to display it in the cout zone |
---|
| 374 | */ |
---|
[484] | 375 | G4int G4UIQt::ReceiveG4cerr ( |
---|
[481] | 376 | G4String a_string |
---|
| 377 | ) |
---|
| 378 | /***************************************************************************/ |
---|
| 379 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 380 | { |
---|
[496] | 381 | // fTextArea->append((char*)a_string.data()); |
---|
[495] | 382 | return 0; |
---|
[481] | 383 | } |
---|
| 384 | /***************************************************************************/ |
---|
[484] | 385 | G4bool G4UIQt::GetHelpChoice( |
---|
[481] | 386 | G4int& aInt |
---|
| 387 | ) |
---|
| 388 | /***************************************************************************/ |
---|
| 389 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 390 | { |
---|
[484] | 391 | // fHelp = true; // TO KEEP |
---|
| 392 | // // SecondaryLoop : // TO KEEP |
---|
| 393 | // G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? |
---|
| 394 | // Prompt("Help"); // TO KEEP |
---|
| 395 | // exitHelp = false; // TO KEEP |
---|
| 396 | // void* event; // TO KEEP |
---|
| 397 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
| 398 | // interactorManager->DispatchEvent(event); // TO KEEP |
---|
| 399 | // if(exitHelp==true) break; // TO KEEP |
---|
| 400 | // } // TO KEEP |
---|
| 401 | // Prompt("session"); // TO KEEP |
---|
| 402 | // // // TO KEEP |
---|
| 403 | // if(fHelp==false) return false; // TO KEEP |
---|
| 404 | // aInt = fHelpChoice; // TO KEEP |
---|
| 405 | // fHelp = false; // TO KEEP |
---|
| 406 | // return true; // TO KEEP |
---|
[481] | 407 | } |
---|
| 408 | /***************************************************************************/ |
---|
[484] | 409 | void G4UIQt::ExitHelp( |
---|
[481] | 410 | ) |
---|
| 411 | /***************************************************************************/ |
---|
| 412 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 413 | { |
---|
| 414 | } |
---|
| 415 | /***************************************************************************/ |
---|
[484] | 416 | void G4UIQt::AddMenu ( |
---|
[481] | 417 | const char* a_name |
---|
| 418 | ,const char* a_label |
---|
| 419 | ) |
---|
| 420 | /***************************************************************************/ |
---|
| 421 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 422 | { |
---|
| 423 | // if(menuBar==NULL) return; |
---|
| 424 | // if(a_name==NULL) return; |
---|
| 425 | // if(a_label==NULL) return; |
---|
| 426 | // XtManageChild (menuBar); |
---|
| 427 | // // Pulldown menu : |
---|
| 428 | // Widget widget; |
---|
| 429 | // widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0); |
---|
| 430 | // AddInteractor (a_name,(G4Interactor)widget); |
---|
| 431 | // // Cascade button : |
---|
| 432 | // Arg args[2]; |
---|
| 433 | // XmString cps = XmStringLtoRCreate((char*)a_label,XmSTRING_DEFAULT_CHARSET); |
---|
| 434 | // XtSetArg (args[0],XmNlabelString,cps); |
---|
| 435 | // XtSetArg (args[1],XmNsubMenuId,widget); |
---|
| 436 | // widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2); |
---|
| 437 | // XmStringFree (cps); |
---|
| 438 | // XtManageChild (widget); |
---|
| 439 | // ExecuteChangeSizeFunction(form); |
---|
| 440 | } |
---|
| 441 | /***************************************************************************/ |
---|
[484] | 442 | void G4UIQt::AddButton ( |
---|
[481] | 443 | const char* a_menu |
---|
| 444 | ,const char* a_label |
---|
| 445 | ,const char* a_command |
---|
| 446 | ) |
---|
| 447 | /***************************************************************************/ |
---|
| 448 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 449 | { |
---|
[484] | 450 | // if(a_menu==NULL) return; // TO KEEP |
---|
| 451 | // if(a_label==NULL) return; // TO KEEP |
---|
| 452 | // if(a_command==NULL) return; // TO KEEP |
---|
[481] | 453 | // Widget parent = (Widget)GetInteractor(a_menu); |
---|
| 454 | // if(parent==NULL) return; |
---|
| 455 | // Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0); |
---|
| 456 | // XtManageChild (widget); |
---|
| 457 | // XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this); |
---|
| 458 | // commands[widget] = a_command; |
---|
[491] | 459 | } |
---|
[481] | 460 | // /***************************************************************************/ |
---|
| 461 | // G4String G4UIXm::GetCommand ( |
---|
| 462 | // Widget a_widget |
---|
| 463 | // ) |
---|
| 464 | // /***************************************************************************/ |
---|
| 465 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 466 | // { |
---|
| 467 | // return commands[a_widget]; |
---|
| 468 | // } |
---|
| 469 | /***************************************************************************/ |
---|
| 470 | /***************************************************************************/ |
---|
| 471 | /***************************************************************************/ |
---|
[494] | 472 | |
---|
[481] | 473 | /** |
---|
[494] | 474 | Callback call when "enter" clicked on the command zone. |
---|
[481] | 475 | Send the command to geant4 |
---|
| 476 | */ |
---|
[484] | 477 | // TODO ! |
---|
[494] | 478 | void G4UIQt::commandEnteredCallback ( |
---|
| 479 | ) |
---|
[481] | 480 | /***************************************************************************/ |
---|
| 481 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
[494] | 482 | { |
---|
[496] | 483 | /* fCommandHistoryArea->append(fCommandArea->text()); |
---|
[494] | 484 | G4String command (fCommandArea->text().toStdString().c_str()); |
---|
| 485 | if(fHelp==true) { |
---|
| 486 | exitHelp = true; |
---|
| 487 | fHelp = ConvertStringToInt(command.data(),fHelpChoice); |
---|
| 488 | } else { |
---|
| 489 | ApplyShellCommand (command,exitSession,exitPause); |
---|
| 490 | } |
---|
[495] | 491 | fCommandArea->setText(""); |
---|
[496] | 492 | */ |
---|
[494] | 493 | } |
---|
[481] | 494 | // /***************************************************************************/ |
---|
| 495 | // void G4UIXm::keyHandler ( |
---|
| 496 | // Widget a_widget |
---|
| 497 | // ,XtPointer a_tag |
---|
| 498 | // ,XEvent* a_event |
---|
| 499 | // ,Boolean* |
---|
| 500 | // ) |
---|
| 501 | // /***************************************************************************/ |
---|
| 502 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 503 | // { |
---|
| 504 | // KeySym keySym; |
---|
| 505 | // XLookupString(&(a_event->xkey),NULL,0,&keySym,NULL); |
---|
| 506 | // if(keySym!=XK_Tab) return; |
---|
| 507 | // G4UIXm* This = (G4UIXm*)a_tag; |
---|
| 508 | // char* s = XmTextGetString(a_widget); |
---|
| 509 | // G4String ss = This->Complete(s); |
---|
| 510 | // XmTextSetString(a_widget,(char*)ss.data()); |
---|
| 511 | // XtFree(s); |
---|
| 512 | // XmTextSetInsertionPosition(a_widget,XmTextGetLastPosition(a_widget)); |
---|
| 513 | //} |
---|
[488] | 514 | |
---|
| 515 | /***************************************************************************/ |
---|
[491] | 516 | void G4UIQt::clearButtonCallback ( |
---|
| 517 | ) |
---|
[481] | 518 | /***************************************************************************/ |
---|
| 519 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
[491] | 520 | { |
---|
[496] | 521 | // fTextArea->clear(); |
---|
[491] | 522 | } |
---|
| 523 | |
---|
[481] | 524 | /***************************************************************************/ |
---|
[484] | 525 | // TODO ! |
---|
| 526 | //void G4UIQt::ButtonCallback ( |
---|
| 527 | // Widget a_widget |
---|
| 528 | //,XtPointer a_tag |
---|
| 529 | //,XtPointer |
---|
| 530 | //) |
---|
[481] | 531 | /***************************************************************************/ |
---|
| 532 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
[484] | 533 | //{ |
---|
[481] | 534 | // G4UIXm* This = (G4UIXm*)a_tag; |
---|
| 535 | // if(This->fHelp==true) return; // Disabled when in help. |
---|
| 536 | // G4String ss = This->GetCommand (a_widget); |
---|
| 537 | // //printf ("debug : execute:\n%s\n",ss.data()); |
---|
| 538 | // This->ApplyShellCommand(ss,exitSession,exitPause); |
---|
[484] | 539 | //} |
---|
[481] | 540 | /***************************************************************************/ |
---|
| 541 | /***************************************************************************/ |
---|
| 542 | /***************************************************************************/ |
---|
| 543 | // char* XmConvertCompoundStringToString ( |
---|
| 544 | // XmString a_cps |
---|
| 545 | // ,int a_number |
---|
| 546 | // ) |
---|
| 547 | // /***************************************************************************/ |
---|
| 548 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 549 | // { |
---|
| 550 | // if(a_cps==NULL) return NULL; |
---|
| 551 | // char* ss = NULL; |
---|
| 552 | // XmStringContext context; |
---|
| 553 | // XmStringInitContext(&context,a_cps); |
---|
| 554 | // int icount = 0; |
---|
| 555 | // Boolean Done = False; |
---|
| 556 | // while(Done==False) { |
---|
| 557 | // char* text = NULL; |
---|
| 558 | // XmStringCharSet charset = NULL; |
---|
| 559 | // XmStringDirection direct; |
---|
| 560 | // Boolean sep; |
---|
| 561 | // if(XmStringGetNextSegment(context,&text,&charset,&direct,&sep)==True) { |
---|
| 562 | // XtFree(charset); |
---|
| 563 | // if(sep==True) Done = True; |
---|
| 564 | // if(icount==a_number) { |
---|
| 565 | // ss = text; |
---|
| 566 | // break; |
---|
| 567 | // } |
---|
| 568 | // icount++; |
---|
| 569 | // XtFree(text); |
---|
| 570 | // } |
---|
| 571 | // else |
---|
| 572 | // Done = True; |
---|
| 573 | // } |
---|
| 574 | // XmStringFreeContext(context); |
---|
| 575 | // return ss; |
---|
[491] | 576 | //} |
---|
[481] | 577 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 578 | G4bool ConvertStringToInt( |
---|
| 579 | const char* aString |
---|
| 580 | ,int& aInt |
---|
| 581 | ) |
---|
| 582 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 583 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 584 | { |
---|
[484] | 585 | aInt = 0; // TO KEEP |
---|
| 586 | if(aString==NULL) return false; // TO KEEP |
---|
| 587 | char* s; // TO KEEP |
---|
| 588 | long value = strtol(aString,&s,10); // TO KEEP |
---|
| 589 | if(s==aString) return false; // TO KEEP |
---|
| 590 | aInt = value; // TO KEEP |
---|
| 591 | return true; // TO KEEP |
---|
[481] | 592 | } |
---|
| 593 | #include <X11/IntrinsicP.h> |
---|
| 594 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 595 | // void ExecuteChangeSizeFunction ( |
---|
| 596 | // Widget aWidget |
---|
| 597 | // ) |
---|
| 598 | // ////////////////////////////////////////////////////////////////////////////// |
---|
| 599 | // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 600 | // { |
---|
| 601 | // if(aWidget==NULL) return; |
---|
| 602 | // if(aWidget->core.widget_class->core_class.resize==NULL) return; |
---|
| 603 | // (aWidget->core.widget_class->core_class.resize)(aWidget); |
---|
| 604 | // } |
---|
| 605 | |
---|
| 606 | |
---|
| 607 | #endif |
---|