1 #include "DocumentSerialize.h"
5 #include <QXmlStreamReader>
6 #include <QXmlStreamWriter>
9 const int DEFAULT_LINE_WIDTH = 1;
13 m_paletteColor (COLOR_PALETTE_TRANSPARENT),
14 m_curveConnectAs (CONNECT_AS_FUNCTION_SMOOTH)
19 ColorPalette paletteColor,
20 CurveConnectAs curveConnectAs) :
22 m_paletteColor (paletteColor),
23 m_curveConnectAs (curveConnectAs)
28 m_width (other.width ()),
29 m_paletteColor (other.paletteColor()),
30 m_curveConnectAs (other.curveConnectAs())
36 m_width = other.
width ();
45 return m_curveConnectAs;
51 COLOR_PALETTE_TRANSPARENT,
52 CONNECT_SKIP_FOR_AXIS_CURVE);
59 CONNECT_AS_FUNCTION_SMOOTH);
64 LOG4CPP_INFO_S ((*mainCat)) <<
"LineStyle::loadXml";
66 QXmlStreamAttributes attributes = reader.attributes();
68 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH) &&
69 attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_COLOR) &&
70 attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS)) {
72 setWidth (attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH).toInt());
73 setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_COLOR).toInt());
74 setCurveConnectAs ((CurveConnectAs) attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS).toInt());
77 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
78 (reader.name() != DOCUMENT_SERIALIZE_LINE_STYLE)){
79 loadNextFromReader(reader);
82 reader.raiseError (
"Cannot read line style data");
88 return m_paletteColor;
92 QTextStream &str)
const
94 str << indentation <<
"LineStyle\n";
96 indentation += INDENTATION_DELTA;
98 str << indentation <<
"width=" << m_width <<
"\n";
99 str << indentation <<
"color=" << colorPaletteToString (m_paletteColor) <<
"\n";
100 str << indentation <<
"curveConnectAs=" << curveConnectAsToString (m_curveConnectAs) <<
"\n";
105 LOG4CPP_INFO_S ((*mainCat)) <<
"LineStyle::saveXml";
107 writer.writeStartElement(DOCUMENT_SERIALIZE_LINE_STYLE);
108 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH, QString::number(m_width));
109 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_COLOR, QString::number (m_paletteColor));
110 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_COLOR_STRING, colorPaletteToString (m_paletteColor));
111 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS, QString::number (m_curveConnectAs));
112 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS_STRING, curveConnectAsToString (m_curveConnectAs));
113 writer.writeEndElement();
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
static LineStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
unsigned int width() const
Width of line.
LineStyle & operator=(const LineStyle &other)
Assignment operator.
static LineStyle defaultAxesCurve()
Initial default for axes curve.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Details for a specific Line.
ColorPalette paletteColor() const
Line color.
void setCurveConnectAs(CurveConnectAs curveConnectAs)
Set connect as.
CurveConnectAs curveConnectAs() const
Get method for connect type.
void setPaletteColor(ColorPalette paletteColor)
Set method for line color.
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
void setWidth(int width)
Set width of line.
LineStyle()
Default constructor only for use when this class is being stored by a container that requires the def...