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

Last change on this file since 1018 was 1009, checked in by garnier, 17 years ago

correction du bug de beomOn Bloquant

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