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

Model for DlgSettingsSegments and CmdSettingsSegments. More...

#include <DocumentModelSegments.h>

Inheritance diagram for DocumentModelSegments:
Inheritance graph
Collaboration diagram for DocumentModelSegments:
Collaboration graph

Public Member Functions

 DocumentModelSegments ()
 Default constructor.
 DocumentModelSegments (const Document &document)
 Initial constructor from Document.
 DocumentModelSegments (const DocumentModelSegments &other)
 Copy constructor.
DocumentModelSegmentsoperator= (const DocumentModelSegments &other)
 Assignment constructor.
bool fillCorners () const
 Get method for fill corners.
InactiveOpacity inactiveOpacity () const
 Get method for inactive opacity.
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.
double minLength () const
 Get method for min length.
double pointSeparation () const
 Get method for point separation.
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 setFillCorners (bool fillCorners)
 Set method for fill corners.
void setInactiveOpacity (InactiveOpacity inactiveOpacity)
 Set method for inactive opacity.
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 setMinLength (double minLength)
 Set method for min length.
void setPointSeparation (double pointSeparation)
 Set method for point separation.
Public Member Functions inherited from DocumentModelAbstractBase
 DocumentModelAbstractBase ()
 Single constructor.
virtual ~DocumentModelAbstractBase ()
 Single destructor.

Detailed Description

Model for DlgSettingsSegments and CmdSettingsSegments.

Definition at line 18 of file DocumentModelSegments.h.

Constructor & Destructor Documentation

◆ DocumentModelSegments() [1/3]

DocumentModelSegments::DocumentModelSegments ( )

Default constructor.

Definition at line 24 of file DocumentModelSegments.cpp.

24 :
25 m_pointSeparation (DEFAULT_POINT_SEPARATION),
26 m_minLength (DEFAULT_MIN_LENGTH),
27 m_fillCorners (false),
28 m_lineWidthActive (DEFAULT_LINE_WIDTH_ACTIVE),
29 m_lineWidthInactive (DEFAULT_LINE_WIDTH_INACTIVE),
30 m_lineColor (DEFAULT_LINE_COLOR),
31 m_inactiveOpacity (DEFAULT_INACTIVE_OPACITY)
32{
33}
const ColorPalette DEFAULT_LINE_COLOR
const double DEFAULT_LINE_WIDTH_ACTIVE
const double DEFAULT_LINE_WIDTH_INACTIVE
const double DEFAULT_MIN_LENGTH
const double DEFAULT_POINT_SEPARATION
const InactiveOpacity DEFAULT_INACTIVE_OPACITY

◆ DocumentModelSegments() [2/3]

DocumentModelSegments::DocumentModelSegments ( const Document & document)

Initial constructor from Document.

Definition at line 35 of file DocumentModelSegments.cpp.

35 :
36 m_pointSeparation (document.modelSegments().pointSeparation()),
37 m_minLength (document.modelSegments().minLength()),
38 m_fillCorners (document.modelSegments().fillCorners()),
39 m_lineWidthActive (document.modelSegments().lineWidthActive()),
40 m_lineWidthInactive (document.modelSegments().lineWidthInactive()),
41 m_lineColor (document.modelSegments().lineColor()),
42 m_inactiveOpacity (document.modelSegments().inactiveOpacity())
43{
44}
double lineWidthInactive() const
Get method for line width when inactive.
double lineWidthActive() const
Get method for line width when active.
InactiveOpacity inactiveOpacity() const
Get method for inactive opacity.
ColorPalette lineColor() const
Get method for line color.
double minLength() const
Get method for min length.
bool fillCorners() const
Get method for fill corners.
double pointSeparation() const
Get method for point separation.
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Definition Document.cpp:777

◆ DocumentModelSegments() [3/3]

DocumentModelSegments::DocumentModelSegments ( const DocumentModelSegments & other)

Copy constructor.

Definition at line 46 of file DocumentModelSegments.cpp.

46 :
47 m_pointSeparation (other.pointSeparation()),
48 m_minLength (other.minLength()),
49 m_fillCorners (other.fillCorners ()),
50 m_lineWidthActive (other.lineWidthActive()),
51 m_lineWidthInactive (other.lineWidthInactive()),
52 m_lineColor (other.lineColor()),
53 m_inactiveOpacity (other.inactiveOpacity())
54{
55}

Member Function Documentation

◆ fillCorners()

bool DocumentModelSegments::fillCorners ( ) const

Get method for fill corners.

Definition at line 70 of file DocumentModelSegments.cpp.

71{
72 return m_fillCorners;
73}

◆ inactiveOpacity()

InactiveOpacity DocumentModelSegments::inactiveOpacity ( ) const

Get method for inactive opacity.

Definition at line 75 of file DocumentModelSegments.cpp.

76{
77 return m_inactiveOpacity;
78}

◆ lineColor()

ColorPalette DocumentModelSegments::lineColor ( ) const

Get method for line color.

Definition at line 80 of file DocumentModelSegments.cpp.

81{
82 return m_lineColor;
83}

◆ lineWidthActive()

double DocumentModelSegments::lineWidthActive ( ) const

Get method for line width when active.

Definition at line 85 of file DocumentModelSegments.cpp.

86{
87 return m_lineWidthActive;
88}

◆ lineWidthInactive()

double DocumentModelSegments::lineWidthInactive ( ) const

Get method for line width when inactive.

Definition at line 90 of file DocumentModelSegments.cpp.

91{
92 return m_lineWidthInactive;
93}

◆ loadXml()

void DocumentModelSegments::loadXml ( QXmlStreamReader & reader)
virtual

Load model from serialized xml.

Implements DocumentModelAbstractBase.

Definition at line 95 of file DocumentModelSegments.cpp.

96{
97 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelSegments::loadXml";
98
99 bool success = true;
100
101 QXmlStreamAttributes attributes = reader.attributes ();
102
103 // Entries that are optional since they were removed in version 13
104 // DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH
105 // Entries that are optional since they were added in version 13
106 // DOCUMENT_SERIALIZE_SEGMENTS_INACTIVE_OPACITY
107 // DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_ACTIVE
108 // DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_ACTIVE_STRING
109 // DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_INACTIVE
110 // DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_INACTIVE_STRING
111 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_SEGMENTS_POINT_SEPARATION) &&
112 attributes.hasAttribute(DOCUMENT_SERIALIZE_SEGMENTS_MIN_LENGTH) &&
113 attributes.hasAttribute(DOCUMENT_SERIALIZE_SEGMENTS_FILL_CORNERS) &&
114 attributes.hasAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH) &&
115 attributes.hasAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR)) {
116
117 // Boolean values
118 QString fillCorners = attributes.value(DOCUMENT_SERIALIZE_SEGMENTS_FILL_CORNERS).toString();
119
121 setMinLength (attributes.value (DOCUMENT_SERIALIZE_SEGMENTS_MIN_LENGTH).toDouble());
123 setLineColor (static_cast<ColorPalette> (attributes.value (DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR).toInt()));
124
125 if (attributes.hasAttribute (DOCUMENT_SERIALIZE_SEGMENTS_INACTIVE_OPACITY)) {
126 setInactiveOpacity (static_cast<InactiveOpacity> (attributes.value (DOCUMENT_SERIALIZE_SEGMENTS_INACTIVE_OPACITY).toInt ()));
127 } else{
129 }
130
131 // For line widths, first look for single value (corresponding to versions before 13), then look
132 // for two values (corresponding to version 13+)
135 if (attributes.hasAttribute (DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH)) {
136 lineWidthActive = attributes.value (DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH).toInt ();
137 lineWidthInactive = attributes.value (DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH).toInt ();
138 } else if (attributes.hasAttribute (DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_ACTIVE) &&
139 attributes.hasAttribute (DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_INACTIVE)) {
142 }
145
146 // Read until end of this subtree
147 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
148 (reader.name() != DOCUMENT_SERIALIZE_SEGMENTS)){
149 loadNextFromReader(reader);
150 if (reader.atEnd()) {
151 success = false;
152 break;
153 }
154 }
155 }
156
157 if (!success) {
158 reader.raiseError(QObject::tr ("Cannot read segment data"));
159 }
160}
ColorPalette
const QString DOCUMENT_SERIALIZE_SEGMENTS_MIN_LENGTH
const QString DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_INACTIVE
const QString DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR
const QString DOCUMENT_SERIALIZE_SEGMENTS_POINT_SEPARATION
const QString DOCUMENT_SERIALIZE_SEGMENTS
const QString DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH
const QString DOCUMENT_SERIALIZE_SEGMENTS_FILL_CORNERS
const QString DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_ACTIVE
const QString DOCUMENT_SERIALIZE_SEGMENTS_INACTIVE_OPACITY
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
InactiveOpacity
Enum for opacity/alpha values used for segments that are not currently under hover.
log4cpp::Category * mainCat
Definition Logger.cpp:14
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
void setFillCorners(bool fillCorners)
Set method for fill corners.
void setLineWidthActive(double lineWidth)
Set method for line width when active.
void setInactiveOpacity(InactiveOpacity inactiveOpacity)
Set method for inactive opacity.
void setPointSeparation(double pointSeparation)
Set method for point separation.
void setLineWidthInactive(double lineWidth)
Set method for line width when inactive.
void setLineColor(ColorPalette lineColor)
Set method for line color.
void setMinLength(double minLength)
Set method for min length.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ minLength()

double DocumentModelSegments::minLength ( ) const

Get method for min length.

Definition at line 162 of file DocumentModelSegments.cpp.

163{
164 return m_minLength;
165}

◆ operator=()

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

Assignment constructor.

Definition at line 57 of file DocumentModelSegments.cpp.

58{
59 m_pointSeparation = other.pointSeparation();
60 m_minLength = other.minLength();
61 m_fillCorners = other.fillCorners ();
62 m_lineWidthActive = other.lineWidthActive();
63 m_lineWidthInactive = other.lineWidthInactive();
64 m_lineColor = other.lineColor();
65 m_inactiveOpacity = other.inactiveOpacity();
66
67 return *this;
68}

◆ pointSeparation()

double DocumentModelSegments::pointSeparation ( ) const

Get method for point separation.

Definition at line 167 of file DocumentModelSegments.cpp.

168{
169 return m_pointSeparation;
170}

◆ printStream()

void DocumentModelSegments::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 172 of file DocumentModelSegments.cpp.

174{
175 str << indentation << "DocumentModelSegments\n";
176
177 indentation += INDENTATION_DELTA;
178
179 str << indentation << "pointSeparation=" << m_pointSeparation << "\n";
180 str << indentation << "minLength=" << m_minLength << "\n";
181 str << indentation << "fillCorners=" << (m_fillCorners ? "true" : "false") << "\n";
182 str << indentation << "lineWidthActive=" << m_lineWidthActive << "\n";
183 str << indentation << "lineWidthInactive=" << m_lineWidthInactive << "\n";
184 str << indentation << "lineColor=" << colorPaletteToString (m_lineColor) << "\n";
185 str << indentation << "inactiveOpacity=" << m_inactiveOpacity << "\n";
186}
QString colorPaletteToString(ColorPalette colorPalette)
const QString INDENTATION_DELTA

◆ saveXml()

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

Save entire model as xml into stream.

Implements DocumentModelAbstractBase.

Definition at line 188 of file DocumentModelSegments.cpp.

189{
190 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelSegments::saveXml";
191
192 writer.writeStartElement(DOCUMENT_SERIALIZE_SEGMENTS);
193 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_POINT_SEPARATION, QString::number (m_pointSeparation));
194 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_MIN_LENGTH, QString::number (m_minLength));
195 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_FILL_CORNERS, m_fillCorners ?
198 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_ACTIVE, QString::number (m_lineWidthActive));
199 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_WIDTH_INACTIVE, QString::number (m_lineWidthInactive));
200 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR, QString::number (m_lineColor));
201 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR_STRING, colorPaletteToString (m_lineColor));
202 writer.writeAttribute(DOCUMENT_SERIALIZE_SEGMENTS_INACTIVE_OPACITY, QString::number (m_inactiveOpacity));
203 writer.writeEndElement();
204}
const QString DOCUMENT_SERIALIZE_SEGMENTS_LINE_COLOR_STRING
const QString DOCUMENT_SERIALIZE_BOOL_FALSE

◆ setFillCorners()

void DocumentModelSegments::setFillCorners ( bool fillCorners)

Set method for fill corners.

Definition at line 206 of file DocumentModelSegments.cpp.

207{
208 m_fillCorners = fillCorners;
209}

◆ setInactiveOpacity()

void DocumentModelSegments::setInactiveOpacity ( InactiveOpacity inactiveOpacity)

Set method for inactive opacity.

Definition at line 211 of file DocumentModelSegments.cpp.

212{
213 m_inactiveOpacity = inactiveOpacity;
214}

◆ setLineColor()

void DocumentModelSegments::setLineColor ( ColorPalette lineColor)

Set method for line color.

Definition at line 216 of file DocumentModelSegments.cpp.

217{
218 m_lineColor = lineColor;
219}

◆ setLineWidthActive()

void DocumentModelSegments::setLineWidthActive ( double lineWidth)

Set method for line width when active.

Definition at line 221 of file DocumentModelSegments.cpp.

222{
223 m_lineWidthActive = lineWidthActive;
224}

◆ setLineWidthInactive()

void DocumentModelSegments::setLineWidthInactive ( double lineWidth)

Set method for line width when inactive.

Definition at line 226 of file DocumentModelSegments.cpp.

227{
228 m_lineWidthInactive = lineWidthInactive;
229}

◆ setMinLength()

void DocumentModelSegments::setMinLength ( double minLength)

Set method for min length.

Definition at line 231 of file DocumentModelSegments.cpp.

232{
233 m_minLength = minLength;
234}

◆ setPointSeparation()

void DocumentModelSegments::setPointSeparation ( double pointSeparation)

Set method for point separation.

Definition at line 236 of file DocumentModelSegments.cpp.

237{
238 m_pointSeparation = pointSeparation;
239}

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