1 #include "CmdMediator.h"
2 #include "DocumentModelPointMatch.h"
3 #include "DocumentSerialize.h"
6 #include <QXmlStreamWriter>
9 const double DEFAULT_MIN_POINT_SEPARATION = 20;
10 const double DEFAULT_MAX_POINT_SIZE = 48;
11 const ColorPalette DEFAULT_COLOR_ACCEPTED = COLOR_PALETTE_GREEN;
12 const ColorPalette DEFAULT_COLOR_CANDIDATE = COLOR_PALETTE_YELLOW;
13 const ColorPalette DEFAULT_COLOR_REJECTED = COLOR_PALETTE_RED;
16 m_minPointSeparation (DEFAULT_MIN_POINT_SEPARATION),
17 m_maxPointSize (DEFAULT_MAX_POINT_SIZE),
18 m_paletteColorAccepted (DEFAULT_COLOR_ACCEPTED),
19 m_paletteColorCandidate (DEFAULT_COLOR_CANDIDATE),
20 m_paletteColorRejected (DEFAULT_COLOR_REJECTED)
25 m_maxPointSize (document.modelPointMatch().maxPointSize()),
26 m_paletteColorAccepted (document.modelPointMatch().paletteColorAccepted()),
27 m_paletteColorCandidate (document.modelPointMatch().paletteColorCandidate()),
28 m_paletteColorRejected (document.modelPointMatch().paletteColorRejected())
33 m_maxPointSize (other.maxPointSize()),
34 m_paletteColorAccepted (other.paletteColorAccepted()),
35 m_paletteColorCandidate (other.paletteColorCandidate()),
36 m_paletteColorRejected (other.paletteColorRejected())
52 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelPointMatch::loadXml";
56 QXmlStreamAttributes attributes = reader.attributes();
58 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE) &&
59 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED) &&
60 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE) &&
61 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED)) {
63 setMaxPointSize (attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE).toDouble());
64 setPaletteColorAccepted ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED).toInt());
66 setPaletteColorRejected ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED).toInt());
69 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
70 (reader.name() != DOCUMENT_SERIALIZE_POINT_MATCH)){
71 loadNextFromReader(reader);
80 reader.raiseError (
"Cannot read point match data");
86 return m_maxPointSize;
91 return m_paletteColorAccepted;
96 return m_paletteColorCandidate;
101 return m_paletteColorRejected;
105 QTextStream &str)
const
107 str << indentation <<
"DocumentModelPointMatch\n";
109 indentation += INDENTATION_DELTA;
111 str << indentation <<
"minPointSeparation=" << m_minPointSeparation <<
"\n";
112 str << indentation <<
"maxPointSize=" << m_maxPointSize <<
"\n";
113 str << indentation <<
"colorAccepted=" << colorPaletteToString (m_paletteColorAccepted) <<
"\n";
114 str << indentation <<
"colorCandidate=" << colorPaletteToString (m_paletteColorCandidate) <<
"\n";
115 str << indentation <<
"colorRejected=" << colorPaletteToString (m_paletteColorRejected) <<
"\n";
120 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelPointMatch::saveXml";
122 writer.writeStartElement(DOCUMENT_SERIALIZE_POINT_MATCH);
123 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE, QString::number (m_maxPointSize));
124 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED, QString::number (m_paletteColorAccepted));
125 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED_STRING, colorPaletteToString (m_paletteColorAccepted));
126 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE, QString::number (m_paletteColorCandidate));
127 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE_STRING, colorPaletteToString (m_paletteColorCandidate));
128 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED, QString::number (m_paletteColorRejected));
129 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED_STRING, colorPaletteToString (m_paletteColorRejected));
130 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.