Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / QxScene / QxScene_ViewWindow.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SALOME QxScene : build Supervisor viewer into desktop
23 //
24 #ifndef QXSCENE_VIEWWINDOW_H
25 #define QXSCENE_VIEWWINDOW_H
26
27 #include "QxScene.h"
28 #include "QxScene_ViewModel.h"
29
30 #include "SUIT_ViewWindow.h"
31
32 #include "QtxAction.h"
33
34 #include <qaction.h>
35
36 #include <QGraphicsScene>
37 #include <QGraphicsView>
38
39 #ifdef WIN32
40 #pragma warning ( disable:4251 )
41 #endif
42
43 class SUIT_ResourceMgr;
44
45 class QXSCENE_EXPORT QxScene_ViewWindow : public SUIT_ViewWindow {
46   Q_OBJECT
47
48  public:
49   //! Actions ID
50   enum { FitAllId, FitRectId, ZoomId, ScaleOpId, PanId, GlobalPanId, MoveOpId, ResetId };
51
52   QxScene_ViewWindow(SUIT_Desktop* theDesktop, QxScene_Viewer* theModel);
53   virtual ~QxScene_ViewWindow();
54
55   void              setBackgroundColor( const QColor& );
56   QColor            backgroundColor() const;
57
58   QToolBar*         getToolBar();
59
60   SUIT_ResourceMgr* resMgr() const;
61
62   QxScene_Viewer*   getViewModel() const { return myViewModel; }
63   void              setViewModel(QxScene_Viewer* theViewModel) { myViewModel = theViewModel; }
64
65   virtual void      initLayout();
66
67   void              contextPopupEvent(QContextMenuEvent* theEvent) { emit contextMenuRequested( theEvent); }
68   
69   void              setScene(QGraphicsScene* scene) { _scene = scene; }
70   QGraphicsScene*   getScene() { return _scene; }
71   void              setSceneView(QGraphicsView* sceneView){ _sceneView = sceneView; }
72   QGraphicsView*    getSceneView() { return _sceneView; }
73   virtual bool      closeRequested();
74
75  signals:
76   void              tryClose(bool &isClosed, QxScene_ViewWindow* window);
77
78  public slots:
79   void              onViewFitAll();
80   void              onViewFitArea();
81   void              onViewZoom();
82   void              onViewPan(); 
83   void              onViewGlobalPan(); 
84   void              onViewReset(); 
85   
86  protected:
87   void              resizeEvent( QResizeEvent* theEvent );
88
89   QGraphicsScene*   _scene;
90   QGraphicsView*    _sceneView;
91
92  private:
93   void              createActions();
94   void              createToolBar();
95
96   int               myToolBar;
97
98   QxScene_Viewer*   myViewModel;
99 };
100
101 #ifdef WIN32
102 #pragma warning ( default:4251 )
103 #endif
104
105 #endif