]> SALOME platform Git repositories - modules/gui.git/blob - src/OCCViewer/OCCViewer_ViewModel.h
Salome HOME
Show/Hide trihedron command
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewModel.h
1 #ifndef OCCVIEWER_VIEWMODEL_H
2 #define OCCVIEWER_VIEWMODEL_H
3
4 #include <qcursor.h>
5
6 #include "OCCViewer.h"
7
8 #include "SUIT_ViewModel.h"
9
10 #include <V3d_View.hxx>
11 #include <AIS_Trihedron.hxx>
12 #include <AIS_ListOfInteractive.hxx>
13 #include <AIS_InteractiveContext.hxx>
14
15 class SUIT_ViewWindow;
16 class SUIT_Desktop;
17
18 struct viewAspect
19 {
20 public:
21         double    scale;
22         double  centerX;
23         double  centerY;
24         double    projX;
25         double    projY;
26         double    projZ;
27         double    twist;
28         double      atX;
29         double      atY;
30         double      atZ;
31         double     eyeX;
32         double     eyeY;
33         double     eyeZ;
34         QString    name;
35 };
36
37 typedef QValueList<viewAspect> viewAspectList;
38
39 #ifdef WIN32
40 #pragma warning( disable:4251 )
41 #endif
42
43 class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
44 {
45   Q_OBJECT
46
47 public:
48   static QString Type() { return "OCCViewer"; }
49
50   OCCViewer_Viewer( bool DisplayTrihedron = true );
51         virtual ~OCCViewer_Viewer();
52
53   void update();
54
55         virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
56
57         virtual void                    setViewManager(SUIT_ViewManager* theViewManager);
58   virtual QString                 getType() const { return Type(); }
59
60   virtual void                    contextMenuPopup(QPopupMenu*);
61   
62   void                            getSelectedObjects(AIS_ListOfInteractive& theList);
63   void                            setObjectsSelected(const AIS_ListOfInteractive& theList);
64   void                            setSelected(const Handle(AIS_InteractiveObject)& theIO)
65   { myAISContext->SetSelected(theIO);}
66
67   void                            performSelectionChanged();
68   // emit signal selectionChanged
69
70   virtual const viewAspectList&   getViewAspects();
71   virtual void                    appendViewAspect( const viewAspect& );
72   virtual void                    updateViewAspects( const viewAspectList& );
73   virtual void                    clearViewAspects();
74
75   //! returns true if 3d Trihedron in viewer was created
76   bool trihedronActivated() const { return !myTrihedron.IsNull(); }
77   virtual void toggleTrihedron();
78
79 public slots:
80         void onClearViewAspects();
81
82 public:
83   Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
84   Handle(V3d_Viewer)              getCollector3d() const { return myV3dCollector; }
85   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
86   Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
87
88   void                            enableSelection(bool isEnabled);
89   bool                            isSelectionEnabled() const 
90   { return mySelectionEnabled; }
91
92   void                            enableMultiselection(bool isEnable);
93   bool                            isMultiSelectionEnabled() const 
94   { return myMultiSelectionEnabled; }
95
96   int                             getSelectionCount() const 
97   { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
98
99   /* Selection management */
100   bool          highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
101   bool          unHighlightAll( bool=true ); 
102   bool    isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
103   bool    isVisible( const Handle(AIS_InteractiveObject)& );
104
105   void    setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
106   void    switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
107   void    setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
108
109 signals:
110   void selectionChanged();
111
112 protected slots:
113   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
114   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
115   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
116
117   void onDumpView();
118   void onShowToolbar();
119   void onChangeBgColor();
120
121 private:
122   Handle(V3d_Viewer)              myV3dViewer;
123   Handle(V3d_Viewer)              myV3dCollector;
124   Handle(AIS_InteractiveContext)  myAISContext;
125   Handle(AIS_Trihedron)           myTrihedron;
126
127   viewAspectList                  myViewAspects;
128
129   bool mySelectionEnabled;
130   bool myMultiSelectionEnabled;
131
132   QPoint myStartPnt, myEndPnt;
133 };
134
135 #ifdef WIN32
136 #pragma warning( default:4251 )
137 #endif
138
139 #endif