Advertisement
Guest User

mysquare.h

a guest
May 17th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.48 KB | None | 0 0
  1. #ifndef MYSQUARE_H
  2. #define MYSQUARE_H
  3. #include<QObject>
  4. #include<QPainter>
  5. #include<QGraphicsItem>
  6. #include<QGraphicsItemGroup>
  7. #include<QGraphicsPixmapItem>
  8. #include<QPainterPath>
  9. #include<QPointF>
  10. #include<QSizeF>
  11. #include<QImage>
  12. #include<QLabel>
  13. #include<QCoreApplication>
  14. #include <QStringBuilder>
  15. #include <QString>
  16. #include <QTranslator>
  17. #include <QList>
  18. #include <QVariant>
  19. #include <QDebug>
  20. #include <QtSvg>
  21. #include <QSvgGenerator>
  22. #include "arrow.h"
  23. #include "mysvgitem.h"
  24. class QGraphicsSvgItem;
  25. class QPolygonF;
  26. class Arrow;
  27.  
  28. class MySquare : public QObject,  public QGraphicsItem
  29. {
  30.     Q_OBJECT
  31.     Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity);
  32.     Q_PROPERTY(QSizeF size READ size WRITE setSize);
  33.     Q_PROPERTY(QPointF pos READ pos WRITE setPos);
  34.     Q_PROPERTY(qreal x READ x WRITE setX);
  35.     Q_PROPERTY(qreal y READ y WRITE setY);
  36.     enum resize_direction
  37.     {
  38.         rd_none,
  39.         rd_left,
  40.         rd_top,
  41.         rd_right,
  42.         rd_bottom,
  43.         rd_diagonal
  44.  
  45.     };
  46. public:
  47.     enum { Type = UserType + 1 };
  48.     MySquare();
  49.  
  50.     QRectF boundingRect() const;
  51.     //int type() const Q_DECL_OVERRIDE {return Type ;}
  52.     int type() const  {return Type ;}
  53.     QPolygonF polygon() const { return myPolygon; }
  54.     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
  55.     bool Pressed;
  56.     void addArrow(Arrow *arrow);
  57.     QPointF returnCenter();
  58.     void setMyPolygon();
  59.     void setItemSize(qreal height,qreal width);
  60.     void setImage(const QString& str);
  61.     void setImage(const QString& str ,QSize);
  62.     void setImage(const QString& str ,QRectF rec);
  63.     void setSvgImage(const QString& str);
  64.     void setSvgImage(const QString& str ,QSizeF);
  65.     void setSvgImage(const QString& str ,QRectF rec);
  66.     void setText(const QString& str ,QRectF rec);
  67.     QSizeF size();
  68.     void setSize(QSizeF size);
  69.     ~MySquare();
  70. signals:
  71.     void click();
  72.  
  73. protected:
  74.     void mousePressEvent(QGraphicsSceneMouseEvent *event);
  75.     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
  76.     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
  77.     QVariant itemChange(GraphicsItemChange change, const QVariant &value) ;
  78. private:
  79.     QPolygonF myPolygon;
  80.     QList<Arrow *> arrows;
  81.     QRectF myItemRect;
  82.     QString MyText;
  83.     QRectF MyTextRect;
  84.     QGraphicsTextItem *itemXY;
  85.     QString *posXY;
  86.     resize_direction resize_direction_;
  87.     bool clickFlag ;
  88.  
  89.  
  90. };
  91.  
  92. #endif // MYSQUARE_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement