14 #include <QTextStream>
16 #include <QXmlStreamWriter>
26 const double PI = 3.1415926535;
44 m_lineWidth (lineWidth),
45 m_paletteColor (paletteColor)
50 m_shape (other.shape()),
51 m_radius (other.radius ()),
52 m_lineWidth (other.lineWidth ()),
53 m_paletteColor (other.paletteColor ())
59 m_shape = other.
shape ();
60 m_radius = other.
radius ();
96 shape = pointShapes [index % 4];
99 int indexOneBased = index + 1;
104 settings.beginGroup (groupName);
111 settings.endGroup ();
133 QXmlStreamAttributes attributes = reader.attributes();
146 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
151 reader.raiseError (QObject::tr (
"Cannot read point style data"));
157 return m_paletteColor;
162 const int NUM_XY = 60;
163 QVector<QPointF> points;
169 int xyWidth = signed (m_radius);
170 for (
int i = 0; i <= NUM_XY; i++) {
171 double angle =
TWO_PI * double (i) / double (NUM_XY);
172 double x = xyWidth * cos (angle);
173 double y = xyWidth * sin (angle);
174 points.append (QPointF (x, y));
181 int xyWidth = signed (m_radius);
183 points.append (QPointF (-1 * xyWidth, 0));
184 points.append (QPointF (xyWidth, 0));
185 points.append (QPointF (0, 0));
186 points.append (QPointF (0, xyWidth));
187 points.append (QPointF (0, -1 * xyWidth));
188 points.append (QPointF (0, 0));
194 int xyWidth = signed (m_radius);
196 points.append (QPointF (0, -1 * xyWidth));
197 points.append (QPointF (-1 * xyWidth, 0));
198 points.append (QPointF (0, xyWidth));
199 points.append (QPointF (xyWidth, 0));
205 int xyWidth = signed (m_radius);
207 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
208 points.append (QPointF (xyWidth, -1 * xyWidth));
209 points.append (QPointF (-1 * xyWidth, xyWidth));
210 points.append (QPointF (xyWidth, xyWidth));
216 int xyWidth = signed (m_radius);
218 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
219 points.append (QPointF (-1 * xyWidth, xyWidth));
220 points.append (QPointF (xyWidth, xyWidth));
221 points.append (QPointF (xyWidth, -1 * xyWidth));
227 int xyWidth = signed (m_radius);
229 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
230 points.append (QPointF (0, xyWidth));
231 points.append (QPointF (xyWidth, -1 * xyWidth));
237 int xyWidth = signed (m_radius);
239 points.append (QPointF (-1 * xyWidth, xyWidth));
240 points.append (QPointF (0, -1 * xyWidth));
241 points.append (QPointF (xyWidth, xyWidth));
247 int xyWidth = qFloor (m_radius * qSqrt (0.5));
249 points.append (QPointF (-1 * xyWidth, -1 * xyWidth));
250 points.append (QPointF (xyWidth, xyWidth));
251 points.append (QPointF (0, 0));
252 points.append (QPointF (-1 * xyWidth, xyWidth));
253 points.append (QPointF (xyWidth, -1 * xyWidth));
254 points.append (QPointF (0, 0));
264 QTextStream &str)
const
266 str << indentation <<
"PointStyle\n";
271 str << indentation <<
"radius=" << m_radius <<
"\n";
272 str << indentation <<
"lineWidth=" << m_lineWidth <<
"\n";
292 writer.writeEndElement();
Manage storage and retrieval of the settings for the curves.
const QString SETTINGS_GROUP_CURVE_AXES
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
static PointStyle defaultAxesCurve()
Initial default for axes curve.
QString colorPaletteToString(ColorPalette colorPalette)
const QString SETTINGS_CURVE_POINT_SHAPE
const QString INDENTATION_DELTA
PointStyle()
Default constructor only for use when this class is being stored by a container that requires the def...
int lineWidth() const
Get method for line width.
const QString SETTINGS_CURVE_POINT_RADIUS
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void loadXml(QXmlStreamReader &reader)
Load model from serialized xml. Returns the curve name.
const QString SETTINGS_DIGITIZER
QPolygonF polygon() const
Return the polygon for creating a QGraphicsPolygonItem. The size is determined by the radius...
#define LOG4CPP_INFO_S(logger)
const QString DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE
QString groupNameForNthCurve(int indexOneBased) const
Return the group name, that appears in the settings file/registry, for the specified curve index...
const PointShape DEFAULT_POINT_SHAPE_AXIS
const ColorPalette DEFAULT_POINT_COLOR_GRAPH
const QString SETTINGS_CURVE_POINT_COLOR
void setShape(PointShape shape)
Set method for point shape.
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
Details for a specific Point.
const QString DOCUMENT_SERIALIZE_POINT_STYLE
const ColorPalette DEFAULT_POINT_COLOR_AXES
const QString SETTINGS_ENGAUGE
ColorPalette paletteColor() const
Get method for point color.
const QString DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS
const QString DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH
QString pointShapeToString(PointShape pointShape)
void setPaletteColor(ColorPalette paletteColor)
Set method for point color.
bool isCircle() const
Return true if point is a circle, otherwise it is a polygon. For a circle, the radius is important an...
unsigned int radius() const
Radius of point. For a circle this is all that is needed to draw a circle. For a polygon, the radius determines the size of the polygon.
PointStyle & operator=(const PointStyle &other)
Assignment constructor.
log4cpp::Category * mainCat
const QString DOCUMENT_SERIALIZE_POINT_STYLE_COLOR_STRING
const QString SETTINGS_CURVE_POINT_LINE_WIDTH
const int DEFAULT_POINT_RADIUS
void setRadius(unsigned int radius)
Set method for point radius.
const int DEFAULT_POINT_LINE_WIDTH
static PointStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
const QString DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE_STRING
void setLineWidth(int width)
Set method for line width.
PointShape shape() const
Get method for point shape.
const QString DOCUMENT_SERIALIZE_POINT_STYLE_COLOR