Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLViewer.hh
Go to the documentation of this file.
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 // $Id$
28 //
29 //
30 // Andrew Walkden 27th March 1996
31 // OpenGL viewer - opens window, hard copy, etc.
32 
33 #ifdef G4VIS_BUILD_OPENGL_DRIVER
34 
35 #ifndef G4OPENGLVIEWER_HH
36 #define G4OPENGLVIEWER_HH
37 
38 #include "G4VViewer.hh"
39 #include "G4OpenGL.hh"
40 
41 class G4OpenGLSceneHandler;
42 class G4OpenGL2PSAction;
43 class G4Text;
44 
45 // Base class for various OpenGLView classes.
46 class G4OpenGLViewer: virtual public G4VViewer {
47 
48  friend class G4OpenGLSceneHandler;
49  friend class G4OpenGLImmediateSceneHandler;
50  friend class G4OpenGLStoredSceneHandler;
51  friend class G4OpenGLFileSceneHandler;
52  friend class G4OpenGLViewerMessenger;
53 
54 public:
55  void ClearView ();
57  void printEPS();
58 
59 protected:
60  G4OpenGLViewer (G4OpenGLSceneHandler& scene);
61  virtual ~G4OpenGLViewer ();
62 
63 private:
64  G4OpenGLViewer(const G4OpenGLViewer&);
65  G4OpenGLViewer& operator= (const G4OpenGLViewer&);
66 
67 protected:
68  void SetView ();
69  void ResetView ();
70 
71  virtual void DrawText(const G4Text&);
72  void ChangePointSize(G4double size);
73  void ChangeLineWidth(G4double width);
74  void HaloingFirstPass ();
75  void HaloingSecondPass ();
76  void HLRFirstPass ();
77  void HLRSecondPass ();
78  void HLRThirdPass ();
79  void InitializeGLView ();
80  void ResizeGLView();
81  void ResizeWindow(unsigned int, unsigned int);
82  void Pick(GLdouble x, GLdouble y);
83  virtual void CreateFontLists () {}
84  void rotateScene (G4double dx, G4double dy);
85  void rotateSceneToggle (G4double dx, G4double dy);
87  // print EPS file. Depending of fVectoredPs, it will print Vectored or not
88  void setPrintSize(G4int,G4int);
89  // set the new print size.
90  // -1 means 'print size' = 'window size'
91  // Setting size greater than max OpenGL viewport size will set the size to
92  // maximum
93  void setPrintFilename(G4String name,G4bool inc);
94  // set print filename.
95  // if inc, then the filename will be increment by one each time
96  std::string getRealPrintFilename();
97  unsigned int getWinWidth();
98  unsigned int getWinHeight();
99  G4bool sizeHasChanged();
100  // return true if size has change since last redraw
101  GLdouble getSceneNearWidth();
102  GLdouble getSceneFarWidth();
103  GLdouble getSceneDepth();
104  G4bool isGl2psWriting();
105  G4bool fPrintColour;
106  G4bool fVectoredPs;
107 
108  G4OpenGLSceneHandler& fOpenGLSceneHandler;
109  G4Colour background; //the OpenGL clear colour
110  G4bool
111  transparency_enabled, //is alpha blending enabled?
112  antialiasing_enabled, //is antialiasing enabled?
113  haloing_enabled; //is haloing enabled for wireframe?
114  G4double fStartTime, fEndTime; // Time range (e.g., for trajectory steps).
115  G4double fFadeFactor; // 0: no fade; 1: maximum fade with time within range.
116  G4bool fDisplayHeadTime; // Display head time (fEndTime) in 2D text.
117  G4double fDisplayHeadTimeX, fDisplayHeadTimeY; // 2D screen coords.
118  G4double fDisplayHeadTimeSize; // Screen size.
119  G4double fDisplayHeadTimeRed, fDisplayHeadTimeGreen, fDisplayHeadTimeBlue;
120  G4bool fDisplayLightFront;// Display light front at head time originating at
121  G4double fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ,
122  fDisplayLightFrontT;
123  G4double fDisplayLightFrontRed, fDisplayLightFrontGreen, fDisplayLightFrontBlue;
124  G4OpenGL2PSAction* fGL2PSAction;
125 
126  G4double fRot_sens; // Rotation sensibility in degrees
127  G4double fPan_sens; // Translation sensibility
128 
129 private :
130  static G4int fPrintSizeX;
131  static G4int fPrintSizeY;
132  static G4String fPrintFilename;
133  static int fPrintFilenameIndex;
134  unsigned int fWinSize_x, fWinSize_y;
135  G4float fPointSize;
136  G4bool fSizeHasChanged;
137  int fGl2psDefaultLineWith;
138  int fGl2psDefaultPointSize;
139 
140  // size of the OpenGL frame
141  void rotateSceneThetaPhi(G4double dx, G4double dy);
142  void rotateSceneInViewDirection (G4double dx, G4double dy);
143  bool printGl2PS();
144  G4int getRealPrintSizeX();
145  G4int getRealPrintSizeY();
146  GLubyte* grabPixels (int inColor,
147  unsigned int width,
148  unsigned int height);
149  bool printNonVectoredEPS ();
150  // print non vectored EPS files
151 
152  bool printVectoredEPS();
153  // print vectored EPS files
154 };
155 
156 #endif
157 
158 #endif