Engauge Digitizer 2
Loading...
Searching...
No Matches
DocumentModelGridDisplay Class Reference

Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay. More...

#include <DocumentModelGridDisplay.h>

Inheritance diagram for DocumentModelGridDisplay:
Inheritance graph
Collaboration diagram for DocumentModelGridDisplay:
Collaboration graph

Public Member Functions

 DocumentModelGridDisplay ()
 Default constructor.
 DocumentModelGridDisplay (const Document &document)
 Initial constructor from Document.
 DocumentModelGridDisplay (const DocumentModelGridDisplay &other)
 Copy constructor.
DocumentModelGridDisplayoperator= (const DocumentModelGridDisplay &other)
 Assignment constructor.
unsigned int countX () const
 Get method for x grid line count.
unsigned int countY () const
 Get method for y grid line count.
GridCoordDisable disableX () const
 Get method for x grid line disabled variable.
GridCoordDisable disableY () const
 Get method for y grid line disabled variable.
unsigned int lineWidth () const
 Get method for line width.
virtual void loadXml (QXmlStreamReader &reader)
 Load model from serialized xml.
ColorPalette paletteColor () const
 Get method for color.
void printStream (QString indentation, QTextStream &str) const
 Debugging method that supports print method of this class and printStream method of some other class(es)
virtual void saveXml (QXmlStreamWriter &writer) const
 Save entire model as xml into stream.
void setCountX (unsigned int countX)
 Set method for x grid line count.
void setCountY (unsigned int countY)
 Set method for y grid line count.
void setDisableX (GridCoordDisable disableX)
 Set method for x grid line disabled variable.
void setDisableY (GridCoordDisable disableY)
 Set method for y grid line disabled variable.
void setLineWidth (unsigned int lineWidth)
 Set method for line width.
void setPaletteColor (ColorPalette paletteColor)
 Set method for color.
void setStable (bool stable)
 Set method for stable flag.
void setStartX (double startX)
 Set method for x grid line lower bound (inclusive).
void setStartY (double yStart)
 Set method for y grid line lower bound (inclusive).
void setStepX (double stepX)
 Set method for x grid line increment.
void setStepY (double yStep)
 Set method for y grid line increment.
void setStopX (double stopX)
 Set method for x grid line upper bound (inclusive).
void setStopY (double yStop)
 Set method for y grid line upper bound (inclusive).
bool stable () const
 Get method for stable flag.
double startX () const
 Get method for x grid line lower bound (inclusive).
double startY () const
 Get method for y grid line lower bound (inclusive).
double stepX () const
 Get method for x grid line increment.
double stepY () const
 Get method for y grid line increment.
double stopX () const
 Get method for x grid line upper bound (inclusive).
double stopY () const
 Get method for y grid line upper bound (inclusive).
Public Member Functions inherited from DocumentModelAbstractBase
 DocumentModelAbstractBase ()
 Single constructor.
virtual ~DocumentModelAbstractBase ()
 Single destructor.

Detailed Description

Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.

External code is responsible for calculating the value of the disabled parameter using the values of the other non-disabled parameters, instead of using the current value of the disabled parameter

Definition at line 21 of file DocumentModelGridDisplay.h.

Constructor & Destructor Documentation

◆ DocumentModelGridDisplay() [1/3]

DocumentModelGridDisplay::DocumentModelGridDisplay ( )

Default constructor.

Definition at line 21 of file DocumentModelGridDisplay.cpp.

21 :
22 m_stable (false),
23 m_disableX (GRID_COORD_DISABLE_COUNT),
24 m_countX (2),
25 m_startX (0.0),
26 m_stepX (1.0),
27 m_stopX (1.0),
28 m_disableY (GRID_COORD_DISABLE_COUNT),
29 m_countY (2),
30 m_startY (0.0),
31 m_stepY (1.0),
32 m_stopY (1.0),
33 m_paletteColor (DEFAULT_COLOR),
34 m_lineWidth (DEFAULT_LINE_WIDTH)
35{
36}
const ColorPalette DEFAULT_COLOR
const int DEFAULT_LINE_WIDTH
@ GRID_COORD_DISABLE_COUNT

◆ DocumentModelGridDisplay() [2/3]

DocumentModelGridDisplay::DocumentModelGridDisplay ( const Document & document)

Initial constructor from Document.

Definition at line 38 of file DocumentModelGridDisplay.cpp.

38 :
39 m_stable (document.modelGridDisplay().stable()),
40 m_disableX (document.modelGridDisplay().disableX()),
41 m_countX (document.modelGridDisplay().countX()),
42 m_startX (document.modelGridDisplay().startX()),
43 m_stepX (document.modelGridDisplay().stepX()),
44 m_stopX (document.modelGridDisplay().stopX()),
45 m_disableY (document.modelGridDisplay().disableY()),
46 m_countY (document.modelGridDisplay().countY()),
47 m_startY (document.modelGridDisplay().startY()),
48 m_stepY (document.modelGridDisplay().stepY()),
49 m_stopY (document.modelGridDisplay().stopY()),
50 m_paletteColor (document.modelGridDisplay().paletteColor()),
51 m_lineWidth (document.modelGridDisplay().lineWidth())
52{
53}
GridCoordDisable disableY() const
Get method for y grid line disabled variable.
unsigned int countX() const
Get method for x grid line count.
double startX() const
Get method for x grid line lower bound (inclusive).
GridCoordDisable disableX() const
Get method for x grid line disabled variable.
unsigned int countY() const
Get method for y grid line count.
double stepX() const
Get method for x grid line increment.
double stopX() const
Get method for x grid line upper bound (inclusive).
double stopY() const
Get method for y grid line upper bound (inclusive).
bool stable() const
Get method for stable flag.
ColorPalette paletteColor() const
Get method for color.
double stepY() const
Get method for y grid line increment.
double startY() const
Get method for y grid line lower bound (inclusive).
unsigned int lineWidth() const
Get method for line width.
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
Definition Document.cpp:742

◆ DocumentModelGridDisplay() [3/3]

DocumentModelGridDisplay::DocumentModelGridDisplay ( const DocumentModelGridDisplay & other)

Copy constructor.

Definition at line 55 of file DocumentModelGridDisplay.cpp.

55 :
56 m_stable(other.stable()),
57 m_disableX (other.disableX()),
58 m_countX (other.countX()),
59 m_startX (other.startX()),
60 m_stepX (other.stepX()),
61 m_stopX (other.stopX()),
62 m_disableY (other.disableY()),
63 m_countY (other.countY()),
64 m_startY (other.startY()),
65 m_stepY (other.stepY()),
66 m_stopY (other.stopY()),
67 m_paletteColor (other.paletteColor()),
68 m_lineWidth (other.lineWidth())
69{
70}

Member Function Documentation

◆ countX()

unsigned int DocumentModelGridDisplay::countX ( ) const

Get method for x grid line count.

Definition at line 91 of file DocumentModelGridDisplay.cpp.

92{
93 return m_countX;
94}

◆ countY()

unsigned int DocumentModelGridDisplay::countY ( ) const

Get method for y grid line count.

Definition at line 96 of file DocumentModelGridDisplay.cpp.

97{
98 return m_countY;
99}

◆ disableX()

GridCoordDisable DocumentModelGridDisplay::disableX ( ) const

Get method for x grid line disabled variable.

Definition at line 101 of file DocumentModelGridDisplay.cpp.

102{
103 return m_disableX;
104}

◆ disableY()

GridCoordDisable DocumentModelGridDisplay::disableY ( ) const

Get method for y grid line disabled variable.

Definition at line 106 of file DocumentModelGridDisplay.cpp.

107{
108 return m_disableY;
109}

◆ lineWidth()

unsigned int DocumentModelGridDisplay::lineWidth ( ) const

Get method for line width.

Definition at line 111 of file DocumentModelGridDisplay.cpp.

112{
113 return m_lineWidth;
114}

◆ loadXml()

void DocumentModelGridDisplay::loadXml ( QXmlStreamReader & reader)
virtual

Load model from serialized xml.

Implements DocumentModelAbstractBase.

Definition at line 116 of file DocumentModelGridDisplay.cpp.

117{
118 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGridDisplay::loadXml";
119
120 bool success = true;
121
122 QXmlStreamAttributes attributes = reader.attributes();
123
124 // Line width is optional
125 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE) &&
126 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X) &&
127 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X) &&
128 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X) &&
129 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X) &&
130 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X) &&
131 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y) &&
132 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y) &&
133 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y) &&
134 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y) &&
135 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y) &&
136 attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR)) {
137
138 // Boolean values
139 QString stableValue = attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE).toString();
140
142 setDisableX (static_cast<GridCoordDisable> (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X).toInt()));
143 setCountX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X).toUInt());
144 setStartX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X).toDouble());
145 setStepX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X).toDouble());
146 setStopX (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X).toDouble());
147 setDisableY (static_cast<GridCoordDisable> (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y).toUInt()));
148 setCountY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y).toUInt());
149 setStartY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y).toDouble());
150 setStepY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y).toDouble());
151 setStopY (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y).toDouble());
152 setPaletteColor (static_cast<ColorPalette> (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR).toInt()));
153
154 // Optional values
155 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_LINE_WIDTH)) {
156 setLineWidth (attributes.value(DOCUMENT_SERIALIZE_GRID_DISPLAY_LINE_WIDTH).toUInt());
157 } else {
159 }
160
161 // Read until end of this subtree
162 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
163 (reader.name() != DOCUMENT_SERIALIZE_GRID_DISPLAY)){
164 loadNextFromReader(reader);
165 if (reader.atEnd()) {
166 success = false;
167 break;
168 }
169 }
170 }
171
172 if (!success) {
173 reader.raiseError (QObject::tr ("Cannot read grid display data"));
174 }
175}
ColorPalette
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_LINE_WIDTH
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
GridCoordDisable
log4cpp::Category * mainCat
Definition Logger.cpp:14
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
void setPaletteColor(ColorPalette paletteColor)
Set method for color.
void setStepX(double stepX)
Set method for x grid line increment.
void setStepY(double yStep)
Set method for y grid line increment.
void setStopX(double stopX)
Set method for x grid line upper bound (inclusive).
void setLineWidth(unsigned int lineWidth)
Set method for line width.
void setDisableX(GridCoordDisable disableX)
Set method for x grid line disabled variable.
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
void setDisableY(GridCoordDisable disableY)
Set method for y grid line disabled variable.
void setCountX(unsigned int countX)
Set method for x grid line count.
void setStartX(double startX)
Set method for x grid line lower bound (inclusive).
void setStable(bool stable)
Set method for stable flag.
void setStartY(double yStart)
Set method for y grid line lower bound (inclusive).
void setCountY(unsigned int countY)
Set method for y grid line count.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ operator=()

DocumentModelGridDisplay & DocumentModelGridDisplay::operator= ( const DocumentModelGridDisplay & other)

Assignment constructor.

Definition at line 72 of file DocumentModelGridDisplay.cpp.

73{
74 m_stable = other.stable();
75 m_disableX = other.disableX();
76 m_countX = other.countX();
77 m_startX = other.startX();
78 m_stepX = other.stepX();
79 m_stopX = other.stopX();
80 m_disableY = other.disableY();
81 m_countY = other.countY();
82 m_startY = other.startY();
83 m_stepY = other.stepY();
84 m_stopY = other.stopY();
85 m_paletteColor = other.paletteColor();
86 m_lineWidth = other.lineWidth();
87
88 return *this;
89}

◆ paletteColor()

ColorPalette DocumentModelGridDisplay::paletteColor ( ) const

Get method for color.

Definition at line 177 of file DocumentModelGridDisplay.cpp.

178{
179 return m_paletteColor;
180}

◆ printStream()

void DocumentModelGridDisplay::printStream ( QString indentation,
QTextStream & str ) const

Debugging method that supports print method of this class and printStream method of some other class(es)

Definition at line 182 of file DocumentModelGridDisplay.cpp.

184{
185 str << indentation << "DocumentModelGridDisplay\n";
186
187 indentation += INDENTATION_DELTA;
188
189 str << indentation << "stable=" << (m_stable ? "true" : "false") << "\n";
190 str << indentation << "disableX=" << m_disableX << "\n";
191 str << indentation << "countX=" << m_countX << "\n";
192 str << indentation << "startX=" << m_startX << "\n";
193 str << indentation << "stepX=" << m_stepX << "\n";
194 str << indentation << "stopX=" << m_stopX << "\n";
195 str << indentation << "disableY=" << m_disableY << "\n";
196 str << indentation << "countY=" << m_countY << "\n";
197 str << indentation << "startY=" << m_startY << "\n";
198 str << indentation << "stepY=" << m_stepY << "\n";
199 str << indentation << "stopY=" << m_stopY << "\n";
200 str << indentation << "color=" << colorPaletteToString (m_paletteColor) << "\n";
201 str << indentation << "lineWidth=" << m_lineWidth << "\n";
202}
QString colorPaletteToString(ColorPalette colorPalette)
const QString INDENTATION_DELTA

◆ saveXml()

void DocumentModelGridDisplay::saveXml ( QXmlStreamWriter & writer) const
virtual

Save entire model as xml into stream.

Implements DocumentModelAbstractBase.

Definition at line 204 of file DocumentModelGridDisplay.cpp.

205{
206 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGridDisplay::saveXml";
207
208 writer.writeStartElement(DOCUMENT_SERIALIZE_GRID_DISPLAY);
209 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STABLE, m_stable ?
212 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_X, QString::number (m_disableX));
213 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_X, QString::number (m_countX));
214 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_X, QString::number (m_startX));
215 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_X, QString::number (m_stepX));
216 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_X, QString::number (m_stopX));
217 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_DISABLE_Y, QString::number (m_disableY));
218 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COUNT_Y, QString::number (m_countY));
219 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_START_Y, QString::number (m_startY));
220 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STEP_Y, QString::number (m_stepY));
221 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_STOP_Y, QString::number (m_stopY));
222 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR, QString::number (m_paletteColor));
223 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR_STRING, colorPaletteToString (m_paletteColor));
224 writer.writeAttribute(DOCUMENT_SERIALIZE_GRID_DISPLAY_LINE_WIDTH, QString::number (m_lineWidth));
225 writer.writeEndElement();
226}
const QString DOCUMENT_SERIALIZE_GRID_DISPLAY_COLOR_STRING
const QString DOCUMENT_SERIALIZE_BOOL_FALSE

◆ setCountX()

void DocumentModelGridDisplay::setCountX ( unsigned int countX)

Set method for x grid line count.

Definition at line 228 of file DocumentModelGridDisplay.cpp.

229{
230 m_countX = countX;
231}

◆ setCountY()

void DocumentModelGridDisplay::setCountY ( unsigned int countY)

Set method for y grid line count.

Definition at line 233 of file DocumentModelGridDisplay.cpp.

234{
235 m_countY = countY;
236}

◆ setDisableX()

void DocumentModelGridDisplay::setDisableX ( GridCoordDisable disableX)

Set method for x grid line disabled variable.

Definition at line 238 of file DocumentModelGridDisplay.cpp.

239{
240 m_disableX = disableX;
241}

◆ setDisableY()

void DocumentModelGridDisplay::setDisableY ( GridCoordDisable disableY)

Set method for y grid line disabled variable.

Definition at line 243 of file DocumentModelGridDisplay.cpp.

244{
245 m_disableY = disableY;
246}

◆ setLineWidth()

void DocumentModelGridDisplay::setLineWidth ( unsigned int lineWidth)

Set method for line width.

Definition at line 248 of file DocumentModelGridDisplay.cpp.

249{
250 m_lineWidth = lineWidth;
251}

◆ setPaletteColor()

void DocumentModelGridDisplay::setPaletteColor ( ColorPalette paletteColor)

Set method for color.

Definition at line 253 of file DocumentModelGridDisplay.cpp.

254{
255 m_paletteColor = paletteColor;
256}

◆ setStable()

void DocumentModelGridDisplay::setStable ( bool stable)

Set method for stable flag.

Definition at line 258 of file DocumentModelGridDisplay.cpp.

259{
260 m_stable = stable;
261}

◆ setStartX()

void DocumentModelGridDisplay::setStartX ( double startX)

Set method for x grid line lower bound (inclusive).

Definition at line 263 of file DocumentModelGridDisplay.cpp.

264{
265 m_startX = startX;
266}

◆ setStartY()

void DocumentModelGridDisplay::setStartY ( double yStart)

Set method for y grid line lower bound (inclusive).

Definition at line 268 of file DocumentModelGridDisplay.cpp.

269{
270 m_startY = startY;
271}

◆ setStepX()

void DocumentModelGridDisplay::setStepX ( double stepX)

Set method for x grid line increment.

Definition at line 273 of file DocumentModelGridDisplay.cpp.

274{
275 m_stepX = stepX;
276}

◆ setStepY()

void DocumentModelGridDisplay::setStepY ( double yStep)

Set method for y grid line increment.

Definition at line 278 of file DocumentModelGridDisplay.cpp.

279{
280 m_stepY = stepY;
281}

◆ setStopX()

void DocumentModelGridDisplay::setStopX ( double stopX)

Set method for x grid line upper bound (inclusive).

Definition at line 283 of file DocumentModelGridDisplay.cpp.

284{
285 m_stopX = stopX;
286}

◆ setStopY()

void DocumentModelGridDisplay::setStopY ( double yStop)

Set method for y grid line upper bound (inclusive).

Definition at line 288 of file DocumentModelGridDisplay.cpp.

289{
290 m_stopY = stopY;
291}

◆ stable()

bool DocumentModelGridDisplay::stable ( ) const

Get method for stable flag.

The flag is false to let the settings get automatically updated, until the user selects settings - at which point the stable flag is set to true

Definition at line 293 of file DocumentModelGridDisplay.cpp.

294{
295 return m_stable;
296}

◆ startX()

double DocumentModelGridDisplay::startX ( ) const

Get method for x grid line lower bound (inclusive).

Definition at line 298 of file DocumentModelGridDisplay.cpp.

299{
300 return m_startX;
301}

◆ startY()

double DocumentModelGridDisplay::startY ( ) const

Get method for y grid line lower bound (inclusive).

Definition at line 303 of file DocumentModelGridDisplay.cpp.

304{
305 return m_startY;
306}

◆ stepX()

double DocumentModelGridDisplay::stepX ( ) const

Get method for x grid line increment.

Definition at line 308 of file DocumentModelGridDisplay.cpp.

309{
310 return m_stepX;
311}

◆ stepY()

double DocumentModelGridDisplay::stepY ( ) const

Get method for y grid line increment.

Definition at line 313 of file DocumentModelGridDisplay.cpp.

314{
315 return m_stepY;
316}

◆ stopX()

double DocumentModelGridDisplay::stopX ( ) const

Get method for x grid line upper bound (inclusive).

Definition at line 318 of file DocumentModelGridDisplay.cpp.

319{
320 return m_stopX;
321}

◆ stopY()

double DocumentModelGridDisplay::stopY ( ) const

Get method for y grid line upper bound (inclusive).

Definition at line 323 of file DocumentModelGridDisplay.cpp.

324{
325 return m_stopY;
326}

The documentation for this class was generated from the following files: