G4OpenGLXmSliderBar.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //Slider bar class. Inherits from G4OpenGLXmVWidgetComponent
00030 
00031 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
00032 
00033 #include "G4OpenGLXmVWidgetComponent.hh"
00034 #include "G4OpenGLXmVWidgetContainer.hh"
00035 #include "G4OpenGLXmSliderBar.hh"
00036 #include <X11/Intrinsic.h>
00037 #include <Xm/Scale.h>
00038 #include "globals.hh"
00039 
00040 G4OpenGLXmSliderBar::G4OpenGLXmSliderBar (const char* n,
00041                                           XtCallbackRec* c,
00042                                           G4bool sh,
00043                                           short dp,
00044                                           G4double v,
00045                                           G4double max,
00046                                           G4double min,
00047                                           unsigned char o,
00048                                           unsigned char d) 
00049 {
00050   name = n;
00051   callback = c;
00052   show = sh;
00053   decimal_places = dp;
00054   initial_value = int(v * std::pow(10.0, (G4double)dp));
00055   max_value = int(max * std::pow(10.0, (G4double)dp));
00056   min_value = int(min * std::pow(10.0, (G4double)dp));
00057   orientation = o;
00058   direction = d;
00059 }
00060 
00061 G4OpenGLXmSliderBar::~G4OpenGLXmSliderBar ()
00062 {}
00063 
00064 const char* G4OpenGLXmSliderBar::GetName () 
00065 {
00066   return name;
00067 }
00068 
00069 G4bool G4OpenGLXmSliderBar::GetShow () 
00070 {
00071   return show;
00072 }
00073 
00074 short G4OpenGLXmSliderBar::GetDecimalPlaces () 
00075 {
00076   return decimal_places;
00077 }
00078 
00079 G4double G4OpenGLXmSliderBar::GetInitialValue () 
00080 {
00081   return (G4double)initial_value / std::pow(10.0, (G4double)GetDecimalPlaces());
00082 }
00083 
00084 G4double G4OpenGLXmSliderBar::GetMaxValue () 
00085 {
00086   return (G4double)max_value / std::pow(10.0, (G4double)GetDecimalPlaces());
00087 }
00088 
00089 G4double G4OpenGLXmSliderBar::GetMinValue () 
00090 {
00091   return (G4double)min_value / std::pow(10.0, (G4double)GetDecimalPlaces());
00092 }
00093 
00094 unsigned char G4OpenGLXmSliderBar::GetOrientation () 
00095 {
00096   return orientation;
00097 }
00098 
00099 unsigned char G4OpenGLXmSliderBar::GetDirection () 
00100 {
00101   return direction;
00102 }
00103 
00104 void G4OpenGLXmSliderBar::SetName (const char* n) 
00105 {
00106   name = n;
00107   XmString sliderbar_string = XmStringCreateLocalized ((char*)name);
00108   XtVaSetValues (sliderbar,
00109                  XmNlabelString, sliderbar_string,
00110                  NULL);
00111  XmStringFree (sliderbar_string);
00112 }
00113 
00114 void G4OpenGLXmSliderBar::SetShow (G4bool sh) 
00115 {
00116   show = sh;
00117   XtVaSetValues (sliderbar,
00118                  XmNshowValue, show,
00119                  NULL);
00120   
00121 }
00122 
00123 void G4OpenGLXmSliderBar::SetDecimalPlaces (short dp) 
00124 {
00125   decimal_places = dp;
00126   XtVaSetValues (sliderbar,
00127                  XmNdecimalPoints, decimal_places,
00128                  NULL);
00129   
00130 }
00131 
00132 void G4OpenGLXmSliderBar::SetInitialValue (G4double v) 
00133 {
00134   initial_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
00135   XtVaSetValues (sliderbar,
00136                  XmNvalue, initial_value,
00137                  NULL);
00138   
00139 }
00140 
00141 void G4OpenGLXmSliderBar::SetMaxValue (G4double v) 
00142 {
00143   max_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
00144   XtVaSetValues (sliderbar,
00145                  XmNmaximum, max_value,
00146                  NULL);
00147   
00148 }
00149 
00150 void G4OpenGLXmSliderBar::SetMinValue (G4double v) 
00151 {
00152   min_value = int(v * std::pow(10.0, (G4double)GetDecimalPlaces()));
00153   XtVaSetValues (sliderbar,
00154                  XmNminimum, min_value,
00155                  NULL);
00156   
00157 }
00158 
00159 void G4OpenGLXmSliderBar::SetOrientation (unsigned char o) 
00160 {
00161   orientation = o;
00162   XtVaSetValues (sliderbar,
00163                  XmNorientation, orientation,
00164                  NULL);
00165   
00166 }
00167 
00168 void G4OpenGLXmSliderBar::SetDirection (unsigned char d) 
00169 {
00170   direction = d;
00171   XtVaSetValues (sliderbar,
00172                  XmNprocessingDirection, direction,
00173                  NULL);
00174   
00175 }
00176 
00177 void G4OpenGLXmSliderBar::AddYourselfTo (G4OpenGLXmVWidgetContainer* container)
00178 {
00179 
00180   pView = container->GetView ();
00181   ProcesspView ();
00182 
00183   parent = container->GetPointerToWidget ();
00184   XmString name_string = XmStringCreateLocalized ((char*)name);
00185   sliderbar = XtVaCreateManagedWidget (name,
00186                                        xmScaleWidgetClass,
00187                                        *parent,
00188                                        
00189                                        XmNtitleString, name_string,
00190                                        XmNmaximum, max_value,
00191                                        XmNminimum, min_value,
00192                                        XmNvalue, initial_value,
00193                                        XmNshowValue, show,
00194                                        XmNdecimalPoints, decimal_places,
00195                                        XmNorientation, orientation,
00196                                        XmNprocessingDirection, direction,
00197   
00198                                        XtNvisual, visual,
00199                                        XtNdepth, depth,
00200                                        XtNcolormap, cmap,
00201                                        XtNborderColor, borcol,
00202                                        XtNbackground, bgnd,
00203 
00204                                        NULL);
00205                                        
00206   XtAddCallbacks (sliderbar,
00207                   XmNvalueChangedCallback,
00208                   callback);
00209 
00210   XtAddCallbacks (sliderbar,
00211                   XmNdragCallback,
00212                   callback);
00213   XmStringFree (name_string);
00214 }
00215 
00216 Widget* G4OpenGLXmSliderBar::GetPointerToParent ()
00217 {
00218   return parent;
00219 }
00220 
00221 Widget* G4OpenGLXmSliderBar::GetPointerToWidget () 
00222 {
00223   return &sliderbar;
00224 }
00225 
00226 #endif

Generated on Mon May 27 17:49:11 2013 for Geant4 by  doxygen 1.4.7