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);
37 connect(ui->pb_SetRelativePosition, &QPushButton::released,
this,
38 &CModelBrowserComponent::onSetRelativePosition, Qt::QueuedConnection);
39 connect(ui->pb_LoadModelSet, &QPushButton::released,
this, &CModelBrowserComponent::loadModelSet,
40 Qt::QueuedConnection);
41 connect(ui->pb_Display, &QPushButton::released,
this, &CModelBrowserComponent::display, Qt::QueuedConnection);
42 connect(ui->pb_Remove, &QPushButton::released,
this, &CModelBrowserComponent::remove, Qt::QueuedConnection);
43 connect(ui->editor_Coordinate, &CCoordinateForm::changedCoordinate,
this,
44 &CModelBrowserComponent::onSetAbsolutePosition, Qt::QueuedConnection);
45 connect(ui->editor_Pbh, &CPbhsForm::changeValues,
this, &CModelBrowserComponent::onSetPBH,
46 Qt::QueuedConnection);
47 connect(ui->editor_AircraftParts, &CAircraftPartsForm::changeAircraftParts,
this,
48 &CModelBrowserComponent::onSetParts, Qt::QueuedConnection);
49 connect(ui->tvp_AircraftModels, &CAircraftModelView::objectDoubleClicked,
this,
50 &CModelBrowserComponent::onModelDblClicked, Qt::QueuedConnection);
52 connect(ui->cb_OverrideCG, &QCheckBox::clicked,
this, &CModelBrowserComponent::onCGChecked);
53 connect(ui->cb_UseCG, &QCheckBox::clicked,
this, &CModelBrowserComponent::onCGChecked);
56 this->onSetRelativePosition();
66 void CModelBrowserComponent::onSetRelativePosition()
68 if (!this->hasContexts()) {
return; }
70 ui->editor_RelativePosition->setOriginCoordinate(s);
72 ui->editor_RelativePosition->displayInfo(rel);
76 void CModelBrowserComponent::onSetAbsolutePosition()
78 m_situation.
setPosition(ui->editor_Coordinate->getCoordinate());
81 void CModelBrowserComponent::onSetPBH()
83 ui->cb_UsePBH->setChecked(
true);
84 if (!this->hasContexts()) {
return; }
85 this->updatePartsAndPBH(
true,
false);
88 void CModelBrowserComponent::onSetParts()
90 ui->cb_UseParts->setChecked(
true);
91 if (!this->hasContexts()) {
return; }
92 this->updatePartsAndPBH(
false,
true);
97 return ui->editor_AircraftParts->getAircraftPartsFromGui();
100 void CModelBrowserComponent::updatePartsAndPBH(
bool setPbh,
bool setParts)
102 if (!this->hasContexts()) {
return; }
104 if (setParts || ui->cb_UseParts->isChecked()) { parts = this->getParts(); }
106 if (setPbh || ui->cb_UsePBH->isChecked()) { ui->editor_Pbh->updateSituation(m_situation); }
109 sGui->
getISimulator()->testSendSituationAndParts(ISimulator::getTestCallsign(), m_situation, parts);
112 void CModelBrowserComponent::fetchSimulatorValues()
114 if (!this->hasContexts()) {
return; }
117 void CModelBrowserComponent::onModelDblClicked(
const CVariant &
object)
123 void CModelBrowserComponent::display()
125 if (!this->hasContexts()) {
return; }
131 if (ui->cb_OverrideCG->isChecked())
140 if (ui->cb_UsePBH->isChecked()) { ui->editor_Pbh->updateSituation(m_situation); }
142 if (ui->cb_UseParts->isChecked())
144 const CAircraftParts parts = ui->editor_AircraftParts->getAircraftPartsFromGui();
149 m_aircraft.
setCallsign(ISimulator::getTestCallsign());
153 ui->le_Info->setText(m_situation.
toQString(
true));
159 void CModelBrowserComponent::remove()
161 ui->le_ModelInfo->clear();
162 ui->le_Info->clear();
164 if (!this->hasContexts()) {
return; }
170 void CModelBrowserComponent::loadModelSet()
172 if (!this->hasContexts()) {
return; }
175 ui->tvp_AircraftModels->updateContainerMaybeAsync(modelSet);
177 ui->lbl_ModelSetInfo->setText(QStringLiteral(
"'%1' model set with %2 models").arg(sim).arg(modelSet.
sizeInt()));
180 bool CModelBrowserComponent::hasContexts()
const
188 void CModelBrowserComponent::onCGChecked(
bool checked)
190 if (ui->cb_OverrideCG->isChecked() != checked) { ui->cb_OverrideCG->setChecked(
true); }
191 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.
virtual ~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.