Files
pilotclient/src/blackgui/components/radarcomponent.h
2019-02-22 20:35:49 +00:00

80 lines
2.3 KiB
C++

/* 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