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