Commit 0e6411c7 authored by John Tapsell's avatar John Tapsell

Fix setStyleText() to apply to future curves

parent beb0ecfb
......@@ -157,36 +157,43 @@ void IncrementalPlot::showLegend(bool show)
*/
void IncrementalPlot::setStyleText(const QString &style)
{
styleText = style.toLower();
foreach (QwtPlotCurve* curve, curves) {
// Style of datapoints
if (style.toLower().contains("circles")) {
curve->setSymbol(QwtSymbol(QwtSymbol::Ellipse,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(6, 6)) );
} else if (style.toLower().contains("crosses")) {
curve->setSymbol(QwtSymbol(QwtSymbol::XCross,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(5, 5)) );
} else if (style.toLower().contains("rect")) {
curve->setSymbol(QwtSymbol(QwtSymbol::Rect,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(6, 6)) );
} else if (style.toLower().contains("line")) { // Show no symbol
curve->setSymbol(QwtSymbol(QwtSymbol::NoSymbol,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(6, 6)) );
}
updateStyle(curve);
}
replot();
}
// Style of lines
if (style.toLower().contains("dotted")) {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::DotLine));
} else if (style.toLower().contains("dashed")) {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::DashLine));
} else if (style.toLower().contains("line") || style.toLower().contains("solid")) {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::SolidLine));
} else {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::NoPen));
}
curve->setStyle(QwtPlotCurve::Lines);
void IncrementalPlot::updateStyle(QwtPlotCurve *curve)
{
if(styleText.isNull())
return;
// Style of datapoints
if (styleText.contains("circles")) {
curve->setSymbol(QwtSymbol(QwtSymbol::Ellipse,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(6, 6)) );
} else if (styleText.contains("crosses")) {
curve->setSymbol(QwtSymbol(QwtSymbol::XCross,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(5, 5)) );
} else if (styleText.contains("rect")) {
curve->setSymbol(QwtSymbol(QwtSymbol::Rect,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(6, 6)) );
} else if (styleText.contains("line")) { // Show no symbol
curve->setSymbol(QwtSymbol(QwtSymbol::NoSymbol,
Qt::NoBrush, QPen(QBrush(curve->symbol().pen().color()), symbolWidth), QSize(6, 6)) );
}
// Style of lines
if (styleText.contains("dotted")) {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::DotLine));
} else if (styleText.contains("dashed")) {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::DashLine));
} else if (styleText.contains("line") || styleText.contains("solid")) {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::SolidLine));
} else {
curve->setPen(QPen(QBrush(curve->symbol().pen().color()), curveWidth, Qt::NoPen));
}
replot();
curve->setStyle(QwtPlotCurve::Lines);
}
void IncrementalPlot::resetScaling()
......@@ -275,7 +282,7 @@ void IncrementalPlot::appendData(const QString &key, double *x, double *y, int s
const QColor &c = getNextColor();
curve->setSymbol(QwtSymbol(QwtSymbol::XCross,
QBrush(c), QPen(c, symbolWidth), QSize(5, 5)) );
updateStyle(curve); //Apply any user-set style
curve->attach(this);
} else {
curve = curves.value(key);
......@@ -374,7 +381,7 @@ void IncrementalPlot::showGrid(bool show)
replot();
}
bool IncrementalPlot::gridEnabled()
bool IncrementalPlot::gridEnabled() const
{
return grid->isVisible();
}
......
......@@ -81,7 +81,7 @@ public:
virtual ~IncrementalPlot();
/** @brief Get the state of the grid */
bool gridEnabled();
bool gridEnabled() const;
/** @brief Read out data from a curve */
int data(const QString &key, double* r_x, double* r_y, int maxSize);
......@@ -125,10 +125,12 @@ protected:
double xmax; ///< Maximum x value seen
double ymin; ///< Minimum y value seen
double ymax; ///< Maximum y value seen
QString styleText; ///< Curve style set by setStyleText
private:
QMap<QString, CurveData* > d_data; ///< Data points
/** Helper function to apply styleText style to the given curve */
void updateStyle(QwtPlotCurve *curve);
};
#endif /* INCREMENTALPLOT_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment