39 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
61 void G4OpenGLXmViewer::actions_callback (Widget
w,
66 G4OpenGLXmViewer* pView;
70 XtVaGetValues (XtParent(w),
80 if (!pView->fprotation_top) {
81 std::ostringstream rot_Name;
82 rot_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
84 pView->fprotation_top =
new G4OpenGLXmTopLevelShell (pView,
85 (
char*)rot_Name.str().c_str());
86 pView->fprotation_button_box =
new G4OpenGLXmBox (
"Rotation button box", True);
88 pView->fprotation_top->AddChild (pView->fprotation_button_box);
90 XtCallbackRec* rot_cb_list =
new XtCallbackRec[2];
91 rot_cb_list[0].callback = set_rot_subject_callback;
92 rot_cb_list[0].closure = pView;
93 rot_cb_list[1].callback = NULL;
95 pView->fprotation_button1 =
new G4OpenGLXmRadioButton
98 pView->GetViewParameters().GetLightsMoveWithCamera(),
101 pView->fprotation_button2 =
new G4OpenGLXmRadioButton
104 !(pView->GetViewParameters().GetLightsMoveWithCamera()),
107 pView->fprotation_button_box->AddChild (pView->fprotation_button1);
108 pView->fprotation_button_box->AddChild (pView->fprotation_button2);
110 pView->fprotation_slider_box =
new G4OpenGLXmBox (
"Rotation slider box", False);
111 pView->fprotation_top->AddChild (pView->fprotation_slider_box);
113 XtCallbackRec* rot_slider_list =
new XtCallbackRec[2];
114 rot_slider_list[0].callback = set_rot_sens_callback;
115 rot_slider_list[0].closure = pView;
116 rot_slider_list[1].callback = NULL;
118 pView->fprotation_slider =
new G4OpenGLXmSliderBar (
"Rotation slider",
123 pView->rot_sens_limit,
125 pView->fprotation_slider_box->AddChild (pView->fprotation_slider);
127 pView->fprotation_arrow_box =
new G4OpenGLXmBox (
"Rotation arrow box", False);
128 pView->fprotation_top->AddChild (pView->fprotation_arrow_box);
130 XtCallbackRec** rotation_callbacks =
new XtCallbackRec*[4];
131 for (
G4int i = 0; i < 4; i++) {
132 rotation_callbacks[i] =
new XtCallbackRec[2];
134 rotation_callbacks[0][0].callback = phi_rotation_callback;
135 rotation_callbacks[0][0].closure = pView;
136 rotation_callbacks[0][1].callback = NULL;
138 rotation_callbacks[1][0].callback = phi_rotation_callback;
139 rotation_callbacks[1][0].closure = pView;
140 rotation_callbacks[1][1].callback = NULL;
142 rotation_callbacks[2][0].callback = theta_rotation_callback;
143 rotation_callbacks[2][0].closure = pView;
144 rotation_callbacks[2][1].callback = NULL;
146 rotation_callbacks[3][0].callback = theta_rotation_callback;
147 rotation_callbacks[3][0].closure = pView;
148 rotation_callbacks[3][1].callback = NULL;
150 pView->fprotation_arrow =
new G4OpenGLXmFourArrowButtons (rotation_callbacks);
152 pView->fprotation_arrow_box->AddChild (pView->fprotation_arrow);
154 pView->fprotation_top->Realize ();
163 if (!pView->GetSceneHandler()->GetScene()) {
166 if (!pView->fppanning_top) {
167 std::ostringstream pan_Name;
168 pan_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
170 pView->fppanning_top =
new G4OpenGLXmTopLevelShell (pView,
171 (
char*)pan_Name.str().c_str());
173 pView->fppanning_box =
new G4OpenGLXmFramedBox (
"Pan up-down-left-right",
176 pView->fppanning_top->AddChild (pView->fppanning_box);
178 XtCallbackRec** pan_callbacks =
new XtCallbackRec*[4];
179 for (
G4int i = 0; i < 4; i++) {
180 pan_callbacks[i] =
new XtCallbackRec[2];
182 pan_callbacks[0][0].callback = pan_up_down_callback;
183 pan_callbacks[0][0].closure = pView;
184 pan_callbacks[0][1].callback = NULL;
186 pan_callbacks[1][0].callback = pan_up_down_callback;
187 pan_callbacks[1][0].closure = pView;
188 pan_callbacks[1][1].callback = NULL;
190 pan_callbacks[2][0].callback = pan_left_right_callback;
191 pan_callbacks[2][0].closure = pView;
192 pan_callbacks[2][1].callback = NULL;
194 pan_callbacks[3][0].callback = pan_left_right_callback;
195 pan_callbacks[3][0].closure = pView;
196 pan_callbacks[3][1].callback = NULL;
198 pView->fppanning_arrows =
new G4OpenGLXmFourArrowButtons (pan_callbacks);
200 pView->fppanning_box->AddChild (pView->fppanning_arrows);
202 XtCallbackRec* pan_slider_list =
new XtCallbackRec[2];
203 pan_slider_list[0].callback = set_pan_sens_callback;
204 pan_slider_list[0].closure = pView;
205 pan_slider_list[1].callback = NULL;
207 pView->fppanning_slider =
new G4OpenGLXmSliderBar (
"Panning slider",
211 pView->fPan_sens = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius() / 10.0,
212 pView->pan_sens_limit = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(),
214 pView->fppanning_box->AddChild (pView->fppanning_slider);
216 pView->fpzoom_box =
new G4OpenGLXmFramedBox (
"Zoom",
218 pView->fppanning_top->AddChild (pView->fpzoom_box);
220 XtCallbackRec* zoom_slider_list =
new XtCallbackRec[2];
221 zoom_slider_list[0].callback = zoom_callback;
222 zoom_slider_list[0].closure = pView;
223 zoom_slider_list[1].callback = NULL;
225 pView->fpzoom_slider =
new G4OpenGLXmSliderBar (
"Zoom slider",
229 pView->fVP.GetZoomFactor(),
232 pView->fpzoom_box->AddChild (pView->fpzoom_slider);
234 pView->fpdolly_box =
new G4OpenGLXmFramedBox (
"Dolly",
236 pView->fppanning_top->AddChild (pView->fpdolly_box);
238 XtCallbackRec* dolly_slider_list =
new XtCallbackRec[2];
239 dolly_slider_list[0].callback = dolly_callback;
240 dolly_slider_list[0].closure = pView;
241 dolly_slider_list[1].callback = NULL;
243 pView->fpdolly_slider =
new G4OpenGLXmSliderBar (
"Dolly slider",
247 pView->fVP.GetDolly(),
248 pView->dolly_high = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(),
249 pView->dolly_low = -(pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius()));
252 pView->fpdolly_box->AddChild (pView->fpdolly_slider);
254 pView->fppanning_top->Realize ();
255 pView->UpdateControlPanel ();
264 if (!pView->fpsetting_top) {
265 std::ostringstream set_Name;
266 set_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
268 pView->fpsetting_top =
new G4OpenGLXmTopLevelShell(pView,
269 (
char*)set_Name.str().c_str());
271 pView->fpsetting_box =
new G4OpenGLXmFramedBox (
"Set values for control panels",
273 pView->fpsetting_top->AddChild (pView->fpsetting_box);
275 pView->fppan_set =
new G4OpenGLXmTextField (
"Upper limit of pan sensitivity",
276 &(pView->pan_sens_limit));
278 pView->fprot_set =
new G4OpenGLXmTextField (
"Upper limit of rotation sensitivity",
279 &(pView->rot_sens_limit));
281 pView->fpzoom_upper =
new G4OpenGLXmTextField (
"Upper limit of zoom",
282 &(pView->zoom_high));
284 pView->fpzoom_lower =
new G4OpenGLXmTextField (
"Lower limit of zoom",
287 pView->fpdolly_upper =
new G4OpenGLXmTextField (
"Upper limit of dolly",
288 &(pView->dolly_high));
290 pView->fpdolly_lower =
new G4OpenGLXmTextField (
"Lower limit of dolly",
291 &(pView->dolly_low));
293 XtCallbackRec* ok_list =
new XtCallbackRec[2];
294 ok_list[0].callback = update_panels_callback;
295 ok_list[0].closure = pView;
296 ok_list[1].callback = NULL;
299 pView->fpok_button =
new G4OpenGLXmPushButton (
"ok",
302 pView->fpsetting_box->AddChild (pView->fppan_set);
303 pView->fpsetting_box->AddChild (pView->fprot_set);
304 pView->fpsetting_box->AddChild (pView->fpzoom_upper);
305 pView->fpsetting_box->AddChild (pView->fpzoom_lower);
306 pView->fpsetting_box->AddChild (pView->fpdolly_upper);
307 pView->fpsetting_box->AddChild (pView->fpdolly_lower);
308 pView->fpsetting_box->AddChild (pView->fpok_button);
310 pView->fpsetting_top->Realize ();
319 (
"G4OpenGLXmViewer::actions_callback",
321 "Unrecognised widget child of control_callback");
329 void G4OpenGLXmViewer::misc_callback (Widget w,
330 XtPointer clientData,
333 G4OpenGLXmViewer* pView;
335 XtVaGetValues (XtParent(w),
344 if (!pView->fpmiscellany_top) {
346 std::ostringstream misc_Name;
347 misc_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
349 pView->fpmiscellany_top =
new G4OpenGLXmTopLevelShell (pView,
350 (
char*)misc_Name.str().c_str());
351 pView->fpwobble_box =
new G4OpenGLXmFramedBox (
"Wobble view",
353 pView->fpmiscellany_top->AddChild (pView->fpwobble_box);
355 XtCallbackRec* wob_cb_list =
new XtCallbackRec[2];
356 wob_cb_list[0].callback = wobble_callback;
357 wob_cb_list[0].closure = pView;
358 wob_cb_list[1].callback = NULL;
361 pView->fpwobble_button =
new G4OpenGLXmPushButton (
"Wobble",
364 XtCallbackRec* wobble_slider_list =
new XtCallbackRec[2];
365 wobble_slider_list[0].callback = set_wob_sens_callback;
366 wobble_slider_list[0].closure = pView;
367 wobble_slider_list[1].callback = NULL;
369 pView->fpwobble_slider =
new G4OpenGLXmSliderBar (
"Wobble slider",
376 pView->fpwobble_box->AddChild (pView->fpwobble_button);
377 pView->fpwobble_box->AddChild (pView->fpwobble_slider);
379 pView->fpreset_box =
new G4OpenGLXmFramedBox (
"Reset view",
381 pView->fpmiscellany_top->AddChild (pView->fpreset_box);
383 XtCallbackRec* rst_cb_list =
new XtCallbackRec[3];
384 rst_cb_list[0].callback = reset_callback;
385 rst_cb_list[0].closure = pView;
386 rst_cb_list[1].callback = update_panels_callback;
387 rst_cb_list[1].closure = pView;
388 rst_cb_list[2].callback = NULL;
390 pView->fpreset_button =
new G4OpenGLXmPushButton (
"Reset",
393 pView->fpreset_box->AddChild (pView->fpreset_button);
395 pView->fpproj_style_box =
new G4OpenGLXmFramedBox (
"Projection style",
397 pView->fpmiscellany_top->AddChild (pView->fpproj_style_box);
399 XtCallbackRec* proj_cb_list =
new XtCallbackRec[2];
400 proj_cb_list[0].callback = projection_callback;
401 proj_cb_list[0].closure = pView;
402 proj_cb_list[1].callback = NULL;
404 pView->fporthogonal_button =
new G4OpenGLXmRadioButton (
"Orthographic",
406 pView->fVP.GetFieldHalfAngle() > 0. ? False : True,
409 pView->fpperspective_button =
new G4OpenGLXmRadioButton (
"Perspective",
411 pView->fVP.GetFieldHalfAngle() > 0. ? True : False,
414 pView->fpfov_text =
new G4OpenGLXmTextField (
"Field of view 0.1 -> 89.5 degrees.",
417 pView->fpproj_style_box->AddChild (pView->fpperspective_button);
418 pView->fpproj_style_box->AddChild (pView->fporthogonal_button);
419 pView->fpproj_style_box->AddChild (pView->fpfov_text);
421 pView->fpmiscellany_top->Realize ();
430 G4Xt::getInstance () -> RequireExitSecondaryLoop (
OGL_EXIT_CODE);
436 if (!pView->fpprint_top) {
438 std::ostringstream print_Name;
439 print_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
441 pView->fpprint_top =
new G4OpenGLXmTopLevelShell (pView,
442 (
char*)print_Name.str().c_str());
444 pView->fpprint_box =
new G4OpenGLXmFramedBox (
"Create EPS file of current view",
447 pView->fpprint_top->AddChild (pView->fpprint_box);
449 pView->fpprint_col_box =
new G4OpenGLXmFramedBox (
"Colour choice",
451 pView->fpprint_top->AddChild (pView->fpprint_col_box);
453 XtCallbackRec* prcol_cb_list =
new XtCallbackRec[2];
454 prcol_cb_list[0].callback = set_print_colour_callback;
455 prcol_cb_list[0].closure = pView;
456 prcol_cb_list[1].callback = NULL;
458 pView->fpprint_col_radio1 =
new G4OpenGLXmRadioButton (
"Black and white",
460 pView->fPrintColour==
false ? True : False,
463 pView->fpprint_col_radio2 =
new G4OpenGLXmRadioButton (
"Colour",
465 pView->fPrintColour==
true ? True : False,
468 pView->fpprint_col_box->AddChild (pView->fpprint_col_radio1);
469 pView->fpprint_col_box->AddChild (pView->fpprint_col_radio2);
471 pView->fpprint_style_box =
new G4OpenGLXmFramedBox (
"File type",
473 pView->fpprint_top->AddChild (pView->fpprint_style_box);
475 XtCallbackRec* prsty_cb_list =
new XtCallbackRec[2];
476 prsty_cb_list[0].callback = set_print_style_callback;
477 prsty_cb_list[0].closure = pView;
478 prsty_cb_list[1].callback = NULL;
480 pView->fpprint_style_radio1 =
new G4OpenGLXmRadioButton (
"Screen dump (pixmap)",
482 pView->fVectoredPs==
false ? True : False,
485 pView->fpprint_style_radio2 =
new G4OpenGLXmRadioButton (
"PostScript",
487 pView->fVectoredPs==
true ? True : False,
490 pView->fpprint_style_box->AddChild (pView->fpprint_style_radio1);
491 pView->fpprint_style_box->AddChild (pView->fpprint_style_radio2);
493 pView->fpprint_text =
new G4OpenGLXmTextField (
"Name of .eps file to save",
494 (pView->getRealPrintFilename().c_str()));
495 pView->fpprint_box->AddChild (pView->fpprint_text);
497 pView->fpprint_line =
new G4OpenGLXmSeparator ();
498 pView->fpprint_box->AddChild (pView->fpprint_line);
500 XtCallbackRec* pri_cb_list =
new XtCallbackRec[2];
501 pri_cb_list[0].callback = print_callback;
502 pri_cb_list[0].closure = pView;
503 pri_cb_list[1].callback = NULL;
506 pView->fpprint_button =
new G4OpenGLXmPushButton (
"Create EPS file",
509 pView->fpprint_box->AddChild (pView->fpprint_button);
510 pView->fpprint_top->Realize ();
520 (
"G4OpenGLXmViewer::misc_callback",
522 "Unrecognised widget child of misc_callback.");
529 void G4OpenGLXmViewer::set_wob_sens_callback (Widget w,
530 XtPointer clientData,
533 XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct*) callData;
534 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
539 XmNdecimalPoints, &dp,
544 }
else if ( dp > 0) {
546 ten_to_the_dp *= 10.;
550 (
"G4OpenGLXmViewer::set_wob_sens_callback",
552 "Bad value returned for dp in set_rot_sens_callback");
555 pView->wob_sens = (
G4float)(cbs->value) / ten_to_the_dp;
558 void G4OpenGLXmViewer::update_panels_callback (Widget,
559 XtPointer clientData,
562 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
564 if (pView->fppanning_slider) {
565 pView->fppanning_slider->SetMaxValue (pView->pan_sens_limit);
567 if (pView->fprotation_slider) {
568 pView->fprotation_slider->SetMaxValue (pView->rot_sens_limit);
571 if (pView->fpzoom_slider) {
572 pView->fpzoom_slider->SetMaxValue (pView->zoom_high);
573 pView->fpzoom_slider->SetMinValue (pView->zoom_low);
574 pView->fpzoom_slider->SetInitialValue (pView->fVP.GetZoomFactor());
577 if (pView->fpdolly_slider) {
578 pView->fpdolly_slider->SetMaxValue (pView->dolly_high);
579 pView->fpdolly_slider->SetMinValue (pView->dolly_low);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)