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