1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #ifndef OCCVIEWER_VIEWMODEL_H
20 #define OCCVIEWER_VIEWMODEL_H
25 #include "OCCViewer.h"
27 #include "SUIT_ViewModel.h"
29 #include <V3d_View.hxx>
30 #include <AIS_Trihedron.hxx>
31 #include <AIS_ListOfInteractive.hxx>
32 #include <AIS_InteractiveContext.hxx>
34 class SUIT_ViewWindow;
36 class OCCViewer_ViewWindow;
57 typedef QValueList<viewAspect> viewAspectList;
60 #pragma warning( disable:4251 )
63 class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
68 static QString Type() { return "OCCViewer"; }
70 OCCViewer_Viewer( bool DisplayTrihedron = true );
71 virtual ~OCCViewer_Viewer();
75 virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
77 virtual void setViewManager(SUIT_ViewManager* theViewManager);
78 virtual QString getType() const { return Type(); }
80 virtual void contextMenuPopup(QPopupMenu*);
82 void getSelectedObjects(AIS_ListOfInteractive& theList);
83 void setObjectsSelected(const AIS_ListOfInteractive& theList);
84 void setSelected(const Handle(AIS_InteractiveObject)& theIO)
85 { myAISContext->SetSelected(theIO);}
87 void performSelectionChanged();
88 // emit signal selectionChanged
90 virtual const viewAspectList& getViewAspects();
91 virtual void appendViewAspect( const viewAspect& );
92 virtual void updateViewAspects( const viewAspectList& );
93 virtual void clearViewAspects();
95 QColor backgroundColor() const;
96 void setBackgroundColor( const QColor& );
98 //! returns true if 3d Trihedron in viewer was created
99 bool trihedronActivated() const { return !myTrihedron.IsNull(); }
101 void toggleTrihedron();
102 bool isTrihedronVisible() const;
103 virtual void setTrihedronShown( const bool );
105 int trihedronSize() const;
106 virtual void setTrihedronSize( const int );
109 void onClearViewAspects();
112 Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;}
113 Handle(V3d_Viewer) getCollector3d() const { return myV3dCollector; }
114 Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; }
115 Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; }
117 void enableSelection(bool isEnabled);
118 bool isSelectionEnabled() const
119 { return mySelectionEnabled; }
121 void enableMultiselection(bool isEnable);
122 bool isMultiSelectionEnabled() const
123 { return myMultiSelectionEnabled; }
125 int getSelectionCount() const
126 { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
128 /* Selection management */
129 bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
130 bool unHighlightAll( bool=true );
131 bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
132 bool isVisible( const Handle(AIS_InteractiveObject)& );
134 void setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
135 void switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
136 void setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
137 void setIsos( const int u, const int v ); // number of isolines
138 void isos( int& u, int& v ) const;
141 void selectionChanged();
144 void initView( OCCViewer_ViewWindow* view );
147 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
148 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
149 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
152 void onShowToolbar();
153 void onChangeBgColor();
156 Handle(V3d_Viewer) myV3dViewer;
157 Handle(V3d_Viewer) myV3dCollector;
159 Handle(AIS_Trihedron) myTrihedron;
160 Handle(AIS_InteractiveContext) myAISContext;
162 viewAspectList myViewAspects;
164 bool mySelectionEnabled;
165 bool myMultiSelectionEnabled;
168 QPoint myStartPnt, myEndPnt;
172 #pragma warning( default:4251 )