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
00025
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
00102
00103 }
00104
00105
00106 Q_DECLARE_METATYPE(SciFigs::Legend);
00107
00108 #endif // LEGEND_H