1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef OCCVIEWER_VIEWMODEL_H
23 #define OCCVIEWER_VIEWMODEL_H
28 #include "OCCViewer.h"
30 #include "SUIT_ViewModel.h"
32 #include <V3d_View.hxx>
33 #include <AIS_Trihedron.hxx>
34 #include <AIS_InteractiveContext.hxx>
38 class SUIT_ViewWindow;
40 class OCCViewer_ViewWindow;
42 class AIS_ListOfInteractive;
68 typedef QList<viewAspect> viewAspectList;
71 #pragma warning( disable:4251 )
74 class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
79 static QString Type() { return "OCCViewer"; }
81 OCCViewer_Viewer( bool DisplayTrihedron = true, bool DisplayStaticTrihedron = true );
82 virtual ~OCCViewer_Viewer();
86 virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
88 virtual void setViewManager(SUIT_ViewManager* theViewManager);
89 virtual QString getType() const { return Type(); }
91 virtual void contextMenuPopup(QMenu*);
93 void getSelectedObjects(AIS_ListOfInteractive& theList);
94 void setObjectsSelected(const AIS_ListOfInteractive& theList);
95 void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO);}
97 void performSelectionChanged();
98 // emit signal selectionChanged
100 virtual const viewAspectList& getViewAspects();
101 virtual void appendViewAspect( const viewAspect& );
102 virtual void updateViewAspects( const viewAspectList& );
103 virtual void clearViewAspects();
105 QColor backgroundColor() const;
106 void setBackgroundColor( const QColor& );
108 //! returns true if 3d Trihedron in viewer was created
109 bool trihedronActivated() const { return !myTrihedron.IsNull(); }
111 void toggleTrihedron();
112 bool isTrihedronVisible() const;
113 virtual void setTrihedronShown( const bool );
115 double trihedronSize() const;
116 virtual void setTrihedronSize( const double );
119 void onClearViewAspects();
122 Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;}
123 Handle(V3d_Viewer) getCollector3d() const { return myV3dCollector; }
124 Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; }
125 Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; }
127 void enableSelection(bool isEnabled);
128 bool isSelectionEnabled() const { return mySelectionEnabled; }
130 void enableMultiselection(bool isEnable);
131 bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
133 int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
134 bool isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
136 /* Selection management */
137 bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
138 bool unHighlightAll( bool=true );
139 bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
140 bool isVisible( const Handle(AIS_InteractiveObject)& );
142 void setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
143 void switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
144 void setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
145 void setIsos( const int u, const int v ); // number of isolines
146 void isos( int& u, int& v ) const;
149 void selectionChanged();
153 void initView( OCCViewer_ViewWindow* view );
156 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
157 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
158 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
161 void onChangeBgColor();
164 Handle(V3d_Viewer) myV3dViewer;
165 Handle(V3d_Viewer) myV3dCollector;
167 Handle(AIS_Trihedron) myTrihedron;
168 Handle(AIS_InteractiveContext) myAISContext;
170 viewAspectList myViewAspects;
172 bool mySelectionEnabled;
173 bool myMultiSelectionEnabled;
176 QPoint myStartPnt, myEndPnt;
178 bool myShowStaticTrihedron;
182 #pragma warning( default:4251 )