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

Model for managing the coordinate values corresponding Guidelines. More...

#include <DocumentModelGuideline.h>

Inheritance diagram for DocumentModelGuideline:
Inheritance graph
Collaboration diagram for DocumentModelGuideline:
Collaboration graph

Public Member Functions

 DocumentModelGuideline ()
 Default constructor.
 DocumentModelGuideline (const Document &document)
 Initial constructor from Document.
 DocumentModelGuideline (const DocumentModelGuideline &other)
 Copy constructor.
DocumentModelGuidelineoperator= (const DocumentModelGuideline &other)
 Assignment constructor.
double creationCircleRadius () const
 Get method for creation circle radius in pixels.
ColorPalette lineColor () const
 Get method for line color.
double lineWidthActive () const
 Get method for line width when active.
double lineWidthInactive () const
 Get method for line width when inactive.
virtual void loadXml (QXmlStreamReader &reader)
 Load model from serialized xml.
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 setCreationCircleRadius (double radius)
 Set method for creation circle radius in pixels.
void setLineColor (ColorPalette lineColor)
 Set method for line color.
void setLineWidthActive (double lineWidth)
 Set method for line width when active.
void setLineWidthInactive (double lineWidth)
 Set method for line width when inactive.
void setValuesX (const GuidelineValues &valuesX)
 Set method for x/t values.
void setValuesY (const GuidelineValues &valuesY)
 Set method for y/r values.
GuidelineValues valuesX () const
 Get method for x/t values.
GuidelineValues valuesY () const
 Get method for y/r values.
Public Member Functions inherited from DocumentModelAbstractBase
 DocumentModelAbstractBase ()
 Single constructor.
virtual ~DocumentModelAbstractBase ()
 Single destructor.

Detailed Description

Model for managing the coordinate values corresponding Guidelines.

The strategy for transition between cartesian and polar reference frames is to discard the old Guideline values since there is no intuitive mapping between the two sets

Definition at line 21 of file DocumentModelGuideline.h.

Constructor & Destructor Documentation

◆ DocumentModelGuideline() [1/3]

DocumentModelGuideline::DocumentModelGuideline ( )

Default constructor.

Definition at line 23 of file DocumentModelGuideline.cpp.

23 :
24 m_creationCircleRadius (DEFAULT_CREATION_CIRCLE_RADIUS),
25 m_lineColor (DEFAULT_LINE_COLOR),
26 m_lineWidthActive (DEFAULT_LINE_WIDTH_ACTIVE),
27 m_lineWidthInactive (DEFAULT_LINE_WIDTH_INACTIVE)
28{
29}
const ColorPalette DEFAULT_LINE_COLOR
const double DEFAULT_LINE_WIDTH_ACTIVE
const double DEFAULT_LINE_WIDTH_INACTIVE
const double DEFAULT_CREATION_CIRCLE_RADIUS

◆ DocumentModelGuideline() [2/3]

DocumentModelGuideline::DocumentModelGuideline ( const Document & document)

Initial constructor from Document.

Definition at line 31 of file DocumentModelGuideline.cpp.

31 :
32 m_valuesX (document.modelGuideline().valuesX ()),
33 m_valuesY (document.modelGuideline().valuesY ()),
34 m_creationCircleRadius (document.modelGuideline().creationCircleRadius ()),
35 m_lineColor (document.modelGuideline().lineColor ()),
36 m_lineWidthActive (document.modelGuideline().lineWidthActive ()),
37 m_lineWidthInactive (document.modelGuideline().lineWidthInactive ())
38{
39}
GuidelineValues valuesY() const
Get method for y/r values.
double lineWidthInactive() const
Get method for line width when inactive.
double creationCircleRadius() const
Get method for creation circle radius in pixels.
GuidelineValues valuesX() const
Get method for x/t values.
ColorPalette lineColor() const
Get method for line color.
double lineWidthActive() const
Get method for line width when active.
DocumentModelGuideline modelGuideline() const
Get method for DocumentModelGuideline.
Definition Document.cpp:756

◆ DocumentModelGuideline() [3/3]

DocumentModelGuideline::DocumentModelGuideline ( const DocumentModelGuideline & other)

Copy constructor.

Definition at line 41 of file DocumentModelGuideline.cpp.

41 :
42 m_valuesX (other.valuesX ()),
43 m_valuesY (other.valuesY ()),
44 m_creationCircleRadius (other.creationCircleRadius ()),
45 m_lineColor (other.lineColor ()),
46 m_lineWidthActive (other.lineWidthActive ()),
47 m_lineWidthInactive (other.lineWidthInactive ())
48{
49}

Member Function Documentation

◆ creationCircleRadius()

double DocumentModelGuideline::creationCircleRadius ( ) const

Get method for creation circle radius in pixels.

Definition at line 63 of file DocumentModelGuideline.cpp.

64{
65 return m_creationCircleRadius;
66}

◆ lineColor()

ColorPalette DocumentModelGuideline::lineColor ( ) const

Get method for line color.

Definition at line 68 of file DocumentModelGuideline.cpp.

69{
70 return m_lineColor;
71}

◆ lineWidthActive()

double DocumentModelGuideline::lineWidthActive ( ) const

Get method for line width when active.

Definition at line 73 of file DocumentModelGuideline.cpp.

74{
75 return m_lineWidthActive;
76}

◆ lineWidthInactive()

double DocumentModelGuideline::lineWidthInactive ( ) const

Get method for line width when inactive.

Definition at line 78 of file DocumentModelGuideline.cpp.

79{
80 return m_lineWidthInactive;
81}

◆ loadXml()

void DocumentModelGuideline::loadXml ( QXmlStreamReader & reader)
virtual

Load model from serialized xml.

Implements DocumentModelAbstractBase.

Definition at line 83 of file DocumentModelGuideline.cpp.

84{
85 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGuideline::loadXml";
86
87 bool success = true;
88
89 QXmlStreamAttributes attributes = reader.attributes();
90
91 if (attributes.hasAttribute (DOCUMENT_SERIALIZE_GUIDELINE_CREATION_CIRCLE_RADIUS) &&
92 attributes.hasAttribute (DOCUMENT_SERIALIZE_GUIDELINE_LINE_COLOR) &&
93 attributes.hasAttribute (DOCUMENT_SERIALIZE_GUIDELINE_LINE_WIDTH_ACTIVE) &&
94 attributes.hasAttribute (DOCUMENT_SERIALIZE_GUIDELINE_LINE_WIDTH_INACTIVE)) {
95
97 setLineColor (static_cast<ColorPalette> (attributes.value (DOCUMENT_SERIALIZE_GUIDELINE_LINE_COLOR).toInt ()));
100 }
101
102 // Read until end of this subtree
103 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
104 (reader.name() != DOCUMENT_SERIALIZE_GUIDELINES)){
105
106 QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
107
108 if ((tokenType == QXmlStreamReader::StartElement) &&
109 (reader.name() == DOCUMENT_SERIALIZE_GUIDELINES_X)) {
110
111 loadXmlVector (reader,
113 m_valuesX);
114 }
115
116 if ((tokenType == QXmlStreamReader::StartElement) &&
117 (reader.name() == DOCUMENT_SERIALIZE_GUIDELINES_Y)) {
118
119 loadXmlVector (reader,
121 m_valuesY);
122 }
123
124 if (reader.atEnd()) {
125 success = false;
126 break;
127 }
128 }
129
130 if (!success) {
131 reader.raiseError (QObject::tr ("Cannot read grid display data"));
132 }
133}
ColorPalette
const QString DOCUMENT_SERIALIZE_GUIDELINE_LINE_WIDTH_INACTIVE
const QString DOCUMENT_SERIALIZE_GUIDELINE_CREATION_CIRCLE_RADIUS
const QString DOCUMENT_SERIALIZE_GUIDELINE_LINE_WIDTH_ACTIVE
const QString DOCUMENT_SERIALIZE_GUIDELINES
const QString DOCUMENT_SERIALIZE_GUIDELINE_LINE_COLOR
const QString DOCUMENT_SERIALIZE_GUIDELINES_Y
const QString DOCUMENT_SERIALIZE_GUIDELINES_X
log4cpp::Category * mainCat
Definition Logger.cpp:14
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
void setLineColor(ColorPalette lineColor)
Set method for line color.
void setLineWidthInactive(double lineWidth)
Set method for line width when inactive.
void setCreationCircleRadius(double radius)
Set method for creation circle radius in pixels.
void setLineWidthActive(double lineWidth)
Set method for line width when active.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ operator=()

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

Assignment constructor.

Definition at line 51 of file DocumentModelGuideline.cpp.

52{
53 m_valuesX = other.valuesX ();
54 m_valuesY = other.valuesY ();
55 m_creationCircleRadius = other.creationCircleRadius ();
56 m_lineColor = other.lineColor ();
57 m_lineWidthActive = other.lineWidthActive ();
58 m_lineWidthInactive = other.lineWidthInactive ();
59
60 return *this;
61}

◆ printStream()

void DocumentModelGuideline::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 164 of file DocumentModelGuideline.cpp.

166{
167 str << indentation << "DocumentModelGuideline\n";
168
169 indentation += INDENTATION_DELTA;
170
171 QString valuesX, valuesY, delimiterX, delimiterY;
172 QTextStream strX (&valuesX), strY (&valuesY);
173 GuidelineValues::const_iterator itr;
174
175 for (itr = m_valuesX.constBegin(); itr != m_valuesX.constEnd(); itr++) {
176 strX << delimiterX << itr.value();
177 delimiterX = ", ";
178 }
179
180 for (itr = m_valuesY.constBegin(); itr != m_valuesY.constEnd(); itr++) {
181 strY << delimiterY << itr.value();
182 delimiterY = ", ";
183 }
184
185 str << indentation << "valuesX=" << valuesX << "\n";
186 str << indentation << "valuesY=" << valuesY << "\n";
187 str << indentation << "creationCircleRadius=" << m_creationCircleRadius << "\n";
188 str << indentation << "lineColor=" << colorPaletteToString (m_lineColor) << "\n";
189 str << indentation << "lineWidthActive=" << m_lineWidthActive << "\n";
190 str << indentation << "lineWidthInactive=" << m_lineWidthInactive << "\n";
191}
QString colorPaletteToString(ColorPalette colorPalette)
const QString INDENTATION_DELTA

◆ saveXml()

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

Save entire model as xml into stream.

Implements DocumentModelAbstractBase.

Definition at line 193 of file DocumentModelGuideline.cpp.

194{
195 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGuideline::saveXml";
196
197 writer.writeStartElement(DOCUMENT_SERIALIZE_GUIDELINES);
198 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_CREATION_CIRCLE_RADIUS, QString::number (m_creationCircleRadius));
199 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_LINE_COLOR, QString::number (m_lineColor));
200 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_LINE_COLOR_STRING, colorPaletteToString (m_lineColor));
201 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_LINE_WIDTH_ACTIVE, QString::number (m_lineWidthActive));
202 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_LINE_WIDTH_INACTIVE, QString::number (m_lineWidthInactive));
203 saveXmlVector (writer,
205 m_valuesX);
206 saveXmlVector (writer,
208 m_valuesY);
209 writer.writeEndElement();
210}
const QString DOCUMENT_SERIALIZE_GUIDELINE_LINE_COLOR_STRING

◆ setCreationCircleRadius()

void DocumentModelGuideline::setCreationCircleRadius ( double radius)

Set method for creation circle radius in pixels.

Definition at line 232 of file DocumentModelGuideline.cpp.

233{
234 m_creationCircleRadius = radius;
235}

◆ setLineColor()

void DocumentModelGuideline::setLineColor ( ColorPalette lineColor)

Set method for line color.

Definition at line 237 of file DocumentModelGuideline.cpp.

238{
239 m_lineColor = lineColor;
240}

◆ setLineWidthActive()

void DocumentModelGuideline::setLineWidthActive ( double lineWidth)

Set method for line width when active.

Definition at line 242 of file DocumentModelGuideline.cpp.

243{
244 m_lineWidthActive = lineWidthActive;
245}

◆ setLineWidthInactive()

void DocumentModelGuideline::setLineWidthInactive ( double lineWidth)

Set method for line width when inactive.

Definition at line 247 of file DocumentModelGuideline.cpp.

248{
249 m_lineWidthInactive = lineWidthInactive;
250}

◆ setValuesX()

void DocumentModelGuideline::setValuesX ( const GuidelineValues & valuesX)

Set method for x/t values.

Definition at line 252 of file DocumentModelGuideline.cpp.

253{
254 m_valuesX = valuesX;
255}

◆ setValuesY()

void DocumentModelGuideline::setValuesY ( const GuidelineValues & valuesY)

Set method for y/r values.

Definition at line 257 of file DocumentModelGuideline.cpp.

258{
259 m_valuesY = valuesY;
260}

◆ valuesX()

GuidelineValues DocumentModelGuideline::valuesX ( ) const

Get method for x/t values.

Definition at line 262 of file DocumentModelGuideline.cpp.

263{
264 return m_valuesX;
265}

◆ valuesY()

GuidelineValues DocumentModelGuideline::valuesY ( ) const

Get method for y/r values.

Definition at line 267 of file DocumentModelGuideline.cpp.

268{
269 return m_valuesY;
270}

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