[1350] | 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: G4OpenGL2PSAction.cc,v 1.5 2010/04/26 16:28:18 lgarnier Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | #ifdef G4VIS_BUILD_OPENGL_DRIVER |
---|
| 33 | #define G4VIS_BUILD_OPENGL_GL2PS |
---|
| 34 | #endif |
---|
| 35 | #ifdef G4VIS_BUILD_OI_DRIVER |
---|
| 36 | #define G4VIS_BUILD_OPENGL_GL2PS |
---|
| 37 | #endif |
---|
| 38 | |
---|
| 39 | #ifdef G4VIS_BUILD_OPENGL_GL2PS |
---|
| 40 | |
---|
| 41 | #include "G4OpenGL2PSAction.hh" |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | G4OpenGL2PSAction::G4OpenGL2PSAction( |
---|
| 45 | ) |
---|
| 46 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 47 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 48 | { |
---|
| 49 | fFileName = ""; |
---|
| 50 | fFile = 0; |
---|
| 51 | fViewport[0] = 0; |
---|
| 52 | fViewport[1] = 0; |
---|
| 53 | fViewport[2] = 0; |
---|
| 54 | fViewport[3] = 0; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 58 | void G4OpenGL2PSAction::setLineWidth( |
---|
| 59 | int width |
---|
| 60 | ) |
---|
| 61 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 62 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 63 | { |
---|
| 64 | gl2psLineWidth( width ); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 68 | void G4OpenGL2PSAction::setPointSize( |
---|
| 69 | int size |
---|
| 70 | ) |
---|
| 71 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 72 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 73 | { |
---|
| 74 | gl2psPointSize( size ); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 78 | void G4OpenGL2PSAction::setViewport( |
---|
| 79 | int a |
---|
| 80 | ,int b |
---|
| 81 | ,int winSizeX |
---|
| 82 | ,int winSizeY |
---|
| 83 | ) |
---|
| 84 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 85 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 86 | { |
---|
| 87 | fViewport[0] = a; |
---|
| 88 | fViewport[1] = b; |
---|
| 89 | fViewport[2] = winSizeX; |
---|
| 90 | fViewport[3] = winSizeY; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 94 | void G4OpenGL2PSAction::setFileName( |
---|
| 95 | const char* aFileName |
---|
| 96 | ) |
---|
| 97 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 98 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 99 | { |
---|
| 100 | fFileName = aFileName; |
---|
| 101 | } |
---|
| 102 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 103 | bool G4OpenGL2PSAction::enableFileWriting( |
---|
| 104 | ) |
---|
| 105 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 106 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 107 | { |
---|
| 108 | fFile = ::fopen(fFileName,"w"); |
---|
| 109 | if(!fFile) { |
---|
| 110 | return false; |
---|
| 111 | } |
---|
| 112 | G4gl2psBegin(); |
---|
| 113 | return true; |
---|
| 114 | } |
---|
| 115 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 116 | void G4OpenGL2PSAction::disableFileWriting( |
---|
| 117 | ) |
---|
| 118 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 119 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 120 | { |
---|
| 121 | gl2psEndPage(); |
---|
| 122 | ::fclose(fFile); |
---|
| 123 | fFile = 0; |
---|
| 124 | } |
---|
| 125 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 126 | bool G4OpenGL2PSAction::fileWritingEnabled( |
---|
| 127 | ) const |
---|
| 128 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 129 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 130 | { |
---|
| 131 | return (fFile?true:false); |
---|
| 132 | } |
---|
| 133 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 134 | void G4OpenGL2PSAction::G4gl2psBegin( |
---|
| 135 | ) |
---|
| 136 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 137 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 138 | { |
---|
| 139 | if(!fFile) return; |
---|
| 140 | int options = GL2PS_OCCLUSION_CULL | |
---|
| 141 | GL2PS_BEST_ROOT | GL2PS_SILENT | GL2PS_DRAW_BACKGROUND; |
---|
| 142 | int sort = GL2PS_BSP_SORT; |
---|
| 143 | //int sort = GL2PS_SIMPLE_SORT; |
---|
| 144 | GLint buffsize = 0; |
---|
| 145 | buffsize += 1024*1024; |
---|
| 146 | |
---|
| 147 | glGetIntegerv(GL_VIEWPORT,fViewport); |
---|
| 148 | |
---|
| 149 | gl2psBeginPage("title","HEPVis::G4OpenGL2PSAction", |
---|
| 150 | fViewport, |
---|
| 151 | GL2PS_EPS, |
---|
| 152 | sort, |
---|
| 153 | options, |
---|
| 154 | GL_RGBA,0, NULL,0,0,0, |
---|
| 155 | buffsize, |
---|
| 156 | fFile,fFileName); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | #endif |
---|