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

Last change on this file since 614 was 562, checked in by garnier, 18 years ago

r565@mac-90108: laurentgarnier | 2007-08-14 14:18:03 +0200
mise a jour suite au plantage de svk (cheksum error) suite au crash du DD en juin

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