Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FSliderHandle.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLQt/src/ICLQt/FSliderHandle.h                        **
00010 ** Module : ICLQt                                                  **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <ICLUtils/CompatMacros.h>
00034 #include <ICLQt/GUIHandle.h>
00035 #include <ICLQt/ThreadedUpdatableSlider.h>
00036 
00038 class QSlider;
00039 class QLCDNumber;
00042 namespace icl{
00043   namespace qt{
00044     
00046     class ICLQt_API FSliderHandle : public GUIHandle<ThreadedUpdatableSlider>{
00048       QLCDNumber *lcd;
00049       public:
00051       FSliderHandle();
00052   
00054       FSliderHandle(ThreadedUpdatableSlider *sl,float *minV, float *maxV, float *M, float *B,int range, GUIWidget *w, QLCDNumber *lcd=0);
00055       
00057 
00058       inline QLCDNumber *getDisplay() { return lcd; }
00059       
00061       void setMin(float min);
00062   
00064       void setMax(float max);
00065   
00067       void setRange(float min, float max){ setMin(min); setMax(max); }
00068       
00070       void setValue(float val);
00071   
00073       void setAll(float min ,float max, float val){ setRange(min,max); setValue(val); }
00074   
00076       float getMin() const;
00077   
00079       float getMax() const;
00080   
00082       float getValue() const;
00083       
00085       void operator=(float val) { setValue(val); }
00086   
00088 
00100       virtual void registerCallback(const GUI::Callback &cb, const std::string &events="value"){
00101         (***this).registerCallback(cb,events);
00102       }
00103       
00105       using GUIHandleBase::registerCallback;
00106       
00108       virtual void removeCallbacks(){
00109         GUIHandleBase::removeCallbacks();
00110         (***this).removeCallbacks();
00111       }
00112       
00113       private:
00114       
00116       void updateMB();
00117      
00119       float *m_fMin;
00120       
00122       float *m_fMax;
00123       
00125       int f2i(float f) const{
00126         return (int)((f-*m_fB)/ *m_fM);
00127       }
00128   
00130       float i2f(int i) const{
00131         return *m_fM*i+*m_fB;
00132       } 
00133   
00135       float *m_fM;
00136   
00138       float *m_fB;
00139       
00141       int m_iSliderRange;
00142     };
00143     
00144   } // namespace qt
00145 }
00146 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines