Engauge Digitizer 2
Loading...
Searching...
No Matches
DocumentModelGridRemoval.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 "CmdMediator.h"
9#include "DocumentSerialize.h"
10#include "Logger.h"
11#include <QObject>
12#include <QTextStream>
13#include <QXmlStreamWriter>
14#include "Xml.h"
15
16const double CLOSE_DISTANCE_DEFAULT = 10.0;
17
18// These defaults should always be overwritten when Document coordinates are defined
19const int DEFAULT_COUNT = 2;
20const double DEFAULT_NON_COUNT = 0.0;
21
23 m_stable (false),
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)
36{
37}
38
40 double startY,
41 double stepX,
42 double stepY,
43 int countX,
44 int countY) :
45 m_stable (false),
46 m_removeDefinedGridLines (false),
47 m_closeDistance (CLOSE_DISTANCE_DEFAULT),
48 m_gridCoordDisableX (GRID_COORD_DISABLE_COUNT),
49 m_countX (countX),
50 m_startX (startX),
51 m_stepX (stepX),
52 m_stopX (startX + (countX - 1.0) * stepX),
53 m_gridCoordDisableY (GRID_COORD_DISABLE_COUNT),
54 m_countY (countY),
55 m_startY (startY),
56 m_stepY (stepY),
57 m_stopY (startY + (countY - 1.0) * stepY)
58{
59}
60
62 m_stable (document.modelGridRemoval().stable()),
63 m_removeDefinedGridLines (document.modelGridRemoval().removeDefinedGridLines()),
64 m_closeDistance (document.modelGridRemoval().closeDistance()),
65 m_gridCoordDisableX (document.modelGridRemoval().gridCoordDisableX()),
66 m_countX (document.modelGridRemoval().countX()),
67 m_startX (document.modelGridRemoval().startX()),
68 m_stepX (document.modelGridRemoval().stepX()),
69 m_stopX (document.modelGridRemoval().stopX()),
70 m_gridCoordDisableY (document.modelGridRemoval().gridCoordDisableY()),
71 m_countY (document.modelGridRemoval().countY()),
72 m_startY (document.modelGridRemoval().startY()),
73 m_stepY (document.modelGridRemoval().stepY()),
74 m_stopY (document.modelGridRemoval().stopY())
75{
76}
77
79 m_stable (other.stable()),
80 m_removeDefinedGridLines (other.removeDefinedGridLines()),
81 m_closeDistance (other.closeDistance()),
82 m_gridCoordDisableX (other.gridCoordDisableX()),
83 m_countX (other.countX()),
84 m_startX (other.startX()),
85 m_stepX (other.stepX()),
86 m_stopX (other.stopX()),
87 m_gridCoordDisableY (other.gridCoordDisableX()),
88 m_countY (other.countY()),
89 m_startY (other.startY()),
90 m_stepY (other.stepY()),
91 m_stopY (other.stopY())
92{
93}
94
96{
97 m_stable = other.stable();
98 m_removeDefinedGridLines = other.removeDefinedGridLines();
99 m_closeDistance = other.closeDistance();
100 m_gridCoordDisableX = other.gridCoordDisableX();
101 m_countX = other.countX();
102 m_startX = other.startX();
103 m_stepX = other.stepX();
104 m_stopX = other.stopX();
105 m_gridCoordDisableY = other.gridCoordDisableY();
106 m_countY = other.countY();
107 m_startY = other.startY();
108 m_stepY = other.stepY();
109 m_stopY = other.stopY();
110
111 return *this;
112}
113
115{
116 return m_closeDistance;
117}
118
120{
121 return m_countX;
122}
123
125{
126 return m_countY;
127}
128
130{
131 return m_gridCoordDisableX;
132}
133
135{
136 return m_gridCoordDisableY;
137}
138
140{
141 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGridRemoval::loadXml";
142
143 bool success = true;
144
146
160
161 // Boolean values
164
178
179 // Read until end of this subtree
180 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
183 if (reader.atEnd()) {
184 success = false;
185 break;
186 }
187 }
188 }
189
190 if (!success) {
191 reader.raiseError (QObject::tr ("Cannot read grid removal data"));
192 }
193}
194
196 QTextStream &str) const
197{
198 str << indentation << "DocumentModelGridRemoval\n";
199
201
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";
215}
216
218{
219 return m_removeDefinedGridLines;
220}
221
223{
224 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGridRemoval::saveXml";
225
226 writer.writeStartElement(DOCUMENT_SERIALIZE_GRID_REMOVAL);
227 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_STABLE, m_stable ?
230 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_REMOVAL_DEFINED_GRID_LINES, m_removeDefinedGridLines ?
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));
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));
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));
246
247 writer.writeEndElement();
248}
249
251{
252 m_closeDistance = closeDistance;
253}
254
256{
257 m_countX = countX;
258}
259
261{
262 m_countY = countY;
263}
264
269
274
276{
277 m_removeDefinedGridLines = removeDefinedGridLines;
278}
279
281{
282 m_stable = true;
283}
284
286{
287 m_stable = stable;
288}
289
291{
292 m_startX = startX;
293}
294
296{
297 m_startY = startY;
298}
299
301{
302 m_stepX = stepX;
303}
304
306{
307 m_stepY = stepY;
308}
309
311{
312 m_stopX = stopX;
313}
314
316{
317 m_stopY = stopY;
318}
319
321{
322 return m_stable;
323}
324
326{
327 return m_startX;
328}
329
331{
332 return m_startY;
333}
334
336{
337 return m_stepX;
338}
339
341{
342 return m_stepY;
343}
344
346{
347 return m_stopX;
348}
349
351{
352 return m_stopY;
353}
const int INNER_RADIUS_MIN
const double DEFAULT_NON_COUNT
const double CLOSE_DISTANCE_DEFAULT
const int DEFAULT_COUNT
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_STABLE
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_X
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_STEP_Y
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_X
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_START_X
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_X
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_Y
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_Y_STRING
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_CLOSE_DISTANCE
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_START_Y
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_DEFINED_GRID_LINES
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_STOP_Y
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_COUNT_Y
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_X
const QString DOCUMENT_SERIALIZE_GRID_REMOVAL_COORD_DISABLE_X_STRING
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
QString gridCoordDisableToString(GridCoordDisable gridCoordDisable)
GridCoordDisable
@ GRID_COORD_DISABLE_COUNT
log4cpp::Category * mainCat
Definition Logger.cpp:14
const QString INDENTATION_DELTA
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
double closeDistance() const
Get method for close distance.
GridCoordDisable gridCoordDisableX() const
Get method for x coord parameter to disable.
bool removeDefinedGridLines() const
Get method for removing defined grid lines.
double stopX() const
Get method for x stop.
GridCoordDisable gridCoordDisableY() const
Get method for y coord parameter to disable.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
void setCloseDistance(double closeDistance)
Set method for close distance.
void setStopY(double stopY)
Set method for y stop.
double startX() const
Get method for x start.
void setCountX(int countX)
Set method for x count.
double stopY() const
Get method for y stop.
void setGridCoordDisableY(GridCoordDisable gridCoordDisable)
Set method for y coord parameter to disable.
double stepX() const
Get method for x step.
DocumentModelGridRemoval & operator=(const DocumentModelGridRemoval &other)
Assignment constructor.
void setStable()
Set the stable flag to true. This public version has no argument since it cannot be undone.
void setGridCoordDisableX(GridCoordDisable gridCoordDisable)
Set method for x coord parameter to disable.
void setStepX(double stepX)
Set method for x step.
void setStopX(double stopX)
Set method for x stop.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setStartY(double startY)
Set method for y start.
double stepY() const
Get method for y step.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
int countY() const
Get method for y count.
int countX() const
Get method for x count.
double startY() const
Get method for y start.
void setRemoveDefinedGridLines(bool removeDefinedGridLines)
Set method for removing defined grid lines.
bool stable() const
Get method for stable flag.
void setStepY(double stepY)
Set method for y step.
DocumentModelGridRemoval()
Default constructor.
void setStartX(double startX)
Set method for x start.
void setCountY(int countY)
Set method for y count.
Storage of one imported image and the data attached to that image.
Definition Document.h:42
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18