Geant4_10
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: G4OpenGLXmViewer.cc 68043 2013-03-13 14:27:49Z gcosmo $
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"
39 #include "G4OpenGLSceneHandler.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 
49 #include "G4OpenGLXmSliderBar.hh"
50 #include "G4OpenGLXmTextField.hh"
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 
60 void G4OpenGLXmViewer::ShowView () {
61 
62  G4Xt::getInstance () -> SecondaryLoop ();
63 
64 }
65 
66 void 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 
106 void 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 
169 void 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  draw_str = XmStringCreateLocalized ((char*)"Drawing");
268  bgnd_str = XmStringCreateLocalized ((char*)"Background color");
269 
270  style_cascade = XmVaCreateSimplePulldownMenu
271  (menubar,
272  (char*)"style",
273  0,
274  NULL,
275  XmVaCASCADEBUTTON, draw_str, 'D',
276  XmVaCASCADEBUTTON, bgnd_str, 'B',
277  XtNvisual, vi -> visual,
278  XtNdepth, vi -> depth,
279  XtNcolormap, cmap,
280  XtNborderColor, borcol,
281  XtNbackground, bgnd,
282  NULL);
283 
284  XmStringFree (draw_str);
285  XmStringFree (bgnd_str);
286 
287  // G4cout << "Created Style pulldown menu" << G4endl;
288 
289  //Add Drawing pullright menu to style cascade...
290  wireframe_str = XmStringCreateLocalized ((char*)"Wireframe");
291  hlr_str = XmStringCreateLocalized ((char*)"Hidden line removal");
292  hsr_str = XmStringCreateLocalized ((char*)"Hidden surface removal");
293  hlhsr_str = XmStringCreateLocalized ((char*)"Hidden line and surface removal");
294 
295  drawing_style_pullright = XmVaCreateSimplePulldownMenu
296  (style_cascade,
297  (char*)"drawing_style",
298  1,
299  drawing_style_callback,
300  XmVaRADIOBUTTON, wireframe_str, 'W', NULL, NULL,
301  XmVaRADIOBUTTON, hlr_str, 'L', NULL, NULL,
302  XmVaRADIOBUTTON, hsr_str, 'S', NULL, NULL,
303  XmVaRADIOBUTTON, hlhsr_str, 'H', NULL, NULL,
304  XmNradioBehavior, True,
305  XmNradioAlwaysOne, True,
306  XmNuserData, this,
307  XtNvisual, vi -> visual,
308  XtNdepth, vi -> depth,
309  XtNcolormap, cmap,
310  XtNborderColor, borcol,
311  XtNbackground, bgnd,
312  NULL);
313 
314  Widget special_widget;
315 
317  d_style = fVP.GetDrawingStyle();
318 
319  if (d_style == G4ViewParameters::wireframe) {
320  special_widget = XtNameToWidget(drawing_style_pullright, "button_0");
321  if(special_widget) {
322  XtVaSetValues (special_widget, XmNset, True, NULL);
323  }
324  } else if (d_style == G4ViewParameters::hlr) {
325  special_widget = XtNameToWidget(drawing_style_pullright, "button_1");
326  if(special_widget) {
327  XtVaSetValues (special_widget, XmNset, True, NULL);
328  }
329  } else if (d_style == G4ViewParameters::hsr) {
330  special_widget = XtNameToWidget(drawing_style_pullright, "button_2");
331  if(special_widget) {
332  XtVaSetValues (special_widget, XmNset, True, NULL);
333  }
334  } else if (d_style == G4ViewParameters::hlhsr) {
335  special_widget = XtNameToWidget(drawing_style_pullright, "button_3");
336  if(special_widget) {
337  XtVaSetValues (special_widget, XmNset, True, NULL);
338  }
339  } else {
341  ("G4OpenGLXmViewer::CreateMainWindow",
342  "opengl2015", FatalException,
343  "Invalid Drawing style in G4OpenGLXmViewer::CreateContext");
344  }
345 
346  XmStringFree (wireframe_str);
347  XmStringFree (hlr_str);
348  XmStringFree (hsr_str);
349  XmStringFree (hlhsr_str);
350 
351  // G4cout << "Created Drawing pullright menu" << G4endl;
352 
353  //Add Drawing pullright menu to style cascade...
354  white_str = XmStringCreateLocalized ((char*)"White");
355  black_str = XmStringCreateLocalized ((char*)"Black");
356 
357  background_color_pullright = XmVaCreateSimplePulldownMenu
358  (style_cascade,
359  (char*)"background_color",
360  2,
361  background_color_callback,
362  XmVaRADIOBUTTON, white_str, 'W', NULL, NULL,
363  XmVaRADIOBUTTON, black_str, 'B', NULL, NULL,
364  XmNradioBehavior, True,
365  XmNradioAlwaysOne, True,
366  XmNuserData, this,
367  XtNvisual, vi -> visual,
368  XtNdepth, vi -> depth,
369  XtNcolormap, cmap,
370  XtNborderColor, borcol,
371  XtNbackground, bgnd,
372  NULL);
373 
374  if (background.GetRed() == 1. &&
375  background.GetGreen() == 1. &&
376  background.GetBlue() == 1.) {
377  special_widget = XtNameToWidget(background_color_pullright, "button_0");
378  if(special_widget) {
379  XtVaSetValues (special_widget, XmNset, True, NULL);
380  }
381  } else {
382  special_widget = XtNameToWidget(background_color_pullright, "button_1");
383  if(special_widget) {
384  XtVaSetValues (special_widget, XmNset, True, NULL);
385  }
386  }
387 
388  XmStringFree (white_str);
389  XmStringFree (black_str);
390 
391  // G4cout << "Created Background color pullright menu" << G4endl;
392 
393  //*********Create actions pulldown menu on menubar*********
394  rot_str = XmStringCreateLocalized ((char*)"Rotation control panel");
395  pan_str = XmStringCreateLocalized ((char*)"Panning control panel");
396  set_str = XmStringCreateLocalized ((char*)"Set control panel limits");
397 
398  actions_cascade = XmVaCreateSimplePulldownMenu
399  (menubar,
400  (char*)"actions",
401  1,
402  actions_callback,
403  XmVaPUSHBUTTON, rot_str, 'R', NULL, NULL,
404  XmVaPUSHBUTTON, pan_str, 'P', NULL, NULL,
405  XmVaPUSHBUTTON, set_str, 'S', NULL, NULL,
406  XmNuserData, this,
407  XtNvisual, vi -> visual,
408  XtNdepth, vi -> depth,
409  XtNcolormap, cmap,
410  XtNborderColor, borcol,
411  XtNbackground, bgnd,
412  NULL);
413 
414  XmStringFree (rot_str);
415  XmStringFree (pan_str);
416  XmStringFree (set_str);
417  G4cout << "Created Actions pulldown menu" << G4endl;
418 
419  misc_str = XmStringCreateLocalized ((char*)"Miscellany control panel");
420  exit_str = XmStringCreateLocalized ((char*)"Exit to G4Vis>");
421  print_str = XmStringCreateLocalized ((char*)"Create .eps file");
422 
423  //*********Create miscellany pulldown menu on menubar*********
424  misc_cascade = XmVaCreateSimplePulldownMenu
425  (menubar,
426  (char*)"miscellany",
427  2,
428  misc_callback,
429  XmVaPUSHBUTTON, misc_str, 'M', NULL, NULL,
430  XmVaPUSHBUTTON, exit_str, 'E', NULL, NULL,
431  XmVaPUSHBUTTON, print_str, 'P', NULL, NULL,
432  XmNuserData, this,
433  XtNvisual, vi -> visual,
434  XtNdepth, vi -> depth,
435  XtNcolormap, cmap,
436  XtNborderColor, borcol,
437  XtNbackground, bgnd,
438  NULL);
439 
440  XmStringFree (misc_str);
441  XmStringFree (exit_str);
442  XmStringFree (print_str);
443  G4cout << "Created Miscellany pulldown menu" << G4endl;
444 
445  trans_str = XmStringCreateLocalized ((char*)"Transparency");
446  anti_str = XmStringCreateLocalized ((char*)"Antialiasing");
447  halo_str = XmStringCreateLocalized ((char*)"Haloing");
448  aux_edge_str = XmStringCreateLocalized ((char*)"Auxiliary edges");
449 
450  //*********Create special pulldown menu on menubar*********
451  spec_cascade = XmVaCreateSimplePulldownMenu
452  (menubar,
453  (char*)"special",
454  3,
455  NULL,
456  XmVaCASCADEBUTTON, trans_str, 'T',
457  XmVaCASCADEBUTTON, anti_str, 'A',
458  XmVaCASCADEBUTTON, halo_str, 'H',
459  XmVaCASCADEBUTTON, aux_edge_str, 'E',
460  XtNvisual, vi -> visual,
461  XtNdepth, vi -> depth,
462  XtNcolormap, cmap,
463  XtNborderColor, borcol,
464  XtNbackground, bgnd,
465  NULL);
466 
467  XmStringFree (trans_str);
468  XmStringFree (anti_str);
469  XmStringFree (halo_str);
470  XmStringFree (aux_edge_str);
471 
472  // G4cout << "Created Special pulldown menu" << G4endl;
473 
474  //Add Transparency pullright menu to special cascade...
475  off_str = XmStringCreateLocalized ((char*)"Off");
476  on_str = XmStringCreateLocalized ((char*)"On");
477 
478  transparency_pullright = XmVaCreateSimplePulldownMenu
479  (spec_cascade,
480  (char*)"transparency",
481  0,
482  transparency_callback,
483  XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
484  XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
485  XmNradioBehavior, True,
486  XmNradioAlwaysOne, True,
487  XmNuserData, this,
488  XtNvisual, vi -> visual,
489  XtNdepth, vi -> depth,
490  XtNcolormap, cmap,
491  XtNborderColor, borcol,
492  XtNbackground, bgnd,
493  NULL);
494 
495  if (transparency_enabled == false) {
496  special_widget = XtNameToWidget(transparency_pullright, "button_0");
497  if(special_widget) {
498  XtVaSetValues (special_widget, XmNset, True, NULL);
499  }
500  } else if (transparency_enabled == true) {
501  special_widget = XtNameToWidget(transparency_pullright, "button_1");
502  if(special_widget) {
503  XtVaSetValues (special_widget, XmNset, True, NULL);
504  }
505  } else {
507  ("G4OpenGLXmViewer::CreateMainWindow",
508  "opengl2016", FatalException,
509  "transparency_enabled in G4OpenGLXmViewer is neither true nor false!!");
510  }
511 
512  //Add antialias pullright menu to special cascade...
513  antialias_pullright = XmVaCreateSimplePulldownMenu
514  (spec_cascade,
515  (char*)"antialias",
516  1,
517  antialias_callback,
518  XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
519  XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
520  XmNradioBehavior, True,
521  XmNradioAlwaysOne, True,
522  XmNuserData, this,
523  XtNvisual, vi -> visual,
524  XtNdepth, vi -> depth,
525  XtNcolormap, cmap,
526  XtNborderColor, borcol,
527  XtNbackground, bgnd,
528  NULL);
529 
530  if (antialiasing_enabled == false) {
531  special_widget = XtNameToWidget(antialias_pullright, "button_0");
532  if(special_widget) {
533  XtVaSetValues (special_widget, XmNset, True, NULL);
534  }
535  } else if (antialiasing_enabled == true) {
536  special_widget = XtNameToWidget(antialias_pullright, "button_1");
537  if(special_widget) {
538  XtVaSetValues (special_widget, XmNset, True, NULL);
539  }
540  } else {
542  ("G4OpenGLXmViewer::CreateMainWindow",
543  "opengl2017", FatalException,
544  "antialiasing_enabled in G4OpenGLXmViewer is neither true nor false!!");
545  }
546 
547  //Add Haloing pullright menu to special cascade...
548  haloing_pullright = XmVaCreateSimplePulldownMenu
549  (spec_cascade,
550  (char*)"haloing",
551  2,
552  haloing_callback,
553  XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
554  XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
555  XmNradioBehavior, True,
556  XmNradioAlwaysOne, True,
557  XmNuserData, this,
558  XtNvisual, vi -> visual,
559  XtNdepth, vi -> depth,
560  XtNcolormap, cmap,
561  XtNborderColor, borcol,
562  XtNbackground, bgnd,
563  NULL);
564 
565  if (haloing_enabled == false) {
566  special_widget = XtNameToWidget(haloing_pullright, "button_0");
567  if(special_widget) {
568  XtVaSetValues (special_widget, XmNset, True, NULL);
569  }
570  } else if (haloing_enabled == true) {
571  special_widget = XtNameToWidget(haloing_pullright, "button_1");
572  if(special_widget) {
573  XtVaSetValues (special_widget, XmNset, True, NULL);
574  }
575  } else {
577  ("G4OpenGLXmViewer::CreateMainWindow",
578  "opengl2018", FatalException,
579  "haloing_enabled in G4OpenGLXmViewer is neither true nor false!!");
580  }
581 
582  //Add Aux_Edge pullright menu to special cascade...
583  aux_edge_pullright = XmVaCreateSimplePulldownMenu
584  (spec_cascade,
585  (char*)"aux_edge",
586  3,
587  aux_edge_callback,
588  XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
589  XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
590  XmNradioBehavior, True,
591  XmNradioAlwaysOne, True,
592  XmNuserData, this,
593  XtNvisual, vi -> visual,
594  XtNdepth, vi -> depth,
595  XtNcolormap, cmap,
596  XtNborderColor, borcol,
597  XtNbackground, bgnd,
598  NULL);
599 
600  if (!fVP.IsAuxEdgeVisible()) {
601  special_widget = XtNameToWidget(aux_edge_pullright, "button_0");
602  if(special_widget) {
603  XtVaSetValues (special_widget, XmNset, True, NULL);
604  }
605  } else {
606  special_widget = XtNameToWidget(aux_edge_pullright, "button_1");
607  if(special_widget) {
608  XtVaSetValues (special_widget, XmNset, True, NULL);
609  }
610  }
611 
612  XtManageChild (menubar);
613  frame = XtVaCreateManagedWidget ((char*)"frame",
614  xmFrameWidgetClass, main_win,
615  XtNvisual, vi -> visual,
616  XtNdepth, vi -> depth,
617  XtNcolormap, cmap,
618  XtNborderColor, borcol,
619  XtNbackground, bgnd,
620  NULL);
621 
622  glxarea = XtVaCreateManagedWidget ((char*)"glxarea",
623  xmDrawingAreaWidgetClass,
624  frame,
625  XtNvisual, vi -> visual,
626  XtNdepth, vi -> depth,
627  XtNcolormap, cmap,
628  XtNborderColor, borcol,
629  XtNbackground, bgnd,
630  NULL);
631 
632 
633  XmMainWindowSetAreas (main_win, // main widget, children are specified
634  menubar, // widget to use as menu bar
635  NULL, // widget to use as command window
636  NULL, // widget for horizontal scroll bar
637  NULL, // widget for vertical scroll bar
638  frame // widget to be used for work window
639  );
640 
641  XtRealizeWidget(shell);
642 
643  // Once widget is realized (ie, associated with a created X window), we
644  // can bind the OpenGL rendering context to the window.
645 
646  win = XtWindow (glxarea);
647 
648  glXMakeCurrent (dpy, win, cx);
649 
650  // This should be add AFTER glXMakeCurrent done because it will fire a resizeCallback
651  XtAddCallback (glxarea,
652  XmNresizeCallback,
653  resize_callback,
654  this);
655 
656  XtAddCallback (glxarea,
657  XmNexposeCallback,
658  expose_callback,
659  this);
660 
661 }
662 
663 G4OpenGLXmViewer::G4OpenGLXmViewer (G4OpenGLSceneHandler& scene):
664 G4VViewer (scene, -1),
665 G4OpenGLViewer (scene),
666 G4OpenGLXViewer (scene),
667 toplevel (0),
668 shell (0),
669 main_win (0),
670 menubar (0),
671 style_cascade (0),
672 actions_cascade (0),
673 misc_cascade (0),
674 spec_cascade (0),
675 drawing_style_pullright (0),
676 background_color_pullright (0),
677 transparency_pullright (0),
678 antialias_pullright (0),
679 haloing_pullright (0),
680 aux_edge_pullright (0),
681 frame (0),
682 glxarea (0),
683 style_str (0),
684 actions_str (0),
685 misc_str (0),
686 spec_str (0),
687 draw_str (0),
688 polyhedron_str (0),
689 wireframe_str (0),
690 hlr_str (0),
691 hsr_str (0),
692 hlhsr_str (0),
693 set_str (0),
694 rot_str (0),
695 pan_str (0),
696 exit_str (0),
697 quit_str (0),
698 print_str (0),
699 white_str (0),
700 black_str (0),
701 anti_str (0),
702 trans_str (0),
703 halo_str (0),
704 aux_edge_str (0),
705 bgnd_str (0),
706 off_str (0),
707 on_str (0),
708 zoom_high (0.0),
709 zoom_low (0.0),
710 pan_low (0.0),
711 pan_high (0.0),
712 dolly_low (0.0),
713 dolly_high (0.0),
714 fov (0.0),
715 rot_sens_limit (0.0),
716 pan_sens_limit (0.0),
717 wob_high (0.0),
718 wob_low (0.0),
719 wob_sens (0.0),
720 pan_right (false),
721 rotate_right (false),
722 pan_up (false),
723 rotate_up (false),
724 original_vp(fVP.GetViewpointDirection()),
725 frameNo (0),
726 fprotation_top (0),
727 fprotation_button_box (0),
728 fprotation_button1 (0),
729 fprotation_button2 (0),
730 fprotation_slider_box (0),
731 fprotation_slider (0),
732 fprotation_arrow_box (0),
733 fprotation_arrow (0),
734 fppanning_top (0),
735 fppanning_box (0),
736 fppanning_arrows (0),
737 fppanning_slider (0),
738 fpzoom_box (0),
739 fpzoom_slider (0),
740 fpdolly_box (0),
741 fpdolly_slider (0),
742 fpsetting_top (0),
743 fpsetting_box (0),
744 fppan_set (0),
745 fprot_set (0),
746 fpzoom_upper (0),
747 fpzoom_lower (0),
748 fpdolly_upper (0),
749 fpdolly_lower (0),
750 fpok_button (0),
751 fpmiscellany_top (0),
752 fpwobble_box (0),
753 fpwobble_button (0),
754 fpwobble_slider (0),
755 fpreset_box (0),
756 fpreset_button (0),
757 fpproj_style_box (0),
758 fporthogonal_button (0),
759 fpperspective_button (0),
760 fpfov_text (0),
761 fpprint_top (0),
762 fpprint_box (0),
763 fpprint_col_box (0),
764 fpprint_style_box (0),
765 fpprint_text (0),
766 fpprint_button (0),
767 fpprint_line (0),
768 fpprint_col_radio1 (0),
769 fpprint_col_radio2 (0),
770 fpprint_style_radio1 (0),
771 fpprint_style_radio2 (0)
772 {
773  GetXmConnection ();
774  ResetView();
775  if (fViewId < 0) return;
776 }
777 
778 
779 void G4OpenGLXmViewer::UpdateControlPanel () {
780 
781  // set new values
782 
783  if (fprotation_slider) {
784  fprotation_slider->SetInitialValue(fRot_sens);
785  fprotation_slider->SetMaxValue(rot_sens_limit);
786  fprotation_slider->SetMinValue(0);
787  }
788  if (fppanning_slider) {
789  fppanning_slider->SetInitialValue(fPan_sens);
790  fppanning_slider->SetMaxValue(pan_sens_limit);
791  fppanning_slider->SetMinValue(0);
792  }
793  if (fpzoom_slider) {
794  fpzoom_slider->SetInitialValue(fVP.GetZoomFactor());
795  fpzoom_slider->SetMinValue(zoom_low);
796  fpzoom_slider->SetMaxValue(zoom_high);
797  }
798  if (fpdolly_slider) {
799  fpdolly_slider->SetInitialValue(fVP.GetDolly());
800  fpdolly_slider->SetMinValue(dolly_low);
801  fpdolly_slider->SetMaxValue(dolly_high);
802  }
803 
804  if (fpwobble_slider) {
805  fpwobble_slider->SetInitialValue(fVP.GetDolly());
806  }
807 
808  if (fppan_set) {
809  fppan_set->SetValue(pan_sens_limit);
810  }
811 
812  if (fprot_set) {
813  fprot_set->SetValue(rot_sens_limit);
814  }
815 
816  if (fpzoom_upper) {
817  fpzoom_upper->SetValue(zoom_high);
818  }
819 
820  if (fpzoom_lower) {
821  fpzoom_lower->SetValue(zoom_low);
822  }
823  if (fpdolly_upper) {
824  fpdolly_upper->SetValue(dolly_high);
825  }
826 
827  if (fpdolly_lower) {
828  fpdolly_lower->SetValue(dolly_low);
829  }
830 
831 
832 }
833 
834 
835 G4OpenGLXmViewer::~G4OpenGLXmViewer ()
836 {
837  XtDestroyWidget (shell);
838  win = 0; // ...to avoid XDestroyWindow in G4OpenGLXViewer base class
839  // because XtDestroyWidget has already destroyed it.
840  G4Xt::getInstance () ->RemoveShell (shell);
841 
842 /******************************
843  if (fprotation_top) {
844  delete fprotation_top;
845  }
846 
847  if (fppanning_top) {
848  delete fppanning_top;
849  }
850 
851  if (fpsetting_top) {
852  delete fpsetting_top;
853  }
854 
855  if (fpmiscellany_top) {
856  delete fpmiscellany_top;
857  }
858 ******************************/
859 
860 }
861 
862 #endif
tuple app
Definition: testem0.py:189
G4String fName
Definition: G4AttUtils.hh:55
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const char * data() const
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr