First version of CRadarComponent

This commit is contained in:
Roland Rossgotterer
2019-01-30 09:45:16 +01:00
committed by Mat Sutcliffe
parent e0d04e7b92
commit 4273eb4260
14 changed files with 706 additions and 7 deletions

View 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();
}
}
}

View 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