A graphic symbol. More...
#include <Symbol.h>
Public Types | |
| enum | Type { NoSymbol, Cross, Square, Circle, TriangleUp, TriangleDown, Losange, Star } |
Public Member Functions | |
| const Brush & | brush () const |
| void | fromStream (QTextStream &s) |
| Symbol & | operator= (const Symbol &o) |
| bool | operator== (const Symbol &o) const |
| void | paint (QPainter &p, const QPointF ¢er, double dotpercm=28.346457) const |
| const Pen & | pen () const |
| void | setBrush (const Brush &b) |
| void | setPen (const Pen &p) |
| void | setSize (double s) |
| void | setType (Type t) |
| double | size () const |
| Symbol (Type type=NoSymbol, double size=1.2, Pen pen=Pen(Qt::black), Brush brush=Brush(Qt::NoBrush)) | |
| Symbol (const Symbol &s) | |
| Type | type () const |
| virtual const QString & | xml_tagName () const |
| virtual | ~Symbol () |
Static Public Member Functions | |
| static void | paint (Type type, QPainter &p, QPointF center, double size, double halfSize) |
| static QString | symbolName (Type s) |
| static Type | symbolValue (QString s) |
Static Public Attributes | |
| static const Symbol | null |
| static const QString | xmlSymbolTag = "Symbol" |
Protected Member Functions | |
| virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
| virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
| virtual void | xml_writeChildren (XML_WRITECHILDREN_ARGS) const |
| virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
Protected Attributes | |
| Brush | _brush |
| Pen | _pen |
| double | _size |
| Type | _type |
A graphic symbol.
{NoSymbol, Cross, Square, Circle, TriangleUp, TriangleDown, Losange, Star};
| SciFigs::Symbol::Symbol | ( | const Symbol & | s | ) |
| virtual SciFigs::Symbol::~Symbol | ( | ) | [inline, virtual] |
{}
| const Brush& SciFigs::Symbol::brush | ( | ) | const [inline] |
| void SciFigs::Symbol::fromStream | ( | QTextStream & | s | ) |
| bool SciFigs::Symbol::operator== | ( | const Symbol & | o | ) | const |
| void SciFigs::Symbol::paint | ( | QPainter & | p, |
| const QPointF & | center, | ||
| double | dotpercm = 28.346457 |
||
| ) | const |
References _brush, _pen, _size, _type, SciFigs::Brush::qbrush(), SciFigs::Pen::qpen(), size(), and TRACE.
Referenced by SciFigs::LegendItemDisplay::paint(), SciFigs::LegendTableDelegate::paint(), and SciFigs::LegendWidget::paint().
| void SciFigs::Symbol::paint | ( | Type | type, |
| QPainter & | p, | ||
| QPointF | center, | ||
| double | size, | ||
| double | halfSize | ||
| ) | [inline, static] |
References Cross, Losange, size(), Square, Star, TRACE, TriangleDown, and TriangleUp.
{
TRACE;
switch(type) {
case Cross: {
QPointF h1(halfSize, halfSize);
QPointF h2(halfSize, -halfSize);
p.drawLine(center-h1, center+h1);
p.drawLine(center-h2, center+h2);
}
break;
case Square: {
p.drawRect(QRectF(center-QPointF(halfSize, halfSize),QSizeF(size,size)));
}
break;
case Circle: {
p.drawEllipse(center, halfSize, halfSize);
}
break;
case TriangleUp: {
QPolygonF points(4);
double halfSize=0.5*0.866025403784439*size;
center+=QPointF(-halfSize, 0.25*size);
points[0]=center;
points[1]=center+QPointF(0.866025403784439*size, 0);
points[2]=center+QPointF(halfSize, -0.75*size);
points[3]=points[0];
p.drawPolygon(points);
}
break;
case TriangleDown: {
QPolygonF points(4);
double halfSize=0.5*0.866025403784439*size;
center+=QPointF(-halfSize, -0.25*size);
points[0]=center;
points[1]=center+QPointF(0.866025403784439*size, 0);
points[2]=center+QPointF(halfSize, 0.75*size);
points[3]=points[0];
p.drawPolygon(points);
}
break;
case Losange: {
QPolygonF points(5);
double quarterSize=size*0.25;
points[0]=center-QPointF(0.0, halfSize);
points[1]=center+QPointF(quarterSize, 0.0);
points[2]=center+QPointF(0.0, halfSize);
points[3]=center-QPointF(quarterSize, 0.0);
points[4]=points[0];
p.drawPolygon (points);
}
break;
case Star: {
QPointF h1(halfSize, halfSize);
QPointF h2(halfSize, -halfSize);
QPointF h3(halfSize, 0.0);
QPointF h4(0.0, halfSize);
p.drawLine(center-h1, center+h1);
p.drawLine(center-h2, center+h2);
p.drawLine(center-h3, center+h3);
p.drawLine(center-h4, center+h4);
}
break;
default:
break;
}
}
| const Pen& SciFigs::Symbol::pen | ( | ) | const [inline] |
| void SciFigs::Symbol::setBrush | ( | const Brush & | b | ) | [inline] |
| void SciFigs::Symbol::setPen | ( | const Pen & | p | ) | [inline] |
Referenced by SciFigs::LegendTableItem::setData(), SciFigs::LineLayer::setSymPenColor(), and SciFigs::LineLayer::setSymPenStyle().
{_pen=p;}
| void SciFigs::Symbol::setSize | ( | double | s | ) | [inline] |
Referenced by SciFigs::LegendTableItem::setData(), and SciFigs::LineLayer::setSymSize().
{_size=s;}
| void SciFigs::Symbol::setType | ( | Type | t | ) | [inline] |
Referenced by SciFigs::LegendTableItem::setData(), and SciFigs::LineLayer::setSymType().
{_type=t;}
| double SciFigs::Symbol::size | ( | ) | const [inline] |
Referenced by SciFigs::LegendTableItem::data(), paint(), SciFigs::LegendWidget::paint(), SciFigs::NameLineLayer::paintData(), and Symbol().
{return _size;}
| QString SciFigs::Symbol::symbolName | ( | Type | s | ) | [static] |
References Cross, Losange, Square, Star, TRACE, TriangleDown, and TriangleUp.
Referenced by SciFigs::XYPlot::symbolString(), and xml_writeProperties().
{
TRACE;
switch (s) {
case Cross: return "Cross";
case Square: return "Square";
case Circle: return "Circle";
case TriangleUp: return "TriangleUp";
case TriangleDown: return "TriangleDown";
case Losange: return "Losange";
case Star: return "Star";
default: return "NoSymbol";
}
}
| Symbol::Type SciFigs::Symbol::symbolValue | ( | QString | s | ) | [static] |
References Circle, Cross, Losange, NoSymbol, Square, Star, TriangleDown, and TriangleUp.
Referenced by SciFigs::XYPlot::setSymbol(), SciFigs::LineLayer::setSymType(), and xml_setProperty().
{
if(s.count()>=4) {
switch(s[2].unicode()) {
case 'o':
if(s=="Cross") return Cross;
break;
case 'u':
if(s=="Square") return Square;
break;
case 'i':
if(s=="TriangleUp") return TriangleUp;
else if(s=="TriangleDown") return TriangleDown;
else if(s=="Triangle") return TriangleDown; // For compatibility
break;
case 'r':
if(s=="Circle") return Circle;
break;
case 's':
if(s=="Losange") return Losange;
break;
case 'a':
if(s=="Star") return Star;
break;
default:
break;
}
}
return NoSymbol;
}
| Type SciFigs::Symbol::type | ( | ) | const [inline] |
Referenced by SciFigs::LegendTableItem::data(), and Symbol().
{return _type;}
| XMLMember SciFigs::Symbol::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore (children and properties) support to your class.
From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:
Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):
static const QString tmp("childrenName"); XMLRestoreAttributeIterator it=map.find(tmp); if(it!=map.end()) { // found attribute "childrenName" }
If the map of attributes is not used:
Q_UNUSED(attributes);
if(tag=="x1") return XMLMember(0);
else if(tag=="y1") return XMLMember(1);
else if(tag=="x2") return XMLMember(2);
else if(tag=="y2") return XMLMember(3);
else return XMLMember(XMLMember::Unknown);
Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.
if(tag=="anInteger") return XMLMember(0); else if(tag=="aString") return XMLMember(1); else if(tag=="aDouble") return XMLMember(2); return AbstractLine::xml_member(tag, attributes, context)+3;
For the arguments of this function use Macro XML_MEMBER_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
| bool SciFigs::Symbol::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore properties support to your class.
From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).
For a general case:
Q_UNUSED(attributes); double val=content.toDouble(); switch (memberID) { case 0: _x1=val; return true; case 1: _y1=val; return true; case 2: _x2=val; return true; case 3: _y2=val; return true; default: return false; }
For classes inheriting other classes (see also xml_member())
switch (memberID) { case 0: _anInteger=content.toString(); return true; case 1: _aString=content.toInt(); return true; case 2: _aDouble=content.toDouble(); return true; default: return AbstractLine::xml_setProperty(memberID-3, map, content);
For the arguments of this function use Macro XML_SETPROPERTY_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References _size, _type, symbolValue(), and TRACE.
{
TRACE;
Q_UNUSED(tag);
Q_UNUSED(attributes);
Q_UNUSED(context);
switch (memberID) {
case 0:
_type=symbolValue(content.toString());
return true;
case 1:
_size=content.toDouble();
return true;
default:
return false;
}
}
| virtual const QString& SciFigs::Symbol::xml_tagName | ( | ) | const [inline, virtual] |
Implements QGpCoreTools::XMLClass.
{return xmlSymbolTag;}
| void SciFigs::Symbol::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References _brush, _pen, TRACE, and QGpCoreTools::XMLClass::xml_save().
| void SciFigs::Symbol::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References _size, _type, symbolName(), TRACE, and QGpCoreTools::XMLClass::writeProperty().
{
TRACE;
Q_UNUSED(context);
writeProperty(s, "type",symbolName(_type));
writeProperty(s, "size",_size);
}
Brush SciFigs::Symbol::_brush [protected] |
Referenced by operator=(), operator==(), paint(), Symbol(), xml_member(), and xml_writeChildren().
Pen SciFigs::Symbol::_pen [protected] |
Referenced by operator=(), operator==(), paint(), Symbol(), xml_member(), and xml_writeChildren().
double SciFigs::Symbol::_size [protected] |
Referenced by operator=(), operator==(), paint(), Symbol(), xml_setProperty(), and xml_writeProperties().
Type SciFigs::Symbol::_type [protected] |
Referenced by operator=(), operator==(), paint(), Symbol(), xml_setProperty(), and xml_writeProperties().
const Symbol SciFigs::Symbol::null [static] |
Referenced by SciFigs::Legend::symbol().
const QString SciFigs::Symbol::xmlSymbolTag = "Symbol" [static] |