Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpenGLXmSliderBar.cc
이 파일의 문서화 페이지로 가기
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 68043 2013-03-13 14:27:49Z gcosmo $
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 : sliderbar(0)
50 , parent(0)
51 {
52  name = n;
53  callback = c;
54  show = sh;
55  decimal_places = dp;
56  initial_value = int(v * std::pow(10.0, (G4double)dp));
57  max_value = int(max * std::pow(10.0, (G4double)dp));
58  min_value = int(min * std::pow(10.0, (G4double)dp));
59  orientation = o;
60  direction = d;
61 }
62 
63 G4OpenGLXmSliderBar::~G4OpenGLXmSliderBar ()
64 {}
65 
66 const char* G4OpenGLXmSliderBar::GetName ()
67 {
68  return name;
69 }
70 
71 G4bool G4OpenGLXmSliderBar::GetShow ()
72 {
73  return show;
74 }
75 
76 short G4OpenGLXmSliderBar::GetDecimalPlaces ()
77 {
78  return decimal_places;
79 }
80 
81 G4double G4OpenGLXmSliderBar::GetInitialValue ()
82 {
83  return (G4double)initial_value / std::pow(10.0, (G4double)GetDecimalPlaces());
84 }
85 
86 G4double G4OpenGLXmSliderBar::GetMaxValue ()
87 {
88  return (G4double)max_value / std::pow(10.0, (G4double)GetDecimalPlaces());
89 }
90 
91 G4double G4OpenGLXmSliderBar::GetMinValue ()
92 {
93  return (G4double)min_value / std::pow(10.0, (G4double)GetDecimalPlaces());
94 }
95 
96 unsigned char G4OpenGLXmSliderBar::GetOrientation ()
97 {
98  return orientation;
99 }
100 
101 unsigned char G4OpenGLXmSliderBar::GetDirection ()
102 {
103  return direction;
104 }
105 
106 void G4OpenGLXmSliderBar::SetName (const char* n)
107 {
108  name = n;
109  XmString sliderbar_string = XmStringCreateLocalized ((char*)name);
110  XtVaSetValues (sliderbar,
111  XmNlabelString, sliderbar_string,
112  NULL);
113  XmStringFree (sliderbar_string);
114 }
115 
116 void G4OpenGLXmSliderBar::SetShow (G4bool sh)
117 {
118  show = sh;
119  XtVaSetValues (sliderbar,
120  XmNshowValue, show,
121  NULL);
122 
123 }
124 
125 void G4OpenGLXmSliderBar::SetDecimalPlaces (short dp)
126 {
127  decimal_places = dp;
128  XtVaSetValues (sliderbar,
129  XmNdecimalPoints, decimal_places,
130  NULL);
131 
132 }
133 
134 void G4OpenGLXmSliderBar::SetInitialValue (G4double v)
135 {
136  initial_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
137  XtVaSetValues (sliderbar,
138  XmNvalue, initial_value,
139  NULL);
140 
141 }
142 
143 void G4OpenGLXmSliderBar::SetMaxValue (G4double v)
144 {
145  max_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
146  XtVaSetValues (sliderbar,
147  XmNmaximum, max_value,
148  NULL);
149 
150 }
151 
152 void G4OpenGLXmSliderBar::SetMinValue (G4double v)
153 {
154  min_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
155  XtVaSetValues (sliderbar,
156  XmNminimum, min_value,
157  NULL);
158 
159 }
160 
161 void G4OpenGLXmSliderBar::SetOrientation (unsigned char o)
162 {
163  orientation = o;
164  XtVaSetValues (sliderbar,
165  XmNorientation, orientation,
166  NULL);
167 
168 }
169 
170 void G4OpenGLXmSliderBar::SetDirection (unsigned char d)
171 {
172  direction = d;
173  XtVaSetValues (sliderbar,
174  XmNprocessingDirection, direction,
175  NULL);
176 
177 }
178 
179 void G4OpenGLXmSliderBar::AddYourselfTo (G4OpenGLXmVWidgetContainer* container)
180 {
181 
182  pView = container->GetView ();
183  ProcesspView ();
184 
185  parent = container->GetPointerToWidget ();
186  XmString name_string = XmStringCreateLocalized ((char*)name);
187  sliderbar = XtVaCreateManagedWidget (name,
188  xmScaleWidgetClass,
189  *parent,
190 
191  XmNtitleString, name_string,
192  XmNmaximum, max_value,
193  XmNminimum, min_value,
194  XmNvalue, initial_value,
195  XmNshowValue, show,
196  XmNdecimalPoints, decimal_places,
197  XmNorientation, orientation,
198  XmNprocessingDirection, direction,
199 
200  XtNvisual, visual,
201  XtNdepth, depth,
202  XtNcolormap, cmap,
203  XtNborderColor, borcol,
204  XtNbackground, bgnd,
205 
206  NULL);
207 
208  XtAddCallbacks (sliderbar,
209  XmNvalueChangedCallback,
210  callback);
211 
212  XtAddCallbacks (sliderbar,
213  XmNdragCallback,
214  callback);
215  XmStringFree (name_string);
216 }
217 
218 Widget* G4OpenGLXmSliderBar::GetPointerToParent ()
219 {
220  return parent;
221 }
222 
223 Widget* G4OpenGLXmSliderBar::GetPointerToWidget ()
224 {
225  return &sliderbar;
226 }
227 
228 #endif
T max(const T t1, const T t2)
brief Return the largest of the two arguments
const XML_Char * name
Definition: expat.h:151
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
Float_t d
Char_t n[5]
T min(const T t1, const T t2)
brief Return the smallest of the two arguments