Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpenGLXmStyleCallbacks.cc
이 파일의 문서화 페이지로 가기
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: G4OpenGLXmStyleCallbacks.cc 66373 2012-12-18 09:41:34Z gcosmo $
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 
41 void 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:
59  style = G4ViewParameters::hlr;
60  break;
61 
62  case 2:
63  style = G4ViewParameters::hsr;
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 
85 void G4OpenGLXmViewer::background_color_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);
94 
95 
96  //I need to revisit the kernel if the background colour changes and
97  //hidden line removal is enabled, because hlr drawing utilises the
98  //background colour in its drawing...
99  // (Note added by JA 13/9/2005) Background now handled in view
100  // parameters. A kernel visit is triggered on change of background.
101  switch (choice) {
102 
103  case 0:
104  ((G4ViewParameters&)pView->GetViewParameters()).
105  SetBackgroundColour(G4Colour(1.,1.,1.)); // White
106  break;
107 
108  case 1:
109  ((G4ViewParameters&)pView->GetViewParameters()).
110  SetBackgroundColour(G4Colour(0.,0.,0.)); // Black
111  break;
112 
113  default:
115  ("G4OpenGLXmViewer::background_color_callback",
116  "opengl2008", FatalException,
117  "Unrecognised case in background_color_callback.");
118  }
119 
120  pView->SetView ();
121  pView->ClearView ();
122  pView->DrawView ();
123 }
124 
125 void G4OpenGLXmViewer::transparency_callback (Widget w,
126  XtPointer clientData,
127  XtPointer)
128 {
129  G4long choice = (G4long)clientData;
130  G4OpenGLXmViewer* pView;
131  XtVaGetValues (XtParent(w),
132  XmNuserData, &pView,
133  NULL);
134 
135  switch (choice) {
136 
137  case 0:
138  pView->transparency_enabled = false;
139  break;
140 
141  case 1:
142  pView->transparency_enabled = true;
143  break;
144 
145  default:
147  ("G4OpenGLXmViewer::transparency_callback",
148  "opengl2009", FatalException,
149  "Unrecognised case in transparency_callback.");
150  }
151 
152  pView->SetNeedKernelVisit (true);
153  pView->SetView ();
154  pView->ClearView ();
155  pView->DrawView ();
156 }
157 
158 void G4OpenGLXmViewer::antialias_callback (Widget w,
159  XtPointer clientData,
160  XtPointer)
161 {
162  G4long choice = (G4long)clientData;
163  G4OpenGLXmViewer* pView;
164  XtVaGetValues (XtParent(w),
165  XmNuserData, &pView,
166  NULL);
167 
168  switch (choice) {
169 
170  case 0:
171  pView->antialiasing_enabled = false;
172  glDisable (GL_LINE_SMOOTH);
173  glDisable (GL_POLYGON_SMOOTH);
174  break;
175 
176  case 1:
177  pView->antialiasing_enabled = true;
178  glEnable (GL_LINE_SMOOTH);
179  glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
180  glEnable (GL_POLYGON_SMOOTH);
181  glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
182  break;
183 
184  default:
186  ("G4OpenGLXmViewer::antialias_callback",
187  "opengl2010", FatalException,
188  "Unrecognised case in antialiasing_callback.");
189  }
190 
191  pView->SetView ();
192  pView->ClearView ();
193  pView->DrawView ();
194 }
195 
196 void G4OpenGLXmViewer::haloing_callback (Widget w,
197  XtPointer clientData,
198  XtPointer)
199 {
200  G4long choice = (G4long)clientData;
201  G4OpenGLXmViewer* pView;
202  XtVaGetValues (XtParent(w),
203  XmNuserData, &pView,
204  NULL);
205 
206  switch (choice) {
207 
208  case 0:
209  pView->haloing_enabled = false;
210  break;
211 
212  case 1:
213  pView->haloing_enabled = true;
214  break;
215 
216  default:
218  ("G4OpenGLXmViewer::haloing_callback",
219  "opengl2011", FatalException,
220  "Unrecognised case in haloing_callback.");
221  }
222 
223  pView->SetView ();
224  pView->ClearView ();
225  pView->DrawView ();
226 }
227 
228 void G4OpenGLXmViewer::aux_edge_callback (Widget w,
229  XtPointer clientData,
230  XtPointer)
231 {
232  G4long choice = (G4long)clientData;
233  G4OpenGLXmViewer* pView;
234  XtVaGetValues (XtParent(w),
235  XmNuserData, &pView,
236  NULL);
237 
238  switch (choice) {
239 
240  case 0:
241  pView->fVP.SetAuxEdgeVisible(false);
242  break;
243 
244  case 1:
245  pView->fVP.SetAuxEdgeVisible(true);
246  break;
247 
248  default:
250  ("G4OpenGLXmViewer::aux_edge_callback",
251  "opengl2012", FatalException,
252  "Unrecognised case in aux_edge_callback.");
253  }
254 
255  pView->SetNeedKernelVisit (true);
256  pView->SetView ();
257  pView->ClearView ();
258  pView->DrawView ();
259 }
260 
261 void G4OpenGLXmViewer::projection_callback (Widget w,
262  XtPointer clientData,
263  XtPointer)
264 {
265  G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
266 
267  G4int choice = get_int_userData (w);
268 
269  switch (choice) {
270  case 0:
271  {
272  pView->fVP.SetFieldHalfAngle (0.);
273  break;
274  }
275 
276  case 1:
277  {
278  if (pView->fov > 89.5 || pView->fov <= 0.0) {
279  G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
280  G4cout << G4endl;
281  }
282  else {
283  pView->fVP.SetFieldHalfAngle (pView->fov * deg);
284  }
285  break;
286  }
287  default:
288  {
290  ("G4OpenGLXmViewer::projection_callback",
291  "opengl2013", FatalException,
292  "Unrecognised choice made in projection_callback");
293  }
294  }
295 
296  pView->SetView ();
297  pView->ClearView ();
298  pView->DrawView ();
299 }
300 
301 #endif
302 
#define G4endl
Definition: G4ios.hh:61
long G4long
Definition: G4Types.hh:80
static constexpr double deg
Definition: G4SIunits.hh:152
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout