1// qgraphicsview.sip generated by MetaSIP 2// 3// This file is part of the QtWidgets Python extension module. 4// 5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com> 6// 7// This file is part of PyQt5. 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 22 23class QGraphicsView : QAbstractScrollArea 24{ 25%TypeHeaderCode 26#include <qgraphicsview.h> 27%End 28 29public: 30 enum CacheModeFlag 31 { 32 CacheNone, 33 CacheBackground, 34 }; 35 36 typedef QFlags<QGraphicsView::CacheModeFlag> CacheMode; 37 38 enum DragMode 39 { 40 NoDrag, 41 ScrollHandDrag, 42 RubberBandDrag, 43 }; 44 45 enum ViewportAnchor 46 { 47 NoAnchor, 48 AnchorViewCenter, 49 AnchorUnderMouse, 50 }; 51 52 QGraphicsView(QWidget *parent /TransferThis/ = 0); 53 QGraphicsView(QGraphicsScene *scene /KeepReference/, QWidget *parent /TransferThis/ = 0); 54 virtual ~QGraphicsView(); 55 virtual QSize sizeHint() const; 56 QPainter::RenderHints renderHints() const; 57 void setRenderHint(QPainter::RenderHint hint, bool on = true); 58 void setRenderHints(QPainter::RenderHints hints); 59 Qt::Alignment alignment() const; 60 void setAlignment(Qt::Alignment alignment); 61 QGraphicsView::ViewportAnchor transformationAnchor() const; 62 void setTransformationAnchor(QGraphicsView::ViewportAnchor anchor); 63 QGraphicsView::ViewportAnchor resizeAnchor() const; 64 void setResizeAnchor(QGraphicsView::ViewportAnchor anchor); 65 QGraphicsView::DragMode dragMode() const; 66 void setDragMode(QGraphicsView::DragMode mode); 67 QGraphicsView::CacheMode cacheMode() const; 68 void setCacheMode(QGraphicsView::CacheMode mode); 69 void resetCachedContent(); 70 bool isInteractive() const; 71 void setInteractive(bool allowed); 72 QGraphicsScene *scene() const; 73 void setScene(QGraphicsScene *scene /KeepReference/); 74 QRectF sceneRect() const; 75 void setSceneRect(const QRectF &rect); 76 void rotate(qreal angle); 77 void scale(qreal sx, qreal sy); 78 void shear(qreal sh, qreal sv); 79 void translate(qreal dx, qreal dy); 80 void centerOn(const QPointF &pos); 81 void centerOn(const QGraphicsItem *item); 82 void ensureVisible(const QRectF &rect, int xMargin = 50, int yMargin = 50); 83 void ensureVisible(const QGraphicsItem *item, int xMargin = 50, int yMargin = 50); 84 void fitInView(const QRectF &rect, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio); 85 void fitInView(const QGraphicsItem *item, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio); 86 void render(QPainter *painter, const QRectF &target = QRectF(), const QRect &source = QRect(), Qt::AspectRatioMode mode = Qt::KeepAspectRatio); 87 QList<QGraphicsItem *> items() const; 88 QList<QGraphicsItem *> items(const QPoint &pos) const; 89 QList<QGraphicsItem *> items(int x, int y) const; 90 QList<QGraphicsItem *> items(int x, int y, int w, int h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; 91 QList<QGraphicsItem *> items(const QRect &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; 92 QList<QGraphicsItem *> items(const QPolygon &polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; 93 QList<QGraphicsItem *> items(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; 94 QGraphicsItem *itemAt(const QPoint &pos) const; 95 QPointF mapToScene(const QPoint &point) const; 96 QPolygonF mapToScene(const QRect &rect) const; 97 QPolygonF mapToScene(const QPolygon &polygon) const; 98 QPainterPath mapToScene(const QPainterPath &path) const; 99 QPoint mapFromScene(const QPointF &point) const; 100 QPolygon mapFromScene(const QRectF &rect) const; 101 QPolygon mapFromScene(const QPolygonF &polygon) const; 102 QPainterPath mapFromScene(const QPainterPath &path) const; 103 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; 104 QBrush backgroundBrush() const; 105 void setBackgroundBrush(const QBrush &brush); 106 QBrush foregroundBrush() const; 107 void setForegroundBrush(const QBrush &brush); 108 109public slots: 110 void invalidateScene(const QRectF &rect = QRectF(), QGraphicsScene::SceneLayers layers = QGraphicsScene::AllLayers); 111 void updateScene(const QList<QRectF> &rects); 112 void updateSceneRect(const QRectF &rect); 113 114protected slots: 115 virtual void setupViewport(QWidget *widget); 116 117protected: 118 virtual bool event(QEvent *event); 119 virtual bool viewportEvent(QEvent *event); 120 virtual void contextMenuEvent(QContextMenuEvent *event); 121 virtual void dragEnterEvent(QDragEnterEvent *event); 122 virtual void dragLeaveEvent(QDragLeaveEvent *event); 123 virtual void dragMoveEvent(QDragMoveEvent *event); 124 virtual void dropEvent(QDropEvent *event); 125 virtual void focusInEvent(QFocusEvent *event); 126 virtual void focusOutEvent(QFocusEvent *event); 127 virtual bool focusNextPrevChild(bool next); 128 virtual void keyPressEvent(QKeyEvent *event); 129 virtual void keyReleaseEvent(QKeyEvent *event); 130 virtual void mouseDoubleClickEvent(QMouseEvent *event); 131 virtual void mousePressEvent(QMouseEvent *event); 132 virtual void mouseMoveEvent(QMouseEvent *event); 133 virtual void mouseReleaseEvent(QMouseEvent *event); 134 virtual void wheelEvent(QWheelEvent *event); 135 virtual void paintEvent(QPaintEvent *event); 136 virtual void resizeEvent(QResizeEvent *event); 137 virtual void scrollContentsBy(int dx, int dy); 138 virtual void showEvent(QShowEvent *event); 139 virtual void inputMethodEvent(QInputMethodEvent *event); 140 virtual void drawBackground(QPainter *painter, const QRectF &rect); 141 virtual void drawForeground(QPainter *painter, const QRectF &rect); 142 143public: 144 void setSceneRect(qreal ax, qreal ay, qreal aw, qreal ah); 145 void centerOn(qreal ax, qreal ay); 146 void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xMargin = 50, int yMargin = 50); 147 void fitInView(qreal x, qreal y, qreal w, qreal h, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio); 148 QGraphicsItem *itemAt(int ax, int ay) const; 149 QPointF mapToScene(int ax, int ay) const; 150 QPolygonF mapToScene(int ax, int ay, int w, int h) const; 151 QPoint mapFromScene(qreal ax, qreal ay) const; 152 QPolygon mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const; 153 154 enum ViewportUpdateMode 155 { 156 FullViewportUpdate, 157 MinimalViewportUpdate, 158 SmartViewportUpdate, 159 BoundingRectViewportUpdate, 160 NoViewportUpdate, 161 }; 162 163 enum OptimizationFlag 164 { 165 DontClipPainter, 166 DontSavePainterState, 167 DontAdjustForAntialiasing, 168 }; 169 170 typedef QFlags<QGraphicsView::OptimizationFlag> OptimizationFlags; 171 QGraphicsView::ViewportUpdateMode viewportUpdateMode() const; 172 void setViewportUpdateMode(QGraphicsView::ViewportUpdateMode mode); 173 QGraphicsView::OptimizationFlags optimizationFlags() const; 174 void setOptimizationFlag(QGraphicsView::OptimizationFlag flag, bool enabled = true); 175 void setOptimizationFlags(QGraphicsView::OptimizationFlags flags); 176 Qt::ItemSelectionMode rubberBandSelectionMode() const; 177 void setRubberBandSelectionMode(Qt::ItemSelectionMode mode); 178 QTransform transform() const; 179 QTransform viewportTransform() const; 180 void setTransform(const QTransform &matrix, bool combine = false); 181 void resetTransform(); 182 bool isTransformed() const; 183%If (Qt_5_1_0 -) 184 QRect rubberBandRect() const; 185%End 186 187signals: 188%If (Qt_5_1_0 -) 189 void rubberBandChanged(QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint); 190%End 191}; 192 193QFlags<QGraphicsView::CacheModeFlag> operator|(QGraphicsView::CacheModeFlag f1, QFlags<QGraphicsView::CacheModeFlag> f2); 194QFlags<QGraphicsView::OptimizationFlag> operator|(QGraphicsView::OptimizationFlag f1, QFlags<QGraphicsView::OptimizationFlag> f2); 195