Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - PixmapLabel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schroeder, NLSE, 2018-05-09
|
||||
*/
|
||||
|
||||
#include "aes_pixmap_label.h"
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
PixmapLabel::PixmapLabel(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
, m_pixmap()
|
||||
{
|
||||
setMinimumSize(1, 1);
|
||||
setScaledContents(false);
|
||||
}
|
||||
|
||||
int PixmapLabel::heightForWidth(int width) const
|
||||
{
|
||||
return m_pixmap.isNull() ? this->height() : qRound(double(m_pixmap.height() * width)) / m_pixmap.width();
|
||||
}
|
||||
|
||||
QSize PixmapLabel::sizeHint() const
|
||||
{
|
||||
int w = this->width();
|
||||
return QSize(w, heightForWidth(w));
|
||||
}
|
||||
|
||||
QPixmap PixmapLabel::scaledPixmap(const QSize &size, const Qt::AspectRatioMode &aspectRatioMode, const Qt::TransformationMode &transformationMode) const
|
||||
{
|
||||
return m_pixmap.scaled(size, aspectRatioMode, transformationMode);
|
||||
}
|
||||
|
||||
Qt::BrushStyle PixmapLabel::checkForBrushStyle(const AesEffectState &state)
|
||||
{
|
||||
switch(state.underlying()) // Todo: change to correct BrushStyle?
|
||||
{
|
||||
case AesEffectState_def::EsUnknown:
|
||||
return Qt::BrushStyle::NoBrush;
|
||||
case AesEffectState_def::EsPrepared:
|
||||
case AesEffectState_def::EsFired:
|
||||
return Qt::BrushStyle::BDiagPattern;
|
||||
case AesEffectState_def::EsCreated:
|
||||
case AesEffectState_def::EsReceived:
|
||||
return Qt::BrushStyle::VerPattern;
|
||||
case AesEffectState_def::EsActivated:
|
||||
return Qt::BrushStyle::CrossPattern;
|
||||
case AesEffectState_def::EsRemoved:
|
||||
return Qt::BrushStyle::NoBrush;
|
||||
case AesEffectState_def::EsPaused:
|
||||
case AesEffectState_def::EsExpired:
|
||||
case AesEffectState_def::EsError:
|
||||
return Qt::BrushStyle::SolidPattern;
|
||||
}
|
||||
return Qt::BrushStyle::NoBrush;
|
||||
}
|
||||
|
||||
void PixmapLabel::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
QLabel::setPixmap(scaledPixmap(this->size()));
|
||||
}
|
||||
|
||||
void PixmapLabel::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QLabel::resizeEvent(e);
|
||||
|
||||
if(m_pixmap.isNull())
|
||||
return;
|
||||
QLabel::setPixmap(scaledPixmap(this->size()));
|
||||
}
|
||||
|
||||
QPolygonF PixmapLabel::geographic2Utm(const QPolygonF &poly)
|
||||
{
|
||||
if(poly.isEmpty())
|
||||
return QPolygonF();
|
||||
|
||||
QPolygonF polyOut;
|
||||
polyOut.reserve(poly.size());
|
||||
LtsCoordTrans::UtmCoordinate utmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(poly.at(0));
|
||||
for(const QPointF &p : poly)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate coord = LtsCoordTrans::UtmCoordinate::fromGeographic(p.x(), p.y(), utmPos.zone);
|
||||
polyOut.append(QPointF(coord.x, coord.y));
|
||||
}
|
||||
return polyOut;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user