Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / OCCViewer / OCCViewer_Viewer3d.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_Viewer3d.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef OCCVIEWER_VIEWER3D_H
30 #define OCCVIEWER_VIEWER3D_H
31
32 #include "OCCViewer_ViewPort.h"
33 #include "QAD.h"
34 #include "QAD_Popup.h"
35 #include "QAD_ViewFrame.h"
36 #include "SALOME_InteractiveObject.hxx"
37
38 // Open CASCADE Includes
39 #include <AIS_InteractiveContext.hxx>
40 #include <AIS_Trihedron.hxx>
41
42 class OCCViewer_ViewFrame;
43 class OCCViewer_AISSelector;
44
45 class QAD_EXPORT OCCViewer_Viewer3d : public QObject, public QAD_PopupClientServer
46 {
47   Q_OBJECT
48
49 public:
50   OCCViewer_Viewer3d(OCCViewer_ViewFrame* vf);
51   ~OCCViewer_Viewer3d();
52
53 signals:
54   void          vwKeyPress( QKeyEvent* );
55   void          vwKeyRelease( QKeyEvent* );
56   void          vwDrawExternal( QPainter* );
57
58 public slots:
59  void           onKeyPress(QKeyEvent*);
60
61  void           onMouseMove(QMouseEvent*);
62  void           onMousePress(QMouseEvent*);
63  void           onMouseRelease(QMouseEvent*);
64  void           onMouseDoubleClick(QMouseEvent*);
65
66  void           onSelectionDone( bool bAdded );
67  void           onSelectionCancel( bool bAdded );
68
69  void           onTransformationStarted( OCCViewer_ViewPort::OperationType );
70  void           onTransformationFinished( OCCViewer_ViewPort::OperationType );
71
72 signals:
73  void           vw3dSelectionDone (bool added);
74  void           vw3dSelectionCancel();
75  void           vw3dSelectionEnabled( bool );
76
77 public:
78  void               createViewer3d();
79  Handle(V3d_Viewer) getViewer3d() const;
80
81  void               setTrihedronSize(float size);
82  bool               isTrihedronDisplayed();
83
84   /* popup management */
85   void              onCreatePopup();
86
87   void              setCursor( const QCursor& cursor);
88   const QCursor&    cursor() const;
89   void              setIcon( const QPixmap& icon);
90   const QPixmap&    icon() const;
91   void              setBackgroundColor( const QColor& aColor);
92   const QColor&     backgroundColor() const;
93
94   /* Selection management */
95   bool          highlight( const Handle(SALOME_InteractiveObject)& IObject,
96                            bool highlight, bool update=true); 
97   bool          unHighlightAll(); 
98   bool          isInViewer( const Handle(SALOME_InteractiveObject)& IObject,
99                             bool onlyInViewer = false );
100   bool          isVisible( const Handle(SALOME_InteractiveObject)& IObject );
101   void          rename( const Handle(SALOME_InteractiveObject)& IObject,
102                         QString newName );
103
104   bool          enabledSelection() const;
105   void          enableSelection( bool );
106   void          enableMultipleSelection( bool );
107
108   void          SetColor(const Handle(SALOME_InteractiveObject)& IObject,
109                          QColor thecolor);
110   void          SwitchRepresentation(const Handle(SALOME_InteractiveObject)& IObject,
111                                      int mode);
112   void          SetTransparency(const Handle(SALOME_InteractiveObject)& IObject,
113                                 float transp);
114
115   /* interactive context */
116   Handle (AIS_InteractiveContext) getAISContext() const;
117   OCCViewer_AISSelector*          getAISSelector() const;
118
119   /* trihedron */
120   Handle(AIS_Trihedron)           getTrihedron() const;
121
122 protected:
123  bool        eventFilter( QObject *, QEvent * );
124
125 protected:
126  OCCViewer_ViewFrame*            myViewFrame;
127
128 private:
129
130   void                   globalSelectionDone( const bool );
131   void                   localSelectionDone ( const bool );
132
133  Handle (AIS_InteractiveContext) myAISContext;
134  OCCViewer_AISSelector*          myAISSelector;
135  bool                            myEnableSelection;
136  Handle(AIS_Trihedron)           myTrihedron;
137  Handle(V3d_Viewer)              myV3dViewer;
138  Handle(V3d_Viewer)              myV3dCollector;
139
140  /* attributes for all the views */
141  QPixmap                         myIcon;        /* icon */
142  QCursor                         myCursor;      /* current cursor */
143  QColor                          myBackColor;   /* background */
144
145 };
146
147 #endif
148