Salome HOME
Copyright update 2020
[modules/gui.git] / src / OCCViewer / OCCViewer_ClipPlaneInteractor.cxx
index 7d065210e730bd18b4028baa9bcfc331a83dfd01..3b883d56bf35d773c7298e4d217cc03ca79c61f9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  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
@@ -110,7 +110,7 @@ void OCCViewer_ClipPlaneInteractor::setEnabled( const bool theIsEnabled )
 
 /*!
   \brief Checks whether the interactive operation is in progress.
-  \return TRUE if the interaction is performed on IO object meaning
+  \return \c true if the interaction is performed on IO object meaning
           that no other operations in viewer should be processed.
 */
 bool OCCViewer_ClipPlaneInteractor::isPerforming() const
@@ -120,7 +120,7 @@ bool OCCViewer_ClipPlaneInteractor::isPerforming() const
 
 /*!
   \brief Checks whether the interactive plane can be clicked.
-  \return TRUE if the click interaction is supported for the plane.
+  \return \c true if the click interaction is supported for the plane.
 */
 bool OCCViewer_ClipPlaneInteractor::isClickable( const Handle(AIS_Plane)& thePlane )
 {
@@ -141,7 +141,7 @@ bool OCCViewer_ClipPlaneInteractor::isClickable( const Handle(AIS_Plane)& thePla
 
   Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
 
-  if ( anAISContext->IsSelected( thePlane ) )
+  if ( anAISContext->IsSelected( Handle(AIS_InteractiveObject)::DownCast(thePlane) ) )
   {
     return false;
   }
@@ -151,7 +151,7 @@ bool OCCViewer_ClipPlaneInteractor::isClickable( const Handle(AIS_Plane)& thePla
 
 /*!
   \brief Checks whether the interactive plane can be dragged.
-  \return TRUE if the dragging interaction is supported for the plane.
+  \return \c true if the dragging interaction is supported for the plane.
 */
 bool OCCViewer_ClipPlaneInteractor::isDraggable( const Handle(AIS_Plane)& thePlane )
 {
@@ -172,7 +172,7 @@ bool OCCViewer_ClipPlaneInteractor::isDraggable( const Handle(AIS_Plane)& thePla
 
   Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
 
-  if ( !anAISContext->IsSelected( thePlane ) )
+  if ( !anAISContext->IsSelected( Handle(AIS_InteractiveObject)::DownCast(thePlane) ) ) 
   {
     return false;
   }
@@ -220,10 +220,10 @@ bool OCCViewer_ClipPlaneInteractor::startDragging( const QPoint& thePickPos,
 
   gp_Pnt aPickPoint = aFindPick.Point( 1 );
 
-  const gp_Dir& aPlaneN      = aPlanePln.Axis().Direction();
-  const gp_Dir& aPlaneX      = aPlanePln.XAxis().Direction();
-  const gp_Dir& aPlaneY      = aPlanePln.YAxis().Direction();
-  const gp_Pnt& aPlaneCenter = aPlanePln.Location();
+  gp_Dir aPlaneN      = aPlanePln.Axis().Direction();
+  gp_Dir aPlaneX      = aPlanePln.XAxis().Direction();
+  gp_Dir aPlaneY      = aPlanePln.YAxis().Direction();
+  gp_Pnt aPlaneCenter = aPlanePln.Location();
 
   switch ( theDragOp )
   {
@@ -406,7 +406,7 @@ void OCCViewer_ClipPlaneInteractor::performDragging( const QPoint& theDragPos,
       thePlane->SetToUpdate();
       thePlane->UpdateSelection();
 
-      myViewer->getAISContext()->Update( thePlane );
+      myViewer->getAISContext()->Update( thePlane , Standard_True );
     }
     break;
 
@@ -447,7 +447,7 @@ void OCCViewer_ClipPlaneInteractor::performDragging( const QPoint& theDragPos,
       thePlane->SetToUpdate();
       thePlane->UpdateSelection();
 
-      myViewer->getAISContext()->Update( thePlane );
+      myViewer->getAISContext()->Update( thePlane , Standard_True );
     }
     break;
   }
@@ -495,7 +495,7 @@ bool OCCViewer_ClipPlaneInteractor::mousePress( QMouseEvent* theEvent,
   Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
 
   // check detection of plane
-  anAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3D );
+  anAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3D , Standard_True );
 
   if ( !anAISContext->HasDetected() )
   {
@@ -520,9 +520,9 @@ bool OCCViewer_ClipPlaneInteractor::mousePress( QMouseEvent* theEvent,
   myIsClickable = isClickable( aPlane );
 
   // process mouse click on the object
-  if ( myIsClickable );
+  if ( myIsClickable )
   {
-    myViewer->getAISContext()->SetSelected( aPlane );
+    myViewer->getAISContext()->SetSelected( Handle(AIS_InteractiveObject)::DownCast(aPlane) , Standard_True );
     emit planeClicked( aPlane );
   }
 
@@ -615,6 +615,7 @@ bool OCCViewer_ClipPlaneInteractor::mouseRelease( QMouseEvent* theEvent,
   myInteractedPlane = NULL;
   myIsDraggable     = false;
   myIsClickable     = false;
+  myViewer->getAISContext()->ClearSelected( Standard_True );
   return true;
 }