Browse Source

LinechartWidget - Make the scaling log button a propper toggle button

QGC4.4
John Tapsell 12 years ago
parent
commit
8538e1a8da
  1. 40
      src/ui/linechart/LinechartWidget.cc
  2. 4
      src/ui/linechart/LinechartWidget.h

40
src/ui/linechart/LinechartWidget.cc

@ -225,23 +225,14 @@ void LinechartWidget::createLayout()
layout->setRowStretch(0, 10); layout->setRowStretch(0, 10);
layout->setRowStretch(1, 1); layout->setRowStretch(1, 1);
// Linear scaling button
scalingLinearButton = createButton(this);
scalingLinearButton->setDefaultAction(setScalingLinear);
scalingLinearButton->setCheckable(true);
scalingLinearButton->setToolTip(tr("Set linear scale for Y axis"));
scalingLinearButton->setWhatsThis(tr("Set linear scale for Y axis"));
layout->addWidget(scalingLinearButton, 1, 0);
layout->setColumnStretch(0, 0);
// Logarithmic scaling button // Logarithmic scaling button
scalingLogButton = createButton(this); scalingLogButton = createButton(this);
scalingLogButton->setDefaultAction(setScalingLogarithmic); scalingLogButton->setText(tr("LOG"));
scalingLogButton->setCheckable(true); scalingLogButton->setCheckable(true);
scalingLogButton->setToolTip(tr("Set logarithmic scale for Y axis")); scalingLogButton->setToolTip(tr("Set logarithmic scale for Y axis"));
scalingLogButton->setWhatsThis(tr("Set logarithmic scale for Y axis")); scalingLogButton->setWhatsThis(tr("Set logarithmic scale for Y axis"));
layout->addWidget(scalingLogButton, 1, 1); layout->addWidget(scalingLogButton, 1, 0);
layout->setColumnStretch(1, 0); layout->setColumnStretch(0, 0);
// Averaging spin box // Averaging spin box
averageSpinBox = new QSpinBox(this); averageSpinBox = new QSpinBox(this);
@ -251,8 +242,8 @@ void LinechartWidget::createLayout()
averageSpinBox->setValue(200); averageSpinBox->setValue(200);
setAverageWindow(200); setAverageWindow(200);
averageSpinBox->setMaximum(9999); averageSpinBox->setMaximum(9999);
layout->addWidget(averageSpinBox, 1, 2); layout->addWidget(averageSpinBox, 1, 1);
layout->setColumnStretch(2, 0); layout->setColumnStretch(1, 0);
connect(averageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setAverageWindow(int))); connect(averageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setAverageWindow(int)));
// Log Button // Log Button
@ -260,8 +251,8 @@ void LinechartWidget::createLayout()
logButton->setToolTip(tr("Start to log curve data into a CSV or TXT file")); logButton->setToolTip(tr("Start to log curve data into a CSV or TXT file"));
logButton->setWhatsThis(tr("Start to log curve data into a CSV or TXT file")); logButton->setWhatsThis(tr("Start to log curve data into a CSV or TXT file"));
logButton->setText(tr("Start Logging")); logButton->setText(tr("Start Logging"));
layout->addWidget(logButton, 1, 3); layout->addWidget(logButton, 1, 2);
layout->setColumnStretch(3, 0); layout->setColumnStretch(2, 0);
connect(logButton, SIGNAL(clicked()), this, SLOT(startLogging())); connect(logButton, SIGNAL(clicked()), this, SLOT(startLogging()));
// Ground time button // Ground time button
@ -269,8 +260,8 @@ void LinechartWidget::createLayout()
timeButton->setText(tr("Ground Time")); timeButton->setText(tr("Ground Time"));
timeButton->setToolTip(tr("Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time.")); timeButton->setToolTip(tr("Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time."));
timeButton->setWhatsThis(tr("Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time.")); timeButton->setWhatsThis(tr("Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time."));
layout->addWidget(timeButton, 1, 4); layout->addWidget(timeButton, 1, 3);
layout->setColumnStretch(4, 0); layout->setColumnStretch(3, 0);
connect(timeButton, SIGNAL(clicked(bool)), activePlot, SLOT(enforceGroundTime(bool))); connect(timeButton, SIGNAL(clicked(bool)), activePlot, SLOT(enforceGroundTime(bool)));
connect(timeButton, SIGNAL(clicked()), this, SLOT(writeSettings())); connect(timeButton, SIGNAL(clicked()), this, SLOT(writeSettings()));
@ -294,8 +285,15 @@ void LinechartWidget::createLayout()
connect(this, SIGNAL(plotWindowPositionUpdated(quint64)), activePlot, SLOT(setWindowPosition(quint64))); connect(this, SIGNAL(plotWindowPositionUpdated(quint64)), activePlot, SLOT(setWindowPosition(quint64)));
// Set scaling // Set scaling
connect(scalingLinearButton, SIGNAL(clicked()), activePlot, SLOT(setLinearScaling())); connect(scalingLogButton, SIGNAL(toggled(bool)), this, SLOT(toggleLogarithmicScaling(bool)));
connect(scalingLogButton, SIGNAL(clicked()), activePlot, SLOT(setLogarithmicScaling())); }
void LinechartWidget::toggleLogarithmicScaling(bool checked)
{
if(checked)
activePlot->setLogarithmicScaling();
else
activePlot->setLinearScaling();
} }
void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, qint8 value, quint64 usec) void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, qint8 value, quint64 usec)
@ -626,8 +624,6 @@ void LinechartWidget::setAverageWindow(int windowSize)
void LinechartWidget::createActions() void LinechartWidget::createActions()
{ {
setScalingLogarithmic = new QAction("LOG", this);
setScalingLinear = new QAction("LIN", this);
} }
/** /**

4
src/ui/linechart/LinechartWidget.h

@ -96,6 +96,7 @@ public slots:
/** @brief Append double data to the given curve. */ /** @brief Append double data to the given curve. */
void appendData(int uasId, const QString& curve, const QString& unit, double value, quint64 usec); void appendData(int uasId, const QString& curve, const QString& unit, double value, quint64 usec);
void toggleLogarithmicScaling(bool toggled);
void takeButtonClick(bool checked); void takeButtonClick(bool checked);
void setPlotWindowPosition(int scrollBarValue); void setPlotWindowPosition(int scrollBarValue);
void setPlotWindowPosition(quint64 position); void setPlotWindowPosition(quint64 position);
@ -152,14 +153,11 @@ protected:
QScrollBar* scrollbar; ///< The plot window scroll bar QScrollBar* scrollbar; ///< The plot window scroll bar
QSpinBox* averageSpinBox; ///< Spin box to setup average window filter size QSpinBox* averageSpinBox; ///< Spin box to setup average window filter size
QAction* setScalingLogarithmic; ///< Set logarithmic scaling
QAction* setScalingLinear; ///< Set linear scaling
QAction* addNewCurve; ///< Add curve candidate to the active curves QAction* addNewCurve; ///< Add curve candidate to the active curves
QMenu* curveMenu; QMenu* curveMenu;
QGridLayout* mainLayout; QGridLayout* mainLayout;
QToolButton* scalingLinearButton;
QToolButton* scalingLogButton; QToolButton* scalingLogButton;
QToolButton* logButton; QToolButton* logButton;
QPointer<QCheckBox> timeButton; QPointer<QCheckBox> timeButton;

Loading…
Cancel
Save