7 #include <QStringBuilder>
14 #include "gui/menus/menuaction.h"
21 using namespace swift::config;
23 using namespace swift::misc::physical_quantities;
24 using namespace swift::misc::aviation;
25 using namespace swift::misc::simulation;
26 using namespace swift::core::context;
28 using namespace swift::gui::menus;
46 bool menuEnableAircraft,
bool menuFastPositionUpdates,
bool menuGndFlag,
49 m_withRecalculate = menuRecalculate;
50 m_withMenuEnableAircraft = menuEnableAircraft;
51 m_withMenuFastPosition = menuFastPositionUpdates;
52 m_withMenuHighlightAndFollow = menuHighlightAndFollow;
53 m_withMenuEnableGndFlag = menuGndFlag;
54 m_withMenuFlightPlan = menuFlightPlan;
59 m_withMenuFastPosition = menuFastPositionUpdates;
72 menuActions.
addAction(CIcons::delete16(),
"Temp.disable model from set",
73 CMenuAction::pathClientSimulationRender(),
74 {
this, &CSimulatedAircraftView::requestTempDisable });
77 if (m_withRecalculate)
79 menuActions.
addAction(CIcons::appInterpolation16(),
"Re-calculate all aircraft",
80 CMenuAction::pathClientSimulationRender(),
81 {
this, &CSimulatedAircraftView::recalculateAllAircraft });
82 menuActions.
addAction(CIcons::appInterpolation16(),
"Re-matching all aircraft",
83 CMenuAction::pathClientSimulationRender(),
84 {
this, &CSimulatedAircraftView::doMatchingsAgain });
87 menuActions.
addAction(CIcons::appInterpolation16(),
"Re-matching selected",
88 CMenuAction::pathClientSimulationRender(),
89 {
this, &CSimulatedAircraftView::doMatchingsAgainForSelected });
93 if (m_withMenuEnableAircraft && !this->
isEmpty())
95 menuActions.
addAction(CIcons::appAircraft16(),
"Enable all aircraft",
96 CMenuAction::pathClientSimulationRender(),
97 {
this, &CSimulatedAircraftView::enableAllDisabledAircraft });
98 menuActions.
addAction(CIcons::appAircraft16(),
"Re-enable unrendered aircraft",
99 CMenuAction::pathClientSimulationRender(),
100 {
this, &CSimulatedAircraftView::reEnableAllUnrenderedAircraft });
101 menuActions.
addAction(CIcons::appAircraft16(),
"Disable all aircraft",
102 CMenuAction::pathClientSimulationRender(),
103 {
this, &CSimulatedAircraftView::disableAllEnabledAircraft });
114 menuActions.
addAction(CIcons::appTextMessages16(),
"Show text messages", CMenuAction::pathClientCom(),
115 {
this, &CSimulatedAircraftView::requestTextMessage });
117 if (m_withMenuFlightPlan && networkContext() && networkContext()->isConnected())
119 menuActions.
addAction(CIcons::appFlightPlan16(),
"Flight plan", CMenuAction::pathClientFlightPlan(),
120 {
this, &CSimulatedAircraftView::showFlightPlanDialog });
122 if (m_withMenuEnableAircraft)
124 menuActions.
addAction(CIcons::appAircraft16(),
125 aircraft.
isEnabled() ?
"Disable aircraft" :
"Enabled aircraft",
126 CMenuAction::pathClientSimulationRender(),
127 { this, &CSimulatedAircraftView::toggleEnabledAircraft });
129 if (m_withMenuHighlightAndFollow)
131 menuActions.
addAction(CIcons::appAircraft16(),
"Follow in simulator",
132 CMenuAction::pathClientFollowInSim(),
133 {
this, &CSimulatedAircraftView::requestFollowInSimulator });
136 menuActions.
addSeparator(CMenuAction::pathClientSimulationDisplay());
140 menuActions.
addAction(CIcons::appAircraft16(),
"Temp.disable parts",
141 CMenuAction::pathClientSimulationDisplay(),
142 {
this, &CSimulatedAircraftView::requestDisableParts });
143 menuActions.
addAction(CIcons::appAircraft16(),
"Re/enabled parts",
144 CMenuAction::pathClientSimulationDisplay(),
145 {
this, &CSimulatedAircraftView::requestEnableParts });
147 menuActions.
addAction(CIcons::appAircraft16(),
"Zero 0 pitch on ground",
148 CMenuAction::pathClientSimulationDisplay(),
149 {
this, &CSimulatedAircraftView::request0PitchOnGround });
150 menuActions.
addAction(CIcons::appAircraft16(),
"Remove pitch manipulation",
151 CMenuAction::pathClientSimulationDisplay(),
152 {
this, &CSimulatedAircraftView::requestNullPitchOnGround });
154 if (m_withMenuEnableGndFlag)
156 menuActions.
addAction(CIcons::geoPosition16(),
158 CMenuAction::pathClientSimulationTransfer(),
159 { this, &CSimulatedAircraftView::toggleSupportingGndFlag });
161 if (m_withMenuFastPosition)
165 "Fast position updates (send)",
166 CMenuAction::pathClientSimulationTransfer(),
167 { this, &CSimulatedAircraftView::toggleFastPositionUpdates });
170 const bool any = m_withMenuEnableAircraft || m_withMenuFastPosition || m_withMenuHighlightAndFollow ||
171 m_withMenuEnableGndFlag || m_withMenuFlightPlan;
174 menuActions.
addAction(CIcons::appSimulator16(),
"Show position log.",
175 CMenuAction::pathClientSimulationDisplay(),
176 {
this, &CSimulatedAircraftView::showPositionLogInSimulator });
183 void CSimulatedAircraftView::requestTextMessage()
186 if (aircraft.getCallsign().isEmpty()) {
return; }
190 void CSimulatedAircraftView::toggleEnabledAircraft()
193 if (aircraft.getCallsign().isEmpty()) {
return; }
194 aircraft.setEnabled(!aircraft.isEnabled());
195 this->updateAircraftEnabled(aircraft);
198 void CSimulatedAircraftView::toggleFastPositionUpdates()
201 if (aircraft.getCallsign().isEmpty()) {
return; }
202 aircraft.toggleFastPositionUpdates();
203 this->enableFastPositionUpdates(aircraft);
206 void CSimulatedAircraftView::toggleSupportingGndFlag()
209 if (aircraft.getCallsign().isEmpty()) {
return; }
210 aircraft.setSupportingGndFlag(!aircraft.isSupportingGndFlag());
211 this->updateAircraftSupportingGndFLag(aircraft);
214 void CSimulatedAircraftView::requestFollowInSimulator()
217 if (aircraft.getCallsign().isEmpty()) {
return; }
218 this->followAircraftInSimulator(aircraft);
221 void CSimulatedAircraftView::requestEnableParts()
224 if (aircraft.getCallsign().isEmpty()) {
return; }
225 this->enableParts(aircraft,
true);
228 void CSimulatedAircraftView::requestDisableParts()
231 if (aircraft.getCallsign().isEmpty()) {
return; }
232 this->enableParts(aircraft,
false);
235 void CSimulatedAircraftView::request0PitchOnGround()
238 if (aircraft.getCallsign().isEmpty()) {
return; }
239 this->setPitchOnGround(aircraft,
CAngle(0, CAngleUnit::deg()));
242 void CSimulatedAircraftView::requestNullPitchOnGround()
245 if (aircraft.getCallsign().isEmpty()) {
return; }
246 this->setPitchOnGround(aircraft, CAngle::null());
249 void CSimulatedAircraftView::requestTempDisable()
256 u
"Temp.disabled " % models.getModelStringList(
true).join(
" ")));
259 void CSimulatedAircraftView::showPositionLogInSimulator()
262 if (!simContext) {
return; }
264 if (aircraft.getCallsign().isEmpty()) {
return; }
267 const QString dotCmd(
".drv pos " + aircraft.getCallsignAsString());
271 void CSimulatedAircraftView::enableAllDisabledAircraft()
275 this->enableOrDisableAircraft(aircraft,
true);
278 void CSimulatedAircraftView::disableAllEnabledAircraft()
282 this->enableOrDisableAircraft(aircraft,
false);
285 void CSimulatedAircraftView::reEnableAllUnrenderedAircraft()
289 this->enableOrDisableAircraft(aircraft,
true);
292 void CSimulatedAircraftView::enableOrDisableAircraft(
const CSimulatedAircraftList &aircraft,
bool newEnabled)
294 if (aircraft.
isEmpty()) {
return; }
296 const QPointer<CSimulatedAircraftView> myself(
this);
300 if (!myself) {
return; }
304 this->updateAircraftEnabled(enabledAircraft);
309 void CSimulatedAircraftView::followAircraftInSimulator(
const CSimulatedAircraft &aircraft)
312 if (!simContext) {
return; }
316 void CSimulatedAircraftView::enableParts(
const CSimulatedAircraft &aircraft,
bool enabled)
319 if (!simContext || !aircraft.
hasCallsign()) {
return; }
332 if (!simContext || !aircraft.
hasCallsign()) {
return; }
341 bool CSimulatedAircraftView::isSupportingAircraftParts(
const CCallsign &cs)
const
344 if (!netContext) {
return false; }
348 void CSimulatedAircraftView::recalculateAllAircraft()
351 if (!simContext) {
return; }
355 void CSimulatedAircraftView::doMatchingsAgain()
358 if (!simContext) {
return; }
360 CLogMessage(
this).
info(u
"Triggered re-matching of %1 aircraft") << rematchedNumber;
363 void CSimulatedAircraftView::doMatchingsAgainForSelected()
366 if (!simContext) {
return; }
375 void CSimulatedAircraftView::enableFastPositionUpdates(
const CSimulatedAircraft &aircraft)
378 if (!nwContext) {
return; }
382 void CSimulatedAircraftView::updateAircraftEnabled(
const CSimulatedAircraft &aircraft)
385 if (!nwContext) {
return; }
389 void CSimulatedAircraftView::updateAircraftSupportingGndFLag(
const CSimulatedAircraft &aircraft)
392 if (!nwContext) {
return; }
396 void CSimulatedAircraftView::showFlightPlanDialog()
398 if (!m_withMenuFlightPlan) {
return; }
399 if (!networkContext() || !networkContext()->isConnected()) {
return; }
405 if (!m_fpDialog) { m_fpDialog =
new CFlightPlanDialog(
this); }
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
bool isDeveloperFlagSet() const
Running with dev.flag?
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
bool supportsContexts(bool ignoreShutdownTest=false) const
Supports contexts.
virtual bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator)=0
Parse a given command line.
virtual bool updateAircraftEnabled(const swift::misc::aviation::CCallsign &callsign, bool enabledForRendering)=0
Enable/disable rendering.
virtual bool updateFastPositionEnabled(const swift::misc::aviation::CCallsign &callsign, bool enableFastPositionSending)=0
Change fast position updates.
virtual bool updateAircraftSupportingGndFLag(const swift::misc::aviation::CCallsign &callsign, bool supportGndFlag)=0
Enable/disable support of gnd. flag.
virtual bool isRemoteAircraftSupportingParts(const swift::misc::aviation::CCallsign &callsign) const =0
Parts supported?
virtual bool doMatchingAgain(const swift::misc::aviation::CCallsign &callsign)=0
Repeat the matching callsign.
virtual void recalculateAllAircraft()=0
Recalculate all aircraft.
virtual bool setInterpolationAndRenderingSetupsPerCallsign(const swift::misc::simulation::CInterpolationSetupList &setups, bool ignoreSameAsGlobal)=0
Set all setups per callsign.
virtual int doMatchingsAgain()=0
Repeat all matchings.
virtual swift::misc::simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const swift::misc::aviation::CCallsign &callsign) const =0
Get the setup for callsign, if not existing the global setup.
virtual bool followAircraft(const swift::misc::aviation::CCallsign &callsign)=0
Follow aircraft im simulator view.
bool displayInStatusBar(const swift::misc::CStatusMessage &message)
direct access to main application window
void showFlightPlan(const swift::misc::aviation::CCallsign &callsign)
Show a particular callsign flight plan.
virtual void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
void setAircraftMode(models::CSimulatedAircraftListModel::AircraftMode mode)
Mode.
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign)
Request a text message.
void requestTempDisableModelsForMatching(const swift::misc::simulation::CAircraftModelList &models)
Disable for matching.
void configureMenuFastPositionUpdates(bool menuFastPositionUpdates)
Configure fast position updates menu.
void configureMenu(bool menuRecalculate, bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag, bool menuFlightPlan)
Configure the menu.
void standardInit(ModelClass *model=nullptr)
Standard initialization.
virtual bool isEmpty() const
Empty?
virtual ContainerType selectedObjects() const
Selected objects.
ModelClass * m_model
corresponding model
void setSortIndicator()
Set the search indicator based on model.
ObjectType selectedObject() const
Selected object (or default)
const ContainerType & container() const
Access to container.
virtual void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
Menu m_menus
Default menu settings.
@ MenuRefresh
allow refreshing the view via menu
@ MenuDisableModelsTemp
temp.
bool hasSelection() const
Selection (selected rows)
Base class for views with DB objects.
Value object encapsulating information identifying a component of a modular distributed swift process...
Class for emitting a log message.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
Value object encapsulating information of a callsign.
const QString & asString() const
Get callsign (normalized)
bool isEmpty() const
Is empty?
Physical unit angle (radians, degrees)
Value object encapsulating a list of aircraft models.
bool setPitchOnGround(const physical_quantities::CAngle &pitchOnGround)
Force a given pitch on ground.
bool setEnabledAircraftParts(bool enabled)
Set enabled aircraft parts.
bool isAircraftPartsEnabled() const
Aircraft parts enabled (still requires the other aircraft to send parts)
const physical_quantities::CAngle & getPitchOnGround() const
Force a given pitch on ground.
Value object for interpolator and rendering per callsign.
void setCallsign(const aviation::CCallsign &callsign)
Set callsign.
Comprehensive information of an aircraft.
bool isPartsSynchronized() const
Have parts been synchronized with a remote client?
bool isSupportingGndFlag() const
Is supporting gnd.flag?
bool fastPositionUpdates() const
Support fast position updates.
bool hasCallsign() const
Callsign not empty, no further checks.
const aviation::CCallsign & getCallsign() const
Get callsign.
bool setEnabled(bool enabled)
Enabled / disabled.
bool isEnabled() const
Enabled? Enable means it shall be displayed in the simulator.
Value object encapsulating a list of aircraft.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...