refs #916, interpolator mode utility functions for SimObjects

This commit is contained in:
Klaus Basan
2017-03-17 18:56:57 +01:00
committed by Mathew Sutcliffe
parent 6ec0960811
commit 3a6df31c99
2 changed files with 53 additions and 13 deletions

View File

@@ -22,9 +22,9 @@ namespace BlackSimPlugin
CSimConnectObject::CSimConnectObject(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, CSimConnectObject::CSimConnectObject(const BlackMisc::Simulation::CSimulatedAircraft &aircraft,
DWORD requestId, DWORD requestId,
BlackMisc::Simulation::CInterpolationLogger *logger) : CInterpolationLogger *logger) :
m_aircraft(aircraft), m_requestId(requestId), m_validRequestId(true), m_aircraft(aircraft), m_requestId(requestId), m_validRequestId(true),
m_interpolator(QSharedPointer<BlackMisc::Simulation::CInterpolatorMulti>::create(aircraft.getCallsign())) m_interpolator(QSharedPointer<CInterpolatorMulti>::create(aircraft.getCallsign()))
{ {
m_interpolator->attachLogger(logger); m_interpolator->attachLogger(logger);
} }
@@ -74,6 +74,16 @@ namespace BlackSimPlugin
return this->hasValidRequestId() && this->hasValidObjectId(); return this->hasValidRequestId() && this->hasValidObjectId();
} }
void CSimConnectObject::toggleInterpolatorMode()
{
this->m_interpolator->toggleMode();
}
bool CSimConnectObject::setInterpolatorMode(CInterpolatorMulti::Mode mode)
{
return this->m_interpolator->setMode(mode);
}
bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts) bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts)
{ {
// First check, if this request id belongs to us // First check, if this request id belongs to us
@@ -123,5 +133,29 @@ namespace BlackSimPlugin
} }
return false; return false;
} }
void CSimConnectObjects::toggleInterpolatorModes()
{
for (const CCallsign &cs : this->keys())
{
(*this)[cs].toggleInterpolatorMode();
}
}
void CSimConnectObjects::toggleInterpolatorMode(const CCallsign &callsign)
{
if (!this->contains(callsign)) { return; }
(*this)[callsign].toggleInterpolatorMode();
}
int CSimConnectObjects::setInterpolatorModes(CInterpolatorMulti::Mode mode)
{
int c = 0;
for (const CCallsign &cs : this->keys())
{
if ((*this)[cs].setInterpolatorMode(mode)) c++;
}
return c;
}
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -13,18 +13,10 @@
#define BLACKSIMPLUGIN_FSXCOMMON_SIMCONNECTOBJECT_H #define BLACKSIMPLUGIN_FSXCOMMON_SIMCONNECTOBJECT_H
#include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/simulation/interpolatormulti.h"
#include "simconnectdatadefinition.h" #include "simconnectdatadefinition.h"
#include <QSharedPointer> #include <QSharedPointer>
namespace BlackMisc
{
namespace Simulation
{
class CInterpolatorLinear;
class CInterpolatorMulti;
class CInterpolationLogger;
}
}
namespace BlackSimPlugin namespace BlackSimPlugin
{ {
namespace FsxCommon namespace FsxCommon
@@ -128,12 +120,18 @@ namespace BlackSimPlugin
//! Was the object really added to SIM //! Was the object really added to SIM
bool hasValidRequestAndObjectId() const; bool hasValidRequestAndObjectId() const;
//! Toggle interpolator mode
void toggleInterpolatorMode();
//! Set interpolator mode
bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
private: private:
BlackMisc::Simulation::CSimulatedAircraft m_aircraft; //!< corresponding aircraft BlackMisc::Simulation::CSimulatedAircraft m_aircraft; //!< corresponding aircraft
DWORD m_requestId = 0; DWORD m_requestId = 0;
DWORD m_objectId = 0; DWORD m_objectId = 0;
bool m_validRequestId = false; bool m_validRequestId = false;
bool m_validObjectId = false; bool m_validObjectId = false;
bool m_confirmedAdded = false; bool m_confirmedAdded = false;
bool m_pendingRemoved = false; bool m_pendingRemoved = false;
int m_lightsRequestedAt = -1; int m_lightsRequestedAt = -1;
@@ -141,7 +139,6 @@ namespace BlackSimPlugin
BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling
BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator
SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation
// QSharedPointer<BlackMisc::Simulation::CInterpolatorLinear> m_interpolator; //!< shared pointer because CSimConnectObject can be copied
QSharedPointer<BlackMisc::Simulation::CInterpolatorMulti> m_interpolator; //!< shared pointer because CSimConnectObject can be copied QSharedPointer<BlackMisc::Simulation::CInterpolatorMulti> m_interpolator; //!< shared pointer because CSimConnectObject can be copied
}; };
@@ -166,6 +163,15 @@ namespace BlackSimPlugin
//! Pending add condition //! Pending add condition
bool containsPendingAdd() const; bool containsPendingAdd() const;
//! Toggle interpolator modes
void toggleInterpolatorModes();
//! Toggle interpolator modes
void toggleInterpolatorMode(const BlackMisc::Aviation::CCallsign &callsign);
//! Set interpolator modes
int setInterpolatorModes(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
}; };
} // namespace } // namespace
} // namespace } // namespace