Salome HOME
PR: merge from tag mergeto_trunk_17Jan05
[modules/kernel.git] / src / OCCViewer / OCCViewer_ViewFrame.h
1 //  SALOME OCCViewer : build OCC Viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : OCCViewer_ViewFrame.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$           
28
29 #ifndef OCCViewer_ViewFrame_H
30 #define OCCViewer_ViewFrame_H
31
32 #include "OCCViewer_ViewPort.h"
33 #include "QAD_ViewFrame.h"
34 #include "SALOME_Selection.h"
35
36 class OCCViewer_Viewer3d;
37
38 /*
39   Class       : OCCViewer_ViewFrame
40   Description : View frame for Open CASCADE view
41 */
42
43 class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame
44 {
45   Q_OBJECT
46
47 public:
48
49                               OCCViewer_ViewFrame( QWidget* parent, const QString& title );
50                               OCCViewer_ViewFrame( QWidget* parent = 0 );
51   virtual                     ~OCCViewer_ViewFrame();
52
53   /*
54     Reimplemented from QAD_ViewFrame
55   */
56
57   virtual ViewType            getTypeView() const { return VIEW_OCC; }
58   virtual QWidget*            getViewWidget();
59   virtual void                setBackgroundColor( const QColor& );
60   virtual QColor              backgroundColor() const;
61   virtual void                SetSelectionMode( Selection_Mode mode ) {};
62
63   /*  popup management */
64   
65   virtual void                setPopupServer( QAD_Application* );
66
67   /*  interactive object management */
68
69   virtual void                highlight( const Handle(SALOME_InteractiveObject)&,
70                                          const bool highlight,
71                                          const bool update = true );
72   virtual void                unHighlightAll();
73   virtual void                rename( const Handle(SALOME_InteractiveObject)&,
74                                       QString );
75   virtual bool                isInViewer( const Handle(SALOME_InteractiveObject)& );
76   virtual bool                isVisible( const Handle(SALOME_InteractiveObject)& );
77
78   /*  undo/redo management */
79   
80   void                        undo( QAD_Study* aStudy, const char* StudyFrameEntry );
81   void                        redo( QAD_Study* aStudy, const char* StudyFrameEntry );
82
83   /* selection */
84   
85   virtual Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
86
87   /* display */
88   virtual void                Display( const Handle(SALOME_InteractiveObject)&,
89                                        bool update = true);
90   virtual void                DisplayOnly( const Handle(SALOME_InteractiveObject)& );
91   virtual void                Erase( const Handle(SALOME_InteractiveObject)&,
92                                      bool update = true);
93   virtual void                DisplayAll();
94   virtual void                EraseAll();
95   virtual void                Repaint();
96
97   void                        AdjustTrihedrons( const bool forced  = false );
98
99   /* Reimplemented from SALOME_View */
100   
101   virtual void                Display( const SALOME_OCCPrs* );
102   virtual void                Erase( const SALOME_OCCPrs*, const bool = false );
103   virtual SALOME_Prs*         CreatePrs( const char* entry = 0 );
104   virtual void                BeforeDisplay( SALOME_Displayer* d );
105   virtual void                AfterDisplay ( SALOME_Displayer* d );
106   virtual void                LocalSelection( const SALOME_OCCPrs*, const int );
107   virtual void                GlobalSelection( const bool = false ) const;
108
109   /* Own public methods */
110   
111   void                        setViewPort( OCCViewer_ViewPort* );
112   OCCViewer_ViewPort*         getViewPort() const;
113
114   void                        setViewer( OCCViewer_Viewer3d* );
115   OCCViewer_Viewer3d*         getViewer() const;
116
117   void                        setVisible( const bool isVisible = true );
118
119   void                        setCursor( const QCursor& );
120   QCursor                     cursor() const;
121
122 signals:
123
124   void                        vfTransformationStarted ( OCCViewer_ViewPort::OperationType );
125   void                        vfTransformationFinished( OCCViewer_ViewPort::OperationType );
126   void                        vfDrawExternal( QPainter* painter );
127   void                        vfMousePress( QMouseEvent* );
128   void                        vfMouseRelease( QMouseEvent* );
129   void                        vfMouseMove( QMouseEvent* );
130   void                        vfMouseDoubleClick( QMouseEvent* );
131   void                        vfKeyPress( QKeyEvent* );
132   void                        vfKeyRelease( QKeyEvent* );
133   void                        vfResize( QResizeEvent* );
134   void                        vfPrint( QPaintEvent* );
135   void                        vfViewClosing( QCloseEvent* );
136   void                        vfMoved ( QMoveEvent* );
137
138 public slots:
139
140   void                        onViewPan();
141   void                        onViewZoom();
142   void                        onViewFitAll();
143   void                        onViewFitArea();
144   void                        onViewGlobalPan();
145   void                        onViewRotate();
146   void                        onViewReset();
147   void                        onViewFront();
148   void                        onViewBack();
149   void                        onViewRight();
150   void                        onViewLeft();
151   void                        onViewBottom();
152   void                        onViewTop();
153   void                        onViewTrihedron();
154   void                        onAdjustTrihedron();
155
156   void                        onPanLeft();
157   void                        onPanRight();
158   void                        onPanUp();
159   void                        onPanDown();
160   void                        onZoomIn();
161   void                        onZoomOut();
162   void                        onRotateLeft();
163   void                        onRotateRight();
164   void                        onRotateUp();
165   void                        onRotateDown();
166
167 protected:
168
169   void                        initViewPort();
170   void                        initialize();
171   void                        cleanup();
172   void                        closeEvent( QCloseEvent* );
173   void                        resizeEvent( QResizeEvent* );
174   void                        keyPressEvent( QKeyEvent * );
175 private:
176
177   bool                        getTrihedronSize( double& theNewSize, double& theSize );
178   void                        redisplayAll( QAD_Study*, const bool = true );
179  
180 private:
181
182   OCCViewer_Viewer3d*         myViewer;  // my owner
183   OCCViewer_ViewPort*         myViewPort; // child viewport
184 };
185
186 #endif
187