Skip to content

Commit fef55d0

Browse files
committed
Implement new handle and draw length inputs in the UI
Closes #203
1 parent be1a895 commit fef55d0

24 files changed

Lines changed: 328 additions & 47 deletions

gui/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ add_executable(
6767
source/pre/models/CommentsModel.hpp
6868
source/pre/models/DampingModel.cpp
6969
source/pre/models/DampingModel.hpp
70+
source/pre/models/HandleModel.cpp
71+
source/pre/models/HandleModel.hpp
7072
source/pre/models/DrawModel.cpp
7173
source/pre/models/DrawModel.hpp
7274
source/pre/models/LayerModel.cpp
@@ -121,6 +123,8 @@ add_executable(
121123
source/pre/views/CommentsView.hpp
122124
source/pre/views/DampingView.cpp
123125
source/pre/views/DampingView.hpp
126+
source/pre/views/HandleView.cpp
127+
source/pre/views/HandleView.hpp
124128
source/pre/views/DrawView.cpp
125129
source/pre/views/DrawView.hpp
126130
source/pre/views/docks/EditDock.cpp
Lines changed: 58 additions & 2 deletions
Loading

gui/source/post/ShapePlot.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ ShapePlot::ShapePlot(const Common& common, const States& states, int background_
5252
string_left.back()->setPen({Qt::blue, 2.0});
5353
string_left.back()->setScatterSkip(0);
5454

55+
pivot = new QCPCurve(this->xAxis, this->yAxis);
56+
pivot->setName("Pivot");
57+
pivot->setLineStyle(QCPCurve::lsNone);
58+
pivot->setScatterStyle({QCPScatterStyle::ssCross, Qt::blue, 10});
59+
5560
arrow = new QCPCurve(this->xAxis, this->yAxis);
5661
arrow->setName("Arrow");
5762
arrow->setLineStyle(QCPCurve::lsNone);
@@ -95,6 +100,7 @@ void ShapePlot::updateCurrentState() {
95100
plotLimbOutline(limb_left.back(), limb_right.back(), states.limb_pos[index]);
96101
plotString(string_left.back(), string_right.back(), states.string_pos[index]);
97102
plotArrow(states.arrow_pos[index]);
103+
plotPivot();
98104
}
99105

100106
void ShapePlot::updateAxes() {
@@ -193,3 +199,11 @@ void ShapePlot::plotArrow(double position) {
193199
quantity.getUnit().fromBase(position)
194200
);
195201
}
202+
203+
void ShapePlot::plotPivot() {
204+
pivot->data()->clear();
205+
pivot->addData(
206+
quantity.getUnit().fromBase(0.0),
207+
quantity.getUnit().fromBase(common.limb.pivot_point)
208+
);
209+
}

gui/source/post/ShapePlot.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ShapePlot: public PlotWidget {
2020
QList<QCPCurve*> limb_left;
2121
QList<QCPCurve*> string_right;
2222
QList<QCPCurve*> string_left;
23+
QCPCurve* pivot; // Todo: Replace with other QCustomPlot object?
2324
QCPCurve* arrow; // Todo: Replace with other QCustomPlot object?
2425

2526
void updatePlot();
@@ -31,4 +32,5 @@ class ShapePlot: public PlotWidget {
3132
void plotLimbOutline(QCPCurve* left, QCPCurve* right, const std::vector<std::array<double, 3>>& position);
3233
void plotString(QCPCurve* left, QCPCurve* right, const std::vector<std::array<double, 2>>& position);
3334
void plotArrow(double position);
35+
void plotPivot();
3436
};

gui/source/pre/Language.hpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,36 @@
33

44
// Constants for all texts shown throughout the application
55
// TODO: Actually pull all texts into here, not only tooltips
6+
// TODO: Put actual strings into a *.cpp file to reduce compile times
67

78
namespace Tooltips {
89
inline const QString EnergiesStacked = QStringLiteral("If selected, the energies are plotted as areas stacked on top of each other.\nOtherwise each energy is drawn as an individual line.");
910
inline const QString EnergiesByPart = QStringLiteral("Group energies by the component they belong to (limbs, string, arrow)");
1011
inline const QString EnergiesByType = QStringLiteral("Group enegies by the type they belong to (potential, kinetic, damping)");
1112

13+
inline const QString HandleTypeDefinition = QStringLiteral("Selects the type of handle for this bow");
14+
inline const QString HandleTypeFlexible = QStringLiteral("The handle is flexible and modelled as part of the bow limbs");
15+
inline const QString HandleTypeRigid = QStringLiteral("The handle is modelled as a separate rigid section between the bow limbs");
16+
inline const QString HandleLength = QStringLiteral("Length of the handle section");
17+
inline const QString HandleAngle = QStringLiteral("Attachment angle of the limbs (positive = reflex, negative = deflex)");
18+
inline const QString HandlePivot = QStringLiteral("Position of the pivot point (positive = reflex, negative = deflex)");
19+
20+
inline const QString BraceHeight = QStringLiteral("Brace height of the bow, i.e. distance between string and the handle's pivot point in the braced state");
21+
inline const QString DrawLength = QStringLiteral("Draw length of the bow, i.e. distance between string and the handle's pivot point in the fully drawn state");
22+
1223
inline const QString DrawForceShowLine = QStringLiteral("Show a hypothetical line connecting the start- and endpoint of the draw force curve");
1324
inline const QString DrawForceShowStiffness = QStringLiteral("Show the stiffness of the draw force curve, i.e. force increase per length increase");
1425

15-
inline const QString ArrowMassDefinition = QStringLiteral("Select how the arrow mass is to be defined");
16-
inline const QString ArrowMassAbsolute = QStringLiteral("Arrow mass (absolute value)");
26+
inline const QString ArrowMassDefinition = QStringLiteral("Selects how the arrow mass is specified");
27+
inline const QString ArrowMassAbsolute = QStringLiteral("Arrow mass as an absolute value");
1728
inline const QString ArrowMassPerForce = QStringLiteral("Arrow mass relative to the final draw force of the bow");
18-
inline const QString ArrowMassPerEnergy = QStringLiteral("Arrow mass relative to the input energy of the bow");
29+
inline const QString ArrowMassPerEnergy = QStringLiteral("Arrow mass relative to the stored energy of the bow");
1930

2031
inline const QString MassStringCenter = QStringLiteral("Additional mass(es) at the string center (e.g. serving, nocking point)");
2132
inline const QString MassStringTip = QStringLiteral("Additional mass(es) at the string tip (e.g. serving)");
2233
inline const QString MassLimbTip = QStringLiteral("Additional mass(es) at the limb tip (e.g. tip overlay)");
2334

24-
inline const QString DrawLengthDefinition = QStringLiteral("Select how the draw length is to be defined");
35+
inline const QString DrawLengthDefinition = QStringLiteral("Selects the draw length definition to be used");
2536
inline const QString DrawLengthStandard = QStringLiteral("Draw length as measured from the pivot point of the handle");
2637
inline const QString DrawLengthAMO = QStringLiteral("Draw length as measured from the pivot point of the handle + 1.75\" according to the AMO definition");
2738

@@ -76,17 +87,4 @@ namespace Tooltips {
7687

7788
inline const QString DampingRatioLimbs = QStringLiteral("Damping ratio of the limbs");
7889
inline const QString DampingRatioString = QStringLiteral("Damping ratio of the string");
79-
80-
inline const QString HandleReference = QStringLiteral("Reference point at the limb base from which the handle dimensions as well as the brace height and draw length are measured");
81-
inline const QString HandleReferenceBack = QStringLiteral("Measure from the back of the bow");
82-
inline const QString HandleReferenceBelly = QStringLiteral("Measure from the belly of the bow");
83-
inline const QString HandleReferenceProfile = QStringLiteral("Measure from the profile curve");
84-
85-
inline const QString HandleLength = QStringLiteral("Length of the handle, i.e. distance between the upper and lower limb as measured by the reference points");
86-
inline const QString HandleOffset = QStringLiteral("Offset of the handle's pivot point in the direction of draw");
87-
inline const QString HandleAngle = QStringLiteral("Angle at which the limbs are attached to the handle");
88-
inline const QString BraceHeight = QStringLiteral("Brace height of the bow, i.e. distance between string and the handle's pivot point in the braced state");
89-
inline const QString DrawLength = QStringLiteral("Draw length of the bow, i.e. distance between string and the handle's pivot point in the fully drawn state");
90-
91-
9290
}

gui/source/pre/Main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Q_DECLARE_METATYPE(LayerAlignment)
1111
Q_DECLARE_METATYPE(ArrowMass)
1212
Q_DECLARE_METATYPE(DrawLength)
13+
Q_DECLARE_METATYPE(Handle)
1314

1415
int main(int argc, char* argv[]) {
1516
QApplication::setOrganizationName(Config::ORGANIZATION_NAME);
@@ -22,6 +23,7 @@ int main(int argc, char* argv[]) {
2223
qRegisterMetaType<LayerAlignment>("LayerAlignment");
2324
qRegisterMetaType<ArrowMass>("ArrowMass");
2425
qRegisterMetaType<DrawLength>("DrawLength");
26+
qRegisterMetaType<Handle>("Handle");
2527

2628
QApplication application(argc, argv);
2729
application.installEventFilter(new KeyEventFilter());
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "HandleModel.hpp"
2+
#include "solver/BowModel.hpp"
3+
4+
HandleModel::HandleModel(Handle& handle) {
5+
HANDLE = addCustom(handle);
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
#include "pre/models/PropertyListModel.hpp"
3+
4+
class HandleModel: public PropertyListModel {
5+
public:
6+
QPersistentModelIndex HANDLE;
7+
8+
HandleModel(Handle& handle);
9+
};

gui/source/pre/models/MainModel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "MainTreeModel.hpp"
33
#include "CommentsModel.hpp"
44
#include "SettingsModel.hpp"
5+
#include "HandleModel.hpp"
56
#include "DrawModel.hpp"
67
#include "MaterialModel.hpp"
78
#include "LayerModel.hpp"
@@ -121,6 +122,16 @@ SettingsModel* MainModel::getSettingsModel() {
121122
return nullptr;
122123
}
123124

125+
HandleModel* MainModel::getHandleModel() {
126+
if(bow.has_value()) {
127+
auto model = new HandleModel(bow->handle);
128+
connectSubModel(model);
129+
return model;
130+
}
131+
132+
return nullptr;
133+
}
134+
124135
DrawModel* MainModel::getDrawModel() {
125136
if(bow.has_value()) {
126137
auto model = new DrawModel(bow->draw);

gui/source/pre/models/MainModel.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class MainTreeModel;
1414
class CommentsModel;
1515
class SettingsModel;
16+
class HandleModel;
1617
class DrawModel;
1718
class MaterialModel;
1819
class LayerModel;
@@ -54,6 +55,7 @@ class MainModel: public QObject {
5455

5556
CommentsModel* getCommentsModel();
5657
SettingsModel* getSettingsModel();
58+
HandleModel* getHandleModel();
5759
DrawModel* getDrawModel();
5860
MaterialModel* getMaterialModel(int index);
5961
LayerModel* getLayerModel(int index);

0 commit comments

Comments
 (0)