- Timestamp:
- Jun 25, 2007, 5:30:05 PM (17 years ago)
- Location:
- trunk/geant4/interfaces/basic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/interfaces/basic/include/G4UIQt.hh
r524 r526 108 108 G4bool GetHelpChoice(G4int&) ;// have to be implemeted because we heritate from G4VBasicShell 109 109 void ExitHelp();// have to be implemeted because we heritate from G4VBasicShell 110 bool eventFilter(QObject*,QEvent*);110 bool EventFilter(QObject*,QEvent*); 111 111 112 112 private: … … 122 122 QTextEdit *fHelpArea; 123 123 QListWidget *fCommandHistoryArea; 124 QSignalMapper *signalMapper ;125 124 QTreeWidget *fHelpTreeWidget; 126 125 QDialog *fHelpDialog; … … 130 129 131 130 private slots : 132 void clearButtonCallback();133 void commandEnteredCallback();134 void buttonCallback(const QString&);135 void helpTreeCallback();136 void showHelpCallback();137 void commandHistoryCallback();131 void ClearButtonCallback(); 132 void CommandEnteredCallback(); 133 void ButtonCallback(const QString&); 134 void HelpTreeCallback(); 135 void ShowHelpCallback(); 136 void CommandHistoryCallback(); 138 137 }; 139 138 -
trunk/geant4/interfaces/basic/src/G4UIQt.cc
r525 r526 102 102 fTextArea = new QTextEdit(); 103 103 QPushButton *clearButton = new QPushButton("clear"); 104 connect(clearButton, SIGNAL(clicked()), SLOT( clearButtonCallback()));104 connect(clearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback())); 105 105 106 106 fCommandHistoryArea = new QListWidget(); 107 107 fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection); 108 connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT( commandHistoryCallback()));108 connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback())); 109 109 fCommandHistoryArea->installEventFilter(this); 110 110 fCommandLabel = new QLabel(); … … 113 113 fCommandArea->installEventFilter(this); 114 114 fCommandArea->activateWindow(); 115 connect(fCommandArea, SIGNAL(returnPressed()), SLOT( commandEnteredCallback()));115 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback())); 116 116 // fCommandArea->setFocusPolicy ( Qt::StrongFocus ); 117 117 // fCommandArea->setFocus(Qt::TabFocusReason); … … 148 148 // Add a Help menu 149 149 QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help"); 150 helpMenu->addAction("Show Help", this, SLOT( showHelpCallback()));150 helpMenu->addAction("Show Help", this, SLOT(ShowHelpCallback())); 151 151 152 152 // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow … … 220 220 ) 221 221 { 222 if (aPrompt == NULL) return; 223 222 224 fCommandLabel->setText((char*)aPrompt.data()); 223 225 } … … 246 248 ) 247 249 { 250 if (aState == NULL) return; 251 248 252 printf("G4UIQt::PauseSessionStart\n"); 249 253 if(aState=="G4_pause> ") { // TO KEEP … … 267 271 ) 268 272 { 273 if (aPrompt == NULL) return; 274 269 275 printf("G4UIQt::SecondaryLoop\n"); 270 276 G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? … … 284 290 Receive a cout from Geant4. We have to display it in the cout zone 285 291 @param aString : label to add in the display area 292 @return 0 286 293 */ 287 294 G4int G4UIQt::ReceiveG4cout ( … … 289 296 ) 290 297 { 298 if (aString == NULL) return 0; 299 291 300 fTextArea->append(QString((char*)aString.data()).trimmed()); 292 301 fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum()); … … 298 307 Receive a cerr from Geant4. We have to display it in the cout zone 299 308 @param aString : label to add in the display area 309 @return 0 300 310 */ 301 311 G4int G4UIQt::ReceiveG4cerr ( … … 303 313 ) 304 314 { 315 if (aString == NULL) return 0; 316 305 317 QColor previousColor = fTextArea->textColor(); 306 318 fTextArea->setTextColor(Qt::red); … … 323 335 ) 324 336 { 337 if (aName == NULL) return; 338 if (aLabel == NULL) return; 339 325 340 QMenu *fileMenu = new QMenu(aLabel); 326 341 fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu); … … 344 359 if(aLabel==NULL) return; // TO KEEP 345 360 if(aCommand==NULL) return; // TO KEEP 361 346 362 QMenu *parent = (QMenu*)GetInteractor(aMenu); 347 363 if(parent==NULL) return; 348 364 349 signalMapper = new QSignalMapper(this);365 QSignalMapper *signalMapper = new QSignalMapper(this); 350 366 QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map())); 351 367 signalMapper->setMapping(action, QString(aCommand)); 352 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT( buttonCallback(const QString&)));368 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&))); 353 369 } 354 370 … … 408 424 fHelpTreeWidget->insertTopLevelItems(0, items); 409 425 410 //connecting callback 411 // QSignalMapper signalMapper = new QSignalMapper(this); 412 413 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(helpTreeCallback())); 426 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeCallback())); 414 427 415 428 // Set layouts … … 469 482 470 483 // Call the update of the right textArea 471 helpTreeCallback();484 HelpTreeCallback(); 472 485 } 473 486 } … … 482 495 483 496 484 /** 485 Fill the Help Tree Widget 497 /** Fill the Help Tree Widget 486 498 @param aParent : parent item to fill 487 499 @param aCommandTree : commandTree node associate with this part of the Tree … … 492 504 ) 493 505 { 506 if (aParent == NULL) return; 507 if (aCommandTree == NULL) return; 508 494 509 495 510 // Creating new item … … 498 513 // Get the Sub directories 499 514 for (int a=0;a<aCommandTree->GetTreeEntry();a++) { 500 515 501 516 QStringList stringList; 502 517 stringList << QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed() ; … … 525 540 526 541 527 /** 542 /** Find a treeItemWidget in the help tree 543 @param aCommand item's String to look for 544 @return item if found, NULL if not 528 545 */ 529 546 QTreeWidgetItem* G4UIQt::FindTreeItem( … … 532 549 ) 533 550 { 551 if (aParent == NULL) return NULL; 552 if (aCommand == NULL) return NULL; 553 534 554 if (aParent->text(0) == aCommand) 535 555 return aParent; … … 549 569 @param aCommand : command to list parameters 550 570 @see G4UIparameter::List() 551 @return the command list parameters 571 @see G4UIcommand::List() 572 @return the command list parameters, or "" if nothing 552 573 */ 553 574 QString G4UIQt::GetCommandList ( … … 556 577 { 557 578 558 QString txt; 579 QString txt =""; 580 if (aCommand == NULL) 581 return txt; 582 559 583 G4String commandPath = aCommand->GetCommandPath(); 560 584 G4String rangeString = aCommand->GetRange(); 561 562 if((commandPath.length()-1)!='/') 563 { 564 txt += "Command " + QString((char*)(commandPath).data()) + "\n"; 585 G4int n_guidanceEntry = aCommand->GetGuidanceEntries(); 586 G4int n_parameterEntry = aCommand->GetParameterEntries(); 587 588 if ((commandPath == "") && 589 (rangeString == "") && 590 (n_guidanceEntry == 0) && 591 (n_parameterEntry == 0)) { 592 return txt; 593 } 594 595 if((commandPath.length()-1)!='/') { 596 txt += "Command " + QString((char*)(commandPath).data()) + "\n"; 597 } 598 txt += "Guidance :\n"; 599 600 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) { 601 txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n"; 602 } 603 if( ! rangeString.isNull() ) { 604 txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n"; 605 } 606 if( n_parameterEntry > 0 ) { 607 G4UIparameter *param; 608 609 // Re-implementation of G4UIparameter.cc 610 611 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) { 612 param = aCommand->GetParameter(i_thParameter); 613 txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n"; 614 if( ! param->GetParameterGuidance().isNull() ) 615 txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ; 616 txt += " Parameter type : " + QString(param->GetParameterType())+ "\n"; 617 if(param->IsOmittable()){ 618 txt += " Omittable : True\n"; 619 } else { 620 txt += " Omittable : False\n"; 621 } 622 if( param->GetCurrentAsDefault() ) { 623 txt += " Default value : taken from the current value\n"; 624 } else if( ! param->GetDefaultValue().isNull() ) { 625 txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n"; 626 } 627 if( ! param->GetParameterRange().isNull() ) { 628 txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n"; 629 } 630 if( ! param->GetParameterCandidates().isNull() ) { 631 txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n"; 632 } 565 633 } 566 txt += "Guidance :\n"; 567 G4int n_guidanceEntry = aCommand->GetGuidanceEntries(); 568 569 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) 570 { txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n"; } 571 if( ! rangeString.isNull() ) 572 { txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n"; } 573 G4int n_parameterEntry = aCommand->GetParameterEntries(); 574 if( n_parameterEntry > 0 ) 575 { 576 G4UIparameter *param; 577 578 // Re-implementation of G4UIparameter.cc 579 580 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) 581 { param = aCommand->GetParameter(i_thParameter); 582 txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n"; 583 if( ! param->GetParameterGuidance().isNull() ) 584 txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ; 585 txt += " Parameter type : " + QString(param->GetParameterType())+ "\n"; 586 if(param->IsOmittable()) 587 { txt += " Omittable : True\n"; } 588 else 589 { txt += " Omittable : False\n"; } 590 if( param->GetCurrentAsDefault() ) 591 { txt += " Default value : taken from the current value\n"; } 592 else if( ! param->GetDefaultValue().isNull() ) 593 { txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n"; } 594 if( ! param->GetParameterRange().isNull() ) 595 txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n"; 596 if( ! param->GetParameterCandidates().isNull() ) 597 txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n"; 598 } 599 } 634 } 600 635 return txt; 601 636 } … … 633 668 @param event Kind of event 634 669 */ 635 bool G4UIQt::eventFilter( 636 QObject *obj 637 ,QEvent *event 638 ) 639 { 640 if (obj == fCommandHistoryArea) { 641 if (event->type() == QEvent::KeyPress) { 670 bool G4UIQt::EventFilter( 671 QObject *aObj 672 ,QEvent *aEvent 673 ) 674 { 675 if (aObj == NULL) return false; 676 if (aEvent == NULL) return false; 677 678 if (aObj == fCommandHistoryArea) { 679 if (aEvent->type() == QEvent::KeyPress) { 642 680 fCommandArea->setFocus(); 643 681 } 644 682 } 645 if ( obj == fCommandArea) {646 if ( event->type() == QEvent::KeyPress) {647 QKeyEvent *e = static_cast<QKeyEvent*>( event);683 if (aObj == fCommandArea) { 684 if (aEvent->type() == QEvent::KeyPress) { 685 QKeyEvent *e = static_cast<QKeyEvent*>(aEvent); 648 686 if ((e->key() == (Qt::Key_Down)) || 649 687 (e->key() == (Qt::Key_PageDown)) || … … 677 715 } 678 716 // pass the event on to the parent class 679 return QObject::eventFilter( obj, event);717 return QObject::eventFilter(aObj, aEvent); 680 718 } 681 719 … … 692 730 Called when user give "help" command. 693 731 */ 694 void G4UIQt:: showHelpCallback (732 void G4UIQt::ShowHelpCallback ( 695 733 ) 696 734 { … … 702 740 Called when user click on clear button. Clear the text Output area 703 741 */ 704 void G4UIQt:: clearButtonCallback (742 void G4UIQt::ClearButtonCallback ( 705 743 ) 706 744 { … … 713 751 Send the associated command to geant4 714 752 */ 715 void G4UIQt:: commandEnteredCallback (753 void G4UIQt::CommandEnteredCallback ( 716 754 ) 717 755 { … … 740 778 @param aCommand 741 779 */ 742 void G4UIQt:: buttonCallback (780 void G4UIQt::ButtonCallback ( 743 781 const QString& aCommand 744 782 ) 745 783 { 784 if (aCommand == NULL) return; 785 746 786 G4String ss = G4String(aCommand.toStdString().c_str()); 747 787 printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause); … … 756 796 This callback is activated when user selected a item in the help tree 757 797 */ 758 void G4UIQt::helpTreeCallback ( 759 ) 760 { 761 // G4bool GetHelpChoice(G4int&); 798 void G4UIQt::HelpTreeCallback ( 799 ) 800 { 762 801 QTreeWidgetItem* item = NULL; 763 802 if (!fHelpTreeWidget) … … 792 831 Give it to the command area. 793 832 */ 794 void G4UIQt:: commandHistoryCallback(833 void G4UIQt::CommandHistoryCallback( 795 834 ) 796 835 { -
trunk/geant4/interfaces/basic/src/G4UIQt_moc.cc
r519 r526 2 2 ** Meta object code from reading C++ file 'G4UIQt.hh' 3 3 ** 4 ** Created: Wed Jun 20 18:07:1920074 ** Created: Fri Jun 22 15:30:23 2007 5 5 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.2) 6 6 ** … … 43 43 static const char qt_meta_stringdata_G4UIQt[] = { 44 44 "G4UIQt\0myClicked(QString)\0text\0\0" 45 " clearButtonCallback()\0commandEnteredCallback()\0"46 " buttonCallback(QString)\0helpTreeCallback()\0"47 " showHelpCallback()\0commandHistoryCallback()\0"45 "ClearButtonCallback()\0CommandEnteredCallback()\0" 46 "ButtonCallback(QString)\0HelpTreeCallback()\0" 47 "ShowHelpCallback()\0CommandHistoryCallback()\0" 48 48 }; 49 49 … … 78 78 switch (_id) { 79 79 case 0: myClicked((*reinterpret_cast< const QString(*)>(_a[1]))); break; 80 case 1: clearButtonCallback(); break;81 case 2: commandEnteredCallback(); break;82 case 3: buttonCallback((*reinterpret_cast< const QString(*)>(_a[1]))); break;83 case 4: helpTreeCallback(); break;84 case 5: showHelpCallback(); break;85 case 6: commandHistoryCallback(); break;80 case 1: ClearButtonCallback(); break; 81 case 2: CommandEnteredCallback(); break; 82 case 3: ButtonCallback((*reinterpret_cast< const QString(*)>(_a[1]))); break; 83 case 4: HelpTreeCallback(); break; 84 case 5: ShowHelpCallback(); break; 85 case 6: CommandHistoryCallback(); break; 86 86 } 87 87 _id -= 7;
Note: See TracChangeset
for help on using the changeset viewer.