84 lines
2.7 KiB
C++
Executable File
84 lines
2.7 KiB
C++
Executable File
#pragma once
|
|
|
|
#include "tln_utils.h"
|
|
|
|
#include <LtsTimeline/item.h>
|
|
#include <LtsUtilsCore/qpoint3d.h>
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
|
class QPainter;
|
|
class QStyleOptionViewItem;
|
|
class QModelIndex;
|
|
class QFormLayout;
|
|
|
|
|
|
namespace Timeline
|
|
{
|
|
|
|
class AbstractEventFactory;
|
|
|
|
|
|
class AbstractEventItem : public LtsTimeline::Item
|
|
{
|
|
|
|
public:
|
|
static int s_defaultWidth;
|
|
static int s_defaultHeight;
|
|
|
|
explicit AbstractEventItem(AbstractEventFactory *factory,
|
|
qint64 startTime, int duration, const QJsonObject &properties,
|
|
const QColor &color = Qt::black, EventType type = EventType::Unknown, const LtsUtils::QPoint3D &position = LtsUtils::QPoint3D(0.0,0.0,0.0)
|
|
);
|
|
|
|
const QJsonObject &properties() const { return m_properties; }
|
|
void setProperties(const QJsonObject &properties) { m_properties = properties; }
|
|
|
|
bool isPositionValid() const { return !std::isnan(m_position.x()) && !std::isnan(m_position.y()); }
|
|
const LtsUtils::QPoint3D &position() const { return m_position; }
|
|
QPointF position2D() const { return QPointF(m_position.x(), m_position.y()); }
|
|
void setPosition(const LtsUtils::QPoint3D &position) { m_position = position; }
|
|
|
|
int dbId() const { return m_dbId; }
|
|
int markerDbId() const { return m_markerDbId; }
|
|
|
|
EventType type() const { return m_type; }
|
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, bool) const override = 0;
|
|
virtual void addItemInfoRows(QFormLayout *form) = 0;
|
|
|
|
int m_dbId { -1 };
|
|
int m_markerDbId { -1 };
|
|
|
|
protected:
|
|
AbstractEventFactory *m_factory{nullptr};
|
|
LtsUtils::QPoint3D m_position;
|
|
QJsonObject m_properties;
|
|
|
|
private:
|
|
EventType m_type { EventType::Unknown };
|
|
|
|
};
|
|
typedef AbstractEventItem EventItem;
|
|
typedef std::unique_ptr<EventItem> EventItemPtr;
|
|
typedef std::reference_wrapper<EventItem> EventItemRef;
|
|
|
|
typedef std::reference_wrapper<EventItemPtr> EventItemPtrRef;
|
|
typedef std::vector<EventItemPtr> EventItemPtrs;
|
|
typedef std::vector<std::reference_wrapper<EventItemPtr> > EventItemPtrRefs;
|
|
|
|
typedef std::map <int /* tickId */, LtsTimeline::ItemPtrNCVRefs> TickItemPtrNCVRefs;
|
|
typedef std::pair<int /* tickId */, LtsTimeline::ItemPtrNCVRefs> TickItemPtrNCVRefsPair;
|
|
|
|
typedef std::map <int /* trackId */, TickItemPtrNCVRefs> SectorItemPtrNCVRefs; // Sector = Track + Tick (and contains Items)
|
|
typedef std::pair<int /* trackId */, TickItemPtrNCVRefs> SectorItemPtrNCVRefsPair;
|
|
|
|
typedef std::map <int /* tickId */, EventItemPtrs> TickEventItemPtrs;
|
|
typedef std::pair<int /* tickId */, EventItemPtrs> TickEventItemPtrsPair;
|
|
|
|
typedef std::map <int /* trackId */, TickEventItemPtrs> SectorEventItemPtrs; // Sector = Track + Tick (and contains Items)
|
|
typedef std::pair<int /* trackId */, TickEventItemPtrs> SectorEventItemPtrsPair;
|
|
|
|
} // namespace Timeline
|