65 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
66 settings.beginGroup (SETTINGS_GROUP_CURVE_AXES);
67 PointShape
shape = (PointShape) settings.value (SETTINGS_CURVE_POINT_SHAPE,
68 DEFAULT_POINT_SHAPE_AXIS).toInt();
69 int radius = settings.value (SETTINGS_CURVE_POINT_RADIUS,
70 DEFAULT_POINT_RADIUS).toInt();
71 int pointLineWidth = settings.value (SETTINGS_CURVE_POINT_LINE_WIDTH,
72 DEFAULT_POINT_LINE_WIDTH).toInt();
73 ColorPalette pointColor = (ColorPalette) settings.value (SETTINGS_CURVE_POINT_COLOR,
74 DEFAULT_POINT_COLOR_AXES).toInt();
86 PointShape
shape = POINT_SHAPE_CROSS;
87 static PointShape pointShapes [] = {POINT_SHAPE_CROSS,
91 shape = pointShapes [index % 4];
94 int indexOneBased = index + 1;
98 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
99 settings.beginGroup (groupName);
100 int radius = settings.value (SETTINGS_CURVE_POINT_RADIUS,
101 DEFAULT_POINT_RADIUS).toInt();
102 int pointLineWidth = settings.value (SETTINGS_CURVE_POINT_LINE_WIDTH,
103 DEFAULT_POINT_LINE_WIDTH).toInt();
104 ColorPalette pointColor = (ColorPalette) settings.value (SETTINGS_CURVE_POINT_COLOR,
105 DEFAULT_POINT_COLOR_GRAPH).toInt();
106 settings.endGroup ();
126 LOG4CPP_INFO_S ((*mainCat)) <<
"PointStyle::loadXml";
128 QXmlStreamAttributes attributes = reader.attributes();
130 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS) &&
131 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH) &&
132 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR) &&
133 attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE)) {
135 setRadius (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS).toInt());
136 setLineWidth (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH).toInt());
137 setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR).toInt());
138 setShape ((PointShape) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE).toInt());
141 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
142 (reader.name() != DOCUMENT_SERIALIZE_POINT_STYLE)){
143 loadNextFromReader(reader);
146 reader.raiseError (QObject::tr (
"Cannot read point style data"));
157 const int NUM_XY = 60;
158 QVector<QPointF> points;
162 case POINT_SHAPE_CIRCLE:
164 int xyWidth = m_radius;
165 for (
int i = 0; i <= NUM_XY; i++) {
166 double angle = TWO_PI * (double) i / (
double) NUM_XY;
167 double x = xyWidth * cos (angle);
168 double y = xyWidth * sin (angle);
169 points.append (QPointF (x, y));
174 case POINT_SHAPE_CROSS:
176 int xyWidth = m_radius;
178 points.append (QPointF (-1 * xyWidth, 0));
179 points.append (QPointF (xyWidth, 0));
180 points.append (QPointF (0, 0));
181 points.append (QPointF (0, xyWidth));
182 points.append (QPointF (0, -1 * xyWidth));
183 points.append (QPointF (0, 0));
187 case POINT_SHAPE_DIAMOND:
189 int xyWidth = m_radius;
191 points.append (QPointF (0, -1 * xyWidth));
192 points.append (QPointF (-1 * xyWidth, 0));
193 points.append (QPointF (0, xyWidth));
194 points.append (QPointF (xyWidth, 0));
198 case POINT_SHAPE_SQUARE:
200 int xyWidth = m_radius;
202 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
203 points.append (QPointF (-1 * xyWidth, xyWidth));
204 points.append (QPointF (xyWidth, xyWidth));
205 points.append (QPointF (xyWidth, -1 * xyWidth));
209 case POINT_SHAPE_TRIANGLE:
211 int xyWidth = m_radius;
213 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
214 points.append (QPointF (0, xyWidth));
215 points.append (QPointF (xyWidth, -1 * xyWidth));
221 int xyWidth = m_radius * qSqrt (0.5);
223 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
224 points.append (QPointF (xyWidth, xyWidth));
225 points.append (QPointF (0, 0));
226 points.append (QPointF (-1 * xyWidth, xyWidth));
227 points.append (QPointF (xyWidth, -1 * xyWidth));
228 points.append (QPointF (0, 0));
233 ENGAUGE_ASSERT (
false);
260 LOG4CPP_INFO_S ((*mainCat)) <<
"PointStyle::saveXml";
262 writer.writeStartElement(DOCUMENT_SERIALIZE_POINT_STYLE);
263 writer.writeAttribute (DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS, QString::number (m_radius));
264 writer.writeAttribute (DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH, QString::number (m_lineWidth));
265 writer.writeAttribute (DOCUMENT_SERIALIZE_POINT_STYLE_COLOR, QString::number (m_paletteColor));
266 writer.writeAttribute (DOCUMENT_SERIALIZE_POINT_STYLE_COLOR_STRING, colorPaletteToString (m_paletteColor));
267 writer.writeAttribute (DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE, QString::number (m_shape));
268 writer.writeAttribute (DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE_STRING, pointShapeToString (m_shape));
269 writer.writeEndElement();