00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision: 13599 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef QmitkNumberPropertySliderhincludecd 00018 #define QmitkNumberPropertySliderhincludecd 00019 00020 #include <mitkPropertyObserver.h> 00021 #include "QmitkExtExports.h" 00022 #include <mitkProperties.h> 00023 #include <qslider.h> 00024 00026 class QmitkExt_EXPORT QmitkNumberPropertySlider : public QSlider, public mitk::PropertyEditor 00027 { 00028 Q_OBJECT 00029 Q_PROPERTY( short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces ) 00030 Q_PROPERTY( bool showPercent READ getShowPercent WRITE setShowPercent ) 00031 Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) 00032 Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) 00033 00034 public: 00035 00036 //QmitkNumberPropertySlider( mitk::GenericProperty<short>*, QWidget* parent, const char* name = 0 ); 00037 QmitkNumberPropertySlider( mitk::IntProperty*, QWidget* parent, const char* name = 0 ); 00038 QmitkNumberPropertySlider( mitk::FloatProperty*, QWidget* parent, const char* name = 0 ); 00039 QmitkNumberPropertySlider( mitk::DoubleProperty*, QWidget* parent, const char* name = 0 ); 00040 00041 virtual ~QmitkNumberPropertySlider(); 00042 00043 short getDecimalPlaces() const; 00044 void setDecimalPlaces(short); 00045 00046 bool getShowPercent() const; 00047 void setShowPercent(bool); 00048 00049 int minValue() const; 00050 void setMinValue(int); 00051 int maxValue() const; 00052 void setMaxValue(int); 00053 double doubleValue() const; 00054 void setDoubleValue(double); 00055 00056 protected: 00057 00058 void initialize(); 00059 00060 virtual void PropertyChanged(); 00061 virtual void PropertyRemoved(); 00062 00063 void DisplayNumber(); 00064 00065 union { 00066 //mitk::GenericProperty<short>* m_ShortProperty; 00067 mitk::GenericProperty<int>* m_IntProperty; 00068 mitk::GenericProperty<float>* m_FloatProperty; 00069 mitk::GenericProperty<double>* m_DoubleProperty; 00070 }; 00071 00072 const int m_DataType; 00073 00074 short m_DecimalPlaces; // how many decimal places are shown 00075 double m_FactorPropertyToSlider; // internal conversion factor. neccessary because slider ranges work only with ints 00076 double m_FactorSliderToDisplay; // internal conversion factor. neccessary because slider ranges work only with ints 00077 bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%) 00078 00079 protected slots: 00080 00081 void onValueChanged(int); 00082 00083 private: 00084 00085 void adjustFactors(short, bool); 00086 00087 bool m_SelfChangeLock; 00088 }; 00089 00090 #endif 00091