Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // 28 //Slider bar class. Inherits from G4OpenGLXmVW 29 30 #include "G4OpenGLXmVWidgetComponent.hh" 31 #include "G4OpenGLXmVWidgetContainer.hh" 32 #include "G4OpenGLXmSliderBar.hh" 33 #include <X11/Intrinsic.h> 34 #include <Xm/Scale.h> 35 #include "globals.hh" 36 37 G4OpenGLXmSliderBar::G4OpenGLXmSliderBar (cons 38 XtCallbackRec* c, 39 G4bool sh, 40 short dp, 41 G4double v, 42 G4double max, 43 G4double min, 44 unsigned char o, 45 unsigned char d) 46 : sliderbar(0) 47 , parent(0) 48 { 49 name = n; 50 callback = c; 51 show = sh; 52 decimal_places = dp; 53 initial_value = int(v * std::pow(10.0, (G4do 54 max_value = int(max * std::pow(10.0, (G4doub 55 min_value = int(min * std::pow(10.0, (G4doub 56 orientation = o; 57 direction = d; 58 } 59 60 G4OpenGLXmSliderBar::~G4OpenGLXmSliderBar () 61 {} 62 63 const char* G4OpenGLXmSliderBar::GetName () 64 { 65 return name; 66 } 67 68 G4bool G4OpenGLXmSliderBar::GetShow () 69 { 70 return show; 71 } 72 73 short G4OpenGLXmSliderBar::GetDecimalPlaces () 74 { 75 return decimal_places; 76 } 77 78 G4double G4OpenGLXmSliderBar::GetInitialValue 79 { 80 return (G4double)initial_value / std::pow(10 81 } 82 83 G4double G4OpenGLXmSliderBar::GetMaxValue () 84 { 85 return (G4double)max_value / std::pow(10.0, 86 } 87 88 G4double G4OpenGLXmSliderBar::GetMinValue () 89 { 90 return (G4double)min_value / std::pow(10.0, 91 } 92 93 unsigned char G4OpenGLXmSliderBar::GetOrientat 94 { 95 return orientation; 96 } 97 98 unsigned char G4OpenGLXmSliderBar::GetDirectio 99 { 100 return direction; 101 } 102 103 void G4OpenGLXmSliderBar::SetName (const char* 104 { 105 name = n; 106 XmString sliderbar_string = XmStringCreateLo 107 XtVaSetValues (sliderbar, 108 XmNlabelString, sliderbar_string, 109 NULL); 110 XmStringFree (sliderbar_string); 111 } 112 113 void G4OpenGLXmSliderBar::SetShow (G4bool sh) 114 { 115 show = sh; 116 XtVaSetValues (sliderbar, 117 XmNshowValue, show, 118 NULL); 119 120 } 121 122 void G4OpenGLXmSliderBar::SetDecimalPlaces (sh 123 { 124 decimal_places = dp; 125 XtVaSetValues (sliderbar, 126 XmNdecimalPoints, decimal_places, 127 NULL); 128 129 } 130 131 void G4OpenGLXmSliderBar::SetInitialValue (G4d 132 { 133 initial_value = int(v * std::pow(10.0, (G4do 134 XtVaSetValues (sliderbar, 135 XmNvalue, initial_value, 136 NULL); 137 138 } 139 140 void G4OpenGLXmSliderBar::SetMaxValue (G4doubl 141 { 142 max_value = int(v * std::pow(10.0, (G4double 143 XtVaSetValues (sliderbar, 144 XmNmaximum, max_value, 145 NULL); 146 147 } 148 149 void G4OpenGLXmSliderBar::SetMinValue (G4doubl 150 { 151 min_value = int(v * std::pow(10.0, (G4double 152 XtVaSetValues (sliderbar, 153 XmNminimum, min_value, 154 NULL); 155 156 } 157 158 void G4OpenGLXmSliderBar::SetOrientation (unsi 159 { 160 orientation = o; 161 XtVaSetValues (sliderbar, 162 XmNorientation, orientation, 163 NULL); 164 165 } 166 167 void G4OpenGLXmSliderBar::SetDirection (unsign 168 { 169 direction = d; 170 XtVaSetValues (sliderbar, 171 XmNprocessingDirection, direction, 172 NULL); 173 174 } 175 176 void G4OpenGLXmSliderBar::AddYourselfTo (G4Ope 177 { 178 179 pView = container->GetView (); 180 ProcesspView (); 181 182 parent = container->GetPointerToWidget (); 183 XmString name_string = XmStringCreateLocaliz 184 sliderbar = XtVaCreateManagedWidget (name, 185 xmScaleWidgetClass, 186 *parent, 187 188 XmNtitleString, name_string, 189 XmNmaximum, max_value, 190 XmNminimum, min_value, 191 XmNvalue, initial_value, 192 XmNshowValue, show, 193 XmNdecimalPoints, decimal_place 194 XmNorientation, orientation, 195 XmNprocessingDirection, directi 196 197 XtNvisual, visual, 198 XtNdepth, depth, 199 XtNcolormap, cmap, 200 XtNborderColor, borcol, 201 XtNbackground, bgnd, 202 203 NULL); 204 205 XtAddCallbacks (sliderbar, 206 XmNvalueChangedCallback, 207 callback); 208 209 XtAddCallbacks (sliderbar, 210 XmNdragCallback, 211 callback); 212 XmStringFree (name_string); 213 } 214 215 Widget* G4OpenGLXmSliderBar::GetPointerToParen 216 { 217 return parent; 218 } 219 220 Widget* G4OpenGLXmSliderBar::GetPointerToWidge 221 { 222 return &sliderbar; 223 } 224