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