From 277837bb3088810d746f6ffdb975f11549a51d56 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 17 Mar 2017 19:04:03 +0100 Subject: [PATCH] refs #916, dot command for interpolator mode --- src/blackcore/simulator.h | 4 ++++ src/blackcore/simulatorcommon.cpp | 30 +++++++++++++++++++++++------- src/blackcore/simulatorcommon.h | 12 +++++++----- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 78539314b..c68d37afd 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -19,6 +19,7 @@ #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/interpolationrenderingsetup.h" +#include "blackmisc/simulation/interpolatormulti.h" #include "blackmisc/pq/length.h" #include "blackmisc/pq/time.h" #include "blackmisc/statusmessage.h" @@ -150,6 +151,9 @@ namespace BlackCore //! Driver will be unloaded virtual void unload() = 0; + //! Set interpolation mode, empty callsign applies to all know callsigns + virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) = 0; + //! \addtogroup swiftdotcommands //! @{ //!
diff --git a/src/blackcore/simulatorcommon.cpp b/src/blackcore/simulatorcommon.cpp
index ce323ae05..0625584fd 100644
--- a/src/blackcore/simulatorcommon.cpp
+++ b/src/blackcore/simulatorcommon.cpp
@@ -352,23 +352,24 @@ namespace BlackCore
             return true;
         }
 
-        // .plugin loginterpolator etc.
-        if (parser.part(1).startsWith("logint") && parser.hasPart(2))
+        // .plugin log interpolator
+        const QString part1(parser.part(1).toLower().trimmed());
+        if (part1.startsWith("logint") && parser.hasPart(2))
         {
-            const QString p = parser.part(2).toLower();
-            if (p == "off" || p == "false")
+            const QString part2 = parser.part(2).toLower();
+            if (part2 == "off" || part2 == "false")
             {
                 this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
                 CStatusMessage(this).info("Disabled interpolation logging");
                 return true;
             }
-            if (p == "clear" || p == "clr")
+            if (part2 == "clear" || part2 == "clr")
             {
                 this->m_interpolationLogger.clearLog();
                 CStatusMessage(this).info("Cleared interpolation logging");
                 return true;
             }
-            if (p == "write" || p == "save")
+            if (part2 == "write" || part2 == "save")
             {
                 // stop logging
                 this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
@@ -379,7 +380,7 @@ namespace BlackCore
                 return true;
             }
 
-            const QString cs = p.toUpper();
+            const QString cs = part2.toUpper();
             if (!CCallsign::isValidAircraftCallsign(cs)) { return false; }
             if (this->getAircraftInRangeCallsigns().contains(cs))
             {
@@ -394,6 +395,21 @@ namespace BlackCore
             }
         }
 
+        if (part1.startsWith("spline") || part1.startsWith("linear"))
+        {
+            CCallsign cs(parser.hasPart(2) ? parser.part(2) : "");
+            const bool changed = this->setInterpolatorMode(CInterpolatorMulti::modeFromString(part1), cs);
+            if (changed)
+            {
+                CLogMessage(this).info("Changed interpolation mode");
+            }
+            else
+            {
+                CLogMessage(this).info("Unchanged interpolation mode");
+            }
+            return true;
+        }
+
         // driver specific cmd line arguments
         return this->parseDetails(parser);
     }
diff --git a/src/blackcore/simulatorcommon.h b/src/blackcore/simulatorcommon.h
index 1c1572375..f093b8ae6 100644
--- a/src/blackcore/simulatorcommon.h
+++ b/src/blackcore/simulatorcommon.h
@@ -88,11 +88,12 @@ namespace BlackCore
         //! \addtogroup swiftdotcommands
         //! @{
         //! 
-        //! .drv unload              unload plugin                           BlackCore::CSimulatorCommon
-        //! .drv logint  callsign    log interpolator for callsign           BlackCore::CSimulatorCommon
-        //! .drv logint  off         no log information for interpolator     BlackCore::CSimulatorCommon
-        //! .drv logint  write       write interpolator log to file          BlackCore::CSimulatorCommon
-        //! .drv logint  clear       clear current log                       BlackCore::CSimulatorCommon
+        //! .drv unload                    unload plugin                           BlackCore::CSimulatorCommon
+        //! .drv logint callsign           log interpolator for callsign           BlackCore::CSimulatorCommon
+        //! .drv logint off                no log information for interpolator     BlackCore::CSimulatorCommon
+        //! .drv logint write              write interpolator log to file          BlackCore::CSimulatorCommon
+        //! .drv logint clear              clear current log                       BlackCore::CSimulatorCommon
+        //! .drv spline|linear callsign    interpolator spline                     BlackCore::CSimulatorCommon
         //! 
//! @} //! \copydoc ISimulator::parseCommandLine @@ -107,6 +108,7 @@ namespace BlackCore BlackMisc::CSimpleCommandParser::registerCommand({".drv logint off", "no log information for interpolator"}); BlackMisc::CSimpleCommandParser::registerCommand({".drv logint write", "write interpolator log to file"}); BlackMisc::CSimpleCommandParser::registerCommand({".drv logint clear", "clear current log"}); + BlackMisc::CSimpleCommandParser::registerCommand({".drv spline|linear ", "set spline/linear interpolator for one/all callsign(s)"}); } // --------- ISimulator implementations ------------