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;
38 typedef QValueList<viewAspect> viewAspectList;
41 #pragma warning( disable:4251 )
44 class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
49 static QString Type() { return "OCCViewer"; }
51 OCCViewer_Viewer( bool DisplayTrihedron = true );
52 virtual ~OCCViewer_Viewer();
56 virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
58 virtual void setViewManager(SUIT_ViewManager* theViewManager);
59 virtual QString getType() const { return Type(); }
61 virtual void contextMenuPopup(QPopupMenu*);
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);}
68 void performSelectionChanged();
69 // emit signal selectionChanged
71 virtual const viewAspectList& getViewAspects();
72 virtual void appendViewAspect( const viewAspect& );
73 virtual void updateViewAspects( const viewAspectList& );
74 virtual void clearViewAspects();
76 QColor backgroundColor() const;
77 void setBackgroundColor( const QColor& );
79 //! returns true if 3d Trihedron in viewer was created
80 bool trihedronActivated() const { return !myTrihedron.IsNull(); }
82 void toggleTrihedron();
83 bool isTrihedronVisible() const;
84 virtual void setTrihedronShown( const bool );
86 int trihedronSize() const;
87 virtual void setTrihedronSize( const int );
90 void onClearViewAspects();
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; }
98 void enableSelection(bool isEnabled);
99 bool isSelectionEnabled() const
100 { return mySelectionEnabled; }
102 void enableMultiselection(bool isEnable);
103 bool isMultiSelectionEnabled() const
104 { return myMultiSelectionEnabled; }
106 int getSelectionCount() const
107 { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
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)& );
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 );
120 void selectionChanged();
123 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
124 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
125 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
128 void onShowToolbar();
129 void onChangeBgColor();
132 Handle(V3d_Viewer) myV3dViewer;
133 Handle(V3d_Viewer) myV3dCollector;
135 Handle(AIS_Trihedron) myTrihedron;
136 Handle(AIS_InteractiveContext) myAISContext;
138 viewAspectList myViewAspects;
140 bool mySelectionEnabled;
141 bool myMultiSelectionEnabled;
144 QPoint myStartPnt, myEndPnt;
148 #pragma warning( default:4251 )