#ifndef ONMONITORCORNERSITEM_H
#define ONMONITORCORNERSITEM_H
-#include "abstractonmonitoritem.h"
-#include <QtCore>
#include <QGraphicsPolygonItem>
-class OnMonitorCornersItem : public AbstractOnMonitorItem, public QGraphicsPolygonItem
+class QGraphicsView;
+
+class OnMonitorCornersItem : public QObject, public QGraphicsPolygonItem
{
Q_OBJECT
public:
- OnMonitorCornersItem(MonitorScene *scene, QGraphicsItem *parent = 0);
+ OnMonitorCornersItem(QGraphicsItem *parent = 0);
- enum cornersActions { Corner1, Corner2, Corner3, Corner4, Move, NoAction };
+ enum cornersActions { Corner, Move, MoveSide, NoAction };
/** @brief Gets The action mode for the area @param pos +- 4. */
- cornersActions getMode(QPointF pos);
+ cornersActions getMode(const QPointF &pos, int *corner);
/** @brief Reimplemented to draw the handles. */
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
-public slots:
- /** @brief Saves current mouse position and mode. */
- void slotMousePressed(QGraphicsSceneMouseEvent *event);
- /** @brief Modifies item according to mouse position and mode. */
- void slotMouseMoved(QGraphicsSceneMouseEvent *event);
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
private:
/** @brief Returns the centroid (= 'center of mass') of this polygon. */
/** @brief Returns the points of this polygon but sorted clockwise. */
QList <QPointF> sortedClockwise();
+ /** @brief Tries to get the view of the scene. */
+ bool getView();
+
cornersActions m_mode;
+ /** Number of the selected corner or if in MoveSide mode number of the first corner on this side */
+ int m_selectedCorner;
QPointF m_lastPoint;
+ bool m_modified;
+
+ QGraphicsView *m_view;
+
+signals:
+ void changed();
};
#endif