File indexing completed on 2025-01-18 09:58:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
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
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
0139
0140 void setExportSize(G4int,G4int);
0141
0142
0143
0144
0145 bool setExportFilename(G4String name,G4bool inc = true);
0146
0147
0148
0149
0150 std::string getRealPrintFilename();
0151 unsigned int getWinWidth() const;
0152 unsigned int getWinHeight() const;
0153 G4bool sizeHasChanged();
0154
0155 GLdouble getSceneNearWidth();
0156 GLdouble getSceneFarWidth();
0157 GLdouble getSceneDepth();
0158 void addExportImageFormat(std::string format);
0159
0160 G4bool isGl2psWriting();
0161 G4bool isFramebufferReady();
0162
0163 void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
0164 GLint viewport[4]);
0165
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
0172 void g4GlOrtho (GLdouble left, GLdouble right,
0173 GLdouble bottom, GLdouble top,
0174 GLdouble near, GLdouble far);
0175
0176 void g4GlFrustum (GLdouble left, GLdouble right,
0177 GLdouble bottom, GLdouble top,
0178 GLdouble near, GLdouble far);
0179
0180
0181 G4bool fPrintColour;
0182 G4bool fVectoredPs;
0183
0184 G4OpenGLSceneHandler& fOpenGLSceneHandler;
0185 G4Colour background;
0186 G4bool
0187 transparency_enabled,
0188 antialiasing_enabled,
0189 haloing_enabled;
0190 G4gl2ps* fGL2PSAction;
0191
0192 G4double fRot_sens;
0193 G4double fPan_sens;
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
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
0224
0225 bool printVectoredEPS();
0226
0227
0228 bool fIsGettingPickInfos;
0229
0230
0231 };
0232
0233 #endif