mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
First version of CRadarComponent
This commit is contained in:
committed by
Mat Sutcliffe
parent
e0d04e7b92
commit
4273eb4260
@@ -97,6 +97,11 @@ namespace BlackGui
|
||||
return ui->comp_TextMessages;
|
||||
}
|
||||
|
||||
CRadarComponent *CMainInfoAreaComponent::getRadarComponent()
|
||||
{
|
||||
return ui->comp_Radar;
|
||||
}
|
||||
|
||||
void CMainInfoAreaComponent::displayLog()
|
||||
{
|
||||
ui->comp_Log->displayLog();
|
||||
@@ -195,6 +200,7 @@ namespace BlackGui
|
||||
case InfoAreaLog: return CIcons::appLog16();
|
||||
case InfoAreaTextMessages: return CIcons::appTextMessages16();
|
||||
case InfoAreaInterpolation: return CIcons::appInterpolation16();
|
||||
case InfoAreaRadar: return CIcons::appRadar16();
|
||||
default: return CIcons::empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace BlackGui
|
||||
class CLogComponent;
|
||||
class CMappingComponent;
|
||||
class CInterpolationComponent;
|
||||
class CRadarComponent;
|
||||
class CSettingsComponent;
|
||||
class CSimulatorComponent;
|
||||
class CTextMessageComponent;
|
||||
@@ -68,6 +69,7 @@ namespace BlackGui
|
||||
InfoAreaInterpolation = 9,
|
||||
InfoAreaSettings = 10,
|
||||
InfoAreaLog = 11,
|
||||
InfoAreaRadar = 12,
|
||||
InfoAreaNone = -1
|
||||
};
|
||||
|
||||
@@ -107,6 +109,9 @@ namespace BlackGui
|
||||
//! Text messages
|
||||
CTextMessageComponent *getTextMessageComponent();
|
||||
|
||||
//! Radar
|
||||
CRadarComponent *getRadarComponent();
|
||||
|
||||
//! Display the log
|
||||
void displayLog();
|
||||
|
||||
|
||||
@@ -791,6 +791,66 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Radar">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>165</width>
|
||||
<height>66</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::TopDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Radar</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_RadarOuter">
|
||||
<layout class="QVBoxLayout" name="vl_RadarOuter">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_RadarInner">
|
||||
<layout class="QVBoxLayout" name="vl_RadarInner">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CRadarComponent" name="comp_Radar"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -871,6 +931,12 @@
|
||||
<header>blackgui/components/interpolationcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CRadarComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/radarcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace BlackGui
|
||||
connect(ui->pb_MainLog, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
connect(ui->pb_MainMappings, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
connect(ui->pb_MainInterpolation, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
connect(ui->pb_MainRadar, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
connect(ui->pb_MainSettings, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
connect(ui->pb_MainSimulator, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
connect(ui->pb_MainTextMessages, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
|
||||
@@ -202,6 +203,7 @@ namespace BlackGui
|
||||
if (button == ui->pb_MainLog) return CMainInfoAreaComponent::InfoAreaLog;
|
||||
if (button == ui->pb_MainMappings) return CMainInfoAreaComponent::InfoAreaMapping;
|
||||
if (button == ui->pb_MainInterpolation) return CMainInfoAreaComponent::InfoAreaInterpolation;
|
||||
if (button == ui->pb_MainRadar) return CMainInfoAreaComponent::InfoAreaRadar;
|
||||
if (button == ui->pb_MainSettings) return CMainInfoAreaComponent::InfoAreaSettings;
|
||||
if (button == ui->pb_MainSimulator) return CMainInfoAreaComponent::InfoAreaSimulator;
|
||||
if (button == ui->pb_MainTextMessages) return CMainInfoAreaComponent::InfoAreaTextMessages;
|
||||
@@ -221,6 +223,7 @@ namespace BlackGui
|
||||
case CMainInfoAreaComponent::InfoAreaLog: return ui->pb_MainLog;
|
||||
case CMainInfoAreaComponent::InfoAreaMapping: return ui->pb_MainMappings;
|
||||
case CMainInfoAreaComponent::InfoAreaInterpolation: return ui->pb_MainInterpolation;
|
||||
case CMainInfoAreaComponent::InfoAreaRadar: return ui->pb_MainRadar;
|
||||
case CMainInfoAreaComponent::InfoAreaSettings: return ui->pb_MainSettings;
|
||||
case CMainInfoAreaComponent::InfoAreaSimulator: return ui->pb_MainSimulator;
|
||||
case CMainInfoAreaComponent::InfoAreaTextMessages: return ui->pb_MainTextMessages;
|
||||
@@ -240,6 +243,7 @@ namespace BlackGui
|
||||
ui->pb_MainLog->setChecked(false);
|
||||
ui->pb_MainMappings->setChecked(false);
|
||||
ui->pb_MainInterpolation->setChecked(false);
|
||||
ui->pb_MainRadar->setChecked(false);
|
||||
ui->pb_MainSettings->setChecked(false);
|
||||
ui->pb_MainSimulator->setChecked(false);
|
||||
ui->pb_MainTextMessages->setChecked(false);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>122</height>
|
||||
<width>473</width>
|
||||
<height>144</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -364,9 +364,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="pb_Empty">
|
||||
<widget class="QPushButton" name="pb_MainRadar">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@@ -375,7 +375,10 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>Radar</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -427,7 +430,7 @@
|
||||
<tabstop>pb_Opacity050</tabstop>
|
||||
<tabstop>pb_Opacity100</tabstop>
|
||||
<tabstop>pb_CockpitIdent</tabstop>
|
||||
<tabstop>pb_Empty</tabstop>
|
||||
<tabstop>pb_MainRadar</tabstop>
|
||||
<tabstop>pb_SoundMute</tabstop>
|
||||
<tabstop>pb_SoundMaxVolume</tabstop>
|
||||
</tabstops>
|
||||
|
||||
272
src/blackgui/components/radarcomponent.cpp
Normal file
272
src/blackgui/components/radarcomponent.cpp
Normal file
@@ -0,0 +1,272 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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 "ui_radarcomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/infoarea.h"
|
||||
#include "blackgui/components/radarcomponent.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
|
||||
#include <QtMath>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackGui::Views;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CRadarComponent::CRadarComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CRadarComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->gv_RadarView->setScene(&m_scene);
|
||||
|
||||
ui->cb_RadarRange->addItem(QString::number(0.5) + " nm", 0.5);
|
||||
for (qreal r = 1.0; r < 10; r += 1)
|
||||
{
|
||||
ui->cb_RadarRange->addItem(QString::number(r) + " nm", r);
|
||||
}
|
||||
for (qreal r = 10; r < 91; r += 10)
|
||||
{
|
||||
ui->cb_RadarRange->addItem(QString::number(r) + " nm", r);
|
||||
}
|
||||
|
||||
ui->cb_RadarRange->setCurrentText(QString::number(m_range) + " nm");
|
||||
|
||||
connect(ui->gv_RadarView, &CRadarView::radarViewResized, this, &CRadarComponent::fitInView);
|
||||
connect(ui->gv_RadarView, &CRadarView::zoomEvent, this, &CRadarComponent::changeRangeInSteps);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CRadarComponent::refreshTargets);
|
||||
|
||||
connect(ui->cb_RadarRange, qOverload<int>(&QComboBox::currentIndexChanged), this, &CRadarComponent::changeRangeFromUserSelection);
|
||||
connect(ui->cb_Callsign, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
|
||||
connect(ui->cb_Heading, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
|
||||
connect(ui->cb_Altitude, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
|
||||
connect(ui->cb_GroundSpeed, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
|
||||
connect(ui->cb_Grid, &QCheckBox::toggled, this, &CRadarComponent::toggleGrid);
|
||||
|
||||
prepareScene();
|
||||
|
||||
m_updateTimer.start(5000);
|
||||
}
|
||||
|
||||
CRadarComponent::~CRadarComponent()
|
||||
{ }
|
||||
|
||||
bool CRadarComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
|
||||
{
|
||||
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget);
|
||||
const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CRadarComponent::onInfoAreaTabBarChanged);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect");
|
||||
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
|
||||
return c && parentDockableWidget;
|
||||
}
|
||||
|
||||
void CRadarComponent::prepareScene()
|
||||
{
|
||||
m_scene.addItem(&m_center);
|
||||
m_scene.addItem(&m_macroGraticule);
|
||||
m_scene.addItem(&m_microGraticule);
|
||||
m_scene.addItem(&m_radials);
|
||||
m_scene.addItem(&m_radarTargets);
|
||||
m_radarTargetPen.setCosmetic(true);
|
||||
addCenter();
|
||||
addGraticules();
|
||||
addRadials();
|
||||
}
|
||||
|
||||
void CRadarComponent::addCenter()
|
||||
{
|
||||
QPen pen(Qt::white, 1);
|
||||
pen.setCosmetic(true);
|
||||
QGraphicsLineItem *li = new QGraphicsLineItem{QLineF(-5.0, 0.0, 5.0, 0.0), &m_center};
|
||||
li->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
||||
li->setPen(pen);
|
||||
|
||||
li = new QGraphicsLineItem(QLineF(0.0, -5.0, 0.0, 5.0), &m_center);
|
||||
li->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
||||
li->setPen(pen);
|
||||
}
|
||||
|
||||
void CRadarComponent::addGraticules()
|
||||
{
|
||||
QPen pen(Qt::white, 1);
|
||||
pen.setCosmetic(true);
|
||||
|
||||
// Macro graticule, drawn as full line at every 10 nm
|
||||
for (qreal range = 10.0; range < 101.0; range += 10.0)
|
||||
{
|
||||
qreal x = -range;
|
||||
qreal y = -range;
|
||||
qreal width = 2.0 * range;
|
||||
qreal height = 2.0 * range;
|
||||
QGraphicsEllipseItem *circle = new QGraphicsEllipseItem(x, y, width, height, &m_macroGraticule);
|
||||
circle->setPen(pen);
|
||||
}
|
||||
pen = QPen(Qt::gray, 1, Qt::DashLine);
|
||||
pen.setCosmetic(true);
|
||||
|
||||
// Micro graticule, drawn as dash line at every 2.5 nm
|
||||
for (qreal range = 2.5; range < 9.9; range += 2.5)
|
||||
{
|
||||
qreal x = -range;
|
||||
qreal y = -range;
|
||||
qreal width = 2.0 * range;
|
||||
qreal height = 2.0 * range;
|
||||
QGraphicsEllipseItem *circle = new QGraphicsEllipseItem(x, y, width, height, &m_microGraticule);
|
||||
circle->setPen(pen);
|
||||
}
|
||||
}
|
||||
|
||||
void CRadarComponent::addRadials()
|
||||
{
|
||||
QPen pen(Qt::gray, 1, Qt::DashDotDotLine);
|
||||
pen.setCosmetic(true);
|
||||
|
||||
for (qreal angle = 0.0; angle < 359.0; angle += 30.0)
|
||||
{
|
||||
const QLineF line(0.0, 0.0, 100.0 * qCos(qDegreesToRadians(angle)), -100.0 * qSin(qDegreesToRadians(angle)));
|
||||
QGraphicsLineItem *li = new QGraphicsLineItem(line, &m_radials);
|
||||
li->setPen(pen);
|
||||
}
|
||||
}
|
||||
|
||||
void CRadarComponent::refreshTargets()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
qDeleteAll(m_radarTargets.childItems());
|
||||
|
||||
if (sGui->getIContextNetwork()->isConnected())
|
||||
{
|
||||
if (isVisibleWidget())
|
||||
{
|
||||
const CSimulatedAircraftList aircraft = sGui->getIContextNetwork()->getAircraftInRange();
|
||||
for (const CSimulatedAircraft &sa : aircraft)
|
||||
{
|
||||
double distanceNM = sa.getRelativeDistance().value(CLengthUnit::NM());
|
||||
double bearingRad = sa.getRelativeBearing().value(CAngleUnit::rad());
|
||||
int groundSpeedKts = sa.getGroundSpeed().valueInteger(CSpeedUnit::kts());
|
||||
|
||||
QPointF position(distanceNM * qSin(bearingRad), -distanceNM * qCos(bearingRad));
|
||||
|
||||
QGraphicsEllipseItem *dot = new QGraphicsEllipseItem(-2.0, -2.0, 4.0, 4.0, &m_radarTargets);
|
||||
dot->setPos(position);
|
||||
dot->setPen(m_radarTargetPen);
|
||||
dot->setBrush(m_radarTargetPen.color());
|
||||
dot->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
||||
|
||||
QGraphicsTextItem *tag = new QGraphicsTextItem(&m_radarTargets);
|
||||
QString tagText;
|
||||
if (ui->cb_Callsign->isChecked())
|
||||
{
|
||||
tagText += sa.getCallsignAsString() % QStringLiteral("\n");
|
||||
}
|
||||
if (ui->cb_Altitude->isChecked())
|
||||
{
|
||||
int flightLeveL = sa.getAltitude().valueInteger(CLengthUnit::ft()) / 100;
|
||||
tagText += "FL" % QString("%1").arg(flightLeveL, 3, 10, QChar('0'));
|
||||
}
|
||||
if (ui->cb_GroundSpeed->isChecked())
|
||||
{
|
||||
if (! tagText.isEmpty()) tagText += QStringLiteral(" ");
|
||||
|
||||
tagText += QString::number(groundSpeedKts) % " kt";
|
||||
}
|
||||
|
||||
tag->setPlainText(tagText);
|
||||
tag->setPos(position);
|
||||
tag->setDefaultTextColor(Qt::green);
|
||||
tag->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
||||
|
||||
if (ui->cb_Heading->isChecked() && groundSpeedKts > 3.0)
|
||||
{
|
||||
double headingRad = sa.getHeading().value(CAngleUnit::rad());
|
||||
QPen pen(Qt::green, 1);
|
||||
pen.setCosmetic(true);
|
||||
QGraphicsLineItem *li = new QGraphicsLineItem(QLineF(0.0, 0.0, 20.0 * qSin(headingRad), -20.0 * qCos(headingRad)), dot);
|
||||
li->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
||||
li->setPen(pen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CRadarComponent::toggleGrid(bool checked)
|
||||
{
|
||||
m_macroGraticule.setVisible(checked);
|
||||
m_microGraticule.setVisible(checked);
|
||||
m_radials.setVisible(checked);
|
||||
}
|
||||
|
||||
void CRadarComponent::fitInView()
|
||||
{
|
||||
ui->gv_RadarView->fitInView(-m_range, -m_range, 2.0 * m_range, 2.0 * m_range, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void CRadarComponent::changeRangeInSteps(bool zoomIn)
|
||||
{
|
||||
qreal direction = zoomIn ? 1.0 : -1.0;
|
||||
double factor = 10.0;
|
||||
if (m_range < 10.0 || (qFuzzyCompare(m_range, 10.0) && zoomIn))
|
||||
{
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
if (m_range < 1.0 || (qFuzzyCompare(m_range, 1.0) && zoomIn))
|
||||
{
|
||||
factor = 0.5;
|
||||
}
|
||||
|
||||
m_range = m_range - direction * factor;
|
||||
m_range = qMin(90.0, qMax(0.5, m_range));
|
||||
ui->cb_RadarRange->setCurrentText(QString::number(m_range) + " nm");
|
||||
fitInView();
|
||||
}
|
||||
|
||||
void CRadarComponent::changeRangeFromUserSelection(int index)
|
||||
{
|
||||
double range = ui->cb_RadarRange->itemData(index).toDouble();
|
||||
if (! qFuzzyCompare(m_range, range))
|
||||
{
|
||||
m_range = range;
|
||||
fitInView();
|
||||
}
|
||||
}
|
||||
|
||||
void CRadarComponent::onInfoAreaTabBarChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
// ignore in those cases
|
||||
if (!this->isVisibleWidget()) return;
|
||||
if (this->isParentDockWidgetFloating()) return;
|
||||
if (!sGui->getIContextNetwork()->isConnected()) return;
|
||||
|
||||
// here I know I am the selected widget, update, but keep GUI responsive (hence I use a timer)
|
||||
QPointer<CRadarComponent> myself(this);
|
||||
QTimer::singleShot(1000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
myself->refreshTargets();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
79
src/blackgui/components/radarcomponent.h
Normal file
79
src/blackgui/components/radarcomponent.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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_RADARCOMPONENT_H
|
||||
#define BLACKGUI_RADARCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsItemGroup>
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Ui { class CRadarComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! GUI displaying a radar like view with aircrafts nearby
|
||||
class BLACKGUI_EXPORT CRadarComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CRadarComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CRadarComponent() override;
|
||||
|
||||
//! \copydoc CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea
|
||||
virtual bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget) override;
|
||||
|
||||
private:
|
||||
void prepareScene();
|
||||
void addCenter();
|
||||
void addGraticules();
|
||||
void addRadials();
|
||||
|
||||
void refreshTargets();
|
||||
|
||||
void toggleGrid(bool checked);
|
||||
|
||||
void fitInView();
|
||||
void changeRangeInSteps(bool zoomIn);
|
||||
void changeRangeFromUserSelection(int index);
|
||||
|
||||
//! Info area tab bar has changed
|
||||
void onInfoAreaTabBarChanged(int index);
|
||||
|
||||
QScopedPointer<Ui::CRadarComponent> ui;
|
||||
QGraphicsScene m_scene;
|
||||
QGraphicsItemGroup m_radarTargets;
|
||||
QGraphicsItemGroup m_center;
|
||||
QGraphicsItemGroup m_macroGraticule;
|
||||
QGraphicsItemGroup m_microGraticule;
|
||||
QGraphicsItemGroup m_radials;
|
||||
|
||||
QPen m_radarTargetPen = { Qt::green, 1 };
|
||||
|
||||
qreal m_range = 10.0;
|
||||
|
||||
QTimer m_updateTimer;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
142
src/blackgui/components/radarcomponent.ui
Normal file
142
src/blackgui/components/radarcomponent.ui
Normal file
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CRadarComponent</class>
|
||||
<widget class="QFrame" name="CRadarComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>305</width>
|
||||
<height>414</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Log component</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CRadarView" name="gv_RadarView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cb_Callsign">
|
||||
<property name="text">
|
||||
<string>Callsign</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_Heading">
|
||||
<property name="text">
|
||||
<string>Heading Bug</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_Altitude">
|
||||
<property name="text">
|
||||
<string>Altitude (FL)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_Grid">
|
||||
<property name="text">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Range</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QComboBox" name="cb_RadarRange"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_GroundSpeed">
|
||||
<property name="text">
|
||||
<string>GroundSpeed</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CRadarView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>blackgui/views/radarview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
48
src/blackgui/views/radarview.cpp
Normal file
48
src/blackgui/views/radarview.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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 "radarview.h"
|
||||
|
||||
#include <QResizeEvent>
|
||||
#include <QWheelEvent>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CRadarView::CRadarView(QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setBackgroundBrush(Qt::black);
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
}
|
||||
|
||||
void CRadarView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
emit radarViewResized();
|
||||
QGraphicsView::resizeEvent(event);
|
||||
}
|
||||
|
||||
void CRadarView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
QPoint delta = event->angleDelta();
|
||||
if (delta.y() > 0)
|
||||
{
|
||||
emit zoomEvent(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit zoomEvent(false);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/blackgui/views/radarview.h
Normal file
50
src/blackgui/views/radarview.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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_RADARVIEW_H
|
||||
#define BLACKGUI_RADARVIEW_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include <QGraphicsView>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Radar view
|
||||
class BLACKGUI_EXPORT CRadarView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CRadarView(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
//! Signal emitted when the view is resized
|
||||
void radarViewResized();
|
||||
|
||||
//! Signal emitted when the user zoomed in our out
|
||||
void zoomEvent(bool zoomIn);
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
//! \copydoc QWidget::resizeEvent
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
//! \copydoc QWidget::wheelEvent
|
||||
virtual void wheelEvent(QWheelEvent *event) override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -416,6 +416,7 @@
|
||||
<file>icons/diagona/icons/folders.png</file>
|
||||
<file>icons/diagona/icons/blue-folder-search-result.png</file>
|
||||
<file>icons/diagona/icons/folder-search-result.png</file>
|
||||
<file>icons/diagona/icons/building.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/own">
|
||||
<file>icons/own/app.jpg</file>
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace BlackMisc
|
||||
CIcon(CIcons::ApplicationSimulator, "simulator"),
|
||||
CIcon(CIcons::ApplicationTextMessages, "text messages"),
|
||||
CIcon(CIcons::ApplicationWeather, "weather"),
|
||||
CIcon(CIcons::ApplicationRadar, "radar"),
|
||||
CIcon(CIcons::AviationAtis, "ATIS"),
|
||||
CIcon(CIcons::AviationAttitudeIndicator, "attitude indicator"),
|
||||
CIcon(CIcons::AviationMetar, "METAR"),
|
||||
@@ -190,6 +191,7 @@ namespace BlackMisc
|
||||
CIcon(CIcons::StandardIconWarning16, "warning"),
|
||||
CIcon(CIcons::StandardIconWeatherCloudy16, "cloudy"),
|
||||
CIcon(CIcons::StandardIconWrench16, "wrench"),
|
||||
CIcon(CIcons::StandardIconBuilding16, "building"),
|
||||
CIcon(CIcons::Swift16, "swift"),
|
||||
CIcon(CIcons::Swift24, "swift"),
|
||||
CIcon(CIcons::Swift48, "swift"),
|
||||
|
||||
@@ -413,6 +413,12 @@ namespace BlackMisc
|
||||
return pm;
|
||||
}
|
||||
|
||||
const QPixmap &CIcons::building16()
|
||||
{
|
||||
static const QPixmap pm(":/diagona/icons/diagona/icons/building.png");
|
||||
return pm;
|
||||
}
|
||||
|
||||
const QPixmap &CIcons::filter16()
|
||||
{
|
||||
return tableSheet16();
|
||||
@@ -820,7 +826,7 @@ namespace BlackMisc
|
||||
|
||||
const QPixmap &CIcons::appAtc16()
|
||||
{
|
||||
return radar16();
|
||||
return building16();
|
||||
}
|
||||
|
||||
const QPixmap &CIcons::appAircraft16()
|
||||
@@ -893,6 +899,11 @@ namespace BlackMisc
|
||||
return databaseAdd16();
|
||||
}
|
||||
|
||||
const QPixmap &CIcons::appRadar16()
|
||||
{
|
||||
return radar16();
|
||||
}
|
||||
|
||||
const QPixmap &CIcons::roleC1()
|
||||
{
|
||||
static const QPixmap pm(":/vatsim/icons/vatsim/C1.png");
|
||||
@@ -1126,6 +1137,7 @@ namespace BlackMisc
|
||||
case ApplicationSimulator: return appSimulator16();
|
||||
case ApplicationTextMessages: return appTextMessages16();
|
||||
case ApplicationWeather: return appWeather16();
|
||||
case ApplicationRadar: return appRadar16();
|
||||
case AviationAtis: return atis();
|
||||
case AviationAttitudeIndicator: return attitudeIndicator16();
|
||||
case AviationMetar: return metar();
|
||||
@@ -1254,6 +1266,7 @@ namespace BlackMisc
|
||||
case StandardIconWarning16: return warning16();
|
||||
case StandardIconWeatherCloudy16: return weatherCloudy16();
|
||||
case StandardIconWrench16: return wrench16();
|
||||
case StandardIconBuilding16: return building16();
|
||||
case Swift1024: return swift1024();
|
||||
case Swift128: return swift128();
|
||||
case Swift16: return swift16();
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace BlackMisc
|
||||
ApplicationSimulator,
|
||||
ApplicationTextMessages,
|
||||
ApplicationWeather,
|
||||
ApplicationRadar,
|
||||
AviationAtis,
|
||||
AviationAttitudeIndicator,
|
||||
AviationMetar,
|
||||
@@ -185,6 +186,7 @@ namespace BlackMisc
|
||||
StandardIconWarning16,
|
||||
StandardIconWeatherCloudy16,
|
||||
StandardIconWrench16,
|
||||
StandardIconBuilding16,
|
||||
Swift16,
|
||||
Swift24,
|
||||
Swift48,
|
||||
@@ -426,6 +428,9 @@ namespace BlackMisc
|
||||
//! Cut
|
||||
static const QPixmap &cut16();
|
||||
|
||||
//! Building
|
||||
static const QPixmap &building16();
|
||||
|
||||
// --------------------------------------------------
|
||||
// -- Database
|
||||
// --------------------------------------------------
|
||||
@@ -626,6 +631,9 @@ namespace BlackMisc
|
||||
//! Stash
|
||||
static const QPixmap &appDbStash16();
|
||||
|
||||
//! Radar
|
||||
static const QPixmap &appRadar16();
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Network and aviation
|
||||
// -------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user