Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLXmViewer.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 10th February 1997
30// G4OpenGLXmViewer : Class derived from G4OpenGLXViewer, to provide
31// (Motif) widget OpenGL functionality for GEANT4.
32
33#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
34
35#include "globals.hh"
36
37#include "G4OpenGLXmViewer.hh"
39
40#include "G4VisExtent.hh"
41#include "G4LogicalVolume.hh"
42#include "G4VSolid.hh"
43#include "G4Point3D.hh"
44#include "G4Normal3D.hh"
45
46#include "G4Scene.hh"
47
50
51#include "G4Xt.hh"
52#include <X11/Shell.h>
53#include <Xm/MainW.h>
54#include <Xm/Frame.h>
55#include <Xm/DrawingA.h>
56
57#include <sstream>
58
59void G4OpenGLXmViewer::ShowView () {
60
61 glXWaitGL (); //Wait for effects of all previous OpenGL commands to
62 //be propagated before progressing.
63 glFlush ();
64
65 G4Xt::getInstance () -> SecondaryLoop ();
66
67}
68
69void G4OpenGLXmViewer::ResetView () {
70 // reset global parameters
71 G4OpenGLViewer::ResetView();
72
73 //reset Xm parameteres
74 zoom_high = fVP.GetZoomFactor() * 10.0;
75 zoom_low = fVP.GetZoomFactor() / 10.0;
76 rot_sens_limit = 90.;
77 wob_low = 0.;
78 wob_high = 50.;
79 wob_sens = 20.;
80
81 bool firstInit = true;
82 if (GetSceneHandler() != NULL) {
83 if (GetSceneHandler()->GetScene() != NULL) {
84 firstInit = false;
85 }
86 }
87 if (firstInit) {
88 pan_sens_limit = 100.;
89 fPan_sens = pan_sens_limit / 10.0;
90 dolly_low = fVP.GetDolly() - 1000.0;
91 dolly_high = fVP.GetDolly() + 1000.0;
92 } else {
93 fPan_sens = GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius() / 10.0;
94 pan_sens_limit = GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius();
95
96 dolly_high = GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius();
97 dolly_low = -(GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius());
98 }
99
100 UpdateControlPanel ();
101
102
103 // FIXME : L.Garnier 12 Oct 2011
104 // Has also to change the Camera/Object, but tricky to do...
105
106}
107
108
109void G4OpenGLXmViewer::GetXmConnection () {
110
111 G4Xt* interactorManager = G4Xt::getInstance ();
112 toplevel = (Widget)interactorManager->GetMainInteractor();
113 app = XtWidgetToApplicationContext(toplevel);
114
115 if (!toplevel) {
116 fViewId = -1; // This flags an error.
117 G4cerr << "G4OpenGLXmViewer::GetXmConnection unable to Initialize"
118 " application context." << G4endl;
119 return;
120 }
121
122 // Better to put this in an X11 resource file !!!
123 std::ostringstream oss;
124 oss <<
125 "*glxarea*width: " << fVP.GetWindowSizeHintX() << "\n"
126 "*glxarea*height: " << fVP.GetWindowSizeHintY() << "\n"
127 /*
128 // Tried this as a replacement for the above two lines, but
129 // sub-windows (rotation, etc.) came same size!!
130 "*geometry: " << fVP.GetXGeometryString() << "\n"
131 */
132 "*frame*x: 10\n"
133 "*frame*y: 10\n"
134 "*frame*topOffset: 10\n"
135 "*frame*bottomOffset: 10\n"
136 "*frame*rightOffset: 10\n"
137 "*frame*leftOffset: 10\n"
138 "*frame*shadowType: SHADOW_IN\n"
139 "*frame*useColorObj: False\n"
140 "*frame*primaryColorSetId: 3\n"
141 "*frame*secondaryColorSetId: 3\n"
142 "*menubar*useColorObj: False\n"
143 "*menubar*primaryColorSetId: 3\n"
144 "*menubar*secondaryColorSetId: 3\n"
145 "*toplevel*useColorObj: False\n"
146 "*toplevel*primaryColorSetId: 3\n"
147 "*toplevel*secondaryColorSetId: 3\n";
148 interactorManager->PutStringInResourceDatabase ((char*)oss.str().c_str());
149
150 // interactorManager->AddSecondaryLoopPostAction ((G4SecondaryLoopAction)G4OpenGLXmViewerSecondaryLoopPostAction);
151
152 shell = XtAppCreateShell ((String)fName.data(),(String)fName.data(),topLevelShellWidgetClass,XtDisplay(toplevel),NULL,0);
153 interactorManager->AddShell (shell);
154
155 dpy = XtDisplay (shell);
156
157 if (!dpy) {
158 fViewId = -1; // This flags an error.
159 G4cerr << "G4OpenGLXmViewer::GetXmConnection unable to connect to display."
160 << G4endl;
161 return;
162 }
163
164 if (!glXQueryExtension (dpy, &errorBase, &eventBase)) {
165 fViewId = -1; // This flags an error.
166 G4cerr << "G4OpenGLXmViewer::GetXmConnection. X Server has no GLX extension."
167 << G4endl;;
168 return;
169 }
170}
171
172void G4OpenGLXmViewer::CreateMainWindow () {
173
174 bgnd = XWhitePixelOfScreen (XtScreen(shell));
175 borcol = XBlackPixelOfScreen (XtScreen(shell));
176
177 ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
178
179 G4int x_origin = fVP.GetWindowAbsoluteLocationHintX(DisplayWidth(dpy, vi -> screen));
180
181 // FIXME, screen size != window size on MAC, but I don't know have to get the menuBar
182 // size on MAC. L.Garnier 01/2009
183 G4int y_origin = fVP.GetWindowAbsoluteLocationHintY(DisplayHeight(dpy, vi -> screen));
184
185 if (fVP.IsWindowSizeHintX () && fVP.IsWindowLocationHintX () && fVP.IsWindowLocationHintY ()) {
186 XtVaSetValues (shell,
187 XtNvisual, vi -> visual,
188 XtNdepth, vi -> depth,
189 XtNcolormap, cmap,
190 XtNwidth, getWinWidth(),
191 XtNheight, getWinHeight(),
192 XtNx, x_origin,
193 XtNy, y_origin,
194 XtNborderColor, &borcol,
195 XtNbackground, &bgnd,
196 XmNtitle, fName.data(),
197 NULL);
198 } else if (fVP.IsWindowSizeHintX () && !(fVP.IsWindowLocationHintX () || fVP.IsWindowLocationHintY ())) {
199 XtVaSetValues (shell,
200 XtNvisual, vi -> visual,
201 XtNdepth, vi -> depth,
202 XtNcolormap, cmap,
203 XtNwidth, getWinWidth(),
204 XtNheight, getWinHeight(),
205 XtNborderColor, &borcol,
206 XtNbackground, &bgnd,
207 XmNtitle, fName.data(),
208 NULL);
209 } else if ((!fVP.IsWindowSizeHintX ()) && fVP.IsWindowLocationHintX () && fVP.IsWindowLocationHintY ()) {
210 XtVaSetValues (shell,
211 XtNvisual, vi -> visual,
212 XtNdepth, vi -> depth,
213 XtNcolormap, cmap,
214 XtNx, x_origin,
215 XtNy, y_origin,
216 XtNborderColor, &borcol,
217 XtNbackground, &bgnd,
218 XmNtitle, fName.data(),
219 NULL);
220 } else {
221 XtVaSetValues (shell,
222 XtNvisual, vi -> visual,
223 XtNdepth, vi -> depth,
224 XtNcolormap, cmap,
225 XtNborderColor, &borcol,
226 XtNbackground, &bgnd,
227 XmNtitle, fName.data(),
228 NULL);
229 }
230
231
232 main_win = XtVaCreateManagedWidget ("main_win",
233 xmMainWindowWidgetClass,
234 shell,
235 XtNvisual, vi -> visual,
236 XtNdepth, vi -> depth,
237 XtNcolormap, cmap,
238 XtNborderColor, borcol,
239 XtNbackground, bgnd,
240 NULL);
241
242 //*********Create a menu bar for the window********
243 style_str = XmStringCreateLocalized ((char*)"Style");
244 actions_str = XmStringCreateLocalized ((char*)"Actions");
245 misc_str = XmStringCreateLocalized ((char*)"Miscellany");
246 spec_str = XmStringCreateLocalized ((char*)"Special");
247
248 menubar = XmVaCreateSimpleMenuBar (main_win,
249 (char*)"menubar",
250 XmVaCASCADEBUTTON, style_str, (KeySym)XK_S, /*G.Barrand : cast to KeySym and use XK_*/
251 XmVaCASCADEBUTTON, actions_str, (KeySym)XK_A,
252 XmVaCASCADEBUTTON, misc_str, (KeySym)XK_M,
253 XmVaCASCADEBUTTON, spec_str, (KeySym)XK_p,
254 XtNvisual, vi -> visual,
255 XtNdepth, vi -> depth,
256 XtNcolormap, cmap,
257 XtNborderColor, borcol,
258 XtNbackground, bgnd,
259 NULL);
260
261 XmStringFree (style_str);
262 XmStringFree (actions_str);
263 XmStringFree (misc_str);
264 XmStringFree (spec_str);
265
266 G4cout << "Created menubar" << G4endl;
267
268
269 //*********Create style pulldown menu on menubar*********
270 draw_str = XmStringCreateLocalized ((char*)"Drawing");
271 bgnd_str = XmStringCreateLocalized ((char*)"Background color");
272
273 style_cascade = XmVaCreateSimplePulldownMenu
274 (menubar,
275 (char*)"style",
276 0,
277 NULL,
278 XmVaCASCADEBUTTON, draw_str, (KeySym)XK_D,
279 XmVaCASCADEBUTTON, bgnd_str, (KeySym)XK_B,
280 XtNvisual, vi -> visual,
281 XtNdepth, vi -> depth,
282 XtNcolormap, cmap,
283 XtNborderColor, borcol,
284 XtNbackground, bgnd,
285 NULL);
286
287 XmStringFree (draw_str);
288 XmStringFree (bgnd_str);
289
290 // G4cout << "Created Style pulldown menu" << G4endl;
291
292 //Add Drawing pullright menu to style cascade...
293 wireframe_str = XmStringCreateLocalized ((char*)"Wireframe");
294 hlr_str = XmStringCreateLocalized ((char*)"Hidden line removal");
295 hsr_str = XmStringCreateLocalized ((char*)"Hidden surface removal");
296 hlhsr_str = XmStringCreateLocalized ((char*)"Hidden line and surface removal");
297
298 drawing_style_pullright = XmVaCreateSimplePulldownMenu
299 (style_cascade,
300 (char*)"drawing_style",
301 1,
302 drawing_style_callback,
303 XmVaRADIOBUTTON, wireframe_str, (KeySym)XK_W, NULL, NULL,
304 XmVaRADIOBUTTON, hlr_str, (KeySym)XK_L, NULL, NULL,
305 XmVaRADIOBUTTON, hsr_str, (KeySym)XK_S, NULL, NULL,
306 XmVaRADIOBUTTON, hlhsr_str, (KeySym)XK_H, NULL, NULL,
307 XmNradioBehavior, True,
308 XmNradioAlwaysOne, True,
309 XmNuserData, this,
310 XtNvisual, vi -> visual,
311 XtNdepth, vi -> depth,
312 XtNcolormap, cmap,
313 XtNborderColor, borcol,
314 XtNbackground, bgnd,
315 NULL);
316
317 Widget special_widget;
318
320 d_style = fVP.GetDrawingStyle();
321
322 if (d_style == G4ViewParameters::wireframe) {
323 special_widget = XtNameToWidget(drawing_style_pullright, "button_0");
324 if(special_widget) {
325 XtVaSetValues (special_widget, XmNset, True, NULL);
326 }
327 } else if (d_style == G4ViewParameters::hlr) {
328 special_widget = XtNameToWidget(drawing_style_pullright, "button_1");
329 if(special_widget) {
330 XtVaSetValues (special_widget, XmNset, True, NULL);
331 }
332 } else if (d_style == G4ViewParameters::hsr) {
333 special_widget = XtNameToWidget(drawing_style_pullright, "button_2");
334 if(special_widget) {
335 XtVaSetValues (special_widget, XmNset, True, NULL);
336 }
337 } else if (d_style == G4ViewParameters::hlhsr) {
338 special_widget = XtNameToWidget(drawing_style_pullright, "button_3");
339 if(special_widget) {
340 XtVaSetValues (special_widget, XmNset, True, NULL);
341 }
342 } else {
344 ("G4OpenGLXmViewer::CreateMainWindow",
345 "opengl2015", FatalException,
346 "Invalid Drawing style in G4OpenGLXmViewer::CreateContext");
347 }
348
349 XmStringFree (wireframe_str);
350 XmStringFree (hlr_str);
351 XmStringFree (hsr_str);
352 XmStringFree (hlhsr_str);
353
354 // G4cout << "Created Drawing pullright menu" << G4endl;
355
356 //Add Drawing pullright menu to style cascade...
357 white_str = XmStringCreateLocalized ((char*)"White");
358 black_str = XmStringCreateLocalized ((char*)"Black");
359
360 background_color_pullright = XmVaCreateSimplePulldownMenu
361 (style_cascade,
362 (char*)"background_color",
363 2,
364 background_color_callback,
365 XmVaRADIOBUTTON, white_str, (KeySym)XK_W, NULL, NULL,
366 XmVaRADIOBUTTON, black_str, (KeySym)XK_B, NULL, NULL,
367 XmNradioBehavior, True,
368 XmNradioAlwaysOne, True,
369 XmNuserData, this,
370 XtNvisual, vi -> visual,
371 XtNdepth, vi -> depth,
372 XtNcolormap, cmap,
373 XtNborderColor, borcol,
374 XtNbackground, bgnd,
375 NULL);
376
377 if (background.GetRed() == 1. &&
378 background.GetGreen() == 1. &&
379 background.GetBlue() == 1.) {
380 special_widget = XtNameToWidget(background_color_pullright, "button_0");
381 if(special_widget) {
382 XtVaSetValues (special_widget, XmNset, True, NULL);
383 }
384 } else {
385 special_widget = XtNameToWidget(background_color_pullright, "button_1");
386 if(special_widget) {
387 XtVaSetValues (special_widget, XmNset, True, NULL);
388 }
389 }
390
391 XmStringFree (white_str);
392 XmStringFree (black_str);
393
394 // G4cout << "Created Background color pullright menu" << G4endl;
395
396 //*********Create actions pulldown menu on menubar*********
397 rot_str = XmStringCreateLocalized ((char*)"Rotation control panel");
398 pan_str = XmStringCreateLocalized ((char*)"Panning control panel");
399 set_str = XmStringCreateLocalized ((char*)"Set control panel limits");
400
401 actions_cascade = XmVaCreateSimplePulldownMenu
402 (menubar,
403 (char*)"actions",
404 1,
405 actions_callback,
406 XmVaPUSHBUTTON, rot_str, (KeySym)XK_R, NULL, NULL,
407 XmVaPUSHBUTTON, pan_str, (KeySym)XK_P, NULL, NULL,
408 XmVaPUSHBUTTON, set_str, (KeySym)XK_S, NULL, NULL,
409 XmNuserData, this,
410 XtNvisual, vi -> visual,
411 XtNdepth, vi -> depth,
412 XtNcolormap, cmap,
413 XtNborderColor, borcol,
414 XtNbackground, bgnd,
415 NULL);
416
417 XmStringFree (rot_str);
418 XmStringFree (pan_str);
419 XmStringFree (set_str);
420 G4cout << "Created Actions pulldown menu" << G4endl;
421
422 misc_str = XmStringCreateLocalized ((char*)"Miscellany control panel");
423 exit_str = XmStringCreateLocalized ((char*)"Exit to G4Vis>");
424 print_str = XmStringCreateLocalized ((char*)"Create .eps file");
425
426 //*********Create miscellany pulldown menu on menubar*********
427 misc_cascade = XmVaCreateSimplePulldownMenu
428 (menubar,
429 (char*)"miscellany",
430 2,
431 misc_callback,
432 XmVaPUSHBUTTON, misc_str, (KeySym)XK_M, NULL, NULL,
433 XmVaPUSHBUTTON, exit_str, (KeySym)XK_E, NULL, NULL,
434 XmVaPUSHBUTTON, print_str, (KeySym)XK_P, NULL, NULL,
435 XmNuserData, this,
436 XtNvisual, vi -> visual,
437 XtNdepth, vi -> depth,
438 XtNcolormap, cmap,
439 XtNborderColor, borcol,
440 XtNbackground, bgnd,
441 NULL);
442
443 XmStringFree (misc_str);
444 XmStringFree (exit_str);
445 XmStringFree (print_str);
446 G4cout << "Created Miscellany pulldown menu" << G4endl;
447
448 trans_str = XmStringCreateLocalized ((char*)"Transparency");
449 anti_str = XmStringCreateLocalized ((char*)"Antialiasing");
450 halo_str = XmStringCreateLocalized ((char*)"Haloing");
451 aux_edge_str = XmStringCreateLocalized ((char*)"Auxiliary edges");
452
453 //*********Create special pulldown menu on menubar*********
454 spec_cascade = XmVaCreateSimplePulldownMenu
455 (menubar,
456 (char*)"special",
457 3,
458 NULL,
459 XmVaCASCADEBUTTON, trans_str, (KeySym)XK_T,
460 XmVaCASCADEBUTTON, anti_str, (KeySym)XK_A,
461 XmVaCASCADEBUTTON, halo_str, (KeySym)XK_H,
462 XmVaCASCADEBUTTON, aux_edge_str, (KeySym)XK_E,
463 XtNvisual, vi -> visual,
464 XtNdepth, vi -> depth,
465 XtNcolormap, cmap,
466 XtNborderColor, borcol,
467 XtNbackground, bgnd,
468 NULL);
469
470 XmStringFree (trans_str);
471 XmStringFree (anti_str);
472 XmStringFree (halo_str);
473 XmStringFree (aux_edge_str);
474
475 // G4cout << "Created Special pulldown menu" << G4endl;
476
477 //Add Transparency pullright menu to special cascade...
478 off_str = XmStringCreateLocalized ((char*)"Off");
479 on_str = XmStringCreateLocalized ((char*)"On");
480
481 transparency_pullright = XmVaCreateSimplePulldownMenu
482 (spec_cascade,
483 (char*)"transparency",
484 0,
485 transparency_callback,
486 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, NULL, NULL,
487 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, NULL, NULL,
488 XmNradioBehavior, True,
489 XmNradioAlwaysOne, True,
490 XmNuserData, this,
491 XtNvisual, vi -> visual,
492 XtNdepth, vi -> depth,
493 XtNcolormap, cmap,
494 XtNborderColor, borcol,
495 XtNbackground, bgnd,
496 NULL);
497
498 if (transparency_enabled == false) {
499 special_widget = XtNameToWidget(transparency_pullright, "button_0");
500 if(special_widget) {
501 XtVaSetValues (special_widget, XmNset, True, NULL);
502 }
503 } else if (transparency_enabled == true) {
504 special_widget = XtNameToWidget(transparency_pullright, "button_1");
505 if(special_widget) {
506 XtVaSetValues (special_widget, XmNset, True, NULL);
507 }
508 } else {
510 ("G4OpenGLXmViewer::CreateMainWindow",
511 "opengl2016", FatalException,
512 "transparency_enabled in G4OpenGLXmViewer is neither true nor false!!");
513 }
514
515 //Add antialias pullright menu to special cascade...
516 antialias_pullright = XmVaCreateSimplePulldownMenu
517 (spec_cascade,
518 (char*)"antialias",
519 1,
520 antialias_callback,
521 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, NULL, NULL,
522 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, NULL, NULL,
523 XmNradioBehavior, True,
524 XmNradioAlwaysOne, True,
525 XmNuserData, this,
526 XtNvisual, vi -> visual,
527 XtNdepth, vi -> depth,
528 XtNcolormap, cmap,
529 XtNborderColor, borcol,
530 XtNbackground, bgnd,
531 NULL);
532
533 if (antialiasing_enabled == false) {
534 special_widget = XtNameToWidget(antialias_pullright, "button_0");
535 if(special_widget) {
536 XtVaSetValues (special_widget, XmNset, True, NULL);
537 }
538 } else if (antialiasing_enabled == true) {
539 special_widget = XtNameToWidget(antialias_pullright, "button_1");
540 if(special_widget) {
541 XtVaSetValues (special_widget, XmNset, True, NULL);
542 }
543 } else {
545 ("G4OpenGLXmViewer::CreateMainWindow",
546 "opengl2017", FatalException,
547 "antialiasing_enabled in G4OpenGLXmViewer is neither true nor false!!");
548 }
549
550 //Add Haloing pullright menu to special cascade...
551 haloing_pullright = XmVaCreateSimplePulldownMenu
552 (spec_cascade,
553 (char*)"haloing",
554 2,
555 haloing_callback,
556 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, NULL, NULL,
557 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, NULL, NULL,
558 XmNradioBehavior, True,
559 XmNradioAlwaysOne, True,
560 XmNuserData, this,
561 XtNvisual, vi -> visual,
562 XtNdepth, vi -> depth,
563 XtNcolormap, cmap,
564 XtNborderColor, borcol,
565 XtNbackground, bgnd,
566 NULL);
567
568 if (haloing_enabled == false) {
569 special_widget = XtNameToWidget(haloing_pullright, "button_0");
570 if(special_widget) {
571 XtVaSetValues (special_widget, XmNset, True, NULL);
572 }
573 } else if (haloing_enabled == true) {
574 special_widget = XtNameToWidget(haloing_pullright, "button_1");
575 if(special_widget) {
576 XtVaSetValues (special_widget, XmNset, True, NULL);
577 }
578 } else {
580 ("G4OpenGLXmViewer::CreateMainWindow",
581 "opengl2018", FatalException,
582 "haloing_enabled in G4OpenGLXmViewer is neither true nor false!!");
583 }
584
585 //Add Aux_Edge pullright menu to special cascade...
586 aux_edge_pullright = XmVaCreateSimplePulldownMenu
587 (spec_cascade,
588 (char*)"aux_edge",
589 3,
590 aux_edge_callback,
591 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, NULL, NULL,
592 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, NULL, NULL,
593 XmNradioBehavior, True,
594 XmNradioAlwaysOne, True,
595 XmNuserData, this,
596 XtNvisual, vi -> visual,
597 XtNdepth, vi -> depth,
598 XtNcolormap, cmap,
599 XtNborderColor, borcol,
600 XtNbackground, bgnd,
601 NULL);
602
603 if (!fVP.IsAuxEdgeVisible()) {
604 special_widget = XtNameToWidget(aux_edge_pullright, "button_0");
605 if(special_widget) {
606 XtVaSetValues (special_widget, XmNset, True, NULL);
607 }
608 } else {
609 special_widget = XtNameToWidget(aux_edge_pullright, "button_1");
610 if(special_widget) {
611 XtVaSetValues (special_widget, XmNset, True, NULL);
612 }
613 }
614
615 XtManageChild (menubar);
616 frame = XtVaCreateManagedWidget ((char*)"frame",
617 xmFrameWidgetClass, main_win,
618 XtNvisual, vi -> visual,
619 XtNdepth, vi -> depth,
620 XtNcolormap, cmap,
621 XtNborderColor, borcol,
622 XtNbackground, bgnd,
623 NULL);
624
625 glxarea = XtVaCreateManagedWidget ((char*)"glxarea",
626 xmDrawingAreaWidgetClass,
627 frame,
628 XtNvisual, vi -> visual,
629 XtNdepth, vi -> depth,
630 XtNcolormap, cmap,
631 XtNborderColor, borcol,
632 XtNbackground, bgnd,
633 NULL);
634
635
636 XmMainWindowSetAreas (main_win, // main widget, children are specified
637 menubar, // widget to use as menu bar
638 NULL, // widget to use as command window
639 NULL, // widget for horizontal scroll bar
640 NULL, // widget for vertical scroll bar
641 frame // widget to be used for work window
642 );
643
644 XtRealizeWidget(shell);
645
646 // Once widget is realized (ie, associated with a created X window), we
647 // can bind the OpenGL rendering context to the window.
648
649 win = XtWindow (glxarea);
650
651 glXMakeCurrent (dpy, win, cxMaster);
652
653 // This should be add AFTER glXMakeCurrent done because it will fire a resizeCallback
654 XtAddCallback (glxarea,
655 XmNresizeCallback,
656 resize_callback,
657 this);
658
659 XtAddCallback (glxarea,
660 XmNexposeCallback,
661 expose_callback,
662 this);
663
664}
665
666G4OpenGLXmViewer::G4OpenGLXmViewer (G4OpenGLSceneHandler& scene):
667G4VViewer (scene, -1),
668G4OpenGLViewer (scene),
669G4OpenGLXViewer (scene),
670toplevel (0),
671shell (0),
672main_win (0),
673menubar (0),
674style_cascade (0),
675actions_cascade (0),
676misc_cascade (0),
677spec_cascade (0),
678drawing_style_pullright (0),
679background_color_pullright (0),
680transparency_pullright (0),
681antialias_pullright (0),
682haloing_pullright (0),
683aux_edge_pullright (0),
684frame (0),
685glxarea (0),
686style_str (0),
687actions_str (0),
688misc_str (0),
689spec_str (0),
690draw_str (0),
691polyhedron_str (0),
692wireframe_str (0),
693hlr_str (0),
694hsr_str (0),
695hlhsr_str (0),
696set_str (0),
697rot_str (0),
698pan_str (0),
699exit_str (0),
700quit_str (0),
701print_str (0),
702white_str (0),
703black_str (0),
704anti_str (0),
705trans_str (0),
706halo_str (0),
707aux_edge_str (0),
708bgnd_str (0),
709off_str (0),
710on_str (0),
711zoom_high (0.0),
712zoom_low (0.0),
713pan_low (0.0),
714pan_high (0.0),
715dolly_low (0.0),
716dolly_high (0.0),
717fov (0.0),
718rot_sens_limit (0.0),
719pan_sens_limit (0.0),
720wob_high (0.0),
721wob_low (0.0),
722wob_sens (0.0),
723pan_right (false),
724rotate_right (false),
725pan_up (false),
726rotate_up (false),
727original_vp(fVP.GetViewpointDirection()),
728frameNo (0),
729fprotation_top (0),
730fprotation_button_box (0),
731fprotation_button1 (0),
732fprotation_button2 (0),
733fprotation_slider_box (0),
734fprotation_slider (0),
735fprotation_arrow_box (0),
736fprotation_arrow (0),
737fppanning_top (0),
738fppanning_box (0),
739fppanning_arrows (0),
740fppanning_slider (0),
741fpzoom_box (0),
742fpzoom_slider (0),
743fpdolly_box (0),
744fpdolly_slider (0),
745fpsetting_top (0),
746fpsetting_box (0),
747fppan_set (0),
748fprot_set (0),
749fpzoom_upper (0),
750fpzoom_lower (0),
751fpdolly_upper (0),
752fpdolly_lower (0),
753fpok_button (0),
754fpmiscellany_top (0),
755fpwobble_box (0),
756fpwobble_button (0),
757fpwobble_slider (0),
758fpreset_box (0),
759fpreset_button (0),
760fpproj_style_box (0),
761fporthogonal_button (0),
762fpperspective_button (0),
763fpfov_text (0),
764fpprint_top (0),
765fpprint_box (0),
766fpprint_col_box (0),
767fpprint_style_box (0),
768fpprint_text (0),
769fpprint_button (0),
770fpprint_line (0),
771fpprint_col_radio1 (0),
772fpprint_col_radio2 (0),
773fpprint_style_radio1 (0),
774fpprint_style_radio2 (0)
775{
776 GetXmConnection ();
777 ResetView();
778 if (fViewId < 0) return;
779}
780
781
782void G4OpenGLXmViewer::UpdateControlPanel () {
783
784 // set new values
785
786 if (fprotation_slider) {
787 fprotation_slider->SetInitialValue(fRot_sens);
788 fprotation_slider->SetMaxValue(rot_sens_limit);
789 fprotation_slider->SetMinValue(0);
790 }
791 if (fppanning_slider) {
792 fppanning_slider->SetInitialValue(fPan_sens);
793 fppanning_slider->SetMaxValue(pan_sens_limit);
794 fppanning_slider->SetMinValue(0);
795 }
796 if (fpzoom_slider) {
797 fpzoom_slider->SetInitialValue(fVP.GetZoomFactor());
798 fpzoom_slider->SetMinValue(zoom_low);
799 fpzoom_slider->SetMaxValue(zoom_high);
800 }
801 if (fpdolly_slider) {
802 fpdolly_slider->SetInitialValue(fVP.GetDolly());
803 fpdolly_slider->SetMinValue(dolly_low);
804 fpdolly_slider->SetMaxValue(dolly_high);
805 }
806
807 if (fpwobble_slider) {
808 fpwobble_slider->SetInitialValue(fVP.GetDolly());
809 }
810
811 if (fppan_set) {
812 fppan_set->SetValue(pan_sens_limit);
813 }
814
815 if (fprot_set) {
816 fprot_set->SetValue(rot_sens_limit);
817 }
818
819 if (fpzoom_upper) {
820 fpzoom_upper->SetValue(zoom_high);
821 }
822
823 if (fpzoom_lower) {
824 fpzoom_lower->SetValue(zoom_low);
825 }
826 if (fpdolly_upper) {
827 fpdolly_upper->SetValue(dolly_high);
828 }
829
830 if (fpdolly_lower) {
831 fpdolly_lower->SetValue(dolly_low);
832 }
833
834
835}
836
837
838G4OpenGLXmViewer::~G4OpenGLXmViewer ()
839{
840 XtDestroyWidget (shell);
841 win = 0; // ...to avoid XDestroyWindow in G4OpenGLXViewer base class
842 // because XtDestroyWidget has already destroyed it.
843 G4Xt::getInstance () ->RemoveShell (shell);
844
845/******************************
846 if (fprotation_top) {
847 delete fprotation_top;
848 }
849
850 if (fppanning_top) {
851 delete fppanning_top;
852 }
853
854 if (fpsetting_top) {
855 delete fpsetting_top;
856 }
857
858 if (fpmiscellany_top) {
859 delete fpmiscellany_top;
860 }
861******************************/
862
863}
864
865#endif
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const char * data() const