Changeset 1037 for trunk


Ignore:
Timestamp:
May 11, 2009, 11:55:23 AM (15 years ago)
Author:
garnier
Message:

resize en cours de factorisation

Location:
trunk/source/visualization/OpenGL
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh

    r975 r1037  
    6565  void HLRThirdPass ();
    6666  void InitializeGLView ();
    67   void ResizeGLView();
     67  void ResizeGLView(unsigned int, unsigned int);
    6868  void Pick(GLdouble x, GLdouble y);
    6969  virtual void CreateFontLists () {}
     
    7171//////////////////////////////Vectored PostScript production functions///
    7272  void printEPS();
    73   // print EPS file. Depending of fVectoredPs, it will print Vectored or not
    74  
     73  // print EPS file. Depending of fVectoredPs, it will print Vectored or not 
     74
     75  unsigned int getWinWidth();
     76  unsigned int getWinHeight();
    7577  GLdouble getSceneNearWidth();
    7678  GLdouble getSceneFarWidth();
     
    8486  G4OpenGLSceneHandler& fOpenGLSceneHandler;
    8587  G4Colour background;      //the OpenGL clear colour
    86   unsigned int fWinSize_x, fWinSize_y;
    87   // size of the OpenGL frame
    8888  G4bool
    8989    transparency_enabled,   //is alpha blending enabled?
     
    105105  G4float                           fPointSize;
    106106  bool printGl2PS();
     107  void ResizeGLView();
    107108  GLubyte* grabPixels (int inColor,
    108109                       unsigned int width,
     
    113114  bool printVectoredEPS();
    114115  // print vectored EPS files
     116  unsigned int fWinSize_x, fWinSize_y;
     117  // size of the OpenGL frame
    115118};
    116119
  • trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc

    r976 r1037  
    119119
    120120#ifdef G4DEBUG_VIS_OGL
    121   printf("G4OpenGLImmediateQtViewer::ComputeView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",fWinSize_x, fWinSize_y);
     121  printf("G4OpenGLImmediateQtViewer::ComputeView   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
    122122#endif
    123123  makeCurrent();
     
    150150   
    151151#ifdef G4DEBUG_VIS_OGL
    152   printf("G4OpenGLImmediateQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",fWinSize_x, fWinSize_y);
     152  printf("G4OpenGLImmediateQtViewer::ComputeView  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
    153153#endif
    154154  hasToRepaint = true;
     
    175175,int aHeight)
    176176
    177   fWinSize_x = aWidth;
    178   fWinSize_y = aHeight;
    179   hasToRepaint = true;
     177  ResizeGLView(aWidth,aHeight);
     178  //  hasToRepaint = true;
    180179}
    181180
     
    191190  }
    192191  // DO NOT RESIZE IF SIZE HAS NOT CHANGE
    193   if ( !hasToRepaint) {
    194     if (((fWinSize_x == (unsigned int)width())) &&(fWinSize_y == (unsigned int) height())) {
    195       return;
    196     }
    197   }
     192//   if ( !hasToRepaint) {
     193//     if (((fWinSize_x == (unsigned int)width())) &&(fWinSize_y == (unsigned int) height())) {
     194//       return;
     195//     }
     196//   }
    198197#ifdef G4DEBUG_VIS_OGL
    199198  printf("G4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",readyToPaint);
  • trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r1036 r1037  
    173173  GLWindow->setWindowTitle( name);
    174174#endif
    175   fWinSize_x = fVP.GetWindowSizeHintX();
    176   fWinSize_y = fVP.GetWindowSizeHintY();
    177175
    178176  //useful for MACOSX, we have to compt the menuBar height
     
    184182    YPos = offset;
    185183  }
    186   GLWindow->resize(fWinSize_x, fWinSize_y);
     184  //  ResizeGLView(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
    187185  GLWindow->move(fVP.GetWindowAbsoluteLocationHintX(QApplication::desktop()->width()),YPos);
    188186  GLWindow->show();
     
    15631561  GLdouble coefDepth = 0;
    15641562  if(mouseMove) {
    1565     coefTrans = ((G4double)getSceneNearWidth())/((G4double)fWinSize_x);
    1566     if (fWinSize_y <fWinSize_x) {
    1567       coefTrans = ((G4double)getSceneNearWidth())/((G4double)fWinSize_y);
     1563    coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
     1564    if (getWinHeight() <getWinWidth()) {
     1565      coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
    15681566    }
    15691567  } else {
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

    r976 r1037  
    126126
    127127#ifdef G4DEBUG_VIS_OGL
    128   printf("G4OpenGLStoredQtViewer::ComputeView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",fWinSize_x, fWinSize_y);
     128  printf("G4OpenGLStoredQtViewer::ComputeView  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
    129129#endif
    130130  makeCurrent();
     
    195195
    196196#ifdef G4DEBUG_VIS_OGL
    197   printf("G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",fWinSize_x, fWinSize_y);
     197  printf("G4OpenGLStoredQtViewer::ComputeView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
    198198#endif
    199199  hasToRepaint =true;
     
    209209
    210210  // Set new size, it will be update when next Repaint()->SetView() called
    211   fWinSize_x = aWidth;
    212   fWinSize_y = aHeight;
    213   hasToRepaint = true;
     211  ResizeGLView(aWidth,aHeight);
     212  //  hasToRepaint = true;
    214213}
    215214
     
    227226  //    WHEN CLICK ON THE FRAME FOR EXAMPLE
    228227  //    EXECEPT WHEN MOUSE MOVE EVENT
    229   if ( !hasToRepaint) {
    230     if (((fWinSize_x == (unsigned int)width())) &&(fWinSize_y == (unsigned int) height())) {
    231       return;
    232     }
    233   }
     228//   if ( !hasToRepaint) {
     229//     if (((fWinSize_x == (unsigned int)width())) &&(fWinSize_y == (unsigned int) height())) {
     230//       return;
     231//     }
     232//   }
    234233#ifdef G4DEBUG_VIS_OGL
    235234  printf("G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",readyToPaint);
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc

    r1036 r1037  
    135135
    136136
     137void G4OpenGLViewer::ResizeGLView(unsigned int aWidth,unsigned int aHeight)
     138{
     139  if ((fWinSize_x != aWidth) && (fWinSize_y != aHeight)) {
     140    fWinSize_x = aWidth;
     141    fWinSize_y = aHeight;
     142    ResizeGLView();
     143  }
     144}
     145
     146
    137147/**
    138148 * Set the viewport of the scene
     
    196206
    197207
     208unsigned int G4OpenGLViewer::getWinWidth () {
     209  return fWinSize_x;
     210}
     211
     212unsigned int G4OpenGLViewer::getWinHeight () {
     213  return fWinSize_y;
     214}
     215
     216
    198217void G4OpenGLViewer::SetView () {
    199218
     
    241260 
    242261  // FIXME
    243   ResizeGLView();
     262  ResizeGLView(fWinSize_x,fWinSize_y);
    244263  //SHOULD SetWindowsSizeHint()...
    245264
     
    631650  int Y = fWinSize_y;
    632651
    633   fWinSize_x = width;
    634   fWinSize_y = height;
    635   ResizeGLView();
     652  ResizeGLView(width,height);
    636653  if (fGL2PSAction->enableFileWriting()) {
    637654
     
    645662  }
    646663
    647   fWinSize_x = X;
    648   fWinSize_y = Y;
    649   ResizeGLView();
     664  ResizeGLView(X,Y);
    650665
    651666  // Reset for next time (useful is size change)
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewerMessenger.cc

    r977 r1037  
    2525//
    2626//
    27 // $Id: G4OpenGLViewerMessenger.cc,v 1.16 2009/03/18 14:34:28 allison Exp $
     27// $Id: G4OpenGLViewerMessenger.cc,v 1.17 2009/04/28 15:05:22 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929
     
    274274      if (newValue == "vectored") pOGLViewer->fVectoredPs = true;
    275275      if (newValue == "pixmap") pOGLViewer->fVectoredPs = false;
     276      return;
    276277    }
    277278
     
    281282      if (pOGLViewer->fVP.IsAutoRefresh())
    282283        G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
     284      return;
    283285    }
    284286
     
    286288    dynamic_cast<G4OpenGLStoredViewer*>(pViewer);
    287289
    288   if (!pOGLSViewer) {
    289     G4cout <<
     290  if (!pOGLSViewer)
     291    {
     292      G4cout <<
    290293  "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS."
    291294  "\n  The time slice viewing feature is only implemented for OGL Stored"
    292295  "\n  viewers at present.  Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
    293            << G4endl;
    294     return;
    295   }
     296             << G4endl;
     297      return;
     298    }
    296299
    297300  if (command == fpCommandDisplayHeadTime)
     
    309312      pOGLSViewer->fDisplayHeadTimeGreen = green;
    310313      pOGLSViewer->fDisplayHeadTimeBlue = blue;
     314      return;
    311315    }
    312316
     
    332336      pOGLSViewer->fDisplayLightFrontGreen = green;
    333337      pOGLSViewer->fDisplayLightFrontBlue = blue;
     338      return;
    334339    }
    335340
     
    350355      if (pOGLSViewer->fVP.IsAutoRefresh())
    351356        G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
     357      return;
    352358    }
    353359
     
    375381      if (pOGLSViewer->fVP.IsAutoRefresh())
    376382        G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
     383      return;
    377384    }
    378385
  • trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc

    r1036 r1037  
    231231  size_hints = XAllocSizeHints();
    232232   
    233   fWinSize_x = fVP.GetWindowSizeHintX();
    234   fWinSize_y = fVP.GetWindowSizeHintY();
    235233  G4int x_origin = fVP.GetWindowAbsoluteLocationHintX(DisplayWidth(dpy, vi -> screen));
    236234
     
    239237  G4int y_origin = fVP.GetWindowAbsoluteLocationHintY(DisplayHeight(dpy, vi -> screen));
    240238
    241   size_hints->base_width = fWinSize_x;
    242   size_hints->base_height = fWinSize_y;
     239  size_hints->base_width = getWinWidth();
     240  size_hints->base_height = getWinHeight();
    243241  size_hints->x = x_origin;
    244242  size_hints->y = y_origin;
     
    270268
    271269   win = XCreateWindow (dpy, XRootWindow (dpy, vi -> screen), x_origin,
    272                         y_origin, fWinSize_x, fWinSize_y, 0, vi -> depth,
     270                        y_origin, getWinWidth(), getWinHeight(), 0, vi -> depth,
    273271                        InputOutput, vi -> visual, 
    274272                        CWBorderPixel | CWColormap |
  • trunk/source/visualization/OpenGL/src/G4OpenGLXmViewer.cc

    r1036 r1037  
    146146  borcol = XBlackPixelOfScreen (XtScreen(shell));
    147147 
    148   fWinSize_x = fVP.GetWindowSizeHintX();
    149   fWinSize_y = fVP.GetWindowSizeHintY();
    150148  G4int x_origin = fVP.GetWindowAbsoluteLocationHintX(DisplayWidth(dpy, vi -> screen));
    151149
     
    159157                   XtNdepth, vi -> depth,
    160158                   XtNcolormap, cmap,
    161                    XtNwidth, fWinSize_x,
    162                    XtNheight, fWinSize_y,
     159                   XtNwidth, getWinWidth(),
     160                   XtNheight, getWinHeight(),
    163161                   XtNx, x_origin,
    164162                   XtNy, y_origin,
     
    172170                   XtNdepth, vi -> depth,
    173171                   XtNcolormap, cmap,
    174                    XtNwidth, fWinSize_x,
    175                    XtNheight, fWinSize_y,
     172                   XtNwidth, getWinWidth(),
     173                   XtNheight, getWinHeight(),
    176174                   XtNborderColor, &borcol,
    177175                   XtNbackground, &bgnd,
  • trunk/source/visualization/OpenGL/src/G4OpenGLXmWindowHandlingCallbacks.cc

    r1036 r1037  
    6262                 NULL);
    6363
    64   pView->fWinSize_x = (G4int) width;
    65   pView->fWinSize_y = (G4int) height;
     64  pView->ResizeGLView((G4int) width,(G4int) height);
    6665
    6766  glXMakeCurrent (pView->dpy, XtWindow(pView->glxarea), pView->cx);
     
    7069  printf("G4OpenGLXmViewer::expose_callback\n");
    7170#endif
    72    pView->SetView ();
    73 //   pView->ClearView ();
     71  // FIXME : L.Garnier 11 Mai 2009 : Should be erase
     72  pView->SetView ();
     73  pView->ClearView ();
    7474  pView->DrawView ();
     75  // ENDOF Fixme
     76
    7577}
    7678
Note: See TracChangeset for help on using the changeset viewer.