Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SELECTABLELINESEGMENTGRAPHIC_H
00022 #define SELECTABLELINESEGMENTGRAPHIC_H
00023
00024
00025 #include <QGraphicsItem>
00026 #include <QGraphicsSceneHoverEvent>
00027 #include <QGraphicsSceneMouseEvent>
00028 #include <QColor>
00029 #include <QPainter>
00030 #include <QPen>
00031 #include <QPointF>
00032 #include "cornergrabber.h"
00033 #include <QGraphicsPolygonItem>
00034 #include <QPainterPath>
00035 class SCTransition;
00036 class IAttribute;
00037
00038
00047 class SelectableLineSegmentGraphic : public QObject, public QGraphicsPolygonItem
00048 {
00049 Q_OBJECT
00050
00051 public:
00052 SelectableLineSegmentGraphic(QPointF position, QPointF start, QPointF end, SCTransition* transition );
00053
00054 signals:
00055 void selected();
00056 void unselected();
00057
00058 private:
00059
00060
00061
00062 QPen _pen;
00063 QPointF _dragStart;
00064 QPointF _cornerDragStart;
00065 int _XcornerGrabBuffer;
00066 int _YcornerGrabBuffer;
00067
00068 QPointF _lineEnd_0;
00069 QPointF _lineEnd_1;
00070 bool _cornerGrabbed;
00071 CornerGrabber* _corners[2];
00072 QPolygonF _selectRegion;
00073
00074 SCTransition* _transitionModel;
00075
00076
00077
00078
00079
00080 void updateModel ();
00081
00082 virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00083 virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
00084 virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
00085
00086 virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
00087 virtual void mousePressEvent (QGraphicsSceneMouseEvent * event );
00088 virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent * event );
00089
00090 virtual void mouseMoveEvent(QGraphicsSceneDragDropEvent *event);
00091 virtual void mousePressEvent(QGraphicsSceneDragDropEvent *event);
00092 virtual bool sceneEventFilter ( QGraphicsItem * watched, QEvent * event ) ;
00093
00094 void setCornerPositions();
00095
00096 void createCustomPath(QPointF mouseLocation, CornerGrabber*);
00097
00098 void enclosePathInSceneCoordiates(qreal lineStartX,qreal lineStartY, qreal lineEndX, qreal lineEndY );
00099 void enclosePathInItemCoordiates(qreal lineStartX,qreal lineStartY, qreal lineEndX, qreal lineEndY );
00100
00101 private slots:
00102
00103 void handleAttributeChanged(IAttribute *attr);
00104
00105 };
00106
00107
00108 #endif // SELECTABLELINESEGMENTGRAPHIC_H