Changeset 496 for trunk/geant4


Ignore:
Timestamp:
Jun 8, 2007, 4:43:51 PM (17 years ago)
Author:
garnier
Message:

r589@mac-90108: laurentgarnier | 2007-06-08 15:41:35 +0200
probleme avec les layout, revenons a qq chose de simple

Location:
trunk/geant4/interfaces
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/interfaces/basic/src/G4UIQt.cc

    r495 r496  
    5656#include <QtGui/qlabel.h>
    5757#include <QtGui/qsplitter.h>
     58#include <QtGui/qlistview.h> // en test
     59#include <QtGui/qtreeview.h> // en test
    5860
    5961#include <stdlib.h>
     
    9395/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    9496{
     97  G4Qt* interactorManager = G4Qt::getInstance ();
    9598  G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
    9699  if(UI!=NULL) UI->SetSession(this); // TO KEEP
    97100
    98   G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");  // TO KEEP ?
    99 
    100101  fMainWindow = new QMainWindow();
    101102  fMainWindow->setWindowTitle( "G4UI Session" );
    102   fMainWindow->resize(600,400);
     103
    103104  QWidget* central = new QWidget();
    104   QWidget* topWidget = new QWidget();
    105   QWidget* bottomWidget = new QWidget();
    106   QVBoxLayout* vBox1 = new QVBoxLayout();
    107   QVBoxLayout* vBox2 = new QVBoxLayout();
    108 
    109   QSplitter *splitter = new QSplitter(Qt::Vertical, central);
    110   fTextArea = new QTextEdit();
    111   fCommandHistoryArea = new QTextEdit();
    112   fCommandLabel = new QLabel();
    113 
     105
     106  /*
     107    QSplitter *splitter = new QSplitter(Qt::Vertical,central);
     108    splitter->setMaximumSize(800,800);
     109    QListView *listview = new QListView;
     110    listview->setMaximumSize(800,800);
     111    QTreeView *treeview = new QTreeView;
     112    treeview->setMaximumSize(800,800);
     113  */
     114  QTextEdit *textedit = new QTextEdit;
     115  //  textedit->setMaximumSize(800,800);
    114116  QPushButton *clearButton = new QPushButton("clear");
    115   connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback()));
    116 
    117   fTextArea->setReadOnly(true);
    118   fCommandHistoryArea->setReadOnly(true);
    119 
    120 //  QMenu *menuFile = new QMenu("File");
    121 //  fMainWindow->menuBar()->addMenu(menuFile);
    122 
    123   fCommandArea = new QLineEdit();
    124   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback()));
    125 
    126   vBox1->addWidget(fTextArea);
    127   vBox1->addWidget(clearButton);
    128 
    129   vBox2->addWidget(fCommandHistoryArea);
    130   vBox2->addWidget(fCommandLabel);
    131   vBox2->addWidget(fCommandArea);
    132 
    133   topWidget->setLayout(vBox1);
    134   bottomWidget->setLayout(vBox2);
    135 
    136   splitter->addWidget(topWidget);
    137   splitter->addWidget(bottomWidget);
    138 
     117 
     118  QVBoxLayout *layout = new QVBoxLayout;
     119  layout->addWidget(textedit);
     120  layout->addWidget(clearButton);
     121  central->setLayout(layout);
     122  /*
     123    QSizePolicy *test = new QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
     124    if (splitter->sizePolicy().horizontalPolicy () == test->horizontalPolicy () ) {
     125    printf ("splitter H is fixed\n");
     126    }
     127   
     128    printf("list SP H: %d\n",listview->sizePolicy().horizontalPolicy ());
     129    printf("list SP V: %d\n",listview->sizePolicy().verticalPolicy ());
     130    printf("tree SP H: %d\n",treeview->sizePolicy().horizontalPolicy ());
     131    printf("tree SP V: %d\n",treeview->sizePolicy().verticalPolicy ());
     132    printf("text SP H: %d\n",textedit->sizePolicy().horizontalPolicy ());
     133    printf("text SP V: %d\n",textedit->sizePolicy().verticalPolicy ());
     134   
     135    splitter->addWidget(listview);
     136    splitter->addWidget(treeview);
     137    splitter->addWidget(textedit);
     138  */
    139139  fMainWindow->setCentralWidget(central);
     140
     141  //////////////
     142//  fMainWindow->resize(600,400);
     143//   QWidget* central = new QWidget();
     144//   QWidget* topWidget = new QWidget();
     145//   QWidget* bottomWidget = new QWidget();
     146//   QVBoxLayout* vBox1 = new QVBoxLayout(topWidget);
     147//   QVBoxLayout* vBox2 = new QVBoxLayout(bottomWidget);
     148
     149//   QSplitter *splitter = new QSplitter(Qt::Vertical);
     150//   fTextArea = new QTextEdit();
     151//   fCommandHistoryArea = new QTextEdit();
     152//   fCommandLabel = new QLabel();
     153
     154//   QPushButton *clearButton = new QPushButton("clear");
     155//   connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback()));
     156
     157//   fTextArea->setReadOnly(true);
     158//   fCommandHistoryArea->setReadOnly(true);
     159
     160// //  QMenu *menuFile = new QMenu("File");
     161// //  fMainWindow->menuBar()->addMenu(menuFile);
     162
     163//   fCommandArea = new QLineEdit();
     164//   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback()));
     165
     166//   vBox1->addWidget(fTextArea);
     167//   vBox1->addWidget(clearButton);
     168//   vBox1->setStretchFactor(fTextArea,1);
     169
     170//   vBox2->addWidget(fCommandHistoryArea);
     171//   vBox2->addWidget(fCommandLabel);
     172//   vBox2->addWidget(fCommandArea);
     173//   vBox2->setStretchFactor(fCommandHistoryArea,1);
     174
     175//   splitter->addWidget(topWidget);
     176//   splitter->addWidget(bottomWidget);
     177
     178//   fMainWindow->setCentralWidget(central);
     179////////////////
    140180
    141181//  QMainWindow top = (QMainWindow)interactorManager->GetMainInteractor();
     
    238278{
    239279
     280  G4Qt* interactorManager = G4Qt::getInstance ();
    240281  fMainWindow->show();
    241282  Prompt("session");
    242283  exitSession = false;
    243   qApp->exec();
    244 
    245 //   interactorManager->DisableSecondaryLoop (); // TO KEEP
     284
     285
     286  printf("disable secondary loop\n");
     287  interactorManager->DisableSecondaryLoop (); // TO KEEP
     288  ((QApplication*)interactorManager->GetMainInteractor())->exec();
     289  // on ne passe pas le dessous ? FIXME ????
     290
     291
     292
     293
     294
     295
    246296//   void* event; // TO KEEP
    247297//   while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
     
    249299//     if(exitSession==true) break; // TO KEEP
    250300//   } // TO KEEP
    251 //   interactorManager->EnableSecondaryLoop (); // TO KEEP
     301   interactorManager->EnableSecondaryLoop (); // TO KEEP
     302  printf("enable secondary loop\n");
    252303  return this; // TO KEEP
    253304}
     
    263314/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    264315{
    265   fCommandLabel->setText((char*)aPrompt.data());
     316  //  fCommandLabel->setText((char*)aPrompt.data());
    266317}
    267318/***************************************************************************/
     
    315366/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    316367{
    317   fTextArea->append((char*)a_string.data());
     368  //  fTextArea->append((char*)a_string.data());
    318369  return 0;
    319370}
     
    328379/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    329380{
    330   fTextArea->append((char*)a_string.data());
     381  //  fTextArea->append((char*)a_string.data());
    331382  return 0;
    332383}
     
    430481/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    431482{
    432   fCommandHistoryArea->append(fCommandArea->text());
     483  /*  fCommandHistoryArea->append(fCommandArea->text());
    433484   G4String command (fCommandArea->text().toStdString().c_str());
    434485   if(fHelp==true) {
     
    439490   }
    440491   fCommandArea->setText("");
     492  */
    441493}
    442494// /***************************************************************************/
     
    467519/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    468520{
    469   fTextArea->clear();
     521  //  fTextArea->clear();
    470522}
    471523
  • trunk/geant4/interfaces/common/src/G4Qt.cc

    r484 r496  
    5252//static char** args      = NULL;
    5353// static QtAppContext appContext = NULL;
    54 static QMainWindow *mainWidget = NULL;
     54//static QApplication app = NULL;
    5555
    5656/***************************************************************************/
     
    8888
    8989    new QApplication (a_argn, a_args);
    90     mainWidget = new QMainWindow();
    9190
    92     if(mainWidget==NULL) {
     91    if(qApp==NULL) {
    9392      G4cout        << "G4Qt : Unable to init Qt." << G4endl;
    9493    }
    9594    QtInited  = TRUE;
    96     mainWidget->show();
    97     qApp->exec();
     95    SetMainInteractor (qApp);
    9896  }
    99 //  AddDispatcher     ((G4DispatchFunction)QtDispatchEvent); // FIXME
     97  SetArguments      (a_argn,a_args);
     98  //  AddDispatcher     ((G4DispatchFunction)XtDispatchEvent);
    10099}
    101100/***************************************************************************/
     
    118117}
    119118/***************************************************************************/
     119/**
     120  Si j'ai bien compris, cette fonction ne sert à rien
     121 */
    120122void* G4Qt::GetEvent (
    121123)
     
    124126{
    125127//FIXME
    126    G4cout        << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
     128//   G4cout        << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
    127129//  static XEvent  event;
    128130//  if(appContext==NULL) return NULL;
     
    130132//  QtAppNextEvent (appContext, &event);
    131133//  return         &event;
     134  printf(" Si j'ai bien compris, cette fonction ne sert à rien");
    132135}
    133136/***************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.