DlgSettingsColorGradientImp.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <QLocale>
00027 # include <QMessageBox>
00028 # include <QDoubleValidator>
00029 #endif
00030
00031 #ifndef _PreComp_
00032 #include <math.h>
00033 #endif
00034
00035 #include "DlgSettingsColorGradientImp.h"
00036 #include "SpinBox.h"
00037
00038 using namespace Gui::Dialog;
00039
00040
00041
00046 DlgSettingsColorGradientImp::DlgSettingsColorGradientImp( QWidget* parent, Qt::WFlags fl )
00047 : QDialog( parent, fl )
00048 {
00049 this->setupUi(this);
00050 fMaxVal = new QDoubleValidator(-1000,1000,spinBoxDecimals->maximum(),this);
00051 floatLineEditMax->setValidator(fMaxVal);
00052 fMinVal = new QDoubleValidator(-1000,1000,spinBoxDecimals->maximum(),this);
00053 floatLineEditMin->setValidator(fMinVal);
00054 }
00055
00059 DlgSettingsColorGradientImp::~DlgSettingsColorGradientImp()
00060 {
00061
00062 }
00063
00064 void DlgSettingsColorGradientImp::setColorModel( App::ColorGradient::TColorModel tModel)
00065 {
00066 switch (tModel)
00067 {
00068 case App::ColorGradient::TRIA:
00069 comboBoxModel->setCurrentIndex(0);
00070 break;
00071 case App::ColorGradient::INVERSE_TRIA:
00072 comboBoxModel->setCurrentIndex(1);
00073 break;
00074 case App::ColorGradient::GRAY:
00075 comboBoxModel->setCurrentIndex(2);
00076 break;
00077 case App::ColorGradient::INVERSE_GRAY:
00078 comboBoxModel->setCurrentIndex(3);
00079 break;
00080 }
00081 }
00082
00083 App::ColorGradient::TColorModel DlgSettingsColorGradientImp::colorModel() const
00084 {
00085 int item = comboBoxModel->currentIndex();
00086 if ( item == 0 )
00087 return App::ColorGradient::TRIA;
00088 else if ( item == 1 )
00089 return App::ColorGradient::INVERSE_TRIA;
00090 else if ( item == 2 )
00091 return App::ColorGradient::GRAY;
00092 else
00093 return App::ColorGradient::INVERSE_GRAY;
00094 }
00095
00096 void DlgSettingsColorGradientImp::setColorStyle( App::ColorGradient::TStyle tStyle )
00097 {
00098 switch ( tStyle )
00099 {
00100 case App::ColorGradient::FLOW:
00101 radioButtonFlow->setChecked(true);
00102 break;
00103 case App::ColorGradient::ZERO_BASED:
00104 radioButtonZero->setChecked(true);
00105 break;
00106 }
00107 }
00108
00109 App::ColorGradient::TStyle DlgSettingsColorGradientImp::colorStyle() const
00110 {
00111 return radioButtonZero->isChecked() ? App::ColorGradient::ZERO_BASED : App::ColorGradient::FLOW;
00112 }
00113
00114 void DlgSettingsColorGradientImp::setOutGrayed( bool grayed )
00115 {
00116 checkBoxGrayed->setChecked( grayed );
00117 }
00118
00119 bool DlgSettingsColorGradientImp::isOutGrayed() const
00120 {
00121 return checkBoxGrayed->isChecked();
00122 }
00123
00124 void DlgSettingsColorGradientImp::setOutInvisible( bool invisible )
00125 {
00126 checkBoxInvisible->setChecked( invisible );
00127 }
00128
00129 bool DlgSettingsColorGradientImp::isOutInvisible() const
00130 {
00131 return checkBoxInvisible->isChecked();
00132 }
00133
00134 void DlgSettingsColorGradientImp::setRange( float fMin, float fMax )
00135 {
00136 floatLineEditMax->blockSignals(true);
00137 floatLineEditMax->setText(QLocale::system().toString(fMax, 'f', numberOfDecimals()));
00138 floatLineEditMax->blockSignals(false);
00139 floatLineEditMin->blockSignals(true);
00140 floatLineEditMin->setText(QLocale::system().toString(fMin, 'f', numberOfDecimals()));
00141 floatLineEditMin->blockSignals(false);
00142 }
00143
00144 void DlgSettingsColorGradientImp::getRange( float& fMin, float& fMax) const
00145 {
00146 fMax = floatLineEditMax->text().toFloat();
00147 fMin = floatLineEditMin->text().toFloat();
00148 }
00149
00150 void DlgSettingsColorGradientImp::setNumberOfLabels(int val)
00151 {
00152 spinBoxLabel->setValue( val );
00153 }
00154
00155 int DlgSettingsColorGradientImp::numberOfLabels() const
00156 {
00157 return spinBoxLabel->value();
00158 }
00159
00160 void DlgSettingsColorGradientImp::setNumberOfDecimals(int val)
00161 {
00162 spinBoxDecimals->setValue(val);
00163 }
00164
00165 int DlgSettingsColorGradientImp::numberOfDecimals() const
00166 {
00167 return spinBoxDecimals->value();
00168 }
00169
00170 void DlgSettingsColorGradientImp::accept()
00171 {
00172 double fMax = floatLineEditMax->text().toDouble();
00173 double fMin = floatLineEditMin->text().toDouble();
00174
00175 if (fMax <= fMin) {
00176 QMessageBox::warning(this, tr("Wrong parameter"),
00177 tr("The maximum value must be higher than the minimum value."));
00178 }
00179 else {
00180 QDialog::accept();
00181 }
00182 }
00183
00184 #include "moc_DlgSettingsColorGradientImp.cpp"
00185