swift
Loading...
Searching...
No Matches
radarcomponent.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_GUI_COMPONENTS_RADARCOMPONENT_H
7#define SWIFT_GUI_COMPONENTS_RADARCOMPONENT_H
8
9#include <QFrame>
10#include <QGraphicsItemGroup>
11#include <QGraphicsScene>
12#include <QScopedPointer>
13#include <QTimer>
14
15#include "core/actionbind.h"
17#include "gui/swiftguiexport.h"
19
20namespace Ui
21{
22 class CRadarComponent;
23}
25{
28 {
30
31 public:
33 explicit CRadarComponent(QWidget *parent = nullptr);
34
36 ~CRadarComponent() override;
37
39 bool setParentDockWidgetInfoArea(swift::gui::CDockWidgetInfoArea *parentDockableWidget) override;
40
41 private:
42 void prepareScene();
43 void addCenter();
44 void addGraticules();
45 void addRadials();
46
47 void refreshTargets();
48 void rotateView();
49
50 void toggleGrid(bool checked);
51
52 void fitInView();
53 void changeRangeInSteps(bool zoomIn);
54 void changeRangeFromUserSelection(int index);
55 void updateFont(int pointSize);
56
57 static QPointF polarPoint(double distance, double angleRadians);
58
60 void onInfoAreaTabBarChanged(int index);
61
63 QGraphicsScene m_scene;
64 QGraphicsItemGroup m_radarTargets;
65 QGraphicsItemGroup m_center;
66 QGraphicsItemGroup m_macroGraticule;
67 QGraphicsItemGroup m_microGraticule;
68 QGraphicsItemGroup m_radials;
69
70 QPen m_radarTargetPen = { Qt::green, 1 };
71 qreal m_rangeNM = 10.0;
72 int m_rotatenAngle = 0;
73 QTimer m_updateTimer;
74 QTimer m_headingTimer;
75
76 QFont m_tagFont;
77
78 swift::core::CActionBind m_actionZoomIn { swift::misc::input::radarZoomInHotkeyAction(),
79 swift::misc::input::radarZoomInHotkeyIcon(), this,
80 &CRadarComponent::rangeZoomIn };
81 swift::core::CActionBind m_actionZoomOut { swift::misc::input::radarZoomOutHotkeyAction(),
82 swift::misc::input::radarZoomOutHotkeyIcon(), this,
83 &CRadarComponent::rangeZoomOut };
84 void rangeZoomIn(bool keydown)
85 {
86 if (keydown)
87 {
88 changeRangeInSteps(true);
89 }
90 }
91 void rangeZoomOut(bool keydown)
92 {
93 if (keydown)
94 {
95 changeRangeInSteps(false);
96 }
97 }
98 };
99} // namespace swift::gui::components
100
101#endif // SWIFT_GUI_COMPONENTS_RADARCOMPONENT_H
CActionBind binds a member function to an action.
Definition actionbind.h:18
Specialized class for dock widgets serving as info area.
CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea=nullptr)
Constructor.
CRadarComponent(QWidget *parent=nullptr)
Constructor.
bool setParentDockWidgetInfoArea(swift::gui::CDockWidgetInfoArea *parentDockableWidget)
Corresponding dockable widget in info area.
High level reusable GUI components.
QFrame(QWidget *parent, Qt::WindowFlags f)
Q_OBJECTQ_OBJECT
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)
#define SWIFT_GUI_EXPORT
Export a class or function from the library.