Version: 6.3.1

src/OCCViewer/OCCViewer_ViewModel.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef OCCVIEWER_VIEWMODEL_H
00024 #define OCCVIEWER_VIEWMODEL_H
00025 
00026 #include <QColor>
00027 #include <QPoint>
00028 #include <QVector>
00029 
00030 #include "OCCViewer.h"
00031 
00032 #include "SUIT_ViewModel.h"
00033 
00034 #include <V3d_View.hxx>
00035 #include <AIS_Trihedron.hxx>
00036 #include <AIS_InteractiveContext.hxx>
00037 
00038 class QKeyEvent;
00039 class QMouseEvent;
00040 
00041 class SUIT_ViewWindow;
00042 class SUIT_Desktop;
00043 class OCCViewer_ViewWindow;
00044 
00045 class AIS_ListOfInteractive;
00046 
00047 #ifdef WIN32
00048 #pragma warning( disable:4251 )
00049 #endif
00050 
00051 class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
00052 {
00053   Q_OBJECT
00054 
00055 public:
00056   static QString Type() { return "OCCViewer"; }
00057 
00058   OCCViewer_Viewer( bool DisplayTrihedron = true, bool DisplayStaticTrihedron = true );
00059   virtual ~OCCViewer_Viewer();
00060 
00061   void update();
00062 
00063   virtual SUIT_ViewWindow*        createView(SUIT_Desktop* theDesktop);
00064   
00065   virtual void                    setViewManager(SUIT_ViewManager* theViewManager);
00066   virtual QString                 getType() const { return Type(); }
00067 
00068   virtual void                    contextMenuPopup(QMenu*);
00069   
00070   void                            getSelectedObjects(AIS_ListOfInteractive& theList);
00071   void                            setObjectsSelected(const AIS_ListOfInteractive& theList);
00072   void                            setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO);}
00073 
00074   void                            performSelectionChanged();
00075   // emit signal selectionChanged
00076 
00077   QColor                          backgroundColor() const;
00078   void                            setBackgroundColor( const QColor& );
00079 
00080   QColor                          backgroundColor(int theViewId) const;
00081   void                            setBackgroundColor( int theViewId, const QColor& );
00082 
00084   bool                            trihedronActivated() const { return !myTrihedron.IsNull(); }
00085 
00086   void                            toggleTrihedron();
00087   bool                            isTrihedronVisible() const;
00088   virtual void                    setTrihedronShown( const bool );
00089 
00090   double                          trihedronSize() const;
00091   virtual void                    setTrihedronSize( const double );
00092 
00093   virtual OCCViewer_ViewWindow*   createSubWindow();
00094 
00095 public:
00096   Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
00097   Handle(V3d_Viewer)              getCollector3d() const { return myV3dCollector; }
00098   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
00099   Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
00100 
00101   int                             interactionStyle() const;
00102   void                            setInteractionStyle( const int );
00103 
00104   int                             zoomingStyle() const;
00105   void                            setZoomingStyle( const int );
00106 
00107   void                            enableSelection(bool isEnabled);
00108   bool                            isSelectionEnabled() const { return mySelectionEnabled; }
00109 
00110   void                            enableMultiselection(bool isEnable);
00111   bool                            isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
00112 
00113   int                             getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
00114   bool                            isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
00115 
00116   /* Selection management */
00117   bool    highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
00118   bool    unHighlightAll( bool=true ); 
00119   bool    isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
00120   bool    isVisible( const Handle(AIS_InteractiveObject)& );
00121 
00122   void    setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
00123   void    switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
00124   void    setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
00125   void    setIsos( const int u, const int v ); // number of isolines
00126   void    isos( int& u, int& v ) const;
00127 
00128   void    initView( OCCViewer_ViewWindow* view );
00129 
00130 signals:
00131   void selectionChanged();
00132   void deselection();
00133 
00134 protected:
00135 
00136 protected slots:
00137   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
00138   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
00139   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
00140   void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
00141 
00142   void onDumpView();
00143   void onChangeBgColor();
00144 
00145 private:
00146   Handle(V3d_Viewer)              myV3dViewer;
00147   Handle(V3d_Viewer)              myV3dCollector;
00148 
00149   Handle(AIS_Trihedron)           myTrihedron;
00150   Handle(AIS_InteractiveContext)  myAISContext;
00151 
00152   int                             myInteractionStyle;
00153   int                             myZoomingStyle;
00154 
00155   bool                            mySelectionEnabled;
00156   bool                            myMultiSelectionEnabled;
00157 
00158   //QColor                          myBgColor;
00159   QPoint                          myStartPnt, myEndPnt;
00160 
00161   bool                            myShowStaticTrihedron;
00162 
00163   QVector<QColor>                 myColors;
00164 };
00165 
00166 #ifdef WIN32
00167 #pragma warning( default:4251 )
00168 #endif
00169 
00170 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS