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