38 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
60 void G4OpenGLXmViewer::actions_callback (Widget
w,
65 G4OpenGLXmViewer* pView;
69 XtVaGetValues (XtParent(w),
79 if (!pView->fprotation_top) {
80 std::ostringstream rot_Name;
81 rot_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
83 pView->fprotation_top =
new G4OpenGLXmTopLevelShell (pView,
84 (
char*)rot_Name.str().c_str());
85 pView->fprotation_button_box =
new G4OpenGLXmBox (
"Rotation button box", True);
87 pView->fprotation_top->AddChild (pView->fprotation_button_box);
89 XtCallbackRec* rot_cb_list =
new XtCallbackRec[2];
90 rot_cb_list[0].callback = set_rot_subject_callback;
91 rot_cb_list[0].closure = pView;
92 rot_cb_list[1].callback = NULL;
94 pView->fprotation_button1 =
new G4OpenGLXmRadioButton
97 pView->GetViewParameters().GetLightsMoveWithCamera(),
100 pView->fprotation_button2 =
new G4OpenGLXmRadioButton
103 !(pView->GetViewParameters().GetLightsMoveWithCamera()),
106 pView->fprotation_button_box->AddChild (pView->fprotation_button1);
107 pView->fprotation_button_box->AddChild (pView->fprotation_button2);
109 pView->fprotation_slider_box =
new G4OpenGLXmBox (
"Rotation slider box", False);
110 pView->fprotation_top->AddChild (pView->fprotation_slider_box);
112 XtCallbackRec* rot_slider_list =
new XtCallbackRec[2];
113 rot_slider_list[0].callback = set_rot_sens_callback;
114 rot_slider_list[0].closure = pView;
115 rot_slider_list[1].callback = NULL;
117 pView->fprotation_slider =
new G4OpenGLXmSliderBar (
"Rotation slider",
122 pView->rot_sens_limit,
124 pView->fprotation_slider_box->AddChild (pView->fprotation_slider);
126 pView->fprotation_arrow_box =
new G4OpenGLXmBox (
"Rotation arrow box", False);
127 pView->fprotation_top->AddChild (pView->fprotation_arrow_box);
129 XtCallbackRec** rotation_callbacks =
new XtCallbackRec*[4];
130 for (
G4int i = 0; i < 4; i++) {
131 rotation_callbacks[i] =
new XtCallbackRec[2];
133 rotation_callbacks[0][0].callback = phi_rotation_callback;
134 rotation_callbacks[0][0].closure = pView;
135 rotation_callbacks[0][1].callback = NULL;
137 rotation_callbacks[1][0].callback = phi_rotation_callback;
138 rotation_callbacks[1][0].closure = pView;
139 rotation_callbacks[1][1].callback = NULL;
141 rotation_callbacks[2][0].callback = theta_rotation_callback;
142 rotation_callbacks[2][0].closure = pView;
143 rotation_callbacks[2][1].callback = NULL;
145 rotation_callbacks[3][0].callback = theta_rotation_callback;
146 rotation_callbacks[3][0].closure = pView;
147 rotation_callbacks[3][1].callback = NULL;
149 pView->fprotation_arrow =
new G4OpenGLXmFourArrowButtons (rotation_callbacks);
151 pView->fprotation_arrow_box->AddChild (pView->fprotation_arrow);
153 pView->fprotation_top->Realize ();
162 if (!pView->GetSceneHandler()->GetScene()) {
165 if (!pView->fppanning_top) {
166 std::ostringstream pan_Name;
167 pan_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
169 pView->fppanning_top =
new G4OpenGLXmTopLevelShell (pView,
170 (
char*)pan_Name.str().c_str());
172 pView->fppanning_box =
new G4OpenGLXmFramedBox (
"Pan up-down-left-right",
175 pView->fppanning_top->AddChild (pView->fppanning_box);
177 XtCallbackRec** pan_callbacks =
new XtCallbackRec*[4];
178 for (
G4int i = 0; i < 4; i++) {
179 pan_callbacks[i] =
new XtCallbackRec[2];
181 pan_callbacks[0][0].callback = pan_up_down_callback;
182 pan_callbacks[0][0].closure = pView;
183 pan_callbacks[0][1].callback = NULL;
185 pan_callbacks[1][0].callback = pan_up_down_callback;
186 pan_callbacks[1][0].closure = pView;
187 pan_callbacks[1][1].callback = NULL;
189 pan_callbacks[2][0].callback = pan_left_right_callback;
190 pan_callbacks[2][0].closure = pView;
191 pan_callbacks[2][1].callback = NULL;
193 pan_callbacks[3][0].callback = pan_left_right_callback;
194 pan_callbacks[3][0].closure = pView;
195 pan_callbacks[3][1].callback = NULL;
197 pView->fppanning_arrows =
new G4OpenGLXmFourArrowButtons (pan_callbacks);
199 pView->fppanning_box->AddChild (pView->fppanning_arrows);
201 XtCallbackRec* pan_slider_list =
new XtCallbackRec[2];
202 pan_slider_list[0].callback = set_pan_sens_callback;
203 pan_slider_list[0].closure = pView;
204 pan_slider_list[1].callback = NULL;
206 pView->fppanning_slider =
new G4OpenGLXmSliderBar (
"Panning slider",
210 pView->fPan_sens = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius() / 10.0,
211 pView->pan_sens_limit = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(),
213 pView->fppanning_box->AddChild (pView->fppanning_slider);
215 pView->fpzoom_box =
new G4OpenGLXmFramedBox (
"Zoom",
217 pView->fppanning_top->AddChild (pView->fpzoom_box);
219 XtCallbackRec* zoom_slider_list =
new XtCallbackRec[2];
220 zoom_slider_list[0].callback = zoom_callback;
221 zoom_slider_list[0].closure = pView;
222 zoom_slider_list[1].callback = NULL;
224 pView->fpzoom_slider =
new G4OpenGLXmSliderBar (
"Zoom slider",
228 pView->fVP.GetZoomFactor(),
231 pView->fpzoom_box->AddChild (pView->fpzoom_slider);
233 pView->fpdolly_box =
new G4OpenGLXmFramedBox (
"Dolly",
235 pView->fppanning_top->AddChild (pView->fpdolly_box);
237 XtCallbackRec* dolly_slider_list =
new XtCallbackRec[2];
238 dolly_slider_list[0].callback = dolly_callback;
239 dolly_slider_list[0].closure = pView;
240 dolly_slider_list[1].callback = NULL;
242 pView->fpdolly_slider =
new G4OpenGLXmSliderBar (
"Dolly slider",
246 pView->fVP.GetDolly(),
247 pView->dolly_high = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(),
248 pView->dolly_low = -(pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius()));
251 pView->fpdolly_box->AddChild (pView->fpdolly_slider);
253 pView->fppanning_top->Realize ();
254 pView->UpdateControlPanel ();
263 if (!pView->fpsetting_top) {
264 std::ostringstream set_Name;
265 set_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
267 pView->fpsetting_top =
new G4OpenGLXmTopLevelShell(pView,
268 (
char*)set_Name.str().c_str());
270 pView->fpsetting_box =
new G4OpenGLXmFramedBox (
"Set values for control panels",
272 pView->fpsetting_top->AddChild (pView->fpsetting_box);
274 pView->fppan_set =
new G4OpenGLXmTextField (
"Upper limit of pan sensitivity",
275 &(pView->pan_sens_limit));
277 pView->fprot_set =
new G4OpenGLXmTextField (
"Upper limit of rotation sensitivity",
278 &(pView->rot_sens_limit));
280 pView->fpzoom_upper =
new G4OpenGLXmTextField (
"Upper limit of zoom",
281 &(pView->zoom_high));
283 pView->fpzoom_lower =
new G4OpenGLXmTextField (
"Lower limit of zoom",
286 pView->fpdolly_upper =
new G4OpenGLXmTextField (
"Upper limit of dolly",
287 &(pView->dolly_high));
289 pView->fpdolly_lower =
new G4OpenGLXmTextField (
"Lower limit of dolly",
290 &(pView->dolly_low));
292 XtCallbackRec* ok_list =
new XtCallbackRec[2];
293 ok_list[0].callback = update_panels_callback;
294 ok_list[0].closure = pView;
295 ok_list[1].callback = NULL;
298 pView->fpok_button =
new G4OpenGLXmPushButton (
"ok",
301 pView->fpsetting_box->AddChild (pView->fppan_set);
302 pView->fpsetting_box->AddChild (pView->fprot_set);
303 pView->fpsetting_box->AddChild (pView->fpzoom_upper);
304 pView->fpsetting_box->AddChild (pView->fpzoom_lower);
305 pView->fpsetting_box->AddChild (pView->fpdolly_upper);
306 pView->fpsetting_box->AddChild (pView->fpdolly_lower);
307 pView->fpsetting_box->AddChild (pView->fpok_button);
309 pView->fpsetting_top->Realize ();
318 (
"G4OpenGLXmViewer::actions_callback",
320 "Unrecognised widget child of control_callback");
328 void G4OpenGLXmViewer::misc_callback (Widget w,
329 XtPointer clientData,
332 G4OpenGLXmViewer* pView;
334 XtVaGetValues (XtParent(w),
343 if (!pView->fpmiscellany_top) {
345 std::ostringstream misc_Name;
346 misc_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
348 pView->fpmiscellany_top =
new G4OpenGLXmTopLevelShell (pView,
349 (
char*)misc_Name.str().c_str());
350 pView->fpwobble_box =
new G4OpenGLXmFramedBox (
"Wobble view",
352 pView->fpmiscellany_top->AddChild (pView->fpwobble_box);
354 XtCallbackRec* wob_cb_list =
new XtCallbackRec[2];
355 wob_cb_list[0].callback = wobble_callback;
356 wob_cb_list[0].closure = pView;
357 wob_cb_list[1].callback = NULL;
360 pView->fpwobble_button =
new G4OpenGLXmPushButton (
"Wobble",
363 XtCallbackRec* wobble_slider_list =
new XtCallbackRec[2];
364 wobble_slider_list[0].callback = set_wob_sens_callback;
365 wobble_slider_list[0].closure = pView;
366 wobble_slider_list[1].callback = NULL;
368 pView->fpwobble_slider =
new G4OpenGLXmSliderBar (
"Wobble slider",
375 pView->fpwobble_box->AddChild (pView->fpwobble_button);
376 pView->fpwobble_box->AddChild (pView->fpwobble_slider);
378 pView->fpreset_box =
new G4OpenGLXmFramedBox (
"Reset view",
380 pView->fpmiscellany_top->AddChild (pView->fpreset_box);
382 XtCallbackRec* rst_cb_list =
new XtCallbackRec[3];
383 rst_cb_list[0].callback = reset_callback;
384 rst_cb_list[0].closure = pView;
385 rst_cb_list[1].callback = update_panels_callback;
386 rst_cb_list[1].closure = pView;
387 rst_cb_list[2].callback = NULL;
389 pView->fpreset_button =
new G4OpenGLXmPushButton (
"Reset",
392 pView->fpreset_box->AddChild (pView->fpreset_button);
394 pView->fpproj_style_box =
new G4OpenGLXmFramedBox (
"Projection style",
396 pView->fpmiscellany_top->AddChild (pView->fpproj_style_box);
398 XtCallbackRec* proj_cb_list =
new XtCallbackRec[2];
399 proj_cb_list[0].callback = projection_callback;
400 proj_cb_list[0].closure = pView;
401 proj_cb_list[1].callback = NULL;
403 pView->fporthogonal_button =
new G4OpenGLXmRadioButton (
"Orthographic",
405 pView->fVP.GetFieldHalfAngle() > 0. ? False : True,
408 pView->fpperspective_button =
new G4OpenGLXmRadioButton (
"Perspective",
410 pView->fVP.GetFieldHalfAngle() > 0. ? True : False,
413 pView->fpfov_text =
new G4OpenGLXmTextField (
"Field of view 0.1 -> 89.5 degrees.",
416 pView->fpproj_style_box->AddChild (pView->fpperspective_button);
417 pView->fpproj_style_box->AddChild (pView->fporthogonal_button);
418 pView->fpproj_style_box->AddChild (pView->fpfov_text);
420 pView->fpmiscellany_top->Realize ();
429 G4Xt::getInstance () -> RequireExitSecondaryLoop (
OGL_EXIT_CODE);
435 if (!pView->fpprint_top) {
437 std::ostringstream print_Name;
438 print_Name << pView->GetSceneHandler()->GetSceneHandlerId() <<
'-' << pView->fViewId;
440 pView->fpprint_top =
new G4OpenGLXmTopLevelShell (pView,
441 (
char*)print_Name.str().c_str());
443 pView->fpprint_box =
new G4OpenGLXmFramedBox (
"Create EPS file of current view",
446 pView->fpprint_top->AddChild (pView->fpprint_box);
448 pView->fpprint_col_box =
new G4OpenGLXmFramedBox (
"Colour choice",
450 pView->fpprint_top->AddChild (pView->fpprint_col_box);
452 XtCallbackRec* prcol_cb_list =
new XtCallbackRec[2];
453 prcol_cb_list[0].callback = set_print_colour_callback;
454 prcol_cb_list[0].closure = pView;
455 prcol_cb_list[1].callback = NULL;
457 pView->fpprint_col_radio1 =
new G4OpenGLXmRadioButton (
"Black and white",
459 pView->fPrintColour==
false ? True : False,
462 pView->fpprint_col_radio2 =
new G4OpenGLXmRadioButton (
"Colour",
464 pView->fPrintColour==
true ? True : False,
467 pView->fpprint_col_box->AddChild (pView->fpprint_col_radio1);
468 pView->fpprint_col_box->AddChild (pView->fpprint_col_radio2);
470 pView->fpprint_style_box =
new G4OpenGLXmFramedBox (
"File type",
472 pView->fpprint_top->AddChild (pView->fpprint_style_box);
474 XtCallbackRec* prsty_cb_list =
new XtCallbackRec[2];
475 prsty_cb_list[0].callback = set_print_style_callback;
476 prsty_cb_list[0].closure = pView;
477 prsty_cb_list[1].callback = NULL;
479 pView->fpprint_style_radio1 =
new G4OpenGLXmRadioButton (
"Screen dump (pixmap)",
481 pView->fVectoredPs==
false ? True : False,
484 pView->fpprint_style_radio2 =
new G4OpenGLXmRadioButton (
"PostScript",
486 pView->fVectoredPs==
true ? True : False,
489 pView->fpprint_style_box->AddChild (pView->fpprint_style_radio1);
490 pView->fpprint_style_box->AddChild (pView->fpprint_style_radio2);
492 pView->fpprint_text =
new G4OpenGLXmTextField (
"Name of .eps file to save",
493 (pView->getRealPrintFilename().c_str()));
494 pView->fpprint_box->AddChild (pView->fpprint_text);
496 pView->fpprint_line =
new G4OpenGLXmSeparator ();
497 pView->fpprint_box->AddChild (pView->fpprint_line);
499 XtCallbackRec* pri_cb_list =
new XtCallbackRec[2];
500 pri_cb_list[0].callback = print_callback;
501 pri_cb_list[0].closure = pView;
502 pri_cb_list[1].callback = NULL;
505 pView->fpprint_button =
new G4OpenGLXmPushButton (
"Create EPS file",
508 pView->fpprint_box->AddChild (pView->fpprint_button);
509 pView->fpprint_top->Realize ();
519 (
"G4OpenGLXmViewer::misc_callback",
521 "Unrecognised widget child of misc_callback.");
528 void G4OpenGLXmViewer::set_wob_sens_callback (Widget w,
529 XtPointer clientData,
532 XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct*) callData;
533 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
538 XmNdecimalPoints, &dp,
543 }
else if ( dp > 0) {
545 ten_to_the_dp *= 10.;
549 (
"G4OpenGLXmViewer::set_wob_sens_callback",
551 "Bad value returned for dp in set_rot_sens_callback");
554 pView->wob_sens = (
G4float)(cbs->value) / ten_to_the_dp;
557 void G4OpenGLXmViewer::update_panels_callback (Widget,
558 XtPointer clientData,
561 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
563 if (pView->fppanning_slider) {
564 pView->fppanning_slider->SetMaxValue (pView->pan_sens_limit);
566 if (pView->fprotation_slider) {
567 pView->fprotation_slider->SetMaxValue (pView->rot_sens_limit);
570 if (pView->fpzoom_slider) {
571 pView->fpzoom_slider->SetMaxValue (pView->zoom_high);
572 pView->fpzoom_slider->SetMinValue (pView->zoom_low);
573 pView->fpzoom_slider->SetInitialValue (pView->fVP.GetZoomFactor());
576 if (pView->fpdolly_slider) {
577 pView->fpdolly_slider->SetMaxValue (pView->dolly_high);
578 pView->fpdolly_slider->SetMinValue (pView->dolly_low);