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