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[ 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/G4OpenGLXmSliderBar.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLXmSliderBar.cc (Version 10.1.p1)


  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: G4OpenGLXmSliderBar.cc 68043 2013-03-13 14:27:49Z gcosmo $
 27 //                                                 28 //
 28 //Slider bar class. Inherits from G4OpenGLXmVW     29 //Slider bar class. Inherits from G4OpenGLXmVWidgetComponent
 29                                                    30 
                                                   >>  31 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
                                                   >>  32 
 30 #include "G4OpenGLXmVWidgetComponent.hh"           33 #include "G4OpenGLXmVWidgetComponent.hh"
 31 #include "G4OpenGLXmVWidgetContainer.hh"           34 #include "G4OpenGLXmVWidgetContainer.hh"
 32 #include "G4OpenGLXmSliderBar.hh"                  35 #include "G4OpenGLXmSliderBar.hh"
 33 #include <X11/Intrinsic.h>                         36 #include <X11/Intrinsic.h>
 34 #include <Xm/Scale.h>                              37 #include <Xm/Scale.h>
 35 #include "globals.hh"                              38 #include "globals.hh"
 36                                                    39 
 37 G4OpenGLXmSliderBar::G4OpenGLXmSliderBar (cons     40 G4OpenGLXmSliderBar::G4OpenGLXmSliderBar (const char* n,
 38             XtCallbackRec* c,                      41             XtCallbackRec* c,
 39             G4bool sh,                             42             G4bool sh,
 40             short dp,                              43             short dp,
 41             G4double v,                            44             G4double v,
 42             G4double max,                          45             G4double max,
 43             G4double min,                          46             G4double min,
 44             unsigned char o,                       47             unsigned char o,
 45             unsigned char d)                       48             unsigned char d) 
 46 : sliderbar(0)                                     49 : sliderbar(0)
 47 , parent(0)                                        50 , parent(0)
 48 {                                                  51 {
 49   name = n;                                        52   name = n;
 50   callback = c;                                    53   callback = c;
 51   show = sh;                                       54   show = sh;
 52   decimal_places = dp;                             55   decimal_places = dp;
 53   initial_value = int(v * std::pow(10.0, (G4do     56   initial_value = int(v * std::pow(10.0, (G4double)dp));
 54   max_value = int(max * std::pow(10.0, (G4doub     57   max_value = int(max * std::pow(10.0, (G4double)dp));
 55   min_value = int(min * std::pow(10.0, (G4doub     58   min_value = int(min * std::pow(10.0, (G4double)dp));
 56   orientation = o;                                 59   orientation = o;
 57   direction = d;                                   60   direction = d;
 58 }                                                  61 }
 59                                                    62 
 60 G4OpenGLXmSliderBar::~G4OpenGLXmSliderBar ()       63 G4OpenGLXmSliderBar::~G4OpenGLXmSliderBar ()
 61 {}                                                 64 {}
 62                                                    65 
 63 const char* G4OpenGLXmSliderBar::GetName ()        66 const char* G4OpenGLXmSliderBar::GetName () 
 64 {                                                  67 {
 65   return name;                                     68   return name;
 66 }                                                  69 }
 67                                                    70 
 68 G4bool G4OpenGLXmSliderBar::GetShow ()             71 G4bool G4OpenGLXmSliderBar::GetShow () 
 69 {                                                  72 {
 70   return show;                                     73   return show;
 71 }                                                  74 }
 72                                                    75 
 73 short G4OpenGLXmSliderBar::GetDecimalPlaces ()     76 short G4OpenGLXmSliderBar::GetDecimalPlaces () 
 74 {                                                  77 {
 75   return decimal_places;                           78   return decimal_places;
 76 }                                                  79 }
 77                                                    80 
 78 G4double G4OpenGLXmSliderBar::GetInitialValue      81 G4double G4OpenGLXmSliderBar::GetInitialValue () 
 79 {                                                  82 {
 80   return (G4double)initial_value / std::pow(10     83   return (G4double)initial_value / std::pow(10.0, (G4double)GetDecimalPlaces());
 81 }                                                  84 }
 82                                                    85 
 83 G4double G4OpenGLXmSliderBar::GetMaxValue ()       86 G4double G4OpenGLXmSliderBar::GetMaxValue () 
 84 {                                                  87 {
 85   return (G4double)max_value / std::pow(10.0,      88   return (G4double)max_value / std::pow(10.0, (G4double)GetDecimalPlaces());
 86 }                                                  89 }
 87                                                    90 
 88 G4double G4OpenGLXmSliderBar::GetMinValue ()       91 G4double G4OpenGLXmSliderBar::GetMinValue () 
 89 {                                                  92 {
 90   return (G4double)min_value / std::pow(10.0,      93   return (G4double)min_value / std::pow(10.0, (G4double)GetDecimalPlaces());
 91 }                                                  94 }
 92                                                    95 
 93 unsigned char G4OpenGLXmSliderBar::GetOrientat     96 unsigned char G4OpenGLXmSliderBar::GetOrientation () 
 94 {                                                  97 {
 95   return orientation;                              98   return orientation;
 96 }                                                  99 }
 97                                                   100 
 98 unsigned char G4OpenGLXmSliderBar::GetDirectio    101 unsigned char G4OpenGLXmSliderBar::GetDirection () 
 99 {                                                 102 {
100   return direction;                               103   return direction;
101 }                                                 104 }
102                                                   105 
103 void G4OpenGLXmSliderBar::SetName (const char*    106 void G4OpenGLXmSliderBar::SetName (const char* n) 
104 {                                                 107 {
105   name = n;                                       108   name = n;
106   XmString sliderbar_string = XmStringCreateLo    109   XmString sliderbar_string = XmStringCreateLocalized ((char*)name);
107   XtVaSetValues (sliderbar,                       110   XtVaSetValues (sliderbar,
108      XmNlabelString, sliderbar_string,            111      XmNlabelString, sliderbar_string,
109      NULL);                                       112      NULL);
110  XmStringFree (sliderbar_string);                 113  XmStringFree (sliderbar_string);
111 }                                                 114 }
112                                                   115 
113 void G4OpenGLXmSliderBar::SetShow (G4bool sh)     116 void G4OpenGLXmSliderBar::SetShow (G4bool sh) 
114 {                                                 117 {
115   show = sh;                                      118   show = sh;
116   XtVaSetValues (sliderbar,                       119   XtVaSetValues (sliderbar,
117      XmNshowValue, show,                          120      XmNshowValue, show,
118      NULL);                                       121      NULL);
119                                                   122   
120 }                                                 123 }
121                                                   124 
122 void G4OpenGLXmSliderBar::SetDecimalPlaces (sh    125 void G4OpenGLXmSliderBar::SetDecimalPlaces (short dp) 
123 {                                                 126 {
124   decimal_places = dp;                            127   decimal_places = dp;
125   XtVaSetValues (sliderbar,                       128   XtVaSetValues (sliderbar,
126      XmNdecimalPoints, decimal_places,            129      XmNdecimalPoints, decimal_places,
127      NULL);                                       130      NULL);
128                                                   131   
129 }                                                 132 }
130                                                   133 
131 void G4OpenGLXmSliderBar::SetInitialValue (G4d    134 void G4OpenGLXmSliderBar::SetInitialValue (G4double v) 
132 {                                                 135 {
133   initial_value = int(v * std::pow(10.0, (G4do    136   initial_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
134   XtVaSetValues (sliderbar,                       137   XtVaSetValues (sliderbar,
135      XmNvalue, initial_value,                     138      XmNvalue, initial_value,
136      NULL);                                       139      NULL);
137                                                   140   
138 }                                                 141 }
139                                                   142 
140 void G4OpenGLXmSliderBar::SetMaxValue (G4doubl    143 void G4OpenGLXmSliderBar::SetMaxValue (G4double v) 
141 {                                                 144 {
142   max_value = int(v * std::pow(10.0, (G4double    145   max_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
143   XtVaSetValues (sliderbar,                       146   XtVaSetValues (sliderbar,
144      XmNmaximum, max_value,                       147      XmNmaximum, max_value,
145      NULL);                                       148      NULL);
146                                                   149   
147 }                                                 150 }
148                                                   151 
149 void G4OpenGLXmSliderBar::SetMinValue (G4doubl    152 void G4OpenGLXmSliderBar::SetMinValue (G4double v) 
150 {                                                 153 {
151   min_value = int(v * std::pow(10.0, (G4double    154   min_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
152   XtVaSetValues (sliderbar,                       155   XtVaSetValues (sliderbar,
153      XmNminimum, min_value,                       156      XmNminimum, min_value,
154      NULL);                                       157      NULL);
155                                                   158   
156 }                                                 159 }
157                                                   160 
158 void G4OpenGLXmSliderBar::SetOrientation (unsi    161 void G4OpenGLXmSliderBar::SetOrientation (unsigned char o) 
159 {                                                 162 {
160   orientation = o;                                163   orientation = o;
161   XtVaSetValues (sliderbar,                       164   XtVaSetValues (sliderbar,
162      XmNorientation, orientation,                 165      XmNorientation, orientation,
163      NULL);                                       166      NULL);
164                                                   167   
165 }                                                 168 }
166                                                   169 
167 void G4OpenGLXmSliderBar::SetDirection (unsign    170 void G4OpenGLXmSliderBar::SetDirection (unsigned char d) 
168 {                                                 171 {
169   direction = d;                                  172   direction = d;
170   XtVaSetValues (sliderbar,                       173   XtVaSetValues (sliderbar,
171      XmNprocessingDirection, direction,           174      XmNprocessingDirection, direction,
172      NULL);                                       175      NULL);
173                                                   176   
174 }                                                 177 }
175                                                   178 
176 void G4OpenGLXmSliderBar::AddYourselfTo (G4Ope    179 void G4OpenGLXmSliderBar::AddYourselfTo (G4OpenGLXmVWidgetContainer* container)
177 {                                                 180 {
178                                                   181 
179   pView = container->GetView ();                  182   pView = container->GetView ();
180   ProcesspView ();                                183   ProcesspView ();
181                                                   184 
182   parent = container->GetPointerToWidget ();      185   parent = container->GetPointerToWidget ();
183   XmString name_string = XmStringCreateLocaliz    186   XmString name_string = XmStringCreateLocalized ((char*)name);
184   sliderbar = XtVaCreateManagedWidget (name,      187   sliderbar = XtVaCreateManagedWidget (name,
185                xmScaleWidgetClass,                188                xmScaleWidgetClass,
186                *parent,                           189                *parent,
187                                                   190                
188                XmNtitleString, name_string,       191                XmNtitleString, name_string,
189                XmNmaximum, max_value,             192                XmNmaximum, max_value,
190                XmNminimum, min_value,             193                XmNminimum, min_value,
191                XmNvalue, initial_value,           194                XmNvalue, initial_value,
192                XmNshowValue, show,                195                XmNshowValue, show,
193                XmNdecimalPoints, decimal_place    196                XmNdecimalPoints, decimal_places,
194                XmNorientation, orientation,       197                XmNorientation, orientation,
195                XmNprocessingDirection, directi    198                XmNprocessingDirection, direction,
196                                                   199   
197                XtNvisual, visual,                 200                XtNvisual, visual,
198                XtNdepth, depth,                   201                XtNdepth, depth,
199                XtNcolormap, cmap,                 202                XtNcolormap, cmap,
200                XtNborderColor, borcol,            203                XtNborderColor, borcol,
201                XtNbackground, bgnd,               204                XtNbackground, bgnd,
202                                                   205 
203                NULL);                             206                NULL);
204                                                   207                
205   XtAddCallbacks (sliderbar,                      208   XtAddCallbacks (sliderbar,
206       XmNvalueChangedCallback,                    209       XmNvalueChangedCallback,
207       callback);                                  210       callback);
208                                                   211 
209   XtAddCallbacks (sliderbar,                      212   XtAddCallbacks (sliderbar,
210       XmNdragCallback,                            213       XmNdragCallback,
211       callback);                                  214       callback);
212   XmStringFree (name_string);                     215   XmStringFree (name_string);
213 }                                                 216 }
214                                                   217 
215 Widget* G4OpenGLXmSliderBar::GetPointerToParen    218 Widget* G4OpenGLXmSliderBar::GetPointerToParent ()
216 {                                                 219 {
217   return parent;                                  220   return parent;
218 }                                                 221 }
219                                                   222 
220 Widget* G4OpenGLXmSliderBar::GetPointerToWidge    223 Widget* G4OpenGLXmSliderBar::GetPointerToWidget () 
221 {                                                 224 {
222   return &sliderbar;                              225   return &sliderbar;
223 }                                                 226 }
                                                   >> 227 
                                                   >> 228 #endif
224                                                   229