[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 | */ |
---|
[497] | 114 | QSplitter *splitter = new QSplitter(Qt::Vertical,central); |
---|
[496] | 115 | QTextEdit *textedit = new QTextEdit; |
---|
| 116 | // textedit->setMaximumSize(800,800); |
---|
[490] | 117 | QPushButton *clearButton = new QPushButton("clear"); |
---|
[496] | 118 | |
---|
| 119 | QVBoxLayout *layout = new QVBoxLayout; |
---|
| 120 | layout->addWidget(textedit); |
---|
| 121 | layout->addWidget(clearButton); |
---|
[497] | 122 | |
---|
| 123 | splitter->addWidget(textedit); |
---|
| 124 | splitter->addWidget(clearButton); |
---|
| 125 | splitter->setLayout(layout); |
---|
| 126 | // central->setLayout(layout); |
---|
[496] | 127 | /* |
---|
| 128 | QSizePolicy *test = new QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); |
---|
| 129 | if (splitter->sizePolicy().horizontalPolicy () == test->horizontalPolicy () ) { |
---|
| 130 | printf ("splitter H is fixed\n"); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | printf("list SP H: %d\n",listview->sizePolicy().horizontalPolicy ()); |
---|
| 134 | printf("list SP V: %d\n",listview->sizePolicy().verticalPolicy ()); |
---|
| 135 | printf("tree SP H: %d\n",treeview->sizePolicy().horizontalPolicy ()); |
---|
| 136 | printf("tree SP V: %d\n",treeview->sizePolicy().verticalPolicy ()); |
---|
| 137 | printf("text SP H: %d\n",textedit->sizePolicy().horizontalPolicy ()); |
---|
| 138 | printf("text SP V: %d\n",textedit->sizePolicy().verticalPolicy ()); |
---|
| 139 | |
---|
| 140 | splitter->addWidget(listview); |
---|
| 141 | splitter->addWidget(treeview); |
---|
| 142 | splitter->addWidget(textedit); |
---|
| 143 | */ |
---|
[497] | 144 | fMainWindow->setCentralWidget(splitter); |
---|
| 145 | // fMainWindow->setCentralWidget(central); |
---|
[481] | 146 | |
---|
[496] | 147 | ////////////// |
---|
| 148 | // fMainWindow->resize(600,400); |
---|
| 149 | // QWidget* central = new QWidget(); |
---|
| 150 | // QWidget* topWidget = new QWidget(); |
---|
| 151 | // QWidget* bottomWidget = new QWidget(); |
---|
| 152 | // QVBoxLayout* vBox1 = new QVBoxLayout(topWidget); |
---|
| 153 | // QVBoxLayout* vBox2 = new QVBoxLayout(bottomWidget); |
---|
[494] | 154 | |
---|
[496] | 155 | // QSplitter *splitter = new QSplitter(Qt::Vertical); |
---|
| 156 | // fTextArea = new QTextEdit(); |
---|
| 157 | // fCommandHistoryArea = new QTextEdit(); |
---|
| 158 | // fCommandLabel = new QLabel(); |
---|
[490] | 159 | |
---|
[496] | 160 | // QPushButton *clearButton = new QPushButton("clear"); |
---|
| 161 | // connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback())); |
---|
[494] | 162 | |
---|
[496] | 163 | // fTextArea->setReadOnly(true); |
---|
| 164 | // fCommandHistoryArea->setReadOnly(true); |
---|
[490] | 165 | |
---|
[496] | 166 | // // QMenu *menuFile = new QMenu("File"); |
---|
| 167 | // // fMainWindow->menuBar()->addMenu(menuFile); |
---|
[495] | 168 | |
---|
[496] | 169 | // fCommandArea = new QLineEdit(); |
---|
| 170 | // connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback())); |
---|
[495] | 171 | |
---|
[496] | 172 | // vBox1->addWidget(fTextArea); |
---|
| 173 | // vBox1->addWidget(clearButton); |
---|
| 174 | // vBox1->setStretchFactor(fTextArea,1); |
---|
[495] | 175 | |
---|
[496] | 176 | // vBox2->addWidget(fCommandHistoryArea); |
---|
| 177 | // vBox2->addWidget(fCommandLabel); |
---|
| 178 | // vBox2->addWidget(fCommandArea); |
---|
| 179 | // vBox2->setStretchFactor(fCommandHistoryArea,1); |
---|
[495] | 180 | |
---|
[496] | 181 | // splitter->addWidget(topWidget); |
---|
| 182 | // splitter->addWidget(bottomWidget); |
---|
| 183 | |
---|
| 184 | // fMainWindow->setCentralWidget(central); |
---|
| 185 | //////////////// |
---|
| 186 | |
---|
[484] | 187 | // QMainWindow top = (QMainWindow)interactorManager->GetMainInteractor(); |
---|
[481] | 188 | |
---|
| 189 | // if(getenv("XENVIRONMENT")==NULL) { |
---|
| 190 | // XrmDatabase database = XrmGetDatabase(XtDisplay(top)); |
---|
| 191 | // if(database!=NULL) { |
---|
| 192 | // XrmPutLineResource(&database,"*topShadowColor:white"); |
---|
| 193 | // XrmPutLineResource(&database,"*bottomShadowColor:black"); |
---|
| 194 | // XrmPutLineResource(&database,"*foreground:black"); |
---|
| 195 | // XrmPutLineResource(&database,"*background:lightgrey"); |
---|
| 196 | // XrmPutLineResource(&database,"*borderColor:lightgrey"); |
---|
| 197 | // XrmPutLineResource(&database,"*fontList:-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"); |
---|
| 198 | // XrmPutLineResource(&database,"*text.background:white"); |
---|
| 199 | // XrmPutLineResource(&database,"*text.fontList:*courier*-r-*--14-*"); |
---|
| 200 | // XrmPutLineResource(&database,"*text.maxLength:8000"); |
---|
| 201 | // } |
---|
| 202 | // } |
---|
| 203 | |
---|
| 204 | // Arg args[9]; |
---|
| 205 | // XtSetArg(args[0],XmNkeyboardFocusPolicy,XmPOINTER); // For completion. |
---|
| 206 | // shell = XtAppCreateShell ("G4UIXm","G4UIXm", |
---|
| 207 | // topLevelShellWidgetClass,XtDisplay(top), |
---|
| 208 | // args,1); |
---|
| 209 | // form = XmCreateForm (shell,(char*)"form",NULL,0); |
---|
| 210 | // XtManageChild (form); |
---|
| 211 | |
---|
| 212 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM); |
---|
| 213 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 214 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 215 | // menuBar = XmCreateMenuBar (form,(char*)"menuBar",args,3); |
---|
| 216 | |
---|
| 217 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE); |
---|
| 218 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 219 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 220 | // XtSetArg(args[3],XmNbottomAttachment ,XmATTACH_FORM); |
---|
| 221 | // command = XmCreateCommand (form,(char*)"command",args,4); |
---|
| 222 | // XtManageChild (command); |
---|
| 223 | |
---|
| 224 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE); |
---|
| 225 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 226 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 227 | // XtSetArg(args[3],XmNbottomAttachment,XmATTACH_WIDGET); |
---|
| 228 | // XtSetArg(args[4],XmNbottomWidget ,command); |
---|
| 229 | // XmString cps = XmStringLtoRCreate((char*)"Clear",XmSTRING_DEFAULT_CHARSET); |
---|
| 230 | // XtSetArg (args[5],XmNlabelString,cps); |
---|
| 231 | // Widget clearButton = XmCreatePushButton(form,(char*)"clearButton",args,6); |
---|
| 232 | // XmStringFree (cps); |
---|
| 233 | // XtManageChild (clearButton); |
---|
| 234 | |
---|
| 235 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_WIDGET); |
---|
| 236 | // XtSetArg(args[1],XmNtopWidget ,menuBar); |
---|
| 237 | // XtSetArg(args[2],XmNleftAttachment ,XmATTACH_FORM); |
---|
| 238 | // XtSetArg(args[3],XmNrightAttachment ,XmATTACH_FORM); |
---|
| 239 | // XtSetArg(args[4],XmNbottomAttachment,XmATTACH_WIDGET); |
---|
| 240 | // XtSetArg(args[5],XmNbottomWidget ,clearButton); |
---|
| 241 | // XtSetArg(args[6],XmNeditMode ,XmMULTI_LINE_EDIT); |
---|
| 242 | // XtSetArg(args[7],XmNrows ,12); |
---|
| 243 | // XtSetArg(args[8],XmNcolumns ,80); |
---|
[484] | 244 | // text = XmCreateSGcrolledText (form,(char*)"text",args,9); |
---|
[481] | 245 | // XtManageChild (text); |
---|
| 246 | |
---|
| 247 | // XtAddCallback(clearButton,XmNactivateCallback, |
---|
| 248 | // clearButtonCallback,(XtPointer)text); |
---|
| 249 | // XtAddCallback(command,XmNcommandEnteredCallback, |
---|
| 250 | // commandEnteredCallback,(XtPointer)this); |
---|
| 251 | |
---|
| 252 | // Widget commandText = XmCommandGetChild(command,XmDIALOG_COMMAND_TEXT); |
---|
| 253 | // XtAddEventHandler(commandText,KeyPressMask,False,keyHandler,(XtPointer)this); |
---|
| 254 | |
---|
| 255 | // XtRealizeWidget(shell); |
---|
| 256 | // XtMapWidget(shell); |
---|
| 257 | |
---|
[484] | 258 | if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP |
---|
[481] | 259 | } |
---|
| 260 | /***************************************************************************/ |
---|
| 261 | G4UIQt::~G4UIQt( |
---|
| 262 | ) |
---|
| 263 | /***************************************************************************/ |
---|
| 264 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 265 | { |
---|
[484] | 266 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP |
---|
| 267 | if(UI!=NULL) { // TO KEEP |
---|
| 268 | UI->SetSession(NULL); // TO KEEP |
---|
| 269 | UI->SetCoutDestination(NULL); // TO KEEP |
---|
[481] | 270 | } |
---|
[484] | 271 | |
---|
| 272 | |
---|
[494] | 273 | if (fMainWindow!=NULL) |
---|
| 274 | delete fMainWindow; |
---|
[481] | 275 | } |
---|
| 276 | /***************************************************************************/ |
---|
| 277 | /* |
---|
| 278 | Start the Qt main loop |
---|
| 279 | */ |
---|
| 280 | G4UIsession* G4UIQt::SessionStart ( |
---|
| 281 | ) |
---|
| 282 | /***************************************************************************/ |
---|
| 283 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 284 | { |
---|
[484] | 285 | |
---|
[496] | 286 | G4Qt* interactorManager = G4Qt::getInstance (); |
---|
[494] | 287 | fMainWindow->show(); |
---|
| 288 | Prompt("session"); |
---|
| 289 | exitSession = false; |
---|
[481] | 290 | |
---|
[496] | 291 | |
---|
| 292 | printf("disable secondary loop\n"); |
---|
| 293 | interactorManager->DisableSecondaryLoop (); // TO KEEP |
---|
| 294 | ((QApplication*)interactorManager->GetMainInteractor())->exec(); |
---|
| 295 | // on ne passe pas le dessous ? FIXME ???? |
---|
| 296 | |
---|
| 297 | |
---|
| 298 | |
---|
| 299 | |
---|
| 300 | |
---|
| 301 | |
---|
[484] | 302 | // void* event; // TO KEEP |
---|
| 303 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
| 304 | // interactorManager->DispatchEvent(event); // TO KEEP |
---|
| 305 | // if(exitSession==true) break; // TO KEEP |
---|
| 306 | // } // TO KEEP |
---|
[496] | 307 | interactorManager->EnableSecondaryLoop (); // TO KEEP |
---|
| 308 | printf("enable secondary loop\n"); |
---|
[484] | 309 | return this; // TO KEEP |
---|
[481] | 310 | } |
---|
| 311 | /***************************************************************************/ |
---|
[494] | 312 | |
---|
[481] | 313 | /** |
---|
| 314 | Display the prompt in the prompt area |
---|
| 315 | */ |
---|
| 316 | void G4UIQt::Prompt ( |
---|
| 317 | G4String aPrompt |
---|
| 318 | ) |
---|
| 319 | /***************************************************************************/ |
---|
| 320 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 321 | { |
---|
[496] | 322 | // fCommandLabel->setText((char*)aPrompt.data()); |
---|
[481] | 323 | } |
---|
| 324 | /***************************************************************************/ |
---|
| 325 | void G4UIQt::SessionTerminate ( |
---|
| 326 | ) |
---|
| 327 | /***************************************************************************/ |
---|
| 328 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 329 | { |
---|
| 330 | } |
---|
| 331 | /***************************************************************************/ |
---|
| 332 | void G4UIQt::PauseSessionStart ( |
---|
| 333 | G4String a_state |
---|
| 334 | ) |
---|
| 335 | /***************************************************************************/ |
---|
| 336 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 337 | { |
---|
[484] | 338 | if(a_state=="G4_pause> ") { // TO KEEP |
---|
| 339 | SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP |
---|
| 340 | } // TO KEEP |
---|
[481] | 341 | |
---|
[484] | 342 | if(a_state=="EndOfEvent") { // TO KEEP |
---|
[481] | 343 | // Picking with feed back in event data Done here !!! |
---|
[484] | 344 | SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP |
---|
| 345 | } // TO KEEP |
---|
[481] | 346 | } |
---|
| 347 | /***************************************************************************/ |
---|
[484] | 348 | void G4UIQt::SecondaryLoop ( |
---|
[481] | 349 | G4String a_prompt |
---|
| 350 | ) |
---|
| 351 | /***************************************************************************/ |
---|
| 352 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 353 | { |
---|
[484] | 354 | G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? |
---|
| 355 | Prompt(a_prompt); // TO KEEP |
---|
| 356 | exitPause = false; // TO KEEP |
---|
| 357 | void* event; // TO KEEP |
---|
| 358 | while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
| 359 | interactorManager->DispatchEvent(event); // TO KEEP |
---|
| 360 | if(exitPause==true) break; // TO KEEP |
---|
| 361 | } // TO KEEP |
---|
| 362 | Prompt("session"); // TO KEEP |
---|
[481] | 363 | } |
---|
| 364 | /***************************************************************************/ |
---|
| 365 | /** |
---|
| 366 | Receive a cout from Geant4. We have to display it in the cout zone |
---|
| 367 | */ |
---|
[484] | 368 | G4int G4UIQt::ReceiveG4cout ( |
---|
[481] | 369 | G4String a_string |
---|
| 370 | ) |
---|
| 371 | /***************************************************************************/ |
---|
| 372 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 373 | { |
---|
[496] | 374 | // fTextArea->append((char*)a_string.data()); |
---|
[495] | 375 | return 0; |
---|
[481] | 376 | } |
---|
| 377 | /***************************************************************************/ |
---|
| 378 | /** |
---|
| 379 | Receive a cerr from Geant4. We have to display it in the cout zone |
---|
| 380 | */ |
---|
[484] | 381 | G4int G4UIQt::ReceiveG4cerr ( |
---|
[481] | 382 | G4String a_string |
---|
| 383 | ) |
---|
| 384 | /***************************************************************************/ |
---|
| 385 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 386 | { |
---|
[496] | 387 | // fTextArea->append((char*)a_string.data()); |
---|
[495] | 388 | return 0; |
---|
[481] | 389 | } |
---|
| 390 | /***************************************************************************/ |
---|
[484] | 391 | G4bool G4UIQt::GetHelpChoice( |
---|
[481] | 392 | G4int& aInt |
---|
| 393 | ) |
---|
| 394 | /***************************************************************************/ |
---|
| 395 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 396 | { |
---|
[484] | 397 | // fHelp = true; // TO KEEP |
---|
| 398 | // // SecondaryLoop : // TO KEEP |
---|
| 399 | // G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? |
---|
| 400 | // Prompt("Help"); // TO KEEP |
---|
| 401 | // exitHelp = false; // TO KEEP |
---|
| 402 | // void* event; // TO KEEP |
---|
| 403 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
| 404 | // interactorManager->DispatchEvent(event); // TO KEEP |
---|
| 405 | // if(exitHelp==true) break; // TO KEEP |
---|
| 406 | // } // TO KEEP |
---|
| 407 | // Prompt("session"); // TO KEEP |
---|
| 408 | // // // TO KEEP |
---|
| 409 | // if(fHelp==false) return false; // TO KEEP |
---|
| 410 | // aInt = fHelpChoice; // TO KEEP |
---|
| 411 | // fHelp = false; // TO KEEP |
---|
| 412 | // return true; // TO KEEP |
---|
[481] | 413 | } |
---|
| 414 | /***************************************************************************/ |
---|
[484] | 415 | void G4UIQt::ExitHelp( |
---|
[481] | 416 | ) |
---|
| 417 | /***************************************************************************/ |
---|
| 418 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 419 | { |
---|
| 420 | } |
---|
| 421 | /***************************************************************************/ |
---|
[484] | 422 | void G4UIQt::AddMenu ( |
---|
[481] | 423 | const char* a_name |
---|
| 424 | ,const char* a_label |
---|
| 425 | ) |
---|
| 426 | /***************************************************************************/ |
---|
| 427 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 428 | { |
---|
| 429 | // if(menuBar==NULL) return; |
---|
| 430 | // if(a_name==NULL) return; |
---|
| 431 | // if(a_label==NULL) return; |
---|
| 432 | // XtManageChild (menuBar); |
---|
| 433 | // // Pulldown menu : |
---|
| 434 | // Widget widget; |
---|
| 435 | // widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0); |
---|
| 436 | // AddInteractor (a_name,(G4Interactor)widget); |
---|
| 437 | // // Cascade button : |
---|
| 438 | // Arg args[2]; |
---|
| 439 | // XmString cps = XmStringLtoRCreate((char*)a_label,XmSTRING_DEFAULT_CHARSET); |
---|
| 440 | // XtSetArg (args[0],XmNlabelString,cps); |
---|
| 441 | // XtSetArg (args[1],XmNsubMenuId,widget); |
---|
| 442 | // widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2); |
---|
| 443 | // XmStringFree (cps); |
---|
| 444 | // XtManageChild (widget); |
---|
| 445 | // ExecuteChangeSizeFunction(form); |
---|
| 446 | } |
---|
| 447 | /***************************************************************************/ |
---|
[484] | 448 | void G4UIQt::AddButton ( |
---|
[481] | 449 | const char* a_menu |
---|
| 450 | ,const char* a_label |
---|
| 451 | ,const char* a_command |
---|
| 452 | ) |
---|
| 453 | /***************************************************************************/ |
---|
| 454 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 455 | { |
---|
[484] | 456 | // if(a_menu==NULL) return; // TO KEEP |
---|
| 457 | // if(a_label==NULL) return; // TO KEEP |
---|
| 458 | // if(a_command==NULL) return; // TO KEEP |
---|
[481] | 459 | // Widget parent = (Widget)GetInteractor(a_menu); |
---|
| 460 | // if(parent==NULL) return; |
---|
| 461 | // Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0); |
---|
| 462 | // XtManageChild (widget); |
---|
| 463 | // XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this); |
---|
| 464 | // commands[widget] = a_command; |
---|
[491] | 465 | } |
---|
[481] | 466 | // /***************************************************************************/ |
---|
| 467 | // G4String G4UIXm::GetCommand ( |
---|
| 468 | // Widget a_widget |
---|
| 469 | // ) |
---|
| 470 | // /***************************************************************************/ |
---|
| 471 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 472 | // { |
---|
| 473 | // return commands[a_widget]; |
---|
| 474 | // } |
---|
| 475 | /***************************************************************************/ |
---|
| 476 | /***************************************************************************/ |
---|
| 477 | /***************************************************************************/ |
---|
[494] | 478 | |
---|
[481] | 479 | /** |
---|
[494] | 480 | Callback call when "enter" clicked on the command zone. |
---|
[481] | 481 | Send the command to geant4 |
---|
| 482 | */ |
---|
[484] | 483 | // TODO ! |
---|
[494] | 484 | void G4UIQt::commandEnteredCallback ( |
---|
| 485 | ) |
---|
[481] | 486 | /***************************************************************************/ |
---|
| 487 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
[494] | 488 | { |
---|
[496] | 489 | /* fCommandHistoryArea->append(fCommandArea->text()); |
---|
[494] | 490 | G4String command (fCommandArea->text().toStdString().c_str()); |
---|
| 491 | if(fHelp==true) { |
---|
| 492 | exitHelp = true; |
---|
| 493 | fHelp = ConvertStringToInt(command.data(),fHelpChoice); |
---|
| 494 | } else { |
---|
| 495 | ApplyShellCommand (command,exitSession,exitPause); |
---|
| 496 | } |
---|
[495] | 497 | fCommandArea->setText(""); |
---|
[496] | 498 | */ |
---|
[494] | 499 | } |
---|
[481] | 500 | // /***************************************************************************/ |
---|
| 501 | // void G4UIXm::keyHandler ( |
---|
| 502 | // Widget a_widget |
---|
| 503 | // ,XtPointer a_tag |
---|
| 504 | // ,XEvent* a_event |
---|
| 505 | // ,Boolean* |
---|
| 506 | // ) |
---|
| 507 | // /***************************************************************************/ |
---|
| 508 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 509 | // { |
---|
| 510 | // KeySym keySym; |
---|
| 511 | // XLookupString(&(a_event->xkey),NULL,0,&keySym,NULL); |
---|
| 512 | // if(keySym!=XK_Tab) return; |
---|
| 513 | // G4UIXm* This = (G4UIXm*)a_tag; |
---|
| 514 | // char* s = XmTextGetString(a_widget); |
---|
| 515 | // G4String ss = This->Complete(s); |
---|
| 516 | // XmTextSetString(a_widget,(char*)ss.data()); |
---|
| 517 | // XtFree(s); |
---|
| 518 | // XmTextSetInsertionPosition(a_widget,XmTextGetLastPosition(a_widget)); |
---|
| 519 | //} |
---|
[488] | 520 | |
---|
| 521 | /***************************************************************************/ |
---|
[491] | 522 | void G4UIQt::clearButtonCallback ( |
---|
| 523 | ) |
---|
[481] | 524 | /***************************************************************************/ |
---|
| 525 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
[491] | 526 | { |
---|
[496] | 527 | // fTextArea->clear(); |
---|
[491] | 528 | } |
---|
| 529 | |
---|
[481] | 530 | /***************************************************************************/ |
---|
[484] | 531 | // TODO ! |
---|
| 532 | //void G4UIQt::ButtonCallback ( |
---|
| 533 | // Widget a_widget |
---|
| 534 | //,XtPointer a_tag |
---|
| 535 | //,XtPointer |
---|
| 536 | //) |
---|
[481] | 537 | /***************************************************************************/ |
---|
| 538 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
[484] | 539 | //{ |
---|
[481] | 540 | // G4UIXm* This = (G4UIXm*)a_tag; |
---|
| 541 | // if(This->fHelp==true) return; // Disabled when in help. |
---|
| 542 | // G4String ss = This->GetCommand (a_widget); |
---|
| 543 | // //printf ("debug : execute:\n%s\n",ss.data()); |
---|
| 544 | // This->ApplyShellCommand(ss,exitSession,exitPause); |
---|
[484] | 545 | //} |
---|
[481] | 546 | /***************************************************************************/ |
---|
| 547 | /***************************************************************************/ |
---|
| 548 | /***************************************************************************/ |
---|
| 549 | // char* XmConvertCompoundStringToString ( |
---|
| 550 | // XmString a_cps |
---|
| 551 | // ,int a_number |
---|
| 552 | // ) |
---|
| 553 | // /***************************************************************************/ |
---|
| 554 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 555 | // { |
---|
| 556 | // if(a_cps==NULL) return NULL; |
---|
| 557 | // char* ss = NULL; |
---|
| 558 | // XmStringContext context; |
---|
| 559 | // XmStringInitContext(&context,a_cps); |
---|
| 560 | // int icount = 0; |
---|
| 561 | // Boolean Done = False; |
---|
| 562 | // while(Done==False) { |
---|
| 563 | // char* text = NULL; |
---|
| 564 | // XmStringCharSet charset = NULL; |
---|
| 565 | // XmStringDirection direct; |
---|
| 566 | // Boolean sep; |
---|
| 567 | // if(XmStringGetNextSegment(context,&text,&charset,&direct,&sep)==True) { |
---|
| 568 | // XtFree(charset); |
---|
| 569 | // if(sep==True) Done = True; |
---|
| 570 | // if(icount==a_number) { |
---|
| 571 | // ss = text; |
---|
| 572 | // break; |
---|
| 573 | // } |
---|
| 574 | // icount++; |
---|
| 575 | // XtFree(text); |
---|
| 576 | // } |
---|
| 577 | // else |
---|
| 578 | // Done = True; |
---|
| 579 | // } |
---|
| 580 | // XmStringFreeContext(context); |
---|
| 581 | // return ss; |
---|
[491] | 582 | //} |
---|
[481] | 583 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 584 | G4bool ConvertStringToInt( |
---|
| 585 | const char* aString |
---|
| 586 | ,int& aInt |
---|
| 587 | ) |
---|
| 588 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 589 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 590 | { |
---|
[484] | 591 | aInt = 0; // TO KEEP |
---|
| 592 | if(aString==NULL) return false; // TO KEEP |
---|
| 593 | char* s; // TO KEEP |
---|
| 594 | long value = strtol(aString,&s,10); // TO KEEP |
---|
| 595 | if(s==aString) return false; // TO KEEP |
---|
| 596 | aInt = value; // TO KEEP |
---|
| 597 | return true; // TO KEEP |
---|
[481] | 598 | } |
---|
| 599 | #include <X11/IntrinsicP.h> |
---|
| 600 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 601 | // void ExecuteChangeSizeFunction ( |
---|
| 602 | // Widget aWidget |
---|
| 603 | // ) |
---|
| 604 | // ////////////////////////////////////////////////////////////////////////////// |
---|
| 605 | // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 606 | // { |
---|
| 607 | // if(aWidget==NULL) return; |
---|
| 608 | // if(aWidget->core.widget_class->core_class.resize==NULL) return; |
---|
| 609 | // (aWidget->core.widget_class->core_class.resize)(aWidget); |
---|
| 610 | // } |
---|
| 611 | |
---|
| 612 | |
---|
| 613 | #endif |
---|