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

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

r634@mac-90108: laurentgarnier | 2007-06-19 11:51:28 +0200
bug resolu

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