#ifndef TITAN_PCBCAM_LAYER_H
#define TITAN_PCBCAM_LAYER_H
#include "../titanpcbcamglobal.h"
#include <QString>
#include <QVariantMap>
#include <QPainterPath>
#include "./common.h"


class PcbCamJob;
class PcbCamFeature;

class PcbCamLayerPrivate;
class TITAN_PCBCAM_EXPORT PcbCamLayer
{
public:
    PcbCamLayer(PcbCamJob *iJob);
    ~PcbCamLayer();

    PcbCamJob *job() const;

    QString name() const;
    void setName(const QString &iName);

    QString step() const;
    void setStep(const QString &iStep);

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

    void setAffectedLayer(bool iAffected = true);
    bool isAffectedLayer() const;
    void setWorkLayer(bool iBol = true);
    bool isWorkLayer() const;
    void setDisplayColor(const QString &iColor);
    QString displayColor() const;

    QList<PcbCamFeature*> features() const;
    void clearFeatures();
    void addFeature(PcbCamFeature *iFeature);
    void addFeatures(const QList<PcbCamFeature *> &iFeatures);
    PcbCamFeature *addLine(const QLineF &iLine,
                           const QString &iSymbol,
                           PcbCam::Polarity iPolarity = PcbCam::Positive,
                           const QVariantMap &iAttr = QVariantMap());
    PcbCamFeature *addPad(const QPointF &iPos,
                          const QString &iSymbol,
                          PcbCam::Orient iOrient = PcbCam::Orient_N_0,
                          PcbCam::Polarity iPolarity = PcbCam::Positive,
                          const QVariantMap &iAttr = QVariantMap());
    PcbCamFeature *addArc(const QPointF &iPs,
                          const QPointF &iPe,
                          const QPointF &iPc,
                          bool iCw,
                          const QString &iSymbol,
                          PcbCam::Polarity iPolarity = PcbCam::Positive,
                          const QVariantMap &iAttr = QVariantMap());
    PcbCamFeature *addText(const QPointF &iPos,
                           const QString &iText,
                           const QSizeF &iSize,
                           PcbCam::Orient iOrient = PcbCam::Orient_N_0,
                           PcbCam::Polarity iPolarity = PcbCam::Positive,
                           const QVariantMap &iAttr = QVariantMap(),
                           qreal iWidthFactor = 1.0,
                           const QString &iFont = "standard"
                           );
    PcbCamFeature *addSurface(const QPainterPath &iPath,
                              PcbCam::Polarity iPolarity = PcbCam::Positive,
                              const QVariantMap &iAttr = QVariantMap());

    PcbCamFeature *addPath(const QPainterPath &iPath,
                           int iWidth = 1,
                           PcbCam::Polarity iPolarity = PcbCam::Positive,
                           const QVariantMap &iAttr = QVariantMap());


    void deleteFeature(int iIndex);
    QList<PcbCamFeature *> selectFeature(const QPainterPath &iRegionPath,
                                         const PcbCam::FeatureSelectionFilter &iFilter,
                                         PcbCam::FeatureSelectionOperation iSelOp,
                                         PcbCam::FeatureSelectionMode iSelMode);

    QList<PcbCamFeature *> selectedFeatures() const;
    void clearSelection();
    bool hasFeatureSelected() const;


    QRectF boundingRect() const;

protected:
    const QScopedPointer<PcbCamLayerPrivate> d_ptr;

private:
    Q_DECLARE_PRIVATE(PcbCamLayer)
    Q_DISABLE_COPY(PcbCamLayer)

};

#endif // TITAN_PCBCAM_LAYER_H
