• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ui/ThresholdForm.cpp

Go to the documentation of this file.
00001 #include "ThresholdForm.h"
00002 
00003 ThresholdForm::ThresholdForm(QWidget *parent, Qt::Orientation orientation, QwtSlider::ScalePos scalePos, QwtSlider::BGSTYLE bgStyle)
00004     : QDialog(parent)
00005 {
00006     ui.setupUi(this);
00007 
00008     maxValue = 1.0;
00009     minValue = -1.0;
00010     stepValue = 0.1;
00011     scaleDrawn = true;
00012     usingTicks = true;
00013 
00014     ui.SliderHigh->setOrientation(orientation);
00015     ui.SliderHigh->setScalePosition(scalePos);
00016     ui.SliderHigh->setBgStyle(bgStyle);
00017     ui.SliderHigh->setRange(minValue,maxValue,stepValue);
00018     ui.SliderHigh->setTracking(false); //Only emit when mouse released
00019     ui.SliderLow->setOrientation(orientation);
00020     ui.SliderLow->setScalePosition(scalePos);
00021     ui.SliderLow->setBgStyle(bgStyle);
00022     ui.SliderLow->setRange(minValue,maxValue,stepValue);
00023     ui.SliderLow->setTracking(false); //Only emit when mouse released
00024 
00025     updateScales();
00026 
00027     createConnections();
00028 }
00029 
00030 ThresholdForm::~ThresholdForm()
00031 {
00032     //dtor
00033 }
00034 
00035 void ThresholdForm::setMax(double max)
00036 {
00037     double tmpMin = 0.0, interval = 0.1;
00038 
00039     maxValue = max;
00040     tmpMin = ui.SliderHigh->minValue();
00041     interval = ui.SliderHigh->step();
00042 
00043     ui.SliderHigh->setRange(tmpMin,max,interval);
00044     ui.SliderLow->setRange(tmpMin,max,interval);
00045 
00046     updateScales();
00047 }
00048 
00049 void ThresholdForm::setMin(double min)
00050 {
00051     double tmpMax = 1.0, interval = 0.1;
00052 
00053     minValue = min;
00054     tmpMax = ui.SliderLow->maxValue();
00055     interval = ui.SliderLow->step();
00056 
00057     ui.SliderHigh->setRange(min,tmpMax,interval);
00058     ui.SliderLow->setRange(min,tmpMax,interval);
00059 
00060     updateScales();
00061 }
00062 
00063 void ThresholdForm::setStep(double interval)
00064 {
00065     double tmpMax = 1.0, tmpMin = 0.0;
00066 
00067     stepValue = interval;
00068     tmpMax = ui.SliderHigh->maxValue();
00069     tmpMin = ui.SliderLow->minValue();
00070 
00071     ui.SliderHigh->setRange(tmpMin,tmpMax,interval);
00072     ui.SliderLow->setRange(tmpMin,tmpMax,interval);
00073     usingTicks = false;
00074 
00075     updateScales();
00076 }
00077 
00078 void ThresholdForm::setNoOfMajorTicks(int ticks)
00079 {
00080     ui.SliderHigh->setScaleMaxMajor(ticks);
00081     ui.SliderLow->setScaleMaxMajor(ticks);
00082     usingTicks = true;
00083 }
00084 
00085 void ThresholdForm::setNoOfMinorTicks(int ticks)
00086 {
00087     ui.SliderHigh->setScaleMaxMinor(ticks);
00088     ui.SliderLow->setScaleMaxMinor(ticks);
00089     usingTicks = true;
00090 }
00091 
00092 //slots
00093 void ThresholdForm::updateUpperValue(double value)
00094 {
00095     emit upperValueChanged(value);
00096 }
00097 
00098 void ThresholdForm::updateLowerValue(double value)
00099 {
00100     emit lowerValueChanged(value);
00101 }
00102 
00103 void ThresholdForm::updateScales()
00104 {
00105     if(!usingTicks)
00106     {
00107         ui.SliderHigh->setScale(minValue,maxValue,stepValue);
00108         ui.SliderLow->setScale(minValue,maxValue,stepValue);
00109     }
00110     else
00111     {
00112         ui.SliderHigh->setScale(minValue,maxValue);
00113         ui.SliderLow->setScale(minValue,maxValue);
00114     }
00115 }
00116 
00117 void ThresholdForm::createConnections()
00118 {
00119     connect(ui.SliderHigh, SIGNAL(valueChanged(double)), this, SLOT(updateUpperValue(double)));
00120     connect(ui.SliderLow, SIGNAL(valueChanged(double)), this, SLOT(updateLowerValue(double)));
00121 }

Generated on Wed Sep 8 2010 01:36:52 for DGV by  doxygen 1.7.1