Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // 27 // 28 // 28 // 29 // Andrew Walkden 16th April 1997 29 // Andrew Walkden 16th April 1997 30 // G4OpenGLXmConvenienceRoutines : 30 // G4OpenGLXmConvenienceRoutines : 31 // Collection of routine 31 // Collection of routines to facilitate 32 // the addition of simpl 32 // the addition of simple push button boxes, 33 // and slider bars to th 33 // and slider bars to the control panel. >> 34 // >> 35 // See G4OpenGLXmConvenienceRoutines.hh for more information. 34 36 35 #include "G4OpenGLXmViewer.hh" 37 #include "G4OpenGLXmViewer.hh" 36 38 37 #include <Xm/Form.h> 39 #include <Xm/Form.h> 38 #include <Xm/ToggleB.h> 40 #include <Xm/ToggleB.h> 39 #include <Xm/ArrowBG.h> 41 #include <Xm/ArrowBG.h> 40 #include <Xm/RowColumn.h> 42 #include <Xm/RowColumn.h> 41 #include <Xm/TextF.h> 43 #include <Xm/TextF.h> 42 #include <Xm/Separator.h> 44 #include <Xm/Separator.h> 43 #include <Xm/Scale.h> 45 #include <Xm/Scale.h> 44 46 45 #include <sstream> 47 #include <sstream> 46 48 47 const G4String G4OpenGLXmViewer::e_str = ""; << 48 << 49 void G4OpenGLXmViewer::Add_four_arrow_buttons 49 void G4OpenGLXmViewer::Add_four_arrow_buttons (G4OpenGLXmViewer* pView, 50 XtCallbackRec** arrow_callbacks 50 XtCallbackRec** arrow_callbacks, 51 Widget* parent_widget) { 51 Widget* parent_widget) { 52 52 53 Widget arrow_form = XtVaCreateWidget 53 Widget arrow_form = XtVaCreateWidget 54 ("arrow_form", 54 ("arrow_form", 55 xmFormWidgetClass, 55 xmFormWidgetClass, 56 *parent_widget, 56 *parent_widget, 57 XmNfractionBase, 3, 57 XmNfractionBase, 3, 58 XtNvisual, pView->vi->visual, 58 XtNvisual, pView->vi->visual, 59 XtNdepth, pView->vi->depth, 59 XtNdepth, pView->vi->depth, 60 XtNcolormap, pView->cmap, 60 XtNcolormap, pView->cmap, 61 XtNborderColor, pView->borcol, 61 XtNborderColor, pView->borcol, 62 XtNbackground, pView->bgnd, 62 XtNbackground, pView->bgnd, 63 NULL); 63 NULL); 64 64 65 Widget arrow = XtVaCreateManagedWidget 65 Widget arrow = XtVaCreateManagedWidget 66 ("up_arrow", 66 ("up_arrow", 67 xmArrowButtonGadgetClass, 67 xmArrowButtonGadgetClass, 68 arrow_form, 68 arrow_form, 69 XmNtopAttachment, XmATTACH_POSITION, 69 XmNtopAttachment, XmATTACH_POSITION, 70 XmNtopPosition, 0, 70 XmNtopPosition, 0, 71 XmNbottomAttachment, XmATTACH_POSITION, 71 XmNbottomAttachment, XmATTACH_POSITION, 72 XmNbottomPosition, 1, 72 XmNbottomPosition, 1, 73 XmNleftAttachment, XmATTACH_POSITION, 73 XmNleftAttachment, XmATTACH_POSITION, 74 XmNleftPosition, 1, 74 XmNleftPosition, 1, 75 XmNrightAttachment, XmATTACH_POSITION, 75 XmNrightAttachment, XmATTACH_POSITION, 76 XmNrightPosition, 2, 76 XmNrightPosition, 2, 77 XmNarrowDirection, XmARROW_UP, 77 XmNarrowDirection, XmARROW_UP, 78 NULL); 78 NULL); 79 79 80 XtVaSetValues (arrow, 80 XtVaSetValues (arrow, 81 XmNuserData, True, 81 XmNuserData, True, 82 NULL); 82 NULL); 83 83 84 XtAddCallbacks (arrow, 84 XtAddCallbacks (arrow, 85 XmNactivateCallback, 85 XmNactivateCallback, 86 arrow_callbacks[0]); 86 arrow_callbacks[0]); 87 87 88 XtAddCallbacks (arrow, 88 XtAddCallbacks (arrow, 89 XmNarmCallback, 89 XmNarmCallback, 90 arrow_callbacks[0]); 90 arrow_callbacks[0]); 91 91 92 XtAddCallbacks (arrow, 92 XtAddCallbacks (arrow, 93 XmNdisarmCallback, 93 XmNdisarmCallback, 94 arrow_callbacks[0]); 94 arrow_callbacks[0]); 95 95 96 arrow = XtVaCreateManagedWidget 96 arrow = XtVaCreateManagedWidget 97 ("down_arrow", 97 ("down_arrow", 98 xmArrowButtonGadgetClass, 98 xmArrowButtonGadgetClass, 99 arrow_form, 99 arrow_form, 100 XmNtopAttachment, XmATTACH_POSITION, 100 XmNtopAttachment, XmATTACH_POSITION, 101 XmNtopPosition, 2, 101 XmNtopPosition, 2, 102 XmNbottomAttachment, XmATTACH_POSITION, 102 XmNbottomAttachment, XmATTACH_POSITION, 103 XmNbottomPosition, 3, 103 XmNbottomPosition, 3, 104 XmNleftAttachment, XmATTACH_POSITION, 104 XmNleftAttachment, XmATTACH_POSITION, 105 XmNleftPosition, 1, 105 XmNleftPosition, 1, 106 XmNrightAttachment, XmATTACH_POSITION, 106 XmNrightAttachment, XmATTACH_POSITION, 107 XmNrightPosition, 2, 107 XmNrightPosition, 2, 108 XmNarrowDirection, XmARROW_DOWN, 108 XmNarrowDirection, XmARROW_DOWN, 109 NULL); 109 NULL); 110 110 111 XtVaSetValues (arrow, 111 XtVaSetValues (arrow, 112 XmNuserData, False, 112 XmNuserData, False, 113 NULL); 113 NULL); 114 114 115 XtAddCallbacks (arrow, 115 XtAddCallbacks (arrow, 116 XmNactivateCallback, 116 XmNactivateCallback, 117 arrow_callbacks[1]); 117 arrow_callbacks[1]); 118 118 119 XtAddCallbacks (arrow, 119 XtAddCallbacks (arrow, 120 XmNarmCallback, 120 XmNarmCallback, 121 arrow_callbacks[1]); 121 arrow_callbacks[1]); 122 122 123 XtAddCallbacks (arrow, 123 XtAddCallbacks (arrow, 124 XmNdisarmCallback, 124 XmNdisarmCallback, 125 arrow_callbacks[1]); 125 arrow_callbacks[1]); 126 126 127 arrow = XtVaCreateManagedWidget 127 arrow = XtVaCreateManagedWidget 128 ("left_arrow", 128 ("left_arrow", 129 xmArrowButtonGadgetClass, 129 xmArrowButtonGadgetClass, 130 arrow_form, 130 arrow_form, 131 XmNtopAttachment, XmATTACH_POSITION, 131 XmNtopAttachment, XmATTACH_POSITION, 132 XmNtopPosition, 1, 132 XmNtopPosition, 1, 133 XmNbottomAttachment, XmATTACH_POSITION, 133 XmNbottomAttachment, XmATTACH_POSITION, 134 XmNbottomPosition, 2, 134 XmNbottomPosition, 2, 135 XmNleftAttachment, XmATTACH_POSITION, 135 XmNleftAttachment, XmATTACH_POSITION, 136 XmNleftPosition, 0, 136 XmNleftPosition, 0, 137 XmNrightAttachment, XmATTACH_POSITION, 137 XmNrightAttachment, XmATTACH_POSITION, 138 XmNrightPosition, 1, 138 XmNrightPosition, 1, 139 XmNarrowDirection, XmARROW_LEFT, 139 XmNarrowDirection, XmARROW_LEFT, 140 NULL); 140 NULL); 141 141 142 XtVaSetValues (arrow, 142 XtVaSetValues (arrow, 143 XmNuserData, False, 143 XmNuserData, False, 144 NULL); 144 NULL); 145 145 146 XtAddCallbacks (arrow, 146 XtAddCallbacks (arrow, 147 XmNactivateCallback, 147 XmNactivateCallback, 148 arrow_callbacks[2]); 148 arrow_callbacks[2]); 149 149 150 XtAddCallbacks (arrow, 150 XtAddCallbacks (arrow, 151 XmNarmCallback, 151 XmNarmCallback, 152 arrow_callbacks[2]); 152 arrow_callbacks[2]); 153 153 154 XtAddCallbacks (arrow, 154 XtAddCallbacks (arrow, 155 XmNdisarmCallback, 155 XmNdisarmCallback, 156 arrow_callbacks[2]); 156 arrow_callbacks[2]); 157 157 158 arrow = XtVaCreateManagedWidget 158 arrow = XtVaCreateManagedWidget 159 ("right_arrow", 159 ("right_arrow", 160 xmArrowButtonGadgetClass, 160 xmArrowButtonGadgetClass, 161 arrow_form, 161 arrow_form, 162 XmNtopAttachment, XmATTACH_POSITION, 162 XmNtopAttachment, XmATTACH_POSITION, 163 XmNtopPosition, 1, 163 XmNtopPosition, 1, 164 XmNbottomAttachment, XmATTACH_POSITION, 164 XmNbottomAttachment, XmATTACH_POSITION, 165 XmNbottomPosition, 2, 165 XmNbottomPosition, 2, 166 XmNleftAttachment, XmATTACH_POSITION, 166 XmNleftAttachment, XmATTACH_POSITION, 167 XmNleftPosition, 2, 167 XmNleftPosition, 2, 168 XmNrightAttachment, XmATTACH_POSITION, 168 XmNrightAttachment, XmATTACH_POSITION, 169 XmNrightPosition, 3, 169 XmNrightPosition, 3, 170 XmNarrowDirection, XmARROW_RIGHT, 170 XmNarrowDirection, XmARROW_RIGHT, 171 NULL); 171 NULL); 172 172 173 XtVaSetValues (arrow, 173 XtVaSetValues (arrow, 174 XmNuserData, True, 174 XmNuserData, True, 175 NULL); 175 NULL); 176 176 177 XtAddCallbacks (arrow, 177 XtAddCallbacks (arrow, 178 XmNactivateCallback, 178 XmNactivateCallback, 179 arrow_callbacks[3]); 179 arrow_callbacks[3]); 180 180 181 XtAddCallbacks (arrow, 181 XtAddCallbacks (arrow, 182 XmNarmCallback, 182 XmNarmCallback, 183 arrow_callbacks[3]); 183 arrow_callbacks[3]); 184 184 185 XtAddCallbacks (arrow, 185 XtAddCallbacks (arrow, 186 XmNdisarmCallback, 186 XmNdisarmCallback, 187 arrow_callbacks[3]); 187 arrow_callbacks[3]); 188 188 189 XtManageChild (arrow_form); 189 XtManageChild (arrow_form); 190 190 191 } 191 } 192 192 193 void G4OpenGLXmViewer::Add_radio_box (char* la 193 void G4OpenGLXmViewer::Add_radio_box (char* label_string, 194 Widget* parent_widget, 194 Widget* parent_widget, 195 XtCallbackRec* radio_box_callback, 195 XtCallbackRec* radio_box_callback, 196 G4int num_buttons, 196 G4int num_buttons, 197 G4int default_button, 197 G4int default_button, 198 char* radio_box_name, 198 char* radio_box_name, 199 char** button_names, 199 char** button_names, 200 G4OpenGLXmViewer* pView) 200 G4OpenGLXmViewer* pView) 201 { 201 { 202 XmString button_str = XmStringCreateLocalize << 202 XmString button_str = XmStringCreateLocalized((char*) ""); // ...to 203 // initialise to something to avoid pedantic 203 // initialise to something to avoid pedantic warning. 204 Arg** args; 204 Arg** args; 205 args = new Arg* [num_buttons]; 205 args = new Arg* [num_buttons]; 206 Widget button; 206 Widget button; 207 207 208 G4int i; 208 G4int i; 209 for (i = 0; i < num_buttons; i++) { 209 for (i = 0; i < num_buttons; i++) { 210 210 211 args[i] = new Arg[7]; 211 args[i] = new Arg[7]; 212 button_str = XmStringCreateLocalized (butt 212 button_str = XmStringCreateLocalized (button_names[i]); 213 213 214 XtSetArg (args[i][0], XtNvisual, pView->vi 214 XtSetArg (args[i][0], XtNvisual, pView->vi->visual); 215 XtSetArg (args[i][1], XtNdepth, pView->vi- 215 XtSetArg (args[i][1], XtNdepth, pView->vi->depth); 216 XtSetArg (args[i][2], XtNcolormap, pView-> 216 XtSetArg (args[i][2], XtNcolormap, pView->cmap); 217 XtSetArg (args[i][3], XtNborderColor, pVie 217 XtSetArg (args[i][3], XtNborderColor, pView->borcol); 218 XtSetArg (args[i][4], XtNbackground, pView 218 XtSetArg (args[i][4], XtNbackground, pView->bgnd); 219 XtSetArg (args[i][5], XmNlabelString, butt 219 XtSetArg (args[i][5], XmNlabelString, button_str); 220 220 221 if (i == default_button) { 221 if (i == default_button) { 222 XtSetArg (args[i][6], XmNset, True); 222 XtSetArg (args[i][6], XmNset, True); 223 } else { 223 } else { 224 XtSetArg (args[i][6], XmNset, False); 224 XtSetArg (args[i][6], XmNset, False); 225 } 225 } 226 } 226 } 227 227 228 Widget radio_box = XtVaCreateWidget (radio_b 228 Widget radio_box = XtVaCreateWidget (radio_box_name, 229 xmRowColumnWidgetClass, 229 xmRowColumnWidgetClass, 230 *parent_widget, 230 *parent_widget, 231 XmNisHomogeneous, False, 231 XmNisHomogeneous, False, 232 XmNradioBehavior, True, 232 XmNradioBehavior, True, 233 XmNradioAlwaysOne, True, 233 XmNradioAlwaysOne, True, 234 XmNuserData, pView, 234 XmNuserData, pView, 235 XtNvisual, pView->vi->visual, 235 XtNvisual, pView->vi->visual, 236 XtNdepth, pView->vi->depth, 236 XtNdepth, pView->vi->depth, 237 XtNcolormap, pView->cmap, 237 XtNcolormap, pView->cmap, 238 XtNborderColor, pView->borcol, 238 XtNborderColor, pView->borcol, 239 XtNbackground, pView->bgnd, 239 XtNbackground, pView->bgnd, 240 NULL); 240 NULL); 241 241 242 XmString lab = XmStringCreateLocalized (labe 242 XmString lab = XmStringCreateLocalized (label_string); 243 243 244 // Unused! 244 // Unused! 245 //Widget label = XtVaCreateManagedWidget ("r 245 //Widget label = XtVaCreateManagedWidget ("radio_label", 246 // xmLabelWidgetClass, 246 // xmLabelWidgetClass, 247 // radio_box, 247 // radio_box, 248 // XmNalignment, XmALIGNMENT_CENTER 248 // XmNalignment, XmALIGNMENT_CENTER, 249 // XmNlabelString, lab, 249 // XmNlabelString, lab, 250 // XtNvisual, pView->vi->visual, 250 // XtNvisual, pView->vi->visual, 251 // XtNdepth, pView->vi->depth, 251 // XtNdepth, pView->vi->depth, 252 // XtNcolormap, pView->cmap, 252 // XtNcolormap, pView->cmap, 253 // XtNborderColor, pView->borcol, 253 // XtNborderColor, pView->borcol, 254 // XtNbackground, pView->bgnd, 254 // XtNbackground, pView->bgnd, 255 // NULL); 255 // NULL); 256 256 257 XmStringFree (lab); 257 XmStringFree (lab); 258 258 259 for (i = 0; i < num_buttons; i++) { 259 for (i = 0; i < num_buttons; i++) { 260 button = XtCreateManagedWidget (button_nam 260 button = XtCreateManagedWidget (button_names[i], 261 xmToggleButtonWidgetClass, 261 xmToggleButtonWidgetClass, 262 radio_box, 262 radio_box, 263 args[i], 263 args[i], 264 7); 264 7); 265 XtVaSetValues (button, 265 XtVaSetValues (button, 266 XmNuserData, i, 266 XmNuserData, i, 267 NULL); 267 NULL); 268 268 269 XtAddCallbacks (button, 269 XtAddCallbacks (button, 270 XmNarmCallback, 270 XmNarmCallback, 271 radio_box_callback); 271 radio_box_callback); 272 } 272 } 273 273 274 XtManageChild (radio_box); 274 XtManageChild (radio_box); 275 275 276 XmStringFree (button_str); 276 XmStringFree (button_str); 277 277 278 for (i = 0; i < num_buttons; i++) { 278 for (i = 0; i < num_buttons; i++) { 279 279 280 delete[] args[i]; 280 delete[] args[i]; 281 281 282 } 282 } 283 283 284 delete[] args; 284 delete[] args; 285 } 285 } 286 286 287 void G4OpenGLXmViewer::Add_set_field (char* w_ 287 void G4OpenGLXmViewer::Add_set_field (char* w_name, 288 char* w_text, 288 char* w_text, 289 Widget* row_col_box, 289 Widget* row_col_box, 290 Widget* wid, 290 Widget* wid, 291 G4double* val, 291 G4double* val, 292 G4OpenGLXmViewer* pView) 292 G4OpenGLXmViewer* pView) 293 { 293 { 294 294 295 char local_w_text[50]; 295 char local_w_text[50]; 296 strcpy (local_w_text, w_text); 296 strcpy (local_w_text, w_text); 297 297 298 char label_name[50]; 298 char label_name[50]; 299 strcpy (label_name, w_name); 299 strcpy (label_name, w_name); 300 strcat (label_name, "_label"); 300 strcat (label_name, "_label"); 301 301 302 char text_field_name[50]; 302 char text_field_name[50]; 303 strcpy (text_field_name, w_name); 303 strcpy (text_field_name, w_name); 304 strcat (text_field_name, "_text_field"); 304 strcat (text_field_name, "_text_field"); 305 305 306 XmString local_text = XmStringCreateLocalize 306 XmString local_text = XmStringCreateLocalized (local_w_text); 307 307 308 // Unused! 308 // Unused! 309 // Widget label = XtVaCreateManagedWidget ( 309 // Widget label = XtVaCreateManagedWidget (label_name, 310 // xmLabelWidgetClass, 310 // xmLabelWidgetClass, 311 // *row_col_box, 311 // *row_col_box, 312 // XmNlabelString, local_text, 312 // XmNlabelString, local_text, 313 // XtNvisual, pView->vi->visual, 313 // XtNvisual, pView->vi->visual, 314 // XtNdepth, pView->vi->depth, 314 // XtNdepth, pView->vi->depth, 315 // XtNcolormap, pView->cmap, 315 // XtNcolormap, pView->cmap, 316 // XtNborderColor, pView->borcol, 316 // XtNborderColor, pView->borcol, 317 // XtNbackground, pView->bgnd, 317 // XtNbackground, pView->bgnd, 318 // NULL); 318 // NULL); 319 319 320 XmStringFree (local_text); 320 XmStringFree (local_text); 321 321 322 char initial[50]; 322 char initial[50]; 323 snprintf (initial, sizeof initial, "%6.2f", << 323 sprintf (initial, "%6.2f", *val); 324 324 325 *wid = XtVaCreateManagedWidget (text_field_n 325 *wid = XtVaCreateManagedWidget (text_field_name, 326 xmTextFieldWidgetClass, 326 xmTextFieldWidgetClass, 327 *row_col_box, 327 *row_col_box, 328 XmNvalue, (String)initial, 328 XmNvalue, (String)initial, 329 XtNvisual, pView->vi->visual, 329 XtNvisual, pView->vi->visual, 330 XtNdepth, pView->vi->depth, 330 XtNdepth, pView->vi->depth, 331 XtNcolormap, pView->cmap, 331 XtNcolormap, pView->cmap, 332 XtNborderColor, pView->borcol, 332 XtNborderColor, pView->borcol, 333 XtNbackground, pView->bgnd, 333 XtNbackground, pView->bgnd, 334 NULL); 334 NULL); 335 335 336 XtAddCallback (*wid, 336 XtAddCallback (*wid, 337 XmNvalueChangedCallback, 337 XmNvalueChangedCallback, 338 get_double_value_callback, 338 get_double_value_callback, 339 val); 339 val); 340 340 341 /* Not actually used - comment out to preven 341 /* Not actually used - comment out to prevent compiler warnings. 342 Instead, just in case it matters, just in 342 Instead, just in case it matters, just invoke 343 XtVaCreateManagedWidget (JA) 343 XtVaCreateManagedWidget (JA) 344 Widget sep = XtVaCreateManagedWidget ("sep", 344 Widget sep = XtVaCreateManagedWidget ("sep", 345 xmSeparatorWidgetClass, 345 xmSeparatorWidgetClass, 346 *row_col_box, 346 *row_col_box, 347 XmNorientation, XmHORIZONTAL, 347 XmNorientation, XmHORIZONTAL, 348 XtNvisual, pView->vi->visual, 348 XtNvisual, pView->vi->visual, 349 XtNdepth, pView->vi->depth, 349 XtNdepth, pView->vi->depth, 350 XtNcolormap, pView->cmap, 350 XtNcolormap, pView->cmap, 351 XtNborderColor, pView->borcol, 351 XtNborderColor, pView->borcol, 352 XtNbackground, pView->bgnd, 352 XtNbackground, pView->bgnd, 353 NULL); 353 NULL); 354 sep = XtVaCreateManagedWidget ("sep", 354 sep = XtVaCreateManagedWidget ("sep", 355 xmSeparatorWidgetClass, 355 xmSeparatorWidgetClass, 356 *row_col_box, 356 *row_col_box, 357 XmNseparatorType, XmNO_LINE, 357 XmNseparatorType, XmNO_LINE, 358 XmNmargin, 1, 358 XmNmargin, 1, 359 XmNorientation, XmHORIZONTAL, 359 XmNorientation, XmHORIZONTAL, 360 XtNvisual, pView->vi->visual, 360 XtNvisual, pView->vi->visual, 361 XtNdepth, pView->vi->depth, 361 XtNdepth, pView->vi->depth, 362 XtNcolormap, pView->cmap, 362 XtNcolormap, pView->cmap, 363 XtNborderColor, pView->borcol, 363 XtNborderColor, pView->borcol, 364 XtNbackground, pView->bgnd, 364 XtNbackground, pView->bgnd, 365 NULL); 365 NULL); 366 */ 366 */ 367 XtVaCreateManagedWidget ("sep", 367 XtVaCreateManagedWidget ("sep", 368 xmSeparatorWidgetClass, 368 xmSeparatorWidgetClass, 369 *row_col_box, 369 *row_col_box, 370 XmNseparatorType, XmNO_LINE, 370 XmNseparatorType, XmNO_LINE, 371 XmNmargin, 1, 371 XmNmargin, 1, 372 XmNorientation, XmHORIZONTAL, 372 XmNorientation, XmHORIZONTAL, 373 XtNvisual, pView->vi->visual, 373 XtNvisual, pView->vi->visual, 374 XtNdepth, pView->vi->depth, 374 XtNdepth, pView->vi->depth, 375 XtNcolormap, pView->cmap, 375 XtNcolormap, pView->cmap, 376 XtNborderColor, pView->borcol, 376 XtNborderColor, pView->borcol, 377 XtNbackground, pView->bgnd, 377 XtNbackground, pView->bgnd, 378 NULL); 378 NULL); 379 } 379 } 380 380 381 void G4OpenGLXmViewer::Add_slider_box (char* l 381 void G4OpenGLXmViewer::Add_slider_box (char* label_string, 382 G4int num_sliders, 382 G4int num_sliders, 383 char** slider_names, 383 char** slider_names, 384 G4OpenGLXmViewer* pView, 384 G4OpenGLXmViewer* pView, 385 G4double* min_array, 385 G4double* min_array, 386 G4double* max_array, 386 G4double* max_array, 387 G4double* value_array, 387 G4double* value_array, 388 G4bool* show, 388 G4bool* show, 389 short* decimals, 389 short* decimals, 390 unsigned char* orientation, 390 unsigned char* orientation, 391 unsigned char* direction, 391 unsigned char* direction, 392 XtCallbackRec** slider_box_callba 392 XtCallbackRec** slider_box_callbacks, 393 Widget* parent_widget) 393 Widget* parent_widget) 394 { 394 { 395 XmString slider_name_str = XmStringCreateLoc << 395 XmString slider_name_str = XmStringCreateLocalized((char*) ""); // ...to 396 // initialise to something to avoid pedantic 396 // initialise to something to avoid pedantic warning. 397 Arg** slider_args; 397 Arg** slider_args; 398 slider_args = new Arg*[num_sliders]; 398 slider_args = new Arg*[num_sliders]; 399 Widget slider; 399 Widget slider; 400 G4int j = 0; 400 G4int j = 0; 401 401 402 G4int i; 402 G4int i; 403 for (i = 0; i < num_sliders; i++) { 403 for (i = 0; i < num_sliders; i++) { 404 j = 0; 404 j = 0; 405 slider_args[i] = new Arg[13]; 405 slider_args[i] = new Arg[13]; 406 slider_name_str = XmStringCreateLtoR (slid 406 slider_name_str = XmStringCreateLtoR (slider_names[i], 407 XmFONTLIST_DEFAULT_TAG); 407 XmFONTLIST_DEFAULT_TAG); 408 408 409 XtSetArg (slider_args[i][j], 409 XtSetArg (slider_args[i][j], 410 XtNvisual, pView->vi->visual); j++; 410 XtNvisual, pView->vi->visual); j++; 411 XtSetArg (slider_args[i][j], 411 XtSetArg (slider_args[i][j], 412 XtNdepth, pView->vi->depth); j++; 412 XtNdepth, pView->vi->depth); j++; 413 XtSetArg (slider_args[i][j], 413 XtSetArg (slider_args[i][j], 414 XtNcolormap, pView->cmap); j++; 414 XtNcolormap, pView->cmap); j++; 415 XtSetArg (slider_args[i][j], 415 XtSetArg (slider_args[i][j], 416 XtNborderColor, pView->borcol); j++; 416 XtNborderColor, pView->borcol); j++; 417 XtSetArg (slider_args[i][j], 417 XtSetArg (slider_args[i][j], 418 XtNbackground, pView->bgnd); j++; 418 XtNbackground, pView->bgnd); j++; 419 419 420 XtSetArg (slider_args[i][j], 420 XtSetArg (slider_args[i][j], 421 XmNtitleString, slider_name_str); j++ 421 XmNtitleString, slider_name_str); j++; 422 422 423 XtSetArg (slider_args[i][j], 423 XtSetArg (slider_args[i][j], 424 XmNmaximum, G4int(max_array[i] * std:: 424 XmNmaximum, G4int(max_array[i] * std::pow(10.0, (G4double)decimals[i]))); j++; 425 XtSetArg (slider_args[i][j], 425 XtSetArg (slider_args[i][j], 426 XmNminimum, G4int(min_array[i] * std:: 426 XmNminimum, G4int(min_array[i] * std::pow(10.0, (G4double)decimals[i]))); j++; 427 XtSetArg (slider_args[i][j], 427 XtSetArg (slider_args[i][j], 428 XmNvalue, G4int(value_array[i] * std:: 428 XmNvalue, G4int(value_array[i] * std::pow(10.0, (G4double)decimals[i]))); j++; 429 XtSetArg (slider_args[i][j], 429 XtSetArg (slider_args[i][j], 430 XmNshowValue, show[i]); j++; 430 XmNshowValue, show[i]); j++; 431 XtSetArg (slider_args[i][j], 431 XtSetArg (slider_args[i][j], 432 XmNdecimalPoints, decimals[i]); j++; 432 XmNdecimalPoints, decimals[i]); j++; 433 433 434 XtSetArg (slider_args[i][j], 434 XtSetArg (slider_args[i][j], 435 XmNorientation, orientation[i]); j++; 435 XmNorientation, orientation[i]); j++; 436 XtSetArg (slider_args[i][j], 436 XtSetArg (slider_args[i][j], 437 XmNprocessingDirection, direction[i]); 437 XmNprocessingDirection, direction[i]); j++; 438 438 439 } 439 } 440 440 441 Widget slider_box = XtVaCreateWidget ("slide 441 Widget slider_box = XtVaCreateWidget ("slider_box", 442 xmRowColumnWidgetClass, 442 xmRowColumnWidgetClass, 443 *parent_widget, 443 *parent_widget, 444 XmNisHomogeneous, False, 444 XmNisHomogeneous, False, 445 XtNvisual, pView->vi->visual, 445 XtNvisual, pView->vi->visual, 446 XtNdepth, pView->vi->depth, 446 XtNdepth, pView->vi->depth, 447 XtNcolormap, pView->cmap, 447 XtNcolormap, pView->cmap, 448 XtNborderColor, pView->borcol, 448 XtNborderColor, pView->borcol, 449 XtNbackground, pView->bgnd, 449 XtNbackground, pView->bgnd, 450 NULL); 450 NULL); 451 451 452 XmString lab = XmStringCreateLocalized (labe 452 XmString lab = XmStringCreateLocalized (label_string); 453 453 454 // Unused! 454 // Unused! 455 //Widget label = XtVaCreateManagedWidget ("s 455 //Widget label = XtVaCreateManagedWidget ("slider_label", 456 // xmLabelWidgetClass, 456 // xmLabelWidgetClass, 457 // slider_box, 457 // slider_box, 458 // XmNlabelString, lab, 458 // XmNlabelString, lab, 459 // XmNalignment, XmALIGNMENT_CENTER 459 // XmNalignment, XmALIGNMENT_CENTER, 460 // XtNvisual, pView->vi->visual, 460 // XtNvisual, pView->vi->visual, 461 // XtNdepth, pView->vi->depth, 461 // XtNdepth, pView->vi->depth, 462 // XtNcolormap, pView->cmap, 462 // XtNcolormap, pView->cmap, 463 // XtNborderColor, pView->borcol, 463 // XtNborderColor, pView->borcol, 464 // XtNbackground, pView->bgnd, 464 // XtNbackground, pView->bgnd, 465 // NULL); 465 // NULL); 466 466 467 XmStringFree (lab); 467 XmStringFree (lab); 468 468 469 for (i = 0; i < num_sliders; i++) { 469 for (i = 0; i < num_sliders; i++) { 470 470 471 slider = XtCreateManagedWidget (slider_nam 471 slider = XtCreateManagedWidget (slider_names[i], 472 xmScaleWidgetClass, 472 xmScaleWidgetClass, 473 slider_box, 473 slider_box, 474 slider_args[i], 474 slider_args[i], 475 j); 475 j); 476 476 477 XtAddCallbacks (slider, 477 XtAddCallbacks (slider, 478 XmNvalueChangedCallback, 478 XmNvalueChangedCallback, 479 slider_box_callbacks[i]); 479 slider_box_callbacks[i]); 480 480 481 XtAddCallbacks (slider, 481 XtAddCallbacks (slider, 482 XmNdragCallback, 482 XmNdragCallback, 483 slider_box_callbacks[i]); 483 slider_box_callbacks[i]); 484 484 485 } 485 } 486 486 487 XtManageChild (slider_box); 487 XtManageChild (slider_box); 488 XmStringFree (slider_name_str); 488 XmStringFree (slider_name_str); 489 489 490 for (i = 0; i < num_sliders; i++) { 490 for (i = 0; i < num_sliders; i++) { 491 491 492 delete[] slider_args[i]; 492 delete[] slider_args[i]; 493 493 494 } 494 } 495 495 496 delete[] slider_args; 496 delete[] slider_args; 497 497 498 } 498 } 499 499 500 void G4OpenGLXmViewer::get_double_value_callba 500 void G4OpenGLXmViewer::get_double_value_callback (Widget w, 501 XtPointer clientData, 501 XtPointer clientData, 502 XtPointer) 502 XtPointer) 503 { 503 { 504 G4double* val = (G4double*) clientData; 504 G4double* val = (G4double*) clientData; 505 String string; 505 String string; 506 506 507 XtVaGetValues (w, 507 XtVaGetValues (w, 508 XmNvalue, &string, 508 XmNvalue, &string, 509 NULL); 509 NULL); 510 510 511 // sscanf (string, "%lg", val); 511 // sscanf (string, "%lg", val); 512 std::istringstream iss(string); 512 std::istringstream iss(string); 513 iss >> *val; 513 iss >> *val; 514 } 514 } 515 515 516 void G4OpenGLXmViewer::get_text_callback (Widg 516 void G4OpenGLXmViewer::get_text_callback (Widget w, 517 XtPointer clientData, 517 XtPointer clientData, 518 XtPointer) 518 XtPointer) 519 { 519 { 520 char* txt = (char*)clientData; 520 char* txt = (char*)clientData; 521 String string; 521 String string; 522 522 523 XtVaGetValues (w, 523 XtVaGetValues (w, 524 XmNvalue, &string, 524 XmNvalue, &string, 525 NULL); 525 NULL); 526 526 527 strcpy(txt, string); 527 strcpy(txt, string); 528 } 528 } 529 529 530 G4bool G4OpenGLXmViewer::get_boolean_userData 530 G4bool G4OpenGLXmViewer::get_boolean_userData (Widget w) 531 { 531 { 532 XtPointer userData; 532 XtPointer userData; 533 XtVaGetValues (w,XmNuserData,&userData,NULL) 533 XtVaGetValues (w,XmNuserData,&userData,NULL); 534 return (G4bool)(((unsigned long)userData)&0x 534 return (G4bool)(((unsigned long)userData)&0xffff); 535 } 535 } 536 536 537 G4int G4OpenGLXmViewer::get_int_userData (Widg 537 G4int G4OpenGLXmViewer::get_int_userData (Widget w) 538 { 538 { 539 XtPointer userData; 539 XtPointer userData; 540 XtVaGetValues (w,XmNuserData,&userData,NULL) 540 XtVaGetValues (w,XmNuserData,&userData,NULL); 541 return (G4int)(unsigned long)userData; 541 return (G4int)(unsigned long)userData; 542 } 542 } 543 543