38#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
43#include <Xm/ToggleB.h>
44#include <Xm/ArrowBG.h>
45#include <Xm/RowColumn.h>
47#include <Xm/Separator.h>
50void G4OpenGLXmViewer::Add_four_arrow_buttons (G4OpenGLXmViewer* pView,
51 XtCallbackRec** arrow_callbacks,
52 Widget* parent_widget) {
54 Widget arrow_form = XtVaCreateWidget
59 XtNvisual, pView->vi->visual,
60 XtNdepth, pView->vi->depth,
61 XtNcolormap, pView->cmap,
62 XtNborderColor, pView->borcol,
63 XtNbackground, pView->bgnd,
66 Widget arrow = XtVaCreateManagedWidget
68 xmArrowButtonGadgetClass,
70 XmNtopAttachment, XmATTACH_POSITION,
72 XmNbottomAttachment, XmATTACH_POSITION,
74 XmNleftAttachment, XmATTACH_POSITION,
76 XmNrightAttachment, XmATTACH_POSITION,
78 XmNarrowDirection, XmARROW_UP,
85 XtAddCallbacks (arrow,
89 XtAddCallbacks (arrow,
93 XtAddCallbacks (arrow,
97 arrow = XtVaCreateManagedWidget
99 xmArrowButtonGadgetClass,
101 XmNtopAttachment, XmATTACH_POSITION,
103 XmNbottomAttachment, XmATTACH_POSITION,
104 XmNbottomPosition, 3,
105 XmNleftAttachment, XmATTACH_POSITION,
107 XmNrightAttachment, XmATTACH_POSITION,
109 XmNarrowDirection, XmARROW_DOWN,
112 XtVaSetValues (arrow,
116 XtAddCallbacks (arrow,
120 XtAddCallbacks (arrow,
124 XtAddCallbacks (arrow,
128 arrow = XtVaCreateManagedWidget
130 xmArrowButtonGadgetClass,
132 XmNtopAttachment, XmATTACH_POSITION,
134 XmNbottomAttachment, XmATTACH_POSITION,
135 XmNbottomPosition, 2,
136 XmNleftAttachment, XmATTACH_POSITION,
138 XmNrightAttachment, XmATTACH_POSITION,
140 XmNarrowDirection, XmARROW_LEFT,
143 XtVaSetValues (arrow,
147 XtAddCallbacks (arrow,
151 XtAddCallbacks (arrow,
155 XtAddCallbacks (arrow,
159 arrow = XtVaCreateManagedWidget
161 xmArrowButtonGadgetClass,
163 XmNtopAttachment, XmATTACH_POSITION,
165 XmNbottomAttachment, XmATTACH_POSITION,
166 XmNbottomPosition, 2,
167 XmNleftAttachment, XmATTACH_POSITION,
169 XmNrightAttachment, XmATTACH_POSITION,
171 XmNarrowDirection, XmARROW_RIGHT,
174 XtVaSetValues (arrow,
178 XtAddCallbacks (arrow,
182 XtAddCallbacks (arrow,
186 XtAddCallbacks (arrow,
190 XtManageChild (arrow_form);
194void G4OpenGLXmViewer::Add_radio_box (
char* label_string,
195 Widget* parent_widget,
196 XtCallbackRec* radio_box_callback,
198 G4int default_button,
199 char* radio_box_name,
201 G4OpenGLXmViewer* pView)
203 XmString button_str = XmStringCreateLocalized((
char*)
"");
206 args =
new Arg* [num_buttons];
210 for (i = 0; i < num_buttons; i++) {
212 args[i] =
new Arg[7];
213 button_str = XmStringCreateLocalized (button_names[i]);
215 XtSetArg (args[i][0], XtNvisual, pView->vi->visual);
216 XtSetArg (args[i][1], XtNdepth, pView->vi->depth);
217 XtSetArg (args[i][2], XtNcolormap, pView->cmap);
218 XtSetArg (args[i][3], XtNborderColor, pView->borcol);
219 XtSetArg (args[i][4], XtNbackground, pView->bgnd);
220 XtSetArg (args[i][5], XmNlabelString, button_str);
222 if (i == default_button) {
223 XtSetArg (args[i][6], XmNset, True);
225 XtSetArg (args[i][6], XmNset, False);
229 Widget radio_box = XtVaCreateWidget (radio_box_name,
230 xmRowColumnWidgetClass,
232 XmNisHomogeneous, False,
233 XmNradioBehavior, True,
234 XmNradioAlwaysOne, True,
236 XtNvisual, pView->vi->visual,
237 XtNdepth, pView->vi->depth,
238 XtNcolormap, pView->cmap,
239 XtNborderColor, pView->borcol,
240 XtNbackground, pView->bgnd,
243 XmString lab = XmStringCreateLocalized (label_string);
260 for (i = 0; i < num_buttons; i++) {
261 button = XtCreateManagedWidget (button_names[i],
262 xmToggleButtonWidgetClass,
266 XtVaSetValues (button,
270 XtAddCallbacks (button,
275 XtManageChild (radio_box);
277 XmStringFree (button_str);
279 for (i = 0; i < num_buttons; i++) {
288void G4OpenGLXmViewer::Add_set_field (
char* w_name,
293 G4OpenGLXmViewer* pView)
296 char local_w_text[50];
297 strcpy (local_w_text, w_text);
300 strcpy (label_name, w_name);
301 strcat (label_name,
"_label");
303 char text_field_name[50];
304 strcpy (text_field_name, w_name);
305 strcat (text_field_name,
"_text_field");
307 XmString local_text = XmStringCreateLocalized (local_w_text);
321 XmStringFree (local_text);
324 sprintf (initial,
"%6.2f", *val);
326 *wid = XtVaCreateManagedWidget (text_field_name,
327 xmTextFieldWidgetClass,
329 XmNvalue, (String)initial,
330 XtNvisual, pView->vi->visual,
331 XtNdepth, pView->vi->depth,
332 XtNcolormap, pView->cmap,
333 XtNborderColor, pView->borcol,
334 XtNbackground, pView->bgnd,
338 XmNvalueChangedCallback,
339 get_double_value_callback,
368 XtVaCreateManagedWidget (
"sep",
369 xmSeparatorWidgetClass,
371 XmNseparatorType, XmNO_LINE,
373 XmNorientation, XmHORIZONTAL,
374 XtNvisual, pView->vi->visual,
375 XtNdepth, pView->vi->depth,
376 XtNcolormap, pView->cmap,
377 XtNborderColor, pView->borcol,
378 XtNbackground, pView->bgnd,
382void G4OpenGLXmViewer::Add_slider_box (
char* label_string,
385 G4OpenGLXmViewer* pView,
391 unsigned char* orientation,
392 unsigned char* direction,
393 XtCallbackRec** slider_box_callbacks,
394 Widget* parent_widget)
396 XmString slider_name_str = XmStringCreateLocalized((
char*)
"");
399 slider_args =
new Arg*[num_sliders];
404 for (i = 0; i < num_sliders; i++) {
406 slider_args[i] =
new Arg[13];
407 slider_name_str = XmStringCreateLtoR (slider_names[i],
408 XmFONTLIST_DEFAULT_TAG);
410 XtSetArg (slider_args[i][j],
411 XtNvisual, pView->vi->visual); j++;
412 XtSetArg (slider_args[i][j],
413 XtNdepth, pView->vi->depth); j++;
414 XtSetArg (slider_args[i][j],
415 XtNcolormap, pView->cmap); j++;
416 XtSetArg (slider_args[i][j],
417 XtNborderColor, pView->borcol); j++;
418 XtSetArg (slider_args[i][j],
419 XtNbackground, pView->bgnd); j++;
421 XtSetArg (slider_args[i][j],
422 XmNtitleString, slider_name_str); j++;
424 XtSetArg (slider_args[i][j],
425 XmNmaximum,
G4int(max_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
426 XtSetArg (slider_args[i][j],
427 XmNminimum,
G4int(min_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
428 XtSetArg (slider_args[i][j],
429 XmNvalue,
G4int(value_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
430 XtSetArg (slider_args[i][j],
431 XmNshowValue, show[i]); j++;
432 XtSetArg (slider_args[i][j],
433 XmNdecimalPoints, decimals[i]); j++;
435 XtSetArg (slider_args[i][j],
436 XmNorientation, orientation[i]); j++;
437 XtSetArg (slider_args[i][j],
438 XmNprocessingDirection, direction[i]); j++;
442 Widget slider_box = XtVaCreateWidget (
"slider_box",
443 xmRowColumnWidgetClass,
445 XmNisHomogeneous, False,
446 XtNvisual, pView->vi->visual,
447 XtNdepth, pView->vi->depth,
448 XtNcolormap, pView->cmap,
449 XtNborderColor, pView->borcol,
450 XtNbackground, pView->bgnd,
453 XmString lab = XmStringCreateLocalized (label_string);
470 for (i = 0; i < num_sliders; i++) {
472 slider = XtCreateManagedWidget (slider_names[i],
478 XtAddCallbacks (slider,
479 XmNvalueChangedCallback,
480 slider_box_callbacks[i]);
482 XtAddCallbacks (slider,
484 slider_box_callbacks[i]);
488 XtManageChild (slider_box);
489 XmStringFree (slider_name_str);
491 for (i = 0; i < num_sliders; i++) {
493 delete[] slider_args[i];
497 delete[] slider_args;
501void G4OpenGLXmViewer::get_double_value_callback (Widget w,
502 XtPointer clientData,
512 sscanf (
string,
"%lg", val);
516void G4OpenGLXmViewer::get_text_callback (Widget w,
517 XtPointer clientData,
520 char* txt = (
char*)clientData;
527 sscanf (
string,
"%s", txt);
530G4bool G4OpenGLXmViewer::get_boolean_userData (Widget w)
533 XtVaGetValues (w,XmNuserData,&
userData,NULL);
537G4int G4OpenGLXmViewer::get_int_userData (Widget w)
540 XtVaGetValues (w,XmNuserData,&
userData,NULL);