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