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