![]() |
TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
|
00001 /**************************************************************************** 00002 00003 Copyright (c) 2008 Deepak Chandran 00004 Contact: Deepak Chandran (dchandran1@gmail.com) 00005 See COPYRIGHT.TXT 00006 00007 One of the main classes in Tinkercell. 00008 00009 ControlPoint is a drawable item that is used by NodeGraphicsItem and ConnectionGraphicsItem 00010 to draw movable points. 00011 00012 ****************************************************************************/ 00013 00014 #ifndef TINKERCELL_CONTROLPOINTGRAPHICSITEM_H 00015 #define TINKERCELL_CONTROLPOINTGRAPHICSITEM_H 00016 00017 #include <math.h> 00018 #include <QObject> 00019 #include <QtDebug> 00020 #include <QString> 00021 #include <QColor> 00022 #include <QPoint> 00023 #include <QPainter> 00024 #include <QGraphicsPolygonItem> 00025 #include <QAbstractGraphicsShapeItem> 00026 #include <QGraphicsItemGroup> 00027 #include <QGraphicsRectItem> 00028 #include <QStyleOptionGraphicsItem> 00029 #include <QGraphicsScene> 00030 #include <QTransform> 00031 #include <QUndoCommand> 00032 #include <QTextCursor> 00033 00034 #ifndef TINKERCELLCOREEXPORT 00035 #ifdef Q_WS_WIN 00036 # if defined(TC_EXPORTS) || defined(TinkerCellCore_EXPORTS) 00037 # define TINKERCELLCOREEXPORT __declspec(dllexport) 00038 # else 00039 # define TINKERCELLCOREEXPORT __declspec(dllimport) 00040 # endif 00041 #else 00042 # define TINKERCELLCOREEXPORT 00043 #endif 00044 #endif 00045 00046 namespace Tinkercell 00047 { 00048 class ItemHandle; 00049 00052 class TINKERCELLCOREEXPORT ControlPoint : public QAbstractGraphicsShapeItem 00053 { 00054 public: 00056 QBrush defaultBrush; 00058 QPen defaultPen; 00060 QSizeF defaultSize; 00062 virtual qreal x() { return scenePos().x(); } 00064 virtual qreal y() { return scenePos().y(); } 00066 ControlPoint(QGraphicsItem * parent = 0); 00068 ControlPoint(const ControlPoint& copy); 00070 //virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option=new QStyleOptionGraphicsItem() ,QWidget *widget=0); 00072 enum { Type = UserType + 1 }; 00074 virtual int type() const 00075 { 00076 // Enable the use of dynamic_cast with this item. 00077 return Type; 00078 } 00080 static ControlPoint * cast(QGraphicsItem* item); 00082 static QList<ControlPoint*> cast(const QList<QGraphicsItem*>& items); 00084 virtual void sideEffect(); 00086 virtual ControlPoint* clone() const; 00088 enum ShapeType { circle, square, triangle }; 00090 ShapeType shapeType; 00092 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option=new QStyleOptionGraphicsItem() ,QWidget *widget=0); 00094 virtual QRectF boundingRect() const; 00096 virtual void setRect(const QRectF&); 00098 virtual QRectF rect() const; 00100 virtual ItemHandle * handle() const; 00102 virtual void setHandle(ItemHandle *); 00103 protected: 00104 QRectF bounds; 00105 }; 00106 } 00107 #endif