qgraphicsview.sip 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // qgraphicsview.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtWidgets Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QGraphicsView : public QAbstractScrollArea
  22. {
  23. %TypeHeaderCode
  24. #include <qgraphicsview.h>
  25. %End
  26. public:
  27. enum CacheModeFlag /BaseType=Flag/
  28. {
  29. CacheNone,
  30. CacheBackground,
  31. };
  32. typedef QFlags<QGraphicsView::CacheModeFlag> CacheMode;
  33. enum DragMode
  34. {
  35. NoDrag,
  36. ScrollHandDrag,
  37. RubberBandDrag,
  38. };
  39. enum ViewportAnchor
  40. {
  41. NoAnchor,
  42. AnchorViewCenter,
  43. AnchorUnderMouse,
  44. };
  45. QGraphicsView(QWidget *parent /TransferThis/ = 0);
  46. QGraphicsView(QGraphicsScene *scene /KeepReference/, QWidget *parent /TransferThis/ = 0);
  47. virtual ~QGraphicsView();
  48. virtual QSize sizeHint() const;
  49. QPainter::RenderHints renderHints() const;
  50. void setRenderHint(QPainter::RenderHint hint, bool on = true);
  51. void setRenderHints(QPainter::RenderHints hints);
  52. Qt::Alignment alignment() const;
  53. void setAlignment(Qt::Alignment alignment);
  54. QGraphicsView::ViewportAnchor transformationAnchor() const;
  55. void setTransformationAnchor(QGraphicsView::ViewportAnchor anchor);
  56. QGraphicsView::ViewportAnchor resizeAnchor() const;
  57. void setResizeAnchor(QGraphicsView::ViewportAnchor anchor);
  58. QGraphicsView::DragMode dragMode() const;
  59. void setDragMode(QGraphicsView::DragMode mode);
  60. QGraphicsView::CacheMode cacheMode() const;
  61. void setCacheMode(QGraphicsView::CacheMode mode);
  62. void resetCachedContent();
  63. bool isInteractive() const;
  64. void setInteractive(bool allowed);
  65. QGraphicsScene *scene() const;
  66. void setScene(QGraphicsScene *scene /KeepReference/);
  67. QRectF sceneRect() const;
  68. void setSceneRect(const QRectF &rect);
  69. void rotate(qreal angle);
  70. void scale(qreal sx, qreal sy);
  71. void shear(qreal sh, qreal sv);
  72. void translate(qreal dx, qreal dy);
  73. void centerOn(const QPointF &pos);
  74. void centerOn(const QGraphicsItem *item);
  75. void ensureVisible(const QRectF &rect, int xMargin = 50, int yMargin = 50);
  76. void ensureVisible(const QGraphicsItem *item, int xMargin = 50, int yMargin = 50);
  77. void fitInView(const QRectF &rect, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio);
  78. void fitInView(const QGraphicsItem *item, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio);
  79. void render(QPainter *painter, const QRectF &target = QRectF(), const QRect &source = QRect(), Qt::AspectRatioMode mode = Qt::KeepAspectRatio);
  80. QList<QGraphicsItem *> items() const;
  81. QList<QGraphicsItem *> items(const QPoint &pos) const;
  82. QList<QGraphicsItem *> items(int x, int y) const;
  83. QList<QGraphicsItem *> items(int x, int y, int w, int h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
  84. QList<QGraphicsItem *> items(const QRect &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
  85. QList<QGraphicsItem *> items(const QPolygon &polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
  86. QList<QGraphicsItem *> items(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
  87. QGraphicsItem *itemAt(const QPoint &pos) const;
  88. QPointF mapToScene(const QPoint &point) const;
  89. QPolygonF mapToScene(const QRect &rect) const;
  90. QPolygonF mapToScene(const QPolygon &polygon) const;
  91. QPainterPath mapToScene(const QPainterPath &path) const;
  92. QPoint mapFromScene(const QPointF &point) const;
  93. QPolygon mapFromScene(const QRectF &rect) const;
  94. QPolygon mapFromScene(const QPolygonF &polygon) const;
  95. QPainterPath mapFromScene(const QPainterPath &path) const;
  96. virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
  97. QBrush backgroundBrush() const;
  98. void setBackgroundBrush(const QBrush &brush);
  99. QBrush foregroundBrush() const;
  100. void setForegroundBrush(const QBrush &brush);
  101. public slots:
  102. void invalidateScene(const QRectF &rect = QRectF(), QGraphicsScene::SceneLayers layers = QGraphicsScene::AllLayers);
  103. void updateScene(const QList<QRectF> &rects);
  104. void updateSceneRect(const QRectF &rect);
  105. protected slots:
  106. virtual void setupViewport(QWidget *widget);
  107. protected:
  108. virtual bool event(QEvent *event);
  109. virtual bool viewportEvent(QEvent *event);
  110. virtual void contextMenuEvent(QContextMenuEvent *event);
  111. virtual void dragEnterEvent(QDragEnterEvent *event);
  112. virtual void dragLeaveEvent(QDragLeaveEvent *event);
  113. virtual void dragMoveEvent(QDragMoveEvent *event);
  114. virtual void dropEvent(QDropEvent *event);
  115. virtual void focusInEvent(QFocusEvent *event);
  116. virtual void focusOutEvent(QFocusEvent *event);
  117. virtual bool focusNextPrevChild(bool next);
  118. virtual void keyPressEvent(QKeyEvent *event);
  119. virtual void keyReleaseEvent(QKeyEvent *event);
  120. virtual void mouseDoubleClickEvent(QMouseEvent *event);
  121. virtual void mousePressEvent(QMouseEvent *event);
  122. virtual void mouseMoveEvent(QMouseEvent *event);
  123. virtual void mouseReleaseEvent(QMouseEvent *event);
  124. virtual void wheelEvent(QWheelEvent *event);
  125. virtual void paintEvent(QPaintEvent *event);
  126. virtual void resizeEvent(QResizeEvent *event);
  127. virtual void scrollContentsBy(int dx, int dy);
  128. virtual void showEvent(QShowEvent *event);
  129. virtual void inputMethodEvent(QInputMethodEvent *event);
  130. virtual void drawBackground(QPainter *painter, const QRectF &rect);
  131. virtual void drawForeground(QPainter *painter, const QRectF &rect);
  132. public:
  133. void setSceneRect(qreal ax, qreal ay, qreal aw, qreal ah);
  134. void centerOn(qreal ax, qreal ay);
  135. void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xMargin = 50, int yMargin = 50);
  136. void fitInView(qreal x, qreal y, qreal w, qreal h, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio);
  137. QGraphicsItem *itemAt(int ax, int ay) const;
  138. QPointF mapToScene(int ax, int ay) const;
  139. QPolygonF mapToScene(int ax, int ay, int w, int h) const;
  140. QPoint mapFromScene(qreal ax, qreal ay) const;
  141. QPolygon mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const;
  142. enum ViewportUpdateMode
  143. {
  144. FullViewportUpdate,
  145. MinimalViewportUpdate,
  146. SmartViewportUpdate,
  147. BoundingRectViewportUpdate,
  148. NoViewportUpdate,
  149. };
  150. enum OptimizationFlag /BaseType=Flag/
  151. {
  152. DontSavePainterState,
  153. DontAdjustForAntialiasing,
  154. };
  155. typedef QFlags<QGraphicsView::OptimizationFlag> OptimizationFlags;
  156. QGraphicsView::ViewportUpdateMode viewportUpdateMode() const;
  157. void setViewportUpdateMode(QGraphicsView::ViewportUpdateMode mode);
  158. QGraphicsView::OptimizationFlags optimizationFlags() const;
  159. void setOptimizationFlag(QGraphicsView::OptimizationFlag flag, bool enabled = true);
  160. void setOptimizationFlags(QGraphicsView::OptimizationFlags flags);
  161. Qt::ItemSelectionMode rubberBandSelectionMode() const;
  162. void setRubberBandSelectionMode(Qt::ItemSelectionMode mode);
  163. QTransform transform() const;
  164. QTransform viewportTransform() const;
  165. void setTransform(const QTransform &matrix, bool combine = false);
  166. void resetTransform();
  167. bool isTransformed() const;
  168. QRect rubberBandRect() const;
  169. signals:
  170. void rubberBandChanged(QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint);
  171. };