X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSVTK%2FSVTK_InteractorStyle.cxx;h=cd5396b4261a85e212bf36b2c5376d81b5881216;hb=refs%2Fheads%2Fngr%2Fpython3_dev_pv5.4;hp=1274acc0da9fcdb235af3a538fd0675798aafd62;hpb=d26f738c9c427a45409bacf3848fd8c224edf6ed;p=modules%2Fgui.git diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 1274acc0d..cd5396b42 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -56,9 +57,10 @@ #include #include +#include + #include #include -#include #include #include @@ -535,22 +537,61 @@ void SVTK_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, { if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) ) { - SVTK::TPickLimiter aPickLimiter( myPointPicker, anActor ); - myPointPicker->Pick( aSelectionEvent->myX, - aSelectionEvent->myY, - 0.0, + Selection_Mode aSelectionMode = GetSelector()->SelectionMode(); + double* aCoords; + int aVtkId; + bool isTrueType = false; + + if( myCurrFocalPointType == SVTK::StartFocalPointSelection || + ( myCurrRotationPointType == SVTK::StartPointSelection && aSelectionMode == NodeSelection ) ) + { + SVTK::TPickLimiter aPickLimiter( myPointPicker, anActor ); + myPointPicker->Pick( aSelectionEvent->myX, + aSelectionEvent->myY, + 0.0, + GetCurrentRenderer() ); + aVtkId = myPointPicker->GetPointId(); + if ( aVtkId >= 0 ) + { + int anObjId = anActor->GetNodeObjId( aVtkId ); + aCoords = anActor->GetNodeCoord(anObjId); + isTrueType = true; + } + } + + if( aSelectionMode == EdgeSelection || aSelectionMode == FaceSelection || aSelectionMode == VolumeSelection ) + { + vtkSmartPointer aCellPicker = vtkCellPicker::New(); + aCellPicker->SetTolerance( 0.005 ); + SVTK::TPickLimiter aPickLimiter( aCellPicker, anActor ); + aCellPicker->Pick( aSelectionEvent->myX, + aSelectionEvent->myY, + 0.0, GetCurrentRenderer() ); - int aVtkId = myPointPicker->GetPointId(); - if ( aVtkId >= 0 ) - { - int anObjId = anActor->GetNodeObjId( aVtkId ); - double* aCoords = anActor->GetNodeCoord(anObjId); - + aVtkId = aCellPicker->GetCellId(); + int aCellId = anActor->GetElemObjId( aVtkId ); + + if( aSelectionMode == EdgeSelection ) + isTrueType = anActor->GetObjDimension( aCellId ) == 1; + else if( aSelectionMode == FaceSelection ) + isTrueType = anActor->GetObjDimension( aCellId ) == 2; + else if( aSelectionMode == VolumeSelection ) + isTrueType = anActor->GetObjDimension( aCellId ) == 3; + + if ( aVtkId >= 0 && isTrueType ) + aCoords = anActor->GetGravityCenter( aCellId ); + } + + if( aVtkId >= 0 ) + { if (myCurrRotationPointType == SVTK::StartPointSelection) { myCurrRotationPointType = SVTK::SetRotateSelected; - // invoke event for update coordinates in SVTK_SetRotationPointDlg - InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords); + if( isTrueType ) + InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords); + else + InvokeEvent(SVTK::RotationPointChanged); + GetSelector()->SetSelectionMode(ActorSelection); } else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) { myCurrFocalPointType = SVTK::SetFocalPointSelected; @@ -572,6 +613,7 @@ void SVTK_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, // invoke event with no data (for SVTK_SetRotationPointDlg) InvokeEvent(SVTK::RotationPointChanged,0); myCurrRotationPointType = myPrevRotationPointType; + GetSelector()->SetSelectionMode(ActorSelection); } else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) { // invoke event with no data (for SVTK_ViewParameterDlg) @@ -1159,6 +1201,11 @@ void SVTK_InteractorStyle::onFinishOperation() if( anActorCollection ) { + if( !myShiftState && + anActorCollection->GetNumberOfItems () > 1 && + myLastHighlitedActor.GetPointer() ) { + anActorCollection->RemoveItem ( myLastHighlitedActor.GetPointer() ); + } anActorCollection->InitTraversal(); while( vtkActor* aVTKActor = anActorCollection->GetNextActor() ) { @@ -1310,8 +1357,7 @@ void SVTK_InteractorStyle::onCursorMove(QPoint mousePos) SALOME_Actor* aPreHighlightedActor = NULL; vtkActorCollection* anActorCollection = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer()); - if ( myCurrRotationPointType == SVTK::StartPointSelection || - myCurrFocalPointType == SVTK::StartFocalPointSelection ) + if ( myCurrFocalPointType == SVTK::StartFocalPointSelection ) { myHighlightSelectionPointActor->SetVisibility( false ); @@ -1571,17 +1617,28 @@ void SVTK_InteractorStyle::DominantCombinedSwitch() */ void SVTK_InteractorStyle::drawRect() { - if ( !myRectBand ) { - myRectBand = new QRubberBand( QRubberBand::Rectangle, GetRenderWidget() ); - QPalette palette; - palette.setColor(myRectBand->foregroundRole(), Qt::white); - myRectBand->setPalette(palette); - } - myRectBand->hide(); + if ( !myRectBand ) + myRectBand = new QtxRectRubberBand( GetRenderWidget() ); + myRectBand->setUpdatesEnabled ( false ); QRect aRect = SUIT_Tools::makeRect(myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y()); - myRectBand->setGeometry( aRect ); - myRectBand->setVisible( aRect.isValid() ); + myRectBand->initGeometry( aRect ); + + if ( !myRectBand->isVisible() ) + myRectBand->show(); + + myRectBand->setUpdatesEnabled ( true ); +} + +/*! + \brief Delete rubber band on the end on the dragging operation. +*/ +void SVTK_InteractorStyle::endDrawRect() +{ + if ( myRectBand ) { + myRectBand->clearGeometry(); + myRectBand->hide(); + } } bool isIntersect( const QPoint& theStart1, const QPoint& theEnd1, @@ -1709,17 +1766,6 @@ void SVTK_InteractorStyle::drawPolygon() } } -/*! - \brief Delete rubber band on the end on the dragging operation. -*/ -void SVTK_InteractorStyle::endDrawRect() -{ - if ( myRectBand ) myRectBand->hide(); - - delete myRectBand; - myRectBand = 0; -} - /*! \brief Delete rubber band on the end on the dragging operation. */