Salome HOME
Copyright update 2022
[modules/gui.git] / src / QxScene / QxScene_ViewWindow.h
1 // Copyright (C) 2007-2022  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 //  SALOME QxScene : build Supervisor viewer into desktop
21 //
22 #ifndef QXSCENE_VIEWWINDOW_H
23 #define QXSCENE_VIEWWINDOW_H
24
25 #include "QxScene.h"
26 #include "QxScene_ViewModel.h"
27
28 #include "SUIT_ViewWindow.h"
29
30 #include "QtxAction.h"
31
32 #include <qaction.h>
33
34 #include <QGraphicsScene>
35 #include <QGraphicsView>
36
37 #ifdef WIN32
38 #pragma warning ( disable:4251 )
39 #endif
40
41 class SUIT_ResourceMgr;
42
43 class QXSCENE_EXPORT QxScene_ViewWindow : public SUIT_ViewWindow {
44   Q_OBJECT
45
46  public:
47   //! Actions ID
48   enum { FitAllId, FitRectId, ZoomId, ScaleOpId, PanId, GlobalPanId, MoveOpId, ResetId };
49
50   QxScene_ViewWindow(SUIT_Desktop* theDesktop, QxScene_Viewer* theModel);
51   virtual ~QxScene_ViewWindow();
52
53   void              setBackgroundColor( const QColor& );
54   QColor            backgroundColor() const;
55
56   QToolBar*         getToolBar();
57
58   SUIT_ResourceMgr* resMgr() const;
59
60   QxScene_Viewer*   getViewModel() const { return myViewModel; }
61   void              setViewModel(QxScene_Viewer* theViewModel) { myViewModel = theViewModel; }
62
63   virtual void      initLayout();
64
65   void              contextPopupEvent(QContextMenuEvent* theEvent) { emit contextMenuRequested( theEvent); }
66   
67   void              setScene(QGraphicsScene* scene) { _scene = scene; }
68   QGraphicsScene*   getScene() { return _scene; }
69   void              setSceneView(QGraphicsView* sceneView){ _sceneView = sceneView; }
70   QGraphicsView*    getSceneView() { return _sceneView; }
71   virtual bool      closeRequested();
72
73  signals:
74   void              tryClose(bool &isClosed, QxScene_ViewWindow* window);
75
76  public slots:
77   void              onViewFitAll();
78   void              onViewFitArea();
79   void              onViewZoom();
80   void              onViewPan(); 
81   void              onViewGlobalPan(); 
82   void              onViewReset(); 
83   
84  protected:
85   void              resizeEvent( QResizeEvent* );
86
87   QGraphicsScene*   _scene;
88   QGraphicsView*    _sceneView;
89
90  private:
91   void              createActions();
92   void              createToolBar();
93
94   int               myToolBar;
95
96   QxScene_Viewer*   myViewModel;
97 };
98
99 #ifdef WIN32
100 #pragma warning ( default:4251 )
101 #endif
102
103 #endif