Salome HOME
updated copyright message
[modules/gui.git] / src / GraphicsView / GraphicsView_ViewFrame.h
1 // Copyright (C) 2013-2023  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 GRAPHICSVIEW_VIEWFRAME_H
21 #define GRAPHICSVIEW_VIEWFRAME_H
22
23 #include "GraphicsView.h"
24
25 #include <SUIT_ViewWindow.h>
26 #include <QPainterPath>
27
28 class QGraphicsSceneContextMenuEvent;
29 class QGraphicsSceneMouseEvent;
30 class QGraphicsSceneWheelEvent;
31
32 class QAction;
33
34 class SUIT_Desktop;
35
36 class GraphicsView_Viewer;
37 class GraphicsView_ViewPort;
38
39 /*
40   Class       : GraphicsView_ViewFrame
41   Description : View frame of the graphics view
42 */
43 class GRAPHICSVIEW_API GraphicsView_ViewFrame : public SUIT_ViewWindow
44 {
45   Q_OBJECT
46
47 public:
48   enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId };
49
50 public:
51   GraphicsView_ViewFrame( SUIT_Desktop*, GraphicsView_Viewer*, QWidget* w = NULL );
52   ~GraphicsView_ViewFrame();
53
54   GraphicsView_Viewer*    getViewer() const { return myViewer; }
55   GraphicsView_ViewPort*  getViewPort() const  { return myViewPort; }
56
57   virtual QImage          dumpView();
58   
59   virtual QString         getVisualParameters();
60   virtual void            setVisualParameters( const QString& theParameters );
61
62   virtual void            expandToolBarActions();
63   int                     getToolBarId();
64
65 public slots:
66   virtual void showEvent( QShowEvent* );
67   virtual void hideEvent( QHideEvent* );
68
69 protected slots:
70   void                    onViewPan();
71   void                    onViewZoom();
72   void                    onViewFitAll();
73   void                    onViewFitArea();
74   void                    onViewFitSelect();
75   void                    onViewGlobalPan();
76   void                    onViewReset();
77
78 private slots:
79   void                    keyEvent( QKeyEvent* );
80   void                    mouseEvent( QGraphicsSceneMouseEvent* );
81   void                    wheelEvent( QGraphicsSceneWheelEvent* );
82   void                    contextMenuEvent( QGraphicsSceneContextMenuEvent* );
83
84 signals:
85   void                    keyPressed( QKeyEvent* );
86   void                    keyReleased( QKeyEvent* );
87   void                    mousePressed( QGraphicsSceneMouseEvent* );
88   void                    mouseMoving( QGraphicsSceneMouseEvent* );
89   void                    mouseReleased( QGraphicsSceneMouseEvent* );
90   void                    mouseDoubleClicked( QGraphicsSceneMouseEvent* );
91   void                    wheeling( QGraphicsSceneWheelEvent* );
92
93   void                    sketchingFinished( QPainterPath );
94
95   void Show( QShowEvent* );
96   void Hide( QHideEvent* );
97
98 protected:
99   virtual void            createActions();
100   virtual int             createToolBar();
101   virtual QString         filter() const;
102   virtual bool            dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
103
104 private:
105   GraphicsView_Viewer*    myViewer;
106   GraphicsView_ViewPort*  myViewPort;
107
108   int                     myToolBarId;
109   QAction*                myScaleAction;
110   QAction*                myPanAction;
111 };
112
113 #endif