SciFigs/ColorPaletteWidget.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of SciFigs.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2003-05-07
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef COLORPALETTEWIDGET_H
00030 #define COLORPALETTEWIDGET_H
00031 
00032 #include "GraphicObject.h"
00033 #include "Axis.h"
00034 
00035 namespace SciFigs {
00036 
00037 class PaletteProperties;
00038 class PaletteEditor;
00039 class ColorPaletteLayer;
00040 
00041 class SCIFIGS_EXPORT ColorPaletteWidget : public GraphicObject
00042 {
00043   Q_OBJECT
00044   // Compatibility
00045   Q_PROPERTY(QString numType READ dummyPropertyString WRITE setNumberType STORED false)
00046   Q_PROPERTY(int numPrec READ dummyPropertyInt WRITE setNumberPrecision STORED false)
00047   Q_PROPERTY(QString title READ dummyPropertyString WRITE setTitle STORED false)
00048   Q_PROPERTY(QString numberType READ dummyPropertyString WRITE setNumberType STORED false)
00049   Q_PROPERTY(int numberPrecision READ dummyPropertyInt WRITE setNumberPrecision STORED false)
00050   Q_PROPERTY(QString font READ dummyPropertyString WRITE setFontString STORED false)
00051   Q_PROPERTY(double lineWeight READ dummyPropertyDouble WRITE setLineWeight STORED false)
00052   Q_PROPERTY(double tickLength READ dummyPropertyDouble WRITE setTickSize STORED false)
00053   Q_PROPERTY(double tickLenght READ dummyPropertyDouble WRITE setTickSize STORED false)
00054 public:
00055   ColorPaletteWidget(QWidget *parent=0, Qt::WFlags f=0);
00056   ~ColorPaletteWidget();
00057 
00058   ColorPaletteWidget& operator=(const ColorPaletteWidget& o);
00059 
00060   virtual const QString& xml_tagName() const {return xmlColorPaletteWidgetTag;}
00061   static const QString xmlColorPaletteWidgetTag;
00062 
00063   void setAxis(const Axis& a);
00064   const Axis& axis() const;
00065 
00066   const ColorPalette& palette() const;
00067 
00068   void setOrientation(Axis::Orientation o) {axis().setOrientation(o);}
00069   Axis::Orientation orientation() const {return axis().orientation();}
00070 
00071   virtual int* scaleFonts(double factor);
00072   virtual void restoreScaleFonts(int* tmp);
00073 
00074   virtual void addProperties(PropertyProxy * pp);
00075   virtual void removeProperties(PropertyProxy * pp);
00076   virtual void properties(PropertyWidget * w) const;
00077   virtual void setProperty(uint wid, int pid, QVariant val);
00078 public slots:
00079   virtual Q_SCRIPTABLE void update();
00080   virtual Q_SCRIPTABLE void deepUpdate();
00081   Q_SCRIPTABLE void setNumColor(int n);
00082   Q_SCRIPTABLE void defaultColors(int n);
00083   Q_SCRIPTABLE void defaultBW(int n);
00084   Q_SCRIPTABLE void defaultHSVColors(int sat, int value, int n=10, int transparency=255);
00085   Q_SCRIPTABLE void colorInterpole(int imin, int imax);
00086   Q_SCRIPTABLE void setVLinear(double min, double max);
00087   Q_SCRIPTABLE void setVLog(double min, double max);
00088   Q_SCRIPTABLE void load(QString fileName);
00089   Q_SCRIPTABLE void save(QString fileName);
00090   void setPalette(const ColorPalette& pal);
00091 
00092   void setScaleType(Scale::Type t) {axis().setScaleType(t);}
00093   void setNumberType(QString t) {axis().setNumberType(Number::type(t.toAscii().data()[0]));}
00094   void setNumberPrecision(int p) {axis().setCurrentNumberPrecision(p);}
00095   void setTitle(QString s) {axis().setCurrentTitle(s);}
00096   void setFontString(QString fs) {axis().setFontString(fs);}
00097   void setLineWeight(double val) {axis().setLineWeight(val);}
00098   void setTickSize(double val) {axis().setTickSize(val);}
00099 protected:
00100   virtual bool eventFilter(QObject * obj, QEvent * e);
00101   virtual void resizeEvent(QResizeEvent * );
00102 private slots:
00103   void setOrientation();
00104 signals:
00105   void changed(ColorPalette pal);
00106 protected:
00107   virtual void print(QPainter& p, double dotpercm, int x0Sheet, int y0Sheet, bool mask);
00108   XMLMember xml_member(XML_MEMBER_ARGS);
00109   void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00110   void xml_polishChild(XML_POLISHCHILD_ARGS);
00111 private:
00112   Axis& axis();
00113   QMouseEvent * convertMouseEvent(QObject * obj, QEvent * e);
00114 
00115   ColorPaletteLayer * _paletteLayer;
00116   static uint _category, _tabPalette;
00117 };
00118 
00119 } // namespace SciFigs
00120 
00121 #endif // COLORPALETTEWIDGET_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines