#ifndef CUSTOMWIDGET2_H
#define CUSTOMWIDGET2_H

#include <QWidget>


class MyCustomWidget2 : public QWidget
{
    Q_OBJECT
public:
    explicit MyCustomWidget2(QWidget *parent = 0);
    void setHilfe(bool on);
    bool isValid() const;
    void setSoftwareEndschalter(double plus_x, double minus_x, double plus_y, double minus_y);
    void invalidate();

protected:
    // reimplemented methods:
    virtual void timerEvent(QTimerEvent *event);
    virtual void paintEvent(QPaintEvent *event);
    virtual void resizeEvent(QResizeEvent *event);
//    virtual void mouseDoubleClickEvent(QMouseEvent *event);
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
    virtual void mouseMoveEvent(QMouseEvent *event);
//    virtual void wheelEvent(QWheelEvent *event);
    void draw();
    void createGrid();
    void calc();
    double arcusTangens(double x, double y);

private:
    QPixmap m_buffer;
    QColor m_backgroundColor;
    QPointF m_mousePoint;
    QRectF m_baseRect;
    QRectF m_moveableRect;
    bool m_move;
    QPointF m_startPoint;
    QPointF m_endPoint;
    double alpha;
    QVector <QPointF> m_curve;
    QVector <QLineF> m_gridV;
    QVector <QLineF> m_gridH;
    double m_laengeMax;
    double m_hoeheMax;
    double m_scaleFactorX;
    double m_scaleFactorY;
    QString m_text[8][3];
    bool m_hilfe;
    double m_startPositionX;
    double m_startPositionY;
    bool m_error;
    QPixmap m_gestell;
    QPixmap m_ausgabetrichter;
    QFont m_font;
    double textHeight;
    double textWidth[4][3];
    bool m_errorValue[4][2];
    bool m_valid;
    double m_sw_end_pos_x;
    double m_sw_end_neg_x;
    double m_sw_end_pos_y;
    double m_sw_end_neg_y;
    bool drawStartPoint;
    bool m_isEnabled;
    double m_widthGesamt;
    double m_offset_x;
    bool m_moveStartPoint;

signals:
    void startPositionChanged(QPointF);
    void startSpiel(double h, double weite);
    void error(bool);

public slots:
    void setError(bool);
    void setEnabled(bool);
    void setDisabled(bool);

};

#endif // CUSTOMWIDGET_H
