Salome HOME
Properly process show/hide static trihedron in OCC view
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewModel.h
index 46c1e47869abe9157c08d9619b49bccf03444ac1..5e2e955b38192864e1c8435dddc3266ddb8b44d4 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// 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
@@ -6,7 +6,7 @@
 // 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.
+// 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
@@ -28,6 +28,7 @@
 #include <QVector>
 
 #include "OCCViewer.h"
+#include "OCCViewer_ClipPlane.h"
 
 #include "Qtx.h"
 #include "SUIT_ViewModel.h"
 #include <V3d_View.hxx>
 #include <AIS_Trihedron.hxx>
 #include <AIS_InteractiveContext.hxx>
+#include <Basics_OCCTVersion.hxx>
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
 
 class QKeyEvent;
 class QMouseEvent;
 
 class SUIT_ViewWindow;
 class SUIT_Desktop;
+class OCCViewer_ClippingDlg;
 class OCCViewer_ViewWindow;
+class OCCViewer_ViewPort3d;
 
 class AIS_ListOfInteractive;
 
+class QtxAction;
+
+
 #ifdef WIN32
 #pragma warning( disable:4251 )
 #endif
@@ -107,8 +115,9 @@ public:
   
   bool                            trihedronRelative() const {return myIsRelative; }
 
-  // a utility function, used by SALOME_View_s methods
+  // 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();
   
@@ -117,7 +126,9 @@ public:
 
 public:
   Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
+#if OCC_VERSION_LARGE <= 0x06060000 
   Handle(V3d_Viewer)              getCollector3d() const { return myV3dCollector; }
+#endif
   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
   Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
 
@@ -129,20 +140,33 @@ public:
   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; }
 
   int                             getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
 
-  bool                            isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
   void                            setStaticTrihedronDisplayed(const bool on);
 
+  /* Clip planes management */
+  void                            setClipPlanes (ClipPlanesList theList);
+  ClipPlanesList                  getClipPlanes() const;
+  void                            applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject);
+
+  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    unHighlightAll( bool=true, bool=true ); 
   bool    isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
   bool    isVisible( const Handle(AIS_InteractiveObject)& );
 
@@ -163,21 +187,27 @@ protected slots:
   virtual void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
-  virtual void onViewClosed();
+  virtual void onViewClosed(OCCViewer_ViewPort3d*);
+  virtual void onViewMapped(OCCViewer_ViewPort3d*);
 
   void onDumpView();
   void onChangeBackground();
 
 protected:
   Handle(V3d_Viewer)              myV3dViewer;
+
+#if OCC_VERSION_LARGE <= 0x06060000
   Handle(V3d_Viewer)              myV3dCollector;
+#endif
+
 
   Handle(AIS_Trihedron)           myTrihedron;
-  Handle(AIS_InteractiveContext)  myAISContext;  
+  Handle(AIS_InteractiveContext)  myAISContext;
 
   int                             myInteractionStyle;
   int                             myZoomingStyle;
 
+  bool                            myPreselectionEnabled;
   bool                            mySelectionEnabled;
   bool                            myMultiSelectionEnabled;
   bool                            myIsRelative;
@@ -185,13 +215,16 @@ protected:
   int                             myTopLayerId;
 
   //QColor                          myBgColor;
-  QPoint                          myStartPnt, myEndPnt;
-
-  bool                            myShowStaticTrihedron;
+  QPoint                          myStartPnt, myEndPnt, myCurPnt;
 
   double                          myTrihedronSize;
 
   QVector<Qtx::BackgroundData>    myBackgrounds;
+
+  OCCViewer_ClippingDlg*          myClippingDlg;
+
+  ClipPlanesList                  myClipPlanes;
+  Graphic3d_SequenceOfHClipPlane  myInternalClipPlanes;
 };
 
 #ifdef WIN32