Image Component Library (ICL)
|
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.GPL ** 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 <ICLQt/GUIHandle.h> 00034 #include <ICLQt/ThreadedUpdatableSlider.h> 00035 00037 class QSlider; 00038 class QLCDNumber; 00041 namespace icl{ 00042 namespace qt{ 00043 00045 class FSliderHandle : public GUIHandle<ThreadedUpdatableSlider>{ 00047 QLCDNumber *lcd; 00048 public: 00050 FSliderHandle(); 00051 00053 FSliderHandle(ThreadedUpdatableSlider *sl,float *minV, float *maxV, float *M, float *B,int range, GUIWidget *w, QLCDNumber *lcd=0); 00054 00056 00057 inline QLCDNumber *getDisplay() { return lcd; } 00058 00060 void setMin(float min); 00061 00063 void setMax(float max); 00064 00066 void setRange(float min, float max){ setMin(min); setMax(max); } 00067 00069 void setValue(float val); 00070 00072 void setAll(float min ,float max, float val){ setRange(min,max); setValue(val); } 00073 00075 float getMin() const; 00076 00078 float getMax() const; 00079 00081 float getValue() const; 00082 00084 void operator=(float val) { setValue(val); } 00085 00087 00099 virtual void registerCallback(const GUI::Callback &cb, const std::string &events="value"){ 00100 (***this).registerCallback(cb,events); 00101 } 00102 00104 using GUIHandleBase::registerCallback; 00105 00107 virtual void removeCallbacks(){ 00108 GUIHandleBase::removeCallbacks(); 00109 (***this).removeCallbacks(); 00110 } 00111 00112 private: 00113 00115 void updateMB(); 00116 00118 float *m_fMin; 00119 00121 float *m_fMax; 00122 00124 int f2i(float f) const{ 00125 return (int)((f-*m_fB)/ *m_fM); 00126 } 00127 00129 float i2f(int i) const{ 00130 return *m_fM*i+*m_fB; 00131 } 00132 00134 float *m_fM; 00135 00137 float *m_fB; 00138 00140 int m_iSliderRange; 00141 }; 00142 00143 } // namespace qt 00144 } 00145