#ifndef DESIGNER_VIEW_H
#define DESIGNER_VIEW_H

#include <QGraphicsView>

class DesignerView : public QGraphicsView
{
    Q_OBJECT

public:
    explicit DesignerView(QWidget *parent = 0);
    virtual ~DesignerView();

    //视图操作-外部调用
    void zoomIn();
    void zoomOut();
    void zoomFit();

protected:
    virtual void contextMenuEvent(QContextMenuEvent*) override;
    virtual void mousePressEvent(QMouseEvent*) override;
    virtual void mouseMoveEvent(QMouseEvent*) override;
    virtual void mouseReleaseEvent(QMouseEvent*) override;
    virtual void wheelEvent(QWheelEvent*) override;

private:
    void initialize();
    //视图操作相关
    void zoom(const QPointF&, double);
    bool zoomLimit(double&);
    double getScaleFactor();
    void translate(const QPointF&);

private:
    bool    m_bMousePress;
    double  m_dScale;
    QPointF m_ptLatstMouse_view; //鼠标最后按下在view中的位置
};

#endif
