Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLXmStyleCallbacks.cc
Go to the documentation of this file.
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$
28//
29//
30// Andrew Walkden 16th April 1997
31// G4OpenGLXmStyleCallbacks :
32// Several callback functions used by
33// elements of the control panel to
34// determine how to visualize the view.
35
36#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
37
38#include "G4OpenGLXmViewer.hh"
39#include "G4SystemOfUnits.hh"
40
41void 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);
51
52 switch (choice) {
53
54 case 0:
56 break;
57
58 case 1:
60 break;
61
62 case 2:
64 break;
65
66 case 3:
68 break;
69
70 default:
73 ("G4OpenGLXmViewer::drawing_style_callback",
74 "opengl2006", FatalException,
75 "Unrecognised case in drawing_style_callback.");
76 }
77
78 pView->fVP.SetDrawingStyle (style);
79
80 pView->SetView ();
81 pView->ClearView ();
82 pView->DrawView ();
83}
84
85void G4OpenGLXmViewer::rep_style_callback (Widget w,
86 XtPointer clientData,
87 XtPointer)
88{
89 G4long choice = (G4long)clientData;
90 G4OpenGLXmViewer* pView;
91 XtVaGetValues (XtParent(w),
92 XmNuserData, &pView,
93 NULL);
95
96 switch (choice) {
97
98 case 0:
100 break;
101
102 case 1:
104 break;
105
106 default:
109 ("G4OpenGLXmViewer::rep_style_callback",
110 "opengl2007", FatalException,
111 "Unrecognised case in rep_style_callback.");
112 }
113
114 pView->fVP.SetRepStyle (style);
115
116 pView->SetView ();
117 pView->ClearView ();
118 pView->DrawView ();
119}
120
121void G4OpenGLXmViewer::background_color_callback (Widget w,
122 XtPointer clientData,
123 XtPointer)
124{
125 G4long choice = (G4long)clientData;
126 G4OpenGLXmViewer* pView;
127 XtVaGetValues (XtParent(w),
128 XmNuserData, &pView,
129 NULL);
130
131
132 //I need to revisit the kernel if the background colour changes and
133 //hidden line removal is enabled, because hlr drawing utilises the
134 //background colour in its drawing...
135 // (Note added by JA 13/9/2005) Background now handled in view
136 // parameters. A kernel visit is triggered on change of background.
137 switch (choice) {
138
139 case 0:
140 ((G4ViewParameters&)pView->GetViewParameters()).
141 SetBackgroundColour(G4Colour(1.,1.,1.)); // White
142 break;
143
144 case 1:
145 ((G4ViewParameters&)pView->GetViewParameters()).
146 SetBackgroundColour(G4Colour(0.,0.,0.)); // Black
147 break;
148
149 default:
151 ("G4OpenGLXmViewer::background_color_callback",
152 "opengl2008", FatalException,
153 "Unrecognised case in background_color_callback.");
154 }
155
156 pView->SetView ();
157 pView->ClearView ();
158 pView->DrawView ();
159}
160
161void G4OpenGLXmViewer::transparency_callback (Widget w,
162 XtPointer clientData,
163 XtPointer)
164{
165 G4long choice = (G4long)clientData;
166 G4OpenGLXmViewer* pView;
167 XtVaGetValues (XtParent(w),
168 XmNuserData, &pView,
169 NULL);
170
171 switch (choice) {
172
173 case 0:
174 pView->transparency_enabled = false;
175 break;
176
177 case 1:
178 pView->transparency_enabled = true;
179 break;
180
181 default:
183 ("G4OpenGLXmViewer::transparency_callback",
184 "opengl2009", FatalException,
185 "Unrecognised case in transparency_callback.");
186 }
187
188 pView->SetNeedKernelVisit (true);
189 pView->SetView ();
190 pView->ClearView ();
191 pView->DrawView ();
192}
193
194void G4OpenGLXmViewer::antialias_callback (Widget w,
195 XtPointer clientData,
196 XtPointer)
197{
198 G4long choice = (G4long)clientData;
199 G4OpenGLXmViewer* pView;
200 XtVaGetValues (XtParent(w),
201 XmNuserData, &pView,
202 NULL);
203
204 switch (choice) {
205
206 case 0:
207 pView->antialiasing_enabled = false;
208 glDisable (GL_LINE_SMOOTH);
209 glDisable (GL_POLYGON_SMOOTH);
210 break;
211
212 case 1:
213 pView->antialiasing_enabled = true;
214 glEnable (GL_LINE_SMOOTH);
215 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
216 glEnable (GL_POLYGON_SMOOTH);
217 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
218 break;
219
220 default:
222 ("G4OpenGLXmViewer::antialias_callback",
223 "opengl2010", FatalException,
224 "Unrecognised case in antialiasing_callback.");
225 }
226
227 pView->SetView ();
228 pView->ClearView ();
229 pView->DrawView ();
230}
231
232void G4OpenGLXmViewer::haloing_callback (Widget w,
233 XtPointer clientData,
234 XtPointer)
235{
236 G4long choice = (G4long)clientData;
237 G4OpenGLXmViewer* pView;
238 XtVaGetValues (XtParent(w),
239 XmNuserData, &pView,
240 NULL);
241
242 switch (choice) {
243
244 case 0:
245 pView->haloing_enabled = false;
246 break;
247
248 case 1:
249 pView->haloing_enabled = true;
250 break;
251
252 default:
254 ("G4OpenGLXmViewer::haloing_callback",
255 "opengl2011", FatalException,
256 "Unrecognised case in haloing_callback.");
257 }
258
259 pView->SetView ();
260 pView->ClearView ();
261 pView->DrawView ();
262}
263
264void G4OpenGLXmViewer::aux_edge_callback (Widget w,
265 XtPointer clientData,
266 XtPointer)
267{
268 G4long choice = (G4long)clientData;
269 G4OpenGLXmViewer* pView;
270 XtVaGetValues (XtParent(w),
271 XmNuserData, &pView,
272 NULL);
273
274 switch (choice) {
275
276 case 0:
277 pView->fVP.SetAuxEdgeVisible(false);
278 break;
279
280 case 1:
281 pView->fVP.SetAuxEdgeVisible(true);
282 break;
283
284 default:
286 ("G4OpenGLXmViewer::aux_edge_callback",
287 "opengl2012", FatalException,
288 "Unrecognised case in aux_edge_callback.");
289 }
290
291 pView->SetNeedKernelVisit (true);
292 pView->SetView ();
293 pView->ClearView ();
294 pView->DrawView ();
295}
296
297void G4OpenGLXmViewer::projection_callback (Widget w,
298 XtPointer clientData,
299 XtPointer)
300{
301 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
302
303 G4int choice = get_int_userData (w);
304
305 switch (choice) {
306 case 0:
307 {
308 pView->fVP.SetFieldHalfAngle (0.);
309 break;
310 }
311
312 case 1:
313 {
314 if (pView->fov > 89.5 || pView->fov <= 0.0) {
315 G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
316 G4cout << G4endl;
317 }
318 else {
319 pView->fVP.SetFieldHalfAngle (pView->fov * deg);
320 }
321 break;
322 }
323 default:
324 {
326 ("G4OpenGLXmViewer::projection_callback",
327 "opengl2013", FatalException,
328 "Unrecognised choice made in projection_callback");
329 }
330 }
331
332 pView->SetView ();
333 pView->ClearView ();
334 pView->DrawView ();
335}
336
337#endif
338
@ FatalException
long G4long
Definition: G4Types.hh:68
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41