7 #include "CmdMediator.h"
8 #include "DocumentModelPointMatch.h"
9 #include "DocumentSerialize.h"
12 #include <QTextStream>
13 #include <QXmlStreamWriter>
16 const double DEFAULT_MIN_POINT_SEPARATION = 20;
17 const double DEFAULT_MAX_POINT_SIZE = 48;
18 const ColorPalette DEFAULT_COLOR_ACCEPTED = COLOR_PALETTE_GREEN;
19 const ColorPalette DEFAULT_COLOR_CANDIDATE = COLOR_PALETTE_YELLOW;
20 const ColorPalette DEFAULT_COLOR_REJECTED = COLOR_PALETTE_RED;
23 m_minPointSeparation (DEFAULT_MIN_POINT_SEPARATION),
24 m_maxPointSize (DEFAULT_MAX_POINT_SIZE),
25 m_paletteColorAccepted (DEFAULT_COLOR_ACCEPTED),
26 m_paletteColorCandidate (DEFAULT_COLOR_CANDIDATE),
27 m_paletteColorRejected (DEFAULT_COLOR_REJECTED)
32 m_maxPointSize (document.modelPointMatch().maxPointSize()),
33 m_paletteColorAccepted (document.modelPointMatch().paletteColorAccepted()),
34 m_paletteColorCandidate (document.modelPointMatch().paletteColorCandidate()),
35 m_paletteColorRejected (document.modelPointMatch().paletteColorRejected())
40 m_maxPointSize (other.maxPointSize()),
41 m_paletteColorAccepted (other.paletteColorAccepted()),
42 m_paletteColorCandidate (other.paletteColorCandidate()),
43 m_paletteColorRejected (other.paletteColorRejected())
59 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelPointMatch::loadXml";
63 QXmlStreamAttributes attributes = reader.attributes();
65 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE) &&
66 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED) &&
67 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE) &&
68 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED)) {
70 setMaxPointSize (attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE).toDouble());
71 setPaletteColorAccepted ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED).toInt());
73 setPaletteColorRejected ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED).toInt());
76 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
77 (reader.name() != DOCUMENT_SERIALIZE_POINT_MATCH)){
78 loadNextFromReader(reader);
87 reader.raiseError (QObject::tr (
"Cannot read point match data"));
93 return m_maxPointSize;
98 return m_paletteColorAccepted;
103 return m_paletteColorCandidate;
108 return m_paletteColorRejected;
112 QTextStream &str)
const
114 str << indentation <<
"DocumentModelPointMatch\n";
116 indentation += INDENTATION_DELTA;
118 str << indentation <<
"minPointSeparation=" << m_minPointSeparation <<
"\n";
119 str << indentation <<
"maxPointSize=" << m_maxPointSize <<
"\n";
120 str << indentation <<
"colorAccepted=" << colorPaletteToString (m_paletteColorAccepted) <<
"\n";
121 str << indentation <<
"colorCandidate=" << colorPaletteToString (m_paletteColorCandidate) <<
"\n";
122 str << indentation <<
"colorRejected=" << colorPaletteToString (m_paletteColorRejected) <<
"\n";
127 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelPointMatch::saveXml";
129 writer.writeStartElement(DOCUMENT_SERIALIZE_POINT_MATCH);
130 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE, QString::number (m_maxPointSize));
131 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED, QString::number (m_paletteColorAccepted));
132 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED_STRING, colorPaletteToString (m_paletteColorAccepted));
133 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE, QString::number (m_paletteColorCandidate));
134 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE_STRING, colorPaletteToString (m_paletteColorCandidate));
135 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED, QString::number (m_paletteColorRejected));
136 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED_STRING, colorPaletteToString (m_paletteColorRejected));
137 writer.writeEndElement();
double maxPointSize() const
Get method for max point size.
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
void setPaletteColorCandidate(ColorPalette paletteColorCandidate)
Set method for candidate color.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
DocumentModelPointMatch & operator=(const DocumentModelPointMatch &other)
Assignment constructor.
void setMaxPointSize(double maxPointSize)
Set method for max point size.
DocumentModelPointMatch()
Default constructor.
Storage of one imported image and the data attached to that image.
void setPaletteColorRejected(ColorPalette paletteColorRejected)
Set method for rejected color.
ColorPalette paletteColorCandidate() const
Get method for candidate color.
ColorPalette paletteColorRejected() const
Get method for rejected color.
ColorPalette paletteColorAccepted() const
Get method for accepted color.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setPaletteColorAccepted(ColorPalette paletteColorAccepted)
Set method for accepted color.