84 lines
2.9 KiB
C++
Executable File
84 lines
2.9 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* CustomView for AES MineArea
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2016-09-26
|
|
*/
|
|
|
|
#include "aes_mine_area.h"
|
|
#include "ui_aes_mine_area.h"
|
|
|
|
#include "aes_mine_areas_model.h"
|
|
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
CustomViewMineArea::CustomViewMineArea(QWidget *parent)
|
|
: AbstractDisplayWidget(parent)
|
|
, m_ui(new Ui::CustomViewMineArea)
|
|
{
|
|
m_ui->setupUi(this);
|
|
}
|
|
|
|
CustomViewMineArea::~CustomViewMineArea()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
bool CustomViewMineArea::init(const QModelIndex &idx)
|
|
{
|
|
if (!idx.isValid())
|
|
return false;
|
|
|
|
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcName).toString());
|
|
m_ui->lbChargeType->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcChargeType).toString());
|
|
m_ui->lbParty->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcParty).toString());
|
|
m_ui->lbWidth->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::ColWidth).toString());
|
|
m_ui->lbEffectStart->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcEffectStart).toString());
|
|
m_ui->lbEffectDuration->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcEffectDuration).toString());
|
|
m_ui->lbEffectState->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcEffectState).toString());
|
|
m_ui->lblIcon->clear();
|
|
m_ui->lblIcon->setAutoFillBackground(true);
|
|
|
|
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel *>(idx.model());
|
|
if (!sfpm)
|
|
return false;
|
|
const MineAreasModel *aesModel = qobject_cast<const MineAreasModel *>(sfpm->sourceModel());
|
|
if (!aesModel)
|
|
return false;
|
|
const auto srcIdx = sfpm->mapToSource(idx);
|
|
MineArea mineArea = aesModel->getRowData(srcIdx.row());
|
|
calculateIcon(mineArea, sfpm->partyColor(idx.row()));
|
|
return true;
|
|
}
|
|
|
|
bool CustomViewMineArea::calculateIcon(const MineArea &area, const QColor &color)
|
|
{
|
|
if (area.segments().size() == 0)
|
|
return false;
|
|
|
|
QVector<Database::AesMineAreaSegment> segments;
|
|
segments.reserve(area.segments().size());
|
|
for (AreaEffectSimulation::MineSegment segmentIn : area.segments())
|
|
{
|
|
Database::AesMineAreaSegment segmentOut;
|
|
segmentOut.startPosition = QPointF(segmentIn.positionStart().lon(),
|
|
segmentIn.positionStart().lat());
|
|
segmentOut.endPosition = QPointF(segmentIn.positionEnd().lon(),
|
|
segmentIn.positionEnd().lat());
|
|
segments.append(segmentOut);
|
|
}
|
|
|
|
QPolygonF poly = AreaEffectSimulation::Polygons::mineArea(segments, area.width(), area.density(), area.isCenterLine());
|
|
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(area.effectStateId());
|
|
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
|
|
m_ui->lblIcon->setPixmap(pix);
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace AreaEffectSimulation
|