00001 /*************************************************************************** 00002 File : ColorMapEditor.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2006 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : A QwtLinearColorMap Editor Widget 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 * This program is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU General Public License * 00023 * along with this program; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00025 * Boston, MA 02110-1301 USA * 00026 * * 00027 ***************************************************************************/ 00028 #ifndef COLORMAPEDITOR_H 00029 #define COLORMAPEDITOR_H 00030 00031 #include <QWidget> 00032 #include <QLocale> 00033 #include <qwt_color_map.h> 00034 00035 class QPushButton; 00036 class QTableWidget; 00037 class QCheckBox; 00038 class DoubleSpinBox; 00039 00041 00047 class ColorMapEditor: public QWidget 00048 { 00049 Q_OBJECT 00050 00051 public: 00053 00056 ColorMapEditor(const QLocale& locale = QLocale::system(), int precision = 6, QWidget* parent = 0); 00058 QwtLinearColorMap colorMap(){return color_map;}; 00060 void setColorMap(const QwtLinearColorMap& map); 00062 void setRange(double min, double max); 00064 static QString saveToXmlString(const QwtLinearColorMap& color_map); 00065 00066 protected slots: 00067 void updateColorMap(); 00068 void enableButtons(int row); 00069 void showColorDialog(int row, int col); 00070 void insertLevel(); 00071 void deleteLevel(); 00072 void setScaledColors(bool scale = true); 00073 void spinBoxActivated(DoubleSpinBox *); 00074 00075 bool eventFilter(QObject *object, QEvent *e); 00076 00077 private: 00079 QTableWidget *table; 00080 QPushButton *insertBtn, *deleteBtn; 00081 QCheckBox *scaleColorsBox; 00082 00084 QwtLinearColorMap color_map; 00086 double min_val, max_val; 00088 QLocale d_locale; 00090 int d_precision; 00091 }; 00092 00093 #endif
1.4.6