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