SciFigs/Legend.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 : 2002-05-24
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef LEGEND_H
00030 #define LEGEND_H
00031 
00032 #include "LegendItem.h"
00033 #include "SciFigsDLLExport.h"
00034 
00035 namespace SciFigs {
00036 
00037 class Pen;
00038 class Symbol;
00039 
00040 class SCIFIGS_EXPORT Legend : public XMLClass
00041 {
00042 public:
00043   Legend() {_textLookup=0;}
00044   Legend(const Legend& o) : XMLClass() {_textLookup=0; operator=(o);}
00045   Legend(int n) {_textLookup=0; resize(n);}
00046   virtual ~Legend();
00047 
00048   Legend& operator=(const Legend& o);
00049   bool operator==(const Legend& o) const;
00050   bool operator!=(const Legend& o) const {return !operator==(o);}
00051 
00052   virtual const QString& xml_tagName() const {return xmlLegendTag;}
00053   static const QString xmlLegendTag;
00054 
00055   void resize(int n);
00056   void clear();
00057   void setTexts(const QStringList& texts, const Pen& defaultPen, const Symbol& defaultSymbol);
00058 
00059   void defaultColors(int n=10);
00060   void defaultBW(int n=10);
00061   void colorRGBInterpole(int imin, int imax);
00062   void colorHSVInterpole(int imin, int imax);
00063   const LegendItem& item(int i);
00064 
00065   int count() const {return _items.size();}
00066   int indexOf(const QString& text) const;
00067 
00068   void setText(int i, QString t);
00069   const QString& text(int i) const;
00070 
00071   void setTextColor(int i, QColor c);
00072   const QColor& textColor(int i) const;
00073 
00074   void setPen(int i, Pen p);
00075   const Pen& pen(int i) const;
00076   const Pen& pen(const QString& text) const;
00077 
00078   void setSymbol(int i, Symbol s);
00079   const Symbol& symbol(int i) const;
00080   const Symbol& symbol(const QString& text) const;
00081 
00082   QStringList texts() const;
00083   void setTexts(const Legend& o);
00084   void setTextColors(const Legend& o);
00085   void setPens(const Legend& o);
00086   void setSymbols(const Legend& o);
00087 
00088   void penColorToSymbolPen();
00089   void penColorToSymbolBrush();
00090   void penColorToText();
00091 protected:
00092   virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00093   virtual XMLMember xml_member(XML_MEMBER_ARGS);
00094 private:
00095   void resetTextLookup();
00096 
00097   QVector<LegendItem> _items;
00098   mutable QMap<QString, int> * _textLookup;
00099 };
00100 
00101 //QTextStream& operator>>(QTextStream& s, Legend& p);
00102 
00103 } // namespace SciFigs
00104 
00105 // Allow passing Legend as a QVariant
00106 Q_DECLARE_METATYPE(SciFigs::Legend);
00107 
00108 #endif // LEGEND_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines