1 #include "CmdMediator.h"
2 #include "DocumentModelSegments.h"
3 #include "DocumentSerialize.h"
6 #include <QXmlStreamWriter>
9 const double DEFAULT_POINT_SEPARATION = 25;
10 const double DEFAULT_MIN_LENGTH = 2;
11 const double DEFAULT_LINE_WIDTH = 4;
12 const ColorPalette DEFAULT_LINE_COLOR (COLOR_PALETTE_GREEN);
15 m_pointSeparation (DEFAULT_POINT_SEPARATION),
16 m_minLength (DEFAULT_MIN_LENGTH),
17 m_fillCorners (false),
18 m_lineWidth (DEFAULT_LINE_WIDTH),
19 m_lineColor (DEFAULT_LINE_COLOR)
24 m_pointSeparation (document.modelSegments().pointSeparation()),
25 m_minLength (document.modelSegments().minLength()),
26 m_fillCorners (document.modelSegments().fillCorners()),
27 m_lineWidth (document.modelSegments().lineWidth()),
28 m_lineColor (document.modelSegments().lineColor())
33 m_pointSeparation (other.pointSeparation()),
34 m_minLength (other.minLength()),
35 m_fillCorners (other.fillCorners ()),
36 m_lineWidth (other.lineWidth()),
37 m_lineColor (other.lineColor())
69 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelSegments::loadXml";
74 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
75 (reader.name() != DOCUMENT_SERIALIZE_SEGMENTS)){
76 loadNextFromReader(reader);
84 reader.raiseError(
"Cannot read segment data");
95 return m_pointSeparation;
99 QTextStream &str)
const
101 str << indentation <<
"DocumentModelSegments\n";
103 indentation += INDENTATION_DELTA;
105 str << indentation <<
"pointSeparation=" << m_pointSeparation <<
"\n";
106 str << indentation <<
"minLength=" << m_minLength <<
"\n";
107 str << indentation <<
"fillCorners=" << (m_fillCorners ?
"true" :
"false") <<
"\n";
108 str << indentation <<
"lineWidth=" << m_lineWidth <<
"\n";
109 str << indentation <<
"lineColor=" << colorPaletteToString (m_lineColor) <<
"\n";
114 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelSegments::saveXml";
116 writer.writeStartElement(DOCUMENT_SERIALIZE_SEGMENTS);
117 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_POINT_SEPARATION, QString::number (m_pointSeparation));
118 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_MIN_LENGTH, QString::number (m_minLength));
119 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_FILL_CORNERS, m_fillCorners ?
120 DOCUMENT_SERIALIZE_BOOL_TRUE :
121 DOCUMENT_SERIALIZE_BOOL_FALSE);
122 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH, QString::number (m_lineWidth));
123 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR, QString::number (m_lineColor));
124 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR_STRING, colorPaletteToString (m_lineColor));
125 writer.writeEndElement();
ColorPalette lineColor() const
Get method for line color.
void setLineColor(ColorPalette lineColor)
Set method for line color.
void setMinLength(double minLength)
Set method for min length.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
double pointSeparation() const
Get method for point separation.
void setLineWidth(double lineWidth)
Set method for line width.
void setFillCorners(bool fillCorners)
Set method for fill corners.
Storage of one imported image and the data attached to that image.
double lineWidth() const
Get method for line width.
DocumentModelSegments()
Default constructor.
DocumentModelSegments & operator=(const DocumentModelSegments &other)
Assignment constructor.
double minLength() const
Get method for min length.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Model for DlgSettingsSegments and CmdSettingsSegments.
void setPointSeparation(double pointSeparation)
Set method for point separation.
bool fillCorners() const
Get method for fill corners.