Changeset 484 for trunk


Ignore:
Timestamp:
Jun 5, 2007, 4:09:01 PM (17 years ago)
Author:
garnier
Message:

r573@mac-90108: laurentgarnier | 2007-06-05 16:12:24 +0200
remise a jour

Location:
trunk/geant4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/N03/exampleN03.cc

    r483 r484  
    2525//
    2626//
    27 // $Id: exampleN03.cc,v 1.30 2006/10/26 14:58:24 allison Exp $
    28 // GEANT4 tag $Name: geant4-08-02-patch-01-ref $
     27// $Id: exampleN03.cc,v 1.28 2006/06/29 17:48:30 gunter Exp $
     28// GEANT4 tag $Name: geant4-08-01 $
    2929//
    3030//
     
    3939#ifdef G4UI_USE_XM
    4040#include "G4UIXm.hh"
     41#endif
     42
     43#ifdef G4UI_USE_QT
     44#include "G4UIQt.hh"
    4145#endif
    4246
     
    9498#elif defined(G4UI_USE_WIN32)
    9599      session = new G4UIWin32();
     100#elif defined(G4UI_USE_QT)
     101      session = new G4UIQt(argc,argv);
    96102#elif defined(G4UI_USE_TCSH)
    97103      session = new G4UIterminal(new G4UItcsh);     
     
    136142      //
    137143      UI->ApplyCommand("/control/execute vis.mac");   
    138 #if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32)
     144#if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32) || defined(G4UI_USE_QT)
    139145      // Customize the G4UIXm,Win32 menubar with a macro file
    140146      //
  • trunk/geant4/interfaces/basic/src/G4UIQt.cc

    r481 r484  
     1// TODO !
     2
    13//
    24// ********************************************************************
     
    2527//
    2628//
    27 // $Id: G4UIQt.cc,v 1.14 2006/06/29 19:09:49 gunter Exp $
     29// $Id: G4UIQt.cc,v 1.14 2007/05/29 11:09:49 $
    2830// GEANT4 tag $Name: geant4-08-01 $
    2931//
    30 // G.Barrand
     32// L. Garnier
    3133
    3234//#define DEBUG
     
    7274      | |> promt area       | |
    7375      | +-------------------+ |
     76      +-----------------------+
    7477*/
    7578
     
    7881 char** argv
    7982)
    80 :shell(NULL)
    81 /***************************************************************************/
    82 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    83 {
    84   G4UImanager* UI = G4UImanager::GetUIpointer(); # TO KEEP
    85   if(UI!=NULL) UI->SetSession(this); # TO KEEP
    86 
    87   new QApplication (argc, argv);
    88 
    89   mainWindow = new QMainWindow(0,qApp->applicationDirPath () );
    90 
    91 //  G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");  # TO KEEP ?
    92 
    93 //   Widget top = (Widget)interactorManager->GetMainInteractor();
     83/***************************************************************************/
     84/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
     85{
     86  G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
     87  if(UI!=NULL) UI->SetSession(this); // TO KEEP
     88
     89  G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");  // TO KEEP ?
     90
     91  mainWindow = new QMainWindow();
     92
     93
     94//  QMainWindow top = (QMainWindow)interactorManager->GetMainInteractor();
    9495
    9596//   if(getenv("XENVIRONMENT")==NULL) {
     
    148149//   XtSetArg(args[7],XmNrows            ,12);
    149150//   XtSetArg(args[8],XmNcolumns         ,80);
    150 //   text = XmCreateScrolledText (form,(char*)"text",args,9);
     151//   text = XmCreateSGcrolledText (form,(char*)"text",args,9);
    151152//   XtManageChild (text);
    152153
     
    162163//   XtMapWidget(shell);
    163164
    164   if(UI!=NULL) UI->SetCoutDestination(this);  # TO KEEP
     165  if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
    165166}
    166167/***************************************************************************/
     
    170171/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    171172{
    172   G4UImanager* UI = G4UImanager::GetUIpointer();  # TO KEEP
    173   if(UI!=NULL) {  # TO KEEP
    174     UI->SetSession(NULL);  # TO KEEP
    175     UI->SetCoutDestination(NULL);  # TO KEEP
     173  G4UImanager* UI = G4UImanager::GetUIpointer();  // TO KEEP
     174  if(UI!=NULL) {  // TO KEEP
     175    UI->SetSession(NULL);  // TO KEEP
     176    UI->SetCoutDestination(NULL);  // TO KEEP
    176177  }
    177   XtDestroyWidget(shell);
     178
     179 
     180  if (mainWindow!=NULL)
     181    delete mainWindow;
    178182}
    179183/***************************************************************************/
     
    186190/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    187191{
    188   frame->show();
     192
     193  mainWindow->show();
    189194  qApp->exec();
    190195
    191 //   G4Qt* interactorManager = G4Qt::getInstance (); # TO KEEP ?
    192 //   Prompt("session"); # TO KEEP
    193 //   exitSession = false; # TO KEEP
    194 //   interactorManager->DisableSecondaryLoop (); # TO KEEP
    195 //   void* event; # TO KEEP
    196 //   while((event = interactorManager->GetEvent())!=NULL) {  # TO KEEP
    197 //     interactorManager->DispatchEvent(event); # TO KEEP
    198 //     if(exitSession==true) break; # TO KEEP
    199 //   } # TO KEEP
    200 //   interactorManager->EnableSecondaryLoop (); # TO KEEP
    201   return this; # TO KEEP
     196//   Prompt("session"); // TO KEEP
     197//   exitSession = false; // TO KEEP
     198//   interactorManager->DisableSecondaryLoop (); // TO KEEP
     199//   void* event; // TO KEEP
     200//   while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
     201//     interactorManager->DispatchEvent(event); // TO KEEP
     202//     if(exitSession==true) break; // TO KEEP
     203//   } // TO KEEP
     204//   interactorManager->EnableSecondaryLoop (); // TO KEEP
     205  return this; // TO KEEP
    202206}
    203207/***************************************************************************/
     
    211215/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    212216{
    213   Arg args[1];
    214   char* str = (char*)XtNewString(aPrompt.data());
    215   XmString cps = XmStringLtoRCreate(str,XmSTRING_DEFAULT_CHARSET);
    216   XtFree(str);
    217   XtSetArg(args[0],XmNpromptString,cps);
    218   XtSetValues(command,args,1);
    219   XmStringFree(cps);
     217// TODO !
     218//  Arg args[1];
     219//  char* str = (char*)XtNewString(aPrompt.data());
     220//  XmString cps = XmStringLtoRCreate(str,XmSTRING_DEFAULT_CHARSET);
     221//  XtFree(str);
     222//  XtSetArg(args[0],XmNpromptString,cps);
     223//  XtSetValues(command,args,1);
     224//  XmStringFree(cps);
    220225}
    221226/***************************************************************************/
     
    233238/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    234239{
    235   if(a_state=="G4_pause> ") {  # TO KEEP
    236     SecondaryLoop ("Pause, type continue to exit this state"); # TO KEEP
    237   } # TO KEEP
    238 
    239   if(a_state=="EndOfEvent") { # TO KEEP
     240  if(a_state=="G4_pause> ") {  // TO KEEP
     241    SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
     242  } // TO KEEP
     243
     244  if(a_state=="EndOfEvent") { // TO KEEP
    240245    // Picking with feed back in event data Done here !!!
    241     SecondaryLoop ("End of event, type continue to exit this state"); # TO KEEP
    242   } # TO KEEP
    243 }
    244 /***************************************************************************/
    245 void G4UIXm::SecondaryLoop (
     246    SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
     247  } // TO KEEP
     248}
     249/***************************************************************************/
     250void G4UIQt::SecondaryLoop (
    246251 G4String a_prompt
    247252)
     
    249254/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    250255{
    251   G4Qt* interactorManager = G4Qt::getInstance (); # TO KEEP ?
    252   Prompt(a_prompt); # TO KEEP
    253   exitPause = false; # TO KEEP
    254   void* event; # TO KEEP
    255   while((event = interactorManager->GetEvent())!=NULL) {  # TO KEEP
    256     interactorManager->DispatchEvent(event); # TO KEEP
    257     if(exitPause==true) break; # TO KEEP
    258   } # TO KEEP
    259   Prompt("session"); # TO KEEP
     256  G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
     257  Prompt(a_prompt); // TO KEEP
     258  exitPause = false; // TO KEEP
     259  void* event; // TO KEEP
     260  while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
     261    interactorManager->DispatchEvent(event); // TO KEEP
     262    if(exitPause==true) break; // TO KEEP
     263  } // TO KEEP
     264  Prompt("session"); // TO KEEP
    260265}
    261266/***************************************************************************/
     
    263268  Receive a cout from Geant4. We have to display it in the cout zone
    264269 */
    265 G4int G4UIXm::ReceiveG4cout (
     270G4int G4UIQt::ReceiveG4cout (
    266271 G4String a_string
    267272)
     
    269274/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    270275{
    271   XmTextAppendString(text,(char*)a_string.data());
    272   return 0;
     276// TODO !
     277//  XmTextAppendString(text,(char*)a_string.data());
     278//  return 0;
    273279}
    274280/***************************************************************************/
     
    276282  Receive a cerr from Geant4. We have to display it in the cout zone
    277283 */
    278 G4int G4UIXm::ReceiveG4cerr (
     284G4int G4UIQt::ReceiveG4cerr (
    279285 G4String a_string
    280286)
     
    282288/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    283289{
    284   XmTextAppendString(text,(char*)a_string.data());
    285   return 0;
    286 }
    287 /***************************************************************************/
    288 G4bool G4UIXm::GetHelpChoice(
     290// TODO !
     291//  XmTextAppendString(text,(char*)a_string.data());
     292//  return 0;
     293}
     294/***************************************************************************/
     295G4bool G4UIQt::GetHelpChoice(
    289296 G4int& aInt
    290297)
     
    292299/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    293300{
    294 //   fHelp = true; # TO KEEP
    295 //   // SecondaryLoop : # TO KEEP
    296 //   G4Qt* interactorManager = G4Qt::getInstance (); # TO KEEP ?
    297 //   Prompt("Help"); # TO KEEP
    298 //   exitHelp = false; # TO KEEP
    299 //   void* event; # TO KEEP
    300 //   while((event = interactorManager->GetEvent())!=NULL) {  # TO KEEP
    301 //     interactorManager->DispatchEvent(event); # TO KEEP
    302 //     if(exitHelp==true) break; # TO KEEP
    303 //   } # TO KEEP
    304 //   Prompt("session"); # TO KEEP
    305 //   // # TO KEEP
    306 //   if(fHelp==false) return false; # TO KEEP
    307 //   aInt = fHelpChoice; # TO KEEP
    308 //   fHelp = false; # TO KEEP
    309 //   return true; # TO KEEP
    310 }
    311 /***************************************************************************/
    312 void G4UIXm::ExitHelp(
    313 )
    314 /***************************************************************************/
    315 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    316 {
    317 }
    318 /***************************************************************************/
    319 void G4UIXm::AddMenu (
     301//   fHelp = true; // TO KEEP
     302//   // SecondaryLoop : // TO KEEP
     303//   G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
     304//   Prompt("Help"); // TO KEEP
     305//   exitHelp = false; // TO KEEP
     306//   void* event; // TO KEEP
     307//   while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
     308//     interactorManager->DispatchEvent(event); // TO KEEP
     309//     if(exitHelp==true) break; // TO KEEP
     310//   } // TO KEEP
     311//   Prompt("session"); // TO KEEP
     312//   // // TO KEEP
     313//   if(fHelp==false) return false; // TO KEEP
     314//   aInt = fHelpChoice; // TO KEEP
     315//   fHelp = false; // TO KEEP
     316//   return true; // TO KEEP
     317}
     318/***************************************************************************/
     319void G4UIQt::ExitHelp(
     320)
     321/***************************************************************************/
     322/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
     323{
     324}
     325/***************************************************************************/
     326void G4UIQt::AddMenu (
    320327 const char* a_name
    321328,const char* a_label
     
    343350}
    344351/***************************************************************************/
    345 void G4UIXm::AddButton (
     352void G4UIQt::AddButton (
    346353 const char* a_menu
    347354,const char* a_label
     
    351358/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    352359{
    353 //   if(a_menu==NULL) return; # TO KEEP
    354 //   if(a_label==NULL) return; # TO KEEP
    355 //   if(a_command==NULL) return; # TO KEEP
     360//   if(a_menu==NULL) return; // TO KEEP
     361//   if(a_label==NULL) return; // TO KEEP
     362//   if(a_command==NULL) return; // TO KEEP
    356363//   Widget parent = (Widget)GetInteractor(a_menu);
    357364//   if(parent==NULL) return;
     
    377384  Send the command to geant4
    378385 */
    379 void G4UIXm::commandEnteredCallback (
    380  Widget    a_widget
    381 ,XtPointer a_tag
    382 ,XtPointer a_data
    383 )
    384 /***************************************************************************/
    385 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    386 {
    387   G4UIQt*  This = (G4UIQt*)a_tag;
     386// TODO !
     387//void G4UIQt::commandEnteredCallback (
     388// Widget    a_widget
     389//,XtPointer a_tag
     390//,XtPointer a_data
     391//)
     392/***************************************************************************/
     393/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
     394//{
     395//  G4UIQt*  This = (G4UIQt*)a_tag;
    388396
    389397//   XmString cps  = ((XmCommandCallbackStruct*)a_data)->value;
     
    401409//   a_widget = NULL;
    402410//   a_tag    = NULL;
    403 }
     411//}
    404412// /***************************************************************************/
    405413// void G4UIXm::keyHandler (
     
    430438/***************************************************************************/
    431439/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    432 {
     440//{
    433441//   XmTextSetString((Widget)a_tag,(char*)"");
    434 }
    435 /***************************************************************************/
    436 void G4UIXm::ButtonCallback (
    437  Widget a_widget
    438 ,XtPointer a_tag
    439 ,XtPointer
    440 )
    441 /***************************************************************************/
    442 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    443 {
     442//}
     443/***************************************************************************/
     444// TODO !
     445//void G4UIQt::ButtonCallback (
     446// Widget a_widget
     447//,XtPointer a_tag
     448//,XtPointer
     449//)
     450/***************************************************************************/
     451/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
     452//{
    444453//   G4UIXm* This = (G4UIXm*)a_tag;
    445454//   if(This->fHelp==true) return; // Disabled when in help.
     
    447456//   //printf ("debug : execute:\n%s\n",ss.data());
    448457//   This->ApplyShellCommand(ss,exitSession,exitPause);
    449 }
     458//}
    450459/***************************************************************************/
    451460/***************************************************************************/
     
    508517//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    509518{
    510   aInt = 0; # TO KEEP
    511   if(aString==NULL) return false; # TO KEEP
    512   char* s; # TO KEEP
    513   long value = strtol(aString,&s,10); # TO KEEP
    514   if(s==aString) return false; # TO KEEP
    515   aInt = value; # TO KEEP
    516   return true; # TO KEEP
     519  aInt = 0; // TO KEEP
     520  if(aString==NULL) return false; // TO KEEP
     521  char* s; // TO KEEP
     522  long value = strtol(aString,&s,10); // TO KEEP
     523  if(s==aString) return false; // TO KEEP
     524  aInt = value; // TO KEEP
     525  return true; // TO KEEP
    517526}
    518527#include <X11/IntrinsicP.h>
  • trunk/geant4/interfaces/common/include/G4Qt.hh

    r481 r484  
    2525//
    2626//
    27 // $Id: G4Xt.hh,v 1.6 2006/06/29 19:10:14 gunter Exp $
     27// $Id: G4Qt.hh,v 1.6 2007/05/29 11:10:14 $
    2828// GEANT4 tag $Name: geant4-08-01 $
    2929//
    30 //  To unify X11 event treatment between
    31 // G4/interfaces Xt sessions and G4/visualizations Xt drivers.
    32 // G.Barrand
     30//  To unify Qt event treatment between
     31// G4/interfaces Qt sessions and G4/visualizations Qt drivers.
     32// L. Garnier
    3333
    34 #ifndef G4XT_HH
    35 #define G4XT_HH
     34#ifndef G4QT_HH
     35#define G4QT_HH
    3636
    37 #if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
    38 
    39 #include <X11/Intrinsic.h>
     37#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
    4038
    4139#include "G4VInteractorManager.hh"
    4240
     41#include <QtGui/qapplication.h>
     42#include <QtGui/qwidget.h>
     43#include <QtGui/qmainwindow.h>
     44
    4345// Class description :
    4446//
    45 //  G4Xt : a singleton to handle GUI sessions and visualization
    46 // drivers built over Xt. It permits to have one Xt main loop for
    47 // the whole application. The Xt toolkit is inited in the
     47//  G4Qt : a singleton to handle GUI sessions and visualization
     48// drivers built over Qt. It permits to have one Qt main loop for
     49// the whole application. The Qt toolkit is inited in the
    4850// constructor. It is done once for the whole application.
    4951//
    5052// Class description - end :
    5153
    52 class G4Xt : public G4VInteractorManager {
     54class G4Qt : public G4VInteractorManager {
    5355public:
    54   static G4Xt* getInstance();
    55   static G4Xt* getInstance(int,char**,char*);
    56   void PutStringInResourceDatabase(char*);
     56  static G4Qt* getInstance();
     57  static G4Qt* getInstance(int,char**,char*);
    5758  G4bool Inited();
    5859  void* GetEvent();
    5960  void FlushAndWaitExecution();
    60   virtual ~G4Xt();                     
     61  virtual ~G4Qt();                     
    6162private:
    62   G4Xt (int,char**,char*);                     
    63   static G4Xt* instance; // Pointer to single instance.
     63  G4Qt (int,char**,char*);                     
     64  static G4Qt* instance; // Pointer to single instance.
    6465};
    6566
    66 #endif //HAS_XT
     67#endif //HAS_QT
    6768
    6869#endif
  • trunk/geant4/interfaces/common/src/G4Qt.cc

    r481 r484  
    2525//
    2626//
    27 // $Id: G4Xt.cc,v 1.11 2006/06/29 19:10:28 gunter Exp $
     27// $Id: G4Qt.cc,v 1.11 2007/05/29 11:10:28 $
    2828// GEANT4 tag $Name: geant4-08-01 $
    2929//
    30 // G.Barrand
     30// L. Garnier
    3131
    32 #if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
     32#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
    3333
    3434#include <stdlib.h>
    3535#include <string.h>
    3636
    37 #include <X11/Intrinsic.h>
    38 #include <X11/Shell.h>
    39 
    4037#include "G4ios.hh"
    4138
    42 #include "G4Xt.hh"
     39#include "G4Qt.hh"
    4340
    4441#define NewString(str)  \
     
    4946//static void XDisplaySetWindowToNormalState (Display*,Window);
    5047
    51 G4Xt* G4Xt::instance    = NULL;
     48G4Qt* G4Qt::instance    = NULL;
    5249
    53 static G4bool XtInited  = FALSE;
    54 static int    argn      = 0;
    55 static char** args      = NULL;
    56 static XtAppContext appContext = NULL;
    57 static Widget topWidget = NULL;
     50static G4bool QtInited  = FALSE;
     51//static int    argn      = 0;
     52//static char** args      = NULL;
     53// static QtAppContext appContext = NULL;
     54static QMainWindow *mainWidget = NULL;
     55
    5856/***************************************************************************/
    59 G4Xt* G4Xt::getInstance (
     57G4Qt* G4Qt::getInstance (
    6058)
    6159/***************************************************************************/
    6260/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    6361{
    64   return G4Xt::getInstance (0,NULL,(char*)"Geant4");
     62  return G4Qt::getInstance (0,NULL,(char*)"Geant4");
    6563}
    6664/***************************************************************************/
    67 G4Xt* G4Xt::getInstance (
     65G4Qt* G4Qt::getInstance (
    6866 int    a_argn
    6967,char** a_args
     
    7472{
    7573  if (instance==NULL) {
    76     instance = new G4Xt(a_argn,a_args,a_class);
     74    instance = new G4Qt(a_argn,a_args,a_class);
    7775  }
    7876  return instance;
    7977}
    8078/***************************************************************************/
    81 G4Xt::G4Xt (
     79G4Qt::G4Qt (
    8280 int    a_argn
    8381,char** a_args
     
    8785/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    8886{
    89   if(XtInited==FALSE) {  //Xt should be Inited once !
    90     if(a_argn!=0) {  //Save args.
    91       args = (char**)malloc(a_argn * sizeof(char*));
    92       if(args!=NULL) {
    93         argn = a_argn;
    94         for(int argi=0;argi<a_argn;argi++) {
    95           args[argi] = (char*)NewString (a_args[argi]);
    96         }
    97       }
     87  if(QtInited==FALSE) {  //Qt should be Inited once !
     88
     89    new QApplication (a_argn, a_args);
     90    mainWidget = new QMainWindow();
     91
     92    if(mainWidget==NULL) {
     93      G4cout        << "G4Qt : Unable to init Qt." << G4endl;
    9894    }
    99 #if XtSpecificationRelease == 4
    100     Cardinal     narg;
    101     narg         = (Cardinal)a_argn;
    102 #else
    103     int          narg;
    104     narg         = a_argn;
    105 #endif
    106     Arg          xargs[1];
    107     XtSetArg     (xargs[0],XtNgeometry,"100x100");
    108     topWidget    = XtAppInitialize (&appContext,a_class,
    109                                     NULL,(Cardinal)0,
    110                                     &narg,a_args,NULL,
    111                                     xargs,1);
    112     if(topWidget==NULL) {
    113       G4cout        << "G4Xt : Unable to init Xt." << G4endl;
    114     }
    115     // Restore a_args. XtAppInitialize corrupts the given ones !!!
    116     if( (a_argn!=0) && (args!=NULL)) {
    117       for(int argi=0;argi<a_argn;argi++) {
    118         if(args[argi]!=NULL)
    119           strcpy(a_args[argi],args[argi]);
    120         else
    121           a_args[argi] = NULL;
    122       }
    123     }
    124     // If topWidget not realized, pbs with Inventor shells.
    125     XtSetMappedWhenManaged (topWidget,False);
    126     XtRealizeWidget (topWidget);
    127     XtInited = TRUE;
     95    QtInited  = TRUE;
     96    mainWidget->show();
     97    qApp->exec();
    12898  }
    129   SetArguments      (argn,args);
    130   SetMainInteractor (topWidget);
    131   AddDispatcher     ((G4DispatchFunction)XtDispatchEvent);
     99//  AddDispatcher     ((G4DispatchFunction)QtDispatchEvent); // FIXME
    132100}
    133101/***************************************************************************/
    134 G4Xt::~G4Xt (
     102G4Qt::~G4Qt (
    135103)
    136104/***************************************************************************/
     
    142110}
    143111/***************************************************************************/
    144 G4bool G4Xt::Inited (
     112G4bool G4Qt::Inited (
    145113)
    146114/***************************************************************************/
    147115/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    148116{
    149   return XtInited;
     117  return QtInited;
    150118}
    151119/***************************************************************************/
    152 void* G4Xt::GetEvent (
     120void* G4Qt::GetEvent (
    153121)
    154122/***************************************************************************/
    155123/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    156124{
    157   static XEvent  event;
    158   if(appContext==NULL) return NULL;
    159   if(topWidget==NULL) return NULL;
    160   XtAppNextEvent (appContext, &event);
    161   return         &event;
     125//FIXME
     126   G4cout        << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
     127//  static XEvent  event;
     128//  if(appContext==NULL) return NULL;
     129//  if(mainApp==NULL) return NULL;
     130//  QtAppNextEvent (appContext, &event);
     131//  return         &event;
    162132}
    163133/***************************************************************************/
    164 void G4Xt::PutStringInResourceDatabase (
    165  char* a_string
     134void G4Qt::FlushAndWaitExecution (
    166135)
    167136/***************************************************************************/
    168137/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    169138{
    170   if(topWidget==NULL)  return;
    171   if(a_string==NULL)   return;
    172   Display*             dpy   = XtDisplay(topWidget);
    173   XrmDatabase          dbres = XrmGetStringDatabase (a_string);
    174   if(dbres==NULL)      return;
    175   XrmDatabase          database = XrmGetDatabase (dpy);
    176   if(database!=NULL)  {
    177     XrmMergeDatabases  (dbres,&database);
    178   } else {
    179     XrmSetDatabase     (dpy,dbres);
    180   }
    181 }
    182 /***************************************************************************/
    183 void G4Xt::FlushAndWaitExecution (
    184 )
    185 /***************************************************************************/
    186 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    187 {
    188   if(topWidget==NULL) return;
    189   XSync(XtDisplay(topWidget),False);
     139//FIXME
     140   G4cout        << "G4Qt : Rien compris a cette fonction G4Qt::FlushAndWaitExecution." << G4endl;
     141//  if(mainApp==NULL) return;
     142//  XSync(QtDisplay(mainApp),False);
    190143}
    191144
Note: See TracChangeset for help on using the changeset viewer.