#ifndef TITAN_PCBCAM_FEATURE_H
#define TITAN_PCBCAM_FEATURE_H
#include "../titanpcbcamglobal.h"
#include <QPointF>
#include <QVariantMap>
#include <QSizeF>
#include <QPainterPath>
#include <QLineF>
#include "./common.h"
#include "./font.h"

class PcbCamSymbol;

class PcbCamFeaturePrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeature
{
public:
    PcbCamFeature();
    virtual ~PcbCamFeature();

    PcbCam::FeatureType type() const;

    PcbCam::Polarity polarity() const;
    void setPolarity(PcbCam::Polarity iPolarity);

    int index() const;
    void setIndex(int iIndex);

    int dcode() const;
    void setDcode(int iDcode);

    void setSymbol(PcbCamSymbol *iSymbol);
    PcbCamSymbol *symbol() const;

    QVariantMap attr() const;
    QVariant attr(const QString &iName) const;
    bool hasAttr(const QString &iName) const;
    void setAttr(const QString &iName, const QVariant &iValue);
    void setAttr(const QVariantMap &iAttrMap);
    void removeAttr(const QString &iName);
    void clearAttr();

    void setSelected(bool iSel = true);
    bool isSelected() const;

    virtual QPainterPath shape() const = 0;
    virtual QRectF boundingRect() const = 0;

protected:
    PcbCamFeature(PcbCamFeaturePrivate &dd);
    const QScopedPointer<PcbCamFeaturePrivate> d_ptr;

private:
    Q_DECLARE_PRIVATE(PcbCamFeature)
    Q_DISABLE_COPY(PcbCamFeature)
};

class PcbCamFeatureLinePrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeatureLine : public PcbCamFeature
{
public:
    PcbCamFeatureLine();
    ~PcbCamFeatureLine();

    void setLine(const QLineF &iLine);
    QLineF line() const;

    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    Q_DECLARE_PRIVATE(PcbCamFeatureLine)
    Q_DISABLE_COPY(PcbCamFeatureLine)
};

class PcbCamFeaturePadPrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeaturePad : public PcbCamFeature
{
public:
    PcbCamFeaturePad();
    ~PcbCamFeaturePad();

    QPointF pos() const;
    void setPos(const QPointF &iPos);

    PcbCam::Orient orient() const;
    void setOrient(PcbCam::Orient iOrient);

    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    Q_DECLARE_PRIVATE(PcbCamFeaturePad)
    Q_DISABLE_COPY(PcbCamFeaturePad)
};

class PcbCamFeatureArcPrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeatureArc : public PcbCamFeature
{
public:
    PcbCamFeatureArc();
    ~PcbCamFeatureArc();

    void setData(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw);
    QPointF ps() const;
    QPointF pe() const;
    QPointF pc() const;
    bool cw() const;

    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    Q_DECLARE_PRIVATE(PcbCamFeatureArc)
    Q_DISABLE_COPY(PcbCamFeatureArc)
};

class PcbCamFeatureTextPrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeatureText : public PcbCamFeature
{
public:
    PcbCamFeatureText();
    ~PcbCamFeatureText();

    void setData(const QPointF &iPos,
                 PcbCamFont *iFont,
                 PcbCam::Orient iOrient,
                 const QSizeF &iSize,
                 qreal iWithFactor,
                 const QString &iText,
                 int iVersion = 1);

    QPointF pos() const;
    PcbCamFont *font() const;
    PcbCam::Orient orient() const;
    QSizeF size() const;
    qreal widthFactor() const;
    QString text() const;
    int version() const;
    QString dynamicText() const;
    void setDynamicText(const QString &iText);

    QList<PcbCamFeature *> features() const;

    QPainterPath shape() const;
    QRectF boundingRect() const;


private:
    Q_DECLARE_PRIVATE(PcbCamFeatureText)
    Q_DISABLE_COPY(PcbCamFeatureText)
};

class PcbCamFeatureBarcodePrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeatureBarcode : public PcbCamFeature
{
public:
    PcbCamFeatureBarcode();
    ~PcbCamFeatureBarcode();

    QPointF pos() const;
    void setPos(const QPointF &iPos);

    QString barcode() const;
    void setBarcode(const QString &iBarcode);

    QString font() const;
    void setFont(const QString &iFont);

    PcbCam::Orient orient() const;
    void setOrient(PcbCam::Orient iOrient);

    QSizeF size() const;
    void setSize(const QSizeF &iSize);

    bool fullAscii() const;
    void setFullAscii(bool iBol);

    bool checkSum() const;
    void setCheckSum(bool iBol);

    bool background() const;
    void setBackground(bool iBol);

    bool additionStr() const;
    void setAdditionStr(bool iBol);

    PcbCam::BarcodeTextPos additiontStrPos() const;
    void setAdditionStrPos(PcbCam::BarcodeTextPos iTorB);

    QString text() const;
    void setText(const QString &iText);

    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    Q_DECLARE_PRIVATE(PcbCamFeatureBarcode)
    Q_DISABLE_COPY(PcbCamFeatureBarcode)
};

class PcbCamFeatureSurfacePrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeatureSurface : public PcbCamFeature
{
public:
    PcbCamFeatureSurface();
    ~PcbCamFeatureSurface();

    QPainterPath path() const;
    void setPath(const QPainterPath &iPath);

    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    Q_DECLARE_PRIVATE(PcbCamFeatureSurface)
    Q_DISABLE_COPY(PcbCamFeatureSurface)
};

class PcbCamFeaturePathPrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeaturePath : public PcbCamFeature
{
public:
    PcbCamFeaturePath();
    ~PcbCamFeaturePath();

    QPainterPath path() const;
    void setPath(const QPainterPath &iPath);

    int width() const;
    void setWidth(int iWidth);

    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    Q_DECLARE_PRIVATE(PcbCamFeaturePath)
    Q_DISABLE_COPY(PcbCamFeaturePath)
};


class PcbCamFeatureComponentPrivate;
class TITAN_PCBCAM_EXPORT PcbCamFeatureComponent : public PcbCamFeature
{
public:
    PcbCamFeatureComponent();
    ~PcbCamFeatureComponent();

    void setData(const QPointF &iPos,
                 double iRotation,
                 bool iMirror,
                 const QString &iCompName,
                 const QString &iPartName);

    QPointF pos() const;
    double rotation() const;
    bool mirror() const;
    QString compName() const;
    QString partName() const;

    QPainterPath shape() const;
    QRectF boundingRect() const;


private:
    Q_DECLARE_PRIVATE(PcbCamFeatureComponent)
    Q_DISABLE_COPY(PcbCamFeatureComponent)
};


#endif // TITAN_PCBCAM_FEATURE_H
