Changeset 858 for trunk/source


Ignore:
Timestamp:
Oct 2, 2008, 10:29:48 AM (16 years ago)
Author:
garnier
Message:

protection against no scene + Qapp could be now get on external app

Location:
trunk/source
Files:
5 edited

Legend:

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

    r850 r858  
    3030// L. Garnier
    3131
    32 //define GEANT4_QT_DEBUG
     32//#define GEANT4_QT_DEBUG
    3333
    3434#ifdef G4UI_BUILD_QT_SESSION
     
    113113  if(UI!=NULL) UI->SetSession(this);
    114114
     115  // Check if already define in external app QMainWindow
     116  bool found = false;
     117#if QT_VERSION < 0x040000
     118  // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
     119  // but if I comment them, it doesn't work...
     120  QWidgetList  *list = QApplication::allWidgets();
     121  QWidgetListIt it( *list );         // iterate over the widgets
     122  QWidget * widget;
     123  while ( (widget=it.current()) != 0 ) {  // for each widget...
     124    ++it;
     125    if ((found== false) && (widget->inherits("QMainWindow"))) {
     126      found = true;
     127    }
     128  }
     129  delete list;                      // delete the list, not the widgets
     130#else
     131  foreach (QWidget *widget, QApplication::allWidgets()) {
     132    if ((found== false) && (widget->inherits("QMainWindow"))) {
     133      found = true;
     134    }
     135  }
     136#endif
     137
     138  if (found) {
     139    G4cout        << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted" << G4endl;
     140    return ;
     141  }
    115142  fMainWindow = new QMainWindow();
    116143
  • trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r857 r858  
    317317
    318318  // launch Qt if not
    319   G4Qt* interactorManager = G4Qt::getInstance ();
     319  G4Qt::getInstance ();
    320320
    321321  fLastPos3 = QPoint(-1,-1);   
     
    689689#if QT_VERSION < 0x040000
    690690#if QT_VERSION < 0x030200
    691   QAction *movieParameters =  new QAction("&Movie parameters...","&Make movie ...",CTRL+Key_M,mActions,0,true);
    692 #else
    693   QAction *movieParameters =  new QAction("&Movie parameters...",CTRL+Key_M,mActions);
     691  QAction *movieParameters =  new QAction("&Make Movie...","&Make movie ...",CTRL+Key_M,mActions,0,true);
     692#else
     693  QAction *movieParameters =  new QAction("&Make Movie...",CTRL+Key_M,mActions);
    694694#endif
    695695  movieParameters->addTo(mActions);
     
    17101710  printf("should rescale \n");
    17111711#endif
    1712   GLfloat* feedback_buffer;
    1713   GLint returned;
    1714   FILE* file;
     1712  //  GLfloat* feedback_buffer;
     1713  //  GLint returned;
     1714  //  FILE* file;
    17151715 
    17161716//   feedback_buffer = new GLfloat[size];
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredQt.cc

    r850 r858  
    6262
    6363G4VViewer* G4OpenGLStoredQt::CreateViewer
    64 (G4VSceneHandler& scene, const G4String& name) {
    6564#ifdef GEANT4_QT_DEBUG
    6665  printf("G4OpenGLStoredQt::CreateViewer \n");
    6766#endif
     67(G4VSceneHandler& scene, const G4String& name) {
    6868  G4VViewer* pView =
    6969    new G4OpenGLStoredQtViewer
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

    r850 r858  
    5858  nbPaint =0;
    5959  hasToRepaint =false;
     60
     61  // if no scene...
     62  if (fSceneHandler.GetScene() == 0) {
     63    G4cerr << "G4OpenGLStoredQtViewer: Creating a Viewer without a scene is not allowed. \nPlease use /vis/scene/create before /vis/open/.... "
     64           << G4endl;
     65    return;
     66  }
    6067  if (fViewId < 0) return;  // In case error in base class instantiation.
    6168}
     
    7683void G4OpenGLStoredQtViewer::Initialise() {
    7784#ifdef GEANT4_QT_DEBUG
    78   printf("GLWidget::Initialise \n");
     85  printf("G4OpenGLStoredQtViewer::Initialise 1\n");
    7986#endif
    8087  readyToPaint = false;
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc

    r850 r858  
    150150
    151151void G4OpenGLViewer::SetView () {
    152  
     152
     153  if (!fSceneHandler.GetScene()) {
     154    G4cerr << "G4OpenGLStoredQtViewer: Creating a Viewer without a scene is not allowed. \nPlease use /vis/scene/create before /vis/open/.... "
     155           << G4endl;
     156    return;
     157  }
    153158  // Calculates view representation based on extent of object being
    154159  // viewed and (initial) viewpoint.  (Note: it can change later due
Note: See TracChangeset for help on using the changeset viewer.