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

Last change on this file since 1262 was 1262, checked in by garnier, 14 years ago

test qt3

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