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 PEN_H
00030 #define PEN_H
00031
00032 #include <QtGui>
00033 #include <QGpCoreTools.h>
00034 #include "SciFigsDLLExport.h"
00035
00036 namespace SciFigs {
00037
00038 class SCIFIGS_EXPORT Pen : public XMLClass
00039 {
00040 public:
00041 inline Pen();
00042 inline Pen(Qt::PenStyle style);
00043 inline Pen(const QColor& col, double width=0, Qt::PenStyle style=Qt::SolidLine);
00044 inline Pen(const QColor& col, double width, Qt::PenStyle s, Qt::PenCapStyle c,
00045 Qt::PenJoinStyle j);
00046 inline Pen(const Pen& o);
00047 virtual ~Pen() {}
00048
00049 virtual const QString& xml_tagName() const {return xmlPenTag;}
00050 static const QString xmlPenTag;
00051
00052 inline QPen qpen(double dotpercm) const;
00053 inline Pen& operator=(const Pen& o);
00054 inline bool operator==(const Pen& o) const;
00055
00056 Qt::PenStyle style() const {return _style;}
00057 void setStyle(Qt::PenStyle s) {_style=s;}
00058 double width() const {return _width;}
00059 int screenWidth(double dotpercm) const
00060 {
00061 return (int) floor(0.1 * _width * dotpercm + 0.5);
00062 }
00063 void setWidth (double w) {_width=w;}
00064 const QColor& color() const {return _color;}
00065 void setColor(const QColor & c) {_color=c;}
00066 Qt::PenCapStyle capStyle() const {return _capStyle;}
00067 void setCapStyle(Qt::PenCapStyle c) {_capStyle=c;}
00068 Qt::PenJoinStyle joinStyle() const {return _joinStyle;}
00069 void setJoinStyle(Qt::PenJoinStyle j) {_joinStyle=j;}
00070
00071 static Qt::PenStyle styleValue(QString s);
00072 static QString styleName(Qt::PenStyle s);
00073 static Qt::PenCapStyle capStyleValue(QString s);
00074 static QString capStyleName(Qt::PenCapStyle s);
00075 static Qt::PenJoinStyle joinStyleValue(QString s);
00076 static QString joinStyleName(Qt::PenJoinStyle s);
00077 static const Pen null;
00078 protected:
00079 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00080 virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00081 virtual XMLMember xml_member(XML_MEMBER_ARGS);
00082 private:
00083 QColor _color;
00084 Qt::PenStyle _style;
00085 Qt::PenCapStyle _capStyle;
00086 Qt::PenJoinStyle _joinStyle;
00087
00088 double _width;
00089 };
00090
00091
00092
00093 inline Pen::Pen()
00094 {
00095 _color=Qt::black;
00096 _style=Qt::SolidLine;
00097 _capStyle=Qt::FlatCap;
00098 _joinStyle=Qt::MiterJoin;
00099 _width=0.3;
00100 }
00101
00102 inline Pen::Pen(Qt::PenStyle style)
00103 {
00104 _color=Qt::black;
00105 _style=style;
00106 _capStyle=Qt::FlatCap;
00107 _joinStyle=Qt::MiterJoin;
00108 _width=0.3;
00109 }
00110
00111 inline Pen::Pen(const QColor& col, double width, Qt::PenStyle style)
00112 {
00113 _color=col;
00114 _style=style;
00115 _capStyle=Qt::FlatCap;
00116 _joinStyle=Qt::MiterJoin;
00117 _width=width;
00118 }
00119
00120 inline Pen::Pen(const QColor& col, double width, Qt::PenStyle s, Qt::PenCapStyle c,
00121 Qt::PenJoinStyle j)
00122 {
00123 _color=col;
00124 _style=s;
00125 _capStyle=c;
00126 _joinStyle=j;
00127 _width=width;
00128 }
00129
00130 inline Pen::Pen(const Pen& o) : XMLClass()
00131
00132 {
00133 _color=o._color;
00134 _style=o._style;
00135 _capStyle=o._capStyle;
00136 _joinStyle=o._joinStyle;
00137 _width=o._width;
00138 }
00139
00140 inline Pen& Pen::operator=(const Pen& o)
00141 {
00142 _color=o._color;
00143 _style=o._style;
00144 _capStyle=o._capStyle;
00145 _joinStyle=o._joinStyle;
00146 _width=o._width;
00147 return *this;
00148 }
00149
00150 inline bool Pen::operator==(const Pen& o) const
00151 {
00152 TRACE;
00153 return _color==o._color
00154 && _style==o._style
00155 && _capStyle==o._capStyle
00156 && _joinStyle==o._joinStyle
00157 && _width==o._width;
00158 }
00159
00160 inline QPen Pen::qpen(double dotpercm) const
00161 {
00162 TRACE;
00163 return QPen(QBrush( _color), round(0.1 * _width * dotpercm), _style, _capStyle,
00164 _joinStyle);
00165 }
00166
00167 }
00168
00169 #endif // PEN_H