source: trunk/source/visualization/OpenGL/src/G4OpenGLXmStyleCallbacks.cc@ 1040

Last change on this file since 1040 was 1038, checked in by garnier, 17 years ago

en test pour les refresh, ne marche pas bien

  • Property svn:mime-type set to text/cpp
File size: 7.2 KB
RevLine 
[529]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//
[951]27// $Id: G4OpenGLXmStyleCallbacks.cc,v 1.14 2006/06/29 21:20:02 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
[529]29//
30//
31// Andrew Walkden 16th April 1997
32// G4OpenGLXmStyleCallbacks :
33// Several callback functions used by
34// elements of the control panel to
35// determine how to visualize the view.
36
37#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
38
39#include "G4OpenGLXmViewer.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);
50 G4ViewParameters::DrawingStyle style;
51
52 switch (choice) {
53
54 case 0:
55 style = G4ViewParameters::wireframe;
56 break;
57
58 case 1:
59 style = G4ViewParameters::hlr;
60 break;
61
62 case 2:
63 style = G4ViewParameters::hsr;
64 break;
65
66 case 3:
67 style = G4ViewParameters::hlhsr;
68 break;
69
70 default:
71 style = G4ViewParameters::wireframe;
72 G4Exception("Unrecognised case in drawing_style_callback.");
73 }
74
75 pView->fVP.SetDrawingStyle (style);
76
[1038]77 pView->RepaintGLView();
[529]78}
79
80void G4OpenGLXmViewer::rep_style_callback (Widget w,
81 XtPointer clientData,
82 XtPointer)
83{
84 G4long choice = (G4long)clientData;
85 G4OpenGLXmViewer* pView;
86 XtVaGetValues (XtParent(w),
87 XmNuserData, &pView,
88 NULL);
89 G4ViewParameters::RepStyle style;
90
91 switch (choice) {
92
93 case 0:
94 style = G4ViewParameters::polyhedron;
95 break;
96
97 case 1:
98 style = G4ViewParameters::nurbs;
99 break;
100
101 default:
102 style = G4ViewParameters::polyhedron;
103 G4Exception("Unrecognised case in rep_style_callback.");
104 }
105
106 pView->fVP.SetRepStyle (style);
107
[1038]108 pView->RepaintGLView ();
[529]109}
110
111void G4OpenGLXmViewer::background_color_callback (Widget w,
112 XtPointer clientData,
113 XtPointer)
114{
115 G4long choice = (G4long)clientData;
116 G4OpenGLXmViewer* pView;
117 XtVaGetValues (XtParent(w),
118 XmNuserData, &pView,
119 NULL);
120
121
122 //I need to revisit the kernel if the background colour changes and
123 //hidden line removal is enabled, because hlr drawing utilises the
124 //background colour in its drawing...
125 // (Note added by JA 13/9/2005) Background now handled in view
126 // parameters. A kernel visit is triggered on change of background.
127 switch (choice) {
128
129 case 0:
130 ((G4ViewParameters&)pView->GetViewParameters()).
131 SetBackgroundColour(G4Colour(1.,1.,1.)); // White
132 break;
133
134 case 1:
135 ((G4ViewParameters&)pView->GetViewParameters()).
136 SetBackgroundColour(G4Colour(0.,0.,0.)); // Black
137 break;
138
139 default:
140 G4Exception("Unrecognised case in background_color_callback.");
141 }
142
[1038]143 pView->RepaintGLView ();
[529]144}
145
146void G4OpenGLXmViewer::transparency_callback (Widget w,
147 XtPointer clientData,
148 XtPointer)
149{
150 G4long choice = (G4long)clientData;
151 G4OpenGLXmViewer* pView;
152 XtVaGetValues (XtParent(w),
153 XmNuserData, &pView,
154 NULL);
155
156 switch (choice) {
157
158 case 0:
159 pView->transparency_enabled = false;
160 break;
161
162 case 1:
163 pView->transparency_enabled = true;
164 break;
165
166 default:
167 G4Exception("Unrecognised case in transparency_callback.");
168 }
169
170 pView->SetNeedKernelVisit (true);
[1038]171 pView->RepaintGLView ();
[529]172}
173
174void G4OpenGLXmViewer::antialias_callback (Widget w,
175 XtPointer clientData,
176 XtPointer)
177{
178 G4long choice = (G4long)clientData;
179 G4OpenGLXmViewer* pView;
180 XtVaGetValues (XtParent(w),
181 XmNuserData, &pView,
182 NULL);
183
184 switch (choice) {
185
186 case 0:
187 pView->antialiasing_enabled = false;
188 glDisable (GL_LINE_SMOOTH);
189 glDisable (GL_POLYGON_SMOOTH);
190 break;
191
192 case 1:
193 pView->antialiasing_enabled = true;
194 glEnable (GL_LINE_SMOOTH);
195 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
196 glEnable (GL_POLYGON_SMOOTH);
197 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
198 break;
199
200 default:
201 G4Exception("Unrecognised case in antialiasing_callback.");
202 }
203
[1038]204 pView->RepaintGLView ();
[529]205}
206
207void G4OpenGLXmViewer::haloing_callback (Widget w,
208 XtPointer clientData,
209 XtPointer)
210{
211 G4long choice = (G4long)clientData;
212 G4OpenGLXmViewer* pView;
213 XtVaGetValues (XtParent(w),
214 XmNuserData, &pView,
215 NULL);
216
217 switch (choice) {
218
219 case 0:
220 pView->haloing_enabled = false;
221 break;
222
223 case 1:
224 pView->haloing_enabled = true;
225 break;
226
227 default:
228 G4Exception("Unrecognised case in haloing_callback.");
229 }
230
[1038]231 pView->RepaintGLView ();
[529]232}
233
234void G4OpenGLXmViewer::aux_edge_callback (Widget w,
235 XtPointer clientData,
236 XtPointer)
237{
238 G4long choice = (G4long)clientData;
239 G4OpenGLXmViewer* pView;
240 XtVaGetValues (XtParent(w),
241 XmNuserData, &pView,
242 NULL);
243
244 switch (choice) {
245
246 case 0:
247 pView->fVP.SetAuxEdgeVisible(false);
248 break;
249
250 case 1:
251 pView->fVP.SetAuxEdgeVisible(true);
252 break;
253
254 default:
255 G4Exception("Unrecognised case in aux_edge_callback.");
256 }
257
258 pView->SetNeedKernelVisit (true);
[1038]259 pView->RepaintGLView ();
[529]260}
261
262void G4OpenGLXmViewer::projection_callback (Widget w,
263 XtPointer clientData,
264 XtPointer)
265{
266 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
267
268 G4int choice = get_int_userData (w);
269
270 switch (choice) {
271 case 0:
272 {
273 pView->fVP.SetFieldHalfAngle (0.);
274 break;
275 }
276
277 case 1:
278 {
279 if (pView->fov > 89.5 || pView->fov <= 0.0) {
280 G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
281 G4cout << G4endl;
282 }
283 else {
284 pView->fVP.SetFieldHalfAngle (pView->fov * deg);
285 }
286 break;
287 }
288 default:
289 {
290 G4Exception("Unrecognised choice made in projection_callback");
291 }
292 }
293
[1038]294 pView->RepaintGLView();
[529]295}
296
297#endif
298
Note: See TracBrowser for help on using the repository browser.