X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOCCViewer%2FOCCViewer_ViewModel.h;h=685e362b029a80e8950426bd7e7f0fa16589115f;hb=1c1e0526d452336651ccecf48deb5d8227ecdd47;hp=d42be6a251fa8b24c82e197d9d038a1462eb2075;hpb=f29fc3cc1b08feec27fe150a37a82785e42abe3f;p=modules%2Fgui.git diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index d42be6a25..685e362b0 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -1,41 +1,56 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + #ifndef OCCVIEWER_VIEWMODEL_H #define OCCVIEWER_VIEWMODEL_H -#include -#include +#include +#include +#include #include "OCCViewer.h" +#include "OCCViewer_ClipPlane.h" +#include "Qtx.h" #include "SUIT_ViewModel.h" #include #include -#include #include +#include + +class QKeyEvent; +class QMouseEvent; class SUIT_ViewWindow; class SUIT_Desktop; +class OCCViewer_ClippingDlg; +class OCCViewer_ViewWindow; +class OCCViewer_ViewPort3d; -struct viewAspect -{ -public: - double scale; - double centerX; - double centerY; - double projX; - double projY; - double projZ; - double twist; - double atX; - double atY; - double atZ; - double eyeX; - double eyeY; - double eyeZ; - QString name; -}; +class AIS_ListOfInteractive; + +class QtxAction; -typedef QValueList viewAspectList; #ifdef WIN32 #pragma warning( disable:4251 ) @@ -46,35 +61,46 @@ class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel Q_OBJECT public: - static QString Type() { return "OCCViewer"; } + /*! supported gradient types */ + enum { + HorizontalGradient, VerticalGradient, + Diagonal1Gradient, Diagonal2Gradient, + Corner1Gradient, Corner2Gradient, + Corner3Gradient, Corner4Gradient, + LastGradient = Corner4Gradient + }; + + static QString Type() { return "OCCViewer"; } + static QString backgroundData( QStringList&, QIntList&, QIntList& ); - OCCViewer_Viewer( bool DisplayTrihedron = true ); + OCCViewer_Viewer( bool DisplayTrihedron = true); virtual ~OCCViewer_Viewer(); void update(); - virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); - - virtual void setViewManager(SUIT_ViewManager* theViewManager); + virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + + virtual void setViewManager(SUIT_ViewManager* theViewManager); virtual QString getType() const { return Type(); } - virtual void contextMenuPopup(QPopupMenu*); + virtual void contextMenuPopup(QMenu*); void getSelectedObjects(AIS_ListOfInteractive& theList); void setObjectsSelected(const AIS_ListOfInteractive& theList); - void setSelected(const Handle(AIS_InteractiveObject)& theIO) - { myAISContext->SetSelected(theIO);} + void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO);} void performSelectionChanged(); // emit signal selectionChanged - virtual const viewAspectList& getViewAspects(); - virtual void appendViewAspect( const viewAspect& ); - virtual void updateViewAspects( const viewAspectList& ); - virtual void clearViewAspects(); + QColor backgroundColor() const; // obsolete + void setBackgroundColor( const QColor& ); // obsolete + Qtx::BackgroundData background() const; + void setBackground( const Qtx::BackgroundData& ); - QColor backgroundColor() const; - void setBackgroundColor( const QColor& ); + QColor backgroundColor(int theViewId) const; // obsolete + void setBackgroundColor( int theViewId, const QColor& ); // obsolete + Qtx::BackgroundData background(int theViewId) const; + void setBackground( int theViewId, const Qtx::BackgroundData& ); //! returns true if 3d Trihedron in viewer was created bool trihedronActivated() const { return !myTrihedron.IsNull(); } @@ -83,32 +109,61 @@ public: bool isTrihedronVisible() const; virtual void setTrihedronShown( const bool ); - int trihedronSize() const; - virtual void setTrihedronSize( const int ); + double trihedronSize() const; + virtual void setTrihedronSize( const double , bool isRelative = true); + + bool trihedronRelative() const {return myIsRelative; } + + // a utility functions, used by SALOME_View_s methods + bool computeTrihedronSize( double& theNewSize, double& theSize ); + virtual double computeSceneSize(const Handle(V3d_View)&) const; + + void updateTrihedron(); + + + virtual OCCViewer_ViewWindow* createSubWindow(); -public slots: - void onClearViewAspects(); - public: Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;} - Handle(V3d_Viewer) getCollector3d() const { return myV3dCollector; } Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; } Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; } + int getTopLayerId(); + + int interactionStyle() const; + void setInteractionStyle( const int ); + + int zoomingStyle() const; + void setZoomingStyle( const int ); + + void enablePreselection(bool isEnabled); + bool isPreselectionEnabled() const; + void enableSelection(bool isEnabled); - bool isSelectionEnabled() const - { return mySelectionEnabled; } + bool isSelectionEnabled() const; + + void setSelectionOptions( bool, bool ); void enableMultiselection(bool isEnable); - bool isMultiSelectionEnabled() const - { return myMultiSelectionEnabled; } + bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } + + int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; } + + void setStaticTrihedronDisplayed(const bool on); + + /* Clip planes management */ + Handle(Graphic3d_ClipPlane) createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn); + void setClipPlanes (ClipPlanesList theList); + ClipPlanesList getClipPlanes() const; + void applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject); - int getSelectionCount() const - { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; } + OCCViewer_ClippingDlg* getClippingDlg() const; + void setClippingDlg(OCCViewer_ClippingDlg* theDlg); + /* Selection management */ - bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); - bool unHighlightAll( bool=true ); + bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); + bool unHighlightAll( bool=true, bool=true ); bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false ); bool isVisible( const Handle(AIS_InteractiveObject)& ); @@ -118,32 +173,50 @@ public: void setIsos( const int u, const int v ); // number of isolines void isos( int& u, int& v ) const; + void initView( OCCViewer_ViewWindow* view ); + signals: void selectionChanged(); + void deselection(); protected slots: - void onMousePress(SUIT_ViewWindow*, QMouseEvent*); - void onMouseMove(SUIT_ViewWindow*, QMouseEvent*); - void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); + virtual void onMousePress(SUIT_ViewWindow*, QMouseEvent*); + virtual void onMouseMove(SUIT_ViewWindow*, QMouseEvent*); + virtual void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); + virtual void onKeyPress(SUIT_ViewWindow*, QKeyEvent*); + virtual void onViewClosed(OCCViewer_ViewPort3d*); + virtual void onViewMapped(OCCViewer_ViewPort3d*); void onDumpView(); - void onShowToolbar(); - void onChangeBgColor(); + void onChangeBackground(); -private: +protected: Handle(V3d_Viewer) myV3dViewer; - Handle(V3d_Viewer) myV3dCollector; Handle(AIS_Trihedron) myTrihedron; Handle(AIS_InteractiveContext) myAISContext; - viewAspectList myViewAspects; + int myInteractionStyle; + int myZoomingStyle; + bool myPreselectionEnabled; bool mySelectionEnabled; bool myMultiSelectionEnabled; + bool myIsRelative; + + int myTopLayerId; + + //QColor myBgColor; + QPoint myStartPnt, myEndPnt, myCurPnt; + + double myTrihedronSize; + + QVector myBackgrounds; + + OCCViewer_ClippingDlg* myClippingDlg; - QColor myBgColor; - QPoint myStartPnt, myEndPnt; + ClipPlanesList myClipPlanes; + Graphic3d_SequenceOfHClipPlane myInternalClipPlanes; }; #ifdef WIN32