Skip to content

Commit 81db985

Browse files
committed
Show width and height over arc length if there is a valid profile curve
1 parent 29222d1 commit 81db985

2 files changed

Lines changed: 35 additions & 38 deletions

File tree

gui/source/pre/views/limb2d/HeightPlotView.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void HeightPlotView::updatePlot() {
5050
return;
5151
}
5252

53-
xAxis->setLabel("Length " + Quantities::ratio.getUnit().getLabel());
53+
// Y axis always shows the width in length units
5454
yAxis->setLabel("Height " + Quantities::length.getUnit().getLabel());
5555

5656
graphLine->data()->clear();
@@ -60,41 +60,40 @@ void HeightPlotView::updatePlot() {
6060
int iLayer = index.row(); // Layer index comes from row of the model index
6161

6262
if(model->hasGeometry()) {
63+
// If the geometry is valid, the x axis shows the length in length units
64+
xAxis->setLabel("Length " + Quantities::length.getUnit().getLabel());
65+
66+
// Line
6367
for(size_t i = 0; i < model->getGeometry().ratio.size(); ++i) {
6468
graphLine->addData(
65-
Quantities::ratio.getUnit().fromBase(model->getGeometry().ratio[i]),
69+
Quantities::length.getUnit().fromBase(model->getGeometry().length[i]),
6670
Quantities::length.getUnit().fromBase(model->getGeometry().heights[i][iLayer])
6771
);
6872
}
69-
}
7073

71-
if(model->hasBow()) {
74+
// Points
75+
double length = model->getGeometry().length.back(); // Total length for scaling of the control points
7276
const Layer& layer = *std::next(model->getBow().section.layers.begin(), iLayer);
7377
for(auto& point: layer.height) {
7478
graphPoints->addData(
75-
Quantities::ratio.getUnit().fromBase(point[0]),
79+
Quantities::length.getUnit().fromBase(length*point[0]),
7680
Quantities::length.getUnit().fromBase(point[1])
7781
);
7882
}
7983
}
84+
else if(model->hasBow()) {
85+
// If the geometry is invalid, the x axis shows the length in relative units, so that the control points can still be shown
86+
xAxis->setLabel("Length " + Quantities::ratio.getUnit().getLabel());
8087

81-
/*
82-
// Control points
83-
for(int i = 0; i < input.size(); ++i) {
84-
if(selection.contains(i)) {
85-
this->graph(2)->addData(
86-
x_quantity.getUnit().fromBase(input[i][0]),
87-
y_quantity.getUnit().fromBase(input[i][1])
88-
);
89-
}
90-
else {
91-
this->graph(1)->addData(
92-
x_quantity.getUnit().fromBase(input[i][0]),
93-
y_quantity.getUnit().fromBase(input[i][1])
88+
// Points
89+
const Layer& layer = *std::next(model->getBow().section.layers.begin(), iLayer);
90+
for(auto& point: layer.height) {
91+
graphPoints->addData(
92+
Quantities::ratio.getUnit().fromBase(point[0]),
93+
Quantities::length.getUnit().fromBase(point[1])
9494
);
9595
}
9696
}
97-
*/
9897

9998
this->rescaleAxes(true, true, 1.0, 1.05);
10099
this->replot();

gui/source/pre/views/limb2d/WidthPlotView.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,44 @@ WidthPlotView::WidthPlotView(MainModel* model):
4444
}
4545

4646
void WidthPlotView::updatePlot() {
47-
xAxis->setLabel("Length " + Quantities::ratio.getUnit().getLabel());
47+
// Y axis always shows the width in length units
4848
yAxis->setLabel("Width " + Quantities::length.getUnit().getLabel());
4949

5050
graphLine->data()->clear();
5151
graphPoints->data()->clear();
5252
graphSelected->data()->clear();
5353

5454
if(model->hasGeometry()) {
55+
// If the geometry is valid, the x axis shows the length in length units
56+
xAxis->setLabel("Length " + Quantities::length.getUnit().getLabel());
57+
58+
// Line
5559
graphLine->addData(
56-
Quantities::ratio.getUnit().fromBase(model->getGeometry().ratio),
60+
Quantities::length.getUnit().fromBase(model->getGeometry().length),
5761
Quantities::length.getUnit().fromBase(model->getGeometry().width)
5862
);
59-
}
6063

61-
if(model->hasBow()) {
64+
// Points
65+
double length = model->getGeometry().length.back(); // Total length for scaling of the control points
6266
for(auto& point: model->getBow().section.width) {
6367
graphPoints->addData(
64-
Quantities::ratio.getUnit().fromBase(point[0]),
68+
Quantities::length.getUnit().fromBase(length*point[0]),
6569
Quantities::length.getUnit().fromBase(point[1])
6670
);
6771
}
6872
}
73+
else if(model->hasBow()) {
74+
// If the geometry is invalid, the x axis shows the length in relative units, so that the control points can still be shown
75+
xAxis->setLabel("Length " + Quantities::ratio.getUnit().getLabel());
6976

70-
/*
71-
// Control points
72-
for(int i = 0; i < input.size(); ++i) {
73-
if(selection.contains(i)) {
74-
this->graph(2)->addData(
75-
x_quantity.getUnit().fromBase(input[i][0]),
76-
y_quantity.getUnit().fromBase(input[i][1])
77-
);
78-
}
79-
else {
80-
this->graph(1)->addData(
81-
x_quantity.getUnit().fromBase(input[i][0]),
82-
y_quantity.getUnit().fromBase(input[i][1])
77+
// Points
78+
for(auto& point: model->getBow().section.width) {
79+
graphPoints->addData(
80+
Quantities::ratio.getUnit().fromBase(point[0]),
81+
Quantities::length.getUnit().fromBase(point[1])
8382
);
8483
}
8584
}
86-
*/
8785

8886
this->rescaleAxes(true, true, 1.0, 1.05);
8987
this->replot();

0 commit comments

Comments
 (0)