1 #ifndef OCCVIEWER_VIEWMODEL_H
2 #define OCCVIEWER_VIEWMODEL_H
9 #include "SUIT_ViewModel.h"
11 #include <V3d_View.hxx>
12 #include <AIS_Trihedron.hxx>
13 #include <AIS_ListOfInteractive.hxx>
14 #include <AIS_InteractiveContext.hxx>
16 class SUIT_ViewWindow;
18 class OCCViewer_ViewWindow;
39 typedef QValueList<viewAspect> viewAspectList;
42 #pragma warning( disable:4251 )
45 class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
50 static QString Type() { return "OCCViewer"; }
52 OCCViewer_Viewer( bool DisplayTrihedron = true );
53 virtual ~OCCViewer_Viewer();
57 virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
59 virtual void setViewManager(SUIT_ViewManager* theViewManager);
60 virtual QString getType() const { return Type(); }
62 virtual void contextMenuPopup(QPopupMenu*);
64 void getSelectedObjects(AIS_ListOfInteractive& theList);
65 void setObjectsSelected(const AIS_ListOfInteractive& theList);
66 void setSelected(const Handle(AIS_InteractiveObject)& theIO)
67 { myAISContext->SetSelected(theIO);}
69 void performSelectionChanged();
70 // emit signal selectionChanged
72 virtual const viewAspectList& getViewAspects();
73 virtual void appendViewAspect( const viewAspect& );
74 virtual void updateViewAspects( const viewAspectList& );
75 virtual void clearViewAspects();
77 QColor backgroundColor() const;
78 void setBackgroundColor( const QColor& );
80 //! returns true if 3d Trihedron in viewer was created
81 bool trihedronActivated() const { return !myTrihedron.IsNull(); }
83 void toggleTrihedron();
84 bool isTrihedronVisible() const;
85 virtual void setTrihedronShown( const bool );
87 int trihedronSize() const;
88 virtual void setTrihedronSize( const int );
91 void onClearViewAspects();
94 Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;}
95 Handle(V3d_Viewer) getCollector3d() const { return myV3dCollector; }
96 Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; }
97 Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; }
99 void enableSelection(bool isEnabled);
100 bool isSelectionEnabled() const
101 { return mySelectionEnabled; }
103 void enableMultiselection(bool isEnable);
104 bool isMultiSelectionEnabled() const
105 { return myMultiSelectionEnabled; }
107 int getSelectionCount() const
108 { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
110 /* Selection management */
111 bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
112 bool unHighlightAll( bool=true );
113 bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
114 bool isVisible( const Handle(AIS_InteractiveObject)& );
116 void setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
117 void switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
118 void setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
119 void setIsos( const int u, const int v ); // number of isolines
120 void isos( int& u, int& v ) const;
123 void selectionChanged();
126 void initView( OCCViewer_ViewWindow* view );
129 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
130 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
131 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
134 void onShowToolbar();
135 void onChangeBgColor();
138 Handle(V3d_Viewer) myV3dViewer;
139 Handle(V3d_Viewer) myV3dCollector;
141 Handle(AIS_Trihedron) myTrihedron;
142 Handle(AIS_InteractiveContext) myAISContext;
144 viewAspectList myViewAspects;
146 bool mySelectionEnabled;
147 bool myMultiSelectionEnabled;
150 QPoint myStartPnt, myEndPnt;
154 #pragma warning( default:4251 )