7 #include "CmdMediator.h" 8 #include "DocumentModelGridRemoval.h" 9 #include "DocumentSerialize.h" 12 #include <QTextStream> 13 #include <QXmlStreamWriter> 16 const double CLOSE_DISTANCE_DEFAULT = 10.0;
19 const int DEFAULT_COUNT = 2;
20 const double DEFAULT_NON_COUNT = 0.0;
24 m_removeDefinedGridLines (false),
25 m_closeDistance (CLOSE_DISTANCE_DEFAULT),
26 m_gridCoordDisableX (GRID_COORD_DISABLE_COUNT),
27 m_countX (DEFAULT_COUNT),
28 m_startX (DEFAULT_NON_COUNT),
29 m_stepX (DEFAULT_NON_COUNT),
30 m_stopX (DEFAULT_NON_COUNT),
31 m_gridCoordDisableY (GRID_COORD_DISABLE_COUNT),
32 m_countY (DEFAULT_COUNT),
33 m_startY (DEFAULT_NON_COUNT),
34 m_stepY (DEFAULT_NON_COUNT),
35 m_stopY (DEFAULT_NON_COUNT)
46 m_removeDefinedGridLines (false),
47 m_closeDistance (CLOSE_DISTANCE_DEFAULT),
48 m_gridCoordDisableX (GRID_COORD_DISABLE_COUNT),
52 m_stopX (startX + (countX - 1.0) * stepX),
53 m_gridCoordDisableY (GRID_COORD_DISABLE_COUNT),
57 m_stopY (startY + (countY - 1.0) * stepY)
62 m_stable (document.modelGridRemoval().
stable()),
64 m_closeDistance (document.modelGridRemoval().
closeDistance()),
66 m_countX (document.modelGridRemoval().
countX()),
67 m_startX (document.modelGridRemoval().
startX()),
68 m_stepX (document.modelGridRemoval().
stepX()),
69 m_stopX (document.modelGridRemoval().
stopX()),
71 m_countY (document.modelGridRemoval().
countY()),
72 m_startY (document.modelGridRemoval().
startY()),
73 m_stepY (document.modelGridRemoval().
stepY()),
74 m_stopY (document.modelGridRemoval().
stopY())
85 m_stepX (other.
stepX()),
86 m_stopX (other.
stopX()),
90 m_stepY (other.
stepY()),
91 m_stopY (other.
stopY())
101 m_countX = other.
countX();
102 m_startX = other.
startX();
103 m_stepX = other.
stepX();
104 m_stopX = other.
stopX();
106 m_countY = other.
countY();
107 m_startY = other.
startY();
108 m_stepY = other.
stepY();
109 m_stopY = other.
stopY();
116 return m_closeDistance;
131 return m_gridCoordDisableX;
136 return m_gridCoordDisableY;
141 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGridRemoval::loadXml";
145 QXmlStreamAttributes attributes = reader.attributes();
147 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STABLE) &&
148 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_DEFINED_GRID_LINES) &&
149 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_CLOSE_DISTANCE) &&
150 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_X) &&
151 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_X) &&
152 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_START_X) &&
153 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_X) &&
154 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_X) &&
155 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_Y) &&
156 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_Y) &&
157 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_START_Y) &&
158 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_Y) &&
159 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_Y)) {
162 QString stableValue = attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_STABLE).toString();
163 QString definedValue = attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_DEFINED_GRID_LINES).toString();
165 setStable (stableValue == DOCUMENT_SERIALIZE_BOOL_TRUE);
167 setCloseDistance (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_CLOSE_DISTANCE).toDouble());
168 setGridCoordDisableX ((GridCoordDisable) attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_X).toInt());
169 setCountX (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_X).toInt());
170 setStartX (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_START_X).toDouble());
171 setStepX (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_X).toDouble());
172 setStopX (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_X).toDouble());
173 setGridCoordDisableY ((GridCoordDisable) attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_Y).toInt());
174 setCountY (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_Y).toInt());
175 setStartY (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_START_Y).toDouble());
176 setStepY (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_Y).toDouble());
177 setStopY (attributes.value(DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_Y).toDouble());
180 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
181 (reader.name() != DOCUMENT_SERIALIZE_GRID_REMOVAL)){
182 loadNextFromReader(reader);
183 if (reader.atEnd()) {
191 reader.raiseError (QObject::tr (
"Cannot read grid removal data"));
196 QTextStream &str)
const 198 str << indentation <<
"DocumentModelGridRemoval\n";
200 indentation += INDENTATION_DELTA;
202 str << indentation <<
"stable=" << (m_stable ?
"true" :
"false") <<
"\n";
203 str << indentation <<
"removeDefinedGridLines=" << (m_removeDefinedGridLines ?
"true" :
"false") <<
"\n";
204 str << indentation <<
"closeDistance=" << m_closeDistance <<
"\n";
205 str << indentation <<
"gridCoordDisableX=" << gridCoordDisableToString (m_gridCoordDisableX) <<
"\n";
206 str << indentation <<
"countX=" << m_countX <<
"\n";
207 str << indentation <<
"startX=" << m_startX <<
"\n";
208 str << indentation <<
"stepX=" << m_stepX <<
"\n";
209 str << indentation <<
"stopX=" << m_stopX <<
"\n";
210 str << indentation <<
"gridCoordDisableY=" << gridCoordDisableToString (m_gridCoordDisableY) <<
"\n";
211 str << indentation <<
"countY=" << m_countY <<
"\n";
212 str << indentation <<
"startY=" << m_startY <<
"\n";
213 str << indentation <<
"stepY=" << m_stepY <<
"\n";
214 str << indentation <<
"stopY=" << m_stopY <<
"\n";
219 return m_removeDefinedGridLines;
224 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGridRemoval::saveXml";
226 writer.writeStartElement(DOCUMENT_SERIALIZE_GRID_REMOVAL);
227 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STABLE, m_stable ?
228 DOCUMENT_SERIALIZE_BOOL_TRUE :
229 DOCUMENT_SERIALIZE_BOOL_FALSE);
230 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_DEFINED_GRID_LINES, m_removeDefinedGridLines ?
231 DOCUMENT_SERIALIZE_BOOL_TRUE :
232 DOCUMENT_SERIALIZE_BOOL_FALSE);
233 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_CLOSE_DISTANCE, QString::number (m_closeDistance));
234 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_X, QString::number (m_gridCoordDisableX));
235 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_X_STRING, gridCoordDisableToString (m_gridCoordDisableX));
236 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_X, QString::number (m_countX));
237 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_START_X, QString::number (m_startX));
238 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_X, QString::number (m_stepX));
239 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_X, QString::number (m_stopX));
240 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_Y, QString::number (m_gridCoordDisableY));
241 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_Y_STRING, gridCoordDisableToString (m_gridCoordDisableY));
242 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_Y, QString::number (m_countY));
243 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_START_Y, QString::number (m_startY));
244 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_Y, QString::number (m_stepY));
245 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_Y, QString::number (m_stopY));
247 writer.writeEndElement();
267 m_gridCoordDisableX = gridCoordDisable;
272 m_gridCoordDisableY = gridCoordDisable;
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 saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
double closeDistance() const
Get method for close distance.
bool stable() const
Get method for stable flag.
DocumentModelGridRemoval()
Default constructor.
GridCoordDisable gridCoordDisableX() const
Get method for x coord parameter to disable.
double stopY() const
Get method for y stop.
void setCloseDistance(double closeDistance)
Set method for close distance.
double stopX() const
Get method for x stop.
int countY() const
Get method for y count.
void setCountX(int countX)
Set method for x count.
double startY() const
Get method for y start.
void setStopY(double stopY)
Set method for y stop.
void setStartY(double startY)
Set method for y start.
void setStepY(double stepY)
Set method for y step.
void setStartX(double startX)
Set method for x start.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
double stepX() const
Get method for x step.
DocumentModelGridRemoval & operator=(const DocumentModelGridRemoval &other)
Assignment constructor.
void setCountY(int countY)
Set method for y count.
bool removeDefinedGridLines() const
Get method for removing defined grid lines.
void setStepX(double stepX)
Set method for x step.
void setRemoveDefinedGridLines(bool removeDefinedGridLines)
Set method for removing defined grid lines.
Storage of one imported image and the data attached to that image.
void setGridCoordDisableY(GridCoordDisable gridCoordDisable)
Set method for y coord parameter to disable.
void setGridCoordDisableX(GridCoordDisable gridCoordDisable)
Set method for x coord parameter to disable.
int countX() const
Get method for x count.
void setStable()
Set the stable flag to true. This public version has no argument since it cannot be undone...
double startX() const
Get method for x start.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
GridCoordDisable gridCoordDisableY() const
Get method for y coord parameter to disable.
void setStopX(double stopX)
Set method for x stop.
double stepY() const
Get method for y step.