swift
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 
20 namespace Ui
21 {
22  class CRadarComponent;
23 }
24 namespace swift::gui::components
25 {
28  {
29  Q_OBJECT
30 
31  public:
33  explicit CRadarComponent(QWidget *parent = nullptr);
34 
36  virtual ~CRadarComponent() override;
37 
39  virtual 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 
62  QScopedPointer<Ui::CRadarComponent> ui;
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) { changeRangeInSteps(true); }
87  }
88  void rangeZoomOut(bool keydown)
89  {
90  if (keydown) { changeRangeInSteps(false); }
91  }
92  };
93 } // namespace swift::gui::components
94 
95 #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.
Helper class: If a component is residing in an dockable widget. This class provides access to its inf...
GUI displaying a radar like view with aircrafts nearby.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.