| [607] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| [1293] | 27 | // $Id: G4UIQt.cc,v 1.40 2010/06/01 15:43:30 lgarnier Exp $
|
|---|
| [1248] | 28 | // GEANT4 tag $Name: $
|
|---|
| [607] | 29 | //
|
|---|
| 30 | // L. Garnier
|
|---|
| 31 |
|
|---|
| 32 | #ifdef G4UI_BUILD_QT_SESSION
|
|---|
| 33 |
|
|---|
| 34 | #include "G4Types.hh"
|
|---|
| 35 |
|
|---|
| 36 | #include <string.h>
|
|---|
| 37 |
|
|---|
| 38 | #include "G4UIQt.hh"
|
|---|
| 39 | #include "G4UImanager.hh"
|
|---|
| 40 | #include "G4StateManager.hh"
|
|---|
| 41 | #include "G4UIcommandTree.hh"
|
|---|
| 42 | #include "G4UIcommandStatus.hh"
|
|---|
| 43 |
|
|---|
| 44 | #include "G4Qt.hh"
|
|---|
| 45 |
|
|---|
| 46 | #include <qapplication.h>
|
|---|
| 47 | #include <qlineedit.h>
|
|---|
| 48 | #include <qwidget.h>
|
|---|
| 49 | #include <qmenubar.h>
|
|---|
| 50 | #include <qlayout.h>
|
|---|
| 51 | #include <qpushbutton.h>
|
|---|
| 52 | #include <qlabel.h>
|
|---|
| [1223] | 53 | #include <qtoolbox.h>
|
|---|
| [607] | 54 | #include <qsplitter.h>
|
|---|
| 55 | #include <qscrollbar.h>
|
|---|
| 56 | #include <qdialog.h>
|
|---|
| 57 | #include <qevent.h>
|
|---|
| 58 | #include <qtextedit.h>
|
|---|
| 59 | #include <qsignalmapper.h>
|
|---|
| [1158] | 60 | #include <qtabwidget.h>
|
|---|
| [1223] | 61 | #include <qtabbar.h>
|
|---|
| [1224] | 62 | #include <qstringlist.h>
|
|---|
| [607] | 63 |
|
|---|
| [608] | 64 | #include <qmainwindow.h>
|
|---|
| [607] | 65 | #if QT_VERSION >= 0x040000
|
|---|
| 66 | #include <qmenu.h>
|
|---|
| 67 | #include <qlistwidget.h>
|
|---|
| 68 | #include <qtreewidget.h>
|
|---|
| 69 | #else
|
|---|
| 70 | #include <qaction.h>
|
|---|
| 71 | #include <qheader.h>
|
|---|
| 72 | #include <qlistview.h>
|
|---|
| 73 | #include <qpopupmenu.h>
|
|---|
| [867] | 74 | #include <qwidgetlist.h>
|
|---|
| [607] | 75 | #endif
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | #include <stdlib.h>
|
|---|
| 80 |
|
|---|
| 81 | // Pourquoi Static et non variables de classe ?
|
|---|
| 82 | static G4bool exitSession = true;
|
|---|
| 83 | static G4bool exitPause = true;
|
|---|
| 84 |
|
|---|
| 85 | /** Build a Qt window with a menubar, output area and promt area<br>
|
|---|
| 86 | <pre>
|
|---|
| 87 | +-----------------------+
|
|---|
| 88 | |exit menu| |
|
|---|
| 89 | | |
|
|---|
| 90 | | +-------------------+ |
|
|---|
| 91 | | | | |
|
|---|
| 92 | | | Output area | |
|
|---|
| 93 | | | | |
|
|---|
| 94 | | +-------------------+ |
|
|---|
| 95 | | | clear | |
|
|---|
| 96 | | +-------------------+ |
|
|---|
| 97 | | | promt history | |
|
|---|
| 98 | | +-------------------+ |
|
|---|
| 99 | | +-------------------+ |
|
|---|
| 100 | | |> promt area | |
|
|---|
| 101 | | +-------------------+ |
|
|---|
| 102 | +-----------------------+
|
|---|
| 103 | </pre>
|
|---|
| 104 | */
|
|---|
| 105 | G4UIQt::G4UIQt (
|
|---|
| [874] | 106 | int argc
|
|---|
| [607] | 107 | ,char** argv
|
|---|
| 108 | )
|
|---|
| [1224] | 109 | :fG4cout("")
|
|---|
| [1248] | 110 | ,fHelpTreeWidget(NULL)
|
|---|
| [1224] | 111 | ,fHelpTBWidget(NULL)
|
|---|
| 112 | ,fHistoryTBWidget(NULL)
|
|---|
| 113 | ,fCoutTBWidget(NULL)
|
|---|
| 114 | ,fVisParametersTBWidget(NULL)
|
|---|
| 115 | ,fViewComponentsTBWidget(NULL)
|
|---|
| 116 | ,fTabWidget(NULL)
|
|---|
| [1163] | 117 | ,fCoutText("Output")
|
|---|
| [607] | 118 | {
|
|---|
| [1224] | 119 |
|
|---|
| [607] | 120 | G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
|
|---|
| [889] | 121 | if (!(QApplication*)interactorManager->GetMainInteractor()) {
|
|---|
| 122 | G4cout << "G4UIQt : Unable to init Qt. Aborted" << G4endl;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| [607] | 125 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 126 | if(UI!=NULL) UI->SetSession(this);
|
|---|
| [1252] | 127 | if(UI!=NULL) UI->SetG4UIWindow(this);
|
|---|
| [607] | 128 |
|
|---|
| [858] | 129 | // Check if already define in external app QMainWindow
|
|---|
| 130 | bool found = false;
|
|---|
| 131 | #if QT_VERSION < 0x040000
|
|---|
| 132 | // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
|
|---|
| 133 | // but if I comment them, it doesn't work...
|
|---|
| 134 | QWidgetList *list = QApplication::allWidgets();
|
|---|
| 135 | QWidgetListIt it( *list ); // iterate over the widgets
|
|---|
| 136 | QWidget * widget;
|
|---|
| 137 | while ( (widget=it.current()) != 0 ) { // for each widget...
|
|---|
| 138 | ++it;
|
|---|
| 139 | if ((found== false) && (widget->inherits("QMainWindow"))) {
|
|---|
| 140 | found = true;
|
|---|
| 141 | }
|
|---|
| 142 | }
|
|---|
| 143 | delete list; // delete the list, not the widgets
|
|---|
| 144 | #else
|
|---|
| 145 | foreach (QWidget *widget, QApplication::allWidgets()) {
|
|---|
| 146 | if ((found== false) && (widget->inherits("QMainWindow"))) {
|
|---|
| 147 | found = true;
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 | #endif
|
|---|
| 151 |
|
|---|
| 152 | if (found) {
|
|---|
| 153 | G4cout << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted" << G4endl;
|
|---|
| 154 | return ;
|
|---|
| 155 | }
|
|---|
| [607] | 156 | fMainWindow = new QMainWindow();
|
|---|
| 157 |
|
|---|
| [1118] | 158 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| [1255] | 159 | printf("G4UIQt::Initialise after main window creation +++++++++++\n");
|
|---|
| [608] | 160 | #endif
|
|---|
| [607] | 161 |
|
|---|
| [1118] | 162 | QWidget *mainWidget = new QWidget(fMainWindow);
|
|---|
| [1156] | 163 | #if QT_VERSION < 0x040000
|
|---|
| [1239] | 164 | fMyVSplitter = new QSplitter(Qt::Horizontal,fMainWindow);
|
|---|
| [1261] | 165 | fToolBox = new QToolBox(fMyVSplitter);
|
|---|
| [1156] | 166 | #else
|
|---|
| [1239] | 167 | fMyVSplitter = new QSplitter(Qt::Horizontal,fMainWindow);
|
|---|
| [1261] | 168 | fToolBox = new QToolBox();
|
|---|
| [1156] | 169 | #endif
|
|---|
| [611] | 170 |
|
|---|
| [610] | 171 | // Set layouts
|
|---|
| 172 |
|
|---|
| [1224] | 173 | // Add a empty tabwidget
|
|---|
| [1239] | 174 | fTabWidget = new G4QTabWidget(fMyVSplitter);
|
|---|
| [1236] | 175 | #if QT_VERSION >= 0x040500
|
|---|
| 176 | fTabWidget->setTabsClosable (true);
|
|---|
| 177 | #endif
|
|---|
| [1223] | 178 |
|
|---|
| [1236] | 179 | #if QT_VERSION >= 0x040200
|
|---|
| 180 | fTabWidget->setUsesScrollButtons (true);
|
|---|
| 181 | #endif
|
|---|
| 182 |
|
|---|
| [1223] | 183 | QWidget* commandLineWidget = new QWidget(mainWidget);
|
|---|
| [1224] | 184 | #if QT_VERSION < 0x040000
|
|---|
| [1158] | 185 | QVBoxLayout *layoutCommandLine = new QVBoxLayout(commandLineWidget);
|
|---|
| [1224] | 186 | #else
|
|---|
| 187 | QVBoxLayout *layoutCommandLine = new QVBoxLayout();
|
|---|
| 188 | #endif
|
|---|
| [610] | 189 |
|
|---|
| 190 | // fill them
|
|---|
| 191 |
|
|---|
| [1158] | 192 | fCommandLabel = new QLabel("",commandLineWidget);
|
|---|
| [607] | 193 |
|
|---|
| [1158] | 194 | fCommandArea = new QLineEdit(commandLineWidget);
|
|---|
| [607] | 195 | fCommandArea->installEventFilter(this);
|
|---|
| 196 | #if QT_VERSION < 0x040000
|
|---|
| 197 | fCommandArea->setActiveWindow();
|
|---|
| 198 | #else
|
|---|
| 199 | fCommandArea->activateWindow();
|
|---|
| 200 | #endif
|
|---|
| [1224] | 201 |
|
|---|
| [607] | 202 | #if QT_VERSION < 0x040000
|
|---|
| 203 | fCommandArea->setFocusPolicy ( QWidget::StrongFocus );
|
|---|
| 204 | fCommandArea->setFocus();
|
|---|
| 205 | #else
|
|---|
| 206 | fCommandArea->setFocusPolicy ( Qt::StrongFocus );
|
|---|
| 207 | fCommandArea->setFocus(Qt::TabFocusReason);
|
|---|
| 208 | #endif
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| [1223] | 211 |
|
|---|
| [1158] | 212 | layoutCommandLine->addWidget(fCommandLabel);
|
|---|
| 213 | layoutCommandLine->addWidget(fCommandArea);
|
|---|
| [607] | 214 | #if QT_VERSION >= 0x040000
|
|---|
| [1224] | 215 | QVBoxLayout *mainLayout = new QVBoxLayout();
|
|---|
| 216 | #else
|
|---|
| [1118] | 217 | QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
|
|---|
| [1224] | 218 | #endif
|
|---|
| [1118] | 219 |
|
|---|
| [1224] | 220 | fHelpTBWidget = new QWidget(fToolBox);
|
|---|
| 221 | fHistoryTBWidget = new QWidget(fToolBox);
|
|---|
| 222 | fCoutTBWidget = new QWidget(fToolBox);
|
|---|
| 223 | fVisParametersTBWidget = new QWidget(fToolBox);
|
|---|
| 224 | fViewComponentsTBWidget = new QWidget(fToolBox);
|
|---|
| [1226] | 225 |
|
|---|
| [1224] | 226 | CreateVisParametersTBWidget();
|
|---|
| [1226] | 227 | CreateViewComponentsTBWidget();
|
|---|
| 228 | CreateHelpTBWidget();
|
|---|
| [1224] | 229 | CreateCoutTBWidget();
|
|---|
| 230 | CreateHistoryTBWidget();
|
|---|
| 231 |
|
|---|
| [1223] | 232 | // the splitter
|
|---|
| [1248] | 233 | // fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
|
|---|
| 234 | // fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
|
|---|
| [1223] | 235 | fToolBox->addItem(fHelpTBWidget,"Help");
|
|---|
| [1224] | 236 | fToolBox->addItem(fCoutTBWidget,"Cout");
|
|---|
| 237 | fToolBox->addItem(fHistoryTBWidget,"History");
|
|---|
| [1118] | 238 |
|
|---|
| [1158] | 239 |
|
|---|
| [1224] | 240 |
|
|---|
| [1223] | 241 | fToolBox->setSizePolicy (QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
|
|---|
| [1224] | 242 | fTabWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
|
|---|
| [1158] | 243 |
|
|---|
| [1224] | 244 | QSizePolicy policy = fTabWidget->sizePolicy();
|
|---|
| [1261] | 245 | #if QT_VERSION < 0x040000
|
|---|
| 246 | policy.setHorStretch(1);
|
|---|
| 247 | policy.setVerStretch(1);
|
|---|
| 248 | #else
|
|---|
| [1223] | 249 | policy.setHorizontalStretch(1);
|
|---|
| 250 | policy.setVerticalStretch(1);
|
|---|
| [1261] | 251 | #endif
|
|---|
| [1224] | 252 | fTabWidget->setSizePolicy(policy);
|
|---|
| [1223] | 253 |
|
|---|
| [1262] | 254 | #if QT_VERSION < 0x040000
|
|---|
| 255 | fEmptyViewerTabLabel = new QLabel(fToolBox," If you want to have a Viewer, please use /vis/open commands. ");
|
|---|
| 256 | #else
|
|---|
| 257 | fEmptyViewerTabLabel = new QLabel(" If you want to have a Viewer, please use /vis/open commands. ");
|
|---|
| 258 | #endif
|
|---|
| [1223] | 259 |
|
|---|
| [1243] | 260 | // Only at creation. Will be set visible when sessionStart();
|
|---|
| [1261] | 261 | #if QT_VERSION >= 0x040000
|
|---|
| [1266] | 262 | #if QT_VERSION >= 0x040200
|
|---|
| [1243] | 263 | fTabWidget->setVisible(false);
|
|---|
| 264 | fEmptyViewerTabLabel->setVisible(false);
|
|---|
| [1266] | 265 | #else
|
|---|
| [1261] | 266 | fTabWidget->hide();
|
|---|
| 267 | fEmptyViewerTabLabel->hide();
|
|---|
| [1266] | 268 | #endif
|
|---|
| [1261] | 269 | #else
|
|---|
| 270 | fTabWidget->hide();
|
|---|
| 271 | fEmptyViewerTabLabel->hide();
|
|---|
| 272 | #endif
|
|---|
| [1243] | 273 |
|
|---|
| [1261] | 274 |
|
|---|
| [1239] | 275 | // fMyVSplitter->addWidget(fTabWidget);
|
|---|
| 276 |
|
|---|
| 277 | // unset parent fot TabWidget
|
|---|
| 278 | #if QT_VERSION < 0x040000
|
|---|
| 279 | fTabWidget->reparent(0,0,QPoint(0,0));
|
|---|
| 280 | #else
|
|---|
| [1261] | 281 | fMyVSplitter->addWidget(fToolBox);
|
|---|
| 282 | fMyVSplitter->addWidget(fEmptyViewerTabLabel);
|
|---|
| [1239] | 283 | fTabWidget->setParent(0);
|
|---|
| 284 | #endif
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| [1224] | 287 | #if QT_VERSION >= 0x040000
|
|---|
| 288 | commandLineWidget->setLayout(layoutCommandLine);
|
|---|
| 289 | #endif
|
|---|
| [1223] | 290 | commandLineWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
|
|---|
| [1239] | 291 | mainLayout->addWidget(fMyVSplitter,1);
|
|---|
| [1223] | 292 | mainLayout->addWidget(commandLineWidget);
|
|---|
| 293 |
|
|---|
| [1158] | 294 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 295 | printf("G4UIQt::G4UIQt :: 5\n");
|
|---|
| 296 | #endif
|
|---|
| [1118] | 297 |
|
|---|
| [1156] | 298 | #if QT_VERSION >= 0x040000
|
|---|
| [1224] | 299 | mainWidget->setLayout(mainLayout);
|
|---|
| [607] | 300 | #endif
|
|---|
| 301 |
|
|---|
| [1224] | 302 | fMainWindow->setCentralWidget(mainWidget);
|
|---|
| 303 |
|
|---|
| [607] | 304 | #if QT_VERSION < 0x040000
|
|---|
| 305 |
|
|---|
| 306 | // Add a quit subMenu
|
|---|
| 307 | QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
|
|---|
| [889] | 308 | fileMenu->insertItem( "&Quit", this, SLOT(ExitSession()), CTRL+Key_Q );
|
|---|
| [607] | 309 | fMainWindow->menuBar()->insertItem( QString("&File"), fileMenu );
|
|---|
| 310 |
|
|---|
| 311 | #else
|
|---|
| 312 |
|
|---|
| 313 | // Add a quit subMenu
|
|---|
| 314 | QMenu *fileMenu = fMainWindow->menuBar()->addMenu("File");
|
|---|
| [889] | 315 | fileMenu->addAction("Quit", this, SLOT(ExitSession()));
|
|---|
| [607] | 316 |
|
|---|
| 317 | #endif
|
|---|
| 318 |
|
|---|
| [922] | 319 | AddInteractor ("file",(G4Interactor)fileMenu);
|
|---|
| [1158] | 320 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 321 | printf("G4UIQt::G4UIQt :: 6\n");
|
|---|
| 322 | #endif
|
|---|
| [922] | 323 |
|
|---|
| [1248] | 324 | // Connect signal
|
|---|
| [1224] | 325 | connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
|
|---|
| [1283] | 326 | #if QT_VERSION >= 0x040500
|
|---|
| [1239] | 327 | connect(fTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));
|
|---|
| [1283] | 328 | #endif
|
|---|
| [1239] | 329 | connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
|
|---|
| [1248] | 330 | connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
|
|---|
| 331 |
|
|---|
| [607] | 332 | if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP
|
|---|
| [1158] | 333 |
|
|---|
| [1224] | 334 | #if QT_VERSION < 0x040000
|
|---|
| 335 | fMainWindow->setCaption( tr( "G4UI Session" ));
|
|---|
| 336 | fMainWindow->resize(900,600);
|
|---|
| 337 | fMainWindow->move(50,100);
|
|---|
| 338 | #else
|
|---|
| 339 | fMainWindow->setWindowTitle( tr("G4UI Session") );
|
|---|
| 340 | fMainWindow->resize(900,600);
|
|---|
| 341 | fMainWindow->move(QPoint(50,100));
|
|---|
| 342 | #endif
|
|---|
| 343 |
|
|---|
| [1232] | 344 | // Set visible
|
|---|
| 345 | #if QT_VERSION >= 0x040000
|
|---|
| [1266] | 346 | #if QT_VERSION >= 0x040200
|
|---|
| [1232] | 347 | fMainWindow->setVisible(true);
|
|---|
| [1266] | 348 | #else
|
|---|
| [1232] | 349 | fMainWindow->show();
|
|---|
| [1266] | 350 | #endif
|
|---|
| [1232] | 351 | #else
|
|---|
| 352 | fMainWindow->show();
|
|---|
| 353 | #endif
|
|---|
| 354 |
|
|---|
| [1158] | 355 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 356 | printf("G4UIQt::G4UIQt END\n");
|
|---|
| 357 | #endif
|
|---|
| [607] | 358 | }
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | G4UIQt::~G4UIQt(
|
|---|
| 363 | )
|
|---|
| 364 | {
|
|---|
| [1177] | 365 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 366 | printf("G4UIQt::~G4UIQt Delete\n");
|
|---|
| 367 | #endif
|
|---|
| [607] | 368 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
|
|---|
| 369 | if(UI!=NULL) { // TO KEEP
|
|---|
| 370 | UI->SetSession(NULL); // TO KEEP
|
|---|
| [1255] | 371 | UI->SetG4UIWindow(NULL);
|
|---|
| [607] | 372 | UI->SetCoutDestination(NULL); // TO KEEP
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| [1177] | 375 | if (fMainWindow!=NULL) {
|
|---|
| 376 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 377 | printf("G4UIQt::~G4UIQt DELETE fMainWindow\n");
|
|---|
| 378 | #endif
|
|---|
| [607] | 379 | delete fMainWindow;
|
|---|
| [1177] | 380 | }
|
|---|
| [607] | 381 | }
|
|---|
| 382 |
|
|---|
| [1224] | 383 | /** Create the History ToolBox Widget
|
|---|
| 384 | */
|
|---|
| 385 | void G4UIQt::CreateHistoryTBWidget(
|
|---|
| 386 | )
|
|---|
| 387 | {
|
|---|
| [607] | 388 |
|
|---|
| [1224] | 389 | #if QT_VERSION < 0x040000
|
|---|
| 390 | QVBoxLayout *layoutHistoryTB = new QVBoxLayout(fHistoryTBWidget);
|
|---|
| 391 |
|
|---|
| 392 | fHistoryTBTableList = new QListView(fHistoryTBWidget);
|
|---|
| 393 | fHistoryTBTableList->setSorting (-1, FALSE);
|
|---|
| 394 | fHistoryTBTableList->setSelectionMode(QListView::Single);
|
|---|
| 395 | fHistoryTBTableList->addColumn("");
|
|---|
| 396 | fHistoryTBTableList->header()->hide();
|
|---|
| 397 | connect(fHistoryTBTableList, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));
|
|---|
| 398 | #else
|
|---|
| 399 | QVBoxLayout *layoutHistoryTB = new QVBoxLayout();
|
|---|
| 400 | fHistoryTBTableList = new QListWidget();
|
|---|
| 401 | fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
|
|---|
| 402 | connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
|
|---|
| 403 | #endif
|
|---|
| 404 | fHistoryTBTableList->installEventFilter(this);
|
|---|
| 405 |
|
|---|
| 406 | layoutHistoryTB->addWidget(fHistoryTBTableList);
|
|---|
| 407 |
|
|---|
| 408 | #if QT_VERSION >= 0x040000
|
|---|
| 409 | fHistoryTBWidget->setLayout(layoutHistoryTB);
|
|---|
| 410 | #endif
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | /** Create the Help ToolBox Widget
|
|---|
| 414 | */
|
|---|
| 415 | void G4UIQt::CreateHelpTBWidget(
|
|---|
| 416 | )
|
|---|
| 417 | {
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 | #if QT_VERSION < 0x040000
|
|---|
| [1228] | 421 | QWidget *helpWidget = new QWidget(fHelpTBWidget);
|
|---|
| [1224] | 422 | QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);
|
|---|
| [1248] | 423 | fHelpVSplitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
|
|---|
| [1224] | 424 | #else
|
|---|
| [1228] | 425 | QWidget *helpWidget = new QWidget();
|
|---|
| [1224] | 426 | QHBoxLayout *helpLayout = new QHBoxLayout();
|
|---|
| 427 | QVBoxLayout *vLayout = new QVBoxLayout();
|
|---|
| [1248] | 428 | fHelpVSplitter = new QSplitter(Qt::Horizontal);
|
|---|
| [1224] | 429 | #endif
|
|---|
| [1239] | 430 | fHelpLine = new QLineEdit(fHelpTBWidget);
|
|---|
| [1228] | 431 | helpLayout->addWidget(new QLabel("Search :",helpWidget));
|
|---|
| [1239] | 432 | helpLayout->addWidget(fHelpLine);
|
|---|
| [1224] | 433 | #if QT_VERSION < 0x040000
|
|---|
| [1239] | 434 | connect( fHelpLine, SIGNAL( returnPressed () ), this, SLOT( LookForHelpStringCallback() ) );
|
|---|
| [1224] | 435 | #else
|
|---|
| [1239] | 436 | connect( fHelpLine, SIGNAL( editingFinished () ), this, SLOT( LookForHelpStringCallback() ) );
|
|---|
| [1224] | 437 | #endif
|
|---|
| 438 |
|
|---|
| [1248] | 439 | // Create Help tree
|
|---|
| 440 | FillHelpTree();
|
|---|
| [1224] | 441 |
|
|---|
| [1248] | 442 | fHelpArea = new QTextEdit(fHelpVSplitter);
|
|---|
| [1224] | 443 | fHelpArea->setReadOnly(true);
|
|---|
| 444 |
|
|---|
| 445 | // Set layouts
|
|---|
| 446 |
|
|---|
| 447 | #if QT_VERSION >= 0x040000
|
|---|
| [1248] | 448 | if (fHelpTreeWidget) {
|
|---|
| 449 | fHelpVSplitter->addWidget(fHelpTreeWidget);
|
|---|
| 450 | }
|
|---|
| 451 | fHelpVSplitter->addWidget(fHelpArea);
|
|---|
| [1224] | 452 | #endif
|
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 | #if QT_VERSION >= 0x040000
|
|---|
| 456 | vLayout->addWidget(helpWidget);
|
|---|
| [1248] | 457 | vLayout->addWidget(fHelpVSplitter,1);
|
|---|
| [1224] | 458 | #endif
|
|---|
| 459 |
|
|---|
| [1228] | 460 | fHelpTBWidget->setMinimumSize(50,50);
|
|---|
| 461 | fHelpTBWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
|
|---|
| [1224] | 462 | // set the splitter size
|
|---|
| 463 | #if QT_VERSION >= 0x040000
|
|---|
| 464 | QList<int> list;
|
|---|
| 465 | #else
|
|---|
| 466 | QValueList<int> list;
|
|---|
| 467 | #endif
|
|---|
| [1228] | 468 | list.append( 50 );
|
|---|
| 469 | list.append( 50 );
|
|---|
| [1248] | 470 | fHelpVSplitter->setSizes(list);
|
|---|
| [1228] | 471 |
|
|---|
| [1224] | 472 | #if QT_VERSION >= 0x040000
|
|---|
| 473 | helpWidget->setLayout(helpLayout);
|
|---|
| 474 | fHelpTBWidget->setLayout(vLayout);
|
|---|
| 475 | #endif
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 | /** Create the Cout ToolBox Widget
|
|---|
| 480 | */
|
|---|
| 481 | void G4UIQt::CreateCoutTBWidget(
|
|---|
| 482 | )
|
|---|
| 483 | {
|
|---|
| 484 | #if QT_VERSION >= 0x040000
|
|---|
| 485 | QVBoxLayout *layoutCoutTB = new QVBoxLayout();
|
|---|
| 486 | #else
|
|---|
| 487 | QVBoxLayout *layoutCoutTB = new QVBoxLayout(fCoutTBWidget);
|
|---|
| 488 | #endif
|
|---|
| 489 |
|
|---|
| 490 | fCoutTBTextArea = new QTextEdit(fCoutTBWidget);
|
|---|
| 491 | fCoutFilter = new QLineEdit(fCoutTBWidget);
|
|---|
| 492 | QLabel* coutFilterLabel = new QLabel("Filter : ",fCoutTBWidget);
|
|---|
| 493 |
|
|---|
| 494 | QPushButton *coutTBClearButton = new QPushButton("clear",fCoutTBWidget);
|
|---|
| 495 | connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
|
|---|
| 496 | connect(fCoutFilter, SIGNAL(textEdited ( const QString &)), SLOT(CoutFilterCallback( const QString &)));
|
|---|
| 497 |
|
|---|
| 498 | fCoutTBTextArea->setReadOnly(true);
|
|---|
| 499 |
|
|---|
| 500 | QWidget* coutButtonWidget = new QWidget(fCoutTBWidget);
|
|---|
| 501 | QHBoxLayout* layoutCoutTBButtons = new QHBoxLayout(coutButtonWidget);
|
|---|
| 502 | layoutCoutTBButtons->addWidget(coutTBClearButton);
|
|---|
| 503 | layoutCoutTBButtons->addWidget(coutFilterLabel);
|
|---|
| 504 | layoutCoutTBButtons->addWidget(fCoutFilter);
|
|---|
| 505 |
|
|---|
| 506 | layoutCoutTB->addWidget(fCoutTBTextArea);
|
|---|
| 507 | layoutCoutTB->addWidget(coutButtonWidget);
|
|---|
| 508 |
|
|---|
| 509 | #if QT_VERSION >= 0x040000
|
|---|
| 510 | fCoutTBWidget->setLayout(layoutCoutTB);
|
|---|
| 511 | #endif
|
|---|
| 512 | }
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 | /** Create the VisParameters ToolBox Widget
|
|---|
| 516 | */
|
|---|
| 517 | void G4UIQt::CreateVisParametersTBWidget(
|
|---|
| 518 | )
|
|---|
| 519 | {
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 523 | /** Create the ViewComponents ToolBox Widget
|
|---|
| 524 | */
|
|---|
| 525 | void G4UIQt::CreateViewComponentsTBWidget(
|
|---|
| 526 | )
|
|---|
| 527 | {
|
|---|
| 528 | }
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| [1158] | 531 | /** Add a new tab widget.
|
|---|
| 532 | Create the tab if it was not done
|
|---|
| 533 | */
|
|---|
| [1232] | 534 | bool G4UIQt::AddTabWidget(
|
|---|
| [1158] | 535 | QWidget* aWidget
|
|---|
| [1177] | 536 | ,QString name
|
|---|
| 537 | ,int sizeX
|
|---|
| 538 | ,int sizeY
|
|---|
| [1158] | 539 | )
|
|---|
| 540 | {
|
|---|
| [1223] | 541 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| [1255] | 542 | printf("G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY);
|
|---|
| [1223] | 543 | #endif
|
|---|
| [1243] | 544 | if (!aWidget) {
|
|---|
| 545 | return false;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| [1239] | 548 | // Remove QLabel
|
|---|
| [1264] | 549 |
|
|---|
| 550 | // L.Garnier 26/05/2010 : not exactly the same in qt3. Could cause some
|
|---|
| [1262] | 551 | // troubles
|
|---|
| [1264] | 552 | #if QT_VERSION >= 0x040000
|
|---|
| [1239] | 553 | if ( fMyVSplitter->indexOf(fEmptyViewerTabLabel) != -1) {
|
|---|
| [1262] | 554 | #endif
|
|---|
| [1264] | 555 |
|
|---|
| [1239] | 556 | #if QT_VERSION < 0x040000
|
|---|
| 557 | fEmptyViewerTabLabel->reparent(0,0,QPoint(0,0));
|
|---|
| 558 | #else
|
|---|
| 559 | fEmptyViewerTabLabel->setParent(0);
|
|---|
| [1262] | 560 | fMyVSplitter->addWidget(fTabWidget);
|
|---|
| [1223] | 561 | #endif
|
|---|
| [1264] | 562 |
|
|---|
| [1158] | 563 | #if QT_VERSION < 0x040000
|
|---|
| [1239] | 564 | aWidget->reparent(fTabWidget,0,QPoint(0,0));
|
|---|
| [1158] | 565 | #else
|
|---|
| [1239] | 566 | aWidget->setParent(fTabWidget);
|
|---|
| [1158] | 567 | #endif
|
|---|
| [1264] | 568 | #if QT_VERSION >= 0x040000
|
|---|
| [1239] | 569 | }
|
|---|
| [1264] | 570 | #endif
|
|---|
| [1239] | 571 |
|
|---|
| 572 |
|
|---|
| [1232] | 573 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| [1239] | 574 | printf("G4UIQt::AddTabWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-fTabWidget->width(),sizeY-fTabWidget->height());
|
|---|
| 575 | #endif
|
|---|
| 576 |
|
|---|
| [1232] | 577 | fMainWindow->resize(fMainWindow->width()+sizeX-fTabWidget->width(),fMainWindow->height()+sizeY-fTabWidget->height());
|
|---|
| 578 |
|
|---|
| 579 | // Problems with resize. The widgets are not realy drawn at this step,
|
|---|
| 580 | // then we have to force them on order to check the size
|
|---|
| 581 |
|
|---|
| [1262] | 582 | #if QT_VERSION < 0x040000
|
|---|
| 583 | fTabWidget->insertTab(aWidget,name,fTabWidget->count());
|
|---|
| 584 | #else
|
|---|
| [1236] | 585 | fTabWidget->insertTab(fTabWidget->count(),aWidget,name);
|
|---|
| [1262] | 586 | #endif
|
|---|
| [1239] | 587 |
|
|---|
| [1262] | 588 | #if QT_VERSION < 0x040000
|
|---|
| 589 | fTabWidget->setCurrentPage(fTabWidget->count()-1);
|
|---|
| 590 | #else
|
|---|
| 591 | fTabWidget->setCurrentIndex(fTabWidget->count()-1);
|
|---|
| 592 | #endif
|
|---|
| [1236] | 593 |
|
|---|
| [1232] | 594 | // Set visible
|
|---|
| 595 | #if QT_VERSION >= 0x040000
|
|---|
| [1252] | 596 | #if QT_VERSION >= 0x040200
|
|---|
| 597 | fTabWidget->setLastTabCreated(fTabWidget->currentIndex());
|
|---|
| 598 | fMainWindow->setVisible(true);
|
|---|
| 599 | #else
|
|---|
| 600 | fTabWidget->setLastTabCreated(fTabWidget->currentIndex());
|
|---|
| 601 | fMainWindow->show();
|
|---|
| 602 | #endif
|
|---|
| [1232] | 603 | #else
|
|---|
| [1252] | 604 | fTabWidget->setLastTabCreated(fTabWidget->currentPageIndex());
|
|---|
| [1232] | 605 | fMainWindow->show();
|
|---|
| [1262] | 606 | #endif
|
|---|
| 607 |
|
|---|
| 608 | #if QT_VERSION >= 0x040000
|
|---|
| 609 | #if QT_VERSION >= 0x040200
|
|---|
| 610 | fTabWidget->setVisible(true);
|
|---|
| 611 | #else
|
|---|
| [1265] | 612 | fTabWidget->show();
|
|---|
| [1232] | 613 | #endif
|
|---|
| [1262] | 614 | #else
|
|---|
| [1265] | 615 | fTabWidget->show();
|
|---|
| [1262] | 616 | #endif
|
|---|
| [1232] | 617 |
|
|---|
| 618 | return true;
|
|---|
| [1163] | 619 | }
|
|---|
| [1158] | 620 |
|
|---|
| [1163] | 621 |
|
|---|
| 622 | void G4UIQt::UpdateTabWidget(int tabNumber) {
|
|---|
| [1223] | 623 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| [1239] | 624 | printf("G4UIQt::UpdateTabWidget %d\n",tabNumber);
|
|---|
| [1223] | 625 | #endif
|
|---|
| [1224] | 626 | if ( fTabWidget == NULL) {
|
|---|
| [1236] | 627 | fTabWidget = new G4QTabWidget;
|
|---|
| [1224] | 628 | }
|
|---|
| 629 |
|
|---|
| [1239] | 630 |
|
|---|
| [1236] | 631 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 632 | printf("G4UIQt::UpdateTabWidget CALL REPAINT tabGL\n");
|
|---|
| 633 | #endif
|
|---|
| [1163] | 634 |
|
|---|
| [1262] | 635 | #if QT_VERSION < 0x040000
|
|---|
| 636 | fTabWidget->setCurrentPage(tabNumber);
|
|---|
| 637 | #else
|
|---|
| [1239] | 638 | fTabWidget->setCurrentIndex(tabNumber);
|
|---|
| [1262] | 639 | #endif
|
|---|
| [1243] | 640 |
|
|---|
| 641 | // Send this signal to unblock graphic updates !
|
|---|
| [1281] | 642 | fTabWidget->setTabSelected(false);
|
|---|
| [1280] | 643 |
|
|---|
| [1262] | 644 | #if QT_VERSION >= 0x040000
|
|---|
| 645 | #if QT_VERSION >= 0x040200
|
|---|
| 646 | fTabWidget->setVisible(true);
|
|---|
| 647 | #else
|
|---|
| [1265] | 648 | fTabWidget->show();
|
|---|
| [1262] | 649 | #endif
|
|---|
| 650 | #else
|
|---|
| [1265] | 651 | fTabWidget->show();
|
|---|
| [1262] | 652 | #endif
|
|---|
| [1243] | 653 |
|
|---|
| 654 | // This will send a paintEvent to OGL Viewers
|
|---|
| [1281] | 655 | fTabWidget->setTabSelected(true);
|
|---|
| [1236] | 656 |
|
|---|
| [1263] | 657 | #if QT_VERSION < 0x040000
|
|---|
| 658 | QApplication::sendPostedEvents () ;
|
|---|
| 659 | #else
|
|---|
| [1252] | 660 | QCoreApplication::sendPostedEvents () ;
|
|---|
| [1263] | 661 | #endif
|
|---|
| [1252] | 662 |
|
|---|
| [1236] | 663 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 664 | printf("G4UIQt::UpdateTabWidget END\n");
|
|---|
| 665 | #endif
|
|---|
| [1158] | 666 | }
|
|---|
| 667 |
|
|---|
| 668 |
|
|---|
| [1223] | 669 | /** Send resize event to all tabs
|
|---|
| 670 | */
|
|---|
| 671 | void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
|
|---|
| 672 | for (int a=0;a<fTabWidget->count() ;a++) {
|
|---|
| 673 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 674 | printf("G4UIQt::ResizeTabWidget +++++++++++++++++++++++++++++++++++++++\n");
|
|---|
| 675 | #endif
|
|---|
| [1265] | 676 | #if QT_VERSION < 0x040000
|
|---|
| 677 | fTabWidget->page(a)->resize(e->size());
|
|---|
| 678 | #else
|
|---|
| [1223] | 679 | fTabWidget->widget(a)->resize(e->size());
|
|---|
| [1265] | 680 | #endif
|
|---|
| [1223] | 681 | }
|
|---|
| 682 | }
|
|---|
| [1163] | 683 |
|
|---|
| [1223] | 684 |
|
|---|
| [607] | 685 | /** Start the Qt main loop
|
|---|
| 686 | */
|
|---|
| 687 | G4UIsession* G4UIQt::SessionStart (
|
|---|
| 688 | )
|
|---|
| 689 | {
|
|---|
| [1232] | 690 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 691 | printf("G4UIQt::G4UIQt SessionStart\n");
|
|---|
| 692 | #endif
|
|---|
| [607] | 693 |
|
|---|
| 694 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 695 |
|
|---|
| [1232] | 696 | Prompt("Session :");
|
|---|
| 697 | exitSession = false;
|
|---|
| 698 |
|
|---|
| [1265] | 699 | #if QT_VERSION >= 0x040000
|
|---|
| [1266] | 700 | #if QT_VERSION >= 0x040200
|
|---|
| [1243] | 701 | fTabWidget->setVisible(true);
|
|---|
| [1266] | 702 | fEmptyViewerTabLabel->setVisible(true);
|
|---|
| 703 | #else
|
|---|
| [1265] | 704 | fTabWidget->show();
|
|---|
| [1266] | 705 | fEmptyViewerTabLabel->show();
|
|---|
| 706 | #endif
|
|---|
| [1265] | 707 | #else
|
|---|
| 708 | fTabWidget->show();
|
|---|
| [1266] | 709 | fEmptyViewerTabLabel->show();
|
|---|
| [1265] | 710 | #endif
|
|---|
| 711 |
|
|---|
| [1243] | 712 |
|
|---|
| [1156] | 713 | #if QT_VERSION >= 0x040000
|
|---|
| [1266] | 714 | #if QT_VERSION >= 0x040200
|
|---|
| [1156] | 715 | fMainWindow->setVisible(true);
|
|---|
| [1266] | 716 | #else
|
|---|
| [607] | 717 | fMainWindow->show();
|
|---|
| [1266] | 718 | #endif
|
|---|
| [1156] | 719 | #else
|
|---|
| 720 | fMainWindow->show();
|
|---|
| 721 | #endif
|
|---|
| [607] | 722 |
|
|---|
| [1263] | 723 | #if QT_VERSION < 0x040000
|
|---|
| 724 | QApplication::sendPostedEvents () ;
|
|---|
| 725 | #else
|
|---|
| [1243] | 726 | QCoreApplication::sendPostedEvents () ;
|
|---|
| [1263] | 727 | #endif
|
|---|
| [1243] | 728 |
|
|---|
| [1232] | 729 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 730 | printf("G4UIQt::G4UIQt SessionStart2\n");
|
|---|
| 731 | #endif
|
|---|
| [607] | 732 | interactorManager->DisableSecondaryLoop (); // TO KEEP
|
|---|
| [610] | 733 | if ((QApplication*)interactorManager->GetMainInteractor())
|
|---|
| 734 | ((QApplication*)interactorManager->GetMainInteractor())->exec();
|
|---|
| [850] | 735 |
|
|---|
| 736 | // on ne passe pas le dessous ? FIXME ????
|
|---|
| 737 | // je ne pense pas 13/06
|
|---|
| 738 |
|
|---|
| 739 | // void* event; // TO KEEP
|
|---|
| 740 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP
|
|---|
| 741 | // interactorManager->DispatchEvent(event); // TO KEEP
|
|---|
| 742 | // if(exitSession==true) break; // TO KEEP
|
|---|
| 743 | // } // TO KEEP
|
|---|
| 744 |
|
|---|
| [607] | 745 | interactorManager->EnableSecondaryLoop ();
|
|---|
| 746 | return this;
|
|---|
| 747 | }
|
|---|
| 748 |
|
|---|
| 749 |
|
|---|
| 750 | /** Display the prompt in the prompt area
|
|---|
| 751 | @param aPrompt : string to display as the promt label
|
|---|
| [850] | 752 | //FIXME : probablement inutile puisque le seul a afficher qq chose d'autre
|
|---|
| 753 | que "session" est SecondaryLoop()
|
|---|
| [607] | 754 | */
|
|---|
| 755 | void G4UIQt::Prompt (
|
|---|
| 756 | G4String aPrompt
|
|---|
| 757 | )
|
|---|
| 758 | {
|
|---|
| 759 | if (!aPrompt) return;
|
|---|
| 760 |
|
|---|
| 761 | fCommandLabel->setText((char*)aPrompt.data());
|
|---|
| 762 | }
|
|---|
| 763 |
|
|---|
| 764 |
|
|---|
| [922] | 765 |
|
|---|
| [607] | 766 | void G4UIQt::SessionTerminate (
|
|---|
| 767 | )
|
|---|
| 768 | {
|
|---|
| 769 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 770 | fMainWindow->close();
|
|---|
| 771 | ((QApplication*)interactorManager->GetMainInteractor())->exit();
|
|---|
| 772 | }
|
|---|
| 773 |
|
|---|
| 774 |
|
|---|
| 775 |
|
|---|
| 776 | /**
|
|---|
| 777 | Called by intercoms/src/G4UImanager.cc<br>
|
|---|
| 778 | Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument<br>
|
|---|
| 779 | It have to pause the session command terminal.<br>
|
|---|
| 780 | Call SecondaryLoop to wait for exit event<br>
|
|---|
| 781 | @param aState
|
|---|
| 782 | @see : G4VisCommandReviewKeptEvents::SetNewValue
|
|---|
| 783 | */
|
|---|
| 784 | void G4UIQt::PauseSessionStart (
|
|---|
| 785 | G4String aState
|
|---|
| 786 | )
|
|---|
| 787 | {
|
|---|
| 788 | if (!aState) return;
|
|---|
| 789 |
|
|---|
| 790 | if(aState=="G4_pause> ") { // TO KEEP
|
|---|
| 791 | SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
|
|---|
| 792 | } // TO KEEP
|
|---|
| 793 |
|
|---|
| 794 | if(aState=="EndOfEvent") { // TO KEEP
|
|---|
| 795 | // Picking with feed back in event data Done here !!!
|
|---|
| 796 | SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
|
|---|
| 797 | } // TO KEEP
|
|---|
| 798 | }
|
|---|
| 799 |
|
|---|
| 800 |
|
|---|
| 801 |
|
|---|
| 802 | /**
|
|---|
| 803 | Begin the secondary loop
|
|---|
| 804 | @param a_prompt : label to display as the prompt label
|
|---|
| 805 | */
|
|---|
| 806 | void G4UIQt::SecondaryLoop (
|
|---|
| 807 | G4String aPrompt
|
|---|
| 808 | )
|
|---|
| 809 | {
|
|---|
| 810 | if (!aPrompt) return;
|
|---|
| 811 |
|
|---|
| 812 | G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
|
|---|
| 813 | Prompt(aPrompt); // TO KEEP
|
|---|
| 814 | exitPause = false; // TO KEEP
|
|---|
| 815 | void* event; // TO KEEP
|
|---|
| 816 | while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP
|
|---|
| 817 | interactorManager->DispatchEvent(event); // TO KEEP
|
|---|
| 818 | if(exitPause==true) break; // TO KEEP
|
|---|
| 819 | } // TO KEEP
|
|---|
| [1223] | 820 | Prompt("Session :"); // TO KEEP
|
|---|
| [607] | 821 | }
|
|---|
| 822 |
|
|---|
| 823 |
|
|---|
| 824 |
|
|---|
| 825 | /**
|
|---|
| 826 | Receive a cout from Geant4. We have to display it in the cout zone
|
|---|
| 827 | @param aString : label to add in the display area
|
|---|
| 828 | @return 0
|
|---|
| 829 | */
|
|---|
| 830 | G4int G4UIQt::ReceiveG4cout (
|
|---|
| 831 | G4String aString
|
|---|
| [1224] | 832 | )
|
|---|
| [607] | 833 | {
|
|---|
| 834 | if (!aString) return 0;
|
|---|
| 835 |
|
|---|
| [1224] | 836 | QStringList newStr;
|
|---|
| 837 |
|
|---|
| 838 | // Add to stringList
|
|---|
| [607] | 839 | #if QT_VERSION < 0x040000
|
|---|
| [1224] | 840 | newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace());
|
|---|
| [607] | 841 | #else
|
|---|
| [1224] | 842 | newStr = QStringList(QString((char*)aString.data()).trimmed());
|
|---|
| [607] | 843 | #endif
|
|---|
| [1224] | 844 | fG4cout += newStr;
|
|---|
| 845 |
|
|---|
| [1265] | 846 | #if QT_VERSION >= 0x040000
|
|---|
| [1224] | 847 | QStringList result = newStr.filter(fCoutFilter->text());
|
|---|
| [1265] | 848 | #else
|
|---|
| [1266] | 849 | //L. Garnier : in qt3 filter will does nothing
|
|---|
| 850 | QStringList result = "";
|
|---|
| [1265] | 851 | #endif
|
|---|
| [1224] | 852 |
|
|---|
| 853 | if (result.join("\n").isEmpty()) {
|
|---|
| 854 | return 0;
|
|---|
| 855 | }
|
|---|
| 856 | fCoutTBTextArea->append(result.join("\n"));
|
|---|
| 857 | fCoutTBTextArea->repaint();
|
|---|
| 858 |
|
|---|
| 859 | #if QT_VERSION < 0x040000
|
|---|
| 860 | fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
|
|---|
| 861 | #else
|
|---|
| 862 | fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
|
|---|
| 863 | #endif
|
|---|
| 864 |
|
|---|
| [607] | 865 | return 0;
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 |
|
|---|
| 869 | /**
|
|---|
| 870 | Receive a cerr from Geant4. We have to display it in the cout zone
|
|---|
| 871 | @param aString : label to add in the display area
|
|---|
| 872 | @return 0
|
|---|
| 873 | */
|
|---|
| 874 | G4int G4UIQt::ReceiveG4cerr (
|
|---|
| 875 | G4String aString
|
|---|
| 876 | )
|
|---|
| 877 | {
|
|---|
| 878 | if (!aString) return 0;
|
|---|
| 879 |
|
|---|
| [1224] | 880 | QStringList newStr;
|
|---|
| 881 |
|
|---|
| 882 | // Add to stringList
|
|---|
| [607] | 883 | #if QT_VERSION < 0x040000
|
|---|
| [1224] | 884 | newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace());
|
|---|
| [607] | 885 | #else
|
|---|
| [1224] | 886 | newStr = QStringList(QString((char*)aString.data()).trimmed());
|
|---|
| [607] | 887 | #endif
|
|---|
| [1224] | 888 | fG4cout += newStr;
|
|---|
| 889 |
|
|---|
| [1266] | 890 | #if QT_VERSION < 0x040000
|
|---|
| 891 | //L. Garnier : in qt3 filter will does nothing
|
|---|
| 892 | QStringList result = "";
|
|---|
| 893 | #else
|
|---|
| 894 | QStringList result = newStr.filter(fCoutFilter->text());
|
|---|
| 895 | #endif
|
|---|
| [1224] | 896 |
|
|---|
| 897 | #if QT_VERSION < 0x040000
|
|---|
| 898 | QColor previousColor = fCoutTBTextArea->color();
|
|---|
| 899 | fCoutTBTextArea->setColor(Qt::red);
|
|---|
| 900 | fCoutTBTextArea->append(result.join("\n"));
|
|---|
| 901 | fCoutTBTextArea->setColor(previousColor);
|
|---|
| 902 | fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
|
|---|
| 903 | #else
|
|---|
| 904 | QColor previousColor = fCoutTBTextArea->textColor();
|
|---|
| 905 | fCoutTBTextArea->setTextColor(Qt::red);
|
|---|
| 906 | fCoutTBTextArea->append(result.join("\n"));
|
|---|
| 907 | fCoutTBTextArea->setTextColor(previousColor);
|
|---|
| 908 | fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
|
|---|
| 909 | #endif
|
|---|
| 910 | fCoutTBTextArea->repaint();
|
|---|
| [607] | 911 | return 0;
|
|---|
| 912 | }
|
|---|
| 913 |
|
|---|
| 914 |
|
|---|
| 915 |
|
|---|
| 916 | /**
|
|---|
| 917 | Add a new menu to the menu bar
|
|---|
| 918 | @param aName name of menu
|
|---|
| 919 | @param aLabel label to display
|
|---|
| 920 | */
|
|---|
| 921 | void G4UIQt::AddMenu (
|
|---|
| 922 | const char* aName
|
|---|
| 923 | ,const char* aLabel
|
|---|
| 924 | )
|
|---|
| 925 | {
|
|---|
| 926 | if (aName == NULL) return;
|
|---|
| 927 | if (aLabel == NULL) return;
|
|---|
| 928 |
|
|---|
| 929 | #if QT_VERSION < 0x040000
|
|---|
| 930 | QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
|
|---|
| 931 | fMainWindow->menuBar()->insertItem( aLabel, fileMenu );
|
|---|
| 932 | #else
|
|---|
| 933 | QMenu *fileMenu = new QMenu(aLabel);
|
|---|
| 934 | fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu);
|
|---|
| 935 | #endif
|
|---|
| 936 |
|
|---|
| 937 | AddInteractor (aName,(G4Interactor)fileMenu);
|
|---|
| 938 | }
|
|---|
| 939 |
|
|---|
| 940 |
|
|---|
| 941 | /**
|
|---|
| 942 | Add a new button to a menu
|
|---|
| 943 | @param aMenu : parent menu
|
|---|
| 944 | @param aLabel : label to display
|
|---|
| 945 | @param aCommand : command to execute as a callback
|
|---|
| 946 | */
|
|---|
| 947 | void G4UIQt::AddButton (
|
|---|
| 948 | const char* aMenu
|
|---|
| 949 | ,const char* aLabel
|
|---|
| 950 | ,const char* aCommand
|
|---|
| 951 | )
|
|---|
| 952 | {
|
|---|
| 953 | if(aMenu==NULL) return; // TO KEEP
|
|---|
| 954 | if(aLabel==NULL) return; // TO KEEP
|
|---|
| 955 | if(aCommand==NULL) return; // TO KEEP
|
|---|
| 956 |
|
|---|
| 957 | #if QT_VERSION < 0x040000
|
|---|
| 958 | QPopupMenu *parent = (QPopupMenu*)GetInteractor(aMenu);
|
|---|
| 959 | #else
|
|---|
| 960 | QMenu *parent = (QMenu*)GetInteractor(aMenu);
|
|---|
| 961 | #endif
|
|---|
| 962 |
|
|---|
| 963 | if(parent==NULL) return;
|
|---|
| 964 |
|
|---|
| 965 | QSignalMapper *signalMapper = new QSignalMapper(this);
|
|---|
| [617] | 966 | #if QT_VERSION < 0x030200
|
|---|
| [1248] | 967 | QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
|
|---|
| [620] | 968 | action->addTo(parent);
|
|---|
| 969 | connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
|
|---|
| 970 |
|
|---|
| 971 | #elif QT_VERSION < 0x040000
|
|---|
| [1248] | 972 | QAction *action = new QAction(QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
|
|---|
| [607] | 973 | action->addTo(parent);
|
|---|
| [624] | 974 | connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
|
|---|
| [620] | 975 |
|
|---|
| [607] | 976 | #else
|
|---|
| 977 | QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map()));
|
|---|
| [620] | 978 |
|
|---|
| [607] | 979 | #endif
|
|---|
| [620] | 980 | connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
|
|---|
| [607] | 981 | signalMapper->setMapping(action, QString(aCommand));
|
|---|
| 982 | }
|
|---|
| 983 |
|
|---|
| 984 |
|
|---|
| 985 |
|
|---|
| 986 |
|
|---|
| [695] | 987 | void G4UIQt::ActivateCommand(
|
|---|
| 988 | G4String newCommand
|
|---|
| 989 | )
|
|---|
| 990 | {
|
|---|
| [697] | 991 | if (!fHelpTreeWidget) {
|
|---|
| 992 | return;
|
|---|
| 993 | }
|
|---|
| [607] | 994 | // Look for the choosen command "newCommand"
|
|---|
| 995 | size_t i = newCommand.index(" ");
|
|---|
| [1226] | 996 | G4String targetCom ="";
|
|---|
| [607] | 997 | if( i != std::string::npos )
|
|---|
| 998 | {
|
|---|
| 999 | G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
|
|---|
| 1000 | newValue.strip(G4String::both);
|
|---|
| 1001 | targetCom = ModifyToFullPathCommand( newValue );
|
|---|
| 1002 | }
|
|---|
| [1226] | 1003 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| [1248] | 1004 | printf("G4UIQt::ActivateCommand found : %s \n",targetCom.data());
|
|---|
| [1226] | 1005 | #endif
|
|---|
| [607] | 1006 | if (targetCom != "") {
|
|---|
| [1226] | 1007 | OpenHelpTreeOnCommand(targetCom.data());
|
|---|
| 1008 | }
|
|---|
| [607] | 1009 |
|
|---|
| [1266] | 1010 | #if QT_VERSION < 0x040000
|
|---|
| 1011 | fToolBox->setCurrentItem(fHelpTBWidget);
|
|---|
| 1012 | #else
|
|---|
| [1223] | 1013 | fToolBox->setCurrentWidget(fHelpTBWidget);
|
|---|
| [1266] | 1014 | #endif
|
|---|
| [607] | 1015 | }
|
|---|
| 1016 |
|
|---|
| [697] | 1017 |
|
|---|
| 1018 |
|
|---|
| 1019 | /**
|
|---|
| 1020 | Create the help tree widget
|
|---|
| 1021 | @param parent : parent of tree widget
|
|---|
| 1022 | @return the widget containing the tree or NULL if it could not have beeen created
|
|---|
| 1023 | */
|
|---|
| 1024 |
|
|---|
| [1248] | 1025 | void G4UIQt::InitHelpTree()
|
|---|
| 1026 | {
|
|---|
| 1027 |
|
|---|
| 1028 | if (! fHelpTreeWidget ) {
|
|---|
| [697] | 1029 | #if QT_VERSION < 0x040000
|
|---|
| [1266] | 1030 | fHelpTreeWidget = new QListView(fHelpVSplitter);
|
|---|
| [697] | 1031 | #else
|
|---|
| [1248] | 1032 | fHelpTreeWidget = new QTreeWidget();
|
|---|
| [697] | 1033 | #endif
|
|---|
| [1248] | 1034 | }
|
|---|
| [697] | 1035 |
|
|---|
| [1252] | 1036 |
|
|---|
| [697] | 1037 | // build widget
|
|---|
| 1038 | #if QT_VERSION < 0x040000
|
|---|
| 1039 | fHelpTreeWidget->setSelectionMode(QListView::Single);
|
|---|
| 1040 | fHelpTreeWidget->setRootIsDecorated(true);
|
|---|
| 1041 | fHelpTreeWidget->addColumn("Command");
|
|---|
| 1042 | fHelpTreeWidget->header()->setResizeEnabled(FALSE,1);
|
|---|
| 1043 | #else
|
|---|
| 1044 | fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|---|
| 1045 | QStringList labels;
|
|---|
| [700] | 1046 | labels << QString("Command");
|
|---|
| [697] | 1047 | fHelpTreeWidget->setHeaderLabels(labels);
|
|---|
| 1048 | #endif
|
|---|
| 1049 |
|
|---|
| [1248] | 1050 |
|
|---|
| 1051 | #if QT_VERSION < 0x040000
|
|---|
| 1052 | connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback()));
|
|---|
| 1053 | connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback()));
|
|---|
| 1054 | #else
|
|---|
| 1055 | connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback()));
|
|---|
| 1056 | connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback()));
|
|---|
| 1057 | #endif
|
|---|
| 1058 |
|
|---|
| 1059 | }
|
|---|
| 1060 | /**
|
|---|
| 1061 | Create the help tree widget
|
|---|
| 1062 | @param parent : parent of tree widget
|
|---|
| 1063 | @return the widget containing the tree or NULL if it could not have beeen created
|
|---|
| 1064 | */
|
|---|
| 1065 |
|
|---|
| 1066 | void G4UIQt::FillHelpTree()
|
|---|
| 1067 | {
|
|---|
| 1068 | if (! fHelpTreeWidget ) {
|
|---|
| 1069 | InitHelpTree();
|
|---|
| 1070 | }
|
|---|
| [1250] | 1071 |
|
|---|
| [1248] | 1072 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 1073 | if(UI==NULL) return;
|
|---|
| 1074 | G4UIcommandTree * treeTop = UI->GetTree();
|
|---|
| 1075 |
|
|---|
| [697] | 1076 | G4int treeSize = treeTop->GetTreeEntry();
|
|---|
| 1077 | #if QT_VERSION < 0x040000
|
|---|
| [1250] | 1078 | QListViewItem * newItem = NULL;
|
|---|
| [697] | 1079 | #else
|
|---|
| [1250] | 1080 | QTreeWidgetItem * newItem = NULL;
|
|---|
| [697] | 1081 | #endif
|
|---|
| [1250] | 1082 | QString commandText = "";
|
|---|
| [697] | 1083 | for (int a=0;a<treeSize;a++) {
|
|---|
| 1084 | // Creating new item
|
|---|
| [1251] | 1085 | newItem = NULL;
|
|---|
| [697] | 1086 |
|
|---|
| 1087 | #if QT_VERSION < 0x040000
|
|---|
| [1250] | 1088 | commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace();
|
|---|
| [697] | 1089 | #else
|
|---|
| [1250] | 1090 | commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed();
|
|---|
| [697] | 1091 | #endif
|
|---|
| 1092 |
|
|---|
| [1250] | 1093 | // if already exist, don't create it !
|
|---|
| 1094 | #if QT_VERSION < 0x040000
|
|---|
| [1252] | 1095 | QListViewItem* tmpAddItem = fHelpTreeWidget->firstChild();
|
|---|
| 1096 | while (tmpAddItem != 0) {
|
|---|
| [1250] | 1097 | if (!newItem) {
|
|---|
| [1252] | 1098 | newItem = FindTreeItem(tmpAddItem,commandText);
|
|---|
| [1250] | 1099 | }
|
|---|
| [1252] | 1100 | tmpAddItem = tmpAddItem->nextSibling();
|
|---|
| [1250] | 1101 | }
|
|---|
| 1102 | #else
|
|---|
| [1251] | 1103 | for (int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
|
|---|
| [1250] | 1104 | if (!newItem)
|
|---|
| 1105 | newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
|
|---|
| 1106 | }
|
|---|
| 1107 | #endif
|
|---|
| [697] | 1108 |
|
|---|
| [1250] | 1109 | if (newItem == NULL) {
|
|---|
| 1110 |
|
|---|
| 1111 | #if QT_VERSION < 0x040000
|
|---|
| 1112 | newItem = new QListViewItem(fHelpTreeWidget);
|
|---|
| 1113 | #else
|
|---|
| 1114 | newItem = new QTreeWidgetItem(fHelpTreeWidget);
|
|---|
| 1115 | #endif
|
|---|
| 1116 | newItem->setText(0,GetShortCommandPath(commandText));
|
|---|
| 1117 | }
|
|---|
| 1118 |
|
|---|
| [697] | 1119 | // look for childs
|
|---|
| 1120 | CreateChildTree(newItem,treeTop->GetTree(a+1));
|
|---|
| 1121 | }
|
|---|
| [1252] | 1122 |
|
|---|
| [697] | 1123 | }
|
|---|
| 1124 |
|
|---|
| 1125 |
|
|---|
| 1126 |
|
|---|
| [607] | 1127 | /** Fill the Help Tree Widget
|
|---|
| 1128 | @param aParent : parent item to fill
|
|---|
| 1129 | @param aCommandTree : commandTree node associate with this part of the Tree
|
|---|
| 1130 | */
|
|---|
| 1131 | #if QT_VERSION < 0x040000
|
|---|
| 1132 | void G4UIQt::CreateChildTree(
|
|---|
| 1133 | QListViewItem *aParent
|
|---|
| 1134 | ,G4UIcommandTree *aCommandTree
|
|---|
| 1135 | #else
|
|---|
| 1136 | void G4UIQt::CreateChildTree(
|
|---|
| 1137 | QTreeWidgetItem *aParent
|
|---|
| 1138 | ,G4UIcommandTree *aCommandTree
|
|---|
| 1139 | #endif
|
|---|
| 1140 | )
|
|---|
| 1141 | {
|
|---|
| 1142 | if (aParent == NULL) return;
|
|---|
| 1143 | if (aCommandTree == NULL) return;
|
|---|
| 1144 |
|
|---|
| 1145 |
|
|---|
| 1146 | // Creating new item
|
|---|
| 1147 | #if QT_VERSION < 0x040000
|
|---|
| 1148 | QListViewItem * newItem;
|
|---|
| 1149 | #else
|
|---|
| 1150 | QTreeWidgetItem * newItem;
|
|---|
| 1151 | #endif
|
|---|
| 1152 |
|
|---|
| [1250] | 1153 | QString commandText = "";
|
|---|
| [607] | 1154 | // Get the Sub directories
|
|---|
| 1155 | for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
|
|---|
| 1156 |
|
|---|
| 1157 | #if QT_VERSION < 0x040000
|
|---|
| [1250] | 1158 | commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace();
|
|---|
| 1159 | #else
|
|---|
| 1160 | commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed();
|
|---|
| 1161 | #endif
|
|---|
| 1162 |
|
|---|
| 1163 | // if already exist, don't create it !
|
|---|
| 1164 | newItem = FindTreeItem(aParent,commandText);
|
|---|
| 1165 | if (newItem == NULL) {
|
|---|
| 1166 | #if QT_VERSION < 0x040000
|
|---|
| [607] | 1167 | newItem = new QListViewItem(aParent);
|
|---|
| 1168 | #else
|
|---|
| [1250] | 1169 | newItem = new QTreeWidgetItem(aParent);
|
|---|
| [607] | 1170 | #endif
|
|---|
| [1250] | 1171 | newItem->setText(0,GetShortCommandPath(commandText));
|
|---|
| 1172 | }
|
|---|
| [607] | 1173 | CreateChildTree(newItem,aCommandTree->GetTree(a+1));
|
|---|
| 1174 | }
|
|---|
| 1175 |
|
|---|
| 1176 |
|
|---|
| 1177 |
|
|---|
| 1178 | // Get the Commands
|
|---|
| 1179 |
|
|---|
| 1180 | for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
|
|---|
| 1181 |
|
|---|
| 1182 | QStringList stringList;
|
|---|
| 1183 | #if QT_VERSION < 0x040000
|
|---|
| [1251] | 1184 | commandText = QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace();
|
|---|
| 1185 | #else
|
|---|
| 1186 | commandText = QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed();
|
|---|
| 1187 | #endif
|
|---|
| [607] | 1188 |
|
|---|
| [1251] | 1189 | // if already exist, don't create it !
|
|---|
| 1190 | newItem = FindTreeItem(aParent,commandText);
|
|---|
| 1191 | if (newItem == NULL) {
|
|---|
| 1192 | #if QT_VERSION < 0x040000
|
|---|
| 1193 | newItem = new QListViewItem(aParent);
|
|---|
| 1194 | newItem->setText(0,GetShortCommandPath(commandText));
|
|---|
| 1195 | newItem->setOpen(false);
|
|---|
| 1196 |
|
|---|
| [607] | 1197 | #else
|
|---|
| [1251] | 1198 | newItem = new QTreeWidgetItem(aParent);
|
|---|
| 1199 | newItem->setText(0,GetShortCommandPath(commandText));
|
|---|
| [607] | 1200 | #if QT_VERSION < 0x040202
|
|---|
| [1251] | 1201 | fHelpTreeWidget->setItemExpanded(newItem,false);
|
|---|
| [607] | 1202 | #else
|
|---|
| [1251] | 1203 | newItem->setExpanded(false);
|
|---|
| [607] | 1204 | #endif
|
|---|
| 1205 | #endif
|
|---|
| [1251] | 1206 | }
|
|---|
| [607] | 1207 | }
|
|---|
| 1208 | }
|
|---|
| 1209 |
|
|---|
| [1248] | 1210 |
|
|---|
| [607] | 1211 | /** Find a treeItemWidget in the help tree
|
|---|
| 1212 | @param aCommand item's String to look for
|
|---|
| 1213 | @return item if found, NULL if not
|
|---|
| 1214 | */
|
|---|
| 1215 | #if QT_VERSION < 0x040000
|
|---|
| 1216 | QListViewItem* G4UIQt::FindTreeItem(
|
|---|
| 1217 | QListViewItem *aParent
|
|---|
| 1218 | #else
|
|---|
| 1219 | QTreeWidgetItem* G4UIQt::FindTreeItem(
|
|---|
| 1220 | QTreeWidgetItem *aParent
|
|---|
| 1221 | #endif
|
|---|
| 1222 | ,const QString& aCommand
|
|---|
| 1223 | )
|
|---|
| 1224 | {
|
|---|
| 1225 | if (aParent == NULL) return NULL;
|
|---|
| 1226 |
|
|---|
| [1251] | 1227 | // Suppress last "/"
|
|---|
| 1228 | QString myCommand = aCommand;
|
|---|
| 1229 |
|
|---|
| [1266] | 1230 | #if QT_VERSION < 0x040000
|
|---|
| [1267] | 1231 | if (myCommand.findRev("/") == ((int)myCommand.length()-1)) {
|
|---|
| [1266] | 1232 | myCommand = myCommand.left(myCommand.length()-1);
|
|---|
| 1233 | #else
|
|---|
| [1251] | 1234 | if (myCommand.lastIndexOf("/") == (myCommand.size()-1)) {
|
|---|
| 1235 | myCommand = myCommand.left(myCommand.size()-1);
|
|---|
| [1266] | 1236 | #endif
|
|---|
| [1251] | 1237 | }
|
|---|
| 1238 |
|
|---|
| 1239 | if (GetLongCommandPath(aParent) == myCommand)
|
|---|
| [607] | 1240 | return aParent;
|
|---|
| 1241 |
|
|---|
| 1242 | #if QT_VERSION < 0x040000
|
|---|
| 1243 | QListViewItem * tmp = NULL;
|
|---|
| 1244 | QListViewItem* tmpItem = aParent->firstChild();
|
|---|
| 1245 | while (tmpItem != 0) {
|
|---|
| 1246 | if (!tmp)
|
|---|
| [1251] | 1247 | tmp = FindTreeItem(tmpItem,myCommand);
|
|---|
| [607] | 1248 | tmpItem = tmpItem->nextSibling();
|
|---|
| 1249 | }
|
|---|
| 1250 | #else
|
|---|
| 1251 | QTreeWidgetItem * tmp = NULL;
|
|---|
| 1252 | for (int a=0;a<aParent->childCount();a++) {
|
|---|
| 1253 | if (!tmp)
|
|---|
| [1251] | 1254 | tmp = FindTreeItem(aParent->child(a),myCommand);
|
|---|
| [607] | 1255 | }
|
|---|
| 1256 | #endif
|
|---|
| 1257 | return tmp;
|
|---|
| 1258 | }
|
|---|
| 1259 |
|
|---|
| 1260 |
|
|---|
| [1158] | 1261 |
|
|---|
| [607] | 1262 | /** Build the command list parameters in a QString<br>
|
|---|
| 1263 | Reimplement partialy the G4UIparameter.cc
|
|---|
| 1264 | @param aCommand : command to list parameters
|
|---|
| 1265 | @see G4UIparameter::List()
|
|---|
| 1266 | @see G4UIcommand::List()
|
|---|
| 1267 | @return the command list parameters, or "" if nothing
|
|---|
| 1268 | */
|
|---|
| 1269 | QString G4UIQt::GetCommandList (
|
|---|
| 1270 | const G4UIcommand *aCommand
|
|---|
| 1271 | )
|
|---|
| 1272 | {
|
|---|
| 1273 |
|
|---|
| 1274 | QString txt ="";
|
|---|
| 1275 | if (aCommand == NULL)
|
|---|
| 1276 | return txt;
|
|---|
| 1277 |
|
|---|
| 1278 | G4String commandPath = aCommand->GetCommandPath();
|
|---|
| 1279 | G4String rangeString = aCommand->GetRange();
|
|---|
| 1280 | G4int n_guidanceEntry = aCommand->GetGuidanceEntries();
|
|---|
| 1281 | G4int n_parameterEntry = aCommand->GetParameterEntries();
|
|---|
| 1282 |
|
|---|
| 1283 | if ((commandPath == "") &&
|
|---|
| 1284 | (rangeString == "") &&
|
|---|
| 1285 | (n_guidanceEntry == 0) &&
|
|---|
| 1286 | (n_parameterEntry == 0)) {
|
|---|
| 1287 | return txt;
|
|---|
| 1288 | }
|
|---|
| 1289 |
|
|---|
| 1290 | if((commandPath.length()-1)!='/') {
|
|---|
| 1291 | txt += "Command " + QString((char*)(commandPath).data()) + "\n";
|
|---|
| 1292 | }
|
|---|
| 1293 | txt += "Guidance :\n";
|
|---|
| 1294 |
|
|---|
| 1295 | for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
|
|---|
| 1296 | txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
|
|---|
| 1297 | }
|
|---|
| 1298 | if( ! rangeString.isNull() ) {
|
|---|
| 1299 | txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n";
|
|---|
| 1300 | }
|
|---|
| 1301 | if( n_parameterEntry > 0 ) {
|
|---|
| 1302 | G4UIparameter *param;
|
|---|
| 1303 |
|
|---|
| 1304 | // Re-implementation of G4UIparameter.cc
|
|---|
| 1305 |
|
|---|
| 1306 | for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
|
|---|
| 1307 | param = aCommand->GetParameter(i_thParameter);
|
|---|
| 1308 | txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
|
|---|
| 1309 | if( ! param->GetParameterGuidance().isNull() )
|
|---|
| 1310 | txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
|
|---|
| 1311 | txt += " Parameter type : " + QString(QChar(param->GetParameterType())) + "\n";
|
|---|
| 1312 | if(param->IsOmittable()){
|
|---|
| 1313 | txt += " Omittable : True\n";
|
|---|
| 1314 | } else {
|
|---|
| 1315 | txt += " Omittable : False\n";
|
|---|
| 1316 | }
|
|---|
| 1317 | if( param->GetCurrentAsDefault() ) {
|
|---|
| 1318 | txt += " Default value : taken from the current value\n";
|
|---|
| 1319 | } else if( ! param->GetDefaultValue().isNull() ) {
|
|---|
| 1320 | txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n";
|
|---|
| 1321 | }
|
|---|
| 1322 | if( ! param->GetParameterRange().isNull() ) {
|
|---|
| 1323 | txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
|
|---|
| 1324 | }
|
|---|
| 1325 | if( ! param->GetParameterCandidates().isNull() ) {
|
|---|
| 1326 | txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
|
|---|
| 1327 | }
|
|---|
| 1328 | }
|
|---|
| 1329 | }
|
|---|
| 1330 | return txt;
|
|---|
| 1331 | }
|
|---|
| 1332 |
|
|---|
| 1333 |
|
|---|
| 1334 |
|
|---|
| 1335 | /** Implement G4VBasicShell vurtual function
|
|---|
| 1336 | */
|
|---|
| 1337 | G4bool G4UIQt::GetHelpChoice(
|
|---|
| [1033] | 1338 | G4int&
|
|---|
| [607] | 1339 | )
|
|---|
| 1340 | {
|
|---|
| [1118] | 1341 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| [607] | 1342 | printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
|
|---|
| [608] | 1343 | #endif
|
|---|
| [607] | 1344 | return true;
|
|---|
| 1345 | }
|
|---|
| 1346 |
|
|---|
| 1347 |
|
|---|
| 1348 | /** Event filter method. Every event from QtApplication goes here.<br/>
|
|---|
| 1349 | We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/>
|
|---|
| 1350 | is active. If this filter match, Up arrow we give the previous command<br/>
|
|---|
| 1351 | and Down arrow will give the next if exist.<br/>
|
|---|
| 1352 | @param obj Emitter of the event
|
|---|
| 1353 | @param event Kind of event
|
|---|
| 1354 | */
|
|---|
| 1355 | bool G4UIQt::eventFilter( // Should stay with a minuscule eventFilter because of Qt
|
|---|
| 1356 | QObject *aObj
|
|---|
| 1357 | ,QEvent *aEvent
|
|---|
| 1358 | )
|
|---|
| 1359 | {
|
|---|
| [1223] | 1360 | bool moveCommandCursor = false;
|
|---|
| [607] | 1361 | if (aObj == NULL) return false;
|
|---|
| 1362 | if (aEvent == NULL) return false;
|
|---|
| 1363 |
|
|---|
| [1224] | 1364 | if (aObj == fHistoryTBTableList) {
|
|---|
| [607] | 1365 | if (aEvent->type() == QEvent::KeyPress) {
|
|---|
| 1366 | fCommandArea->setFocus();
|
|---|
| 1367 | }
|
|---|
| 1368 | }
|
|---|
| 1369 | if (aObj == fCommandArea) {
|
|---|
| 1370 | if (aEvent->type() == QEvent::KeyPress) {
|
|---|
| 1371 | QKeyEvent *e = static_cast<QKeyEvent*>(aEvent);
|
|---|
| 1372 | if ((e->key() == (Qt::Key_Down)) ||
|
|---|
| 1373 | (e->key() == (Qt::Key_PageDown)) ||
|
|---|
| 1374 | (e->key() == (Qt::Key_Up)) ||
|
|---|
| 1375 | (e->key() == (Qt::Key_PageUp))) {
|
|---|
| 1376 | #if QT_VERSION < 0x040000
|
|---|
| 1377 | // count rows...
|
|---|
| [1224] | 1378 | QListViewItem* tmpItem = fHistoryTBTableList->firstChild();
|
|---|
| [607] | 1379 | int selection = -1;
|
|---|
| 1380 | int index = 0;
|
|---|
| 1381 | while (tmpItem != 0) {
|
|---|
| [1224] | 1382 | if (tmpItem == fHistoryTBTableList->selectedItem()) {
|
|---|
| [607] | 1383 | selection = index;
|
|---|
| 1384 | }
|
|---|
| 1385 | index ++;
|
|---|
| 1386 | tmpItem = tmpItem->nextSibling();
|
|---|
| 1387 | }
|
|---|
| [1224] | 1388 | if (fHistoryTBTableList->childCount()) {
|
|---|
| [607] | 1389 | if (selection == -1) {
|
|---|
| [1224] | 1390 | selection = fHistoryTBTableList->childCount()-1;
|
|---|
| [607] | 1391 | } else {
|
|---|
| 1392 | if (e->key() == (Qt::Key_Down)) {
|
|---|
| [1224] | 1393 | if (selection <(fHistoryTBTableList->childCount()-1))
|
|---|
| [607] | 1394 | selection++;
|
|---|
| 1395 | } else if (e->key() == (Qt::Key_PageDown)) {
|
|---|
| [1224] | 1396 | selection = fHistoryTBTableList->childCount()-1;
|
|---|
| [607] | 1397 | #else
|
|---|
| [1224] | 1398 | int selection = fHistoryTBTableList->currentRow();
|
|---|
| 1399 | if (fHistoryTBTableList->count()) {
|
|---|
| [607] | 1400 | if (selection == -1) {
|
|---|
| [1224] | 1401 | selection = fHistoryTBTableList->count()-1;
|
|---|
| [607] | 1402 | } else {
|
|---|
| 1403 | if (e->key() == (Qt::Key_Down)) {
|
|---|
| [1224] | 1404 | if (selection <(fHistoryTBTableList->count()-1))
|
|---|
| [607] | 1405 | selection++;
|
|---|
| 1406 | } else if (e->key() == (Qt::Key_PageDown)) {
|
|---|
| [1224] | 1407 | selection = fHistoryTBTableList->count()-1;
|
|---|
| [607] | 1408 | #endif
|
|---|
| 1409 | } else if (e->key() == (Qt::Key_Up)) {
|
|---|
| 1410 | if (selection >0)
|
|---|
| 1411 | selection --;
|
|---|
| 1412 | } else if (e->key() == (Qt::Key_PageUp)) {
|
|---|
| 1413 | selection = 0;
|
|---|
| 1414 | }
|
|---|
| 1415 | }
|
|---|
| [1224] | 1416 | fHistoryTBTableList->clearSelection();
|
|---|
| [607] | 1417 | #if QT_VERSION < 0x040000
|
|---|
| [1224] | 1418 | QListViewItem* tmpItem = fHistoryTBTableList->firstChild();
|
|---|
| [607] | 1419 | int index = 0;
|
|---|
| 1420 | while (tmpItem != 0) {
|
|---|
| 1421 | if (index == selection) {
|
|---|
| 1422 | tmpItem->setSelected(true);
|
|---|
| [1224] | 1423 | fHistoryTBTableList->setCurrentItem(tmpItem);
|
|---|
| [607] | 1424 | }
|
|---|
| 1425 | index ++;
|
|---|
| 1426 | tmpItem = tmpItem->nextSibling();
|
|---|
| 1427 | }
|
|---|
| 1428 | #else
|
|---|
| 1429 | #if QT_VERSION < 0x040202
|
|---|
| [1224] | 1430 | fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),true);
|
|---|
| [607] | 1431 | #else
|
|---|
| [1224] | 1432 | fHistoryTBTableList->item(selection)->setSelected(true);
|
|---|
| [607] | 1433 | #endif
|
|---|
| [1224] | 1434 | fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
|
|---|
| [607] | 1435 | #endif
|
|---|
| 1436 | }
|
|---|
| [1223] | 1437 | moveCommandCursor = true;
|
|---|
| [607] | 1438 | } else if (e->key() == (Qt::Key_Tab)) {
|
|---|
| 1439 | #if QT_VERSION < 0x040000
|
|---|
| 1440 | G4String ss = Complete(fCommandArea->text().ascii());
|
|---|
| 1441 | #else
|
|---|
| 1442 | G4String ss = Complete(fCommandArea->text().toStdString().c_str());
|
|---|
| 1443 | #endif
|
|---|
| 1444 | fCommandArea->setText((char*)(ss.data()));
|
|---|
| 1445 |
|
|---|
| 1446 | // do not pass by parent, it will disable widget tab focus !
|
|---|
| 1447 | return true;
|
|---|
| [1183] | 1448 | #if QT_VERSION >= 0x040000
|
|---|
| [1184] | 1449 | // L.Garnier : MetaModifier is CTRL for MAC, but I don't want to put a MAC
|
|---|
| 1450 | // specific #ifdef
|
|---|
| 1451 | } else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
|
|---|
| 1452 | fCommandArea->home(false);
|
|---|
| 1453 | return true;
|
|---|
| 1454 | } else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
|
|---|
| 1455 | fCommandArea->end(false);
|
|---|
| 1456 | return true;
|
|---|
| [1177] | 1457 | #endif
|
|---|
| [607] | 1458 | }
|
|---|
| 1459 | }
|
|---|
| 1460 | }
|
|---|
| [1223] | 1461 | bool res= false;
|
|---|
| 1462 | // change cursor position if needed
|
|---|
| 1463 | if (moveCommandCursor == true) {
|
|---|
| 1464 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 1465 | printf("G4UIQt::eventFilter setCursor Position\n");
|
|---|
| 1466 | #endif
|
|---|
| 1467 | fCommandArea->setCursorPosition ( fCommandArea->text().length() );
|
|---|
| 1468 | fCommandArea->setCursorPosition (4);
|
|---|
| 1469 | } else {
|
|---|
| 1470 | // pass the event on to the parent class
|
|---|
| 1471 | res = QObject::eventFilter(aObj, aEvent);
|
|---|
| 1472 | }
|
|---|
| 1473 | return res;
|
|---|
| [607] | 1474 | }
|
|---|
| 1475 |
|
|---|
| 1476 |
|
|---|
| 1477 |
|
|---|
| 1478 |
|
|---|
| 1479 | /***************************************************************************/
|
|---|
| 1480 | //
|
|---|
| 1481 | // SLOTS DEFINITIONS
|
|---|
| 1482 | //
|
|---|
| 1483 | /***************************************************************************/
|
|---|
| 1484 |
|
|---|
| 1485 | /** Called when user give "help" command.
|
|---|
| 1486 | */
|
|---|
| 1487 | void G4UIQt::ShowHelpCallback (
|
|---|
| 1488 | )
|
|---|
| 1489 | {
|
|---|
| 1490 | TerminalHelp("");
|
|---|
| 1491 | }
|
|---|
| 1492 |
|
|---|
| 1493 |
|
|---|
| 1494 | /** Called when user click on clear button. Clear the text Output area
|
|---|
| 1495 | */
|
|---|
| 1496 | void G4UIQt::ClearButtonCallback (
|
|---|
| 1497 | )
|
|---|
| 1498 | {
|
|---|
| [1224] | 1499 | fCoutTBTextArea->clear();
|
|---|
| 1500 | fG4cout.clear();
|
|---|
| [607] | 1501 | }
|
|---|
| 1502 |
|
|---|
| [608] | 1503 | /** Called when user exit session
|
|---|
| 1504 | */
|
|---|
| 1505 | void G4UIQt::ExitSession (
|
|---|
| 1506 | )
|
|---|
| 1507 | {
|
|---|
| 1508 | SessionTerminate();
|
|---|
| 1509 | }
|
|---|
| [607] | 1510 |
|
|---|
| [1224] | 1511 | void G4UIQt::ExitHelp(
|
|---|
| 1512 | )
|
|---|
| 1513 | {
|
|---|
| 1514 | }
|
|---|
| [608] | 1515 |
|
|---|
| [607] | 1516 | /** Callback call when "click on a menu entry.<br>
|
|---|
| 1517 | Send the associated command to geant4
|
|---|
| 1518 | */
|
|---|
| 1519 | void G4UIQt::CommandEnteredCallback (
|
|---|
| 1520 | )
|
|---|
| 1521 | {
|
|---|
| 1522 | #if QT_VERSION < 0x040000
|
|---|
| 1523 | G4String command (fCommandArea->text().ascii());
|
|---|
| 1524 | if (fCommandArea->text().simplifyWhiteSpace() != "") {
|
|---|
| 1525 |
|
|---|
| [1224] | 1526 | QListViewItem *newItem = new QListViewItem(fHistoryTBTableList);
|
|---|
| [607] | 1527 | newItem->setText(0,fCommandArea->text());
|
|---|
| [1224] | 1528 | fHistoryTBTableList->insertItem(newItem);
|
|---|
| [620] | 1529 | // now we have to arrange
|
|---|
| [1224] | 1530 | QListViewItem *temp= fHistoryTBTableList->lastItem();
|
|---|
| 1531 | for (int i=0; i<fHistoryTBTableList->childCount()-1;i++) {
|
|---|
| 1532 | fHistoryTBTableList->takeItem(temp);
|
|---|
| 1533 | fHistoryTBTableList->insertItem(temp);
|
|---|
| 1534 | temp= fHistoryTBTableList->lastItem();
|
|---|
| [620] | 1535 | }
|
|---|
| [607] | 1536 | #else
|
|---|
| 1537 | G4String command (fCommandArea->text().toStdString().c_str());
|
|---|
| 1538 | if (fCommandArea->text().trimmed() != "") {
|
|---|
| [1224] | 1539 | fHistoryTBTableList->addItem(fCommandArea->text());
|
|---|
| [607] | 1540 | #endif
|
|---|
| [1224] | 1541 | fHistoryTBTableList->clearSelection();
|
|---|
| 1542 | fHistoryTBTableList->setCurrentItem(NULL);
|
|---|
| [607] | 1543 | fCommandArea->setText("");
|
|---|
| 1544 |
|
|---|
| 1545 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 1546 | if (interactorManager) {
|
|---|
| 1547 | interactorManager->FlushAndWaitExecution();
|
|---|
| 1548 | }
|
|---|
| 1549 | if (command(0,4) != "help") {
|
|---|
| 1550 | ApplyShellCommand (command,exitSession,exitPause);
|
|---|
| 1551 | } else {
|
|---|
| [1223] | 1552 | ActivateCommand(command);
|
|---|
| [607] | 1553 | }
|
|---|
| [1248] | 1554 | // Rebuild help tree
|
|---|
| 1555 | FillHelpTree();
|
|---|
| 1556 |
|
|---|
| [607] | 1557 | if(exitSession==true)
|
|---|
| 1558 | SessionTerminate();
|
|---|
| 1559 | }
|
|---|
| 1560 | }
|
|---|
| 1561 |
|
|---|
| 1562 |
|
|---|
| 1563 | /** Callback call when "enter" clicked on the command zone.<br>
|
|---|
| 1564 | Send the command to geant4
|
|---|
| 1565 | @param aCommand
|
|---|
| 1566 | */
|
|---|
| 1567 | void G4UIQt::ButtonCallback (
|
|---|
| 1568 | const QString& aCommand
|
|---|
| 1569 | )
|
|---|
| 1570 | {
|
|---|
| 1571 | #if QT_VERSION < 0x040000
|
|---|
| 1572 | G4String ss = G4String(aCommand.ascii());
|
|---|
| 1573 | #else
|
|---|
| 1574 | G4String ss = G4String(aCommand.toStdString().c_str());
|
|---|
| 1575 | #endif
|
|---|
| 1576 | ApplyShellCommand(ss,exitSession,exitPause);
|
|---|
| [1248] | 1577 |
|
|---|
| 1578 | // Rebuild help tree
|
|---|
| 1579 | FillHelpTree();
|
|---|
| 1580 |
|
|---|
| [607] | 1581 | if(exitSession==true)
|
|---|
| 1582 | SessionTerminate();
|
|---|
| 1583 | }
|
|---|
| 1584 |
|
|---|
| 1585 |
|
|---|
| 1586 |
|
|---|
| 1587 | /** This callback is activated when user selected a item in the help tree
|
|---|
| 1588 | */
|
|---|
| 1589 | void G4UIQt::HelpTreeClicCallback (
|
|---|
| 1590 | )
|
|---|
| 1591 | {
|
|---|
| 1592 | #if QT_VERSION < 0x040000
|
|---|
| 1593 | QListViewItem* item = NULL;
|
|---|
| 1594 | #else
|
|---|
| 1595 | QTreeWidgetItem* item = NULL;
|
|---|
| 1596 | #endif
|
|---|
| 1597 | if (!fHelpTreeWidget)
|
|---|
| 1598 | return ;
|
|---|
| 1599 |
|
|---|
| 1600 | if (!fHelpArea)
|
|---|
| 1601 | return;
|
|---|
| 1602 |
|
|---|
| 1603 | #if QT_VERSION < 0x040000
|
|---|
| 1604 | item =fHelpTreeWidget->selectedItem();
|
|---|
| 1605 | #else
|
|---|
| 1606 | QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
|
|---|
| 1607 | if (list.isEmpty())
|
|---|
| 1608 | return;
|
|---|
| 1609 | item = list.first();
|
|---|
| 1610 | #endif
|
|---|
| 1611 | if (!item)
|
|---|
| 1612 | return;
|
|---|
| 1613 |
|
|---|
| 1614 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 1615 | if(UI==NULL) return;
|
|---|
| 1616 | G4UIcommandTree * treeTop = UI->GetTree();
|
|---|
| [699] | 1617 |
|
|---|
| [1266] | 1618 | #if QT_VERSION < 0x040000
|
|---|
| 1619 | std::string itemText = GetLongCommandPath(item).ascii();
|
|---|
| 1620 | #else
|
|---|
| [1249] | 1621 | std::string itemText = GetLongCommandPath(item).toStdString();
|
|---|
| [1266] | 1622 | #endif
|
|---|
| [1249] | 1623 |
|
|---|
| [699] | 1624 | G4UIcommand* command = treeTop->FindPath(itemText.c_str());
|
|---|
| 1625 |
|
|---|
| [607] | 1626 | if (command) {
|
|---|
| 1627 | #if QT_VERSION >= 0x040000
|
|---|
| 1628 | #if QT_VERSION < 0x040200
|
|---|
| 1629 | fHelpArea->clear();
|
|---|
| 1630 | fHelpArea->append(GetCommandList(command));
|
|---|
| 1631 | #else
|
|---|
| 1632 | fHelpArea->setText(GetCommandList(command));
|
|---|
| 1633 | #endif
|
|---|
| 1634 | #else
|
|---|
| 1635 | fHelpArea->setText(GetCommandList(command));
|
|---|
| 1636 | #endif
|
|---|
| [699] | 1637 | } else { // this is a command
|
|---|
| 1638 | G4UIcommandTree* path = treeTop->FindCommandTree(itemText.c_str());
|
|---|
| 1639 | if ( path) {
|
|---|
| 1640 | // this is not a command, this is a sub directory
|
|---|
| 1641 | // We display the Title
|
|---|
| [607] | 1642 | #if QT_VERSION >= 0x040000
|
|---|
| 1643 | #if QT_VERSION < 0x040200
|
|---|
| [699] | 1644 | fHelpArea->clear();
|
|---|
| 1645 | fHelpArea->append(path->GetTitle().data());
|
|---|
| [607] | 1646 | #else
|
|---|
| [699] | 1647 | fHelpArea->setText(path->GetTitle().data());
|
|---|
| [607] | 1648 | #endif
|
|---|
| 1649 | #else
|
|---|
| [699] | 1650 | fHelpArea->setText(path->GetTitle().data());
|
|---|
| [607] | 1651 | #endif
|
|---|
| [699] | 1652 | }
|
|---|
| [607] | 1653 | }
|
|---|
| 1654 | }
|
|---|
| [699] | 1655 |
|
|---|
| [607] | 1656 | /** This callback is activated when user double clic on a item in the help tree
|
|---|
| 1657 | */
|
|---|
| 1658 | void G4UIQt::HelpTreeDoubleClicCallback (
|
|---|
| [648] | 1659 | )
|
|---|
| 1660 | {
|
|---|
| 1661 | HelpTreeClicCallback();
|
|---|
| 1662 |
|
|---|
| [607] | 1663 | #if QT_VERSION < 0x040000
|
|---|
| [648] | 1664 | QListViewItem* item = NULL;
|
|---|
| [607] | 1665 | #else
|
|---|
| [648] | 1666 | QTreeWidgetItem* item = NULL;
|
|---|
| [607] | 1667 | #endif
|
|---|
| [648] | 1668 | if (!fHelpTreeWidget)
|
|---|
| 1669 | return ;
|
|---|
| 1670 |
|
|---|
| 1671 | if (!fHelpArea)
|
|---|
| 1672 | return;
|
|---|
| 1673 |
|
|---|
| 1674 | #if QT_VERSION < 0x040000
|
|---|
| 1675 | item =fHelpTreeWidget->selectedItem();
|
|---|
| 1676 | #else
|
|---|
| 1677 | QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
|
|---|
| 1678 | if (list.isEmpty())
|
|---|
| 1679 | return;
|
|---|
| 1680 | item = list.first();
|
|---|
| 1681 | #endif
|
|---|
| 1682 | if (!item)
|
|---|
| 1683 | return;
|
|---|
| 1684 |
|
|---|
| [683] | 1685 | fCommandArea->clear();
|
|---|
| [1249] | 1686 | fCommandArea->setText(GetLongCommandPath(item));
|
|---|
| [607] | 1687 | }
|
|---|
| 1688 |
|
|---|
| 1689 |
|
|---|
| 1690 | /** Callback called when user select an old command in the command history<br>
|
|---|
| 1691 | Give it to the command area.
|
|---|
| 1692 | */
|
|---|
| 1693 | void G4UIQt::CommandHistoryCallback(
|
|---|
| 1694 | )
|
|---|
| 1695 | {
|
|---|
| 1696 | #if QT_VERSION < 0x040000
|
|---|
| 1697 | QListViewItem* item = NULL;
|
|---|
| 1698 | #else
|
|---|
| 1699 | QListWidgetItem* item = NULL;
|
|---|
| 1700 | #endif
|
|---|
| [1224] | 1701 | if (!fHistoryTBTableList)
|
|---|
| [607] | 1702 | return ;
|
|---|
| [632] | 1703 |
|
|---|
| [607] | 1704 |
|
|---|
| 1705 | #if QT_VERSION < 0x040000
|
|---|
| [1224] | 1706 | item =fHistoryTBTableList->selectedItem();
|
|---|
| [607] | 1707 | #else
|
|---|
| [1224] | 1708 | QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
|
|---|
| [607] | 1709 | if (list.isEmpty())
|
|---|
| 1710 | return;
|
|---|
| 1711 | item = list.first();
|
|---|
| 1712 | #endif
|
|---|
| 1713 | if (!item)
|
|---|
| 1714 | return;
|
|---|
| 1715 | #if QT_VERSION < 0x040000
|
|---|
| 1716 | fCommandArea->setText(item->text(0));
|
|---|
| 1717 | #else
|
|---|
| 1718 | fCommandArea->setText(item->text());
|
|---|
| 1719 | #endif
|
|---|
| [1223] | 1720 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 1721 | printf("G4UIQt::CommandHistoryCallback change text\n");
|
|---|
| 1722 | #endif
|
|---|
| [607] | 1723 | }
|
|---|
| 1724 |
|
|---|
| [697] | 1725 |
|
|---|
| [1224] | 1726 | void G4UIQt::CoutFilterCallback(
|
|---|
| 1727 | const QString & text) {
|
|---|
| 1728 |
|
|---|
| [1266] | 1729 | #if QT_VERSION < 0x040000
|
|---|
| 1730 | QStringList result = "";
|
|---|
| 1731 | #else
|
|---|
| 1732 | QStringList result = fG4cout.filter(text);
|
|---|
| [1224] | 1733 | #endif
|
|---|
| 1734 |
|
|---|
| [1300] | 1735 | fCoutTBTextArea->setPlainText(result.join("\n"));
|
|---|
| [1224] | 1736 | fCoutTBTextArea->repaint();
|
|---|
| 1737 | #if QT_VERSION < 0x040000
|
|---|
| 1738 | fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
|
|---|
| 1739 | #else
|
|---|
| 1740 | fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
|
|---|
| 1741 | #endif
|
|---|
| 1742 |
|
|---|
| 1743 | }
|
|---|
| 1744 |
|
|---|
| [695] | 1745 | /** Callback called when user give a new string to look for<br>
|
|---|
| [697] | 1746 | Display a list of matching commands descriptions. If no string is set,
|
|---|
| 1747 | will display the complete help tree
|
|---|
| [695] | 1748 | */
|
|---|
| [1226] | 1749 | void G4UIQt::LookForHelpStringCallback(
|
|---|
| [695] | 1750 | )
|
|---|
| 1751 | {
|
|---|
| [1239] | 1752 | QString searchText = fHelpLine->text();
|
|---|
| [1226] | 1753 |
|
|---|
| [698] | 1754 | #if QT_VERSION < 0x040200
|
|---|
| 1755 | fHelpArea->clear();
|
|---|
| 1756 | #else
|
|---|
| 1757 | fHelpArea->setText("");
|
|---|
| 1758 | #endif
|
|---|
| [1226] | 1759 | if (searchText =="") {
|
|---|
| [697] | 1760 | // clear old help tree
|
|---|
| 1761 | fHelpTreeWidget->clear();
|
|---|
| [791] | 1762 | #if QT_VERSION < 0x040000
|
|---|
| [719] | 1763 | fHelpTreeWidget->removeColumn(1);
|
|---|
| 1764 | fHelpTreeWidget->removeColumn(0);
|
|---|
| 1765 | #endif
|
|---|
| [1248] | 1766 |
|
|---|
| 1767 | FillHelpTree();
|
|---|
| 1768 |
|
|---|
| [697] | 1769 | return;
|
|---|
| [1226] | 1770 | } else {
|
|---|
| 1771 | OpenHelpTreeOnCommand(searchText);
|
|---|
| [697] | 1772 | }
|
|---|
| [1226] | 1773 | }
|
|---|
| [697] | 1774 |
|
|---|
| [1226] | 1775 |
|
|---|
| 1776 | void G4UIQt::OpenHelpTreeOnCommand(
|
|---|
| 1777 | const QString & searchText
|
|---|
| 1778 | )
|
|---|
| 1779 | {
|
|---|
| 1780 |
|
|---|
| [695] | 1781 | // the help tree
|
|---|
| 1782 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 1783 | if(UI==NULL) return;
|
|---|
| 1784 | G4UIcommandTree * treeTop = UI->GetTree();
|
|---|
| 1785 |
|
|---|
| 1786 | G4int treeSize = treeTop->GetTreeEntry();
|
|---|
| [697] | 1787 |
|
|---|
| 1788 | // clear old help tree
|
|---|
| 1789 | fHelpTreeWidget->clear();
|
|---|
| [793] | 1790 | #if QT_VERSION < 0x040000
|
|---|
| [719] | 1791 | fHelpTreeWidget->removeColumn(1);
|
|---|
| 1792 | fHelpTreeWidget->removeColumn(0);
|
|---|
| 1793 | #endif
|
|---|
| [697] | 1794 |
|
|---|
| 1795 | // look for new items
|
|---|
| 1796 |
|
|---|
| [695] | 1797 | int tmp = 0;
|
|---|
| [719] | 1798 | #if QT_VERSION < 0x040000
|
|---|
| 1799 | int multFactor = 1000; // factor special for having double keys in Qt3
|
|---|
| 1800 | int doubleKeyAdd = 0; // decay for doubleKeys in Qt3
|
|---|
| 1801 | #endif
|
|---|
| 1802 |
|
|---|
| [697] | 1803 | QMap<int,QString> commandResultMap;
|
|---|
| 1804 | QMap<int,QString> commandChildResultMap;
|
|---|
| 1805 |
|
|---|
| [695] | 1806 | for (int a=0;a<treeSize;a++) {
|
|---|
| 1807 | G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a+1)->GetPathName().data());
|
|---|
| [719] | 1808 | #if QT_VERSION > 0x040000
|
|---|
| [1226] | 1809 | tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
|
|---|
| [719] | 1810 | #else
|
|---|
| [1226] | 1811 | tmp = GetCommandList (command).contains(searchText,false);
|
|---|
| [719] | 1812 | #endif
|
|---|
| [695] | 1813 | if (tmp >0) {
|
|---|
| [719] | 1814 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1815 | commandResultMap.insertMulti(tmp,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()));
|
|---|
| [719] | 1816 | #else // tricky thing for Qt3...
|
|---|
| 1817 | doubleKeyAdd = 0;
|
|---|
| 1818 | while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
|
|---|
| 1819 | doubleKeyAdd ++;
|
|---|
| 1820 | }
|
|---|
| 1821 | commandResultMap.insert( tmp*multFactor+doubleKeyAdd,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()) );
|
|---|
| [695] | 1822 | #endif
|
|---|
| 1823 | }
|
|---|
| 1824 | // look for childs
|
|---|
| [1226] | 1825 | commandChildResultMap = LookForHelpStringInChildTree(treeTop->GetTree(a+1),searchText);
|
|---|
| [697] | 1826 | // insert new childs
|
|---|
| 1827 | if (!commandChildResultMap.empty()) {
|
|---|
| [719] | 1828 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1829 | QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
|
|---|
| 1830 | while (i != commandChildResultMap.constEnd()) {
|
|---|
| 1831 | commandResultMap.insertMulti(i.key(),i.value());
|
|---|
| [719] | 1832 | #else // tricky thing for Qt3...
|
|---|
| 1833 | QMap<int,QString>::const_iterator i = commandChildResultMap.begin();
|
|---|
| 1834 | while (i != commandChildResultMap.end()) {
|
|---|
| 1835 | doubleKeyAdd = 0;
|
|---|
| 1836 | while (commandResultMap.find( i.key()*multFactor+doubleKeyAdd) != commandResultMap.end()) {
|
|---|
| 1837 | doubleKeyAdd ++;
|
|---|
| 1838 | }
|
|---|
| 1839 | commandResultMap.insert(i.key()*multFactor+doubleKeyAdd,i.data());
|
|---|
| 1840 | #endif
|
|---|
| [697] | 1841 | i++;
|
|---|
| 1842 | }
|
|---|
| 1843 | commandChildResultMap.clear();
|
|---|
| 1844 | }
|
|---|
| [695] | 1845 | }
|
|---|
| [697] | 1846 |
|
|---|
| 1847 | // build new help tree
|
|---|
| 1848 | #if QT_VERSION < 0x040000
|
|---|
| 1849 | fHelpTreeWidget->setSelectionMode(QListView::Single);
|
|---|
| 1850 | fHelpTreeWidget->setRootIsDecorated(true);
|
|---|
| 1851 | fHelpTreeWidget->addColumn("Command");
|
|---|
| 1852 | fHelpTreeWidget->addColumn("Match");
|
|---|
| 1853 | // fHelpTreeWidget->header()->setResizeEnabled(FALSE,1);
|
|---|
| 1854 | #else
|
|---|
| 1855 | fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|---|
| [700] | 1856 | fHelpTreeWidget->setColumnCount(2);
|
|---|
| [697] | 1857 | QStringList labels;
|
|---|
| [700] | 1858 | labels << QString("Command") << QString("Match");
|
|---|
| [697] | 1859 | fHelpTreeWidget->setHeaderLabels(labels);
|
|---|
| 1860 | #endif
|
|---|
| 1861 |
|
|---|
| 1862 | if (commandResultMap.empty()) {
|
|---|
| 1863 | #if QT_VERSION < 0x040200
|
|---|
| 1864 | fHelpArea->clear();
|
|---|
| 1865 | fHelpArea->append("No match found");
|
|---|
| 1866 | #else
|
|---|
| 1867 | fHelpArea->setText("No match found");
|
|---|
| 1868 | #endif
|
|---|
| 1869 | return;
|
|---|
| 1870 | }
|
|---|
| 1871 |
|
|---|
| [719] | 1872 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1873 | QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
|
|---|
| [719] | 1874 | #else
|
|---|
| 1875 | QMap<int,QString>::const_iterator i = commandResultMap.end();
|
|---|
| 1876 | #endif
|
|---|
| [697] | 1877 | i--;
|
|---|
| 1878 | // 10 maximum progress values
|
|---|
| 1879 | float multValue = 10.0/(float)(i.key());
|
|---|
| 1880 | QString progressChar = "|";
|
|---|
| 1881 | QString progressStr = "|";
|
|---|
| 1882 |
|
|---|
| 1883 | #if QT_VERSION < 0x040000
|
|---|
| 1884 | QListViewItem * newItem;
|
|---|
| 1885 | #else
|
|---|
| 1886 | QTreeWidgetItem * newItem;
|
|---|
| 1887 | #endif
|
|---|
| 1888 | bool end = false;
|
|---|
| 1889 | while (!end) {
|
|---|
| [719] | 1890 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1891 | if (i == commandResultMap.constBegin()) {
|
|---|
| [719] | 1892 | #else
|
|---|
| 1893 | if (i == commandResultMap.begin()) {
|
|---|
| 1894 | #endif
|
|---|
| [697] | 1895 | end = true;
|
|---|
| 1896 | }
|
|---|
| 1897 | for(int a=0;a<int(i.key()*multValue);a++) {
|
|---|
| 1898 | progressStr += progressChar;
|
|---|
| 1899 | }
|
|---|
| 1900 | #if QT_VERSION < 0x040000
|
|---|
| 1901 | newItem = new QListViewItem(fHelpTreeWidget);
|
|---|
| [719] | 1902 | newItem->setText(0,i.data().simplifyWhiteSpace());
|
|---|
| [697] | 1903 | #else
|
|---|
| 1904 | newItem = new QTreeWidgetItem(fHelpTreeWidget);
|
|---|
| 1905 | newItem->setText(0,i.value().trimmed());
|
|---|
| [719] | 1906 | #endif
|
|---|
| [700] | 1907 | newItem->setText(1,progressStr);
|
|---|
| [697] | 1908 |
|
|---|
| 1909 | #if QT_VERSION >= 0x040200
|
|---|
| [700] | 1910 | newItem->setForeground ( 1, QBrush(Qt::blue) );
|
|---|
| [697] | 1911 | #endif
|
|---|
| 1912 | progressStr = "|";
|
|---|
| 1913 | i--;
|
|---|
| 1914 | }
|
|---|
| 1915 | // FIXME : to be checked on Qt3
|
|---|
| 1916 | #if QT_VERSION < 0x040000
|
|---|
| [700] | 1917 | fHelpTreeWidget->setColumnWidthMode (1,QListView::Maximum);
|
|---|
| [719] | 1918 | fHelpTreeWidget->setSorting(1,false);
|
|---|
| [697] | 1919 | #else
|
|---|
| 1920 | fHelpTreeWidget->resizeColumnToContents (0);
|
|---|
| [719] | 1921 | fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
|
|---|
| [700] | 1922 | // fHelpTreeWidget->setColumnWidth(1,10);//resizeColumnToContents (1);
|
|---|
| [697] | 1923 | #endif
|
|---|
| [695] | 1924 | }
|
|---|
| 1925 |
|
|---|
| [697] | 1926 |
|
|---|
| 1927 |
|
|---|
| 1928 |
|
|---|
| 1929 | QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
|
|---|
| [695] | 1930 | G4UIcommandTree *aCommandTree
|
|---|
| [697] | 1931 | ,const QString & text
|
|---|
| 1932 | )
|
|---|
| [695] | 1933 | {
|
|---|
| [697] | 1934 | QMap<int,QString> commandResultMap;
|
|---|
| 1935 | if (aCommandTree == NULL) return commandResultMap;
|
|---|
| 1936 |
|
|---|
| [719] | 1937 | #if QT_VERSION < 0x040000
|
|---|
| 1938 | int multFactor = 1000; // factor special for having double keys in Qt3
|
|---|
| 1939 | int doubleKeyAdd = 0; // decay for doubleKeys in Qt3
|
|---|
| 1940 | #endif
|
|---|
| 1941 |
|
|---|
| [695] | 1942 | // Get the Sub directories
|
|---|
| 1943 | int tmp = 0;
|
|---|
| [697] | 1944 | QMap<int,QString> commandChildResultMap;
|
|---|
| 1945 |
|
|---|
| [695] | 1946 | for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
|
|---|
| 1947 | const G4UIcommand* command = aCommandTree->GetGuidance();
|
|---|
| [719] | 1948 | #if QT_VERSION > 0x040000
|
|---|
| [695] | 1949 | tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
|
|---|
| [719] | 1950 | #else
|
|---|
| 1951 | tmp = GetCommandList (command).contains(text,false);
|
|---|
| 1952 | #endif
|
|---|
| [695] | 1953 | if (tmp >0) {
|
|---|
| [719] | 1954 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1955 | commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
|
|---|
| [719] | 1956 | #else // tricky thing for Qt3...
|
|---|
| 1957 | doubleKeyAdd = 0;
|
|---|
| 1958 | while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
|
|---|
| 1959 | doubleKeyAdd ++;
|
|---|
| 1960 | }
|
|---|
| 1961 | commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
|
|---|
| 1962 | #endif
|
|---|
| [695] | 1963 | }
|
|---|
| 1964 | // look for childs
|
|---|
| [697] | 1965 | commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->GetTree(a+1),text);
|
|---|
| 1966 |
|
|---|
| 1967 | if (!commandChildResultMap.empty()) {
|
|---|
| 1968 | // insert new childs
|
|---|
| [719] | 1969 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1970 | QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
|
|---|
| 1971 | while (i != commandChildResultMap.constEnd()) {
|
|---|
| 1972 | commandResultMap.insertMulti(i.key(),i.value());
|
|---|
| [719] | 1973 | #else // tricky thing for Qt3...
|
|---|
| 1974 | QMap<int,QString>::const_iterator i = commandChildResultMap.begin();
|
|---|
| 1975 | while (i != commandChildResultMap.end()) {
|
|---|
| 1976 | doubleKeyAdd = 0;
|
|---|
| 1977 | while (commandResultMap.find( i.key()*multFactor+doubleKeyAdd) != commandResultMap.end()) {
|
|---|
| 1978 | doubleKeyAdd ++;
|
|---|
| 1979 | }
|
|---|
| 1980 | commandResultMap.insert(i.key()*multFactor+doubleKeyAdd,i.data());
|
|---|
| 1981 | #endif
|
|---|
| [697] | 1982 | i++;
|
|---|
| 1983 | }
|
|---|
| 1984 | commandChildResultMap.clear();
|
|---|
| 1985 | }
|
|---|
| [695] | 1986 | }
|
|---|
| 1987 | // Get the Commands
|
|---|
| [697] | 1988 |
|
|---|
| [695] | 1989 | for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
|
|---|
| 1990 | const G4UIcommand* command = aCommandTree->GetCommand(a+1);
|
|---|
| [719] | 1991 | #if QT_VERSION > 0x040000
|
|---|
| 1992 | tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
|
|---|
| 1993 | #else
|
|---|
| 1994 | tmp = GetCommandList (command).contains(text,false);
|
|---|
| [695] | 1995 | #endif
|
|---|
| 1996 | if (tmp >0) {
|
|---|
| [719] | 1997 | #if QT_VERSION > 0x040000
|
|---|
| [697] | 1998 | commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
|
|---|
| [719] | 1999 | #else // tricky thing for Qt3...
|
|---|
| 2000 | doubleKeyAdd = 0;
|
|---|
| 2001 | while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
|
|---|
| 2002 | doubleKeyAdd ++;
|
|---|
| 2003 | }
|
|---|
| 2004 | commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
|
|---|
| 2005 | #endif
|
|---|
| [695] | 2006 | }
|
|---|
| 2007 |
|
|---|
| 2008 | }
|
|---|
| [697] | 2009 | return commandResultMap;
|
|---|
| [695] | 2010 | }
|
|---|
| [1232] | 2011 |
|
|---|
| [1236] | 2012 |
|
|---|
| [1249] | 2013 | QString G4UIQt::GetShortCommandPath(
|
|---|
| 2014 | QString commandPath
|
|---|
| 2015 | )
|
|---|
| 2016 | {
|
|---|
| [1267] | 2017 | #if QT_VERSION < 0x040000
|
|---|
| [1268] | 2018 | if (commandPath.find("/") == 0) {
|
|---|
| [1267] | 2019 | commandPath = commandPath.right(commandPath.length()-1);
|
|---|
| 2020 | #else
|
|---|
| [1268] | 2021 | if (commandPath.indexOf("/") == 0) {
|
|---|
| [1249] | 2022 | commandPath = commandPath.right(commandPath.size()-1);
|
|---|
| [1267] | 2023 | #endif
|
|---|
| [1249] | 2024 | }
|
|---|
| [1236] | 2025 |
|
|---|
| [1267] | 2026 | #if QT_VERSION < 0x040000
|
|---|
| 2027 | commandPath = commandPath.right(commandPath.length()-commandPath.findRev("/",-2)-1);
|
|---|
| 2028 | #else
|
|---|
| [1249] | 2029 | commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf("/",-2)-1);
|
|---|
| [1267] | 2030 | #endif
|
|---|
| [1249] | 2031 |
|
|---|
| [1267] | 2032 | #if QT_VERSION < 0x040000
|
|---|
| 2033 | if (commandPath.findRev("/") == ((int)commandPath.length()-1)) {
|
|---|
| 2034 | commandPath = commandPath.left(commandPath.length()-1);
|
|---|
| 2035 | }
|
|---|
| 2036 | #else
|
|---|
| [1249] | 2037 | if (commandPath.lastIndexOf("/") == (commandPath.size()-1)) {
|
|---|
| 2038 | commandPath = commandPath.left(commandPath.size()-1);
|
|---|
| [1267] | 2039 | }
|
|---|
| 2040 | #endif
|
|---|
| [1249] | 2041 |
|
|---|
| 2042 | return commandPath;
|
|---|
| 2043 | }
|
|---|
| 2044 |
|
|---|
| 2045 |
|
|---|
| 2046 | QString G4UIQt::GetLongCommandPath(
|
|---|
| 2047 | #if QT_VERSION < 0x040000
|
|---|
| 2048 | QListViewItem* item
|
|---|
| 2049 | #else
|
|---|
| 2050 | QTreeWidgetItem* item
|
|---|
| 2051 | #endif
|
|---|
| 2052 | )
|
|---|
| 2053 | {
|
|---|
| 2054 | if (item == NULL) return "";
|
|---|
| 2055 |
|
|---|
| 2056 | // rebuild path:
|
|---|
| 2057 | QString itemText = "";
|
|---|
| 2058 | itemText = item->text(0);
|
|---|
| 2059 |
|
|---|
| 2060 | while (item->parent() != NULL) {
|
|---|
| 2061 | itemText = item->parent()->text(0)+"/"+itemText;
|
|---|
| 2062 | item = item->parent();
|
|---|
| 2063 | }
|
|---|
| 2064 | itemText = "/"+itemText;
|
|---|
| 2065 |
|
|---|
| 2066 | return itemText;
|
|---|
| 2067 | }
|
|---|
| 2068 |
|
|---|
| [1236] | 2069 | G4QTabWidget::G4QTabWidget(
|
|---|
| 2070 | QSplitter*& split
|
|---|
| 2071 | ):QTabWidget(split)
|
|---|
| [1252] | 2072 | ,tabSelected(false)
|
|---|
| 2073 | ,lastCreated(-1)
|
|---|
| [1236] | 2074 | {
|
|---|
| 2075 | }
|
|---|
| 2076 |
|
|---|
| 2077 | G4QTabWidget::G4QTabWidget(
|
|---|
| 2078 | ):QTabWidget()
|
|---|
| [1252] | 2079 | ,tabSelected(false)
|
|---|
| 2080 | ,lastCreated(-1)
|
|---|
| [1236] | 2081 | {
|
|---|
| 2082 | }
|
|---|
| 2083 |
|
|---|
| 2084 |
|
|---|
| [1239] | 2085 |
|
|---|
| [1304] | 2086 | void G4UIQt::TabCloseCallback(int a){
|
|---|
| [1283] | 2087 | #if QT_VERSION >= 0x040500
|
|---|
| [1239] | 2088 | QWidget* temp = fTabWidget->widget(a);
|
|---|
| 2089 | fTabWidget->removeTab (a);
|
|---|
| [1267] | 2090 |
|
|---|
| [1239] | 2091 | delete temp;
|
|---|
| [1236] | 2092 |
|
|---|
| [1239] | 2093 | if (fTabWidget->count() == 0) {
|
|---|
| [1267] | 2094 | fMyVSplitter->addWidget(fEmptyViewerTabLabel);
|
|---|
| [1239] | 2095 | fTabWidget->setParent(0);
|
|---|
| 2096 | }
|
|---|
| [1304] | 2097 | #endif
|
|---|
| [1239] | 2098 | }
|
|---|
| 2099 |
|
|---|
| 2100 |
|
|---|
| [1248] | 2101 | void G4UIQt::ToolBoxActivated(int a){
|
|---|
| 2102 |
|
|---|
| [1267] | 2103 | #if QT_VERSION < 0x040000
|
|---|
| [1270] | 2104 | if (fToolBox->item(a) == fHelpTBWidget) {
|
|---|
| [1267] | 2105 | #else
|
|---|
| [1248] | 2106 | if (fToolBox->widget(a) == fHelpTBWidget) {
|
|---|
| [1267] | 2107 | #endif
|
|---|
| [1248] | 2108 | // Rebuild the help tree
|
|---|
| 2109 | FillHelpTree();
|
|---|
| 2110 | }
|
|---|
| [1239] | 2111 | }
|
|---|
| 2112 |
|
|---|
| [1236] | 2113 | void G4QTabWidget::paintEvent(
|
|---|
| 2114 | QPaintEvent * event
|
|---|
| 2115 | )
|
|---|
| 2116 | {
|
|---|
| 2117 |
|
|---|
| [1267] | 2118 | #if QT_VERSION < 0x040000
|
|---|
| [1268] | 2119 | if (currentPage()) {
|
|---|
| [1267] | 2120 | #else
|
|---|
| [1236] | 2121 | if (currentWidget()) {
|
|---|
| [1267] | 2122 | #endif
|
|---|
| 2123 |
|
|---|
| [1236] | 2124 | if ( isTabSelected()) {
|
|---|
| [1239] | 2125 |
|
|---|
| [1263] | 2126 | #if QT_VERSION < 0x040000
|
|---|
| [1268] | 2127 | QApplication::sendPostedEvents () ;
|
|---|
| [1263] | 2128 | #else
|
|---|
| [1268] | 2129 | QCoreApplication::sendPostedEvents () ;
|
|---|
| [1263] | 2130 | #endif
|
|---|
| 2131 |
|
|---|
| [1236] | 2132 | #ifdef G4DEBUG_INTERFACES_BASIC
|
|---|
| 2133 | printf("G4QTabWidget::paintEvent OK\n");
|
|---|
| 2134 | #endif
|
|---|
| [1252] | 2135 | #if QT_VERSION < 0x040000
|
|---|
| 2136 | QString text = label (currentPageIndex());
|
|---|
| 2137 | #else
|
|---|
| [1236] | 2138 | QString text = tabText (currentIndex());
|
|---|
| [1252] | 2139 | #endif
|
|---|
| 2140 |
|
|---|
| 2141 | if (lastCreated == -1) {
|
|---|
| 2142 | QString paramSelect = QString("/vis/viewer/select ")+text;
|
|---|
| 2143 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 2144 | if(UI != NULL) {
|
|---|
| [1266] | 2145 | #if QT_VERSION < 0x040000
|
|---|
| [1267] | 2146 | UI->ApplyCommand(paramSelect.ascii());
|
|---|
| [1266] | 2147 | #else
|
|---|
| [1252] | 2148 | UI->ApplyCommand(paramSelect.toStdString().c_str());
|
|---|
| [1266] | 2149 | #endif
|
|---|
| [1252] | 2150 | }
|
|---|
| 2151 | } else {
|
|---|
| 2152 | lastCreated = -1;
|
|---|
| [1236] | 2153 | }
|
|---|
| [1281] | 2154 | setTabSelected(false);
|
|---|
| [1236] | 2155 | repaint();
|
|---|
| 2156 | }
|
|---|
| 2157 | }
|
|---|
| 2158 | }
|
|---|
| 2159 |
|
|---|
| 2160 | #endif
|
|---|