diff --git a/src/ui/linechart/ChartPlot.cc b/src/ui/linechart/ChartPlot.cc index d78258a7a699b7fcff4f5f5ad3b4d7dbb3c9f322..71bee45c3b1b1419be1e059f977df215ca304778 100644 --- a/src/ui/linechart/ChartPlot.cc +++ b/src/ui/linechart/ChartPlot.cc @@ -26,12 +26,15 @@ const QColor ChartPlot::baseColors[numColors] = { ChartPlot::ChartPlot(QWidget *parent): QwtPlot(parent), - nextColorIndex(0)/*, + nextColorIndex(0), symbolWidth(1.2f), - curveWidth(1.0f), + curveWidth(2.0f), gridWidth(0.8f), - scaleWidth(1.0f)*/ + zoomerWidth(3.0f) { + // Initialize the list of curves. + curves = QMap(); + // Set the grid. The colorscheme was already set in generateColorScheme(). grid = new QwtPlotGrid; grid->enableXMin(true); @@ -80,52 +83,55 @@ void ChartPlot::shuffleColors() { foreach (QwtPlotCurve* curve, curves) { - QPen pen(curve->pen()); - pen.setColor(getNextColor()); - curve->setPen(pen); + if (curve->isVisible()) { + QPen pen(curve->pen()); + pen.setColor(getNextColor()); + curve->setPen(pen); + } } } void ChartPlot::applyColorScheme(MainWindow::QGC_MAINWINDOW_STYLE style) { - // Generate the color list for curves + // Generate a new color list for curves and recolor them. for (int i = 0; i < numColors; ++i) { if (style == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) { -// colors[i] = baseColors[i].lighter(150); + colors[i] = baseColors[i].lighter(150); } else { -// colors[i] = baseColors[i].darker(150); + colors[i] = baseColors[i].darker(150); } } + shuffleColors(); // Configure the rest of the UI colors based on the current theme. if (style == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) { // Set the coloring of the area selector for zooming. - zoomer->setRubberBandPen(QPen(Qt::darkRed, 3.0f, Qt::DotLine)); + zoomer->setRubberBandPen(QPen(Qt::darkRed, zoomerWidth, Qt::DotLine)); zoomer->setTrackerPen(QPen(Qt::darkRed)); // Set canvas background setCanvasBackground(QColor(0xFF, 0xFF, 0xFF)); // Configure the plot grid. - grid->setMinPen(QPen(QColor(0x55, 0x55, 0x55), 0.8f, Qt::DotLine)); - grid->setMajPen(QPen(QColor(0x22, 0x22, 0x22), 0.8f, Qt::DotLine)); + grid->setMinPen(QPen(QColor(0x55, 0x55, 0x55), gridWidth, Qt::DotLine)); + grid->setMajPen(QPen(QColor(0x22, 0x22, 0x22), gridWidth, Qt::DotLine)); } else { // Set the coloring of the area selector for zooming. - zoomer->setRubberBandPen(QPen(Qt::red, 3.0f, Qt::DotLine)); + zoomer->setRubberBandPen(QPen(Qt::red, zoomerWidth, Qt::DotLine)); zoomer->setTrackerPen(QPen(Qt::red)); // Set canvas background setCanvasBackground(QColor(0, 0, 0)); // Configure the plot grid. - grid->setMinPen(QPen(QColor(0xAA, 0xAA, 0xAA), 0.8f, Qt::DotLine)); - grid->setMajPen(QPen(QColor(0xDD, 0xDD, 0xDD), 0.8f, Qt::DotLine)); + grid->setMinPen(QPen(QColor(0xAA, 0xAA, 0xAA), gridWidth, Qt::DotLine)); + grid->setMajPen(QPen(QColor(0xDD, 0xDD, 0xDD), gridWidth, Qt::DotLine)); } // And finally refresh the widget to make sure all color changes are redrawn. diff --git a/src/ui/linechart/ChartPlot.h b/src/ui/linechart/ChartPlot.h index 56d5b0071054b71a50ae7c4cda2764fa4091e338..cef45096ec7d446b593822eba72b2d39146811b1 100644 --- a/src/ui/linechart/ChartPlot.h +++ b/src/ui/linechart/ChartPlot.h @@ -31,6 +31,11 @@ protected: ScrollZoomer* zoomer; ///< Zoomer class for widget QwtPlotGrid* grid; ///< Plot grid + float symbolWidth; ///< Width of curve symbols in pixels + float curveWidth; ///< Width of curve lines in pixels + float gridWidth; ///< Width of gridlines in pixels + float zoomerWidth; ///< Width of zoomer selection box + protected slots: /** @brief Generate coloring for this plot canvas based on current window theme */ diff --git a/src/ui/linechart/IncrementalPlot.cc b/src/ui/linechart/IncrementalPlot.cc index 5da648a73911094df212ca9468ba27dc1747c985..6ef4c437547e9fa450e869c413d9194e445d74ae 100644 --- a/src/ui/linechart/IncrementalPlot.cc +++ b/src/ui/linechart/IncrementalPlot.cc @@ -85,10 +85,6 @@ const double* CurveData::y() const IncrementalPlot::IncrementalPlot(QWidget *parent): ChartPlot(parent), - symbolWidth(1.2f), - curveWidth(1.0f), - gridWidth(0.8f), - scaleWidth(1.0f), symmetric(false) { setAutoReplot(false); @@ -96,10 +92,6 @@ IncrementalPlot::IncrementalPlot(QWidget *parent): plotLayout()->setAlignCanvasToScales(true); - grid = new QwtPlotGrid; - grid->setMajPen(QPen(Qt::gray, 0.8f, Qt::DotLine)); - grid->attach(this); - QwtLinearScaleEngine* yScaleEngine = new QwtLinearScaleEngine(); setAxisScaleEngine(QwtPlot::yLeft, yScaleEngine); @@ -280,7 +272,7 @@ void IncrementalPlot::appendData(QString key, double *x, double *y, int size) const QColor &c = getNextColor(); curve->setSymbol(QwtSymbol(QwtSymbol::XCross, - QBrush(c), QPen(c, 1.2f), QSize(5, 5)) ); + QBrush(c), QPen(c, symbolWidth), QSize(5, 5)) ); curve->attach(this); } else { diff --git a/src/ui/linechart/IncrementalPlot.h b/src/ui/linechart/IncrementalPlot.h index bce6925bd2393b57705ff977bc01d5de8007d0bb..06dee02ff04e90449343b0392e326d39ecc81c84 100644 --- a/src/ui/linechart/IncrementalPlot.h +++ b/src/ui/linechart/IncrementalPlot.h @@ -86,11 +86,6 @@ public: /** @brief Read out data from a curve */ int data(QString key, double* r_x, double* r_y, int maxSize); - float symbolWidth; - float curveWidth; - float gridWidth; - float scaleWidth; - public slots: /** @brief Append one data point */ void appendData(QString key, double x, double y); diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc index 5e677818f6e0fd324bfe11ad5b026402776bcc87..098f451fed46335449bc9baf4f11244016e07af9 100644 --- a/src/ui/linechart/LinechartPlot.cc +++ b/src/ui/linechart/LinechartPlot.cc @@ -54,7 +54,6 @@ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): //lastMaxTimeAdded = QTime(); - curves = QMap(); data = QMap(); scaleMaps = QMap(); @@ -63,14 +62,6 @@ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): setAutoReplot(false); - // Set grid - QwtPlotGrid *grid = new QwtPlotGrid; - grid->setMinPen(QPen(Qt::darkGray, 0, Qt::DotLine)); - grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); - grid->enableXMin(true); - // TODO xmin? - grid->attach(this); - // Set left scale //setAxisOptions(QwtPlot::yLeft, QwtAutoScale::Logarithmic); @@ -87,15 +78,6 @@ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): plotLayout()->setAlignCanvasToScales(true); - // Set canvas background - setCanvasBackground(QColor(40, 40, 40)); - - // Enable zooming - //zoomer = new Zoomer(canvas()); - zoomer = new ScrollZoomer(canvas()); - zoomer->setRubberBandPen(QPen(Qt::blue, 1.2, Qt::DotLine)); - zoomer->setTrackerPen(QPen(Qt::blue)); - // Start QTimer for plot update updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(paintRealtime())); @@ -400,22 +382,6 @@ quint64 LinechartPlot::getWindowPosition() return plotPosition; } -/** - * @brief Set the color of a curve - * - * This method emits the colorSet(id, color) signal. - * - * @param id The id-string of the curve - * @param color The newly assigned color - **/ -void LinechartPlot::setCurveColor(QString id, QColor color) -{ - QwtPlotCurve* curve = curves.value(id); - curve->setPen(color); - - emit colorSet(id, color); -} - /** * @brief Set the scaling of the (vertical) y axis * The mapping of the variable values on the drawing pane can be @@ -495,6 +461,20 @@ void LinechartPlot::showCurve(QString id) // curves.value(id)->show(); //} +/** + * @brief Set the color of a curve + * + * This method emits the colorSet(id, color) signal. + * + * @param id The id-string of the curve + * @param color The newly assigned color + **/ +void LinechartPlot::setCurveColor(QString id, QColor color) +{ + QwtPlotCurve* curve = curves.value(id); + curve->setPen(color); +} + /** * @brief Check the visibility of a curve * diff --git a/src/ui/linechart/LinechartPlot.h b/src/ui/linechart/LinechartPlot.h index 6c6e16a1c91f78f390c274c142316e4bc4d94bff..66af4d2ce88f4fec52a0c00915de9de2e2417c1a 100644 --- a/src/ui/linechart/LinechartPlot.h +++ b/src/ui/linechart/LinechartPlot.h @@ -175,7 +175,6 @@ public: quint64 getPlotInterval(); quint64 getDataInterval(); quint64 getWindowPosition(); - QList getColorMap(); /** @brief Get the short-term mean of a curve */ double getMean(QString id); @@ -215,7 +214,13 @@ public slots: // Functions referring to the currently active plot void setVisible(QString id, bool visible); - //void showCurve(QString id, int position); + + /** + * @brief Set the color of a curve + * + * @param id The id-string of the curve + * @param color The newly assigned color + **/ void setCurveColor(QString id, QColor color); /** @brief Enforce the use of the receive timestamp */ @@ -291,13 +296,6 @@ signals: * @param color The curve color in the diagram **/ void curveAdded(QString idstring); - /** - * @brief This signal is emitted when a curve gets assigned a color - * - * @param idstring The id-string of the curve - * @param color The curve color in the diagram - **/ - void colorSet(QString idstring, QColor color); /** * @brief This signal is emitted when a curve is removed * diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index eb6600eaff49f2d303725b495bc1eec51f004e9c..ccd64f98b51aa4dd6c5cffb8d42bd94b7c36b1a9 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -61,7 +61,6 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent plotWindowLock(), curveListIndex(0), curveListCounter(0), - listedCurves(new QList()), curveLabels(new QMap()), curveMeans(new QMap()), curveMedians(new QMap()), @@ -154,8 +153,6 @@ LinechartWidget::~LinechartWidget() stopLogging(); if (activePlot) delete activePlot; activePlot = NULL; - delete listedCurves; - listedCurves = NULL; } void LinechartWidget::selectActiveSystem(int mav) diff --git a/src/ui/linechart/LinechartWidget.h b/src/ui/linechart/LinechartWidget.h index 3e57975c73529fc5f284a60c74d7100fd3777030..a775c303f182764f4e5b25432de8ae37769ad63f 100644 --- a/src/ui/linechart/LinechartWidget.h +++ b/src/ui/linechart/LinechartWidget.h @@ -95,7 +95,7 @@ public slots: void appendData(int uasId, const QString& curve, const QString& unit, quint64 value, quint64 usec); /** @brief Append double data to the given curve. */ void appendData(int uasId, const QString& curve, const QString& unit, double value, quint64 usec); - + void takeButtonClick(bool checked); void setPlotWindowPosition(int scrollBarValue); void setPlotWindowPosition(quint64 position); @@ -138,7 +138,6 @@ protected: int curveListIndex; int curveListCounter; ///< Counter of curves in curve list - QList* listedCurves; ///< Curves listed QMap* curveLabels; ///< References to the curve labels QMap curveNameLabels; ///< References to the curve labels QMap curveNames; ///< Full curve names