7 #include "CmdMediator.h" 8 #include "DocumentModelGridDisplay.h" 9 #include "DocumentSerialize.h" 10 #include "EngaugeAssert.h" 13 #include <QTextStream> 14 #include "QtToString.h" 15 #include <QXmlStreamWriter> 18 const ColorPalette DEFAULT_COLOR = COLOR_PALETTE_BLACK;
22 m_disableX (GRID_COORD_DISABLE_COUNT),
27 m_disableY (GRID_COORD_DISABLE_COUNT),
32 m_paletteColor (DEFAULT_COLOR)
37 m_stable (document.modelGridDisplay().
stable()),
38 m_disableX (document.modelGridDisplay().
disableX()),
39 m_countX (document.modelGridDisplay().
countX()),
40 m_startX (document.modelGridDisplay().
startX()),
41 m_stepX (document.modelGridDisplay().
stepX()),
42 m_stopX (document.modelGridDisplay().
stopX()),
43 m_disableY (document.modelGridDisplay().
disableY()),
44 m_countY (document.modelGridDisplay().
countY()),
45 m_startY (document.modelGridDisplay().
startY()),
46 m_stepY (document.modelGridDisplay().
stepY()),
47 m_stopY (document.modelGridDisplay().
stopY()),
48 m_paletteColor (document.modelGridDisplay().
paletteColor())
57 m_stepX (other.
stepX()),
58 m_stopX (other.
stopX()),
62 m_stepY (other.
stepY()),
63 m_stopY (other.
stopY()),
74 m_stepX = other.
stepX();
75 m_stopX = other.
stopX();
79 m_stepY = other.
stepY();
80 m_stopY = other.
stopY();
108 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGridDisplay::loadXml";
112 QXmlStreamAttributes attributes = reader.attributes();
114 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE) &&
115 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X) &&
116 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X) &&
117 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X) &&
118 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X) &&
119 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X) &&
120 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y) &&
121 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y) &&
122 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y) &&
123 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y) &&
124 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y) &&
125 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR)) {
128 QString stableValue = attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE).toString();
130 setStable (stableValue == DOCUMENT_SERIALIZE_BOOL_TRUE);
131 setDisableX ((GridCoordDisable) attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X).toInt());
132 setCountX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X).toInt());
133 setStartX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X).toDouble());
134 setStepX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X).toDouble());
135 setStopX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X).toDouble());
136 setDisableY ((GridCoordDisable) attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y).toInt());
137 setCountY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y).toInt());
138 setStartY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y).toDouble());
139 setStepY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y).toDouble());
140 setStopY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y).toDouble());
141 setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR).toInt());
144 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
145 (reader.name() != DOCUMENT_SERIALIZE_GRID_DISPLAY)){
146 loadNextFromReader(reader);
147 if (reader.atEnd()) {
155 reader.raiseError (QObject::tr (
"Cannot read grid display data"));
161 return m_paletteColor;
165 QTextStream &str)
const 167 str << indentation <<
"DocumentModelGridDisplay\n";
169 indentation += INDENTATION_DELTA;
171 str << indentation <<
"stable=" << (m_stable ?
"true" :
"false") <<
"\n";
172 str << indentation <<
"disableX=" << m_disableX <<
"\n";
173 str << indentation <<
"countX=" << m_countX <<
"\n";
174 str << indentation <<
"startX=" << m_startX <<
"\n";
175 str << indentation <<
"stepX=" << m_stepX <<
"\n";
176 str << indentation <<
"stopX=" << m_stopX <<
"\n";
177 str << indentation <<
"disableY=" << m_disableY <<
"\n";
178 str << indentation <<
"countY=" << m_countY <<
"\n";
179 str << indentation <<
"startY=" << m_startY <<
"\n";
180 str << indentation <<
"stepY=" << m_stepY <<
"\n";
181 str << indentation <<
"stopY=" << m_stopY <<
"\n";
182 str << indentation <<
"color=" << colorPaletteToString (m_paletteColor) <<
"\n";
187 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGridDisplay::saveXml";
189 writer.writeStartElement(DOCUMENT_SERIALIZE_GRID_DISPLAY);
190 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE, m_stable ?
191 DOCUMENT_SERIALIZE_BOOL_TRUE :
192 DOCUMENT_SERIALIZE_BOOL_FALSE);
193 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X, QString::number (m_disableX));
194 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X, QString::number (m_countX));
195 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X, QString::number (m_startX));
196 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X, QString::number (m_stepX));
197 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X, QString::number (m_stopX));
198 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y, QString::number (m_disableY));
199 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y, QString::number (m_countY));
200 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y, QString::number (m_startY));
201 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y, QString::number (m_stepY));
202 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y, QString::number (m_stopY));
203 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR, QString::number (m_paletteColor));
204 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR_STRING, colorPaletteToString (m_paletteColor));
205 writer.writeEndElement();
void setStartX(double startX)
Set method for x grid line lower bound (inclusive).
GridCoordDisable disableY() const
Get method for y grid line disabled variable.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
void setCountY(unsigned int countY)
Set method for y grid line count.
void setStepX(double stepX)
Set method for x grid line increment.
unsigned int countX() const
Get method for x grid line count.
DocumentModelGridDisplay()
Default constructor.
void setStepY(double yStep)
Set method for y grid line increment.
bool stable() const
Get method for stable flag.
unsigned int countY() const
Get method for y grid line count.
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.
void setStable(bool stable)
Set method for stable flag.
GridCoordDisable disableX() const
Get method for x grid line disabled variable.
DocumentModelGridDisplay & operator=(const DocumentModelGridDisplay &other)
Assignment constructor.
void setStopX(double stopX)
Set method for x grid line upper bound (inclusive).
double stopY() const
Get method for y grid line upper bound (inclusive).
void setDisableX(GridCoordDisable disableX)
Set method for x grid line disabled variable.
double stopX() const
Get method for x grid line upper bound (inclusive).
ColorPalette paletteColor() const
Get method for color.
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
Storage of one imported image and the data attached to that image.
void setDisableY(GridCoordDisable disableY)
Set method for y grid line disabled variable.
double startY() const
Get method for y grid line lower bound (inclusive).
void setCountX(unsigned int countX)
Set method for x grid line count.
void setStartY(double yStart)
Set method for y grid line lower bound (inclusive).
double stepY() const
Get method for y grid line increment.
double startX() const
Get method for x grid line lower bound (inclusive).
double stepX() const
Get method for x grid line increment.
void setPaletteColor(ColorPalette paletteColor)
Set method for color.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.