00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "GammaDialog.hpp"
00024
00025 #include <QGridLayout>
00026 #include <QSlider>
00027 #include <QDoubleSpinBox>
00028 #include <QPushButton>
00029
00030 #ifndef QT_NO_DEBUG
00031 #include <iostream>
00032 #endif
00033
00034 GammaDialog :: GammaDialog(QWidget* parent )
00035 :QDialog(parent),
00036 pGammaValue(NULL),
00037 pValidateButton(NULL), pApplicateButton(NULL), pCancelButton(NULL)
00038 {
00039 pMainLayout = new QGridLayout(this);
00040
00041 pGammaValue = new QSlider(Qt::Horizontal, this);
00042
00043 pGammaValue->setTickInterval(1);
00044 pGammaValue->setRange(0, 200);
00045 pGammaValue->setValue(100);
00046
00047 pMainLayout->addWidget(pGammaValue, 0, 0);
00048
00049 connect(pGammaValue, SIGNAL(valueChanged(int)), this, SLOT(synchroniseValueSTODSB(int)));
00050
00051 pGammaValueSpinBox = new QDoubleSpinBox(this);
00052
00053 pGammaValueSpinBox->setRange(0, 2);
00054 pGammaValueSpinBox->setDecimals(2);
00055 pGammaValueSpinBox->setSingleStep(0.01);
00056 pGammaValueSpinBox->setValue(1);
00057
00058 pMainLayout->addWidget(pGammaValueSpinBox, 0,1);
00059
00060 connect(pGammaValueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(synchroniseValueDSBTOS(double)));
00061
00062 pValidateButton = new QPushButton(tr("Ok"), this);
00063 pApplicateButton = new QPushButton(tr("Apply"), this);
00064 pCancelButton = new QPushButton(tr("Cancel"), this);
00065
00066 pMainLayout->addWidget(pValidateButton, 1, 0);
00067 pMainLayout->addWidget(pApplicateButton, 1, 1);
00068 pMainLayout->addWidget(pCancelButton, 1, 2);
00069
00070 connect(pValidateButton, SIGNAL(clicked()), this, SLOT(validateGamma()));
00071 connect(pApplicateButton, SIGNAL(clicked()), this, SLOT(applicateGamma()));
00072 connect(pCancelButton, SIGNAL(clicked()), this, SLOT(cancelGamma()));
00073
00074 #ifndef QT_NO_DEBUG
00075 std::cout << "GammaDialog created" << std::endl;
00076 #endif
00077 }
00078
00079 GammaDialog :: ~GammaDialog(void)
00080 {
00081 delete pGammaValue;
00082 delete pGammaValueSpinBox;
00083
00084 delete pValidateButton;
00085 delete pApplicateButton;
00086 delete pCancelButton;
00087
00088 delete pMainLayout;
00089
00090 #ifndef QT_NO_DEBUG
00091 std::cout << "GammaDialog deleted" << std::endl;
00092 #endif
00093 }
00094
00095 void GammaDialog :: validateGamma(void)
00096 {
00097 #ifndef QT_NO_DEBUG
00098 std::cout << "SLOT: validateGamma()" << std::endl;
00099 #endif
00100
00101 this->done(0);
00102 }
00103
00104 void GammaDialog :: applicateGamma(void)
00105 {
00106 #ifndef QT_NO_DEBUG
00107 std::cout << "SLOT: applicateGamma()" << std::endl;
00108 #endif
00109
00110 emit valueChanged(pGammaValueSpinBox->value());
00111 }
00112
00113 void GammaDialog :: cancelGamma(void)
00114 {
00115 #ifndef QT_NO_DEBUG
00116 std::cout << "SLOT: cancelGamma()" << std::endl;
00117 #endif
00118
00119 this->done(1);
00120 }
00121
00122 void GammaDialog :: synchroniseValueSTODSB(int value)
00123 {
00124 #ifndef QT_NO_DEBUG
00125 std::cout << "SLOT: synchroniseValueSTODSB(): " << value << std::endl;
00126 #endif
00127
00128 if ( value != static_cast<int>(pGammaValueSpinBox->value() * 100) )
00129 {
00130 pGammaValueSpinBox->setValue(value/100.0);
00131 }
00132 }
00133
00134 void GammaDialog :: synchroniseValueDSBTOS(double value)
00135 {
00136 #ifndef QT_NO_DEBUG
00137 std::cout << "SLOT: synchroniseValueDSBTOS(): " << value << std::endl;
00138 #endif
00139
00140 if ( static_cast<int>(value * 100) != pGammaValue->value() )
00141 {
00142 pGammaValue->setValue(value*100);
00143 }
00144 }