diff --git a/src/ui/Linechart.ui b/src/ui/Linechart.ui
index a46a506..d56d7c2 100644
--- a/src/ui/Linechart.ui
+++ b/src/ui/Linechart.ui
@@ -29,7 +29,16 @@
-
+
+ 6
+
+
+ 6
+
+
+ 6
+
+
6
-
@@ -103,8 +112,8 @@
0
0
- 884
- 491
+ 879
+ 462
@@ -113,7 +122,7 @@
-
- 2
+ 4
-
@@ -139,7 +148,7 @@
-
- 0
+ 6
-
@@ -172,7 +181,7 @@
-
- 0
+ 6
QLayout::SetMinimumSize
diff --git a/src/ui/linechart/ChartPlot.cc b/src/ui/linechart/ChartPlot.cc
index 61f1de0..736120d 100644
--- a/src/ui/linechart/ChartPlot.cc
+++ b/src/ui/linechart/ChartPlot.cc
@@ -2,80 +2,72 @@
#include "QGCApplication.h"
const QColor ChartPlot::baseColors[numColors] = {
- QColor(242,255,128),
- QColor(70,80,242),
- QColor(232,33,47),
- QColor(116,251,110),
- QColor(81,183,244),
- QColor(234,38,107),
- QColor(92,247,217),
- QColor(151,59,239),
- QColor(231,72,28),
- QColor(236,48,221),
- QColor(75,133,243),
- QColor(203,254,121),
- QColor(104,64,240),
- QColor(200,54,238),
- QColor(104,250,138),
- QColor(235,43,165),
- QColor(98,248,176),
- QColor(161,252,116),
- QColor(87,231,246),
- QColor(230,126,23)
+ QColor(242, 255, 128),
+ QColor(70, 80, 242),
+ QColor(232, 33, 47),
+ QColor(116, 251, 110),
+ QColor(81, 183, 244),
+ QColor(234, 38, 107),
+ QColor(92, 247, 217),
+ QColor(151, 59, 239),
+ QColor(231, 72, 28),
+ QColor(236, 48, 221),
+ QColor(75, 133, 243),
+ QColor(203, 254, 121),
+ QColor(104, 64, 240),
+ QColor(200, 54, 238),
+ QColor(104, 250, 138),
+ QColor(235, 43, 165),
+ QColor(98, 248, 176),
+ QColor(161, 252, 116),
+ QColor(87, 231, 246),
+ QColor(230, 126, 23)
};
-ChartPlot::ChartPlot(QWidget *parent):
+ChartPlot::ChartPlot(QWidget* parent):
QwtPlot(parent),
- nextColorIndex(0),
- symbolWidth(2.0f),
- curveWidth(2.0f),
- gridWidth(0.8f)
+ _nextColorIndex(0),
+ _symbolWidth(2.0f),
+ _curveWidth(2.0f),
+ _gridWidth(0.8f)
{
// Initialize the list of curves.
- curves = QMap();
-
+ _curves = QMap();
// Set the grid. The colorscheme was already set in generateColorScheme().
- grid = new QwtPlotGrid;
- grid->enableXMin(true);
- grid->attach(this);
-
- colors = QList();
-
+ _grid = new QwtPlotGrid;
+ _grid->enableXMin(true);
+ _grid->attach(this);
+ _colors = QList();
///> Color map for plots, includes 20 colors
///> Map will start from beginning when the first 20 colors are exceeded
- for (int i = 0; i < numColors; ++i)
- {
- colors.append(baseColors[i]);
+ for(int i = 0; i < numColors; ++i) {
+ _colors.append(baseColors[i]);
}
-
// Now that all objects have been initialized, color everything.
styleChanged(qgcApp()->styleIsDark());
}
ChartPlot::~ChartPlot()
{
-
}
QColor ChartPlot::getNextColor()
{
- if(nextColorIndex >= colors.count())
- {
- nextColorIndex = 0;
+ if(_nextColorIndex >= _colors.count()) {
+ _nextColorIndex = 0;
}
- return colors[nextColorIndex++];
+ return _colors[_nextColorIndex++];
}
-QColor ChartPlot::getColorForCurve(const QString &id)
+QColor ChartPlot::getColorForCurve(const QString& id)
{
- return curves.value(id)->pen().color();
+ return _curves.value(id)->pen().color();
}
void ChartPlot::shuffleColors()
{
- foreach (QwtPlotCurve* curve, curves)
- {
- if (curve->isVisible()) {
+ foreach(QwtPlotCurve* curve, _curves) {
+ if(curve->isVisible()) {
QPen pen(curve->pen());
pen.setColor(getNextColor());
curve->setPen(pen);
@@ -86,32 +78,24 @@ void ChartPlot::shuffleColors()
void ChartPlot::styleChanged(bool styleIsDark)
{
// Generate a new color list for curves and recolor them.
- for (int i = 0; i < numColors; ++i)
- {
- colors[i] = styleIsDark ? baseColors[i].lighter(150) : baseColors[i].darker(150);
+ for(int i = 0; i < numColors; ++i) {
+ _colors[i] = styleIsDark ? baseColors[i].lighter(150) : baseColors[i].darker(150);
}
shuffleColors();
-
// Configure the rest of the UI colors based on the current theme.
- if (styleIsDark)
- {
+ if(styleIsDark) {
// Set canvas background
setCanvasBackground(QColor(0, 0, 0));
-
// Configure the plot grid.
- grid->setMinorPen(QPen(QColor(0xAA, 0xAA, 0xAA), gridWidth, Qt::DotLine));
- grid->setMajorPen(QPen(QColor(0xDD, 0xDD, 0xDD), gridWidth, Qt::DotLine));
- }
- else
- {
+ _grid->setMinorPen(QPen(QColor(64, 64, 64), _gridWidth, Qt::SolidLine));
+ _grid->setMajorPen(QPen(QColor(96, 96, 96), _gridWidth, Qt::SolidLine));
+ } else {
// Set canvas background
setCanvasBackground(QColor(0xFF, 0xFF, 0xFF));
-
// Configure the plot grid.
- grid->setMinorPen(QPen(QColor(0x55, 0x55, 0x55), gridWidth, Qt::DotLine));
- grid->setMajorPen(QPen(QColor(0x22, 0x22, 0x22), gridWidth, Qt::DotLine));
+ _grid->setMinorPen(QPen(QColor(192, 192, 192), _gridWidth, Qt::SolidLine));
+ _grid->setMajorPen(QPen(QColor(128, 128, 128), _gridWidth, Qt::SolidLine));
}
-
// And finally refresh the widget to make sure all color changes are redrawn.
replot();
}
diff --git a/src/ui/linechart/ChartPlot.h b/src/ui/linechart/ChartPlot.h
index acbb85a..1a6a5b5 100644
--- a/src/ui/linechart/ChartPlot.h
+++ b/src/ui/linechart/ChartPlot.h
@@ -31,14 +31,15 @@ public slots:
protected:
const static int numColors = 20;
const static QColor baseColors[numColors];
- QList colors; ///< Colormap for curves
- int nextColorIndex; ///< Next index in color map
- QMap curves; ///< Plot curves
- 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
+
+ QList _colors; ///< Colormap for curves
+ int _nextColorIndex; ///< Next index in color map
+ QMap _curves; ///< Plot curves
+ 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
};
#endif // CHARTPLOT_H
diff --git a/src/ui/linechart/IncrementalPlot.cc b/src/ui/linechart/IncrementalPlot.cc
index ff594e2..11f336e 100644
--- a/src/ui/linechart/IncrementalPlot.cc
+++ b/src/ui/linechart/IncrementalPlot.cc
@@ -143,7 +143,7 @@ void IncrementalPlot::showLegend(bool show)
void IncrementalPlot::setStyleText(const QString &style)
{
styleText = style.toLower();
- foreach (QwtPlotCurve* curve, curves) {
+ foreach (QwtPlotCurve* curve, _curves) {
updateStyle(curve);
}
replot();
@@ -161,24 +161,24 @@ void IncrementalPlot::updateStyle(QwtPlotCurve *curve)
// Update the symbol style
QwtSymbol *newSymbol = NULL;
if (styleText.contains("circles")) {
- newSymbol = new QwtSymbol(QwtSymbol::Ellipse, Qt::NoBrush, QPen(oldColor, symbolWidth), QSize(6, 6));
+ newSymbol = new QwtSymbol(QwtSymbol::Ellipse, Qt::NoBrush, QPen(oldColor, _symbolWidth), QSize(6, 6));
} else if (styleText.contains("crosses")) {
- newSymbol = new QwtSymbol(QwtSymbol::XCross, Qt::NoBrush, QPen(oldColor, symbolWidth), QSize(5, 5));
+ newSymbol = new QwtSymbol(QwtSymbol::XCross, Qt::NoBrush, QPen(oldColor, _symbolWidth), QSize(5, 5));
} else if (styleText.contains("rect")) {
- newSymbol = new QwtSymbol(QwtSymbol::Rect, Qt::NoBrush, QPen(oldColor, symbolWidth), QSize(6, 6));
+ newSymbol = new QwtSymbol(QwtSymbol::Rect, Qt::NoBrush, QPen(oldColor, _symbolWidth), QSize(6, 6));
}
// Else-case already handled by NULL value, which indicates no symbol
curve->setSymbol(newSymbol);
// Update the line style
if (styleText.contains("dotted")) {
- curve->setPen(QPen(oldColor, curveWidth, Qt::DotLine));
+ curve->setPen(QPen(oldColor, _curveWidth, Qt::DotLine));
} else if (styleText.contains("dashed")) {
- curve->setPen(QPen(oldColor, curveWidth, Qt::DashLine));
+ curve->setPen(QPen(oldColor, _curveWidth, Qt::DashLine));
} else if (styleText.contains("line") || styleText.contains("solid")) {
- curve->setPen(QPen(oldColor, curveWidth, Qt::SolidLine));
+ curve->setPen(QPen(oldColor, _curveWidth, Qt::SolidLine));
} else {
- curve->setPen(QPen(oldColor, curveWidth, Qt::NoPen));
+ curve->setPen(QPen(oldColor, _curveWidth, Qt::NoPen));
}
curve->setStyle(QwtPlotCurve::Lines);
}
@@ -260,22 +260,22 @@ void IncrementalPlot::appendData(const QString &key, double *x, double *y, int s
}
// If this is a new curve, create it.
- if (!curves.contains(key)) {
+ if (!_curves.contains(key)) {
curve = new QwtPlotCurve(key);
- curves.insert(key, curve);
+ _curves.insert(key, curve);
curve->setStyle(QwtPlotCurve::NoCurve);
curve->setPaintAttribute(QwtPlotCurve::FilterPoints);
// Set the color. Only the pen needs to be set
const QColor &c = getNextColor();
- curve->setPen(c, symbolWidth);
+ curve->setPen(c, _symbolWidth);
qDebug() << "Creating curve" << key << "with color" << c;
updateStyle(curve);
curve->attach(this);
} else {
- curve = curves.value(key);
+ curve = _curves.value(key);
}
data->append(x, y, size);
@@ -359,21 +359,21 @@ int IncrementalPlot::data(const QString &key, double* r_x, double* r_y, int maxS
*/
void IncrementalPlot::showGrid(bool show)
{
- grid->setVisible(show);
+ _grid->setVisible(show);
replot();
}
bool IncrementalPlot::gridEnabled() const
{
- return grid->isVisible();
+ return _grid->isVisible();
}
void IncrementalPlot::removeData()
{
- foreach (QwtPlotCurve* curve, curves) {
+ foreach (QwtPlotCurve* curve, _curves) {
delete curve;
}
- curves.clear();
+ _curves.clear();
foreach (CurveData* data, d_data) {
delete data;
diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc
index dc6b84f..61d14b8 100644
--- a/src/ui/linechart/LinechartPlot.cc
+++ b/src/ui/linechart/LinechartPlot.cc
@@ -190,7 +190,7 @@ void LinechartPlot::removeTimedOutCurves()
{
// Remove this curve
// Delete curves
- QwtPlotCurve* curve = curves.take(key);
+ QwtPlotCurve* curve = _curves.take(key);
// Delete the object
delete curve;
// Set the pointer null
@@ -276,7 +276,7 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value)
valueInterval = maxValue - minValue;
// Assign dataset to curve
- QwtPlotCurve* curve = curves.value(dataname);
+ QwtPlotCurve* curve = _curves.value(dataname);
curve->setRawSamples(dataset->getPlotX(), dataset->getPlotY(), dataset->getPlotCount());
// qDebug() << "mintime" << minTime << "maxtime" << maxTime << "last max time" << "window position" << getWindowPosition();
@@ -321,7 +321,7 @@ void LinechartPlot::addCurve(QString id)
// Create new curve and set style
QwtPlotCurve* curve = new QwtPlotCurve(id);
// Add curve to list
- curves.insert(id, curve);
+ _curves.insert(id, curve);
curve->setStyle(QwtPlotCurve::Lines);
curve->setPaintAttribute(QwtPlotCurve::FilterPoints, true);
@@ -414,15 +414,15 @@ void LinechartPlot::setScaling(int scaling)
**/
void LinechartPlot::setVisibleById(QString id, bool visible)
{
- if(curves.contains(id)) {
- curves.value(id)->setVisible(visible);
+ if(_curves.contains(id)) {
+ _curves.value(id)->setVisible(visible);
if(visible)
{
- curves.value(id)->attach(this);
+ _curves.value(id)->attach(this);
}
else
{
- curves.value(id)->detach();
+ _curves.value(id)->detach();
}
}
}
@@ -467,9 +467,9 @@ void LinechartPlot::showCurve(QString id)
**/
void LinechartPlot::setCurveColor(QString id, QColor color)
{
- QwtPlotCurve* curve = curves.value(id);
+ QwtPlotCurve* curve = _curves.value(id);
// Change the color of the curve.
- curve->setPen(QPen(QBrush(color), curveWidth));
+ curve->setPen(QPen(QBrush(color), _curveWidth));
//qDebug() << "Setting curve" << id << "to" << color;
@@ -477,7 +477,7 @@ void LinechartPlot::setCurveColor(QString id, QColor color)
const QwtSymbol *oldSymbol = curve->symbol();
QwtSymbol *newSymbol = NULL;
if (oldSymbol) {
- newSymbol = new QwtSymbol(oldSymbol->style(), QBrush(color), QPen(color, symbolWidth), QSize(symbolWidth, symbolWidth));
+ newSymbol = new QwtSymbol(oldSymbol->style(), QBrush(color), QPen(color, _symbolWidth), QSize(_symbolWidth, _symbolWidth));
}
curve->setSymbol(newSymbol);
}
@@ -490,7 +490,7 @@ void LinechartPlot::setCurveColor(QString id, QColor color)
**/
bool LinechartPlot::isVisible(QString id)
{
- return curves.value(id)->isVisible();
+ return _curves.value(id)->isVisible();
}
/**
@@ -499,9 +499,9 @@ bool LinechartPlot::isVisible(QString id)
bool LinechartPlot::anyCurveVisible()
{
bool visible = false;
- foreach (const QString &key, curves.keys())
+ foreach (const QString &key, _curves.keys())
{
- if (curves.value(key)->isVisible())
+ if (_curves.value(key)->isVisible())
{
visible = true;
}
@@ -530,7 +530,7 @@ void LinechartPlot::setAutoScroll(bool active)
**/
QList LinechartPlot::getCurves()
{
- return curves.values();
+ return _curves.values();
}
/**
@@ -702,10 +702,10 @@ void LinechartPlot::removeAllData()
datalock.lock();
// Delete curves
QMap::iterator i;
- for(i = curves.begin(); i != curves.end(); ++i)
+ for(i = _curves.begin(); i != _curves.end(); ++i)
{
// Remove from curve list
- QwtPlotCurve* curve = curves.take(i.key());
+ QwtPlotCurve* curve = _curves.take(i.key());
// Delete the object
delete curve;
// Set the pointer null
diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc
index ba6ca04..339e1f8 100644
--- a/src/ui/linechart/LinechartWidget.cc
+++ b/src/ui/linechart/LinechartWidget.cc
@@ -52,7 +52,6 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent
curveMeans(new QMap()),
curveMedians(new QMap()),
curveVariances(new QMap()),
- curveMenu(new QMenu(this)),
logFile(new QFile()),
logindex(1),
logging(false),
@@ -63,34 +62,28 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent
{
// Add elements defined in Qt Designer
ui.setupUi(this);
- this->setMinimumSize(200, 150);
+ this->setMinimumSize(600, 400);
// Add and customize curve list elements (left side)
curvesWidget = new QWidget(ui.curveListWidget);
ui.curveListWidget->setWidget(curvesWidget);
curvesWidgetLayout = new QGridLayout(curvesWidget);
- curvesWidgetLayout->setMargin(2);
- curvesWidgetLayout->setSpacing(4);
- //curvesWidgetLayout->setSizeConstraint(QSizePolicy::Expanding);
+ curvesWidgetLayout->setMargin(6);
+ curvesWidgetLayout->setSpacing(6);
curvesWidgetLayout->setAlignment(Qt::AlignTop);
+ curvesWidgetLayout->setColumnMinimumWidth(0, 10);
curvesWidgetLayout->setColumnStretch(0, 0);
- curvesWidgetLayout->setColumnStretch(1, 0);
+ curvesWidgetLayout->setColumnStretch(1, 10);
curvesWidgetLayout->setColumnStretch(2, 80);
curvesWidgetLayout->setColumnStretch(3, 50);
curvesWidgetLayout->setColumnStretch(4, 50);
curvesWidgetLayout->setColumnStretch(5, 50);
-// horizontalLayout->setColumnStretch(median, 50);
curvesWidgetLayout->setColumnStretch(6, 50);
curvesWidget->setLayout(curvesWidgetLayout);
// Create curve list headings
- QLabel* label;
- QLabel* value;
- QLabel* mean;
- QLabel* variance;
-
connect(ui.recolorButton, &QPushButton::clicked, this, &LinechartWidget::recolor);
connect(ui.shortNameCheckBox, &QCheckBox::clicked, this, &LinechartWidget::setShortNames);
connect(ui.plotFilterLineEdit, &QLineEdit::textChanged, this, &LinechartWidget::filterCurves);
@@ -100,31 +93,24 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent
int labelRow = curvesWidgetLayout->rowCount();
- selectAllCheckBox = new QCheckBox("", this);
+ selectAllCheckBox = new QCheckBox(this);
connect(selectAllCheckBox, &QCheckBox::clicked, this, &LinechartWidget::selectAllCurves);
- curvesWidgetLayout->addWidget(selectAllCheckBox, labelRow, 0, 1, 2);
+ curvesWidgetLayout->addWidget(selectAllCheckBox, labelRow, 0);
- label = new QLabel(this);
- label->setText("Name");
- curvesWidgetLayout->addWidget(label, labelRow, 2);
+ QWidget* colorIcon = new QWidget(this);
+ colorIcon->setMinimumSize(QSize(5, 14));
+ colorIcon->setMaximumSize(QSize(5, 14));
+ curvesWidgetLayout->addWidget(colorIcon, labelRow, 1);
- // Value
- value = new QLabel(this);
- value->setText("Val");
- curvesWidgetLayout->addWidget(value, labelRow, 3);
+ curvesWidgetLayout->addWidget(new QLabel(tr("Name")), labelRow, 2);
+ curvesWidgetLayout->addWidget(new QLabel(tr("Val")), labelRow, 3, Qt::AlignRight);
- // Unit
- //curvesWidgetLayout->addWidget(new QLabel(tr("Unit")), labelRow, 4);
+ QLabel* pUnit = new QLabel(tr("Unit"));
+ curvesWidgetLayout->addWidget(pUnit, labelRow, 4);
- // Mean
- mean = new QLabel(this);
- mean->setText("Mean");
- curvesWidgetLayout->addWidget(mean, labelRow, 5);
+ curvesWidgetLayout->addWidget(new QLabel(tr("Mean")), labelRow, 5, Qt::AlignRight);
+ curvesWidgetLayout->addWidget(new QLabel(tr("Variance")), labelRow, 6, Qt::AlignRight);
- // Variance
- variance = new QLabel(this);
- variance->setText("Variance");
- curvesWidgetLayout->addWidget(variance, labelRow, 6);
// Create the layout
createLayout();
@@ -134,9 +120,11 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent
updateTimer->setInterval(updateInterval);
connect(updateTimer, &QTimer::timeout, this, &LinechartWidget::refresh);
- connect(ui.uasSelectionBox, static_cast(&QComboBox::currentIndexChanged),
- this, &LinechartWidget::selectActiveSystem);
+ connect(ui.uasSelectionBox, static_cast(&QComboBox::currentIndexChanged), this, &LinechartWidget::selectActiveSystem);
+
readSettings();
+ pUnit->setVisible(ui.showUnitsCheckBox->isChecked());
+ connect(ui.showUnitsCheckBox, &QCheckBox::clicked, pUnit, &QLabel::setVisible);
}
LinechartWidget::~LinechartWidget()
@@ -320,24 +308,25 @@ void LinechartWidget::appendData(int uasId, const QString& curve, const QString&
if(!ok || type == QMetaType::QByteArray || type == QMetaType::QString)
return;
bool isDouble = type == QMetaType::Float || type == QMetaType::Double;
+ QString curveID = curve + unit;
if ((selectedMAV == -1 && isVisible()) || (selectedMAV == uasId && isVisible()))
{
// Order matters here, first append to plot, then update curve list
- activePlot->appendData(curve+unit, usec, value);
+ activePlot->appendData(curveID, usec, value);
// Store data
- QLabel* label = curveLabels->value(curve+unit, NULL);
+ QLabel* label = curveLabels->value(curveID, NULL);
// Make sure the curve will be created if it does not yet exist
if(!label)
{
if(!isDouble)
- intData.insert(curve+unit, 0);
+ intData.insert(curveID, 0);
addCurve(curve, unit);
}
// Add int data
if(!isDouble)
- intData.insert(curve+unit, variant.toInt());
+ intData.insert(curveID, variant.toInt());
}
if (lastTimestamp == 0 && usec != 0)
@@ -360,7 +349,7 @@ void LinechartWidget::appendData(int uasId, const QString& curve, const QString&
// Log data
if (logging)
{
- if (activePlot->isVisible(curve+unit))
+ if (activePlot->isVisible(curveID))
{
if (usec == 0) usec = QGC::groundTimeMilliseconds();
if (logStartTime == 0) logStartTime = usec;
@@ -514,67 +503,59 @@ void LinechartWidget::createActions()
void LinechartWidget::addCurve(const QString& curve, const QString& unit)
{
LinechartPlot* plot = activePlot;
-// QHBoxLayout *horizontalLayout;
- QCheckBox *checkBox;
- QLabel* label;
- QLabel* value;
- QLabel* unitLabel;
- QLabel* mean;
- QLabel* variance;
-
- curveNames.insert(curve+unit, curve);
-
+ QString curveID = curve + unit;
+ curveNames.insert(curveID, curve);
int labelRow = curvesWidgetLayout->rowCount();
// Checkbox
- checkBox = new QCheckBox(this);
+ QCheckBox* checkBox = new QCheckBox(this);
checkBox->setCheckable(true);
- checkBox->setObjectName(curve+unit);
+ checkBox->setObjectName(curveID);
checkBox->setToolTip(tr("Enable the curve in the graph window"));
checkBox->setWhatsThis(tr("Enable the curve in the graph window"));
- checkBoxes.insert(curve+unit, checkBox);
+ checkBoxes.insert(curveID, checkBox);
curvesWidgetLayout->addWidget(checkBox, labelRow, 0);
// Icon
QWidget* colorIcon = new QWidget(this);
- colorIcons.insert(curve+unit, colorIcon);
+ colorIcons.insert(curveID, colorIcon);
colorIcon->setMinimumSize(QSize(5, 14));
- colorIcon->setMaximumSize(4, 14);
+ colorIcon->setMaximumSize(QSize(5, 14));
curvesWidgetLayout->addWidget(colorIcon, labelRow, 1);
// Label
- label = new QLabel(this);
- label->setText(getCurveName(curve+unit, ui.shortNameCheckBox->isChecked()));
- curveNameLabels.insert(curve+unit, label);
+ QLabel* label = new QLabel(this);
+ label->setText(getCurveName(curveID, ui.shortNameCheckBox->isChecked()));
+ curveNameLabels.insert(curveID, label);
curvesWidgetLayout->addWidget(label, labelRow, 2);
// Value
- value = new QLabel(this);
+ QLabel* value = new QLabel(this);
value->setNum(0.00);
value->setStyleSheet(QString("QLabel {font-family:\"Courier\"; font-weight: bold;}"));
value->setToolTip(tr("Current value of %1 in %2 units").arg(curve, unit));
value->setWhatsThis(tr("Current value of %1 in %2 units").arg(curve, unit));
- curveLabels->insert(curve+unit, value);
- curvesWidgetLayout->addWidget(value, labelRow, 3);
+ curveLabels->insert(curveID, value);
+ curvesWidgetLayout->addWidget(value, labelRow, 3, Qt::AlignRight);
// Unit
- unitLabel = new QLabel(this);
+ QLabel* unitLabel = new QLabel(this);
unitLabel->setText(unit);
unitLabel->setToolTip(tr("Unit of ") + curve);
unitLabel->setWhatsThis(tr("Unit of ") + curve);
- curveUnits.insert(curve+unit, unitLabel);
+ curveUnits.insert(curveID, unitLabel);
curvesWidgetLayout->addWidget(unitLabel, labelRow, 4);
unitLabel->setVisible(ui.showUnitsCheckBox->isChecked());
connect(ui.showUnitsCheckBox, &QCheckBox::clicked, unitLabel, &QLabel::setVisible);
// Mean
- mean = new QLabel(this);
+ QLabel* mean = new QLabel(this);
mean->setNum(0.00);
mean->setStyleSheet(QString("QLabel {font-family:\"Courier\"; font-weight: bold;}"));
mean->setToolTip(tr("Arithmetic mean of %1 in %2 units").arg(curve, unit));
mean->setWhatsThis(tr("Arithmetic mean of %1 in %2 units").arg(curve, unit));
- curveMeans->insert(curve+unit, mean);
- curvesWidgetLayout->addWidget(mean, labelRow, 5);
+ curveMeans->insert(curveID, mean);
+ curvesWidgetLayout->addWidget(mean, labelRow, 5, Qt::AlignRight);
// // Median
// median = new QLabel(form);
@@ -583,13 +564,13 @@ void LinechartWidget::addCurve(const QString& curve, const QString& unit)
// horizontalLayout->addWidget(median);
// Variance
- variance = new QLabel(this);
+ QLabel* variance = new QLabel(this);
variance->setNum(0.00);
variance->setStyleSheet(QString("QLabel {font-family:\"Courier\"; font-weight: bold;}"));
variance->setToolTip(tr("Variance of %1 in (%2)^2 units").arg(curve, unit));
variance->setWhatsThis(tr("Variance of %1 in (%2)^2 units").arg(curve, unit));
- curveVariances->insert(curve+unit, variance);
- curvesWidgetLayout->addWidget(variance, labelRow, 6);
+ curveVariances->insert(curveID, variance);
+ curvesWidgetLayout->addWidget(variance, labelRow, 6, Qt::AlignRight);
/* Color picker
QColor color = QColorDialog::getColor(Qt::green, this);
@@ -612,7 +593,7 @@ void LinechartWidget::addCurve(const QString& curve, const QString& unit)
// Set UI components to initial state
checkBox->setChecked(false);
- plot->setVisibleById(curve+unit, false);
+ plot->setVisibleById(curveID, false);
}
/**
@@ -684,7 +665,7 @@ void LinechartWidget::filterCurve(const QString &key, bool match)
(*curveLabels)[key]->setVisible(match);
(*curveMeans)[key]->setVisible(match);
(*curveVariances)[key]->setVisible(match);
- curveUnits[key]->setVisible(match);
+ curveUnits[key]->setVisible(match && ui.showUnitsCheckBox->isChecked());
checkBoxes[key]->setVisible(match);
}
}
diff --git a/src/ui/linechart/LinechartWidget.h b/src/ui/linechart/LinechartWidget.h
index cac806a..372acfa 100644
--- a/src/ui/linechart/LinechartWidget.h
+++ b/src/ui/linechart/LinechartWidget.h
@@ -138,7 +138,6 @@ protected:
QAction* addNewCurve; ///< Add curve candidate to the active curves
- QMenu* curveMenu;
QComboBox *timeScaleCmb;
QToolButton* scalingLogButton;