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