From 298f7468625cbc0206f37c37cc0b5bc64742bd0d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 17 Dec 2018 01:46:41 +0100 Subject: [PATCH] Ref T265, Ref T430, Ref T473 CG in model form --- src/blackgui/editors/modelmappingform.cpp | 45 ++++++ src/blackgui/editors/modelmappingform.h | 12 +- src/blackgui/editors/modelmappingform.ui | 161 ++++++++++++---------- 3 files changed, 141 insertions(+), 77 deletions(-) diff --git a/src/blackgui/editors/modelmappingform.cpp b/src/blackgui/editors/modelmappingform.cpp index 816e37f03..7a97d9c20 100644 --- a/src/blackgui/editors/modelmappingform.cpp +++ b/src/blackgui/editors/modelmappingform.cpp @@ -14,6 +14,7 @@ #include "blackgui/labelandicon.h" #include "blackmisc/icons.h" #include "blackmisc/network/authenticateduser.h" +#include "blackmisc/stringutils.h" #include "ui_modelmappingform.h" #include @@ -21,7 +22,9 @@ using namespace BlackMisc; using namespace BlackMisc::Network; +using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Simulation; +using namespace BlackGui::Components; namespace BlackGui { @@ -34,7 +37,10 @@ namespace BlackGui ui->setupUi(this); ui->le_LastUpdated->setReadOnly(true); ui->le_Id->setReadOnly(true); + ui->lai_Id->set(CIcons::appMappings16(), "Id:"); + + connect(ui->le_CG, &QLineEdit::editingFinished, this, &CModelMappingForm::onCgEditFinished); connect(ui->pb_Stash, &QPushButton::clicked, this, &CModelMappingForm::requestStash); // for setting mode (include/exclude) @@ -52,6 +58,7 @@ namespace BlackGui model.setModelString(ui->le_ModelKey->text()); model.setName(ui->le_Name->text()); model.setModelMode(ui->selector_ModelMode->getMode()); + model.setCG(this->getCGFromUI()); return model; } @@ -86,6 +93,7 @@ namespace BlackGui ui->le_FileName->setText(model.getFileName()); ui->selector_ModelMode->setValue(model.getModelMode()); ui->selector_Simulator->setValue(model.getSimulator()); + this->setCGtoUI(model.getCG()); m_originalModel = model; } @@ -104,5 +112,42 @@ namespace BlackGui CFormDbUser::userChanged(); } + + CLength CModelMappingForm::getCGFromUI() const + { + if (ui->le_CG->text().isEmpty()) { return CLength::null(); } + const QString v = ui->le_CG->text(); + + // without unit we assume ft + if (isDigitsOnlyString(v)) + { + bool ok; + const double cgv = v.toDouble(&ok); + if (!ok) { return CLength::null(); } + return CLength(cgv, CLengthUnit::ft()); + } + + CLength cg; + cg.parseFromString(v); + return cg; + } + + void CModelMappingForm::setCGtoUI(const CLength &cg) + { + if (cg.isNull()) + { + ui->le_CG->clear(); + } + else + { + ui->le_CG->setText(cg.valueRoundedWithUnit(CLengthUnit::ft(), 1)); + } + } + + void CModelMappingForm::onCgEditFinished() + { + const CLength cg = this->getCGFromUI(); + this->setCGtoUI(cg); + } } // ns } // ns diff --git a/src/blackgui/editors/modelmappingform.h b/src/blackgui/editors/modelmappingform.h index 60a614eb2..5bd31f09e 100644 --- a/src/blackgui/editors/modelmappingform.h +++ b/src/blackgui/editors/modelmappingform.h @@ -12,8 +12,8 @@ #ifndef BLACKGUI_EDITORS_MODELMAPPINGFORM_H #define BLACKGUI_EDITORS_MODELMAPPINGFORM_H -#include "blackgui/blackguiexport.h" #include "blackgui/editors/form.h" +#include "blackgui/blackguiexport.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/statusmessagelist.h" @@ -51,7 +51,6 @@ namespace BlackGui virtual BlackMisc::CStatusMessageList validate(bool withNestedObjects) const override; //! @} - public slots: //! Set model void setValue(BlackMisc::Simulation::CAircraftModel &model); @@ -64,6 +63,15 @@ namespace BlackGui virtual void userChanged() override; private: + //! CG (aka vertical offset) from UI + BlackMisc::PhysicalQuantities::CLength getCGFromUI() const; + + //! Set CG value properly formatted + void setCGtoUI(const BlackMisc::PhysicalQuantities::CLength &cg); + + //! CG edited + void onCgEditFinished(); + QScopedPointer ui; BlackMisc::Simulation::CAircraftModel m_originalModel; }; diff --git a/src/blackgui/editors/modelmappingform.ui b/src/blackgui/editors/modelmappingform.ui index 5546c8805..15aebcefc 100644 --- a/src/blackgui/editors/modelmappingform.ui +++ b/src/blackgui/editors/modelmappingform.ui @@ -6,7 +6,7 @@ 0 0 - 355 + 452 104 @@ -34,7 +34,7 @@ Simulator model - + 3 @@ -50,34 +50,6 @@ 4 - - - - Model description - - - - - - - Updated: - - - - - - - true - - - - - - - Model key - - - @@ -88,16 +60,6 @@ - - - - Description: - - - le_Description - - - @@ -111,20 +73,40 @@ - - - - Name + + + + Stash - - - - File: + + + + + 10 + 0 + + + + + CG: + + + + + + + Updated: + + + + + + @@ -135,27 +117,38 @@ - - + + + + Model description + + + + + - Stash + File: - - - - - - - - 10 - 0 - + + + + Description: + + + le_Description - + + + + Name + + + + @@ -168,7 +161,10 @@ - + + + + @@ -187,13 +183,27 @@ - - - - QFrame::StyledPanel + + + + + 75 + 16777215 + - - QFrame::Raised + + + + + + true + + + + + + + Model key @@ -209,6 +219,12 @@
blackgui/components/simulatorselector.h
1 + + BlackGui::Components::CModelModeSelector + QFrame +
blackgui/components/modelmodeselector.h
+ 1 +
BlackGui::CLabelAndIcon QFrame @@ -221,12 +237,6 @@
blackgui/editors/validationindicator.h
1
- - BlackGui::Components::CModelModeSelector - QFrame -
blackgui/components/modelmodeselector.h
- 1 -
le_Id @@ -234,6 +244,7 @@ selector_Simulator le_Name le_Description + le_CG selector_ModelMode le_LastUpdated le_FileName