37 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
42 #include <Xm/ToggleB.h>
43 #include <Xm/ArrowBG.h>
44 #include <Xm/RowColumn.h>
46 #include <Xm/Separator.h>
51 void G4OpenGLXmViewer::Add_four_arrow_buttons (G4OpenGLXmViewer* pView,
52 XtCallbackRec** arrow_callbacks,
53 Widget* parent_widget) {
55 Widget arrow_form = XtVaCreateWidget
60 XtNvisual, pView->vi->visual,
61 XtNdepth, pView->vi->depth,
62 XtNcolormap, pView->cmap,
63 XtNborderColor, pView->borcol,
64 XtNbackground, pView->bgnd,
67 Widget arrow = XtVaCreateManagedWidget
69 xmArrowButtonGadgetClass,
71 XmNtopAttachment, XmATTACH_POSITION,
73 XmNbottomAttachment, XmATTACH_POSITION,
75 XmNleftAttachment, XmATTACH_POSITION,
77 XmNrightAttachment, XmATTACH_POSITION,
79 XmNarrowDirection, XmARROW_UP,
86 XtAddCallbacks (arrow,
90 XtAddCallbacks (arrow,
94 XtAddCallbacks (arrow,
98 arrow = XtVaCreateManagedWidget
100 xmArrowButtonGadgetClass,
102 XmNtopAttachment, XmATTACH_POSITION,
104 XmNbottomAttachment, XmATTACH_POSITION,
105 XmNbottomPosition, 3,
106 XmNleftAttachment, XmATTACH_POSITION,
108 XmNrightAttachment, XmATTACH_POSITION,
110 XmNarrowDirection, XmARROW_DOWN,
113 XtVaSetValues (arrow,
117 XtAddCallbacks (arrow,
121 XtAddCallbacks (arrow,
125 XtAddCallbacks (arrow,
129 arrow = XtVaCreateManagedWidget
131 xmArrowButtonGadgetClass,
133 XmNtopAttachment, XmATTACH_POSITION,
135 XmNbottomAttachment, XmATTACH_POSITION,
136 XmNbottomPosition, 2,
137 XmNleftAttachment, XmATTACH_POSITION,
139 XmNrightAttachment, XmATTACH_POSITION,
141 XmNarrowDirection, XmARROW_LEFT,
144 XtVaSetValues (arrow,
148 XtAddCallbacks (arrow,
152 XtAddCallbacks (arrow,
156 XtAddCallbacks (arrow,
160 arrow = XtVaCreateManagedWidget
162 xmArrowButtonGadgetClass,
164 XmNtopAttachment, XmATTACH_POSITION,
166 XmNbottomAttachment, XmATTACH_POSITION,
167 XmNbottomPosition, 2,
168 XmNleftAttachment, XmATTACH_POSITION,
170 XmNrightAttachment, XmATTACH_POSITION,
172 XmNarrowDirection, XmARROW_RIGHT,
175 XtVaSetValues (arrow,
179 XtAddCallbacks (arrow,
183 XtAddCallbacks (arrow,
187 XtAddCallbacks (arrow,
191 XtManageChild (arrow_form);
195 void G4OpenGLXmViewer::Add_radio_box (
char* label_string,
196 Widget* parent_widget,
197 XtCallbackRec* radio_box_callback,
199 G4int default_button,
200 char* radio_box_name,
202 G4OpenGLXmViewer* pView)
204 XmString button_str = XmStringCreateLocalized((
char*)
"");
207 args =
new Arg* [num_buttons];
211 for (i = 0; i < num_buttons; i++) {
213 args[i] =
new Arg[7];
214 button_str = XmStringCreateLocalized (button_names[i]);
216 XtSetArg (args[i][0], XtNvisual, pView->vi->visual);
217 XtSetArg (args[i][1], XtNdepth, pView->vi->depth);
218 XtSetArg (args[i][2], XtNcolormap, pView->cmap);
219 XtSetArg (args[i][3], XtNborderColor, pView->borcol);
220 XtSetArg (args[i][4], XtNbackground, pView->bgnd);
221 XtSetArg (args[i][5], XmNlabelString, button_str);
223 if (i == default_button) {
224 XtSetArg (args[i][6], XmNset, True);
226 XtSetArg (args[i][6], XmNset, False);
230 Widget radio_box = XtVaCreateWidget (radio_box_name,
231 xmRowColumnWidgetClass,
233 XmNisHomogeneous, False,
234 XmNradioBehavior, True,
235 XmNradioAlwaysOne, True,
237 XtNvisual, pView->vi->visual,
238 XtNdepth, pView->vi->depth,
239 XtNcolormap, pView->cmap,
240 XtNborderColor, pView->borcol,
241 XtNbackground, pView->bgnd,
244 XmString lab = XmStringCreateLocalized (label_string);
261 for (i = 0; i < num_buttons; i++) {
262 button = XtCreateManagedWidget (button_names[i],
263 xmToggleButtonWidgetClass,
267 XtVaSetValues (button,
271 XtAddCallbacks (button,
276 XtManageChild (radio_box);
278 XmStringFree (button_str);
280 for (i = 0; i < num_buttons; i++) {
289 void G4OpenGLXmViewer::Add_set_field (
char* w_name,
294 G4OpenGLXmViewer* pView)
297 char local_w_text[50];
298 strcpy (local_w_text, w_text);
301 strcpy (label_name, w_name);
302 strcat (label_name,
"_label");
304 char text_field_name[50];
305 strcpy (text_field_name, w_name);
306 strcat (text_field_name,
"_text_field");
308 XmString local_text = XmStringCreateLocalized (local_w_text);
322 XmStringFree (local_text);
325 sprintf (initial,
"%6.2f", *val);
327 *wid = XtVaCreateManagedWidget (text_field_name,
328 xmTextFieldWidgetClass,
330 XmNvalue, (String)initial,
331 XtNvisual, pView->vi->visual,
332 XtNdepth, pView->vi->depth,
333 XtNcolormap, pView->cmap,
334 XtNborderColor, pView->borcol,
335 XtNbackground, pView->bgnd,
339 XmNvalueChangedCallback,
340 get_double_value_callback,
369 XtVaCreateManagedWidget (
"sep",
370 xmSeparatorWidgetClass,
372 XmNseparatorType, XmNO_LINE,
374 XmNorientation, XmHORIZONTAL,
375 XtNvisual, pView->vi->visual,
376 XtNdepth, pView->vi->depth,
377 XtNcolormap, pView->cmap,
378 XtNborderColor, pView->borcol,
379 XtNbackground, pView->bgnd,
383 void G4OpenGLXmViewer::Add_slider_box (
char* label_string,
386 G4OpenGLXmViewer* pView,
392 unsigned char* orientation,
393 unsigned char* direction,
394 XtCallbackRec** slider_box_callbacks,
395 Widget* parent_widget)
397 XmString slider_name_str = XmStringCreateLocalized((
char*)
"");
400 slider_args =
new Arg*[num_sliders];
405 for (i = 0; i < num_sliders; i++) {
407 slider_args[i] =
new Arg[13];
408 slider_name_str = XmStringCreateLtoR (slider_names[i],
409 XmFONTLIST_DEFAULT_TAG);
411 XtSetArg (slider_args[i][j],
412 XtNvisual, pView->vi->visual); j++;
413 XtSetArg (slider_args[i][j],
414 XtNdepth, pView->vi->depth); j++;
415 XtSetArg (slider_args[i][j],
416 XtNcolormap, pView->cmap); j++;
417 XtSetArg (slider_args[i][j],
418 XtNborderColor, pView->borcol); j++;
419 XtSetArg (slider_args[i][j],
420 XtNbackground, pView->bgnd); j++;
422 XtSetArg (slider_args[i][j],
423 XmNtitleString, slider_name_str); j++;
425 XtSetArg (slider_args[i][j],
426 XmNmaximum,
G4int(max_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
427 XtSetArg (slider_args[i][j],
428 XmNminimum,
G4int(min_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
429 XtSetArg (slider_args[i][j],
430 XmNvalue,
G4int(value_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
431 XtSetArg (slider_args[i][j],
432 XmNshowValue, show[i]); j++;
433 XtSetArg (slider_args[i][j],
434 XmNdecimalPoints, decimals[i]); j++;
436 XtSetArg (slider_args[i][j],
437 XmNorientation, orientation[i]); j++;
438 XtSetArg (slider_args[i][j],
439 XmNprocessingDirection, direction[i]); j++;
443 Widget slider_box = XtVaCreateWidget (
"slider_box",
444 xmRowColumnWidgetClass,
446 XmNisHomogeneous, False,
447 XtNvisual, pView->vi->visual,
448 XtNdepth, pView->vi->depth,
449 XtNcolormap, pView->cmap,
450 XtNborderColor, pView->borcol,
451 XtNbackground, pView->bgnd,
454 XmString lab = XmStringCreateLocalized (label_string);
471 for (i = 0; i < num_sliders; i++) {
473 slider = XtCreateManagedWidget (slider_names[i],
479 XtAddCallbacks (slider,
480 XmNvalueChangedCallback,
481 slider_box_callbacks[i]);
483 XtAddCallbacks (slider,
485 slider_box_callbacks[i]);
489 XtManageChild (slider_box);
490 XmStringFree (slider_name_str);
492 for (i = 0; i < num_sliders; i++) {
494 delete[] slider_args[i];
498 delete[] slider_args;
502 void G4OpenGLXmViewer::get_double_value_callback (Widget
w,
503 XtPointer clientData,
514 std::istringstream iss(
string);
518 void G4OpenGLXmViewer::get_text_callback (Widget
w,
519 XtPointer clientData,
522 char* txt = (
char*)clientData;
530 std::istringstream iss(
string);
534 G4bool G4OpenGLXmViewer::get_boolean_userData (Widget
w)
537 XtVaGetValues (w,XmNuserData,&userData,NULL);
538 return (
G4bool)(((
unsigned long)userData)&0xffff);
541 G4int G4OpenGLXmViewer::get_int_userData (Widget w)
544 XtVaGetValues (w,XmNuserData,&userData,NULL);
545 return (
G4int)(
unsigned long)userData;