Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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//
28//Slider bar class. Inherits from G4OpenGLXmVWidgetComponent
29
30#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
31
35#include <X11/Intrinsic.h>
36#include <Xm/Scale.h>
37#include "globals.hh"
38
39G4OpenGLXmSliderBar::G4OpenGLXmSliderBar (const char* n,
40 XtCallbackRec* c,
41 G4bool sh,
42 short dp,
43 G4double v,
44 G4double max,
45 G4double min,
46 unsigned char o,
47 unsigned char d)
48: sliderbar(0)
49, parent(0)
50{
51 name = n;
52 callback = c;
53 show = sh;
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
62G4OpenGLXmSliderBar::~G4OpenGLXmSliderBar ()
63{}
64
65const char* G4OpenGLXmSliderBar::GetName ()
66{
67 return name;
68}
69
70G4bool G4OpenGLXmSliderBar::GetShow ()
71{
72 return show;
73}
74
75short G4OpenGLXmSliderBar::GetDecimalPlaces ()
76{
77 return decimal_places;
78}
79
80G4double G4OpenGLXmSliderBar::GetInitialValue ()
81{
82 return (G4double)initial_value / std::pow(10.0, (G4double)GetDecimalPlaces());
83}
84
85G4double G4OpenGLXmSliderBar::GetMaxValue ()
86{
87 return (G4double)max_value / std::pow(10.0, (G4double)GetDecimalPlaces());
88}
89
90G4double G4OpenGLXmSliderBar::GetMinValue ()
91{
92 return (G4double)min_value / std::pow(10.0, (G4double)GetDecimalPlaces());
93}
94
95unsigned char G4OpenGLXmSliderBar::GetOrientation ()
96{
97 return orientation;
98}
99
100unsigned char G4OpenGLXmSliderBar::GetDirection ()
101{
102 return direction;
103}
104
105void 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
115void G4OpenGLXmSliderBar::SetShow (G4bool sh)
116{
117 show = sh;
118 XtVaSetValues (sliderbar,
119 XmNshowValue, show,
120 NULL);
121
122}
123
124void G4OpenGLXmSliderBar::SetDecimalPlaces (short dp)
125{
126 decimal_places = dp;
127 XtVaSetValues (sliderbar,
128 XmNdecimalPoints, decimal_places,
129 NULL);
130
131}
132
133void 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
142void 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
151void 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
160void G4OpenGLXmSliderBar::SetOrientation (unsigned char o)
161{
162 orientation = o;
163 XtVaSetValues (sliderbar,
164 XmNorientation, orientation,
165 NULL);
166
167}
168
169void G4OpenGLXmSliderBar::SetDirection (unsigned char d)
170{
171 direction = d;
172 XtVaSetValues (sliderbar,
173 XmNprocessingDirection, direction,
174 NULL);
175
176}
177
178void 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
217Widget* G4OpenGLXmSliderBar::GetPointerToParent ()
218{
219 return parent;
220}
221
222Widget* G4OpenGLXmSliderBar::GetPointerToWidget ()
223{
224 return &sliderbar;
225}
226
227#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
const char * name(G4int ptype)