Salome HOME
4d29bcc441b1e4bbb6c1cad11267e21f81398ffe
[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 class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame
38 {
39   Q_OBJECT
40
41  public:
42   OCCViewer_ViewFrame(QWidget* parent, const QString& title);
43   OCCViewer_ViewFrame(QWidget* parent = 0);
44   virtual ~OCCViewer_ViewFrame();
45
46  protected:
47   virtual void      initViewPort();
48   void              initialize();
49   void              cleanup();
50
51  public:
52   ViewType          getTypeView() const{ return VIEW_OCC;};
53   QWidget*          getViewWidget();
54   void              setViewPort(OCCViewer_ViewPort* view);
55   OCCViewer_ViewPort*       getViewPort() const;
56
57   void              setViewer(OCCViewer_Viewer3d* viewer);
58   OCCViewer_Viewer3d*     getViewer() const;
59
60   void              setVisible( bool isVisible = true );
61
62   void              setBackgroundColor( const QColor& );
63   QColor            backgroundColor() const;
64
65   void              setCursor( const QCursor& );
66   QCursor           cursor() const;
67
68   void              SetSelectionMode( Selection_Mode mode ) {};
69   
70   /*  popup management */
71   void              setPopupServer( QAD_Application* );
72
73
74   /*  interactive object management */
75   void              highlight( const Handle(SALOME_InteractiveObject)& IObject, 
76                                bool highlight, bool update = true );
77   void              unHighlightAll();
78   void              rename( const Handle(SALOME_InteractiveObject)& IObject,
79                             QString newName );
80   bool              isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
81   bool              isVisible( const Handle(SALOME_InteractiveObject)& IObject );
82
83   /*  undo/redo management */
84   void              undo(QAD_Study* aStudy, const char* StudyFrameEntry);
85   void              redo(QAD_Study* aStudy, const char* StudyFrameEntry);
86
87   /* selection */
88   Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
89
90   /* display */         
91   void           Display(const Handle(SALOME_InteractiveObject)& IObject, bool update = true);
92   void           DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
93   void           Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update = true);
94   void           DisplayAll();
95   void           EraseAll();
96   void           Repaint();
97
98   /* Reimplemented from SALOME_View */
99   void          Display( const SALOME_OCCPrs* );
100   void          Erase( const SALOME_OCCPrs*, const bool = false );
101   SALOME_Prs*   CreatePrs( const char* entry = 0 );
102   virtual void  BeforeDisplay( SALOME_Displayer* d );
103   virtual void  AfterDisplay ( SALOME_Displayer* d );
104   virtual void  LocalSelection( const SALOME_OCCPrs*, const int );
105   virtual void  GlobalSelection( const bool = false ) const;
106
107
108   void          AdjustTrihedrons( const bool forced  = false );
109
110   // Method for activation of sub-shapes selection
111
112
113  protected:     
114   void              closeEvent(QCloseEvent* e);
115   void              resizeEvent(QResizeEvent* e);
116   void              keyPressEvent( QKeyEvent *k );
117
118  signals:
119   void              vfTransformationStarted ( OCCViewer_ViewPort::OperationType );
120   void              vfTransformationFinished( OCCViewer_ViewPort::OperationType );
121   void              vfDrawExternal(QPainter* painter);
122   void              vfMousePress(QMouseEvent*);
123   void              vfMouseRelease(QMouseEvent*);
124   void              vfMouseMove(QMouseEvent*);
125   void              vfMouseDoubleClick(QMouseEvent*);
126   void              vfKeyPress(QKeyEvent*);
127   void              vfKeyRelease(QKeyEvent*);
128   void              vfResize(QResizeEvent*);
129   void              vfPrint(QPaintEvent*);
130   void              vfViewClosing(QCloseEvent*);
131   void              vfMoved (QMoveEvent*);
132
133   public slots:
134
135   void           onViewPan(); 
136   void           onViewZoom();
137   void           onViewFitAll();
138   void           onViewFitArea();
139   void           onViewGlobalPan(); 
140   void           onViewRotate();
141   void           onViewReset();     
142   void           onViewFront(); 
143   void           onViewBack(); 
144   void           onViewRight(); 
145   void           onViewLeft();     
146   void           onViewBottom();
147   void           onViewTop();
148   void           onViewTrihedron(); 
149   void           onAdjustTrihedron();
150
151 private:
152   bool           getTrihedronSize( double& theNewSize, double& theSize ); 
153  
154  protected:
155   OCCViewer_Viewer3d*      myViewer;     // my owner
156   OCCViewer_ViewPort*      myViewPort; // child viewport
157 };
158
159 #endif
160