Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: G4OpenGLXmStyleCallbacks.cc,v 1.14 2006/06/29 21:20:02 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02-patch-04 $ 27 // 29 // 28 // 30 // 29 // Andrew Walkden 16th April 1997 31 // Andrew Walkden 16th April 1997 30 // G4OpenGLXmStyleCallbacks : 32 // G4OpenGLXmStyleCallbacks : 31 // Several callback func 33 // Several callback functions used by 32 // elements of the contr 34 // elements of the control panel to 33 // determine how to visu 35 // determine how to visualize the view. 34 36 >> 37 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER >> 38 35 #include "G4OpenGLXmViewer.hh" 39 #include "G4OpenGLXmViewer.hh" 36 #include "G4SystemOfUnits.hh" << 37 40 38 void G4OpenGLXmViewer::drawing_style_callback 41 void G4OpenGLXmViewer::drawing_style_callback (Widget w, 39 XtPointer clientData, 42 XtPointer clientData, 40 XtPointer) 43 XtPointer) 41 { 44 { 42 G4long choice = (G4long)clientData; 45 G4long choice = (G4long)clientData; 43 G4OpenGLXmViewer* pView; 46 G4OpenGLXmViewer* pView; 44 XtVaGetValues (XtParent(w), 47 XtVaGetValues (XtParent(w), 45 XmNuserData, &pView, 48 XmNuserData, &pView, 46 NULL); 49 NULL); 47 G4ViewParameters::DrawingStyle style; 50 G4ViewParameters::DrawingStyle style; 48 51 49 switch (choice) { 52 switch (choice) { 50 53 51 case 0: 54 case 0: 52 style = G4ViewParameters::wireframe; 55 style = G4ViewParameters::wireframe; 53 break; 56 break; 54 57 55 case 1: 58 case 1: 56 style = G4ViewParameters::hlr; 59 style = G4ViewParameters::hlr; 57 break; 60 break; 58 61 59 case 2: 62 case 2: 60 style = G4ViewParameters::hsr; 63 style = G4ViewParameters::hsr; 61 break; 64 break; 62 65 63 case 3: 66 case 3: 64 style = G4ViewParameters::hlhsr; 67 style = G4ViewParameters::hlhsr; 65 break; 68 break; 66 69 67 default: 70 default: 68 style = G4ViewParameters::wireframe; 71 style = G4ViewParameters::wireframe; 69 G4Exception << 72 G4Exception("Unrecognised case in drawing_style_callback."); 70 ("G4OpenGLXmViewer::drawing_style_callba << 71 "opengl2006", FatalException, << 72 "Unrecognised case in drawing_style_cal << 73 } 73 } 74 74 75 pView->fVP.SetDrawingStyle (style); 75 pView->fVP.SetDrawingStyle (style); 76 76 77 pView->SetView (); 77 pView->SetView (); 78 pView->ClearView (); 78 pView->ClearView (); 79 pView->DrawView (); 79 pView->DrawView (); 80 } 80 } 81 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 82 void G4OpenGLXmViewer::background_color_callba 115 void G4OpenGLXmViewer::background_color_callback (Widget w, 83 XtPointer clientData, 116 XtPointer clientData, 84 XtPointer) 117 XtPointer) 85 { 118 { 86 G4long choice = (G4long)clientData; 119 G4long choice = (G4long)clientData; 87 G4OpenGLXmViewer* pView; 120 G4OpenGLXmViewer* pView; 88 XtVaGetValues (XtParent(w), 121 XtVaGetValues (XtParent(w), 89 XmNuserData, &pView, 122 XmNuserData, &pView, 90 NULL); 123 NULL); 91 124 92 125 93 //I need to revisit the kernel if the backgr 126 //I need to revisit the kernel if the background colour changes and 94 //hidden line removal is enabled, because hl 127 //hidden line removal is enabled, because hlr drawing utilises the 95 //background colour in its drawing... 128 //background colour in its drawing... 96 // (Note added by JA 13/9/2005) Background n 129 // (Note added by JA 13/9/2005) Background now handled in view 97 // parameters. A kernel visit is triggered 130 // parameters. A kernel visit is triggered on change of background. 98 switch (choice) { 131 switch (choice) { 99 132 100 case 0: 133 case 0: 101 ((G4ViewParameters&)pView->GetViewParamete 134 ((G4ViewParameters&)pView->GetViewParameters()). 102 SetBackgroundColour(G4Colour(1.,1.,1.)); 135 SetBackgroundColour(G4Colour(1.,1.,1.)); // White 103 break; 136 break; 104 137 105 case 1: 138 case 1: 106 ((G4ViewParameters&)pView->GetViewParamete 139 ((G4ViewParameters&)pView->GetViewParameters()). 107 SetBackgroundColour(G4Colour(0.,0.,0.)); 140 SetBackgroundColour(G4Colour(0.,0.,0.)); // Black 108 break; 141 break; 109 142 110 default: 143 default: 111 G4Exception << 144 G4Exception("Unrecognised case in background_color_callback."); 112 ("G4OpenGLXmViewer::background_color_cal << 113 "opengl2008", FatalException, << 114 "Unrecognised case in background_color_ << 115 } 145 } 116 146 117 pView->SetView (); 147 pView->SetView (); 118 pView->ClearView (); 148 pView->ClearView (); 119 pView->DrawView (); 149 pView->DrawView (); 120 } 150 } 121 151 122 void G4OpenGLXmViewer::transparency_callback ( 152 void G4OpenGLXmViewer::transparency_callback (Widget w, 123 XtPointer clientData, 153 XtPointer clientData, 124 XtPointer) 154 XtPointer) 125 { 155 { 126 G4long choice = (G4long)clientData; 156 G4long choice = (G4long)clientData; 127 G4OpenGLXmViewer* pView; 157 G4OpenGLXmViewer* pView; 128 XtVaGetValues (XtParent(w), 158 XtVaGetValues (XtParent(w), 129 XmNuserData, &pView, 159 XmNuserData, &pView, 130 NULL); 160 NULL); 131 161 132 switch (choice) { 162 switch (choice) { 133 163 134 case 0: 164 case 0: 135 pView->transparency_enabled = false; 165 pView->transparency_enabled = false; 136 break; 166 break; 137 167 138 case 1: 168 case 1: 139 pView->transparency_enabled = true; 169 pView->transparency_enabled = true; 140 break; 170 break; 141 171 142 default: 172 default: 143 G4Exception << 173 G4Exception("Unrecognised case in transparency_callback."); 144 ("G4OpenGLXmViewer::transparency_callbac << 145 "opengl2009", FatalException, << 146 "Unrecognised case in transparency_call << 147 } 174 } 148 175 149 pView->SetNeedKernelVisit (true); 176 pView->SetNeedKernelVisit (true); 150 pView->SetView (); 177 pView->SetView (); 151 pView->ClearView (); 178 pView->ClearView (); 152 pView->DrawView (); 179 pView->DrawView (); 153 } 180 } 154 181 155 void G4OpenGLXmViewer::antialias_callback (Wid 182 void G4OpenGLXmViewer::antialias_callback (Widget w, 156 XtPointer clientData, 183 XtPointer clientData, 157 XtPointer) 184 XtPointer) 158 { 185 { 159 G4long choice = (G4long)clientData; 186 G4long choice = (G4long)clientData; 160 G4OpenGLXmViewer* pView; 187 G4OpenGLXmViewer* pView; 161 XtVaGetValues (XtParent(w), 188 XtVaGetValues (XtParent(w), 162 XmNuserData, &pView, 189 XmNuserData, &pView, 163 NULL); 190 NULL); 164 191 165 switch (choice) { 192 switch (choice) { 166 193 167 case 0: 194 case 0: 168 pView->antialiasing_enabled = false; 195 pView->antialiasing_enabled = false; 169 glDisable (GL_LINE_SMOOTH); 196 glDisable (GL_LINE_SMOOTH); 170 glDisable (GL_POLYGON_SMOOTH); 197 glDisable (GL_POLYGON_SMOOTH); 171 break; 198 break; 172 199 173 case 1: 200 case 1: 174 pView->antialiasing_enabled = true; 201 pView->antialiasing_enabled = true; 175 glEnable (GL_LINE_SMOOTH); 202 glEnable (GL_LINE_SMOOTH); 176 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); 203 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); 177 glEnable (GL_POLYGON_SMOOTH); 204 glEnable (GL_POLYGON_SMOOTH); 178 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST) 205 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); 179 break; 206 break; 180 207 181 default: 208 default: 182 G4Exception << 209 G4Exception("Unrecognised case in antialiasing_callback."); 183 ("G4OpenGLXmViewer::antialias_callback", << 184 "opengl2010", FatalException, << 185 "Unrecognised case in antialiasing_call << 186 } 210 } 187 211 188 pView->SetView (); 212 pView->SetView (); 189 pView->ClearView (); 213 pView->ClearView (); 190 pView->DrawView (); 214 pView->DrawView (); 191 } 215 } 192 216 193 void G4OpenGLXmViewer::haloing_callback (Widge 217 void G4OpenGLXmViewer::haloing_callback (Widget w, 194 XtPointer clientData, 218 XtPointer clientData, 195 XtPointer) 219 XtPointer) 196 { 220 { 197 G4long choice = (G4long)clientData; 221 G4long choice = (G4long)clientData; 198 G4OpenGLXmViewer* pView; 222 G4OpenGLXmViewer* pView; 199 XtVaGetValues (XtParent(w), 223 XtVaGetValues (XtParent(w), 200 XmNuserData, &pView, 224 XmNuserData, &pView, 201 NULL); 225 NULL); 202 226 203 switch (choice) { 227 switch (choice) { 204 228 205 case 0: 229 case 0: 206 pView->haloing_enabled = false; 230 pView->haloing_enabled = false; 207 break; 231 break; 208 232 209 case 1: 233 case 1: 210 pView->haloing_enabled = true; 234 pView->haloing_enabled = true; 211 break; 235 break; 212 236 213 default: 237 default: 214 G4Exception << 238 G4Exception("Unrecognised case in haloing_callback."); 215 ("G4OpenGLXmViewer::haloing_callback", << 216 "opengl2011", FatalException, << 217 "Unrecognised case in haloing_callback. << 218 } 239 } 219 240 220 pView->SetView (); 241 pView->SetView (); 221 pView->ClearView (); 242 pView->ClearView (); 222 pView->DrawView (); 243 pView->DrawView (); 223 } 244 } 224 245 225 void G4OpenGLXmViewer::aux_edge_callback (Widg 246 void G4OpenGLXmViewer::aux_edge_callback (Widget w, 226 XtPointer clientData, 247 XtPointer clientData, 227 XtPointer) 248 XtPointer) 228 { 249 { 229 G4long choice = (G4long)clientData; 250 G4long choice = (G4long)clientData; 230 G4OpenGLXmViewer* pView; 251 G4OpenGLXmViewer* pView; 231 XtVaGetValues (XtParent(w), 252 XtVaGetValues (XtParent(w), 232 XmNuserData, &pView, 253 XmNuserData, &pView, 233 NULL); 254 NULL); 234 255 235 switch (choice) { 256 switch (choice) { 236 257 237 case 0: 258 case 0: 238 pView->fVP.SetAuxEdgeVisible(false); 259 pView->fVP.SetAuxEdgeVisible(false); 239 break; 260 break; 240 261 241 case 1: 262 case 1: 242 pView->fVP.SetAuxEdgeVisible(true); 263 pView->fVP.SetAuxEdgeVisible(true); 243 break; 264 break; 244 265 245 default: 266 default: 246 G4Exception << 267 G4Exception("Unrecognised case in aux_edge_callback."); 247 ("G4OpenGLXmViewer::aux_edge_callback", << 248 "opengl2012", FatalException, << 249 "Unrecognised case in aux_edge_callback << 250 } 268 } 251 269 252 pView->SetNeedKernelVisit (true); 270 pView->SetNeedKernelVisit (true); 253 pView->SetView (); 271 pView->SetView (); 254 pView->ClearView (); 272 pView->ClearView (); 255 pView->DrawView (); 273 pView->DrawView (); 256 } 274 } 257 275 258 void G4OpenGLXmViewer::projection_callback (Wi 276 void G4OpenGLXmViewer::projection_callback (Widget w, 259 XtPointer clientData, 277 XtPointer clientData, 260 XtPointer) 278 XtPointer) 261 { 279 { 262 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer* 280 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData; 263 281 264 G4int choice = get_int_userData (w); 282 G4int choice = get_int_userData (w); 265 283 266 switch (choice) { 284 switch (choice) { 267 case 0: 285 case 0: 268 { 286 { 269 pView->fVP.SetFieldHalfAngle (0.); 287 pView->fVP.SetFieldHalfAngle (0.); 270 break; 288 break; 271 } 289 } 272 290 273 case 1: 291 case 1: 274 { 292 { 275 if (pView->fov > 89.5 || pView->fov <= 0 293 if (pView->fov > 89.5 || pView->fov <= 0.0) { 276 G4cout << "Field half angle should be 0 < an 294 G4cout << "Field half angle should be 0 < angle <= 89.5 degrees."; 277 G4cout << G4endl; 295 G4cout << G4endl; 278 } 296 } 279 else { 297 else { 280 pView->fVP.SetFieldHalfAngle (pView->fov * d 298 pView->fVP.SetFieldHalfAngle (pView->fov * deg); 281 } 299 } 282 break; 300 break; 283 } 301 } 284 default: 302 default: 285 { 303 { 286 G4Exception << 304 G4Exception("Unrecognised choice made in projection_callback"); 287 ("G4OpenGLXmViewer::projection_callback", << 288 "opengl2013", FatalException, << 289 "Unrecognised choice made in projection_cal << 290 } 305 } 291 } 306 } 292 307 293 pView->SetView (); 308 pView->SetView (); 294 pView->ClearView (); 309 pView->ClearView (); 295 pView->DrawView (); 310 pView->DrawView (); 296 } 311 } >> 312 >> 313 #endif >> 314 297 315