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