Ref T180, dot commands to set rendering setup

* enable parts/debug messages via dot command
* allow to log to console via application context
This commit is contained in:
Klaus Basan
2017-11-05 20:15:01 +01:00
parent 1bf2f63589
commit 482023b2c0
7 changed files with 64 additions and 5 deletions

View File

@@ -62,6 +62,9 @@ namespace BlackCore
Q_ASSERT(s);
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"hotkeyActionsRegistered", this, SIGNAL(hotkeyActionsRegistered(QStringList, BlackMisc::CIdentifier)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"requestDisplayOnConsole", this, SIGNAL(requestDisplayOnConsole(QString)));
Q_UNUSED(s);
this->relayBaseClassSignals(serviceName, connection, IContextApplication::ObjectPath(), IContextApplication::InterfaceName());
}

View File

@@ -61,6 +61,7 @@ namespace BlackCore
m_plugins->collectPlugins();
restoreSimulatorPlugins();
CContextSimulator::registerHelp();
connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CContextSimulator::ps_modelSetChanged);
connect(&m_modelSetLoader, &CAircraftModelSetLoader::cacheChanged, this, &CContextSimulator::ps_modelSetChanged);
@@ -626,12 +627,32 @@ namespace BlackCore
if (commandLine.isEmpty()) { return false; }
CSimpleCommandParser parser(
{
".plugin",
".drv", ".driver" // forwarded to driver
".plugin", ".drv", ".driver", // forwarded to driver
".ris" // rendering interpolator setup
});
parser.parse(commandLine);
if (!parser.isKnownCommand()) { return false; }
if (parser.matchesCommand("ris"))
{
CInterpolationAndRenderingSetup rs = this->getInterpolationAndRenderingSetup();
const QString p1 = parser.part(1);
if (p1 == "show")
{
if (this->getIContextApplication())
{
emit this->getIContextApplication()->requestDisplayOnConsole(rs.toQString(true));
}
return true;
}
if (!parser.hasPart(2)) { return false; }
const bool on = stringToBool(parser.part(2));
if (p1 == "debug") { rs.setDriverDebuggingMessages(on); }
else if (p1 == "parts") { rs.setEnabledAircraftParts(on); }
else { return false; }
this->setInterpolationAndRenderingSetup(rs);
CLogMessage(this, CLogCategory::cmdLine()).info("Setup is: '%1'") << rs.toQString(true);
return true;
}
if (parser.matchesCommand("plugin") || parser.matchesCommand("drv") || parser.matchesCommand("driver"))
{
if (!m_simulatorPlugin.second) { return false; }

View File

@@ -107,12 +107,26 @@ namespace BlackCore
//! \addtogroup swiftdotcommands
//! @{
//! <pre>
//! .plugin forwarded to plugin, see details there
//! .driver .drv forwarded to plugin (same as above)
//! .plugin forwarded to plugin, see details there
//! .driver .drv forwarded to plugin (same as above)
//! .ris show show interpolation setup in console
//! .ris debug on|off interpolation/rendering setup, debug messages
//! .ris parts on|off interpolation/rendering setup, aircraft parts
//! </pre>
//! @}
//! \copydoc IContextSimulator::parseCommandLine
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
//! Register dot commands
static void registerHelp()
{
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CContextSimulator")) { return; }
BlackMisc::CSimpleCommandParser::registerCommand({".ris", "rendering/interpolation setup"});
BlackMisc::CSimpleCommandParser::registerCommand({".ris show", "display rendering/interpolation setup on console"});
BlackMisc::CSimpleCommandParser::registerCommand({".ris debug on|off", "rendering/interpolation debug messages"});
BlackMisc::CSimpleCommandParser::registerCommand({".ris parts on|off", "aircraft parts"});
}
// ----------------------------- context interface -----------------------------
protected: