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>
52 void G4OpenGLXmViewer::Add_four_arrow_buttons (G4OpenGLXmViewer* pView,
53 XtCallbackRec** arrow_callbacks,
54 Widget* parent_widget) {
56 Widget arrow_form = XtVaCreateWidget
61 XtNvisual, pView->vi->visual,
62 XtNdepth, pView->vi->depth,
63 XtNcolormap, pView->cmap,
64 XtNborderColor, pView->borcol,
65 XtNbackground, pView->bgnd,
68 Widget arrow = XtVaCreateManagedWidget
70 xmArrowButtonGadgetClass,
72 XmNtopAttachment, XmATTACH_POSITION,
74 XmNbottomAttachment, XmATTACH_POSITION,
76 XmNleftAttachment, XmATTACH_POSITION,
78 XmNrightAttachment, XmATTACH_POSITION,
80 XmNarrowDirection, XmARROW_UP,
87 XtAddCallbacks (arrow,
91 XtAddCallbacks (arrow,
95 XtAddCallbacks (arrow,
99 arrow = XtVaCreateManagedWidget
101 xmArrowButtonGadgetClass,
103 XmNtopAttachment, XmATTACH_POSITION,
105 XmNbottomAttachment, XmATTACH_POSITION,
106 XmNbottomPosition, 3,
107 XmNleftAttachment, XmATTACH_POSITION,
109 XmNrightAttachment, XmATTACH_POSITION,
111 XmNarrowDirection, XmARROW_DOWN,
114 XtVaSetValues (arrow,
118 XtAddCallbacks (arrow,
122 XtAddCallbacks (arrow,
126 XtAddCallbacks (arrow,
130 arrow = XtVaCreateManagedWidget
132 xmArrowButtonGadgetClass,
134 XmNtopAttachment, XmATTACH_POSITION,
136 XmNbottomAttachment, XmATTACH_POSITION,
137 XmNbottomPosition, 2,
138 XmNleftAttachment, XmATTACH_POSITION,
140 XmNrightAttachment, XmATTACH_POSITION,
142 XmNarrowDirection, XmARROW_LEFT,
145 XtVaSetValues (arrow,
149 XtAddCallbacks (arrow,
153 XtAddCallbacks (arrow,
157 XtAddCallbacks (arrow,
161 arrow = XtVaCreateManagedWidget
163 xmArrowButtonGadgetClass,
165 XmNtopAttachment, XmATTACH_POSITION,
167 XmNbottomAttachment, XmATTACH_POSITION,
168 XmNbottomPosition, 2,
169 XmNleftAttachment, XmATTACH_POSITION,
171 XmNrightAttachment, XmATTACH_POSITION,
173 XmNarrowDirection, XmARROW_RIGHT,
176 XtVaSetValues (arrow,
180 XtAddCallbacks (arrow,
184 XtAddCallbacks (arrow,
188 XtAddCallbacks (arrow,
192 XtManageChild (arrow_form);
196 void G4OpenGLXmViewer::Add_radio_box (
char* label_string,
197 Widget* parent_widget,
198 XtCallbackRec* radio_box_callback,
200 G4int default_button,
201 char* radio_box_name,
203 G4OpenGLXmViewer* pView)
205 XmString button_str = XmStringCreateLocalized((
char*)
"");
208 args =
new Arg* [num_buttons];
212 for (i = 0; i < num_buttons; i++) {
214 args[i] =
new Arg[7];
215 button_str = XmStringCreateLocalized (button_names[i]);
217 XtSetArg (args[i][0], XtNvisual, pView->vi->visual);
218 XtSetArg (args[i][1], XtNdepth, pView->vi->depth);
219 XtSetArg (args[i][2], XtNcolormap, pView->cmap);
220 XtSetArg (args[i][3], XtNborderColor, pView->borcol);
221 XtSetArg (args[i][4], XtNbackground, pView->bgnd);
222 XtSetArg (args[i][5], XmNlabelString, button_str);
224 if (i == default_button) {
225 XtSetArg (args[i][6], XmNset, True);
227 XtSetArg (args[i][6], XmNset, False);
231 Widget radio_box = XtVaCreateWidget (radio_box_name,
232 xmRowColumnWidgetClass,
234 XmNisHomogeneous, False,
235 XmNradioBehavior, True,
236 XmNradioAlwaysOne, True,
238 XtNvisual, pView->vi->visual,
239 XtNdepth, pView->vi->depth,
240 XtNcolormap, pView->cmap,
241 XtNborderColor, pView->borcol,
242 XtNbackground, pView->bgnd,
245 XmString lab = XmStringCreateLocalized (label_string);
262 for (i = 0; i < num_buttons; i++) {
263 button = XtCreateManagedWidget (button_names[i],
264 xmToggleButtonWidgetClass,
268 XtVaSetValues (button,
272 XtAddCallbacks (button,
277 XtManageChild (radio_box);
279 XmStringFree (button_str);
281 for (i = 0; i < num_buttons; i++) {
290 void G4OpenGLXmViewer::Add_set_field (
char* w_name,
295 G4OpenGLXmViewer* pView)
298 char local_w_text[50];
299 strcpy (local_w_text, w_text);
302 strcpy (label_name, w_name);
303 strcat (label_name,
"_label");
305 char text_field_name[50];
306 strcpy (text_field_name, w_name);
307 strcat (text_field_name,
"_text_field");
309 XmString local_text = XmStringCreateLocalized (local_w_text);
323 XmStringFree (local_text);
326 sprintf (initial,
"%6.2f", *val);
328 *wid = XtVaCreateManagedWidget (text_field_name,
329 xmTextFieldWidgetClass,
331 XmNvalue, (String)initial,
332 XtNvisual, pView->vi->visual,
333 XtNdepth, pView->vi->depth,
334 XtNcolormap, pView->cmap,
335 XtNborderColor, pView->borcol,
336 XtNbackground, pView->bgnd,
340 XmNvalueChangedCallback,
341 get_double_value_callback,
370 XtVaCreateManagedWidget (
"sep",
371 xmSeparatorWidgetClass,
373 XmNseparatorType, XmNO_LINE,
375 XmNorientation, XmHORIZONTAL,
376 XtNvisual, pView->vi->visual,
377 XtNdepth, pView->vi->depth,
378 XtNcolormap, pView->cmap,
379 XtNborderColor, pView->borcol,
380 XtNbackground, pView->bgnd,
384 void G4OpenGLXmViewer::Add_slider_box (
char* label_string,
387 G4OpenGLXmViewer* pView,
393 unsigned char* orientation,
394 unsigned char* direction,
395 XtCallbackRec** slider_box_callbacks,
396 Widget* parent_widget)
398 XmString slider_name_str = XmStringCreateLocalized((
char*)
"");
401 slider_args =
new Arg*[num_sliders];
406 for (i = 0; i < num_sliders; i++) {
408 slider_args[i] =
new Arg[13];
409 slider_name_str = XmStringCreateLtoR (slider_names[i],
410 XmFONTLIST_DEFAULT_TAG);
412 XtSetArg (slider_args[i][j],
413 XtNvisual, pView->vi->visual); j++;
414 XtSetArg (slider_args[i][j],
415 XtNdepth, pView->vi->depth); j++;
416 XtSetArg (slider_args[i][j],
417 XtNcolormap, pView->cmap); j++;
418 XtSetArg (slider_args[i][j],
419 XtNborderColor, pView->borcol); j++;
420 XtSetArg (slider_args[i][j],
421 XtNbackground, pView->bgnd); j++;
423 XtSetArg (slider_args[i][j],
424 XmNtitleString, slider_name_str); j++;
426 XtSetArg (slider_args[i][j],
427 XmNmaximum,
G4int(max_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
428 XtSetArg (slider_args[i][j],
429 XmNminimum,
G4int(min_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
430 XtSetArg (slider_args[i][j],
431 XmNvalue,
G4int(value_array[i] * std::pow(10.0, (
G4double)decimals[i]))); j++;
432 XtSetArg (slider_args[i][j],
433 XmNshowValue, show[i]); j++;
434 XtSetArg (slider_args[i][j],
435 XmNdecimalPoints, decimals[i]); j++;
437 XtSetArg (slider_args[i][j],
438 XmNorientation, orientation[i]); j++;
439 XtSetArg (slider_args[i][j],
440 XmNprocessingDirection, direction[i]); j++;
444 Widget slider_box = XtVaCreateWidget (
"slider_box",
445 xmRowColumnWidgetClass,
447 XmNisHomogeneous, False,
448 XtNvisual, pView->vi->visual,
449 XtNdepth, pView->vi->depth,
450 XtNcolormap, pView->cmap,
451 XtNborderColor, pView->borcol,
452 XtNbackground, pView->bgnd,
455 XmString lab = XmStringCreateLocalized (label_string);
472 for (i = 0; i < num_sliders; i++) {
474 slider = XtCreateManagedWidget (slider_names[i],
480 XtAddCallbacks (slider,
481 XmNvalueChangedCallback,
482 slider_box_callbacks[i]);
484 XtAddCallbacks (slider,
486 slider_box_callbacks[i]);
490 XtManageChild (slider_box);
491 XmStringFree (slider_name_str);
493 for (i = 0; i < num_sliders; i++) {
495 delete[] slider_args[i];
499 delete[] slider_args;
503 void G4OpenGLXmViewer::get_double_value_callback (Widget w,
504 XtPointer clientData,
515 std::istringstream iss(
string);
519 void G4OpenGLXmViewer::get_text_callback (Widget w,
520 XtPointer clientData,
523 char* txt = (
char*)clientData;
531 std::istringstream iss(
string);
535 G4bool G4OpenGLXmViewer::get_boolean_userData (Widget w)
538 XtVaGetValues (w,XmNuserData,&userData,NULL);
539 return (
G4bool)(((
unsigned long)userData)&0xffff);
542 G4int G4OpenGLXmViewer::get_int_userData (Widget w)
545 XtVaGetValues (w,XmNuserData,&userData,NULL);
546 return (
G4int)(
unsigned long)userData;