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

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

History change, and a Warning added

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