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

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

update before cvs

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