source: trunk/source/visualization/OpenGL/src/G4OpenGLXmViewer.cc @ 908

Last change on this file since 908 was 908, checked in by garnier, 15 years ago

update with CVS

  • Property svn:mime-type set to text/cpp
File size: 20.6 KB
Line 
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,v 1.26 2009/01/15 18:14:58 lgarnier Exp $
28// GEANT4 tag $Name:  $
29//
30//
31// Andrew Walkden  10th February 1997
32// G4OpenGLXmViewer : Class derived from G4OpenGLXViewer, to provide
33//                  (Motif) widget OpenGL functionality for GEANT4.
34
35#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
36
37#include "globals.hh"
38
39#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 "G4OpenGLXmSliderBar.hh"
48
49#include "G4Xt.hh"
50#include <X11/Shell.h>
51
52#include <sstream>
53
54void G4OpenGLXmViewer::ShowView () {
55
56  G4Xt::getInstance () -> SecondaryLoop ();
57
58}
59
60void G4OpenGLXmViewer::GetXmConnection () {
61 
62  G4Xt* interactorManager = G4Xt::getInstance ();
63  toplevel = (Widget)interactorManager->GetMainInteractor();
64  app      = XtWidgetToApplicationContext(toplevel);
65
66  if (!toplevel) {
67    fViewId = -1;  // This flags an error.
68    G4cerr << "G4OpenGLXmViewer::GetXmConnection unable to Initialize"
69      " application context." << G4endl;
70    return;
71  }
72
73  // Better to put this in an X11 resource file !!!
74  std::ostringstream oss;
75  oss <<
76    "*glxarea*width: " << fVP.GetWindowSizeHintX() << "\n"
77    "*glxarea*height: " << fVP.GetWindowSizeHintY() << "\n"
78    /*
79    // Tried this as a replacement for the above two lines, but
80    // sub-windows (rotation, etc.) came same size!!
81    "*geometry: " << fVP.GetXGeometryString() << "\n"
82    */
83    "*frame*x: 10\n"
84    "*frame*y: 10\n"
85    "*frame*topOffset: 10\n"
86    "*frame*bottomOffset: 10\n"
87    "*frame*rightOffset: 10\n"
88    "*frame*leftOffset: 10\n"
89    "*frame*shadowType: SHADOW_IN\n"
90    "*frame*useColorObj: False\n"
91    "*frame*primaryColorSetId: 3\n"
92    "*frame*secondaryColorSetId: 3\n"
93    "*menubar*useColorObj: False\n"
94    "*menubar*primaryColorSetId: 3\n"
95    "*menubar*secondaryColorSetId: 3\n"
96    "*toplevel*useColorObj: False\n"
97    "*toplevel*primaryColorSetId: 3\n"
98    "*toplevel*secondaryColorSetId: 3\n";
99  interactorManager->PutStringInResourceDatabase ((char*)oss.str().c_str());
100
101  //  interactorManager->AddSecondaryLoopPostAction ((G4SecondaryLoopAction)G4OpenGLXmViewerSecondaryLoopPostAction);
102 
103  shell = XtAppCreateShell ((String)fName.data(),(String)fName.data(),topLevelShellWidgetClass,XtDisplay(toplevel),NULL,0);
104  interactorManager->AddShell (shell);
105
106  dpy = XtDisplay (shell);
107
108  if (!dpy) {
109    fViewId = -1;  // This flags an error.
110    G4cerr << "G4OpenGLXmViewer::GetXmConnection unable to connect to display."
111         << G4endl;
112    return;
113  }
114
115  if (!glXQueryExtension (dpy, &errorBase, &eventBase)) {
116    fViewId = -1;  // This flags an error.
117    G4cerr << "G4OpenGLXmViewer::GetXmConnection. X Server has no GLX extension."
118         << G4endl;;
119    return;
120  }
121}
122
123void G4OpenGLXmViewer::CreateMainWindow () {
124
125  bgnd = XWhitePixelOfScreen (XtScreen(shell));
126  borcol = XBlackPixelOfScreen (XtScreen(shell));
127 
128  fWinSize_x = fVP.GetWindowSizeHintX();
129  fWinSize_y = fVP.GetWindowSizeHintY();
130  G4int x_origin = fVP.GetWindowAbsoluteLocationHintX(DisplayWidth(dpy, vi -> screen));
131  G4int y_origin = fVP.GetWindowAbsoluteLocationHintY(DisplayHeight(dpy, vi -> screen));
132
133  XtVaSetValues (shell,
134                 XtNvisual, vi -> visual,
135                 XtNdepth, vi -> depth,
136                 XtNcolormap, cmap,
137                 XtNwidth, fWinSize_x,
138                 XtNheight, fWinSize_y,
139                 XtNx, x_origin,
140                 XtNy, y_origin,
141                 XtNborderColor, &borcol,
142                 XtNbackground, &bgnd,
143                 XmNtitle, fName.data(),
144                 NULL);
145
146  main_win = XtVaCreateManagedWidget ("main_win",
147                                      xmMainWindowWidgetClass,
148                                      shell,
149                                      XtNvisual, vi -> visual,
150                                      XtNdepth, vi -> depth,
151                                      XtNcolormap, cmap,
152                                      XtNborderColor, borcol,
153                                      XtNbackground, bgnd,
154                                      NULL);
155
156  //*********Create a menu bar for the window********
157  style_str = XmStringCreateLocalized ((char*)"Style");
158  actions_str = XmStringCreateLocalized ((char*)"Actions");
159  misc_str = XmStringCreateLocalized ((char*)"Miscellany");
160  spec_str = XmStringCreateLocalized ((char*)"Special");
161
162  menubar = XmVaCreateSimpleMenuBar (main_win,
163                                     (char*)"menubar",
164                                     XmVaCASCADEBUTTON, style_str, 'S',
165                                     XmVaCASCADEBUTTON, actions_str, 'A',
166                                     XmVaCASCADEBUTTON, misc_str, 'M',
167                                     XmVaCASCADEBUTTON, spec_str, 'p',
168                                     XtNvisual, vi -> visual,
169                                     XtNdepth, vi -> depth,
170                                     XtNcolormap, cmap,
171                                     XtNborderColor, borcol,
172                                     XtNbackground, bgnd,
173                                     NULL);
174
175  XmStringFree (style_str);
176  XmStringFree (actions_str);
177  XmStringFree (misc_str);
178  XmStringFree (spec_str);
179
180  G4cout << "Created menubar" << G4endl;
181
182
183  //*********Create style pulldown menu on menubar*********
184  rep_str = XmStringCreateLocalized ((char*)"Representation");
185  draw_str = XmStringCreateLocalized ((char*)"Drawing");
186  bgnd_str = XmStringCreateLocalized ((char*)"Background color");
187
188  style_cascade = XmVaCreateSimplePulldownMenu
189    (menubar,
190     (char*)"style",
191     0,
192     NULL,
193     XmVaCASCADEBUTTON, rep_str, 'R',
194     XmVaCASCADEBUTTON, draw_str, 'D',
195     XmVaCASCADEBUTTON, bgnd_str, 'B',
196     XtNvisual, vi -> visual,
197     XtNdepth, vi -> depth,
198     XtNcolormap, cmap,
199     XtNborderColor, borcol,
200     XtNbackground, bgnd,
201     NULL);
202 
203  XmStringFree (rep_str);
204  XmStringFree (draw_str);
205  XmStringFree (bgnd_str);
206
207  //  G4cout << "Created Style pulldown menu" << G4endl;
208
209  //Add Representation pullright menu to style cascade...
210  polyhedron_str = XmStringCreateLocalized ((char*)"Polyhedron");
211  nurbs_str = XmStringCreateLocalized ((char*)"NURBS");
212
213  rep_style_pullright = XmVaCreateSimplePulldownMenu
214    (style_cascade,
215     (char*)"rep_style",
216     0,
217     rep_style_callback,
218     XmVaRADIOBUTTON, polyhedron_str, 'P', NULL, NULL,
219     XmVaRADIOBUTTON, nurbs_str, 'N', NULL, NULL,
220     XmNradioBehavior, True,
221     XmNradioAlwaysOne, True,
222     XmNuserData, this,
223     XtNvisual, vi -> visual,
224     XtNdepth, vi -> depth,
225     XtNcolormap, cmap,
226     XtNborderColor, borcol,
227     XtNbackground, bgnd,
228     NULL);
229 
230  Widget special_widget;
231
232  G4ViewParameters::RepStyle style;
233  style = fVP.GetRepStyle();
234 
235  if (style == G4ViewParameters::polyhedron) {
236    special_widget = XtNameToWidget(rep_style_pullright, "button_0");
237    if(special_widget) {
238      XtVaSetValues (special_widget, XmNset, True, NULL);
239    }
240  } else if (style == G4ViewParameters::nurbs) {
241    special_widget = XtNameToWidget(rep_style_pullright, "button_1");
242    if(special_widget) {
243      XtVaSetValues (special_widget, XmNset, True, NULL);
244    }
245  } else {
246    G4Exception("Invalid Representation style in G4OpenGLXmViewer::CreateContext");
247  }
248  XmStringFree (polyhedron_str);
249  XmStringFree (nurbs_str);
250 
251  //  G4cout << "Created Representation pulldown menu" << G4endl;
252
253  //Add Drawing pullright menu to style cascade...
254  wireframe_str = XmStringCreateLocalized ((char*)"Wireframe");
255  hlr_str = XmStringCreateLocalized ((char*)"Hidden line removal");
256  hsr_str = XmStringCreateLocalized ((char*)"Hidden surface removal");
257  hlhsr_str = XmStringCreateLocalized ((char*)"Hidden line and surface removal");
258
259  drawing_style_pullright = XmVaCreateSimplePulldownMenu
260    (style_cascade,
261     (char*)"drawing_style",
262     1,
263     drawing_style_callback,
264     XmVaRADIOBUTTON, wireframe_str, 'W', NULL, NULL,
265     XmVaRADIOBUTTON, hlr_str, 'L', NULL, NULL,
266     XmVaRADIOBUTTON, hsr_str, 'S', NULL, NULL,
267     XmVaRADIOBUTTON, hlhsr_str, 'H', NULL, NULL,
268     XmNradioBehavior, True,
269     XmNradioAlwaysOne, True,
270     XmNuserData, this,
271     XtNvisual, vi -> visual,
272     XtNdepth, vi -> depth,
273     XtNcolormap, cmap,
274     XtNborderColor, borcol,
275     XtNbackground, bgnd,
276     NULL);
277 
278  G4ViewParameters::DrawingStyle d_style;
279  d_style = fVP.GetDrawingStyle();
280 
281  if (d_style == G4ViewParameters::wireframe) {
282    special_widget = XtNameToWidget(drawing_style_pullright, "button_0");
283    if(special_widget) {
284      XtVaSetValues (special_widget, XmNset, True, NULL);
285    }
286  } else if (d_style == G4ViewParameters::hlr) {
287    special_widget = XtNameToWidget(drawing_style_pullright, "button_1");
288    if(special_widget) {
289      XtVaSetValues (special_widget, XmNset, True, NULL);
290    }
291  } else if (d_style == G4ViewParameters::hsr) {
292    special_widget = XtNameToWidget(drawing_style_pullright, "button_2");
293    if(special_widget) {
294      XtVaSetValues (special_widget, XmNset, True, NULL);
295    }
296  } else if (d_style == G4ViewParameters::hlhsr) {
297    special_widget = XtNameToWidget(drawing_style_pullright, "button_3");
298    if(special_widget) {
299      XtVaSetValues (special_widget, XmNset, True, NULL);
300    }
301  } else {
302    G4Exception("Invalid Drawing style in G4OpenGLXmViewer::CreateContext");
303  }
304
305  XmStringFree (wireframe_str);
306  XmStringFree (hlr_str);
307  XmStringFree (hsr_str);
308  XmStringFree (hlhsr_str);
309
310  //  G4cout << "Created Drawing pullright menu" << G4endl;
311
312  //Add Drawing pullright menu to style cascade...
313  white_str = XmStringCreateLocalized ((char*)"White");
314  black_str = XmStringCreateLocalized ((char*)"Black");
315
316  background_color_pullright = XmVaCreateSimplePulldownMenu
317    (style_cascade,
318     (char*)"background_color",
319     2,
320     background_color_callback,
321     XmVaRADIOBUTTON, white_str, 'W', NULL, NULL,
322     XmVaRADIOBUTTON, black_str, 'B', NULL, NULL,
323     XmNradioBehavior, True,
324     XmNradioAlwaysOne, True,
325     XmNuserData, this,
326     XtNvisual, vi -> visual,
327     XtNdepth, vi -> depth,
328     XtNcolormap, cmap,
329     XtNborderColor, borcol,
330     XtNbackground, bgnd,
331     NULL);
332 
333  if (background.GetRed() == 1. &&
334      background.GetGreen() == 1. &&
335      background.GetBlue() == 1.) {
336    special_widget = XtNameToWidget(background_color_pullright, "button_0");
337    if(special_widget) {
338      XtVaSetValues (special_widget, XmNset, True, NULL);
339    }
340  } else {
341    special_widget = XtNameToWidget(background_color_pullright, "button_1");
342    if(special_widget) {
343      XtVaSetValues (special_widget, XmNset, True, NULL);
344    }
345  }
346
347  XmStringFree (white_str);
348  XmStringFree (black_str);
349
350  //  G4cout << "Created Background color pullright menu" << G4endl;
351
352  //*********Create actions pulldown menu on menubar*********
353  rot_str = XmStringCreateLocalized ((char*)"Rotation control panel");
354  pan_str = XmStringCreateLocalized ((char*)"Panning control panel");
355  set_str = XmStringCreateLocalized ((char*)"Set control panel limits");
356
357  actions_cascade = XmVaCreateSimplePulldownMenu
358    (menubar,
359     (char*)"actions",
360     1,
361     actions_callback,
362     XmVaPUSHBUTTON, rot_str, 'R', NULL, NULL,
363     XmVaPUSHBUTTON, pan_str, 'P', NULL, NULL,
364     XmVaPUSHBUTTON, set_str, 'S', NULL, NULL,
365     XmNuserData, this,
366     XtNvisual, vi -> visual,
367     XtNdepth, vi -> depth,
368     XtNcolormap, cmap,
369     XtNborderColor, borcol,
370     XtNbackground, bgnd,
371     NULL);
372 
373  XmStringFree (rot_str);
374  XmStringFree (pan_str);
375  XmStringFree (set_str);
376  G4cout << "Created Actions pulldown menu" << G4endl;
377
378  misc_str = XmStringCreateLocalized ((char*)"Miscellany control panel");
379  exit_str = XmStringCreateLocalized ((char*)"Exit to G4Vis>");
380  print_str = XmStringCreateLocalized ((char*)"Create .eps file");
381
382  //*********Create miscellany pulldown menu on menubar*********
383  misc_cascade = XmVaCreateSimplePulldownMenu
384    (menubar,
385     (char*)"miscellany",
386     2,
387     misc_callback,
388     XmVaPUSHBUTTON, misc_str, 'M', NULL, NULL,
389     XmVaPUSHBUTTON, exit_str, 'E', NULL, NULL,
390     XmVaPUSHBUTTON, print_str, 'P', NULL, NULL,
391     XmNuserData, this,
392     XtNvisual, vi -> visual,
393     XtNdepth, vi -> depth,
394     XtNcolormap, cmap,
395     XtNborderColor, borcol,
396     XtNbackground, bgnd,
397     NULL);
398 
399  XmStringFree (misc_str);
400  XmStringFree (exit_str);
401  XmStringFree (print_str);
402  G4cout << "Created Miscellany pulldown menu" << G4endl;
403
404  trans_str = XmStringCreateLocalized ((char*)"Transparency");
405  anti_str = XmStringCreateLocalized ((char*)"Antialiasing");
406  halo_str = XmStringCreateLocalized ((char*)"Haloing");
407  aux_edge_str = XmStringCreateLocalized ((char*)"Auxiliary edges");
408
409  //*********Create special pulldown menu on menubar*********
410  spec_cascade = XmVaCreateSimplePulldownMenu
411    (menubar,
412     (char*)"special",
413     3,
414     NULL,
415     XmVaCASCADEBUTTON, trans_str, 'T',
416     XmVaCASCADEBUTTON, anti_str, 'A',
417     XmVaCASCADEBUTTON, halo_str, 'H',
418     XmVaCASCADEBUTTON, aux_edge_str, 'E',
419     XtNvisual, vi -> visual,
420     XtNdepth, vi -> depth,
421     XtNcolormap, cmap,
422     XtNborderColor, borcol,
423     XtNbackground, bgnd,
424     NULL);
425 
426  XmStringFree (trans_str);
427  XmStringFree (anti_str);
428  XmStringFree (halo_str);
429  XmStringFree (aux_edge_str);
430
431  //  G4cout << "Created Special pulldown menu" << G4endl;
432
433  //Add Transparency pullright menu to special cascade...
434  off_str = XmStringCreateLocalized ((char*)"Off");
435  on_str = XmStringCreateLocalized ((char*)"On");
436
437  transparency_pullright = XmVaCreateSimplePulldownMenu
438    (spec_cascade,
439     (char*)"transparency",
440     0,
441     transparency_callback,
442     XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
443     XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
444     XmNradioBehavior, True,
445     XmNradioAlwaysOne, True,
446     XmNuserData, this,
447     XtNvisual, vi -> visual,
448     XtNdepth, vi -> depth,
449     XtNcolormap, cmap,
450     XtNborderColor, borcol,
451     XtNbackground, bgnd,
452     NULL);
453 
454  if (transparency_enabled == false) {
455    special_widget = XtNameToWidget(transparency_pullright, "button_0");
456    if(special_widget) {
457      XtVaSetValues (special_widget, XmNset, True, NULL);
458    }
459  } else if (transparency_enabled == true) {
460    special_widget = XtNameToWidget(transparency_pullright, "button_1");
461    if(special_widget) {
462      XtVaSetValues (special_widget, XmNset, True, NULL);
463    }
464  } else {
465    G4Exception("transparency_enabled in G4OpenGLXmViewer is neither true nor false!!");
466  }
467
468  //Add antialias pullright menu to special cascade...
469  antialias_pullright = XmVaCreateSimplePulldownMenu
470    (spec_cascade,
471     (char*)"antialias",
472     1,
473     antialias_callback,
474     XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
475     XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
476     XmNradioBehavior, True,
477     XmNradioAlwaysOne, True,
478     XmNuserData, this,
479     XtNvisual, vi -> visual,
480     XtNdepth, vi -> depth,
481     XtNcolormap, cmap,
482     XtNborderColor, borcol,
483     XtNbackground, bgnd,
484     NULL);
485 
486  if (antialiasing_enabled == false) {
487    special_widget = XtNameToWidget(antialias_pullright, "button_0");
488    if(special_widget) {
489      XtVaSetValues (special_widget, XmNset, True, NULL);
490    }
491  } else if (antialiasing_enabled == true) {
492    special_widget = XtNameToWidget(antialias_pullright, "button_1");
493    if(special_widget) {
494      XtVaSetValues (special_widget, XmNset, True, NULL);
495    }
496  } else {
497    G4Exception("antialiasing_enabled in G4OpenGLXmViewer is neither true nor false!!");
498  }
499
500  //Add Haloing pullright menu to special cascade...
501  haloing_pullright = XmVaCreateSimplePulldownMenu
502    (spec_cascade,
503     (char*)"haloing",
504     2,
505     haloing_callback,
506     XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
507     XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
508     XmNradioBehavior, True,
509     XmNradioAlwaysOne, True,
510     XmNuserData, this,
511     XtNvisual, vi -> visual,
512     XtNdepth, vi -> depth,
513     XtNcolormap, cmap,
514     XtNborderColor, borcol,
515     XtNbackground, bgnd,
516     NULL);
517 
518  if (haloing_enabled == false) {
519    special_widget = XtNameToWidget(haloing_pullright, "button_0");
520    if(special_widget) {
521      XtVaSetValues (special_widget, XmNset, True, NULL);
522    }
523  } else if (haloing_enabled == true) {
524    special_widget = XtNameToWidget(haloing_pullright, "button_1");
525    if(special_widget) {
526      XtVaSetValues (special_widget, XmNset, True, NULL);
527    }
528  } else {
529    G4Exception("haloing_enabled in G4OpenGLXmViewer is neither true nor false!!");
530  }
531
532  //Add Aux_Edge pullright menu to special cascade...
533  aux_edge_pullright = XmVaCreateSimplePulldownMenu
534    (spec_cascade,
535     (char*)"aux_edge",
536     3,
537     aux_edge_callback,
538     XmVaRADIOBUTTON, off_str, 'f', NULL, NULL,
539     XmVaRADIOBUTTON, on_str, 'n', NULL, NULL,
540     XmNradioBehavior, True,
541     XmNradioAlwaysOne, True,
542     XmNuserData, this,
543     XtNvisual, vi -> visual,
544     XtNdepth, vi -> depth,
545     XtNcolormap, cmap,
546     XtNborderColor, borcol,
547     XtNbackground, bgnd,
548     NULL);
549 
550  if (!fVP.IsAuxEdgeVisible()) {
551    special_widget = XtNameToWidget(aux_edge_pullright, "button_0");
552    if(special_widget) {
553      XtVaSetValues (special_widget, XmNset, True, NULL);
554    }
555  } else {
556    special_widget = XtNameToWidget(aux_edge_pullright, "button_1");
557    if(special_widget) {
558      XtVaSetValues (special_widget, XmNset, True, NULL);
559    }
560  }
561
562  XtManageChild (menubar);
563  frame = XtVaCreateManagedWidget ((char*)"frame",
564                                   xmFrameWidgetClass, main_win,
565                                   XtNvisual, vi -> visual,
566                                   XtNdepth, vi -> depth,
567                                   XtNcolormap, cmap,
568                                   XtNborderColor, borcol,
569                                   XtNbackground, bgnd,
570                                   NULL);
571
572  glxarea = XtVaCreateManagedWidget ((char*)"glxarea",
573                                     xmDrawingAreaWidgetClass,
574                                     frame,
575                                     XtNvisual, vi -> visual,
576                                     XtNdepth, vi -> depth,
577                                     XtNcolormap, cmap,
578                                     XtNborderColor, borcol,
579                                     XtNbackground, bgnd,
580                                     NULL);
581 
582
583  XmMainWindowSetAreas (main_win,  // main widget, children are specified
584                        menubar,   // widget to use as menu bar
585                        NULL,      // widget to use as command window
586                        NULL,      // widget for horizontal scroll bar
587                        NULL,      // widget for vertical scroll bar
588                        frame      // widget to be used for work window
589                        );
590
591  XtRealizeWidget(shell);
592 
593  // Once widget is realized (ie, associated with a created X window), we
594  // can bind the OpenGL rendering context to the window.
595
596  win = XtWindow (glxarea);
597
598  glXMakeCurrent (dpy, win, cx);
599
600  // This should be add AFTER glXMakeCurrent done because it will fire a resizeCallback
601  XtAddCallback (glxarea,
602                 XmNresizeCallback,
603                 resize_callback,
604                 this);
605
606  XtAddCallback (glxarea,
607                 XmNexposeCallback,
608                 expose_callback,
609                 this);
610
611}
612
613G4OpenGLXmViewer::G4OpenGLXmViewer (G4OpenGLSceneHandler& scene):
614G4VViewer (scene, -1),
615G4OpenGLViewer (scene),
616G4OpenGLXViewer (scene),
617zoom_high (fVP.GetZoomFactor() * 10.0),
618zoom_low (fVP.GetZoomFactor() / 10.0),
619dolly_low (fVP.GetDolly() - 1000.0),
620dolly_high (fVP.GetDolly() + 1000.0),
621fov (0.0),
622rot_sens_limit (90.),
623pan_sens_limit (100.),
624rot_sens (1.),
625wob_sens (20.),
626original_vp(fVP.GetViewpointDirection()),
627frameNo (0),
628fprotation_top (0),
629fprotation_slider (0),
630fppanning_top (0),
631fppanning_slider (0),
632fpzoom_slider (0),
633fpdolly_slider (0),
634fpsetting_top (0),
635fpmiscellany_top (0),
636fpprint_top (0)
637{
638  GetXmConnection ();
639  if (fViewId < 0) return;
640}
641
642G4OpenGLXmViewer::~G4OpenGLXmViewer ()
643{
644  XtDestroyWidget  (shell);
645  win = 0; // ...to avoid XDestroyWindow in G4OpenGLXViewer base class
646  // because XtDestroyWidget has already destroyed it.
647  G4Xt::getInstance () ->RemoveShell (shell);
648
649/******************************
650  if (fprotation_top) {
651    delete fprotation_top;
652  }
653
654  if (fppanning_top) {
655    delete fppanning_top;
656  }
657
658  if (fpsetting_top) {
659    delete fpsetting_top;
660  }
661
662  if (fpmiscellany_top) {
663    delete fpmiscellany_top;
664  }
665******************************/
666
667}
668
669#endif
Note: See TracBrowser for help on using the repository browser.