Engauge Digitizer 2
Loading...
Searching...
No Matches
CurveStyle.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "CurveStyle.h"
8#include "DocumentSerialize.h"
9#include "Logger.h"
10#include <QTextStream>
11#include <QXmlStreamReader>
12#include <QXmlStreamWriter>
13#include "Xml.h"
14
18
20 const PointStyle &pointStyle) :
21 m_pointStyle (pointStyle),
22 m_lineStyle (lineStyle)
23{
24}
25
27{
28 return m_lineStyle;
29}
30
31QString CurveStyle::loadXml(QXmlStreamReader &reader)
32{
33 LOG4CPP_INFO_S ((*mainCat)) << "CurveStyle::loadXml";
34
35 bool success = true;
36 QString curveName;
37
38 QXmlStreamAttributes attributes = reader.attributes();
39
40 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_CURVE_NAME)) {
41
42 curveName = attributes.value (DOCUMENT_SERIALIZE_CURVE_NAME).toString();
43
44 // Read until end of this subtree
45 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
46 (reader.name() != DOCUMENT_SERIALIZE_POINT_STYLE)){
47 loadNextFromReader(reader);
48
49 if (reader.atEnd()) {
50 success = false;
51 break;
52 }
53
54 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
55 (reader.name() == DOCUMENT_SERIALIZE_LINE_STYLE)) {
56
57 m_lineStyle.loadXml (reader);
58
59 } else if ((reader.tokenType() == QXmlStreamReader::StartElement) &
60 (reader.name() == DOCUMENT_SERIALIZE_POINT_STYLE)) {
61
62 m_pointStyle.loadXml (reader);
63
64 }
65 }
66 }
67
68 if (!success) {
69 reader.raiseError (QObject::tr ("Cannot read curve style data"));
70 }
71
72 return curveName;
73}
74
76{
77 return m_pointStyle;
78}
79
80void CurveStyle::printStream(QString indentation,
81 QTextStream &str) const
82{
83 str << indentation << "CurveStyle\n";
84
85 indentation += INDENTATION_DELTA;
86
87 m_pointStyle.printStream (indentation,
88 str);
89 m_lineStyle.printStream (indentation,
90 str);
91}
92
93void CurveStyle::saveXml(QXmlStreamWriter &writer,
94 const QString &curveName) const
95{
96 LOG4CPP_INFO_S ((*mainCat)) << "CurveStyle::saveXml";
97
98 writer.writeStartElement(DOCUMENT_SERIALIZE_CURVE_STYLE);
99 writer.writeAttribute (DOCUMENT_SERIALIZE_CURVE_NAME, curveName);
100 m_lineStyle.saveXml (writer);
101 m_pointStyle.saveXml (writer);
102 writer.writeEndElement();
103}
104
106{
107 m_lineStyle.setPaletteColor(lineColor);
108}
109
111{
112 m_lineStyle.setCurveConnectAs(curveConnectAs);
113}
114
116{
117 m_lineStyle = lineStyle;
118}
119
121{
122 m_lineStyle.setWidth(width);
123}
124
126{
127 m_pointStyle.setPaletteColor(curveColor);
128}
129
131{
132 m_pointStyle.setLineWidth(width);
133}
134
136{
137 m_pointStyle.setRadius(radius);
138}
139
141{
142 m_pointStyle.setShape(shape);
143}
144
146{
147 m_pointStyle = pointStyle;
148}
ColorPalette
CurveConnectAs
const QString DOCUMENT_SERIALIZE_LINE_STYLE
const QString DOCUMENT_SERIALIZE_CURVE_NAME
const QString DOCUMENT_SERIALIZE_CURVE_STYLE
const QString DOCUMENT_SERIALIZE_POINT_STYLE
log4cpp::Category * mainCat
Definition Logger.cpp:14
const QString INDENTATION_DELTA
PointShape
Definition PointShape.h:12
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
void setLineColor(ColorPalette lineColor)
Set method for line color in specified curve.
void setPointRadius(int radius)
Set method for curve point radius.
LineStyle lineStyle() const
Get method for LineStyle.
void setPointLineWidth(int width)
Set method for curve point perimeter line width.
QString loadXml(QXmlStreamReader &reader)
Load from serialized xml. Returns the curve name.
void setLineConnectAs(CurveConnectAs curveConnectAs)
Set method for connect as method for lines in specified curve.
void setLineWidth(int width)
Set method for line width in specified curve.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setPointStyle(const PointStyle &pointStyle)
Set method for PointStyle.
void saveXml(QXmlStreamWriter &writer, const QString &curveName) const
Serialize to xml.
void setPointColor(ColorPalette curveColor)
Set method curve point color in specified curve.
CurveStyle()
Default constructor.
PointStyle pointStyle() const
Get method for PointStyle.
void setLineStyle(const LineStyle &lineStyle)
Set method for LineStyle.
void setPointShape(PointShape shape)
Set method for curve point shape in specified curve.
Details for a specific Line.
Definition LineStyle.h:20
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
void setCurveConnectAs(CurveConnectAs curveConnectAs)
Set connect as.
void setWidth(int width)
Set width of line.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setPaletteColor(ColorPalette paletteColor)
Set method for line color.
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
Details for a specific Point.
Definition PointStyle.h:21
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
void setPaletteColor(ColorPalette paletteColor)
Set method for point color.
void setShape(PointShape shape)
Set method for point shape.
void setLineWidth(int width)
Set method for line width.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setRadius(unsigned int radius)
Set method for point radius.
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18