swift
Loading...
Searching...
No Matches
simulatorplugincommon.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
9
10using namespace swift::gui;
11using namespace swift::gui::components;
12using namespace swift::core;
13using namespace swift::misc;
14using namespace swift::misc::network;
15using namespace swift::misc::simulation;
16
17namespace swift::simplugin::common
18{
20 IOwnAircraftProvider *ownAircraftProvider,
21 IRemoteAircraftProvider *renderedAircraftProvider,
22 IClientProvider *clientProvider, QObject *parent)
23 : ISimulator(info, ownAircraftProvider, renderedAircraftProvider, clientProvider, parent)
24 {
26 }
27
28 CSimulatorPluginCommon::~CSimulatorPluginCommon() { this->deleteInterpolationDisplay(); }
29
30 void CSimulatorPluginCommon::deleteInterpolationDisplay()
31 {
32 if (m_interpolationDisplayDialog)
33 {
34 // if there is no parent widget, we clean dialog up
35 // otherwise the parent is supposed to clean up
36 CInterpolationLogDisplayDialog *dialog = m_interpolationDisplayDialog;
37 m_interpolationDisplayDialog = nullptr;
38 dialog->close();
39 delete dialog;
40 }
41 }
42
43 void CSimulatorPluginCommon::showInterpolationDisplay()
44 {
45 if (!m_interpolationDisplayDialog)
46 {
47 QWidget *parentWidget = sGui ? CGuiApplication::mainApplicationWidget() : nullptr;
48 auto *dialog = new CInterpolationLogDisplayDialog(this, nullptr, parentWidget);
49 m_interpolationDisplayDialog = dialog;
50 m_interpolationDisplayDialog->setModal(false);
51 }
52
53 if (m_interpolationDisplayDialog)
54 {
55 m_interpolationDisplayDialog->show();
56 }
57 }
58
60 {
61 // .driver fsuipc on|off
62 if (parser.matchesPart(1, "intdisplay"))
63 {
64 this->showInterpolationDisplay();
65 return true;
66 }
67 return false;
68 }
69
71 {
72 this->deleteInterpolationDisplay();
74 }
75
77 {
78 this->deleteInterpolationDisplay();
80 }
81
83 {
84 if (CSimpleCommandParser::registered("swift::simplugin::common::CSimulatorPluginCommon"))
85 {
86 return;
87 }
88 CSimpleCommandParser::registerCommand({ ".drv intdisplay", "interpolation display" });
89 }
90} // namespace swift::simplugin::common
virtual void unload()
Driver will be unloaded.
virtual bool disconnectFrom()
Disconnect from simulator.
ISimulator(const swift::misc::simulation::CSimulatorPluginInfo &pluginInfo, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *remoteAircraftProvider, swift::misc::network::IClientProvider *clientProvider, QObject *parent=nullptr)
Constructor with all the providers.
static QWidget * mainApplicationWidget()
Main application window widget.
Utility methods for simple line parsing used with the command line.
static void registerCommand(const CommandHtmlHelp &command)
Register a command.
bool matchesPart(int index, const QString &toMatch, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
Matches given part.
static bool registered(const QString &helpContext)
Help already registered.
Direct in memory access to client (network client) data.
Direct threadsafe in memory access to own aircraft.
Direct thread safe in memory access to remote aircraft.
CSimulatorPluginCommon(const swift::misc::simulation::CSimulatorPluginInfo &info, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *renderedAircraftProvider, swift::misc::network::IClientProvider *clientProvider, QObject *parent=nullptr)
Constructor.
bool parseDetails(const swift::misc::CSimpleCommandParser &parser)
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
High level reusable GUI components.
GUI related classes.
Free functions in swift::misc.
QObject(QObject *parent)
QObject * parent() const const
bool close()