Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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#include "G4OpenGLXmViewer.hh"
36#include "G4SystemOfUnits.hh"
37
39 XtPointer clientData,
40 XtPointer)
41{
42 G4long choice = (G4long)clientData;
43 G4OpenGLXmViewer* pView;
44 XtVaGetValues (XtParent(w),
45 XmNuserData, &pView,
46 NULL);
48
49 switch (choice) {
50
51 case 0:
53 break;
54
55 case 1:
57 break;
58
59 case 2:
61 break;
62
63 case 3:
65 break;
66
67 default:
70 ("G4OpenGLXmViewer::drawing_style_callback",
71 "opengl2006", FatalException,
72 "Unrecognised case in drawing_style_callback.");
73 }
74
75 pView->fVP.SetDrawingStyle (style);
76
77 pView->SetView ();
78 pView->ClearView ();
79 pView->DrawView ();
80}
81
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 background colour changes and
94 //hidden line removal is enabled, because hlr drawing utilises the
95 //background colour in its drawing...
96 // (Note added by JA 13/9/2005) Background now handled in view
97 // parameters. A kernel visit is triggered on change of background.
98 switch (choice) {
99
100 case 0:
102 SetBackgroundColour(G4Colour(1.,1.,1.)); // White
103 break;
104
105 case 1:
107 SetBackgroundColour(G4Colour(0.,0.,0.)); // Black
108 break;
109
110 default:
112 ("G4OpenGLXmViewer::background_color_callback",
113 "opengl2008", FatalException,
114 "Unrecognised case in background_color_callback.");
115 }
116
117 pView->SetView ();
118 pView->ClearView ();
119 pView->DrawView ();
120}
121
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:
144 ("G4OpenGLXmViewer::transparency_callback",
145 "opengl2009", FatalException,
146 "Unrecognised case in transparency_callback.");
147 }
148
149 pView->SetNeedKernelVisit (true);
150 pView->SetView ();
151 pView->ClearView ();
152 pView->DrawView ();
153}
154
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:
183 ("G4OpenGLXmViewer::antialias_callback",
184 "opengl2010", FatalException,
185 "Unrecognised case in antialiasing_callback.");
186 }
187
188 pView->SetView ();
189 pView->ClearView ();
190 pView->DrawView ();
191}
192
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:
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
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:
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
259 XtPointer clientData,
260 XtPointer)
261{
262 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
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.0) {
276 G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
277 G4cout << G4endl;
278 }
279 else {
280 pView->fVP.SetFieldHalfAngle (pView->fov * deg);
281 }
282 break;
283 }
284 default:
285 {
287 ("G4OpenGLXmViewer::projection_callback",
288 "opengl2013", FatalException,
289 "Unrecognised choice made in projection_callback");
290 }
291 }
292
293 pView->SetView ();
294 pView->ClearView ();
295 pView->DrawView ();
296}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
long G4long
Definition: G4Types.hh:87
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4bool antialiasing_enabled
G4bool transparency_enabled
static void background_color_callback(Widget w, XtPointer clientData, XtPointer callData)
static void antialias_callback(Widget w, XtPointer clientData, XtPointer callData)
static void drawing_style_callback(Widget w, XtPointer clientData, XtPointer callData)
static void haloing_callback(Widget w, XtPointer clientData, XtPointer callData)
static void aux_edge_callback(Widget w, XtPointer clientData, XtPointer callData)
static void projection_callback(Widget w, XtPointer clientData, XtPointer callData)
static G4int get_int_userData(Widget w)
static void transparency_callback(Widget w, XtPointer clientData, XtPointer callData)
virtual void DrawView()=0
const G4ViewParameters & GetViewParameters() const
void SetNeedKernelVisit(G4bool need)
G4ViewParameters fVP
Definition: G4VViewer.hh:220
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
void SetFieldHalfAngle(G4double fieldHalfAngle)
void SetAuxEdgeVisible(G4bool)