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