mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
First version of CRadarComponent
This commit is contained in:
committed by
Mat Sutcliffe
parent
e0d04e7b92
commit
4273eb4260
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
|
||||
Reference in New Issue
Block a user