#include <G4UIQt.hh>
Inheritance diagram for G4UIQt:
Signals | |
void | myClicked (const QString &text) |
Public Member Functions | |
G4UIQt (int, char **) | |
G4UIsession * | SessionStart () |
void | AddMenu (const char *, const char *) |
void | AddButton (const char *, const char *, const char *) |
~G4UIQt () | |
void | Prompt (G4String) |
void | SessionTerminate () |
void | PauseSessionStart (G4String) |
G4int | ReceiveG4cout (G4String) |
G4int | ReceiveG4cerr (G4String) |
Private Slots | |
void | clearButtonCallback () |
void | commandEnteredCallback () |
void | buttonCallback (const QString &) |
void | helpTreeCallback () |
void | showHelpCallback () |
void | commandHistoryCallback () |
Private Member Functions | |
void | SecondaryLoop (G4String) |
void | TerminalHelp (G4String) |
void | CreateChildTree (QTreeWidgetItem *, G4UIcommandTree *) |
QString | GetCommandList (G4UIcommand *) |
G4bool | GetHelpChoice (G4int &) |
void | ExitHelp () |
bool | eventFilter (QObject *, QEvent *) |
Private Attributes | |
QMainWindow * | fMainWindow |
QLabel * | fCommandLabel |
QLineEdit * | fCommandArea |
QTextEdit * | fTextArea |
QTextEdit * | fHelpArea |
QListWidget * | fCommandHistoryArea |
QSignalMapper * | signalMapper |
QTreeWidget * | fHelpTreeWidget |
QDialog * | fHelpDialog |
|
Build a Qt window with a menubar, output area and promt area
|
Here is the call graph for this function:
|
Definition at line 167 of file G4UIQt.cc. References fMainWindow.
00169 { 00170 G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP 00171 if(UI!=NULL) { // TO KEEP 00172 UI->SetSession(NULL); // TO KEEP 00173 UI->SetCoutDestination(NULL); // TO KEEP 00174 } 00175 00176 00177 if (fMainWindow!=NULL) 00178 delete fMainWindow; 00179 } |
|
Add a new button to a menu
Reimplemented from G4VInteractiveSession. Definition at line 340 of file G4UIQt.cc. References buttonCallback(), G4VInteractiveSession::GetInteractor(), and signalMapper.
00345 { 00346 if(aMenu==NULL) return; // TO KEEP 00347 if(aLabel==NULL) return; // TO KEEP 00348 if(aCommand==NULL) return; // TO KEEP 00349 QMenu *parent = (QMenu*)GetInteractor(aMenu); 00350 if(parent==NULL) return; 00351 00352 signalMapper = new QSignalMapper(this); 00353 QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map())); 00354 signalMapper->setMapping(action, QString(aCommand)); 00355 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(buttonCallback(const QString&))); 00356 } |
Here is the call graph for this function:
|
Add a new menu to the menu bar
Reimplemented from G4VInteractiveSession. Definition at line 323 of file G4UIQt.cc. References G4VInteractiveSession::AddInteractor(), fMainWindow, and G4Interactor.
00327 { 00328 QMenu *fileMenu = new QMenu(aLabel); 00329 fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu); 00330 AddInteractor (aName,(G4Interactor)fileMenu); 00331 } |
Here is the call graph for this function:
|
Callback call when "enter" clicked on the command zone.
Definition at line 715 of file G4UIQt.cc. References G4VBasicShell::ApplyShellCommand(), exitPause, exitSession, and SessionTerminate(). Referenced by AddButton().
00718 { 00719 G4String ss = G4String(aCommand.toStdString().c_str()); 00720 printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause); 00721 ApplyShellCommand(ss,exitSession,exitPause); 00722 if(exitSession==true) 00723 SessionTerminate(); 00724 } |
|
Called when user click on clear button. Clear the text Output area Definition at line 677 of file G4UIQt.cc. References fTextArea. Referenced by G4UIQt().
00679 { 00680 fTextArea->clear(); 00681 } |
|
Callback call when "click on a menu entry. Definition at line 688 of file G4UIQt.cc. References G4VBasicShell::ApplyShellCommand(), exitPause, exitSession, fCommandArea, fCommandHistoryArea, SessionTerminate(), and TerminalHelp(). Referenced by G4UIQt().
00690 { 00691 G4String command (fCommandArea->text().toStdString().c_str()); 00692 if (fCommandArea->text().trimmed() != "") { 00693 fCommandHistoryArea->addItem(fCommandArea->text()); 00694 fCommandHistoryArea->clearSelection(); 00695 fCommandHistoryArea->item(fCommandHistoryArea->count()-1)->setSelected(true); 00696 fCommandHistoryArea->setCurrentItem(fCommandHistoryArea->item(fCommandHistoryArea->count()-1)); 00697 00698 if (command(0,4) != "help") { 00699 ApplyShellCommand (command,exitSession,exitPause); 00700 } else { 00701 TerminalHelp(command); 00702 } 00703 if(exitSession==true) 00704 SessionTerminate(); 00705 } 00706 fCommandArea->setText(""); 00707 } |
|
Callback called when user select an old command in the command history Definition at line 767 of file G4UIQt.cc. References fCommandArea, and fCommandHistoryArea. Referenced by G4UIQt().
00769 { 00770 QListWidgetItem* item = NULL; 00771 if (!fCommandHistoryArea) 00772 return ; 00773 00774 00775 QList<QListWidgetItem *> list =fCommandHistoryArea->selectedItems(); 00776 if (list.isEmpty()) 00777 return; 00778 item = list.first(); 00779 if (!item) 00780 return; 00781 fCommandArea->setText(item->text()); 00782 00783 } |
|
Fill the Help Tree Widget
Definition at line 480 of file G4UIQt.cc. Referenced by TerminalHelp().
00484 { 00485 00486 // Creating new item 00487 QTreeWidgetItem * newItem; 00488 00489 00490 // Get the Sub directories 00491 for (int a=0;a<aCommandTree->GetTreeEntry();a++) { 00492 00493 QStringList stringList; 00494 stringList << QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed() ; 00495 stringList << QString((char*)(aCommandTree->GetTree(a+1)->GetTitle()).data()).trimmed() ; 00496 newItem = new QTreeWidgetItem(stringList); 00497 00498 CreateChildTree(newItem,aCommandTree->GetTree(a+1)); 00499 aParent->addChild(newItem); 00500 } 00501 00502 00503 00504 // Get the Commands 00505 00506 for (int a=0;a<aCommandTree->GetCommandEntry();a++) { 00507 00508 QStringList stringList; 00509 stringList << QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed() ; 00510 stringList << QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed() ; 00511 newItem = new QTreeWidgetItem(stringList); 00512 00513 aParent->addChild(newItem); 00514 newItem->setExpanded(false); 00515 } 00516 } |
|
Event filter method. Every event from QtApplication goes here.<br/> We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/> is active. If this filter match, Up arrow we give the previous command<br/> and Down arrow will give the next if exist.<br/>
Definition at line 608 of file G4UIQt.cc. References fCommandArea, and fCommandHistoryArea.
00612 { 00613 if (obj == fCommandHistoryArea) { 00614 if (event->type() == QEvent::KeyPress) { 00615 fCommandArea->setFocus(); 00616 } 00617 } 00618 if (obj == fCommandArea) { 00619 if (event->type() == QEvent::KeyPress) { 00620 QKeyEvent *e = static_cast<QKeyEvent*>(event); 00621 if ((e->key() == (Qt::Key_Down)) || 00622 (e->key() == (Qt::Key_PageDown)) || 00623 (e->key() == (Qt::Key_Up)) || 00624 (e->key() == (Qt::Key_PageUp))) { 00625 int selection = fCommandHistoryArea->currentRow(); 00626 for (int a=0;a<fCommandHistoryArea->count();a++) { 00627 00628 } 00629 if (fCommandHistoryArea->count()) { 00630 if (selection == -1) { 00631 selection = fCommandHistoryArea->count()-1; 00632 } 00633 if (e->key() == (Qt::Key_Down)) { 00634 if (selection <(fCommandHistoryArea->count()-1)) 00635 selection++; 00636 } else if (e->key() == (Qt::Key_PageDown)) { 00637 selection = fCommandHistoryArea->count()-1; 00638 } else if (e->key() == (Qt::Key_Up)) { 00639 if (selection >0) 00640 selection --; 00641 } else if (e->key() == (Qt::Key_PageUp)) { 00642 selection = 0; 00643 } 00644 fCommandHistoryArea->clearSelection(); 00645 fCommandHistoryArea->item(selection)->setSelected(true); 00646 fCommandHistoryArea->setCurrentItem(fCommandHistoryArea->item(selection)); 00647 } 00648 } 00649 } 00650 } 00651 // pass the event on to the parent class 00652 return QObject::eventFilter(obj, event); 00653 } |
|
Implement G4VBasicShell vurtual function Implements G4VBasicShell. Definition at line 593 of file G4UIQt.cc.
00595 {
00596 printf("G4UIQt::ExitHelp SHOULD NEVER GO HERE");
00597 }
|
|
Build the command list parameters in a QString
Definition at line 526 of file G4UIQt.cc. Referenced by helpTreeCallback().
00529 { 00530 00531 QString txt; 00532 G4String commandPath = aCommand->GetCommandPath(); 00533 G4String rangeString = aCommand->GetRange(); 00534 00535 if((commandPath.length()-1)!='/') 00536 { 00537 txt += "Command " + QString((char*)(commandPath).data()) + "\n"; 00538 } 00539 txt += "Guidance :\n"; 00540 G4int n_guidanceEntry = aCommand->GetGuidanceEntries(); 00541 00542 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) 00543 { txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n"; } 00544 if( ! rangeString.isNull() ) 00545 { txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n"; } 00546 G4int n_parameterEntry = aCommand->GetParameterEntries(); 00547 if( n_parameterEntry > 0 ) 00548 { 00549 G4UIparameter *param; 00550 00551 // Re-implementation of G4UIparameter.cc 00552 00553 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) 00554 { param = aCommand->GetParameter(i_thParameter); 00555 txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n"; 00556 if( ! param->GetParameterGuidance().isNull() ) 00557 txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ; 00558 txt += " Parameter type : " + QString(param->GetParameterType())+ "\n"; 00559 if(param->IsOmittable()) 00560 { txt += " Omittable : True\n"; } 00561 else 00562 { txt += " Omittable : False\n"; } 00563 if( param->GetCurrentAsDefault() ) 00564 { txt += " Default value : taken from the current value\n"; } 00565 else if( ! param->GetDefaultValue().isNull() ) 00566 { txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n"; } 00567 if( ! param->GetParameterRange().isNull() ) 00568 txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n"; 00569 if( ! param->GetParameterCandidates().isNull() ) 00570 txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n"; 00571 } 00572 } 00573 return txt; 00574 } |
|
Implement G4VBasicShell vurtual function Implements G4VBasicShell. Definition at line 581 of file G4UIQt.cc.
00584 { 00585 printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE"); 00586 return true; 00587 } |
|
This callback is activated when user selected a item in the help tree Definition at line 731 of file G4UIQt.cc. References fHelpArea, fHelpTreeWidget, and GetCommandList(). Referenced by TerminalHelp().
00733 { 00734 // G4bool GetHelpChoice(G4int&); 00735 QTreeWidgetItem* item = NULL; 00736 if (!fHelpTreeWidget) 00737 return ; 00738 00739 if (!fHelpArea) 00740 return; 00741 00742 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems(); 00743 if (list.isEmpty()) 00744 return; 00745 item = list.first(); 00746 if (!item) 00747 return; 00748 00749 G4UImanager* UI = G4UImanager::GetUIpointer(); 00750 if(UI==NULL) return; 00751 G4UIcommandTree * treeTop = UI->GetTree(); 00752 G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str()); 00753 if (command) { 00754 fHelpArea->setText(GetCommandList(command)); 00755 } else { 00756 // this is not a command, this is a sub directory 00757 // We display the Title 00758 fHelpArea->setText(item->text (1).toStdString().c_str()); 00759 } 00760 } |
|
Definition at line 93 of file G4UIQt_moc.cc.
00094 { 00095 void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; 00096 QMetaObject::activate(this, &staticMetaObject, 0, _a); 00097 } |
|
Called by intercoms/src/G4UImanager.cc
Implements G4VBasicShell. Definition at line 247 of file G4UIQt.cc. References SecondaryLoop().
00250 { 00251 printf("G4UIQt::PauseSessionStart\n"); 00252 if(aState=="G4_pause> ") { // TO KEEP 00253 SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP 00254 } // TO KEEP 00255 00256 if(aState=="EndOfEvent") { // TO KEEP 00257 // Picking with feed back in event data Done here !!! 00258 SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP 00259 } // TO KEEP 00260 } |
Here is the call graph for this function:
|
Display the prompt in the prompt area
Definition at line 221 of file G4UIQt.cc. References fCommandLabel. Referenced by SecondaryLoop(), and SessionStart().
00224 { 00225 fCommandLabel->setText((char*)aPrompt.data()); 00226 } |
|
Receive a cerr from Geant4. We have to display it in the cout zone
Definition at line 304 of file G4UIQt.cc. References fTextArea.
00307 { 00308 QColor previousColor = fTextArea->textColor(); 00309 fTextArea->setTextColor(Qt::red); 00310 fTextArea->append(QString((char*)aString.data()).trimmed()); 00311 fTextArea->setTextColor(previousColor); 00312 fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum()); 00313 return 0; 00314 } |
|
Receive a cout from Geant4. We have to display it in the cout zone
Definition at line 290 of file G4UIQt.cc. References fTextArea.
|
|
Begin the secondary loop
Definition at line 268 of file G4UIQt.cc. References G4VInteractorManager::DispatchEvent(), exitPause, G4Qt::GetEvent(), G4Qt::getInstance(), and Prompt(). Referenced by PauseSessionStart().
00271 { 00272 printf("G4UIQt::SecondaryLoop\n"); 00273 G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? 00274 Prompt(aPrompt); // TO KEEP 00275 exitPause = false; // TO KEEP 00276 void* event; // TO KEEP 00277 while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP 00278 interactorManager->DispatchEvent(event); // TO KEEP 00279 if(exitPause==true) break; // TO KEEP 00280 } // TO KEEP 00281 Prompt("session"); // TO KEEP 00282 } |
Here is the call graph for this function:
|
Start the Qt main loop Implements G4VBasicShell. Definition at line 187 of file G4UIQt.cc. References G4VInteractorManager::DisableSecondaryLoop(), G4VInteractorManager::EnableSecondaryLoop(), exitSession, fMainWindow, G4Qt::getInstance(), G4VInteractorManager::GetMainInteractor(), and Prompt().
00189 { 00190 00191 G4Qt* interactorManager = G4Qt::getInstance (); 00192 fMainWindow->show(); 00193 Prompt("session"); 00194 exitSession = false; 00195 00196 00197 printf("disable secondary loop\n"); 00198 interactorManager->DisableSecondaryLoop (); // TO KEEP 00199 ((QApplication*)interactorManager->GetMainInteractor())->exec(); 00200 // on ne passe pas le dessous ? FIXME ???? 00201 // je ne pense pas 13/06 00202 00203 // void* event; // TO KEEP 00204 // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP 00205 // interactorManager->DispatchEvent(event); // TO KEEP 00206 // if(exitSession==true) break; // TO KEEP 00207 // } // TO KEEP 00208 00209 interactorManager->EnableSecondaryLoop (); 00210 printf("enable secondary loop\n"); 00211 return this; 00212 } |
Here is the call graph for this function:
|
Definition at line 229 of file G4UIQt.cc. References fMainWindow, G4Qt::getInstance(), and G4VInteractorManager::GetMainInteractor(). Referenced by buttonCallback(), and commandEnteredCallback().
00231 { 00232 G4Qt* interactorManager = G4Qt::getInstance (); 00233 fMainWindow->close(); 00234 ((QApplication*)interactorManager->GetMainInteractor())->exit(); 00235 } |
Here is the call graph for this function:
|
Called when user give "help" command. Definition at line 667 of file G4UIQt.cc. References TerminalHelp(). Referenced by G4UIQt().
00669 { 00670 TerminalHelp(""); 00671 } |
|
Open the help dialog in a separate window.
Reimplemented from G4VBasicShell. Definition at line 368 of file G4UIQt.cc. References CreateChildTree(), fHelpArea, fHelpDialog, fHelpTreeWidget, helpTreeCallback(), and G4VBasicShell::ModifyToFullPathCommand(). Referenced by commandEnteredCallback(), and showHelpCallback().
00371 { 00372 if (!fHelpDialog) { 00373 fHelpDialog = new QDialog; 00374 00375 QSplitter *splitter = new QSplitter(Qt::Horizontal); 00376 fHelpArea = new QTextEdit(); 00377 QPushButton *exitButton = new QPushButton("Exit"); 00378 connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close())); 00379 fHelpArea->setReadOnly(true); 00380 00381 // the help tree 00382 G4UImanager* UI = G4UImanager::GetUIpointer(); 00383 if(UI==NULL) return; 00384 G4UIcommandTree * treeTop = UI->GetTree(); 00385 00386 // build widget 00387 fHelpTreeWidget = new QTreeWidget(); 00388 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); 00389 fHelpTreeWidget->setColumnCount(2); 00390 fHelpTreeWidget->setColumnHidden(1,true); 00391 QStringList labels; 00392 labels << QString("Command") << QString("Description"); 00393 fHelpTreeWidget->setHeaderLabels(labels); 00394 00395 QList<QTreeWidgetItem *> items; 00396 G4int treeSize = treeTop->GetTreeEntry(); 00397 QTreeWidgetItem * newItem; 00398 for (int a=0;a<treeSize;a++) { 00399 // Creating new item 00400 QStringList stringList; 00401 stringList << QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed() ; 00402 stringList << QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed() ; 00403 00404 newItem = new QTreeWidgetItem(stringList); 00405 00406 // look for childs 00407 CreateChildTree(newItem,treeTop->GetTree(a+1)); 00408 items.append(newItem); 00409 } 00410 fHelpTreeWidget->insertTopLevelItems(0, items); 00411 00412 //connecting callback 00413 // QSignalMapper signalMapper = new QSignalMapper(this); 00414 00415 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(helpTreeCallback())); 00416 00417 // Set layouts 00418 00419 QVBoxLayout *vLayout = new QVBoxLayout; 00420 00421 splitter->addWidget(fHelpTreeWidget); 00422 splitter->addWidget(fHelpArea); 00423 00424 vLayout->addWidget(splitter); 00425 vLayout->addWidget(exitButton); 00426 fHelpDialog->setLayout(vLayout); 00427 00428 } 00429 00430 // Look for the choosen command "newCommand" 00431 size_t i = newCommand.index(" "); 00432 G4String targetCom=""; 00433 if( i != std::string::npos ) 00434 { 00435 G4String newValue = newCommand(i+1,newCommand.length()-(i+1)); 00436 newValue.strip(G4String::both); 00437 targetCom = ModifyToFullPathCommand( newValue ); 00438 printf("test : av:%s-- ap:%s--\n",((char*)newValue.data()),((char*)targetCom.data())); 00439 } 00440 if (targetCom != "") { 00441 QList<QTreeWidgetItem *> list = fHelpTreeWidget->findItems(QString(((char*)targetCom.data())),Qt::MatchFixedString,0); 00442 for (int a=0;a<13;a++) { 00443 printf("verif.... =%s= +%s+\n",fHelpTreeWidget->topLevelItem(a)->text(0).toStdString().c_str(),((char*)targetCom.data())); 00444 } 00445 00446 if (!list.isEmpty()) { 00447 if (list.first()->childCount() >0) 00448 list.first()->setExpanded(true); 00449 00450 //collapsed open item 00451 QList<QTreeWidgetItem *> selected; 00452 selected = fHelpTreeWidget->selectedItems(); 00453 if ( selected.count() != 0 ) { 00454 fHelpTreeWidget->collapseItem (selected.at( 0 ) ); 00455 } 00456 00457 // clear old selection 00458 fHelpTreeWidget->clearSelection(); 00459 list.first()->setSelected(true); 00460 00461 // Call the update of the right textArea 00462 helpTreeCallback(); 00463 } 00464 } 00465 fHelpDialog->setWindowTitle("Help on commands"); 00466 fHelpDialog->resize(800,600); 00467 fHelpDialog->move(QPoint(400,150)); 00468 fHelpDialog->show(); 00469 fHelpDialog->raise(); 00470 fHelpDialog->activateWindow(); 00471 } |
Here is the call graph for this function:
|
Definition at line 118 of file G4UIQt.hh. Referenced by commandEnteredCallback(), commandHistoryCallback(), eventFilter(), and G4UIQt(). |
|
Definition at line 121 of file G4UIQt.hh. Referenced by commandEnteredCallback(), commandHistoryCallback(), eventFilter(), and G4UIQt(). |
|
|
|
Definition at line 120 of file G4UIQt.hh. Referenced by helpTreeCallback(), and TerminalHelp(). |
|
Definition at line 124 of file G4UIQt.hh. Referenced by TerminalHelp(). |
|
Definition at line 123 of file G4UIQt.hh. Referenced by helpTreeCallback(), and TerminalHelp(). |
|
Definition at line 116 of file G4UIQt.hh. Referenced by AddMenu(), G4UIQt(), SessionStart(), SessionTerminate(), and ~G4UIQt(). |
|
Definition at line 119 of file G4UIQt.hh. Referenced by clearButtonCallback(), G4UIQt(), ReceiveG4cerr(), and ReceiveG4cout(). |
|
Definition at line 122 of file G4UIQt.hh. Referenced by AddButton(). |