From d280141563fd599a4b7d6534348d64beaef15f3b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 28 Feb 2017 04:33:57 +0100 Subject: [PATCH] refs #891, P3D driver / config --- src/plugins/simulator/p3d/p3d.pro | 37 ++++++++++++++ src/plugins/simulator/p3d/simulatorp3d.cpp | 45 +++++++++++++++++ src/plugins/simulator/p3d/simulatorp3d.h | 48 +++++++++++++++++++ src/plugins/simulator/p3d/simulatorp3d.json | 7 +++ .../simulator/p3d/simulatorp3dfactory.cpp | 34 +++++++++++++ .../simulator/p3d/simulatorp3dfactory.h | 48 +++++++++++++++++++ src/plugins/simulator/p3dconfig/p3dconfig.pro | 27 +++++++++++ .../p3dconfig/simulatorp3dconfig.cpp | 27 +++++++++++ .../simulator/p3dconfig/simulatorp3dconfig.h | 43 +++++++++++++++++ .../p3dconfig/simulatorp3dconfig.json | 3 ++ 10 files changed, 319 insertions(+) create mode 100644 src/plugins/simulator/p3d/p3d.pro create mode 100644 src/plugins/simulator/p3d/simulatorp3d.cpp create mode 100644 src/plugins/simulator/p3d/simulatorp3d.h create mode 100644 src/plugins/simulator/p3d/simulatorp3d.json create mode 100644 src/plugins/simulator/p3d/simulatorp3dfactory.cpp create mode 100644 src/plugins/simulator/p3d/simulatorp3dfactory.h create mode 100644 src/plugins/simulator/p3dconfig/p3dconfig.pro create mode 100644 src/plugins/simulator/p3dconfig/simulatorp3dconfig.cpp create mode 100644 src/plugins/simulator/p3dconfig/simulatorp3dconfig.h create mode 100644 src/plugins/simulator/p3dconfig/simulatorp3dconfig.json diff --git a/src/plugins/simulator/p3d/p3d.pro b/src/plugins/simulator/p3d/p3d.pro new file mode 100644 index 000000000..407f8ccd9 --- /dev/null +++ b/src/plugins/simulator/p3d/p3d.pro @@ -0,0 +1,37 @@ +load(common_pre) + +REQUIRES += contains(BLACK_CONFIG,P3D) + +QT += core dbus gui network concurrent xml + +TARGET = simulatorp3d +TEMPLATE = lib + +CONFIG += plugin shared +CONFIG += blackmisc blackcore + +LIBS += -lsimulatorfscommon -lsimulatorfsxcommon -lSimConnect -lFSUIPC_User + +# required for FSUIPC +win32:!win32-g++*: QMAKE_LFLAGS += /NODEFAULTLIB:LIBC.lib + +DEPENDPATH += . $$SourceRoot/src +INCLUDEPATH += . $$SourceRoot/src + +LIBS += -ldxguid -lole32 + +SOURCES += *.cpp +HEADERS += *.h +DISTFILES += simulatorp3d.json + +DESTDIR = $$DestRoot/bin/plugins/simulator + +win32 { + dlltarget.path = $$PREFIX/bin/plugins/simulator + INSTALLS += dlltarget +} else { + target.path = $$PREFIX/bin/plugins/simulator + INSTALLS += target +} + +load(common_post) diff --git a/src/plugins/simulator/p3d/simulatorp3d.cpp b/src/plugins/simulator/p3d/simulatorp3d.cpp new file mode 100644 index 000000000..614714881 --- /dev/null +++ b/src/plugins/simulator/p3d/simulatorp3d.cpp @@ -0,0 +1,45 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "simulatorp3d.h" +#include "blackcore/application.h" +#include "blackmisc/threadutils.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; +using namespace BlackMisc::PhysicalQuantities; +using namespace BlackMisc::Geo; +using namespace BlackMisc::Network; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::FsCommon; +using namespace BlackMisc::Weather; +using namespace BlackCore; + +namespace BlackSimPlugin +{ + namespace P3D + { + CSimulatorP3D::CSimulatorP3D(const CSimulatorPluginInfo &info, + IOwnAircraftProvider *ownAircraftProvider, + IRemoteAircraftProvider *remoteAircraftProvider, + IWeatherGridProvider *weatherGridProvider, + QObject *parent) : + CSimulatorFsxCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent) + { + //! \todo set P3D default model + m_defaultModel = + { + "Boeing 737-800 Paint1", + CAircraftModel::TypeModelMatchingDefaultModel, + "B737-800 default model", + CAircraftIcaoCode("B738", "L2J") + }; + } + } // namespace +} // namespace diff --git a/src/plugins/simulator/p3d/simulatorp3d.h b/src/plugins/simulator/p3d/simulatorp3d.h new file mode 100644 index 000000000..d49284c21 --- /dev/null +++ b/src/plugins/simulator/p3d/simulatorp3d.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKSIMPLUGIN_SIMULATOR_P3D_H +#define BLACKSIMPLUGIN_SIMULATOR_P3D_H + +#include "../fsxcommon/simulatorfsxcommon.h" + +namespace BlackSimPlugin +{ + namespace P3D + { + //! P3D Simulator Implementation + class CSimulatorP3D : public BlackSimPlugin::FsxCommon::CSimulatorFsxCommon + { + Q_OBJECT + + public: + //! Constructor, parameters as in \sa BlackCore::ISimulatorFactory::create + CSimulatorP3D( + const BlackMisc::Simulation::CSimulatorPluginInfo &info, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, + BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, + QObject *parent = nullptr); + }; + + //! Listener for P3D + class CSimulatorP3DListener : public BlackSimPlugin::FsxCommon::CSimulatorFsxCommonListener + { + Q_OBJECT + + public: + //! Constructor + using CSimulatorFsxCommonListener::CSimulatorFsxCommonListener; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/plugins/simulator/p3d/simulatorp3d.json b/src/plugins/simulator/p3d/simulatorp3d.json new file mode 100644 index 000000000..4fb37997b --- /dev/null +++ b/src/plugins/simulator/p3d/simulatorp3d.json @@ -0,0 +1,7 @@ +{ + "identifier" : "org.swift-project.plugins.simulator.p3d", + "name" : "PREPAR3D", + "simulator" : "p3d", + "description" : "Lockheed Martin PREPAR3D (v1-v3)", + "config" : "org.swift-project.plugins.simulator.p3d.config" +} diff --git a/src/plugins/simulator/p3d/simulatorp3dfactory.cpp b/src/plugins/simulator/p3d/simulatorp3dfactory.cpp new file mode 100644 index 000000000..b0bf8dd68 --- /dev/null +++ b/src/plugins/simulator/p3d/simulatorp3dfactory.cpp @@ -0,0 +1,34 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "simulatorp3dfactory.h" +#include "simulatorp3d.h" +#include "blackmisc/simulation/simulatorplugininfo.h" +#include + +namespace BlackSimPlugin +{ + namespace P3D + { + BlackCore::ISimulator *CSimulatorP3DFactory::create(const BlackMisc::Simulation::CSimulatorPluginInfo &info, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, + BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider) + { + Q_ASSERT(ownAircraftProvider); + return new CSimulatorP3D(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, this); + } + + BlackCore::ISimulatorListener *CSimulatorP3DFactory::createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) + { + return new CSimulatorP3DListener(info); + } + + } // namespace +} // namespace diff --git a/src/plugins/simulator/p3d/simulatorp3dfactory.h b/src/plugins/simulator/p3d/simulatorp3dfactory.h new file mode 100644 index 000000000..c680ca32c --- /dev/null +++ b/src/plugins/simulator/p3d/simulatorp3dfactory.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKSIMPLUGIN_SIMULATOR_P3DFACTORY_H +#define BLACKSIMPLUGIN_SIMULATOR_P3DFACTORY_H + +#include "blackcore/simulator.h" +#include "blackmisc/simulation/simulatorplugininfo.h" + +#include +#include +#include + +namespace BlackSimPlugin +{ + namespace P3D + { + //! Factory implementation to create CSimulatorP3D instances + class CSimulatorP3DFactory : + public QObject, + public BlackCore::ISimulatorFactory + { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.swift-project.blackcore.simulatorinterface" FILE "simulatorp3d.json") + Q_INTERFACES(BlackCore::ISimulatorFactory) + + public: + //! \copydoc BlackCore::ISimulatorFactory::create + virtual BlackCore::ISimulator *create(const BlackMisc::Simulation::CSimulatorPluginInfo &info, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, + BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider) override; + + //! \copydoc BlackCore::ISimulatorFactory::createListener + virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) override; + }; + } // namespace +} // namespace + +#endif // guard diff --git a/src/plugins/simulator/p3dconfig/p3dconfig.pro b/src/plugins/simulator/p3dconfig/p3dconfig.pro new file mode 100644 index 000000000..d6c3bb2f9 --- /dev/null +++ b/src/plugins/simulator/p3dconfig/p3dconfig.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core widgets dbus network + +TARGET = simulatorp3dconfig +TEMPLATE = lib +CONFIG += plugin shared +CONFIG += blackmisc blackcore blackgui + +DEPENDPATH += . $$SourceRoot/src +INCLUDEPATH += . $$SourceRoot/src + +SOURCES += *.cpp +HEADERS += *.h +DISTFILES += simulatorp3dconfig.json +LIBS += -lsimulatorfsxcommon +DESTDIR = $$DestRoot/bin/plugins/simulator + +win32 { + dlltarget.path = $$PREFIX/bin/plugins/simulator + INSTALLS += dlltarget +} else { + target.path = $$PREFIX/bin/plugins/simulator + INSTALLS += target +} + +load(common_post) diff --git a/src/plugins/simulator/p3dconfig/simulatorp3dconfig.cpp b/src/plugins/simulator/p3dconfig/simulatorp3dconfig.cpp new file mode 100644 index 000000000..8d4b62c9c --- /dev/null +++ b/src/plugins/simulator/p3dconfig/simulatorp3dconfig.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "simulatorp3dconfig.h" +#include "../fsxcommon/simulatorfsxconfigwindow.h" + +namespace BlackSimPlugin +{ + namespace P3D + { + CSimulatorP3DConfig::CSimulatorP3DConfig(QObject *parent) : QObject(parent) + { + // void + } + + BlackGui::CPluginConfigWindow *CSimulatorP3DConfig::createConfigWindow(QWidget *parent) + { + return new BlackSimPlugin::FsxCommon::CSimulatorFsxConfigWindow("P3D", parent); + } + } +} diff --git a/src/plugins/simulator/p3dconfig/simulatorp3dconfig.h b/src/plugins/simulator/p3dconfig/simulatorp3dconfig.h new file mode 100644 index 000000000..db185fee2 --- /dev/null +++ b/src/plugins/simulator/p3dconfig/simulatorp3dconfig.h @@ -0,0 +1,43 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKSIMPLUGIN_P3D_SIMULATORP3DCONFIG_H +#define BLACKSIMPLUGIN_P3D_SIMULATORP3DCONFIG_H + +#include "blackgui/pluginconfig.h" + +namespace BlackSimPlugin +{ + namespace P3D + { + /*! + * Window for setting up the P3D plugin. + */ + class CSimulatorP3DConfig : public QObject, public BlackGui::IPluginConfig + { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.swift-project.blackgui.pluginconfiginterface" FILE "simulatorp3dconfig.json") + Q_INTERFACES(BlackGui::IPluginConfig) + + public: + //! Ctor + CSimulatorP3DConfig(QObject *parent = nullptr); + + //! Dtor + virtual ~CSimulatorP3DConfig() {} + + //! \copydoc BlackGui::IPluginConfig::createConfigWindow() + BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override; + }; + } +} + +#endif // guard diff --git a/src/plugins/simulator/p3dconfig/simulatorp3dconfig.json b/src/plugins/simulator/p3dconfig/simulatorp3dconfig.json new file mode 100644 index 000000000..020f2e6b5 --- /dev/null +++ b/src/plugins/simulator/p3dconfig/simulatorp3dconfig.json @@ -0,0 +1,3 @@ +{ + "identifier" : "org.swift-project.plugins.simulator.p3d.config" +}