146 lines
4.5 KiB
C++
Executable File
146 lines
4.5 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* The MountingPoint class wraps all information from InfrastructureManagement which defines a mounting point
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hannes Baeuerle, SLSE, 2017-01-16
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Plugins/InfrastructureManagement/Shared/ismshared_export.h>
|
|
#include <Services/InfrastructureManagement/ism.hpp>
|
|
#include <QImage>
|
|
|
|
|
|
namespace dds
|
|
{
|
|
namespace core
|
|
{
|
|
static inline uint qHash(const InfrastructureManagement::MountingPointType &mpt)
|
|
{
|
|
return ::qHash(mpt.underlying());
|
|
}
|
|
} // namespace core
|
|
} // namespace dds
|
|
|
|
namespace InfrastructureManagement
|
|
{
|
|
|
|
class ISMSHARED_EXPORT MountingPoint
|
|
{
|
|
public:
|
|
explicit MountingPoint();
|
|
explicit MountingPoint(const StructureElement &data, int floorId);
|
|
static void init();
|
|
|
|
const StructureElement &data() const { return m_data; }
|
|
void updateData(const StructureElement &data, int floorId) { m_data = data; m_floor = floorId; }
|
|
int32_t id() const { return m_data.id(); }
|
|
int32_t associatedAssetId() const { return m_associatedAssetId; }
|
|
bool hasAssociatedAsset() const { return m_associatedAssetId > 0; }
|
|
bool hasAssociatedAssetDefect() const { return m_hasAssociatedAssetDefect; }
|
|
|
|
/*! \name aimState depends on the (loaded) plan/schedule!!! */
|
|
//@{
|
|
|
|
//! \brief aimState of currently loaded schedule!!!
|
|
//! \return aimState
|
|
MountingPointState aimState() const { return m_aimState; }
|
|
void setAimState(const MountingPointState &mps) { m_aimState = mps;}
|
|
|
|
//@}
|
|
|
|
bool isValid() const { return m_isValid; }
|
|
Core::GeoPosition geoPosition() const { return m_data.geoPosition(); }
|
|
Core::RelativePosition relPosition() const { return m_data.relPosition(); }
|
|
MountingPointType type() const { return m_data.mountingPointTypeId(); }
|
|
int32_t buildingId() const { return m_data.mainStructureElementId(); }
|
|
QString name() const;
|
|
QString fileName() const;
|
|
QByteArray properties() const { return m_data.properties().c_str(); }
|
|
|
|
QImage toImage(int32_t edgeLength = 100) const;
|
|
bool writeFile(int32_t edgeLength = 25) const;
|
|
int floor() const { return m_floor; }
|
|
void setFloor(int floor) { m_floor = floor; }
|
|
|
|
void setAssociatedAssetId(int32_t id);
|
|
void setHasAssociatedAssetDefect(bool hasAssociatedAssetDefect);
|
|
MountingPointState getNextMountingPointState(const MountingPointState currState);
|
|
|
|
private: // methods
|
|
|
|
private: // attributes
|
|
StructureElement m_data;
|
|
int32_t m_associatedAssetId;
|
|
MountingPointState m_aimState;
|
|
bool m_hasAssociatedAssetDefect;
|
|
bool m_isValid;
|
|
int m_floor;
|
|
|
|
public:
|
|
|
|
enum class MpColor
|
|
{
|
|
GRAY,
|
|
BLUE,
|
|
RED,
|
|
GREEN,
|
|
ORANGE
|
|
};
|
|
static QString mpColorToString(MpColor mpColor);
|
|
static QString mpColorToPostfix(MpColor mpColor);
|
|
|
|
struct NameImagePair
|
|
{
|
|
NameImagePair(const QString &name = QString(),
|
|
const QImage &img = QImage())
|
|
: m_name(name), m_img(img)
|
|
{}
|
|
QString m_name; // like announcement_BLUE
|
|
QImage m_img;
|
|
};
|
|
struct MpNameImageData
|
|
{
|
|
NameImagePair nipGray;
|
|
NameImagePair nipBlue;
|
|
NameImagePair nipRed;
|
|
NameImagePair nipGreen;
|
|
NameImagePair nipOrange;
|
|
};
|
|
|
|
//
|
|
// Some methods regarding ImageTable:
|
|
//
|
|
static QMap<MountingPointType_def::type, MpNameImageData> &getImageTable(); // contains images in good quality (100*100px)
|
|
|
|
static bool getImageAttributePlanActivity(const MountingPoint& mp,
|
|
QImage &imgOut, QString &attribNameOut);
|
|
static bool getImageAttributePlanDefinition(const MountingPoint& mp,
|
|
QImage &imgOut, QString &attribNameOut);
|
|
|
|
static bool getImageAttribute(const MountingPoint& mp, MpColor mpColor,
|
|
QImage &img, QString &attribName);
|
|
|
|
private:
|
|
static QMap<MountingPointType_def::type, MpNameImageData> &getImageTableInternal();
|
|
static void insertHelper(MountingPointType_def::type type,
|
|
const QString &name,
|
|
const QString &colorCodeGray,
|
|
const QString &colorCodeGreen,
|
|
const QString &colorCodeRed,
|
|
const QString &colorCodeOrange,
|
|
const QString &defName = QString());
|
|
|
|
static QImage getImage(const MountingPoint &mp);
|
|
|
|
static const MpNameImageData *getNameImageData(const MountingPoint&mp);
|
|
static const NameImagePair *getNameImagePair(const MountingPoint&mp);
|
|
|
|
|
|
}; // class MountingPoint
|
|
|
|
} // namespace InfrastructureManagement
|