Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:47

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // 
0029 // Andrew Walkden  27th March 1996
0030 // OpenGL viewer - opens window, hard copy, etc.
0031 
0032 #ifndef G4OPENGLVIEWER_HH
0033 #define G4OPENGLVIEWER_HH
0034 
0035 #include "G4VViewer.hh"
0036 #include "G4OpenGL.hh"
0037 
0038 class G4OpenGLSceneHandler;
0039 class G4gl2ps;
0040 class G4Text;
0041 
0042 class G4OpenGLViewerPickMap {
0043   public :
0044   inline void setName(G4String n) {
0045     fName = n;
0046   }
0047   
0048   inline void setHitNumber(G4int n) {
0049     fHitNumber = n;
0050   }
0051 
0052   inline void setSubHitNumber(G4int n) {
0053     fSubHitNumber = n;
0054   }
0055   inline void setPickName(G4int n) {
0056     fPickName= n;
0057   }
0058 
0059   inline void addAttributes(G4String att) {
0060     fAttributes.push_back(att);
0061   }
0062 
0063 
0064   inline G4String getName() {
0065     return fName;
0066   }
0067   inline G4int getHitNumber() {
0068     return fHitNumber;
0069   }
0070 
0071   inline G4int getSubHitNumber() {
0072     return fSubHitNumber;
0073   }
0074 
0075   inline G4int getPickName() {
0076     return fPickName;
0077   }
0078 
0079   inline std::vector <G4String > getAttributes() {
0080     return fAttributes;
0081   }
0082 
0083   G4String print();
0084   
0085   private :
0086   G4String fName;
0087   G4int fHitNumber;
0088   G4int fSubHitNumber;
0089   G4int fPickName;
0090   std::vector <G4String > fAttributes;
0091 
0092 };
0093 
0094 // Base class for various OpenGLView classes.
0095 class G4OpenGLViewer: virtual public G4VViewer {
0096 
0097   friend class G4OpenGLSceneHandler;
0098   friend class G4OpenGLImmediateSceneHandler;
0099   friend class G4OpenGLStoredSceneHandler;
0100   friend class G4OpenGLFileSceneHandler;
0101   friend class G4OpenGLViewerMessenger;
0102 
0103 public:
0104   void ClearView  ();
0105   void ClearViewWithoutFlush ();
0106 
0107   virtual bool exportImage(std::string name="", int width=-1, int height=-1);
0108   bool setExportImageFormat(std::string format,bool quiet = false);
0109 
0110 protected:
0111   G4OpenGLViewer (G4OpenGLSceneHandler& scene);
0112   virtual ~G4OpenGLViewer ();
0113 
0114 private:
0115   G4OpenGLViewer(const G4OpenGLViewer&);
0116   G4OpenGLViewer& operator= (const G4OpenGLViewer&);
0117 
0118 protected:
0119   void SetView    ();
0120   void ResetView ();
0121 
0122   virtual void DrawText(const G4Text&);
0123   void ChangePointSize(G4double size);
0124   void ChangeLineWidth(G4double width);
0125   void HaloingFirstPass ();
0126   void HaloingSecondPass ();
0127   void HLRFirstPass ();
0128   void HLRSecondPass ();
0129   void HLRThirdPass ();
0130   void InitializeGLView ();
0131   void ResizeGLView();
0132   void ResizeWindow(unsigned int, unsigned int);
0133   virtual G4String Pick(GLdouble x, GLdouble y);
0134   const std::vector < G4OpenGLViewerPickMap* > & GetPickDetails(GLdouble x, GLdouble y);
0135   virtual void CreateFontLists () {}
0136   void rotateScene (G4double dx, G4double dy);
0137   void rotateSceneToggle (G4double dx, G4double dy);
0138 //////////////////////////////Vectored PostScript production functions///
0139   // print EPS file. Depending of fVectoredPs, it will print Vectored or not
0140   void setExportSize(G4int,G4int);
0141   // set the new print size. 
0142   // -1 means 'print size' = 'window size'
0143   // Setting size greater than max OpenGL viewport size will set the size to
0144   // maximum
0145   bool setExportFilename(G4String name,G4bool inc = true);
0146   // set export filename.
0147   // if inc, then the filename will be increment by one each time
0148   // try to guesss the correct format according to the extention
0149 
0150   std::string getRealPrintFilename();
0151   unsigned int getWinWidth() const;
0152   unsigned int getWinHeight() const;
0153   G4bool sizeHasChanged();
0154   // return true if size has change since last redraw
0155   GLdouble getSceneNearWidth();
0156   GLdouble getSceneFarWidth();
0157   GLdouble getSceneDepth();
0158   void addExportImageFormat(std::string format);
0159   // add a image format to the available export format list
0160   G4bool isGl2psWriting();
0161   G4bool isFramebufferReady();
0162   
0163   void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
0164                        GLint viewport[4]);
0165   // MESA implementation of gluPickMatrix
0166   
0167   void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
0168                    GLdouble centerx, GLdouble centery, GLdouble
0169                    centerz,
0170                    GLdouble upx, GLdouble upy, GLdouble upz );
0171   // MESA implementation of gluLookAt
0172   void g4GlOrtho (GLdouble left, GLdouble right,
0173                   GLdouble bottom, GLdouble top,
0174                   GLdouble near, GLdouble far);
0175   // Redefinition on glOrtho to solve precision issues
0176   void g4GlFrustum (GLdouble left, GLdouble right,
0177                   GLdouble bottom, GLdouble top,
0178                   GLdouble near, GLdouble far);
0179   // Redefinition on glFrustum to solve precision issues
0180 
0181   G4bool                            fPrintColour;
0182   G4bool                            fVectoredPs;
0183 
0184   G4OpenGLSceneHandler& fOpenGLSceneHandler;
0185   G4Colour background;      //the OpenGL clear colour
0186   G4bool
0187     transparency_enabled,   //is alpha blending enabled?
0188     antialiasing_enabled,   //is antialiasing enabled?
0189     haloing_enabled;        //is haloing enabled for wireframe?
0190   G4gl2ps* fGL2PSAction;
0191 
0192   G4double     fRot_sens;        // Rotation sensibility in degrees
0193   G4double     fPan_sens;        // Translation sensibility
0194   unsigned int fWinSize_x;
0195   unsigned int fWinSize_y;
0196   std::vector < std::string > fExportImageFormatVector;
0197   std::string fDefaultExportImageFormat;
0198   std::string fExportImageFormat;
0199   int fExportFilenameIndex;
0200   G4int fPrintSizeX;
0201   G4int fPrintSizeY;
0202 
0203 
0204 private :
0205   G4float fPointSize;
0206   G4String fExportFilename;
0207   G4String fDefaultExportFilename;
0208   G4bool fSizeHasChanged;
0209   int fGl2psDefaultLineWith;
0210   int fGl2psDefaultPointSize;
0211   bool fGlViewInitialized;
0212   
0213   // size of the OpenGL frame
0214   void rotateSceneThetaPhi(G4double dx, G4double dy);
0215   void rotateSceneInViewDirection (G4double dx, G4double dy);
0216   bool printGl2PS();
0217   G4int getRealExportWidth();
0218   G4int getRealExportHeight();
0219   GLubyte* grabPixels (int inColor,
0220                unsigned int width,
0221                unsigned int height);
0222   bool printNonVectoredEPS ();
0223   // print non vectored EPS files
0224 
0225   bool printVectoredEPS();
0226   // print vectored EPS files
0227   
0228   bool fIsGettingPickInfos;
0229   // Block SetView() during picking
0230   
0231 };
0232 
0233 #endif