• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

C:/Users/David/Documents/QtProjects/visualsc/scgraphicsview/selectablelinesegmentgraphic.h

Go to the documentation of this file.
00001 /*
00002     visualsc - Visual State Chart Editing for SCXML State Engines
00003     Copyright (C) 2011  David W. Drell (david@davidwdrell.net) and
00004     Contributing Authors:
00005 
00006 
00007     This program is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
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     // private data
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];// 0,1  - starting at x=0,y=0
00072     QPolygonF       _selectRegion;
00073 
00074      SCTransition*  _transitionModel;
00075 
00076 
00077     // private methods
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

Generated on Mon Sep 26 2011 06:59:25 for visualsc by  doxygen 1.7.1