Skip to content

Commit a11f301

Browse files
committed
Add more tooltips for output results
Closes #17
1 parent 2afc40d commit a11f301

File tree

13 files changed

+202
-105
lines changed

13 files changed

+202
-105
lines changed

gui/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ add_executable(
218218
source/post/DrawForcePlot.hpp
219219
source/post/EnergyPlot.cpp
220220
source/post/EnergyPlot.hpp
221-
source/post/NumberGrid.cpp
222-
source/post/NumberGrid.hpp
221+
source/post/OutputGrid.cpp
222+
source/post/OutputGrid.hpp
223223
source/post/OutputWidget.cpp
224224
source/post/OutputWidget.hpp
225225
source/post/ShapePlot.cpp

gui/source/post/ComboPlot.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#include "ComboPlot.hpp"
2+
#include "pre/Language.hpp"
23

34
ComboPlot::ComboPlot()
4-
: combo_x(new QComboBox()),
5-
combo_y(new QComboBox()),
6-
plot(new PlotWidget()),
5+
: plot(new PlotWidget()),
76
curve(new QCPCurve(plot->xAxis, plot->yAxis))
87
{
8+
combo_x = new QComboBox();
9+
combo_x->setToolTip(Tooltips::SelectPlotChannelX);
10+
11+
combo_y = new QComboBox();
12+
combo_y->setToolTip(Tooltips::SelectPlotChannelY);
13+
914
curve->setName("Line");
1015
curve->setPen({Qt::blue, 2.0});
1116

gui/source/post/NumberGrid.hpp

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "NumberGrid.hpp"
1+
#include "OutputGrid.hpp"
22
#include "pre/widgets/DoubleOutput.hpp"
33
#include "pre/models/units/Quantity.hpp"
44
#include <QHBoxLayout>
@@ -8,7 +8,7 @@
88
#include <QLineEdit>
99
#include <QLabel>
1010

11-
NumberGrid::NumberGrid()
11+
OutputGrid::OutputGrid()
1212
: columnLayout(new QHBoxLayout()),
1313
currentColumn(nullptr),
1414
currentGrid(nullptr)
@@ -19,7 +19,7 @@ NumberGrid::NumberGrid()
1919
this->setLayout(columnLayout);
2020
}
2121

22-
void NumberGrid::addColumn() {
22+
void OutputGrid::addColumn() {
2323
// Create new column
2424
currentColumn = new QVBoxLayout();
2525
currentColumn->addStretch();
@@ -32,7 +32,7 @@ void NumberGrid::addColumn() {
3232
columnLayout->insertLayout(i, currentColumn);
3333
}
3434

35-
void NumberGrid::addGroup(const QString& name) {
35+
void OutputGrid::addGroup(const QString& name) {
3636
if(currentColumn == nullptr) {
3737
addColumn();
3838
}
@@ -46,7 +46,7 @@ void NumberGrid::addGroup(const QString& name) {
4646
currentColumn->insertWidget(i, group);
4747
}
4848

49-
void NumberGrid::addHeaders(const QStringList& headers) {
49+
void OutputGrid::addHeaders(const QStringList& headers) {
5050
if(currentColumn == nullptr) {
5151
addColumn();
5252
}
@@ -63,7 +63,11 @@ void NumberGrid::addHeaders(const QStringList& headers) {
6363
}
6464
}
6565

66-
void NumberGrid::addValues(const QString& name, const QList<double>& values, const QList<const Quantity*> quantities, const QList<double>& allowed, const QList<double>& maximum, int decimals) {
66+
void OutputGrid::addValue(const QString& name, QWidget* widget) {
67+
addValues(name, {widget});
68+
}
69+
70+
void OutputGrid::addValues(const QString& name, QList<QWidget*> widgets) {
6771
if(currentColumn == nullptr) {
6872
addColumn();
6973
}
@@ -74,20 +78,10 @@ void NumberGrid::addValues(const QString& name, const QList<double>& values, con
7478

7579
int row = currentGrid->rowCount();
7680
auto label = new QLabel(name);
77-
currentGrid->addWidget(label, row, 0);
7881

79-
for(int col = 0; col < values.size(); ++col) {
80-
auto output = new DoubleOutput(values[col], *quantities[col], decimals);
81-
currentGrid->addWidget(output, row, col + 1);
82-
83-
// Set warning limits if nonzero ones are given
84-
if(col < allowed.size() && col < maximum.size() && allowed[col] != 0.0 && maximum[col] != 0.0) {
85-
output->setAllowedLimit(allowed[col]);
86-
output->setMaximumLimit(maximum[col]);
87-
}
82+
currentGrid->addWidget(label, row, 0);
83+
for(int col = 0; col < widgets.size(); ++col) {
84+
currentGrid->addWidget(widgets[col], row, col + 1);
8885
}
8986
}
9087

91-
void NumberGrid::addValue(const QString& name, double value, const Quantity& quantity, int decimals) {
92-
addValues(name, {value}, {&quantity}, {}, {}, decimals);
93-
}

gui/source/post/OutputGrid.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
#include <QWidget>
3+
4+
class Quantity;
5+
class QHBoxLayout;
6+
class QVBoxLayout;
7+
class QGridLayout;
8+
9+
class OutputGrid : public QWidget {
10+
public:
11+
OutputGrid();
12+
13+
void addColumn();
14+
void addGroup(const QString& name);
15+
void addHeaders(const QStringList& headers);
16+
17+
void addValue(const QString& name, QWidget* widget);
18+
void addValues(const QString& name, QList<QWidget*> widgets);
19+
20+
//void addValues(const QString& name, const QList<double>& values, const QList<const Quantity*> quantities, const QList<double>& allowed = {}, const QList<double>& maximum = {}, int decimals = 2);
21+
//void addValue(const QString& name, double value, const Quantity& quantity, int decimals = 2);
22+
23+
private:
24+
QHBoxLayout* columnLayout;
25+
QVBoxLayout* currentColumn;
26+
QGridLayout* currentGrid;
27+
};

0 commit comments

Comments
 (0)