source: trunk/source/interfaces/basic/src/G4UIQt.cc@ 1236

Last change on this file since 1236 was 1236, checked in by garnier, 16 years ago

debug mode

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