Version: 9.16.0
QtViewer_ViewPort.h
Go to the documentation of this file.
1// Copyright (C) 2013-2026 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
27class QRubberBand;
28
29/*
30 Class : QtViewer_ViewPort
31 Description : View port of the graphics view
32*/
34{
35 Q_OBJECT
36
37public:
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
65signals:
66 void vpMouseEvent(QMouseEvent*);
67
68protected:
69
70 virtual void mousePressEvent(QMouseEvent *event);
71 virtual void mouseMoveEvent(QMouseEvent *event);
72 virtual void mouseReleaseEvent(QMouseEvent *event);
73 virtual void resizeEvent(QResizeEvent *event);
74 virtual void wheelEvent(QWheelEvent *event);
75 virtual void keyPressEvent(QKeyEvent *event);
76
77 virtual void drawForeground(QPainter *painter, const QRectF &rect);
78
79 void clearActions();
80
81private:
82
84 QRubberBand* myRectBand;
87
89 bool zooming;
90 bool panning;
93 QCursor* zoomCursor;
94
96};
97
98#endif
#define QTVIEWER_API
Definition: QtViewer.h:29
Definition: QtViewer_PainterObject.h:27
Definition: QtViewer_ViewPort.h:34
bool globalPanning
Definition: QtViewer_ViewPort.h:91
QPoint myRectBandEnd
Definition: QtViewer_ViewPort.h:86
double myFitAllGap
Definition: QtViewer_ViewPort.h:83
QCursor * zoomCursor
Definition: QtViewer_ViewPort.h:93
QPoint previousPos
Definition: QtViewer_ViewPort.h:92
QRubberBand * myRectBand
Definition: QtViewer_ViewPort.h:84
QPoint myRectBandStart
Definition: QtViewer_ViewPort.h:85
bool panning
Definition: QtViewer_ViewPort.h:90
bool fittingArea
Definition: QtViewer_ViewPort.h:88
bool zooming
Definition: QtViewer_ViewPort.h:89
QList< QSharedPointer< QtViewer_PainterObject > > foregroundObjects
Definition: QtViewer_ViewPort.h:95
void addForegroundObject(QSharedPointer< QtViewer_PainterObject > obj)
Definition: QtViewer_ViewPort.h:62
void vpMouseEvent(QMouseEvent *)