From 70e08fdf8b2f081b99aee79cf29b9a6812b33792 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 14 Feb 2020 00:41:31 +0100 Subject: [PATCH] Ref T773, allow to clear/write log. from interpolation UI via buttons --- src/blackcore/simulator.cpp | 6 +-- .../components/interpolationlogdisplay.cpp | 43 ++++++++++++++----- .../components/interpolationlogdisplay.h | 11 +++-- .../components/interpolationlogdisplay.ui | 38 +++++++++++++++- 4 files changed, 80 insertions(+), 18 deletions(-) diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 483775a29..53775b0eb 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -418,14 +418,14 @@ namespace BlackCore const QString part2 = parser.part(2).toLower(); if (part2 == "off" || part2 == "false") { - CStatusMessage(this).info(u"Disabled interpolation logging"); + CLogMessage(this).info(u"Disabled interpolation logging"); this->clearInterpolationLogCallsigns(); return true; } if (part2 == "clear" || part2 == "clr") { m_interpolationLogger.clearLog(); - CStatusMessage(this).info(u"Cleared interpolation logging"); + CLogMessage(this).info(u"Cleared interpolation logging"); this->clearInterpolationLogCallsigns(); return true; } @@ -436,7 +436,7 @@ namespace BlackCore const int max = parser.part(3).toInt(&ok); if (!ok) { return false; } m_interpolationLogger.setMaxSituations(max); - CStatusMessage(this).info(u"Max.situations logged: %1") << max; + CLogMessage(this).info(u"Max.situations logged: %1") << max; return true; } if (part2 == "write" || part2 == "save") diff --git a/src/blackgui/components/interpolationlogdisplay.cpp b/src/blackgui/components/interpolationlogdisplay.cpp index 625909e2c..5c4d4e5ad 100644 --- a/src/blackgui/components/interpolationlogdisplay.cpp +++ b/src/blackgui/components/interpolationlogdisplay.cpp @@ -76,13 +76,17 @@ namespace BlackGui connect(ui->pb_StartStop, &QPushButton::released, this, &CInterpolationLogDisplay::toggleStartStop); connect(ui->pb_ResetLastSent, &QPushButton::released, this, &CInterpolationLogDisplay::resetLastSentValues); connect(ui->pb_ResetStats, &QPushButton::released, this, &CInterpolationLogDisplay::resetStatistics); - connect(ui->pb_ShowLogInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::showLogInSimulator); + connect(ui->pb_ShowLogInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::logPosCommand); connect(ui->pb_FollowInSimulator, &QPushButton::released, this, &CInterpolationLogDisplay::followInSimulator); connect(ui->pb_RequestElevation1, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked); connect(ui->pb_RequestElevation2, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked); connect(ui->pb_GetLastInterpolation, &QPushButton::released, this, &CInterpolationLogDisplay::getLogAmdDisplayLastInterpolation); connect(ui->pb_InjectElevation, &QPushButton::released, this, &CInterpolationLogDisplay::onInjectElevation); connect(ui->pb_ElvClear, &QPushButton::released, this, &CInterpolationLogDisplay::clearElevationResults); + connect(ui->pb_ClearLog, &QPushButton::released, this, &CInterpolationLogDisplay::clearLogCommand); + connect(ui->pb_ClearLog2, &QPushButton::released, this, &CInterpolationLogDisplay::clearLogCommand); + connect(ui->pb_WriteLogToFile, &QPushButton::released, this, &CInterpolationLogDisplay::writeLogCommand); + connect(ui->pb_WriteLogToFile2, &QPushButton::released, this, &CInterpolationLogDisplay::writeLogCommand); connect(ui->tvp_InboundAircraftSituations, &CAircraftSituationView::requestElevation, this, &CInterpolationLogDisplay::requestElevation); connect(ui->le_InjectElevation, &QLineEdit::returnPressed, this, &CInterpolationLogDisplay::onInjectElevation); connect(ui->le_ElvHistoryCount, &QLineEdit::editingFinished, this, &CInterpolationLogDisplay::onElevationHistoryCountFinished); @@ -180,6 +184,7 @@ namespace BlackGui void CInterpolationLogDisplay::getLogAmdDisplayLastInterpolation() { + if (!m_simulator) { return; } const SituationLog sLog = m_simulator->interpolationLogger().getLastSituationLog(); this->displayLastInterpolation(sLog); } @@ -283,15 +288,6 @@ namespace BlackGui } } - void CInterpolationLogDisplay::showLogInSimulator() - { - if (m_callsign.isEmpty()) { return; } - if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } - - const QString cmd = QStringLiteral(".drv pos ") % m_callsign.asString(); - sGui->getIContextSimulator()->parseCommandLine(cmd, this->identifier()); - } - void CInterpolationLogDisplay::followInSimulator() { if (m_callsign.isEmpty()) { return; } @@ -479,13 +475,38 @@ namespace BlackGui } } + void CInterpolationLogDisplay::logPosCommand() + { + if (m_callsign.isEmpty()) { return; } + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } + + const QString cmd = QStringLiteral(".drv logint clear") % m_callsign.asString(); + sGui->getIContextSimulator()->parseCommandLine(cmd, this->identifier()); + } + + void CInterpolationLogDisplay::clearLogCommand() + { + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } + + const QString cmd = QStringLiteral(".drv logint clear"); + sGui->getIContextSimulator()->parseCommandLine(cmd, this->identifier()); + } + + void CInterpolationLogDisplay::writeLogCommand() + { + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } + + const QString cmd = QStringLiteral(".drv logint write"); + sGui->getIContextSimulator()->parseCommandLine(cmd, this->identifier()); + } + bool CInterpolationLogDisplay::checkLogPrerequisites() { CStatusMessage m; do { if (!this->isVisible()) { return false; } // silently return - if (!sApp || sApp->isShuttingDown()) { break; } // stop and return + if (!sGui || sGui->isShuttingDown()) { break; } // stop and return if (m_callsign.isEmpty()) { // static const CStatusMessage ms = CStatusMessage(this).validationError(u"No callsign for logging"); diff --git a/src/blackgui/components/interpolationlogdisplay.h b/src/blackgui/components/interpolationlogdisplay.h index c341151fa..a618866b2 100644 --- a/src/blackgui/components/interpolationlogdisplay.h +++ b/src/blackgui/components/interpolationlogdisplay.h @@ -96,9 +96,6 @@ namespace BlackGui //! Toggle start/stop void toggleStartStop(); - //! Display log in simulator - void showLogInSimulator(); - //! Follow aircraft in simulator void followInSimulator(); @@ -150,6 +147,14 @@ namespace BlackGui //! Clear elevation results void clearElevationResults(); + //! Clear log. command + void clearLogCommand(); + + //! Write log. command + void writeLogCommand(); + + //! Display log in simulator + void logPosCommand(); //! Check if can do logging, otherwise stop and display message bool checkLogPrerequisites(); diff --git a/src/blackgui/components/interpolationlogdisplay.ui b/src/blackgui/components/interpolationlogdisplay.ui index 47aa7ef11..afc67d618 100644 --- a/src/blackgui/components/interpolationlogdisplay.ui +++ b/src/blackgui/components/interpolationlogdisplay.ui @@ -177,7 +177,7 @@ - + 3 @@ -197,6 +197,20 @@ + + + + write log. + + + + + + + clear log. + + + @@ -664,6 +678,20 @@ + + + + write log. + + + + + + + clear log. + + + @@ -1018,6 +1046,8 @@ hs_UpdateTime pb_StartStop comp_CallsignCompleter + pb_WriteLogToFile + pb_ClearLog pb_ResetStats pb_ResetLastSent pb_ShowLogInSimulator @@ -1037,6 +1067,7 @@ le_ElevationReqRec le_Elevation le_SimulatorSpecific + le_InboundSituationsInfo tvp_InboundAircraftSituations tvp_InboundAircraftParts tvp_Changes @@ -1050,7 +1081,12 @@ tvp_InterpolatedAircraftSituations tvp_LoopbackAircraftSituations te_TextLog + pb_ElvClear + le_ElvHistoryCount + cb_ElvAllowPseudo + le_ElevationTestValue pte_ElevationAtPosition + lv_ElevevationHistory