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