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

Last change on this file since 1040 was 1039, checked in by garnier, 17 years ago

remise a jour

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