6 #include "ui_modelbrowsercomponent.h"
16 using namespace swift::misc::aviation;
17 using namespace swift::misc::simulation;
18 using namespace swift::misc::physical_quantities;
19 using namespace swift::misc::geo;
20 using namespace swift::gui::editors;
23 using namespace swift::core::context;
30 ui->tw_Tab->setCurrentIndex(0);
31 ui->tvp_AircraftModels->acceptClickSelection(
false);
32 ui->tvp_AircraftModels->acceptDoubleClickSelection(
true);
34 const CLength relDistance(40.0, CLengthUnit::m());
35 ui->editor_RelativePosition->setDistance(relDistance);
43 connect(ui->editor_Coordinate, &CCoordinateForm::changedCoordinate,
this,
45 connect(ui->editor_Pbh, &CPbhsForm::changeValues,
this, &CModelBrowserComponent::onSetPBH,
47 connect(ui->editor_AircraftParts, &CAircraftPartsForm::changeAircraftParts,
this,
49 connect(ui->tvp_AircraftModels, &CAircraftModelView::objectDoubleClicked,
this,
56 this->onSetRelativePosition();
63 void CModelBrowserComponent::onSetRelativePosition()
65 if (!this->hasContexts()) {
return; }
67 ui->editor_RelativePosition->setOriginCoordinate(s);
69 ui->editor_RelativePosition->displayInfo(rel);
73 void CModelBrowserComponent::onSetAbsolutePosition()
75 m_situation.
setPosition(ui->editor_Coordinate->getCoordinate());
78 void CModelBrowserComponent::onSetPBH()
80 ui->cb_UsePBH->setChecked(
true);
81 if (!this->hasContexts()) {
return; }
82 this->updatePartsAndPBH(
true,
false);
85 void CModelBrowserComponent::onSetParts()
87 ui->cb_UseParts->setChecked(
true);
88 if (!this->hasContexts()) {
return; }
89 this->updatePartsAndPBH(
false,
true);
94 return ui->editor_AircraftParts->getAircraftPartsFromGui();
97 void CModelBrowserComponent::updatePartsAndPBH(
bool setPbh,
bool setParts)
99 if (!this->hasContexts()) {
return; }
101 if (setParts || ui->cb_UseParts->isChecked()) { parts = this->getParts(); }
103 if (setPbh || ui->cb_UsePBH->isChecked()) { ui->editor_Pbh->updateSituation(m_situation); }
106 sGui->
getISimulator()->testSendSituationAndParts(ISimulator::getTestCallsign(), m_situation, parts);
109 void CModelBrowserComponent::fetchSimulatorValues()
111 if (!this->hasContexts()) {
return; }
114 void CModelBrowserComponent::onModelDblClicked(
const CVariant &
object)
120 void CModelBrowserComponent::display()
122 if (!this->hasContexts()) {
return; }
128 if (ui->cb_OverrideCG->isChecked())
137 if (ui->cb_UsePBH->isChecked()) { ui->editor_Pbh->updateSituation(m_situation); }
139 if (ui->cb_UseParts->isChecked())
141 const CAircraftParts parts = ui->editor_AircraftParts->getAircraftPartsFromGui();
146 m_aircraft.
setCallsign(ISimulator::getTestCallsign());
150 ui->le_Info->setText(m_situation.
toQString(
true));
156 void CModelBrowserComponent::remove()
158 ui->le_ModelInfo->clear();
159 ui->le_Info->clear();
161 if (!this->hasContexts()) {
return; }
167 void CModelBrowserComponent::loadModelSet()
169 if (!this->hasContexts()) {
return; }
172 ui->tvp_AircraftModels->updateContainerMaybeAsync(modelSet);
174 ui->lbl_ModelSetInfo->setText(QStringLiteral(
"'%1' model set with %2 models").arg(sim).arg(modelSet.
sizeInt()));
177 bool CModelBrowserComponent::hasContexts()
const
185 void CModelBrowserComponent::onCGChecked(
bool checked)
187 if (ui->cb_OverrideCG->isChecked() != checked) { ui->cb_OverrideCG->setChecked(
true); }
188 if (ui->cb_UseCG->isChecked() != checked) { ui->cb_UseCG->setChecked(
true); }
const context::IContextOwnAircraft * getIContextOwnAircraft() const
Direct access to contexts if a CCoreFacade has been initialized.
QPointer< ISimulator > getISimulator() const
The simulator plugin, if available.
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
virtual swift::misc::aviation::CAircraftSituation getOwnAircraftSituation() const =0
Get own aircraft.
virtual swift::misc::simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const =0
Simulator info, currently loaded plugin.
virtual swift::misc::simulation::CAircraftModelList getModelSet() const =0
Installed models in simulator eco system.
virtual bool testRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &aircraft, bool add)=0
Test a remote aircraft.
virtual bool requestElevationBySituation(const swift::misc::aviation::CAircraftSituation &situation)=0
Request elevation, there is no guarantee the requested elevation will be available in the provider.
Allow to browse thru the model set.
void close()
Browser has been closed.
~CModelBrowserComponent()
Destructor.
int sizeInt() const
Avoid compiler warnings when using with int.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Value object encapsulating information of aircraft's parts.
bool isNull() const
NULL parts object?
Value object encapsulating information of an aircraft's situation.
const CHeading & getHeading() const
Get heading.
void setZeroPBHandGs()
Set PBH and GS values to 0 (zero)
void setPosition(const geo::CCoordinateGeodetic &position)
Set position.
QString toQString(bool i18n=false) const
Cast as QString.
Physical unit length (length)
void parseFromString(const QString &value)
Parse value from string.
bool isNull() const
Is quantity null?
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
Aircraft model (used by another pilot, my models on disk)
const physical_quantities::CLength & getCG() const
Get center of gravity.
void setCG(const physical_quantities::CLength &cg)
Get center of gravity.
QString getModelStringAndDbKey() const
Model string and DB key (if available)
bool hasModelString() const
Non empty model string?
Value object encapsulating a list of aircraft models.
Comprehensive information of an aircraft.
void setCallsign(const aviation::CCallsign &callsign)
Set callsign.
void setModel(const CAircraftModel &model)
Set model.
void setSituation(const aviation::CAircraftSituation &situation)
Set situation. Won't overwrite the velocity unless it held the default value.
bool hasCallsign() const
Callsign not empty, no further checks.
void setParts(const aviation::CAircraftParts &parts)
Set aircraft parts.
const CSimulatorInfo & getSimulatorInfo() const
Simulator info object.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Views, mainly QTableView.
Free functions in swift::misc.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)