7 #include "DocumentSerialize.h" 12 #include <QTextStream> 13 #include <QXmlStreamReader> 14 #include <QXmlStreamWriter> 16 #include "SettingsForGraph.h" 19 const ColorPalette DEFAULT_LINE_COLOR_AXES = COLOR_PALETTE_TRANSPARENT;
20 const ColorPalette DEFAULT_LINE_COLOR_GRAPH = COLOR_PALETTE_BLUE;
21 const CurveConnectAs DEFAULT_LINE_CONNECT_AS_AXES = CONNECT_SKIP_FOR_AXIS_CURVE;
22 const CurveConnectAs DEFAULT_LINE_CONNECT_AS_GRAPH = CONNECT_AS_FUNCTION_SMOOTH;
23 const int DEFAULT_LINE_WIDTH_AXES = 0;
24 const int DEFAULT_LINE_WIDTH_GRAPH = 1;
28 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
29 settings.beginGroup (SETTINGS_GROUP_CURVE_AXES);
30 m_width = settings.value (SETTINGS_CURVE_LINE_WIDTH,
31 DEFAULT_LINE_WIDTH_AXES).toInt();
32 m_paletteColor = (ColorPalette) settings.value (SETTINGS_CURVE_LINE_COLOR,
33 DEFAULT_LINE_COLOR_AXES).toInt();
34 m_curveConnectAs = (CurveConnectAs) settings.value (SETTINGS_CURVE_LINE_CONNECT_AS,
35 DEFAULT_LINE_CONNECT_AS_AXES).toInt();
42 m_paletteColor (paletteColor),
43 m_curveConnectAs (curveConnectAs)
48 m_width (other.
width ()),
56 m_width = other.
width ();
65 return m_curveConnectAs;
70 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
71 settings.beginGroup (SETTINGS_GROUP_CURVE_AXES);
72 int width = settings.value (SETTINGS_CURVE_LINE_WIDTH,
73 DEFAULT_LINE_WIDTH_AXES).toInt();
74 ColorPalette color = (ColorPalette) settings.value (SETTINGS_CURVE_LINE_COLOR,
75 DEFAULT_LINE_COLOR_AXES).toInt();
76 CurveConnectAs connectAs = (CurveConnectAs) settings.value (SETTINGS_CURVE_LINE_CONNECT_AS,
77 DEFAULT_LINE_CONNECT_AS_AXES).toInt();
87 int indexOneBased = index + 1;
90 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
91 settings.beginGroup (groupName);
92 int width = settings.value (SETTINGS_CURVE_LINE_WIDTH,
93 DEFAULT_LINE_WIDTH_GRAPH).toInt();
94 ColorPalette color = (ColorPalette) settings.value (SETTINGS_CURVE_LINE_COLOR,
95 DEFAULT_LINE_COLOR_GRAPH).toInt();
96 CurveConnectAs connectAs = (CurveConnectAs) settings.value (SETTINGS_CURVE_LINE_CONNECT_AS,
97 DEFAULT_LINE_CONNECT_AS_GRAPH).toInt();
106 LOG4CPP_INFO_S ((*mainCat)) <<
"LineStyle::loadXml";
108 QXmlStreamAttributes attributes = reader.attributes();
110 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH) &&
111 attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_COLOR) &&
112 attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS)) {
114 setWidth (attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH).toInt());
115 setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_COLOR).toInt());
116 setCurveConnectAs ((CurveConnectAs) attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS).toInt());
119 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
120 (reader.name() != DOCUMENT_SERIALIZE_LINE_STYLE)){
121 loadNextFromReader(reader);
124 reader.raiseError (QObject::tr (
"Cannot read line style data"));
130 return m_paletteColor;
134 QTextStream &str)
const 136 str << indentation <<
"LineStyle\n";
138 indentation += INDENTATION_DELTA;
140 str << indentation <<
"width=" << m_width <<
"\n";
141 str << indentation <<
"color=" << colorPaletteToString (m_paletteColor) <<
"\n";
142 str << indentation <<
"curveConnectAs=" << curveConnectAsToString (m_curveConnectAs) <<
"\n";
147 LOG4CPP_INFO_S ((*mainCat)) <<
"LineStyle::saveXml";
149 writer.writeStartElement(DOCUMENT_SERIALIZE_LINE_STYLE);
150 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH, QString::number(m_width));
151 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_COLOR, QString::number (m_paletteColor));
152 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_COLOR_STRING, colorPaletteToString (m_paletteColor));
153 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS, QString::number (m_curveConnectAs));
154 writer.writeAttribute (DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS_STRING, curveConnectAsToString (m_curveConnectAs));
155 writer.writeEndElement();
Manage storage and retrieval of the settings for the curves.
CurveConnectAs curveConnectAs() const
Get method for connect type.
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
static LineStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
unsigned int width() const
Width of line.
LineStyle & operator=(const LineStyle &other)
Assignment operator.
static LineStyle defaultAxesCurve()
Initial default for axes curve.
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
ColorPalette paletteColor() const
Line color.
Details for a specific Line.
QString groupNameForNthCurve(int indexOneBased) const
Return the group name, that appears in the settings file/registry, for the specified curve index...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setCurveConnectAs(CurveConnectAs curveConnectAs)
Set connect as.
void setPaletteColor(ColorPalette paletteColor)
Set method for line color.
void setWidth(int width)
Set width of line.
LineStyle()
Default constructor only for use when this class is being stored by a container that requires the def...