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