G4OpenGLViewer.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // Andrew Walkden  27th March 1996
00031 // OpenGL viewer - opens window, hard copy, etc.
00032 
00033 #ifdef G4VIS_BUILD_OPENGL_DRIVER
00034 
00035 #ifndef G4OPENGLVIEWER_HH
00036 #define G4OPENGLVIEWER_HH
00037 
00038 #include "G4VViewer.hh"
00039 #include "G4OpenGL.hh"
00040 
00041 class G4OpenGLSceneHandler;
00042 class G4OpenGL2PSAction;
00043 class G4Text;
00044 
00045 // Base class for various OpenGLView classes.
00046 class G4OpenGLViewer: virtual public G4VViewer {
00047 
00048   friend class G4OpenGLSceneHandler;
00049   friend class G4OpenGLImmediateSceneHandler;
00050   friend class G4OpenGLStoredSceneHandler;
00051   friend class G4OpenGLFileSceneHandler;
00052   friend class G4OpenGLViewerMessenger;
00053 
00054 public:
00055   void ClearView  ();
00057   void printEPS();
00058 
00059 protected:
00060   G4OpenGLViewer (G4OpenGLSceneHandler& scene);
00061   virtual ~G4OpenGLViewer ();
00062 
00063 private:
00064   G4OpenGLViewer(const G4OpenGLViewer&);
00065   G4OpenGLViewer& operator= (const G4OpenGLViewer&);
00066 
00067 protected:
00068   void SetView    ();
00069   void ResetView ();
00070 
00071   virtual void DrawText(const G4Text&);
00072   void ChangePointSize(G4double size);
00073   void ChangeLineWidth(G4double width);
00074   void HaloingFirstPass ();
00075   void HaloingSecondPass ();
00076   void HLRFirstPass ();
00077   void HLRSecondPass ();
00078   void HLRThirdPass ();
00079   void InitializeGLView ();
00080   void ResizeGLView();
00081   void ResizeWindow(unsigned int, unsigned int);
00082   void Pick(GLdouble x, GLdouble y);
00083   virtual void CreateFontLists () {}
00084   void rotateScene (G4double dx, G4double dy);
00085   void rotateSceneToggle (G4double dx, G4double dy);
00087   // print EPS file. Depending of fVectoredPs, it will print Vectored or not
00088   void setPrintSize(G4int,G4int);
00089   // set the new print size. 
00090   // -1 means 'print size' = 'window size'
00091   // Setting size greater than max OpenGL viewport size will set the size to
00092   // maximum
00093   void setPrintFilename(G4String name,G4bool inc);
00094   // set print filename. 
00095   // if inc, then the filename will be increment by one each time
00096   std::string getRealPrintFilename();
00097   unsigned int getWinWidth();
00098   unsigned int getWinHeight();
00099   G4bool sizeHasChanged();
00100   // return true if size has change since last redraw
00101   GLdouble getSceneNearWidth();
00102   GLdouble getSceneFarWidth();
00103   GLdouble getSceneDepth();
00104   G4bool isGl2psWriting();
00105   G4bool                            fPrintColour;
00106   G4bool                            fVectoredPs;
00107 
00108   G4OpenGLSceneHandler& fOpenGLSceneHandler;
00109   G4Colour background;      //the OpenGL clear colour
00110   G4bool
00111     transparency_enabled,   //is alpha blending enabled?
00112     antialiasing_enabled,   //is antialiasing enabled?
00113     haloing_enabled;        //is haloing enabled for wireframe?
00114   G4double fStartTime, fEndTime;  // Time range (e.g., for trajectory steps).
00115   G4double fFadeFactor;  // 0: no fade; 1: maximum fade with time within range.
00116   G4bool fDisplayHeadTime;  // Display head time (fEndTime) in 2D text.
00117   G4double fDisplayHeadTimeX, fDisplayHeadTimeY;  // 2D screen coords.
00118   G4double fDisplayHeadTimeSize;  // Screen size.
00119   G4double fDisplayHeadTimeRed, fDisplayHeadTimeGreen, fDisplayHeadTimeBlue;
00120   G4bool fDisplayLightFront;// Display light front at head time originating at
00121   G4double fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ,
00122     fDisplayLightFrontT;
00123   G4double fDisplayLightFrontRed, fDisplayLightFrontGreen, fDisplayLightFrontBlue;
00124   G4OpenGL2PSAction* fGL2PSAction;
00125 
00126   G4double     fRot_sens;        // Rotation sensibility in degrees
00127   G4double     fPan_sens;        // Translation sensibility
00128 
00129 private :
00130   static G4int                             fPrintSizeX;
00131   static G4int                             fPrintSizeY;
00132   static G4String                          fPrintFilename;
00133   static int                               fPrintFilenameIndex;
00134   unsigned int fWinSize_x, fWinSize_y;
00135   G4float                           fPointSize;
00136   G4bool fSizeHasChanged;
00137   int fGl2psDefaultLineWith;
00138   int fGl2psDefaultPointSize;
00139 
00140   // size of the OpenGL frame
00141   void rotateSceneThetaPhi(G4double dx, G4double dy);
00142   void rotateSceneInViewDirection (G4double dx, G4double dy);
00143   bool printGl2PS();
00144   G4int getRealPrintSizeX();
00145   G4int getRealPrintSizeY();
00146   GLubyte* grabPixels (int inColor,
00147                        unsigned int width,
00148                        unsigned int height);
00149   bool printNonVectoredEPS ();
00150   // print non vectored EPS files
00151 
00152   bool printVectoredEPS();
00153   // print vectored EPS files
00154 };
00155 
00156 #endif
00157 
00158 #endif

Generated on Mon May 27 17:49:11 2013 for Geant4 by  doxygen 1.4.7