35 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
44 void G4OpenGLXmViewer::theta_rotation_callback (Widget
w,
48 XmArrowButtonCallbackStruct *cbs = (XmArrowButtonCallbackStruct*) callData;
49 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
51 pView->rotate_right = get_boolean_userData (w);
53 if (cbs->reason == XmCR_ARM) {
54 rotate_in_theta (pView, NULL);
55 }
else if (cbs->reason == XmCR_DISARM) {
56 XtRemoveTimeOut (pView->rotation_timer);
60 void G4OpenGLXmViewer::rotate_in_theta (XtPointer clientData,
61 XtIntervalId* timer_id)
64 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
66 if (pView->rotate_right) {
67 pView->rotateScene(1,0);
69 pView->rotateScene(-1,0);
114 pView->rotation_timer = XtAppAddTimeOut
116 timer_id == NULL ? 500 : 1,
121 void G4OpenGLXmViewer::phi_rotation_callback (Widget w,
122 XtPointer clientData,
125 XmArrowButtonCallbackStruct *cbs = (XmArrowButtonCallbackStruct*) callData;
126 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
128 pView->rotate_up = get_boolean_userData (w);
130 if (cbs->reason == XmCR_ARM) {
131 rotate_in_phi (pView, NULL);
132 }
else if (cbs->reason == XmCR_DISARM) {
133 XtRemoveTimeOut (pView->rotation_timer);
137 void G4OpenGLXmViewer::rotate_in_phi (XtPointer clientData,
138 XtIntervalId* timer_id)
142 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
144 if (pView -> rotate_up) {
145 pView->rotateScene(0,-1);
147 pView->rotateScene(0,1);
187 pView->rotation_timer = XtAppAddTimeOut
189 timer_id == NULL ? 500 : 1,
194 void G4OpenGLXmViewer::set_rot_sens_callback (Widget w,
195 XtPointer clientData,
198 XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct*) callData;
199 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData;
204 XmNdecimalPoints, &dp,
209 }
else if ( dp > 0) {
211 ten_to_the_dp *= 10.;
215 (
"G4OpenGLXmViewer::set_rot_sens_callback",
217 "Bad value returned for dp in set_rot_sens_callback");
220 pView->fRot_sens = (
G4float)(cbs->value) / ten_to_the_dp;
223 void G4OpenGLXmViewer::set_rot_subject_callback (Widget w,
224 XtPointer clientData,
227 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
229 G4int choice = get_int_userData (w);
234 pView->fVP.SetLightsMoveWithCamera (
true);
239 pView->fVP.SetLightsMoveWithCamera (
false);
245 (
"G4OpenGLXmViewer::set_rot_subject_callback",
247 "Unrecognised choice made in set_rot_subject_callback");
252 void G4OpenGLXmViewer::wobble_callback (Widget w,
256 G4OpenGLXmViewer* pView;
262 pView->original_vp = pView->fVP.GetViewpointDirection();
263 pView->wobble_timer = XtAppAddTimeOut
265 (
long unsigned int) (1000. * (1. / pView->wob_sens)),
266 wobble_timer_callback,
270 void G4OpenGLXmViewer::wobble_timer_callback (XtPointer clientData,
273 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
274 const G4Vector3D& up = pView->fVP.GetUpVector();
277 G4Vector3D d_up = 0.1 * (std::sin ((
G4double)pView->frameNo * pi_div_by_ten * 2.)) * up;
278 G4Vector3D d_third_axis = 0.1 * (std::sin ((
G4double)pView->frameNo * (pi_div_by_ten))) * third_axis;
280 pView->fVP.SetViewAndLights (pView->original_vp + d_up + d_third_axis);
286 if (pView->frameNo++ == 20) {
287 if (pView->wobble_timer) {
288 XtRemoveTimeOut (pView->wobble_timer);
290 pView->fVP.SetViewAndLights (pView->original_vp);
296 pView->wobble_timer = XtAppAddTimeOut
298 (
long unsigned int) (1000. * (1. / pView->wob_sens)),
299 wobble_timer_callback,
304 void G4OpenGLXmViewer::reset_callback (Widget w,
309 G4OpenGLXmViewer* pView;
315 pView->fVP.SetCurrentTargetPoint(
G4Point3D());
316 pView->fVP.SetZoomFactor(1.0);
317 pView->fVP.SetDolly(0.0);
321 pView->zoom_low = 0.1;
322 pView->zoom_high = 10.0;