Ignore:
Timestamp:
Jun 25, 2007, 5:30:05 PM (17 years ago)
Author:
garnier
Message:

r655@mac-90108: laurentgarnier | 2007-06-22 15:33:05 +0200
corrections de mises en forme

Location:
trunk/geant4/interfaces/basic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/interfaces/basic/include/G4UIQt.hh

    r524 r526  
    108108  G4bool GetHelpChoice(G4int&) ;// have to be implemeted because we heritate from G4VBasicShell
    109109  void ExitHelp();// have to be implemeted because we heritate from G4VBasicShell
    110   bool eventFilter(QObject*,QEvent*);
     110  bool EventFilter(QObject*,QEvent*);
    111111
    112112private:
     
    122122  QTextEdit *fHelpArea;
    123123  QListWidget *fCommandHistoryArea;
    124   QSignalMapper *signalMapper ;
    125124  QTreeWidget *fHelpTreeWidget;
    126125  QDialog *fHelpDialog;
     
    130129
    131130private 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();
    138137};
    139138
  • trunk/geant4/interfaces/basic/src/G4UIQt.cc

    r525 r526  
    102102  fTextArea = new QTextEdit();
    103103  QPushButton *clearButton = new QPushButton("clear");
    104   connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback()));
     104  connect(clearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
    105105
    106106  fCommandHistoryArea = new QListWidget();
    107107  fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection);
    108   connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(commandHistoryCallback()));
     108  connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
    109109  fCommandHistoryArea->installEventFilter(this);
    110110  fCommandLabel = new QLabel();
     
    113113  fCommandArea->installEventFilter(this);
    114114  fCommandArea->activateWindow();
    115   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback()));
     115  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
    116116  //  fCommandArea->setFocusPolicy ( Qt::StrongFocus );
    117117  //  fCommandArea->setFocus(Qt::TabFocusReason);
     
    148148  // Add a Help menu
    149149  QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help");
    150   helpMenu->addAction("Show Help", this, SLOT(showHelpCallback()));
     150  helpMenu->addAction("Show Help", this, SLOT(ShowHelpCallback()));
    151151
    152152  // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
     
    220220)
    221221{
     222  if (aPrompt == NULL) return;
     223
    222224  fCommandLabel->setText((char*)aPrompt.data());
    223225}
     
    246248)
    247249{
     250  if (aState == NULL) return;
     251
    248252  printf("G4UIQt::PauseSessionStart\n");
    249253  if(aState=="G4_pause> ") {  // TO KEEP
     
    267271)
    268272{
     273  if (aPrompt == NULL) return;
     274
    269275  printf("G4UIQt::SecondaryLoop\n");
    270276  G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
     
    284290   Receive a cout from Geant4. We have to display it in the cout zone
    285291   @param aString : label to add in the display area
     292   @return 0
    286293*/
    287294G4int G4UIQt::ReceiveG4cout (
     
    289296)
    290297{
     298  if (aString == NULL) return 0;
     299
    291300  fTextArea->append(QString((char*)aString.data()).trimmed());
    292301  fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
     
    298307   Receive a cerr from Geant4. We have to display it in the cout zone
    299308   @param aString : label to add in the display area
     309   @return 0
    300310*/
    301311G4int G4UIQt::ReceiveG4cerr (
     
    303313)
    304314{
     315  if (aString == NULL) return 0;
     316
    305317  QColor previousColor = fTextArea->textColor();
    306318  fTextArea->setTextColor(Qt::red);
     
    323335)
    324336{
     337  if (aName == NULL) return;
     338  if (aLabel == NULL) return;
     339
    325340  QMenu *fileMenu = new QMenu(aLabel);
    326341  fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu);
     
    344359  if(aLabel==NULL) return; // TO KEEP
    345360  if(aCommand==NULL) return; // TO KEEP
     361
    346362  QMenu *parent = (QMenu*)GetInteractor(aMenu);
    347363  if(parent==NULL) return;
    348364 
    349   signalMapper = new QSignalMapper(this);
     365  QSignalMapper *signalMapper = new QSignalMapper(this);
    350366  QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map()));
    351367  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&)));
    353369}
    354370
     
    408424    fHelpTreeWidget->insertTopLevelItems(0, items);
    409425
    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())); 
    414427
    415428    // Set layouts
     
    469482
    470483      // Call the update of the right textArea
    471       helpTreeCallback();
     484      HelpTreeCallback();
    472485    }
    473486  }
     
    482495
    483496
    484 /**
    485    Fill the Help Tree Widget
     497/**   Fill the Help Tree Widget
    486498   @param aParent : parent item to fill
    487499   @param aCommandTree : commandTree node associate with this part of the Tree
     
    492504)
    493505{
     506  if (aParent == NULL) return;
     507  if (aCommandTree == NULL) return;
     508
    494509
    495510  // Creating new item
     
    498513  // Get the Sub directories
    499514  for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
    500    
     515
    501516    QStringList stringList;
    502517    stringList << QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed()  ;
     
    525540
    526541
    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
    528545*/
    529546QTreeWidgetItem* G4UIQt::FindTreeItem(
     
    532549)
    533550{
     551  if (aParent == NULL) return NULL;
     552  if (aCommand == NULL) return NULL;
     553
    534554  if (aParent->text(0) == aCommand)
    535555    return aParent;
     
    549569   @param aCommand : command to list parameters
    550570   @see G4UIparameter::List()
    551    @return the command list parameters
     571   @see G4UIcommand::List()
     572   @return the command list parameters, or "" if nothing
    552573*/
    553574QString G4UIQt::GetCommandList (
     
    556577{
    557578
    558   QString txt;
     579  QString txt ="";
     580  if (aCommand == NULL)
     581    return txt;
     582
    559583  G4String commandPath = aCommand->GetCommandPath();
    560584  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      }
    565633    }
    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  }
    600635  return txt;
    601636}
     
    633668   @param event Kind of event
    634669*/
    635 bool G4UIQt::eventFilter(
    636                          QObject *obj
    637                          ,QEvent *event
    638                          )
    639 {
    640   if (obj == fCommandHistoryArea) {
    641     if (event->type() == QEvent::KeyPress) {
     670bool 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) {
    642680      fCommandArea->setFocus();
    643681    }
    644682  }
    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);
    648686      if ((e->key() == (Qt::Key_Down)) ||
    649687          (e->key() == (Qt::Key_PageDown)) ||
     
    677715  }
    678716  // pass the event on to the parent class
    679   return QObject::eventFilter(obj, event);
     717  return QObject::eventFilter(aObj, aEvent);
    680718}
    681719
     
    692730   Called when user give "help" command.
    693731*/
    694 void G4UIQt::showHelpCallback (
     732void G4UIQt::ShowHelpCallback (
    695733)
    696734{
     
    702740   Called when user click on clear button. Clear the text Output area
    703741*/
    704 void G4UIQt::clearButtonCallback (
     742void G4UIQt::ClearButtonCallback (
    705743)
    706744{
     
    713751   Send the associated command to geant4
    714752*/
    715 void G4UIQt::commandEnteredCallback (
     753void G4UIQt::CommandEnteredCallback (
    716754)
    717755{
     
    740778   @param aCommand
    741779*/
    742 void G4UIQt::buttonCallback (
     780void G4UIQt::ButtonCallback (
    743781 const QString& aCommand
    744782)
    745783{
     784  if (aCommand == NULL) return;
     785
    746786  G4String ss = G4String(aCommand.toStdString().c_str());
    747787  printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause);
     
    756796   This callback is activated when user selected a item in the help tree
    757797*/
    758 void G4UIQt::helpTreeCallback (
    759 )
    760 {
    761   //  G4bool GetHelpChoice(G4int&);
     798void G4UIQt::HelpTreeCallback (
     799)
     800{
    762801  QTreeWidgetItem* item =  NULL;
    763802  if (!fHelpTreeWidget)
     
    792831   Give it to the command area.
    793832*/
    794 void G4UIQt::commandHistoryCallback(
     833void G4UIQt::CommandHistoryCallback(
    795834)
    796835{
  • trunk/geant4/interfaces/basic/src/G4UIQt_moc.cc

    r519 r526  
    22** Meta object code from reading C++ file 'G4UIQt.hh'
    33**
    4 ** Created: Wed Jun 20 18:07:19 2007
     4** Created: Fri Jun 22 15:30:23 2007
    55**      by: The Qt Meta Object Compiler version 59 (Qt 4.2.2)
    66**
     
    4343static const char qt_meta_stringdata_G4UIQt[] = {
    4444    "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"
    4848};
    4949
     
    7878        switch (_id) {
    7979        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;
    8686        }
    8787        _id -= 7;
Note: See TracChangeset for help on using the changeset viewer.