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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 //
 28 // 
 29 // Andrew Walkden  27th March 1996
 30 // OpenGL viewer - opens window, hard copy, etc.
 31 
 32 #ifndef G4OPENGLVIEWER_HH
 33 #define G4OPENGLVIEWER_HH
 34 
 35 #include "G4VViewer.hh"
 36 #include "G4OpenGL.hh"
 37 
 38 class G4OpenGLSceneHandler;
 39 class G4gl2ps;
 40 class G4Text;
 41 
 42 class G4OpenGLViewerPickMap {
 43   public :
 44   inline void setName(G4String n) {
 45     fName = n;
 46   }
 47   
 48   inline void setHitNumber(G4int n) {
 49     fHitNumber = n;
 50   }
 51 
 52   inline void setSubHitNumber(G4int n) {
 53     fSubHitNumber = n;
 54   }
 55   inline void setPickName(G4int n) {
 56     fPickName= n;
 57   }
 58 
 59   inline void addAttributes(G4String att) {
 60     fAttributes.push_back(att);
 61   }
 62 
 63 
 64   inline G4String getName() {
 65     return fName;
 66   }
 67   inline G4int getHitNumber() {
 68     return fHitNumber;
 69   }
 70 
 71   inline G4int getSubHitNumber() {
 72     return fSubHitNumber;
 73   }
 74 
 75   inline G4int getPickName() {
 76     return fPickName;
 77   }
 78 
 79   inline std::vector <G4String > getAttributes() {
 80     return fAttributes;
 81   }
 82 
 83   G4String print();
 84   
 85   private :
 86   G4String fName;
 87   G4int fHitNumber;
 88   G4int fSubHitNumber;
 89   G4int fPickName;
 90   std::vector <G4String > fAttributes;
 91 
 92 };
 93 
 94 // Base class for various OpenGLView classes.
 95 class G4OpenGLViewer: virtual public G4VViewer {
 96 
 97   friend class G4OpenGLSceneHandler;
 98   friend class G4OpenGLImmediateSceneHandler;
 99   friend class G4OpenGLStoredSceneHandler;
100   friend class G4OpenGLFileSceneHandler;
101   friend class G4OpenGLViewerMessenger;
102 
103 public:
104   virtual void ClearView  ();
105   void ClearViewWithoutFlush ();
106 
107   virtual bool exportImage(std::string name="", int width=-1, int height=-1);
108   bool setExportImageFormat(std::string format,bool quiet = false);
109 
110 protected:
111   G4OpenGLViewer (G4OpenGLSceneHandler& scene);
112   virtual ~G4OpenGLViewer ();
113 
114 private:
115   G4OpenGLViewer(const G4OpenGLViewer&);
116   G4OpenGLViewer& operator= (const G4OpenGLViewer&);
117 
118 protected:
119   virtual void SetView    ();
120   virtual void ResetView ();
121 
122   virtual void DrawText(const G4Text&);
123   void ChangePointSize(G4double size);
124   void ChangeLineWidth(G4double width);
125   void HaloingFirstPass ();
126   void HaloingSecondPass ();
127   void HLRFirstPass ();
128   void HLRSecondPass ();
129   void HLRThirdPass ();
130   void InitializeGLView ();
131   void ResizeGLView();
132   void ResizeWindow(unsigned int, unsigned int);
133   virtual G4String Pick(GLdouble x, GLdouble y);
134   const std::vector < G4OpenGLViewerPickMap* > & GetPickDetails(GLdouble x, GLdouble y);
135   virtual void CreateFontLists () {}
136   void rotateScene (G4double dx, G4double dy);
137   void rotateSceneToggle (G4double dx, G4double dy);
138 //////////////////////////////Vectored PostScript production functions///
139   // print EPS file. Depending of fVectoredPs, it will print Vectored or not
140   void setExportSize(G4int,G4int);
141   // set the new print size. 
142   // -1 means 'print size' = 'window size'
143   // Setting size greater than max OpenGL viewport size will set the size to
144   // maximum
145   bool setExportFilename(G4String name,G4bool inc = true);
146   // set export filename.
147   // if inc, then the filename will be increment by one each time
148   // try to guesss the correct format according to the extention
149 
150   std::string getRealPrintFilename();
151   unsigned int getWinWidth() const;
152   unsigned int getWinHeight() const;
153   G4bool sizeHasChanged();
154   // return true if size has change since last redraw
155   GLdouble getSceneNearWidth();
156   GLdouble getSceneFarWidth();
157   GLdouble getSceneDepth();
158   void addExportImageFormat(std::string format);
159   // add a image format to the available export format list
160   G4bool isGl2psWriting();
161   G4bool isFramebufferReady();
162   
163   void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
164                        GLint viewport[4]);
165   // MESA implementation of gluPickMatrix
166   
167   void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
168                    GLdouble centerx, GLdouble centery, GLdouble
169                    centerz,
170                    GLdouble upx, GLdouble upy, GLdouble upz );
171   // MESA implementation of gluLookAt
172   void g4GlOrtho (GLdouble left, GLdouble right,
173                   GLdouble bottom, GLdouble top,
174                   GLdouble near, GLdouble far);
175   // Redefinition on glOrtho to solve precision issues
176   void g4GlFrustum (GLdouble left, GLdouble right,
177                   GLdouble bottom, GLdouble top,
178                   GLdouble near, GLdouble far);
179   // Redefinition on glFrustum to solve precision issues
180 
181   bool IsGettingPickInfos() const {return fIsGettingPickInfos;}
182 
183   G4bool                            fPrintColour;
184   G4bool                            fVectoredPs;
185 
186   G4OpenGLSceneHandler& fOpenGLSceneHandler;
187   G4Colour background;      //the OpenGL clear colour
188   G4bool
189     transparency_enabled,   //is alpha blending enabled?
190     antialiasing_enabled,   //is antialiasing enabled?
191     haloing_enabled;        //is haloing enabled for wireframe?
192   G4gl2ps* fGL2PSAction;
193 
194   G4double     fRot_sens;        // Rotation sensibility in degrees
195   G4double     fPan_sens;        // Translation sensibility
196   unsigned int fWinSize_x;
197   unsigned int fWinSize_y;
198   std::vector < std::string > fExportImageFormatVector;
199   std::string fDefaultExportImageFormat;
200   std::string fExportImageFormat;
201   int fExportFilenameIndex;
202   G4int fPrintSizeX;
203   G4int fPrintSizeY;
204 
205 
206 private :
207   G4float fPointSize;
208   G4String fExportFilename;
209   G4String fDefaultExportFilename;
210   G4bool fSizeHasChanged;
211   int fGl2psDefaultLineWith;
212   int fGl2psDefaultPointSize;
213   bool fGlViewInitialized;
214   
215   // size of the OpenGL frame
216   void rotateSceneThetaPhi(G4double dx, G4double dy);
217   void rotateSceneInViewDirection (G4double dx, G4double dy);
218   bool printGl2PS();
219   G4int getRealExportWidth();
220   G4int getRealExportHeight();
221   GLubyte* grabPixels (int inColor,
222            unsigned int width,
223            unsigned int height);
224   bool printNonVectoredEPS ();
225   // print non vectored EPS files
226 
227   bool printVectoredEPS();
228   // print vectored EPS files
229   
230   bool fIsGettingPickInfos;
231   // Block SetView() during picking
232   
233 };
234 
235 #endif
236