[562] | 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: G4OpenGLXmStyleCallbacks.cc,v 1.14 2006/06/29 21:20:02 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-08-01-patch-01 $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | // Andrew Walkden 16th April 1997 |
---|
| 32 | // G4OpenGLXmStyleCallbacks : |
---|
| 33 | // Several callback functions used by |
---|
| 34 | // elements of the control panel to |
---|
| 35 | // determine how to visualize the view. |
---|
| 36 | |
---|
| 37 | #ifdef G4VIS_BUILD_OPENGLXM_DRIVER |
---|
| 38 | |
---|
| 39 | #include "G4OpenGLXmViewer.hh" |
---|
| 40 | |
---|
| 41 | void G4OpenGLXmViewer::drawing_style_callback (Widget w, |
---|
| 42 | XtPointer clientData, |
---|
| 43 | XtPointer) |
---|
| 44 | { |
---|
| 45 | G4long choice = (G4long)clientData; |
---|
| 46 | G4OpenGLXmViewer* pView; |
---|
| 47 | XtVaGetValues (XtParent(w), |
---|
| 48 | XmNuserData, &pView, |
---|
| 49 | NULL); |
---|
| 50 | G4ViewParameters::DrawingStyle style; |
---|
| 51 | |
---|
| 52 | switch (choice) { |
---|
| 53 | |
---|
| 54 | case 0: |
---|
| 55 | style = G4ViewParameters::wireframe; |
---|
| 56 | break; |
---|
| 57 | |
---|
| 58 | case 1: |
---|
| 59 | style = G4ViewParameters::hlr; |
---|
| 60 | break; |
---|
| 61 | |
---|
| 62 | case 2: |
---|
| 63 | style = G4ViewParameters::hsr; |
---|
| 64 | break; |
---|
| 65 | |
---|
| 66 | case 3: |
---|
| 67 | style = G4ViewParameters::hlhsr; |
---|
| 68 | break; |
---|
| 69 | |
---|
| 70 | default: |
---|
| 71 | style = G4ViewParameters::wireframe; |
---|
| 72 | G4Exception("Unrecognised case in drawing_style_callback."); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | pView->fVP.SetDrawingStyle (style); |
---|
| 76 | |
---|
| 77 | pView->SetView (); |
---|
| 78 | pView->ClearView (); |
---|
| 79 | pView->DrawView (); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | void G4OpenGLXmViewer::rep_style_callback (Widget w, |
---|
| 83 | XtPointer clientData, |
---|
| 84 | XtPointer) |
---|
| 85 | { |
---|
| 86 | G4long choice = (G4long)clientData; |
---|
| 87 | G4OpenGLXmViewer* pView; |
---|
| 88 | XtVaGetValues (XtParent(w), |
---|
| 89 | XmNuserData, &pView, |
---|
| 90 | NULL); |
---|
| 91 | G4ViewParameters::RepStyle style; |
---|
| 92 | |
---|
| 93 | switch (choice) { |
---|
| 94 | |
---|
| 95 | case 0: |
---|
| 96 | style = G4ViewParameters::polyhedron; |
---|
| 97 | break; |
---|
| 98 | |
---|
| 99 | case 1: |
---|
| 100 | style = G4ViewParameters::nurbs; |
---|
| 101 | break; |
---|
| 102 | |
---|
| 103 | default: |
---|
| 104 | style = G4ViewParameters::polyhedron; |
---|
| 105 | G4Exception("Unrecognised case in rep_style_callback."); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | pView->fVP.SetRepStyle (style); |
---|
| 109 | |
---|
| 110 | pView->SetView (); |
---|
| 111 | pView->ClearView (); |
---|
| 112 | pView->DrawView (); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | void G4OpenGLXmViewer::background_color_callback (Widget w, |
---|
| 116 | XtPointer clientData, |
---|
| 117 | XtPointer) |
---|
| 118 | { |
---|
| 119 | G4long choice = (G4long)clientData; |
---|
| 120 | G4OpenGLXmViewer* pView; |
---|
| 121 | XtVaGetValues (XtParent(w), |
---|
| 122 | XmNuserData, &pView, |
---|
| 123 | NULL); |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | //I need to revisit the kernel if the background colour changes and |
---|
| 127 | //hidden line removal is enabled, because hlr drawing utilises the |
---|
| 128 | //background colour in its drawing... |
---|
| 129 | // (Note added by JA 13/9/2005) Background now handled in view |
---|
| 130 | // parameters. A kernel visit is triggered on change of background. |
---|
| 131 | switch (choice) { |
---|
| 132 | |
---|
| 133 | case 0: |
---|
| 134 | ((G4ViewParameters&)pView->GetViewParameters()). |
---|
| 135 | SetBackgroundColour(G4Colour(1.,1.,1.)); // White |
---|
| 136 | break; |
---|
| 137 | |
---|
| 138 | case 1: |
---|
| 139 | ((G4ViewParameters&)pView->GetViewParameters()). |
---|
| 140 | SetBackgroundColour(G4Colour(0.,0.,0.)); // Black |
---|
| 141 | break; |
---|
| 142 | |
---|
| 143 | default: |
---|
| 144 | G4Exception("Unrecognised case in background_color_callback."); |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | pView->SetView (); |
---|
| 148 | pView->ClearView (); |
---|
| 149 | pView->DrawView (); |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | void G4OpenGLXmViewer::transparency_callback (Widget w, |
---|
| 153 | XtPointer clientData, |
---|
| 154 | XtPointer) |
---|
| 155 | { |
---|
| 156 | G4long choice = (G4long)clientData; |
---|
| 157 | G4OpenGLXmViewer* pView; |
---|
| 158 | XtVaGetValues (XtParent(w), |
---|
| 159 | XmNuserData, &pView, |
---|
| 160 | NULL); |
---|
| 161 | |
---|
| 162 | switch (choice) { |
---|
| 163 | |
---|
| 164 | case 0: |
---|
| 165 | pView->transparency_enabled = false; |
---|
| 166 | break; |
---|
| 167 | |
---|
| 168 | case 1: |
---|
| 169 | pView->transparency_enabled = true; |
---|
| 170 | break; |
---|
| 171 | |
---|
| 172 | default: |
---|
| 173 | G4Exception("Unrecognised case in transparency_callback."); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | pView->SetNeedKernelVisit (true); |
---|
| 177 | pView->SetView (); |
---|
| 178 | pView->ClearView (); |
---|
| 179 | pView->DrawView (); |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | void G4OpenGLXmViewer::antialias_callback (Widget w, |
---|
| 183 | XtPointer clientData, |
---|
| 184 | XtPointer) |
---|
| 185 | { |
---|
| 186 | G4long choice = (G4long)clientData; |
---|
| 187 | G4OpenGLXmViewer* pView; |
---|
| 188 | XtVaGetValues (XtParent(w), |
---|
| 189 | XmNuserData, &pView, |
---|
| 190 | NULL); |
---|
| 191 | |
---|
| 192 | switch (choice) { |
---|
| 193 | |
---|
| 194 | case 0: |
---|
| 195 | pView->antialiasing_enabled = false; |
---|
| 196 | glDisable (GL_LINE_SMOOTH); |
---|
| 197 | glDisable (GL_POLYGON_SMOOTH); |
---|
| 198 | break; |
---|
| 199 | |
---|
| 200 | case 1: |
---|
| 201 | pView->antialiasing_enabled = true; |
---|
| 202 | glEnable (GL_LINE_SMOOTH); |
---|
| 203 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
---|
| 204 | glEnable (GL_POLYGON_SMOOTH); |
---|
| 205 | glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); |
---|
| 206 | break; |
---|
| 207 | |
---|
| 208 | default: |
---|
| 209 | G4Exception("Unrecognised case in antialiasing_callback."); |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | pView->SetView (); |
---|
| 213 | pView->ClearView (); |
---|
| 214 | pView->DrawView (); |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | void G4OpenGLXmViewer::haloing_callback (Widget w, |
---|
| 218 | XtPointer clientData, |
---|
| 219 | XtPointer) |
---|
| 220 | { |
---|
| 221 | G4long choice = (G4long)clientData; |
---|
| 222 | G4OpenGLXmViewer* pView; |
---|
| 223 | XtVaGetValues (XtParent(w), |
---|
| 224 | XmNuserData, &pView, |
---|
| 225 | NULL); |
---|
| 226 | |
---|
| 227 | switch (choice) { |
---|
| 228 | |
---|
| 229 | case 0: |
---|
| 230 | pView->haloing_enabled = false; |
---|
| 231 | break; |
---|
| 232 | |
---|
| 233 | case 1: |
---|
| 234 | pView->haloing_enabled = true; |
---|
| 235 | break; |
---|
| 236 | |
---|
| 237 | default: |
---|
| 238 | G4Exception("Unrecognised case in haloing_callback."); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | pView->SetView (); |
---|
| 242 | pView->ClearView (); |
---|
| 243 | pView->DrawView (); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | void G4OpenGLXmViewer::aux_edge_callback (Widget w, |
---|
| 247 | XtPointer clientData, |
---|
| 248 | XtPointer) |
---|
| 249 | { |
---|
| 250 | G4long choice = (G4long)clientData; |
---|
| 251 | G4OpenGLXmViewer* pView; |
---|
| 252 | XtVaGetValues (XtParent(w), |
---|
| 253 | XmNuserData, &pView, |
---|
| 254 | NULL); |
---|
| 255 | |
---|
| 256 | switch (choice) { |
---|
| 257 | |
---|
| 258 | case 0: |
---|
| 259 | pView->fVP.SetAuxEdgeVisible(false); |
---|
| 260 | break; |
---|
| 261 | |
---|
| 262 | case 1: |
---|
| 263 | pView->fVP.SetAuxEdgeVisible(true); |
---|
| 264 | break; |
---|
| 265 | |
---|
| 266 | default: |
---|
| 267 | G4Exception("Unrecognised case in aux_edge_callback."); |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | pView->SetNeedKernelVisit (true); |
---|
| 271 | pView->SetView (); |
---|
| 272 | pView->ClearView (); |
---|
| 273 | pView->DrawView (); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | void G4OpenGLXmViewer::projection_callback (Widget w, |
---|
| 277 | XtPointer clientData, |
---|
| 278 | XtPointer) |
---|
| 279 | { |
---|
| 280 | G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData; |
---|
| 281 | |
---|
| 282 | G4int choice = get_int_userData (w); |
---|
| 283 | |
---|
| 284 | switch (choice) { |
---|
| 285 | case 0: |
---|
| 286 | { |
---|
| 287 | pView->fVP.SetFieldHalfAngle (0.); |
---|
| 288 | break; |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | case 1: |
---|
| 292 | { |
---|
| 293 | if (pView->fov > 89.5 || pView->fov <= 0.0) { |
---|
| 294 | G4cout << "Field half angle should be 0 < angle <= 89.5 degrees."; |
---|
| 295 | G4cout << G4endl; |
---|
| 296 | } |
---|
| 297 | else { |
---|
| 298 | pView->fVP.SetFieldHalfAngle (pView->fov * deg); |
---|
| 299 | } |
---|
| 300 | break; |
---|
| 301 | } |
---|
| 302 | default: |
---|
| 303 | { |
---|
| 304 | G4Exception("Unrecognised choice made in projection_callback"); |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | pView->SetView (); |
---|
| 309 | pView->ClearView (); |
---|
| 310 | pView->DrawView (); |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | #endif |
---|
| 314 | |
---|