Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenGL/src/G4OpenGLXmConvenienceRoutines.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenGL/src/G4OpenGLXmConvenienceRoutines.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLXmConvenienceRoutines.cc (Version 9.4)


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