88 lines
2.9 KiB
C++
Executable File
88 lines
2.9 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* CustomView for Functional Area
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Malte Diers, SLSE, 2017-04-06
|
|
*/
|
|
|
|
#include "aes_functional_area.h"
|
|
#include "ui_aes_functional_area.h"
|
|
|
|
#include "aes_functional_areas_model.h"
|
|
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
|
#include <LtsUtilsSettings/settings.h>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
CustomViewFunctionalArea::CustomViewFunctionalArea(QWidget *parent)
|
|
: AbstractDisplayWidget(parent)
|
|
, m_ui(new Ui::CustomViewFunctionalArea)
|
|
{
|
|
m_ui->setupUi(this);
|
|
}
|
|
|
|
CustomViewFunctionalArea::~CustomViewFunctionalArea()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
bool CustomViewFunctionalArea::init(const QModelIndex &idx)
|
|
{
|
|
if (!idx.isValid())
|
|
return false;
|
|
|
|
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::BcName).toString());
|
|
m_ui->lbType->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::ColType).toString());
|
|
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
|
QStringLiteral("HasPvSan"));
|
|
if (!showPvSan)
|
|
m_ui->lbType->hide();
|
|
|
|
m_ui->lbState->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::BcEffectState).toString());
|
|
m_ui->lbTime->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::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 FunctionalAreasModel *aesModel = qobject_cast<const FunctionalAreasModel*>(sfpm->sourceModel());
|
|
if (!aesModel)
|
|
return false;
|
|
const auto srcIdx = sfpm->mapToSource(idx);
|
|
FunctionalArea funcArea = aesModel->getRowData(srcIdx.row());
|
|
calculateIcon(funcArea, sfpm->partyColor(idx.row()));
|
|
|
|
qint64 durationMSecs = rowData(idx, AreaEffectSimulation::FunctionalAreasModel::BcEffectDuration).toInt();
|
|
if (durationMSecs > 0)
|
|
{
|
|
m_ui->lbDuration->setText(QString::number(durationMSecs / (1000 * 60), 'f', 0));
|
|
}
|
|
else
|
|
{
|
|
m_ui->label_4->hide();
|
|
m_ui->lbDuration->hide();
|
|
m_ui->label_6->hide();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool CustomViewFunctionalArea::calculateIcon(const FunctionalArea &funcArea, const QColor &color)
|
|
{
|
|
Database::AesFunctionalArea funcOut;
|
|
funcOut.width = funcArea.area().width();
|
|
funcOut.length = funcArea.area().height();
|
|
funcOut.position = QPointF(funcArea.area().cornerBottomLeft().lon(),
|
|
funcArea.area().cornerBottomLeft().lat());
|
|
|
|
QPolygonF poly = AreaEffectSimulation::Polygons::functionalArea(funcOut);
|
|
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(funcArea.effectStateId());
|
|
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
|
|
m_ui->lblIcon->setPixmap(pix);
|
|
|
|
return true;
|
|
}
|
|
} // namespace AreaEffectSimulation
|