78 lines
2.4 KiB
C++
Executable File
78 lines
2.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* CustomView for AES NContamination
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Mike Wille, SLSE, 2016-04-08
|
|
*/
|
|
|
|
#include "aes_danger_area.h"
|
|
#include "ui_aes_danger_area.h"
|
|
|
|
#include "aes_danger_areas_model.h"
|
|
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
CustomViewDangerArea::CustomViewDangerArea(QWidget *parent)
|
|
: AbstractDisplayWidget(parent)
|
|
, m_ui(new Ui::CustomViewDangerArea)
|
|
{
|
|
m_ui->setupUi(this);
|
|
}
|
|
|
|
CustomViewDangerArea::~CustomViewDangerArea()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
bool CustomViewDangerArea::init(const QModelIndex &idx)
|
|
{
|
|
if (!idx.isValid())
|
|
return false;
|
|
|
|
m_ui->lblIdentifier->setText(rowData(idx, AreaEffectSimulation::DangerAreasModel::BcName).toString());
|
|
m_ui->lblEffectState->setText(rowData(idx, AreaEffectSimulation::DangerAreasModel::BcEffectState).toString());
|
|
m_ui->lblEffectStart->setText(rowData(idx, AreaEffectSimulation::DangerAreasModel::BcEffectStart).toString());
|
|
m_ui->lblIcon->clear();
|
|
m_ui->lblIcon->setAutoFillBackground(true);
|
|
|
|
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel*>(idx.model());
|
|
if (!sfpm)
|
|
return false;
|
|
const DangerAreasModel *aesModel = qobject_cast<const DangerAreasModel*>(sfpm->sourceModel());
|
|
if (!aesModel)
|
|
return false;
|
|
const auto srcIdx = sfpm->mapToSource(idx);
|
|
DangerArea dangerArea = aesModel->getRowData(srcIdx.row());
|
|
calculateIcon(dangerArea, sfpm->partyColor(idx.row()));
|
|
return true;
|
|
}
|
|
|
|
bool CustomViewDangerArea::calculateIcon(const AreaEffectSimulation::DangerArea &area, const QColor &color)
|
|
{
|
|
if (area.segments().size() == 0)
|
|
return false;
|
|
|
|
QVector<QPointF> segments;
|
|
segments.reserve(area.segments().size());
|
|
int setZone = -1;
|
|
for (const Core::GeoPosition2D &s : area.segments())
|
|
{
|
|
const LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(s.lon(), s.lat(), setZone));
|
|
if (setZone < 0)
|
|
setZone = coord.zone;
|
|
segments.append(QPointF(coord.x, coord.y));
|
|
}
|
|
|
|
QPolygonF poly = AreaEffectSimulation::Polygons::dangerArea(segments);
|
|
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(area.effectStateId());
|
|
const auto pix = Polygons::pixmapFromPolygon(poly, color, ICON_RESOLUTION, bStyle);
|
|
m_ui->lblIcon->setPixmap(pix);
|
|
|
|
return true;
|
|
}
|
|
} // namespace AreaEffectSimulation
|