Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for Technical Area
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLEA, 2017-06-09
|
||||
*/
|
||||
|
||||
#include "aes_technical_area.h"
|
||||
#include "ui_aes_technical_area.h"
|
||||
|
||||
#include "aes_technical_areas_model.h"
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewTechnicalArea::CustomViewTechnicalArea(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewTechnicalArea)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewTechnicalArea::~CustomViewTechnicalArea()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewTechnicalArea::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::TechnicalAreasModel::BcName).toString());
|
||||
m_ui->lbType->setText(rowData(idx, AreaEffectSimulation::TechnicalAreasModel::BcChargeType).toString());
|
||||
m_ui->lbState->setText(rowData(idx, AreaEffectSimulation::TechnicalAreasModel::BcEffectState).toString());
|
||||
m_ui->lbTime->setText(rowData(idx, AreaEffectSimulation::TechnicalAreasModel::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 TechnicalAreasModel *aesModel = qobject_cast<const TechnicalAreasModel*>(sfpm->sourceModel());
|
||||
if (!aesModel)
|
||||
return false;
|
||||
const auto srcIdx = sfpm->mapToSource(idx);
|
||||
TechnicalArea tecArea = aesModel->getRowData(srcIdx.row());
|
||||
calculateIcon(tecArea, sfpm->partyColor(idx.row()));
|
||||
|
||||
qint64 durationMSecs = rowData(idx, AreaEffectSimulation::TechnicalAreasModel::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 CustomViewTechnicalArea::calculateIcon(const AreaEffectSimulation::TechnicalArea &tecArea, const QColor &color)
|
||||
{
|
||||
Database::AesTechnicalArea tecOut;
|
||||
tecOut.position = QPointF(tecArea.area().cornerBottomLeft().lon(),
|
||||
tecArea.area().cornerBottomLeft().lat());
|
||||
tecOut.width = tecArea.area().width();
|
||||
tecOut.length = tecArea.area().height();
|
||||
|
||||
QPolygonF poly = AreaEffectSimulation::Polygons::technicalArea(tecOut);
|
||||
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(tecArea.effectStateId());
|
||||
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
|
||||
m_ui->lblIcon->setPixmap(pix);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user