Changeset 1242 for trunk/source


Ignore:
Timestamp:
Apr 12, 2010, 5:20:43 PM (14 years ago)
Author:
garnier
Message:

bugged version

Location:
trunk/source/visualization
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/GNUmakefile

    r1228 r1242  
    2626
    2727# For Debug mode
    28 # CPPFLAGS += -DG4DEBUG_VIS_OGL
     28 CPPFLAGS += -DG4DEBUG_VIS_OGL
    2929# CPPFLAGS += -DG4DEBUG_VIS_OI
    3030# CPPFLAGS += -DG4DEBUG_VIS_MANAGEMENT
     31
    3132
    3233ifdef G4VIS_BUILD
  • trunk/source/visualization/OpenGL/GNUmakefile

    r1233 r1242  
    1212# For debug mode
    1313 CPPFLAGS += -DG4DEBUG_VIS_OGL
     14
     15#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1
     16#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2
     17#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_3
    1418
    1519GLOBLIBS  = libG4vis_management.lib libG4modeling.lib libG4gl2ps.lib
  • trunk/source/visualization/OpenGL/History

    r1240 r1242  
    1 $Id: History,v 1.163 2010/01/28 09:19:04 gcosmo Exp $
     1$Id: History,v 1.164 2010/03/10 11:03:46 lgarnier Exp $
    22-------------------------------------------------------------------
    33
     
    1717     * Reverse chronological order (last date on top), please *
    1818     ----------------------------------------------------------
     199th March 2010 Laurent Garnier
     20 - G4OpenGLViewer : Fix clipping when resizing non square size windows
     21   Remove error message when no scene present.
     22 - G4OpenGLImmediateQtViewer, G4OpenGLStoredQtViewer :
     23    - Add some protections if viewer is in tab
     24    -  fix some redraw probems when focus was outside frame
     25    - Add ShowView() and paintEvent() methods
     26    - DrawView method is now the same in Store and Immediate mode
     27 - G4OpenGLQtViewer : Add things for viewer in tabs
     28
    19293rd March 2010 Laurent Garnier
    2030- G4OpenGLViewer : Add protection against null pointer scene
  • trunk/source/visualization/OpenGL/include/G4OpenGLImmediateQtViewer.hh

    r1240 r1242  
    2525//
    2626//
    27 // $Id: G4OpenGLImmediateQtViewer.hh,v 1.6 2009/10/14 13:27:30 lgarnier Exp $
     27// $Id: G4OpenGLImmediateQtViewer.hh,v 1.7 2010/03/10 11:03:46 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    5656  void initializeGL ();
    5757  void DrawView ();
    58   //  void FinishView ();
    5958  void resizeGL(int width,int height);
    6059  void paintGL();
  • trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh

    r1140 r1242  
    6464  void AddPrimitive (const G4Circle&);
    6565  void AddPrimitive (const G4Square&);
     66  void AddPrimitives (std::vector <G4VMarker>);
    6667  void AddPrimitive (const G4Scale&);
    6768  void AddPrimitive (const G4Polyhedron&);
     
    105106
    106107  void AddCircleSquare (const G4VMarker&, G4OpenGLBitMapStore::Shape);
     108  void AddCircleSquares (std::vector <G4VMarker>, G4OpenGLBitMapStore::Shape);
    107109
    108110  void DrawXYPolygon
  • trunk/source/visualization/OpenGL/include/G4OpenGLStoredQtViewer.hh

    r1240 r1242  
    2525//
    2626//
    27 // $Id: G4OpenGLStoredQtViewer.hh,v 1.9 2009/10/14 13:27:30 lgarnier Exp $
     27// $Id: G4OpenGLStoredQtViewer.hh,v 1.10 2010/03/10 11:03:46 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
  • trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc

    r1240 r1242  
    2525//
    2626//
    27 // $Id: G4OpenGLImmediateQtViewer.cc,v 1.17 2009/11/03 11:02:32 lgarnier Exp $
     27// $Id: G4OpenGLImmediateQtViewer.cc,v 1.18 2010/03/10 11:03:46 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    6767#endif
    6868  fReadyToPaint = false;
    69 #ifdef G4DEBUG_VIS_OGL
    70   printf("G4OpenGLImmediateQtViewer::Initialise VVVVVVVVVVVVVVVV \n");
    71 #endif
    7269  CreateMainWindow (this,QString(fName));
    73 #ifdef G4DEBUG_VIS_OGL
    74   printf("G4OpenGLImmediateQtViewer::Initialise ^^^^^^^^^^^^^^^^\n");
    75 #endif
    7670  CreateFontLists ();
    7771
    7872  fReadyToPaint = true;
    79 #ifdef G4DEBUG_VIS_OGL
    80   printf("G4OpenGLImmediateQtViewer::InitialiseGLView * \n");
    81 #endif
    82 
    83   // L.Garnier 01/2010 Force a update in order to Init GL
    84   //  updateGL();
    85 #ifdef G4DEBUG_VIS_OGL
    86   printf("G4OpenGLImmediateQtViewer::InitialiseGLView end * \n");
    87 #endif
    8873}
    8974
    9075void G4OpenGLImmediateQtViewer::initializeGL () {
    91 #ifdef G4DEBUG_VIS_OGL
    92   printf("G4OpenGLImmediateQtViewer::InitialiseGL * \n");
    93 #endif
    9476
    9577  InitializeGLView ();
     
    11597
    11698
    117 /** To ensure compatibility with DrawView method
    118  */
    11999void  G4OpenGLImmediateQtViewer::DrawView() {
    120 #ifdef G4DEBUG_VIS_OGL
    121   printf("G4OpenGLImmediateQtViewer::DrawView  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
    122 #endif
    123   // That's no the same logic as Stored Viewer, I don't know why...
    124   // see G4OpenGLStoredQtViewer::DrawView for more informations
    125 
    126100  updateQWidget();
    127 
    128 #ifdef G4DEBUG_VIS_OGL
    129   printf("G4OpenGLImmediateQtViewer::DrawView  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
    130 #endif
    131101}
    132102
     
    135105
    136106#ifdef G4DEBUG_VIS_OGL
    137   printf("G4OpenGLImmediateQtViewer::ComputeView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
     107  printf("G4OpenGLImmediateQtViewer::ComputeView %d %d &:%d  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight(),this);
    138108#endif
    139109  makeCurrent();
     
    166136   
    167137#ifdef G4DEBUG_VIS_OGL
    168   printf("G4OpenGLImmediateQtViewer::ComputeView %d %d hasTo:%d^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight(),fHasToRepaint);
     138  printf("G4OpenGLImmediateQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
    169139#endif
    170140  fHasToRepaint = true;
    171141}
    172 
    173142
    174143/**
     
    179148,int aHeight)
    180149
    181 #ifdef G4DEBUG_VIS_OGL
    182   printf("\n\nG4OpenGLImmediateQtViewer::resizeGL VVVV recu : W:%d H:%d\n",aWidth,aHeight);
    183 #endif
    184150  ResizeWindow(aWidth,aHeight);
    185151  fHasToRepaint = sizeHasChanged();
    186 #ifdef G4DEBUG_VIS_OGL
    187   printf("\n\nG4OpenGLImmediateQtViewer::resizeGL ^^^^^\n");
    188 #endif
    189152}
    190153
     
    193156{
    194157#ifdef G4DEBUG_VIS_OGL
    195   printf("\n\nG4OpenGLImmediateQtViewer::paintGL ?? %d W:%d H:%d \n",fHasToRepaint,getWinWidth(),getWinHeight());
     158  printf("\n\nG4OpenGLImmediateQtViewer::paintGL  &: %d??\n",this);
    196159#endif
    197160  if (!fReadyToPaint) {
     
    294257
    295258void G4OpenGLImmediateQtViewer::paintEvent(QPaintEvent *event) {
    296   //  fHasToRepaint= false;
    297 #ifdef G4DEBUG_VIS_OGL
    298   printf("\n\nG4OpenGLImmediateQtViewer::paintEvent VVVVVVVVV %d\n",fHasToRepaint);
    299 #endif
    300259  if ( fHasToRepaint) {
    301260    updateGL();
    302261  }
    303 #ifdef G4DEBUG_VIS_OGL
    304   printf("\n\nG4OpenGLImmediateQtViewer::paintEvent ^^^^^^^^^ %d\n",fHasToRepaint);
    305 #endif
    306262}
    307263
     
    309265void G4OpenGLImmediateQtViewer::updateQWidget() {
    310266  fHasToRepaint= true;
    311 #ifdef G4DEBUG_VIS_OGL
    312   printf("\n\nG4OpenGLImmediateQtViewer::updateQWidget VVVVVVVVV HasTo:%d\n",fHasToRepaint);
    313 #endif
    314267  updateGL();
    315268  repaint();
    316 #ifdef G4DEBUG_VIS_OGL
    317   printf("\n\nG4OpenGLImmediateQtViewer::updateQWidget ^^^^^^^^^\n");
    318 #endif
    319269  fHasToRepaint= false;
    320270}
     
    326276//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    327277{
    328 #ifdef G4DEBUG_VIS_OGL
    329   printf("\n\nG4OpenGLImmediateQtViewer::ShowView VVVV\n");
    330 #endif
    331278  fHasToRepaint = true;
    332279#if QT_VERSION < 0x040000
     
    335282  activateWindow();
    336283#endif
    337 #ifdef G4DEBUG_VIS_OGL
    338   printf("\n\nG4OpenGLImmediateQtViewer::ShowView ^^^^^\n");
    339 #endif
    340 }
    341 #endif
     284}
     285#endif
  • trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc

    r1241 r1242  
    157157
    158158  // See all primitives immediately...
    159   //  glFlush ();
     159  glFlush ();
    160160
    161161  G4OpenGLSceneHandler::EndPrimitives ();
  • trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r1240 r1242  
    2525//
    2626//
    27 // $Id: G4OpenGLQtViewer.cc,v 1.47 2010/01/27 15:49:22 gcosmo Exp $
     27// $Id: G4OpenGLQtViewer.cc,v 1.48 2010/03/10 11:03:46 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    165165      YPos = offset;
    166166    }
    167 #ifdef G4DEBUG_VIS_OGL
    168     printf("G4OpenGLQtViewer::CreateMainWindow :: before resizing to %d %d vvvvvvvvvvvvvvvvvvv\n",getWinWidth(), getWinHeight());
    169 #endif
    170167    fGLWindow->resize(getWinWidth(), getWinHeight());
    171168#ifdef G4DEBUG_VIS_OGL
    172     printf("G4OpenGLQtViewer::CreateMainWindow :: after resizing to %d %d ^^^^^^^^^^^^^^^^^^^^\n",getWinWidth(), getWinHeight());
     169    printf("G4OpenGLQtViewer::CreateMainWindow :: resizing to %d %d \n",getWinWidth(), getWinHeight());
    173170#endif
    174171    fGLWindow->move(fVP.GetWindowAbsoluteLocationHintX(QApplication::desktop()->width()),YPos);
    175172    fGLWindow->show();
    176 #ifdef G4DEBUG_VIS_OGL
    177     printf("G4OpenGLQtViewer::CreateMainWindow :: after show to %d %d --------------------\n",getWinWidth(), getWinHeight());
    178 #endif
    179   } else {
    180 #ifdef G4DEBUG_VIS_OGL
    181     printf("G4OpenGLQtViewer::AddTab VVVVVVVVVVVVVV\n");
    182 #endif
     173  } else {
    183174    fGLWindow = fWindow;
    184 #ifdef G4DEBUG_VIS_OGL
    185     printf("G4OpenGLQtViewer::AddTab ->resize : %d %d\n",getWinWidth(), getWinHeight());
    186 #endif
    187175    fGLWindow->resize(getWinWidth(), getWinHeight());
    188 #ifdef G4DEBUG_VIS_OGL
    189     printf("G4OpenGLQtViewer::AddTab ^^^^^^^^^^^^^^\n");
    190 #endif
    191176  }
    192177
     
    196181    createPopupMenu();
    197182
    198 #ifdef G4DEBUG_VIS_OGL
    199   printf("G4OpenGLQtViewer::CreateMainWindow :: END\n");
    200 #endif
    201183}
    202184
     
    14361418void G4OpenGLQtViewer::FinishView()
    14371419{
    1438 #ifdef G4DEBUG_VIS_OGL
    1439   printf("G4OpenGLQtViewer::FinishView() flush \n");
    1440 #endif
    14411420  glFlush ();
    14421421
  • trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc

    r1238 r1242  
    234234// printf(" circle ");
    235235#endif
     236#ifdef G4VIS_BUILD_OPTIMISE_3
     237      std::vector <G4VMarker> circleV;
     238      // FIXME, must check attribute before doing a list
     239#endif
    236240      for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
    237241        G4Circle circle (polymarker);
     242        // If not already drawn
    238243        circle.SetPosition (polymarker[iPoint]);
    239         G4OpenGLSceneHandler::AddPrimitive (circle);
    240       }
     244#ifdef G4VIS_BUILD_OPTIMISE_3
     245        circleV.push_back(circle);
     246#endif
     247      }
     248#ifdef G4VIS_BUILD_OPTIMISE_3
     249      G4OpenGLSceneHandler::AddPrimitives (circleV);
     250#endif
    241251    }
    242252    break;
     
    246256// printf(" square ");
    247257#endif
     258#ifdef G4VIS_BUILD_OPTIMISE_3
     259      std::vector <G4VMarker> squareV;
     260      // FIXME, must check attribute before doing a list
     261#endif
    248262      for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
    249263        G4Square square (polymarker);
    250264        square.SetPosition (polymarker[iPoint]);
    251         G4OpenGLSceneHandler::AddPrimitive (square);
    252       }
     265#ifdef G4VIS_BUILD_OPTIMISE_3
     266        squareV.push_back(square);
     267#endif
     268      }
     269#ifdef G4VIS_BUILD_OPTIMISE_3
     270      G4OpenGLSceneHandler::AddPrimitives (squareV);
     271#endif
    253272    }
    254273    break;
     
    319338}
    320339
     340void G4OpenGLSceneHandler::AddPrimitives (std::vector <G4VMarker> square) {
     341  glDisable (GL_POINT_SMOOTH);
     342  AddCircleSquares (square, G4OpenGLBitMapStore::square);
     343}
     344
    321345void G4OpenGLSceneHandler::AddCircleSquare
    322346(const G4VMarker& marker,
     
    398422     glBegin (GL_POINTS);
    399423     glVertex3f(centre.x(),centre.y(),centre.z());
     424     glEnd();
     425     //Antialiasing
     426     glEnable (GL_POINT_SMOOTH);
     427     //Transparency
     428     glEnable(GL_BLEND);
     429     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     430
     431     // L. GARNIER 1 March 2009
     432     // Old method, we draw a bitmap instead of a GL_POINT.
     433     // I remove it because it cost in term of computing performances
     434     // and gl2ps can't draw bitmaps
     435
     436     //      glRasterPos3d(centre.x(),centre.y(),centre.z());
     437     //      const GLubyte* marker =
     438     //        G4OpenGLBitMapStore::GetBitMap(shape, size, filled);
     439     //      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
     440     //      glBitmap(GLsizei(size), GLsizei(size), size/2., size/2., 0., 0., marker);
     441   }
     442}
     443
     444void G4OpenGLSceneHandler::AddCircleSquares
     445(std::vector <G4VMarker> marker,
     446 G4OpenGLBitMapStore::Shape shape) {
     447
     448  if (marker.size() == 0) {
     449    return;
     450  }
     451
     452  if (!fProcessingPolymarker) {  // Polymarker has already loaded atts.
     453    // Loads G4Atts for picking...
     454    if (fpViewer->GetViewParameters().IsPicking()) {
     455      G4AttHolder* holder = new G4AttHolder;
     456      LoadAtts(marker[0], holder);
     457      fPickMap[fPickName] = holder;
     458    }
     459  }
     460
     461  // Note: colour treated in sub-class.
     462
     463  if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) {
     464#ifdef G4DEBUG_VIS_OGL
     465    //    printf("+");
     466#endif
     467    glDisable (GL_DEPTH_TEST);
     468  } else {
     469#ifdef G4DEBUG_VIS_OGL
     470    //    printf("-");
     471#endif
     472    glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);}
     473 
     474  glDisable (GL_LIGHTING);
     475 
     476  // Get vis attributes - pick up defaults if none.
     477  const G4VisAttributes* pVA =
     478    fpViewer -> GetApplicableVisAttributes (marker[0].GetVisAttributes ());
     479
     480  G4double lineWidth = GetLineWidth(pVA);
     481  glLineWidth(lineWidth);
     482
     483  G4VMarker::FillStyle style = marker[0].GetFillStyle();
     484
     485  G4bool filled = false;
     486  static G4bool hashedWarned = false;
     487 
     488  switch (style) {
     489  case G4VMarker::noFill:
     490    glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
     491    filled = false;
     492    break;
     493   
     494  case G4VMarker::hashed:
     495    if (!hashedWarned) {
     496      G4cout << "Hashed fill style in G4OpenGLSceneHandler."
     497             << "\n  Not implemented.  Using G4VMarker::filled."
     498             << G4endl;
     499      hashedWarned = true;
     500    }
     501    // Maybe use
     502    //glPolygonStipple (fStippleMaskHashed);
     503    // Drop through to filled...
     504   
     505  case G4VMarker::filled:
     506    glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
     507    filled = true;
     508    break;
     509   
     510  }
     511
     512
     513
     514  MarkerSizeType sizeType;
     515  G4double size = GetMarkerSize(marker[0], sizeType);
     516
     517  // Draw...
     518   if (sizeType == world) {  // Size specified in world coordinates.
     519
     520     for (unsigned int a=0;a<marker.size();a++) {
     521       G4Point3D centre = marker[a].GetPosition();
     522       // A few useful quantities...
     523       DrawXYPolygon (shape, size, centre, pVA);
     524     }
     525   } else { // Size specified in screen (window) coordinates.
     526     // A few useful quantities...
     527     glPointSize (size);
     528     glBegin (GL_POINTS);
     529     for (unsigned int a=0;a<marker.size();a++) {
     530       G4Point3D centre = marker[a].GetPosition();
     531       glVertex3f(centre.x(),centre.y(),centre.z());
     532     }
    400533     glEnd();
    401534     //Antialiasing
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

    r1240 r1242  
    2525//
    2626//
    27 // $Id: G4OpenGLStoredQtViewer.cc,v 1.28 2009/11/03 11:02:32 lgarnier Exp $
     27// $Id: G4OpenGLStoredQtViewer.cc,v 1.29 2010/03/10 11:03:46 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    103103
    104104
    105 void G4OpenGLStoredQtViewer::DrawView () {
    106 #ifdef G4DEBUG_VIS_OGL
    107   printf("G4OpenGLStoredQtViewer::DrawView  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
    108 #endif
    109   // That's no the same logic as Immediate Viewer, I don't know why...
    110   // But if I send updateGL here, we go here :
    111   //  updateQWidget -> paintGL -> ComputeView
    112   // whih is not the same as ComputeView Directly
    113   // And we loose the redraw of things !
    114  
    115   //  ComputeView();
    116 #ifdef G4DEBUG_VIS_OGL
    117   printf("G4OpenGLStoredQtViewer::DrawView  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ llllllllllllllllllllllllllllllll\n");
    118 #endif
     105void G4OpenGLStoredQtViewer::DrawView () { 
    119106  updateQWidget();
    120107}
     
    219206{
    220207#ifdef G4DEBUG_VIS_OGL
    221   printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d?? context:%d\n",fReadyToPaint,fHasToRepaint,context());
     208  printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
    222209#endif
    223210  if (!fReadyToPaint) {
     
    253240
    254241  SetView();
    255 
     242         
    256243  ClearView (); //ok, put the background correct
    257244  ComputeView();
    258245
    259246  fHasToRepaint =false;
    260      
     247
    261248#ifdef G4DEBUG_VIS_OGL
    262249  printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
     
    265252
    266253void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *event) {
    267 #ifdef G4DEBUG_VIS_OGL
    268   printf("\n\nG4OpenGLStoredQtViewer::paintEvent VVVVVVVVV %d context : %d\n",fHasToRepaint,context());
    269 #endif
    270254  if ( fHasToRepaint) {
    271255    updateGL();
    272256  }
    273 #ifdef G4DEBUG_VIS_OGL
    274   printf("\n\nG4OpenGLStoredQtViewer::paintEvent ^^^^^^^^^\n");
    275 #endif
    276257}
    277258
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredViewer.cc

    r1125 r1242  
    126126void G4OpenGLStoredViewer::DrawDisplayLists () {
    127127#ifdef G4DEBUG_VIS_OGL
    128       printf("G4OpenGLStoredViewer::DrawDisplayLists \n");
     128  //      printf("G4OpenGLStoredViewer::DrawDisplayLists \n");
    129129#endif
    130130
     
    134134  size_t nPasses = cutawayUnion? cutaways.size(): 1;
    135135#ifdef G4DEBUG_VIS_OGL
    136   printf("G4OpenGLStoredViewer::DrawDisplayLists");
     136  //  printf("G4OpenGLStoredViewer::DrawDisplayLists");
    137137#endif
    138138  for (size_t i = 0; i < nPasses; ++i) {
    139139#ifdef G4DEBUG_VIS_OGL
    140     printf("+");
     140    //    printf("+");
    141141#endif
    142142
     
    156156    for (size_t i = 0; i < fG4OpenGLStoredSceneHandler.fTOList.size(); ++i) {
    157157#ifdef G4DEBUG_VIS_OGL
    158       printf("-");
     158      //      printf("-");
    159159#endif
    160160      G4OpenGLStoredSceneHandler::TO& to =
     
    179179  }
    180180#ifdef G4DEBUG_VIS_OGL
    181       printf("\n");
     181  //      printf("\n");
    182182#endif
    183183
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc

    r1241 r1242  
    2525//
    2626//
    27 // $Id: G4OpenGLViewer.cc,v 1.59 2009/10/20 12:47:45 lgarnier Exp $
     27// $Id: G4OpenGLViewer.cc,v 1.60 2010/03/10 11:03:46 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    100100  //  glDisable (GL_LINE_SMOOTH);
    101101  //  glDisable (GL_POLYGON_SMOOTH);
    102 }
    103 
    104 G4OpenGLViewer::~G4OpenGLViewer () {
    105 #ifdef G4DEBUG_VIS_OGL
    106   printf("G4OpenGLViewer::~G4OpenGLViewer DELETING \n");
    107 #endif
    108 }
     102
     103}
     104
     105G4OpenGLViewer::~G4OpenGLViewer () {}
    109106
    110107void G4OpenGLViewer::InitializeGLView ()
     
    118115  fWinSize_x = fVP.GetWindowSizeHintX();
    119116  fWinSize_y = fVP.GetWindowSizeHintY();
    120 #ifdef G4DEBUG_VIS_OGL
    121   printf("G4OpenGLViewer::InitializeGLView to W:%d H:%d pt:%d\n",fWinSize_x,fWinSize_y,this);
    122 #endif
    123117
    124118
    125119void G4OpenGLViewer::ClearView () {
    126120#ifdef G4DEBUG_VIS_OGL
    127   printf("G4OpenGLViewer::ClearView\n");
     121  printf("G4OpenGLViewer::ClearView &:%d\n",this);
    128122#endif
    129123  glClearColor (background.GetRed(),
     
    152146    fSizeHasChanged = false;
    153147  }
    154 #ifdef G4DEBUG_VIS_OGL
    155   printf("G4OpenGLViewer::ResizeWindow :W:%d H:%d changed?:%d set:W:%d H:%d pt:%d\n",fWinSize_x,fWinSize_y,fSizeHasChanged,aWidth,aHeight,this);
    156 #endif
    157148}
    158149
     
    166157{
    167158#ifdef G4DEBUG_VIS_OGL
    168   printf("G4OpenGLViewer::ResizeGLView %d %d pt:%d\n",fWinSize_x,fWinSize_y,this);
     159  printf("G4OpenGLViewer::ResizeGLView %d %d &:%d\n",fWinSize_x,fWinSize_y,this);
    169160#endif
    170161  // Check size
     
    172163  glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
    173164
    174   // L.Garnier 01-2010: Some problems with mac 10.6
    175165  if ((dims[0] !=0 ) && (dims[1] !=0)) {
    176166
    177 #ifdef G4DEBUG_VIS_OGL
    178     GLenum err = glGetError();
    179     if (err != GL_NO_ERROR) {                          \
    180       printf("%s: %s at %s:%d\n",                      \
    181              __FUNCTION__,                             \
    182              gluErrorString(err),                      \
    183              __FILE__, __LINE__);                      \
    184       printf("G4OpenGLViewer::ResizeGLView ERRRRR\n");
    185     }
    186     printf("G4OpenGLViewer::ResizeGLView DIM X:%d Y:%d\n",dims[0],dims[1]);
    187 #endif
    188167    if (fWinSize_x > (unsigned)dims[0]) {
    189168      G4cerr << "Try to resize view greater than max X viewport dimension. Desired size "<<dims[0] <<" is resize to "<<  dims[0] << G4endl;
     
    195174    }
    196175  }
    197 //   GLsizei side = fWinSize_x;
    198 //   if (fWinSize_y < fWinSize_x) side = fWinSize_y;
    199  
    200   // SPECIAL CASE if fWinSize_x is even (69 for example)
    201   // Ex : X: 69 Y: 26
    202   // side = 26
    203   // width / 2 = 21,5
    204   // height / 2 = 0
    205   // Should be fixed to closed : 21 0 for ex
    206   // Then size must by change to :
    207   // X:68 Y: 26
    208 
    209   // SPECIAL CASE
    210 //   if ((fWinSize_x - side)%2) {
    211 //     //    fWinSize_x --;
    212 
    213 //     side = fWinSize_x;
    214 //     if (fWinSize_y < fWinSize_x) side = fWinSize_y;
    215 //   }
    216 //   if ((fWinSize_y - side)%2) {
    217 //     //    fWinSize_y --;
    218 
    219 //     side = fWinSize_x;
    220 //     if (fWinSize_y < fWinSize_x) side = fWinSize_y;
    221 //   }
    222  
    223 //   GLint X = (fWinSize_x - side) / 2;
    224 //   GLint Y = (fWinSize_y - side) / 2;
    225  
    226 #ifdef G4DEBUG_VIS_OGL
    227   //  printf("G4OpenGLViewer::ResizeGLView X:%d Y:%d W:%d H:%d --side%d\n",(fWinSize_x - side) / 2,(fWinSize_y - side) / 2,fWinSize_x,fWinSize_y,side);
    228 #endif
    229 
    230   //  glViewport(X, Y, side, side);
     176   
    231177  glViewport(0, 0, fWinSize_x,fWinSize_y); 
    232  
    233 
    234178}
    235179
     
    284228 
    285229  // FIXME
    286 #ifdef G4DEBUG_VIS_OGL
    287   printf("G4OpenGLViewer::SetView Call ResizeGLView VVVVVV sizeX:%d sizeY:%d ratioX:%f ratioY:%f\n",fWinSize_x,fWinSize_y,ratioX,ratioY);
    288 #endif
    289230  ResizeGLView();
    290 #ifdef G4DEBUG_VIS_OGL
    291   printf("G4OpenGLViewer::SetView Call ResizeGLView ^^^^^^\n");
    292 #endif
    293231  //SHOULD SetWindowsSizeHint()...
    294232
     
    301239  if (fVP.GetFieldHalfAngle() == 0.) {
    302240    glOrtho (left, right, bottom, top, pnear, pfar);
    303 #ifdef G4DEBUG_VIS_OGL
    304     printf("G4OpenGLViewer::SetView glOrtho %f %f %f %f %f %f\n",left, right, bottom, top, pnear, pfar);
    305 #endif
    306241  }
    307242  else {
     
    567502  }
    568503
     504#ifdef G4DEBUG_VIS_OGL
     505  printf("G4OpenGLViewer::printEPS END\n");
     506#endif
    569507}
    570508
     
    575513bool G4OpenGLViewer::printNonVectoredEPS () {
    576514
     515
    577516  int width = getRealPrintSizeX();
    578517  int height = getRealPrintSizeY();
    579518
    580519#ifdef G4DEBUG_VIS_OGL
    581   printf("G4OpenGLViewer::printNonVectoredEPS file:%s Vec:%d X:%d Y:%d col:%d\n",getRealPrintFilename().c_str(),fVectoredPs,width,height,fPrintColour);
     520  printf("G4OpenGLViewer::printNonVectoredEPS file:%s Vec:%d X:%d Y:%d col:%d fWinX:%d fWinY:%d\n",getRealPrintFilename().c_str(),fVectoredPs,width,height,fPrintColour,fWinSize_x,fWinSize_y);
    582521#endif
    583522  FILE* fp;
     
    671610  fGL2PSAction->setFileName(getRealPrintFilename().c_str());
    672611  // try to resize
    673   int X = fWinSize_x;
    674   int Y = fWinSize_y;
    675 
    676   fWinSize_x = width;
    677   fWinSize_y = height;
     612   int X = fWinSize_x;
     613   int Y = fWinSize_y;
     614
     615   fWinSize_x = width;
     616   fWinSize_y = height;
     617#ifdef G4DEBUG_VIS_OGL
     618  printf("G4OpenGLViewer::printgl2PS VVVV %d %d\n",getRealPrintSizeX(),getRealPrintSizeY());
     619#endif
     620  // Laurent G. 16/03/10 : Not the good way to do.
     621  // We should draw in a new offscreen context instead of
     622  // resizing and drawing in current window...
     623  // This should be solve when we will do an offscreen method
     624  // to render OpenGL
     625  // See :
     626  // http://developer.apple.com/Mac/library/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_offscreen/opengl_offscreen.html
     627  // http://www.songho.ca/opengl/gl_fbo.html
     628
    678629  ResizeGLView();
    679630  if (fGL2PSAction->enableFileWriting()) {
    680631
     632    // Set the viewport
     633    //    fGL2PSAction->setViewport(0, 0, getRealPrintSizeX(),getRealPrintSizeY()); 
    681634    // By default, we choose the line width (trajectories...)
    682635    fGL2PSAction->setLineWidth(1);
    683636    // By default, we choose the point size (markers...)
    684    
    685 #ifdef G4DEBUG_VIS_OGL
    686     //  printf("G4OpenGLViewer::printGl2PS marker size:%f\n",    GetSceneHandler()->GetMarkerSize());
    687 #endif
    688 #ifdef G4DEBUG_VIS_OGL
    689   //  printf("G4OpenGLViewer::printGl2PS marker2 size:%f\n",fpViewer -> GetViewParameters ()->GetDefaultMarker ().GetScreenSize());
    690 #endif
    691     //    if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) {
    692     //      fGL2PSAction->setPointSize(fpViewer -> GetViewParameters ()->GetDefaultMarker ().GetScreenSize());
    693     //    } else {
    694       fGL2PSAction->setPointSize(2);
    695       //    }
     637    fGL2PSAction->setPointSize(2);
     638
    696639    DrawView ();
    697640    fGL2PSAction->disableFileWriting();
     
    700643  fWinSize_x = X;
    701644  fWinSize_y = Y;
     645#ifdef G4DEBUG_VIS_OGL
     646  printf("G4OpenGLViewer::printgl2PS 22222 %d %d \n",fWinSize_x,fWinSize_y);
     647#endif
    702648  ResizeGLView();
     649  DrawView ();
     650#ifdef G4DEBUG_VIS_OGL
     651  printf("G4OpenGLViewer::printgl2PS ^^^^\n");
     652#endif
    703653
    704654  // Reset for next time (useful is size change)
  • trunk/source/visualization/externals/gl2ps/include/G4OpenGL2PSAction.hh

    r1038 r1242  
    4949 void setLineWidth(int);
    5050 void setPointSize(int);
     51 void setViewport(int,int,int,int);
     52
    5153
    5254protected:
  • trunk/source/visualization/externals/gl2ps/src/G4OpenGL2PSAction.cc

    r1228 r1242  
    7676
    7777//////////////////////////////////////////////////////////////////////////////
     78void G4OpenGL2PSAction::setViewport(
     79int a
     80,int b
     81,int winSizeX
     82,int winSizeY
     83)
     84//////////////////////////////////////////////////////////////////////////////
     85//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
     86{
     87  fViewport[0] = a;
     88  fViewport[1] = b;
     89  fViewport[2] = winSizeX;
     90  fViewport[3] = winSizeY;
     91}
     92
     93//////////////////////////////////////////////////////////////////////////////
    7894void G4OpenGL2PSAction::setFileName(
    7995 const char* aFileName
  • trunk/source/visualization/management/GNUmakefile

    r1241 r1242  
    1111# For debug mode
    1212# CPPFLAGS += -DG4DEBUG_VIS_MANAGEMENT
     13CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1
     14CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2
     15
    1316
    1417GLOBLIBS  = libG4modeling.lib
  • trunk/source/visualization/management/History

    r1241 r1242  
    2626History file for visualization management sub-category
    2727------------------------------------------------------
     289th March 2010 Laurent Garnier
     29 - G4OpenGLViewer : Fix clipping when resizing non square size windows
     30 
    28318th March 2010 Laurent Garnier
    2932-G4VisManager.cc : Add protection against null pointer
  • trunk/source/visualization/management/src/G4VisManager.cc

    r1241 r1242  
    477477    fpSceneHandler -> BeginPrimitives (objectTransform);
    478478    fpSceneHandler -> AddPrimitive (line);
     479#ifndef G4VIS_BUILD_OPTIMISE_2
    479480    fpSceneHandler -> EndPrimitives ();
     481#endif
    480482  }
    481483}
     
    485487  if (IsValidView ()) {
    486488    ClearTransientStoreIfMarked();
     489#ifndef G4VIS_BUILD_OPTIMISE_2
     490    // FIXME : test
    487491    fpSceneHandler -> BeginPrimitives (objectTransform);
     492#endif
    488493    fpSceneHandler -> AddPrimitive (polymarker);
     494    // FIXME : test
     495#ifndef G4VIS_BUILD_OPTIMISE_2
    489496    fpSceneHandler -> EndPrimitives ();
     497#endif
    490498  }
    491499}
     
    515523  if (IsValidView ()) {
    516524    ClearTransientStoreIfMarked();
     525    // FIXME : test
     526#ifndef G4VIS_BUILD_OPTIMISE_2
    517527    fpSceneHandler -> BeginPrimitives (objectTransform);
    518528    fpSceneHandler -> AddPrimitive (text);
     529#endif
    519530    fpSceneHandler -> EndPrimitives ();
    520531  }
  • trunk/source/visualization/modeling/GNUmakefile

    r1171 r1242  
    1717
    1818include $(G4INSTALL)/config/architecture.gmk
     19
     20#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1
     21#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2
     22#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_3
    1923
    2024CPPFLAGS += -I$(G4BASE)/global/management/include
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawerUtils.cc

    r1171 r1242  
    3333#include "G4Polyline.hh"
    3434#include "G4Polymarker.hh"
     35#include "G4Text.hh"
    3536#include "G4VTrajectory.hh"
    3637#include "G4VTrajectoryPoint.hh"
     
    5657        for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
    5758          const G4ThreeVector pos((*auxiliaries)[iAux]);
    58           trajectoryLine.push_back(pos);
    59           auxiliaryPoints.push_back(pos);
    60         }
     59#ifdef G4VIS_BUILD_OPTIMISE_1
     60          if (trajectoryLine.size() >0) {
     61            if (pos != trajectoryLine[trajectoryLine.size()-1]) {
     62              trajectoryLine.push_back(pos);
     63              auxiliaryPoints.push_back(pos);
     64            }
     65         } else {
     66#endif
     67            trajectoryLine.push_back(pos);
     68            auxiliaryPoints.push_back(pos);
     69#ifdef G4VIS_BUILD_OPTIMISE_1
     70          }
     71#endif
     72        }
    6173      }
    6274      const G4ThreeVector pos(aTrajectoryPoint->GetPosition());
    63       trajectoryLine.push_back(pos);
    64       stepPoints.push_back(pos);
    65     }   
     75#ifdef G4VIS_BUILD_OPTIMISE_1
     76      if (trajectoryLine.size() >0) {
     77        if (pos != trajectoryLine[trajectoryLine.size()-1]) {
     78          trajectoryLine.push_back(pos);
     79          stepPoints.push_back(pos);
     80        }
     81      } else {
     82#endif
     83        trajectoryLine.push_back(pos);
     84        stepPoints.push_back(pos);
     85#ifdef G4VIS_BUILD_OPTIMISE_1
     86      }
     87#endif
     88    }
    6689  }
    6790
     
    274297
    275298      pVVisManager->Draw(stepPoints);
     299#ifdef G4VIS_BUILD_OPTIMISE_2
     300      G4Text text = G4Text("");
     301      pVVisManager->Draw(text);
     302#endif
    276303    }
    277304  }
Note: See TracChangeset for help on using the changeset viewer.