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
16{
17}
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
Definition: ColorPalette.h:12
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.
Definition: CurveStyle.cpp:105
void setPointRadius(int radius)
Set method for curve point radius.
Definition: CurveStyle.cpp:135
LineStyle lineStyle() const
Get method for LineStyle.
Definition: CurveStyle.cpp:26
void setPointLineWidth(int width)
Set method for curve point perimeter line width.
Definition: CurveStyle.cpp:130
QString loadXml(QXmlStreamReader &reader)
Load from serialized xml. Returns the curve name.
Definition: CurveStyle.cpp:31
void setLineConnectAs(CurveConnectAs curveConnectAs)
Set method for connect as method for lines in specified curve.
Definition: CurveStyle.cpp:110
void setLineWidth(int width)
Set method for line width in specified curve.
Definition: CurveStyle.cpp:120
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: CurveStyle.cpp:80
void setPointStyle(const PointStyle &pointStyle)
Set method for PointStyle.
Definition: CurveStyle.cpp:145
void saveXml(QXmlStreamWriter &writer, const QString &curveName) const
Serialize to xml.
Definition: CurveStyle.cpp:93
void setPointColor(ColorPalette curveColor)
Set method curve point color in specified curve.
Definition: CurveStyle.cpp:125
CurveStyle()
Default constructor.
Definition: CurveStyle.cpp:15
PointStyle pointStyle() const
Get method for PointStyle.
Definition: CurveStyle.cpp:75
void setLineStyle(const LineStyle &lineStyle)
Set method for LineStyle.
Definition: CurveStyle.cpp:115
void setPointShape(PointShape shape)
Set method for curve point shape in specified curve.
Definition: CurveStyle.cpp:140
Details for a specific Line.
Definition: LineStyle.h:20
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
Definition: LineStyle.cpp:145
void setCurveConnectAs(CurveConnectAs curveConnectAs)
Set connect as.
Definition: LineStyle.cpp:158
void setWidth(int width)
Set width of line.
Definition: LineStyle.cpp:168
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: LineStyle.cpp:133
void setPaletteColor(ColorPalette paletteColor)
Set method for line color.
Definition: LineStyle.cpp:163
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
Definition: LineStyle.cpp:104
Details for a specific Point.
Definition: PointStyle.h:21
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
Definition: PointStyle.cpp:129
void setPaletteColor(ColorPalette paletteColor)
Set method for point color.
Definition: PointStyle.cpp:300
void setShape(PointShape shape)
Set method for point shape.
Definition: PointStyle.cpp:310
void setLineWidth(int width)
Set method for line width.
Definition: PointStyle.cpp:295
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: PointStyle.cpp:263
void setRadius(unsigned int radius)
Set method for point radius.
Definition: PointStyle.cpp:305
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
Definition: PointStyle.cpp:281
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18