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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.