Version: 9.15.0
QtViewer_ViewPort.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2025 CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef QTVIEWER_VIEWPORT_H
21 #define QTVIEWER_VIEWPORT_H
22 
23 #include "QtViewer.h"
24 #include <QGraphicsView>
25 
27 class QRubberBand;
28 
29 /*
30  Class : QtViewer_ViewPort
31  Description : View port of the graphics view
32 */
34 {
35  Q_OBJECT
36 
37 public:
38  QtViewer_ViewPort(QWidget* theParent);
40 
41  void addItem(QGraphicsItem* theItem);
42 
43  void fitAll();
44  void fitSelect();
45  void fitRect(const QRectF& theRect);
46  void pan(double theDX, double theDY);
47 
48  // rectangle selection
49  void startDrawingRect(int x, int y);
50  void drawingRect(int x, int y);
51  void finishDrawingRect();
52  QRect selectionRect();
53 
54  void activateZoomAction();
55  void activateFitAreaAction();
56  void activatePanAction();
57  void activateGlobalPanAction();
58 
59  QImage dumpView(bool theWholeScene = false, QSizeF theSize = QSizeF());
60  bool dumpViewToFormat(const QString& fileName, const QString& format);
61 
62  void addForegroundObject( QSharedPointer<QtViewer_PainterObject> obj) { foregroundObjects.append(obj); }
63  void resetForeground();
64 
65 signals:
66  void vpMouseEvent(QMouseEvent*);
67 
68 
69 public slots:
70  virtual void updateSceneRect(const QRectF &rect);
71 
72 protected:
73 
74  virtual void mousePressEvent(QMouseEvent *event);
75  virtual void mouseMoveEvent(QMouseEvent *event);
76  virtual void mouseReleaseEvent(QMouseEvent *event);
77  virtual void resizeEvent(QResizeEvent *event);
78  virtual void wheelEvent(QWheelEvent *event);
79  virtual void keyPressEvent(QKeyEvent *event);
80 
81  virtual void drawForeground(QPainter *painter, const QRectF &rect);
82 
83  void clearActions();
84 
85 private:
86 
87  double myFitAllGap;
88  QRubberBand* myRectBand;
90  QPoint myRectBandEnd;
91 
93  bool zooming;
94  bool panning;
96  QPoint previousPos;
97  QCursor* zoomCursor;
98 
100 };
101 
102 #endif
#define QTVIEWER_API
Definition: QtViewer.h:29
Definition: QtViewer_PainterObject.h:27
Definition: QtViewer_ViewPort.h:34
bool globalPanning
Definition: QtViewer_ViewPort.h:95
QPoint myRectBandEnd
Definition: QtViewer_ViewPort.h:90
double myFitAllGap
Definition: QtViewer_ViewPort.h:87
QCursor * zoomCursor
Definition: QtViewer_ViewPort.h:97
QPoint previousPos
Definition: QtViewer_ViewPort.h:96
QRubberBand * myRectBand
Definition: QtViewer_ViewPort.h:88
QPoint myRectBandStart
Definition: QtViewer_ViewPort.h:89
bool panning
Definition: QtViewer_ViewPort.h:94
bool fittingArea
Definition: QtViewer_ViewPort.h:92
bool zooming
Definition: QtViewer_ViewPort.h:93
QList< QSharedPointer< QtViewer_PainterObject > > foregroundObjects
Definition: QtViewer_ViewPort.h:99
void addForegroundObject(QSharedPointer< QtViewer_PainterObject > obj)
Definition: QtViewer_ViewPort.h:62
void vpMouseEvent(QMouseEvent *)