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