Ref T265, Ref T430, Ref T473 CG in model form

This commit is contained in:
Klaus Basan
2018-12-17 01:46:41 +01:00
committed by Mat Sutcliffe
parent c14e85a805
commit 298f746862
3 changed files with 141 additions and 77 deletions

View File

@@ -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 <QLineEdit>
@@ -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

View File

@@ -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::CModelMappingForm> ui;
BlackMisc::Simulation::CAircraftModel m_originalModel;
};

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>355</width>
<width>452</width>
<height>104</height>
</rect>
</property>
@@ -34,7 +34,7 @@
<property name="title">
<string>Simulator model</string>
</property>
<layout class="QGridLayout" name="gl_ModelMappingForm" columnstretch="1,2,1,2,2,1,0">
<layout class="QGridLayout" name="gl_ModelMappingForm" columnstretch="0,1,0,1,1,0,1,1,0">
<property name="leftMargin">
<number>3</number>
</property>
@@ -50,34 +50,6 @@
<property name="spacing">
<number>4</number>
</property>
<item row="1" column="3" colspan="2">
<widget class="QLineEdit" name="le_Description">
<property name="placeholderText">
<string>Model description</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Updated">
<property name="text">
<string>Updated:</string>
</property>
</widget>
</item>
<item row="2" column="3" colspan="2">
<widget class="QLineEdit" name="le_FileName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3" colspan="2">
<widget class="QLineEdit" name="le_ModelKey">
<property name="placeholderText">
<string>Model key</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lbl_ModelKey">
<property name="text">
@@ -88,16 +60,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_Description">
<property name="text">
<string>Description:</string>
</property>
<property name="buddy">
<cstring>le_Description</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_Id">
<property name="maximumSize">
@@ -111,20 +73,40 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_Name">
<property name="placeholderText">
<string>Name</string>
<item row="2" column="7" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Stash">
<property name="text">
<string>Stash</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="lbl_Path">
<property name="text">
<string>File:</string>
<item row="0" column="8" rowspan="3">
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="lbl_CG">
<property name="text">
<string>CG:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Updated">
<property name="text">
<string>Updated:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_LastUpdated"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Name">
<property name="text">
@@ -135,27 +117,38 @@
</property>
</widget>
</item>
<item row="2" column="5" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Stash">
<item row="1" column="3" colspan="2">
<widget class="QLineEdit" name="le_Description">
<property name="placeholderText">
<string>Model description</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="lbl_Path">
<property name="text">
<string>Stash</string>
<string>File:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_LastUpdated"/>
</item>
<item row="0" column="6" rowspan="3">
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
<item row="1" column="2">
<widget class="QLabel" name="lbl_Description">
<property name="text">
<string>Description:</string>
</property>
<property name="buddy">
<cstring>le_Description</cstring>
</property>
</widget>
</item>
<item row="1" column="5">
<item row="1" column="1">
<widget class="QLineEdit" name="le_Name">
<property name="placeholderText">
<string>Name</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="BlackGui::Components::CModelModeSelector" name="selector_ModelMode">
<property name="minimumSize">
<size>
@@ -168,7 +161,10 @@
</property>
</widget>
</item>
<item row="0" column="5">
<item row="0" column="0">
<widget class="BlackGui::CLabelAndIcon" name="lai_Id"/>
</item>
<item row="0" column="7">
<widget class="BlackGui::Components::CSimulatorSelector" name="selector_Simulator">
<property name="minimumSize">
<size>
@@ -187,13 +183,27 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="BlackGui::CLabelAndIcon" name="lai_Id">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<item row="1" column="6">
<widget class="QLineEdit" name="le_CG">
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</widget>
</item>
<item row="2" column="3" colspan="4">
<widget class="QLineEdit" name="le_FileName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3" colspan="4">
<widget class="QLineEdit" name="le_ModelKey">
<property name="placeholderText">
<string>Model key</string>
</property>
</widget>
</item>
@@ -209,6 +219,12 @@
<header>blackgui/components/simulatorselector.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CModelModeSelector</class>
<extends>QFrame</extends>
<header>blackgui/components/modelmodeselector.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CLabelAndIcon</class>
<extends>QFrame</extends>
@@ -221,12 +237,6 @@
<header>blackgui/editors/validationindicator.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CModelModeSelector</class>
<extends>QFrame</extends>
<header>blackgui/components/modelmodeselector.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>le_Id</tabstop>
@@ -234,6 +244,7 @@
<tabstop>selector_Simulator</tabstop>
<tabstop>le_Name</tabstop>
<tabstop>le_Description</tabstop>
<tabstop>le_CG</tabstop>
<tabstop>selector_ModelMode</tabstop>
<tabstop>le_LastUpdated</tabstop>
<tabstop>le_FileName</tabstop>