DlgSettingsColorGradientImp.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
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 /* TRANSLATOR Gui::Dialog::DlgSettingsColorGradientImp */
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     // no need to delete child widgets, Qt does it all for us
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 

Generated on Wed Nov 23 19:00:07 2011 for FreeCAD by  doxygen 1.6.1