source: trunk/geant4/interfaces/basic/src/G4UIQt.cc @ 516

Last change on this file since 516 was 516, checked in by garnier, 17 years ago

r635@mac-90108: laurentgarnier | 2007-06-19 15:51:12 +0200
en test

  • Property svn:mime-type set to text/cpp
File size: 22.3 KB
Line 
1// TODO !
2
3//
4// ********************************************************************
5// * License and Disclaimer                                           *
6// *                                                                  *
7// * The  Geant4 software  is  copyright of the Copyright Holders  of *
8// * the Geant4 Collaboration.  It is provided  under  the terms  and *
9// * conditions of the Geant4 Software License,  included in the file *
10// * LICENSE and available at  http://cern.ch/geant4/license .  These *
11// * include a list of copyright holders.                             *
12// *                                                                  *
13// * Neither the authors of this software system, nor their employing *
14// * institutes,nor the agencies providing financial support for this *
15// * work  make  any representation or  warranty, express or implied, *
16// * regarding  this  software system or assume any liability for its *
17// * use.  Please see the license in the file  LICENSE  and URL above *
18// * for the full disclaimer and the limitation of liability.         *
19// *                                                                  *
20// * This  code  implementation is the result of  the  scientific and *
21// * technical work of the GEANT4 collaboration.                      *
22// * By using,  copying,  modifying or  distributing the software (or *
23// * any work based  on the software)  you  agree  to acknowledge its *
24// * use  in  resulting  scientific  publications,  and indicate your *
25// * acceptance of all terms of the Geant4 Software license.          *
26// ********************************************************************
27//
28//
29// $Id: G4UIQt.cc,v 1.14 2007/05/29 11:09:49 $
30// GEANT4 tag $Name: geant4-08-01 $
31//
32// L. Garnier
33
34//#define DEBUG
35
36#ifdef G4UI_BUILD_QT_SESSION
37
38#include "G4Types.hh"
39
40#include <string.h>
41
42#include "G4UIQt.hh"
43#include "G4UImanager.hh"
44#include "G4StateManager.hh"
45#include "G4UIcommandTree.hh"
46#include "G4UIcommandStatus.hh"
47
48#include "G4UIQtLineEdit.hh"
49
50#include "G4Qt.hh"
51
52#include <QtGui/qapplication.h>
53#include <QtGui/qwidget.h>
54#include <QtGui/qmenu.h>
55#include <QtGui/qmenubar.h>
56#include <QtGui/qboxlayout.h>
57#include <QtGui/qpushbutton.h>
58#include <QtGui/qlabel.h>
59#include <QtGui/qsplitter.h>
60#include <QtGui/qscrollbar.h>
61#include <QtGui/qdialog.h>
62
63#include <stdlib.h>
64
65// Pourquoi Static et non  variables de classe ?
66static G4bool exitSession = true;
67static G4bool exitPause = true;
68/***************************************************************************/
69/**
70 Build a Qt window with a menubar, output area and promt area
71      +-----------------------+
72      |exit menu|             |
73      |                       |
74      | +-------------------+ |
75      | |                   | |
76      | |  Output area      | |
77      | |                   | |
78      | +-------------------+ |
79      |     | clear |         |
80      | +-------------------+ |
81      | |  promt history    | |
82      | +-------------------+ |
83      | +-------------------+ |
84      | |> promt area       | |
85      | +-------------------+ |
86      +-----------------------+
87*/
88
89G4UIQt::G4UIQt (
90 int argc,
91 char** argv
92)
93  :fHelpDialog(NULL)
94
95/***************************************************************************/
96/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
97{
98  G4Qt* interactorManager = G4Qt::getInstance ();
99  G4UImanager* UI = G4UImanager::GetUIpointer();
100  if(UI!=NULL) UI->SetSession(this);
101
102  fMainWindow = new QMainWindow();
103  fMainWindow->setWindowTitle( "G4UI Session" );
104  fMainWindow->resize(800,600);
105  fMainWindow->move(QPoint(300,100));
106
107  QSplitter *splitter = new QSplitter(Qt::Vertical);
108  fTextArea = new QTextEdit();
109  QPushButton *clearButton = new QPushButton("clear");
110  connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback()));
111
112  fCommandHistoryArea = new QTextEdit();
113  fCommandLabel = new QLabel();
114
115  fCommandArea = new G4UIQtLineEdit(this); // must surcharge the keyPressEvent function
116  fCommandArea->activateWindow();
117  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback()));
118  fCommandArea->setFocusPolicy ( Qt::StrongFocus );
119  fCommandArea->setFocus(Qt::TabFocusReason);
120  fTextArea->setReadOnly(true);
121  fCommandHistoryArea->setReadOnly(true);
122
123  //  virtual void keyPressEvent(QKeyEvent *e) {
124  //    if (e->key == Qt::Key_F9) {
125  // Do something
126  //}
127  //}
128
129  // Set layouts
130  QVBoxLayout *layoutSplitter = new QVBoxLayout;
131
132  QWidget* topWidget = new QWidget();
133  QVBoxLayout *layoutTop = new QVBoxLayout;
134
135  QWidget* bottomWidget = new QWidget();
136  QVBoxLayout *layoutBottom = new QVBoxLayout;
137
138
139  layoutTop->addWidget(fTextArea);
140  layoutTop->addWidget(clearButton);
141  topWidget->setLayout(layoutTop);
142
143  layoutBottom->addWidget(fCommandHistoryArea);
144  layoutBottom->addWidget(fCommandLabel);
145  layoutBottom->addWidget(fCommandArea);
146  bottomWidget->setLayout(layoutBottom);
147
148
149  layoutSplitter->addWidget(topWidget);
150  layoutSplitter->addWidget(bottomWidget);
151  splitter->setLayout(layoutSplitter);
152
153  fMainWindow->setCentralWidget(splitter);
154
155  // Add a quit subMenu
156  QMenu *fileMenu = fMainWindow->menuBar()->addMenu("File");
157  fileMenu->addAction("Quitter", fMainWindow, SLOT(close()));
158
159  // Add a Help menu
160  QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help");
161  helpMenu->addAction("Show Help", this, SLOT(showHelpCallback()));
162
163  // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
164  QList<int> vals = splitter->sizes();
165  if(vals.size()==2) {
166    vals[0] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*3/4;
167    vals[1] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*1/4;
168    splitter->setSizes(vals);
169  }
170
171
172  if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
173}
174/***************************************************************************/
175G4UIQt::~G4UIQt(
176)
177/***************************************************************************/
178/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
179{
180  G4UImanager* UI = G4UImanager::GetUIpointer();  // TO KEEP
181  if(UI!=NULL) {  // TO KEEP
182    UI->SetSession(NULL);  // TO KEEP
183    UI->SetCoutDestination(NULL);  // TO KEEP
184  }
185
186 
187  if (fMainWindow!=NULL)
188    delete fMainWindow;
189}
190/***************************************************************************/
191/*
192    Start the Qt main loop
193 */
194G4UIsession* G4UIQt::SessionStart (
195)
196/***************************************************************************/
197/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
198{
199
200  G4Qt* interactorManager = G4Qt::getInstance ();
201  fMainWindow->show();
202  Prompt("session");
203  exitSession = false;
204
205
206  printf("disable secondary loop\n");
207  interactorManager->DisableSecondaryLoop (); // TO KEEP
208  ((QApplication*)interactorManager->GetMainInteractor())->exec();
209  // on ne passe pas le dessous ? FIXME ????
210  // je ne pense pas 13/06
211
212//   void* event; // TO KEEP
213//   while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
214//     interactorManager->DispatchEvent(event); // TO KEEP
215//     if(exitSession==true) break; // TO KEEP
216//   } // TO KEEP
217
218  interactorManager->EnableSecondaryLoop ();
219  printf("enable secondary loop\n");
220  return this;
221}
222/***************************************************************************/
223
224/**
225  Display the prompt in the prompt area
226 */
227void G4UIQt::Prompt (
228 G4String aPrompt
229)
230/***************************************************************************/
231/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
232{
233  fCommandLabel->setText((char*)aPrompt.data());
234}
235/***************************************************************************/
236void G4UIQt::SessionTerminate (
237)
238/***************************************************************************/
239/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
240{
241  G4Qt* interactorManager = G4Qt::getInstance ();
242  fMainWindow->close();
243  ((QApplication*)interactorManager->GetMainInteractor())->exit();
244}
245/***************************************************************************/
246void G4UIQt::PauseSessionStart (
247 G4String a_state
248)
249/***************************************************************************/
250/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
251{
252  printf("G4UIQt::PauseSessionStart\n");
253  if(a_state=="G4_pause> ") {  // TO KEEP
254    SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
255  } // TO KEEP
256
257  if(a_state=="EndOfEvent") { // TO KEEP
258    // Picking with feed back in event data Done here !!!
259    SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
260  } // TO KEEP
261}
262/***************************************************************************/
263void G4UIQt::SecondaryLoop (
264 G4String a_prompt
265)
266/***************************************************************************/
267/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
268{
269  printf("G4UIQt::SecondaryLoop\n");
270  G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
271  Prompt(a_prompt); // TO KEEP
272  exitPause = false; // TO KEEP
273  void* event; // TO KEEP
274  while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
275    interactorManager->DispatchEvent(event); // TO KEEP
276    if(exitPause==true) break; // TO KEEP
277  } // TO KEEP
278  Prompt("session"); // TO KEEP
279}
280/***************************************************************************/
281/**
282  Receive a cout from Geant4. We have to display it in the cout zone
283 */
284G4int G4UIQt::ReceiveG4cout (
285 G4String a_string
286)
287/***************************************************************************/
288/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
289{
290  fTextArea->append(QString((char*)a_string.data()).trimmed());
291  fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
292  return 0;
293}
294/***************************************************************************/
295/**
296  Receive a cerr from Geant4. We have to display it in the cout zone
297 */
298G4int G4UIQt::ReceiveG4cerr (
299 G4String a_string
300)
301/***************************************************************************/
302/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
303{
304  QColor previousColor = fTextArea->textColor();
305  fTextArea->setTextColor(Qt::red);
306  fTextArea->append(QString((char*)a_string.data()).trimmed());
307  fTextArea->setTextColor(previousColor);
308  fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
309  return 0;
310}
311
312/***************************************************************************/
313void G4UIQt::AddMenu (
314 const char* a_name
315,const char* a_label
316)
317/***************************************************************************/
318/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
319{
320  printf("G4UIQt::AddMenu %s %s\n",a_name,a_label);
321
322  //  QMenu *fileMenu = fMainWindow->menuBar()->addMenu(a_label);
323  QMenu *fileMenu = new QMenu(a_label);
324  fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu);
325  AddInteractor (a_name,(G4Interactor)fileMenu);
326}
327/***************************************************************************/
328void G4UIQt::AddButton (
329 const char* a_menu
330,const char* a_label
331,const char* a_command
332)
333/***************************************************************************/
334/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
335{
336  if(a_menu==NULL) return; // TO KEEP
337  if(a_label==NULL) return; // TO KEEP
338  if(a_command==NULL) return; // TO KEEP
339  QMenu *parent = (QMenu*)GetInteractor(a_menu);
340  if(parent==NULL) return;
341 
342  signalMapper = new QSignalMapper(this);
343  QAction *action = parent->addAction(a_label, signalMapper, SLOT(map()));
344  signalMapper->setMapping(action, QString(a_command));
345  connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(buttonCallback(const QString&)));
346}
347
348
349
350
351/**
352  Open the help dialog in a separate window.
353  This will be display as a tree widget
354  Implementation of <b>void G4VBasicShell::TerminalHelp(G4String newCommand)</b>
355
356  @param newCommand : open the tree widget item on this command if is set
357 */
358void G4UIQt::TerminalHelp(G4String newCommand)
359{
360
361
362  if (!fHelpDialog) {
363    fHelpDialog = new QDialog;
364
365    QSplitter *splitter = new QSplitter(Qt::Horizontal);
366    fHelpArea = new QTextEdit();
367    QPushButton *exitButton = new QPushButton("Exit");
368    connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close()));
369    fHelpArea->setReadOnly(true);
370
371    // the help tree
372    G4UImanager* UI = G4UImanager::GetUIpointer();
373    if(UI==NULL) return;
374    G4UIcommandTree * treeTop = UI->GetTree();
375
376
377  // en test : creation de doc html
378
379
380    treeTop->CreateHTML();
381    printf("************ create file : -%s-**********\n",((char*)treeTop->GetPathName().data()));
382
383
384
385
386
387
388
389  //
390    // build widget
391    fHelpTreeWidget = new QTreeWidget();
392    fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
393    fHelpTreeWidget->setColumnCount(2);
394    fHelpTreeWidget->setColumnHidden(1,true);
395    QStringList labels;
396    labels << QString("Command") << QString("Description");
397    fHelpTreeWidget->setHeaderLabels(labels);
398
399    QList<QTreeWidgetItem *> items;
400    G4int treeSize = treeTop->GetTreeEntry();
401    QTreeWidgetItem * newItem;
402    for (int a=0;a<treeSize;a++) {
403      // Creating new item
404      QStringList stringList;
405      stringList << QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed()  ;
406      stringList << QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed()  ;
407
408      newItem = new QTreeWidgetItem(stringList);
409
410      // look for childs
411      CreateChildTree(newItem,treeTop->GetTree(a+1));
412      items.append(newItem);
413    }
414    fHelpTreeWidget->insertTopLevelItems(0, items);
415
416    //connecting callback
417    //  QSignalMapper signalMapper = new QSignalMapper(this);
418
419    connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(helpTreeCallback())); 
420
421    // Set layouts
422    QHBoxLayout *splitterLayout = new QHBoxLayout;
423
424    QVBoxLayout *vLayout = new QVBoxLayout;
425
426    splitterLayout->addWidget(fHelpTreeWidget);
427    splitterLayout->addWidget(fHelpArea);
428    splitter->setLayout(splitterLayout);
429
430    vLayout->addWidget(splitter);
431    vLayout->addWidget(exitButton);
432    fHelpDialog->setLayout(vLayout);
433
434  }
435
436  // Look for the choosen command "newCommand"
437  size_t i = newCommand.index(" ");
438  G4String targetCom="";
439  if( i != std::string::npos )
440  {
441    G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
442    newValue.strip(G4String::both);
443    targetCom = ModifyToFullPathCommand( newValue );
444    printf("test : av:%s-- ap:%s--\n",((char*)newValue.data()),((char*)targetCom.data()));
445  }
446  if (targetCom != "") {
447    QList<QTreeWidgetItem *> list = fHelpTreeWidget->findItems(QString(((char*)targetCom.data())),Qt::MatchFixedString,0);
448    for (int a=0;a<13;a++) {
449      printf("verif.... =%s= +%s+\n",fHelpTreeWidget->topLevelItem(a)->text(0).toStdString().c_str(),((char*)targetCom.data()));
450    }
451
452    if (!list.isEmpty()) {
453      if (list.first()->childCount() >0) 
454        list.first()->setExpanded(true);
455     
456      //collapsed open item
457      QList<QTreeWidgetItem *> selected;
458      selected = fHelpTreeWidget->selectedItems();
459      if ( selected.count() != 0 ) {
460        fHelpTreeWidget->collapseItem (selected.at( 0 ) );
461      }
462     
463      // clear old selection
464      fHelpTreeWidget->clearSelection();
465      list.first()->setSelected(true);
466     
467      // Call the update of the right textArea
468      helpTreeCallback();
469    }
470  }
471  fHelpDialog->setWindowTitle("Help on commands");
472  fHelpDialog->resize(800,600);
473  fHelpDialog->move(QPoint(400,150));
474  fHelpDialog->show();
475  fHelpDialog->raise();
476  fHelpDialog->activateWindow();
477}
478
479
480
481void G4UIQt::CreateChildTree(QTreeWidgetItem *a_parent,G4UIcommandTree *a_commandTree) {
482
483  // Creating new item
484  QTreeWidgetItem * newItem;
485
486
487  // Get the Sub directories
488  for (int a=0;a<a_commandTree->GetTreeEntry();a++) {
489   
490    QStringList stringList;
491    stringList << QString((char*)(a_commandTree->GetTree(a+1)->GetPathName()).data()).trimmed()  ;
492    stringList << QString((char*)(a_commandTree->GetTree(a+1)->GetTitle()).data()).trimmed()  ;
493    newItem = new QTreeWidgetItem(stringList);
494
495    CreateChildTree(newItem,a_commandTree->GetTree(a+1));
496    a_parent->addChild(newItem);
497  }
498
499
500
501  // Get the Commands
502
503  for (int a=0;a<a_commandTree->GetCommandEntry();a++) {
504   
505    QStringList stringList;
506    stringList << QString((char*)(a_commandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed()  ;
507    stringList << QString((char*)(a_commandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed()  ;
508    newItem = new QTreeWidgetItem(stringList);
509     
510    a_parent->addChild(newItem);
511    newItem->setExpanded(false);
512  }
513}
514
515
516/**
517  This fonction return the command list parameters in a QString
518
519 */
520/***************************************************************************/
521QString G4UIQt::GetCommandList (
522  G4UIcommand *a_command
523)
524/***************************************************************************/
525/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
526{
527
528  QString txt;
529  G4String commandPath = a_command->GetCommandPath();
530  G4String rangeString = a_command->GetRange();
531
532  if((commandPath.length()-1)!='/')
533  {
534    txt += "Command " + QString((char*)(commandPath).data()) + "\n";
535  }
536  txt += "Guidance :\n";
537  G4int n_guidanceEntry = a_command->GetGuidanceEntries();
538
539  for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
540    { txt += QString((char*)(a_command->GetGuidanceLine(i_thGuidance)).data()) + "\n"; }
541  if( ! rangeString.isNull() )
542    { txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n"; }
543  G4int n_parameterEntry = a_command->GetParameterEntries();
544  if( n_parameterEntry > 0 )
545    {
546      G4UIparameter *param;
547
548      // Re-implementation of G4UIparameter.cc
549
550      for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
551        { param = a_command->GetParameter(i_thParameter);
552          txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
553          if( ! param->GetParameterGuidance().isNull() )
554            txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
555          txt += " Parameter type  : " + QString(param->GetParameterType())+ "\n";
556          if(param->IsOmittable())
557            { txt += " Omittable       : True\n"; }
558          else
559            { txt += " Omittable       : False\n"; }
560          if( param->GetCurrentAsDefault() )
561            { txt += " Default value   : taken from the current value\n"; }
562          else if( ! param->GetDefaultValue().isNull() )
563            { txt += " Default value   : " + QString((char*)(param->GetDefaultValue()).data())+ "\n"; }
564          if( ! param->GetParameterRange().isNull() )
565            txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
566          if( ! param->GetParameterCandidates().isNull() )
567            txt += " Candidates      : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
568        }
569    }
570  return txt;
571}
572
573
574
575/***************************************************************************/
576void G4UIQt::expandHelpItem (
577 QTreeWidgetItem *a_parent
578,G4UIcommand* a_expandCommand
579)
580/***************************************************************************/
581/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
582{
583}
584
585
586
587/***************************************************************************/
588//
589//             SLOTS DEFINITIONS
590//
591/***************************************************************************/
592
593/***************************************************************************/
594void G4UIQt::showHelpCallback (
595)
596/***************************************************************************/
597/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
598{
599  TerminalHelp("");
600}
601
602/***************************************************************************/
603void G4UIQt::clearButtonCallback (
604)
605/***************************************************************************/
606/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
607{
608  fTextArea->clear();
609}
610
611
612/**
613  Callback call when "click on a menu entry.
614  Send the associated command to geant4
615 */
616void G4UIQt::commandEnteredCallback (
617)
618/***************************************************************************/
619/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
620{
621  printf ("debug : callback\n");
622  G4String command (fCommandArea->text().toStdString().c_str());
623  if (fCommandArea->text().toStdString().c_str() != "") {
624    fCommandHistoryArea->append(fCommandArea->text());
625
626    if (command(0,4) != "help") {
627      ApplyShellCommand (command,exitSession,exitPause);
628    } else {
629      printf ("terminal help\n");
630      TerminalHelp(command);
631    }
632    if(exitSession==true)
633      SessionTerminate();
634  }
635  fCommandArea->setText("");
636}
637
638/**
639  Callback call when "enter" clicked on the command zone.
640  Send the command to geant4
641 */
642void G4UIQt::buttonCallback (
643  const QString& a_command
644)
645/***************************************************************************/
646/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
647{
648  G4String ss = G4String(a_command.toStdString().c_str());
649  printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause);
650  ApplyShellCommand(ss,exitSession,exitPause);
651  if(exitSession==true)
652    SessionTerminate();
653}
654/**
655This callback is activated when user selected a item in the help tree
656 */
657void G4UIQt::helpTreeCallback (
658)
659/***************************************************************************/
660/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
661{
662  //  G4bool GetHelpChoice(G4int&);
663  QTreeWidgetItem* item =  NULL;
664  if (!fHelpTreeWidget)
665    return ;
666
667  if (!fHelpArea)
668    return;
669 
670  QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
671  if (list.isEmpty())
672    return;
673  item = list.first();
674  if (!item)
675    return;
676 
677  G4UImanager* UI = G4UImanager::GetUIpointer();
678  if(UI==NULL) return;
679  G4UIcommandTree * treeTop = UI->GetTree();
680  G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str());
681  if (command) {
682    fHelpArea->setText(GetCommandList(command));
683  } else {
684    // this is not a command, this is a sub directory
685    // We display the Title
686    fHelpArea->setText(item->text (1).toStdString().c_str());
687  }
688}
689
690
691#endif
Note: See TracBrowser for help on using the repository browser.