#ifndef GRAPHICSBUSSECTIONITEM_H
#define GRAPHICSBUSSECTIONITEM_H

#include <QObject>
#include <qvectornd.h>
#include <QFile>
#include <QDir>
#include <QColor>
#include <QMatrix4x4>

#include "CommonInclude.h"
#include "propertyType/CustomType.h"
#include "propertyType/CustomGadget.h"

#include "graphicsItem/graphicsBaseItem.h"

class GraphicsBusSectionItem : public GraphicsBaseItem
{
    Q_OBJECT
		Q_CLASSINFO("LimitedDouble", "Min=0,Max=10")
    
public:
    explicit GraphicsBusSectionItem(const QRect &rect, QGraphicsItem *parent = nullptr);
    virtual ~GraphicsBusSectionItem();

    void resize(int, double, double, const QPointF&) override;
    void updateCoordinate() override;
    void move(const QPointF&) override;
    void editShape(int, const QPointF&) override;

public:
	enum QCustomEnum {
		One,
		Two,
		Three
	};
	Q_ENUM(QCustomEnum);

public:
    Q_PROPERTY_VAR(int, Int) = 0;
	Q_PROPERTY_VAR(float, Float) = 1.23f;
	Q_PROPERTY_VAR(double, LimitedDouble) = 5;
	Q_PROPERTY_VAR(QString, String);
    Q_PROPERTY_VAR(QDir, Directory) = QDir(".");
	Q_PROPERTY_VAR(QVector2D, Vec2) = QVector2D(1, 2);
	Q_PROPERTY_VAR(QVector3D, Vec3) = QVector3D(1, 2, 3);
	Q_PROPERTY_VAR(QVector4D, Vec4) = QVector4D(1, 2, 3, 4);
	Q_PROPERTY_VAR(QMatrix4x4, Mat4);
	Q_PROPERTY_VAR(QColor, Color);
	Q_PROPERTY_VAR(QList<QColor>, ColorList) = { Qt::red,Qt::green,Qt::blue };

	typedef QMap<QString, QColor> StringColorMap;
	Q_PROPERTY_VAR(StringColorMap, ColorMap) = { {"Red",Qt::red},{"Green",Qt::green},{"Blue",Qt::blue} };

	Q_PROPERTY_VAR(QCustomEnum, CustomEnum) = QCustomEnum::One;
	Q_PROPERTY_VAR(QCustomType, CustomType);
	Q_PROPERTY_VAR(QCustomGadget, CustomGadget);
	Q_PROPERTY_VAR(QCustomGadget*, CustomGadgetPtr) = new QCustomGadget;
	Q_PROPERTY_VAR(QSharedPointer<QCustomGadget>, CustomGadgetSharedPtr) = QSharedPointer<QCustomGadget>::create();

protected:
    virtual QPainterPath shape() override;
    virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;

private:
    virtual void updateHandles() override;

    QRectF m_lastBoudingRect;
	Q_PROPERTY_VAR(QRectF,  m_lastBoudingRectF);
	Q_PROPERTY_VAR(QPointF, m_lastBoudingPointF);
	Q_PROPERTY_VAR(double, m_dRatioX);
	Q_PROPERTY_VAR(double, m_dRatioY);
    // double m_dRatioX;
    // double m_dRatioY;
};

#endif // GRAPHICSBUSSECTIONITEM_H
