mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 21:45:34 +08:00
Ref T270, display window for interpolation log
This commit is contained in:
133
src/blackgui/components/interpolationlogdisplay.cpp
Normal file
133
src/blackgui/components/interpolationlogdisplay.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "interpolationlogdisplay.h"
|
||||
#include "ui_interpolationlogdisplay.h"
|
||||
#include "blackmisc/simulation/interpolationlogger.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CInterpolationLogDisplay::CInterpolationLogDisplay(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CInterpolationLogDisplay)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
constexpr int timeSecs = 5;
|
||||
ui->hs_UpdateTime->setValue(timeSecs);
|
||||
this->onSliderChanged(timeSecs);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CInterpolationLogDisplay::updateLog);
|
||||
connect(ui->hs_UpdateTime, &QSlider::valueChanged, this, &CInterpolationLogDisplay::onSliderChanged);
|
||||
connect(ui->pb_StartStop, &QPushButton::released, this, &CInterpolationLogDisplay::toggleStartStop);
|
||||
connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validCallsignEntered, this, &CInterpolationLogDisplay::onCallsignEntered);
|
||||
|
||||
m_callsign = ui->comp_CallsignCompleter->getCallsign();
|
||||
}
|
||||
|
||||
CInterpolationLogDisplay::~CInterpolationLogDisplay()
|
||||
{ }
|
||||
|
||||
void CInterpolationLogDisplay::setSimulator(CSimulatorCommon *simulatorCommon)
|
||||
{
|
||||
m_simulatorCommon = simulatorCommon;
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::updateLog()
|
||||
{
|
||||
const bool hasLogger = m_simulatorCommon;
|
||||
if (hasLogger && !m_callsign.isEmpty())
|
||||
{
|
||||
const QString log = m_simulatorCommon->latestLoggedDataFormatted(m_callsign);
|
||||
ui->te_Log->setText(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->te_Log->setText("No logger attached or no callsign");
|
||||
this->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onSliderChanged(int timeSecs)
|
||||
{
|
||||
static const QString time("%1 secs");
|
||||
m_updateTimer.setInterval(timeSecs * 1000);
|
||||
ui->le_UpdateTime->setText(time.arg(timeSecs));
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onCallsignEntered()
|
||||
{
|
||||
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign();
|
||||
if (!m_simulatorCommon)
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// clear last callsign
|
||||
if (!m_callsign.isEmpty())
|
||||
{
|
||||
m_simulatorCommon->setLogInterpolation(false, m_callsign); // stop logging "old" callsign
|
||||
m_callsign = CCallsign(); // clear callsign
|
||||
}
|
||||
|
||||
// set new callsign or stop
|
||||
if (cs.isEmpty())
|
||||
{
|
||||
this->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
m_callsign = cs;
|
||||
m_simulatorCommon->setLogInterpolation(true, cs);
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::toggleStartStop()
|
||||
{
|
||||
const bool running = m_updateTimer.isActive();
|
||||
if (running)
|
||||
{
|
||||
this->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->start();
|
||||
}
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::start()
|
||||
{
|
||||
const int interval = ui->hs_UpdateTime->value() * 1000;
|
||||
m_updateTimer.start(interval);
|
||||
ui->pb_StartStop->setText(stopText());
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::stop()
|
||||
{
|
||||
m_updateTimer.stop();
|
||||
ui->pb_StartStop->setText(startText());
|
||||
}
|
||||
|
||||
const QString &CInterpolationLogDisplay::startText()
|
||||
{
|
||||
static const QString start("start");
|
||||
return start;
|
||||
}
|
||||
|
||||
const QString &CInterpolationLogDisplay::stopText()
|
||||
{
|
||||
static const QString stop("stop");
|
||||
return stop;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
75
src/blackgui/components/interpolationlogdisplay.h
Normal file
75
src/blackgui/components/interpolationlogdisplay.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 BLACKGUI_COMPONENTS_INTERPOLATIONLOGDISPLAY_H
|
||||
#define BLACKGUI_COMPONENTS_INTERPOLATIONLOGDISPLAY_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/simulatorcommon.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include <QFrame>
|
||||
#include <QTimer>
|
||||
#include <QScopedPointer>
|
||||
#include <QPointer>
|
||||
|
||||
namespace Ui { class CInterpolationLogDisplay; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Display live data of interpolation
|
||||
*/
|
||||
class BLACKGUI_EXPORT CInterpolationLogDisplay : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CInterpolationLogDisplay(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CInterpolationLogDisplay();
|
||||
|
||||
//! Set simulator
|
||||
void setSimulator(BlackCore::CSimulatorCommon *simulatorCommon);
|
||||
|
||||
private:
|
||||
//! Update log.
|
||||
void updateLog();
|
||||
|
||||
//! Slider interval
|
||||
void onSliderChanged(int timeSecs);
|
||||
|
||||
//! Callsign has been changed
|
||||
void onCallsignEntered();
|
||||
|
||||
//! Toggle start/stop
|
||||
void toggleStartStop();
|
||||
|
||||
//! Start displaying
|
||||
void start();
|
||||
|
||||
//! Stop displaying
|
||||
void stop();
|
||||
|
||||
QScopedPointer<Ui::CInterpolationLogDisplay> ui;
|
||||
QTimer m_updateTimer;
|
||||
QPointer<BlackCore::CSimulatorCommon> m_simulatorCommon = nullptr; //!< related simulator
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< current callsign
|
||||
|
||||
static const QString &startText();
|
||||
static const QString &stopText();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
78
src/blackgui/components/interpolationlogdisplay.ui
Normal file
78
src/blackgui/components/interpolationlogdisplay.ui
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CInterpolationLogDisplay</class>
|
||||
<widget class="QFrame" name="CInterpolationLogDisplay">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Interpolation log. display</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Top">
|
||||
<layout class="QHBoxLayout" name="hl_Top" stretch="2,4,1,1">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CCallsignCompleter" name="comp_CallsignCompleter"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="hs_UpdateTime">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_UpdateTime">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_StartStop">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="te_Log">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCallsignCompleter</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/callsigncompleter.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
37
src/blackgui/components/interpolationlogdisplaydialog.cpp
Normal file
37
src/blackgui/components/interpolationlogdisplaydialog.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "interpolationlogdisplaydialog.h"
|
||||
#include "ui_interpolationlogdisplaydialog.h"
|
||||
#include "blackcore/simulatorcommon.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CInterpolationLogDisplayDialog::CInterpolationLogDisplayDialog(CSimulatorCommon *simulatorCommon, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CInterpolationLogDisplayDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
this->setSimulator(simulatorCommon);
|
||||
}
|
||||
|
||||
CInterpolationLogDisplayDialog::~CInterpolationLogDisplayDialog()
|
||||
{ }
|
||||
|
||||
void CInterpolationLogDisplayDialog::setSimulator(CSimulatorCommon *simulatorCommon)
|
||||
{
|
||||
ui->comp_InterpolationLogDisplay->setSimulator(simulatorCommon);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
48
src/blackgui/components/interpolationlogdisplaydialog.h
Normal file
48
src/blackgui/components/interpolationlogdisplaydialog.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 BLACKGUI_COMPONENTS_INTERPOLATIONLOGDISPLAYDIALOG_H
|
||||
#define BLACKGUI_COMPONENTS_INTERPOLATIONLOGDISPLAYDIALOG_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include <QScopedPointer>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui { class CInterpolationLogDisplayDialog; }
|
||||
namespace BlackCore { class CSimulatorCommon; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* CInterpolationLogDisplay as dialog
|
||||
*/
|
||||
class BLACKGUI_EXPORT CInterpolationLogDisplayDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CInterpolationLogDisplayDialog(BlackCore::CSimulatorCommon *simulatorCommon, QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CInterpolationLogDisplayDialog();
|
||||
|
||||
//! Set simulator
|
||||
void setSimulator(BlackCore::CSimulatorCommon *simulatorCommon);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CInterpolationLogDisplayDialog> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
82
src/blackgui/components/interpolationlogdisplaydialog.ui
Normal file
82
src/blackgui/components/interpolationlogdisplaydialog.ui
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CInterpolationLogDisplayDialog</class>
|
||||
<widget class="QDialog" name="CInterpolationLogDisplayDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Interpolation log. display</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_InterpolationLogDisplay">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CInterpolationLogDisplay" name="comp_InterpolationLogDisplay">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_InterpolationLogDisplay">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CInterpolationLogDisplay</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/interpolationlogdisplay.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_InterpolationLogDisplay</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CInterpolationLogDisplayDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_InterpolationLogDisplay</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CInterpolationLogDisplayDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user