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