source: trunk/source/visualization/OpenGL/src/G4OpenGLXmSliderBar.cc @ 1047

Last change on this file since 1047 was 1046, checked in by garnier, 15 years ago

update

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