X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKViewer%2FVTKViewer_InteractorStyle.cxx;h=53221dd592c555c6cec874e0cec2ab9c3505e375;hb=0f9dfaa83b994c9d7fdd893f418395fad145f388;hp=1f69e6085d76aa66a8681c7474371e4dfb807a97;hpb=9f1a66957ba9a2308f8fdc3f9397140af9df5fd0;p=modules%2Fgui.git diff --git a/src/VTKViewer/VTKViewer_InteractorStyle.cxx b/src/VTKViewer/VTKViewer_InteractorStyle.cxx index 1f69e6085..53221dd59 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyle.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyle.cxx @@ -1,43 +1,38 @@ -// SALOME VTKViewer : build VTK viewer into Salome desktop +// 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 // -// Copyright (C) 2003 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. -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// 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 +// + +// SALOME VTKViewer : build VTK viewer into Salome desktop // File : VTKViewer_InteractorStyle.cxx // Author : Christophe ATTANASIO -// Module : SALOME #include "VTKViewer_InteractorStyle.h" #include "VTKViewer_Actor.h" #include "VTKViewer_Utilities.h" #include "VTKViewer_Trihedron.h" -#include "VTKViewer_RectPicker.h" #include "VTKViewer_ViewWindow.h" #include "VTKViewer_RenderWindow.h" -#include "VTKViewer_CellRectPicker.h" #include "VTKViewer_RenderWindowInteractor.h" -//#include "SALOME_Actor.h" - #include #include #include @@ -52,18 +47,10 @@ #include #include -#include -//VRV: porting on Qt 3.0.5 -#if QT_VERSION >= 0x030005 -#include -#endif -//VRV: porting on Qt 3.0.5 -#include - -//#include "utilities.h" - -using namespace std; +#include +#include +#include /* static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){ @@ -74,22 +61,22 @@ static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId) float aMinDist = 1000000.0, aDist = 0; for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){ if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){ - int subId; float pcoords[3], closestPoint[3], weights[3]; - aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); - if (aDist < aMinDist) { - aMinDist = aDist; - anEdgeId = i; - } + int subId; float pcoords[3], closestPoint[3], weights[3]; + aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); + if (aDist < aMinDist) { + aMinDist = aDist; + anEdgeId = i; + } } } } return anEdgeId; } */ -//---------------------------------------------------------------------------- + vtkStandardNewMacro(VTKViewer_InteractorStyle); -//---------------------------------------------------------------------------- + /*!Constructor.*/ VTKViewer_InteractorStyle::VTKViewer_InteractorStyle() { @@ -105,17 +92,20 @@ VTKViewer_InteractorStyle::VTKViewer_InteractorStyle() myPreSelectionActor->GetProperty()->SetLineWidth(5); myPreSelectionActor->GetProperty()->SetPointSize(5); + myRectBand = 0; + OnSelectionModeChanged(); } -//---------------------------------------------------------------------------- + /*!Destructor.*/ VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle() { m_ViewWnd->RemoveActor(myPreSelectionActor); + endDrawRect(); } -//---------------------------------------------------------------------------- + /*!Set preselection properties. *\param theRed - red color. *\param theGreen - green color. @@ -123,7 +113,7 @@ VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle() *\param theWidth - width.. */ void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const double& theGreen, - const double& theBlue, const int& theWidth) + const double& theBlue, const int& theWidth) { if ( myPreSelectionActor->GetProperty() == 0 ) return; @@ -132,7 +122,7 @@ void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const myPreSelectionActor->GetProperty()->SetPointSize(theWidth); } -//---------------------------------------------------------------------------- + /*!Set render window interactor *\param theInteractor - interactor. */ @@ -141,7 +131,7 @@ void VTKViewer_InteractorStyle::SetInteractor(vtkRenderWindowInteractor *theInte Superclass::SetInteractor(theInteractor); } -//---------------------------------------------------------------------------- + /*!Set view window. *\param theViewWnd - SALOME VTKViewer_ViewWindow */ @@ -151,7 +141,7 @@ void VTKViewer_InteractorStyle::setViewWnd(VTKViewer_ViewWindow* theViewWnd ){ myPreSelectionActor->Delete(); } -//---------------------------------------------------------------------------- + /*!Set GUI window. *\param theWindow - QWidget window. */ @@ -159,15 +149,14 @@ void VTKViewer_InteractorStyle::setGUIWindow(QWidget* theWindow){ myGUIWindow = theWindow; } -//---------------------------------------------------------------------------- -/*!Set triedron. + +/*!Set trihedron. *\param theTrihedron - SALOME VTKViewer_Trihedron */ void VTKViewer_InteractorStyle::setTriedron(VTKViewer_Trihedron* theTrihedron){ m_Trihedron = theTrihedron; } -//---------------------------------------------------------------------------- /*!Rotate camera. *\param dx - *\param dy - @@ -199,7 +188,6 @@ void VTKViewer_InteractorStyle::RotateXY(int dx, int dy) myGUIWindow->update(); } -//---------------------------------------------------------------------------- void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY) { TranslateView(x, y, oldX, oldY); @@ -208,7 +196,6 @@ void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY) } -//---------------------------------------------------------------------------- /*! Move the position of the camera along the direction of projection. (dx,dy)*/ void VTKViewer_InteractorStyle::DollyXY(int dx, int dy) { @@ -231,8 +218,6 @@ void VTKViewer_InteractorStyle::DollyXY(int dx, int dy) myGUIWindow->update(); } -//---------------------------------------------------------------------------- -/*!*/ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) { vtkCamera *cam; @@ -243,9 +228,9 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) } double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]), - (double)(x - this->CurrentRenderer->GetCenter()[0])); + (double)(x - this->CurrentRenderer->GetCenter()[0])); double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]), - (double)(oldX - this->CurrentRenderer->GetCenter()[0])); + (double)(oldX - this->CurrentRenderer->GetCenter()[0])); newAngle *= this->RadianToDegree; oldAngle *= this->RadianToDegree; @@ -259,7 +244,6 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) } -//---------------------------------------------------------------------------- /*!On mouse move event. *\param ctrl - CTRL (not used) *\param shift - SHIFT (on/off - integer 0/1) @@ -267,8 +251,8 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), - int shift, - int x, int y) + int shift, + int x, int y) { myShiftState = shift; if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) @@ -278,7 +262,6 @@ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), } -//---------------------------------------------------------------------------- /*!On Left button down event. *\param ctrl - CTRL (on/off - integer 0/1) *\param shift - SHIFT (on/off - integer 0/1) @@ -286,7 +269,7 @@ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, - int x, int y) + int x, int y) { if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) { this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL); @@ -315,7 +298,6 @@ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, } -//---------------------------------------------------------------------------- /*!On left button up event. *\param ctrl - CTRL (not used) *\param shift - SHIFT (on/off - integer 0/1) @@ -323,9 +305,9 @@ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, *\param y - y coordinate (not used) */ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -336,7 +318,6 @@ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl), } -//---------------------------------------------------------------------------- /*!On left button up event. *\param ctrl - CTRL (on/off - integer 0/1) *\param shift - SHIFT (on/off - integer 0/1) @@ -344,8 +325,8 @@ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl), *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl, - int shift, - int x, int y) + int shift, + int x, int y) { if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) { @@ -374,7 +355,6 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl, } -//---------------------------------------------------------------------------- /*!On middle button up event. *\param ctrl - CTRL (not used) *\param shift - SHIFT (on/off - integer 0/1) @@ -382,9 +362,9 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl, *\param y - y coordinate (not used) */ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -395,7 +375,6 @@ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl), } -//---------------------------------------------------------------------------- /*!On right button down event. *\param ctrl - CTRL (on/off - integer 0/1) *\param shift - SHIFT (on/off - integer 0/1) @@ -403,8 +382,8 @@ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl), *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl, - int shift, - int x, int y) + int shift, + int x, int y) { if (this->HasObserver(vtkCommand::RightButtonPressEvent)) { @@ -432,7 +411,6 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl, } } -//---------------------------------------------------------------------------- /*!On right button up event. *\param ctrl - CTRL (not used) *\param shift - SHIFT (on/off - integer 0/1) @@ -440,9 +418,9 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl, *\param y - y coordinate (not used) */ void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -452,8 +430,7 @@ void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl), } } -//---------------------------------------------------------------------------- -/** @name XPM - x pixmaps. */ +/*! @name XPM - x pixmaps. */ //@{ /*!Image Zoom cursor*/ const char* imageZoomCursor[] = { @@ -534,22 +511,20 @@ const char* imageRotateCursor[] = { "................................"}; //@} -//---------------------------------------------------------------------------- /*! Loads cursors for viewer operations - zoom, pan, etc...*/ void VTKViewer_InteractorStyle::loadCursors() { - myDefCursor = QCursor(ArrowCursor); - myHandCursor = QCursor(PointingHandCursor); - myPanCursor = QCursor(SizeAllCursor); + myDefCursor = QCursor(Qt::ArrowCursor); + myHandCursor = QCursor(Qt::PointingHandCursor); + myPanCursor = QCursor(Qt::SizeAllCursor); myZoomCursor = QCursor(QPixmap(imageZoomCursor)); myRotateCursor = QCursor(QPixmap(imageRotateCursor)); mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!! - myGlobalPanCursor = QCursor(CrossCursor); + myGlobalPanCursor = QCursor(Qt::CrossCursor); myCursorState = false; } -//---------------------------------------------------------------------------- /*! event filter - controls mouse and keyboard events during viewer operations*/ bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event) { @@ -563,7 +538,6 @@ bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event) } -//---------------------------------------------------------------------------- /*! starts Zoom operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startZoom() { @@ -578,7 +552,6 @@ void VTKViewer_InteractorStyle::startZoom() } -//---------------------------------------------------------------------------- /*! starts Pan operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startPan() { @@ -592,7 +565,6 @@ void VTKViewer_InteractorStyle::startPan() qApp->installEventFilter(this); } -//---------------------------------------------------------------------------- /*! starts Rotate operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startRotate() { @@ -607,7 +579,6 @@ void VTKViewer_InteractorStyle::startRotate() } -//---------------------------------------------------------------------------- /*! starts Spin operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startSpin() { @@ -623,7 +594,6 @@ void VTKViewer_InteractorStyle::startSpin() -//---------------------------------------------------------------------------- /*! starts Fit Area operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startFitArea() { @@ -638,7 +608,6 @@ void VTKViewer_InteractorStyle::startFitArea() } -//---------------------------------------------------------------------------- /*!View fit all.*/ void VTKViewer_InteractorStyle::ViewFitAll() { int aTriedronWasVisible = false; @@ -659,8 +628,29 @@ void VTKViewer_InteractorStyle::ViewFitAll() { ::ResetCameraClippingRange(CurrentRenderer); } +/*!View fit selection.*/ +void VTKViewer_InteractorStyle::ViewFitSelection() { + + vtkActorCollection* aSelectedCollection = vtkActorCollection::New(); + + VTK::ActorCollectionCopy aCopy( CurrentRenderer->GetActors() ); + vtkActorCollection* aCollection = aCopy.GetActors(); + aCollection->InitTraversal(); + while ( vtkActor* aProp = aCollection->GetNextActor() ) + if ( VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast( aProp ) ) + if ( anActor->isPreselected() ) + aSelectedCollection->AddItem( aProp ); + + double bounds[6]; + ::ComputeBounds( aSelectedCollection, bounds ); + + if ( aSelectedCollection->GetNumberOfItems() && ::isBoundValid( bounds ) ) { + CurrentRenderer->ResetCamera( bounds ); + CurrentRenderer->ResetCameraClippingRange( bounds ); + } +} + -//---------------------------------------------------------------------------- /*! starts Global Panning operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startGlobalPan() { @@ -684,8 +674,7 @@ void VTKViewer_InteractorStyle::startGlobalPan() } -//---------------------------------------------------------------------------- -/*!\retval TRUE if needs redrawing*/ +/*!\retval \c true if needs redrawing*/ bool VTKViewer_InteractorStyle::needsRedrawing() { return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM || @@ -696,7 +685,6 @@ bool VTKViewer_InteractorStyle::needsRedrawing() } -//---------------------------------------------------------------------------- /*! fits viewer contents to rectangle *\param left - left side *\param top - top side @@ -735,7 +723,6 @@ void VTKViewer_InteractorStyle::fitRect(const int left, } -//---------------------------------------------------------------------------- /*! starts viewer operation (!internal usage!)*/ void VTKViewer_InteractorStyle::startOperation(int operation) { @@ -764,7 +751,6 @@ void VTKViewer_InteractorStyle::startOperation(int operation) } -//---------------------------------------------------------------------------- /*! sets proper cursor for window when viewer operation is activated*/ void VTKViewer_InteractorStyle::setCursor(const int operation) { @@ -804,8 +790,33 @@ void VTKViewer_InteractorStyle::setCursor(const int operation) } } +/*! + Draws rectangle by starting and current points +*/ +void VTKViewer_InteractorStyle::drawRect() +{ + if ( !myRectBand ) { + myRectBand = new QRubberBand( QRubberBand::Rectangle, myGUIWindow ); + QPalette palette; + palette.setColor(myRectBand->foregroundRole(), Qt::white); + myRectBand->setPalette(palette); + } + myRectBand->hide(); + + QRect aRect(myPoint, myOtherPoint); + myRectBand->setGeometry( aRect ); + myRectBand->setVisible( aRect.isValid() ); +} + +/*! + \brief Delete rubber band on the end on the dragging operation. +*/ +void VTKViewer_InteractorStyle::endDrawRect() +{ + delete myRectBand; + myRectBand = 0; +} -//---------------------------------------------------------------------------- /*! called when viewer operation started (!put necessary initialization here!)*/ void VTKViewer_InteractorStyle::onStartOperation() { @@ -816,10 +827,7 @@ void VTKViewer_InteractorStyle::onStartOperation() case VTK_INTERACTOR_STYLE_CAMERA_SELECT: case VTK_INTERACTOR_STYLE_CAMERA_FIT: { - QPainter p(myGUIWindow); - p.setPen(Qt::lightGray); - p.setRasterOp(Qt::XorROP); - p.drawRect(QRect(myPoint, myOtherPoint)); + drawRect(); break; } case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: @@ -832,7 +840,6 @@ void VTKViewer_InteractorStyle::onStartOperation() } -//---------------------------------------------------------------------------- /*! called when viewer operation finished (!put necessary post-processing here!)*/ void VTKViewer_InteractorStyle::onFinishOperation() { @@ -871,256 +878,256 @@ void VTKViewer_InteractorStyle::onFinishOperation() } else { if (myPoint == myOtherPoint) { - // process point selection + // process point selection int w, h, x, y; m_Interactor->GetSize(w, h); x = myPoint.x(); y = h - myPoint.y() - 1; this->FindPokedRenderer(x, y); - m_Interactor->StartPickCallback(); + m_Interactor->StartPickCallback(); - vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker()); + vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker()); aPicker->Pick(x, y, 0.0, this->CurrentRenderer); - SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor()); + SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor()); if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) { - int aVtkId = picker->GetCellId(); - if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) { - int anObjId = SActor->GetElemObjId(aVtkId); - if(anObjId >= 0){ - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(aSelectionMode != EdgeOfCellSelection) { - if(CheckDimensionId(aSelectionMode,SActor,anObjId)){ - if (IsSelected(IO,aSel)) { - // This IO is already in the selection - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - } else { - if (!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - aSel->AddIObject( IO, false ); - } - } - }else{ - if (!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - int anEdgeId = GetEdgeId(picker,SActor,anObjId); - if (anEdgeId >= 0) { - aSel->AddOrRemoveIndex( IO, anObjId, true, false); - aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true ); - aSel->AddIObject( IO, false ); - } - } - } - } else { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } + int aVtkId = picker->GetCellId(); + if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) { + int anObjId = SActor->GetElemObjId(aVtkId); + if(anObjId >= 0){ + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if(aSelectionMode != EdgeOfCellSelection) { + if(CheckDimensionId(aSelectionMode,SActor,anObjId)){ + if (IsSelected(IO,aSel)) { + // This IO is already in the selection + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + } else { + if (!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + aSel->AddIObject( IO, false ); + } + } + }else{ + if (!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + int anEdgeId = GetEdgeId(picker,SActor,anObjId); + if (anEdgeId >= 0) { + aSel->AddOrRemoveIndex( IO, anObjId, true, false); + aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true ); + aSel->AddIObject( IO, false ); + } + } + } + } else { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) { - int aVtkId = picker->GetPointId(); - if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) { - if ( SActor && SActor->hasIO() ) { - int anObjId = SActor->GetNodeObjId(aVtkId); - if(anObjId >= 0){ - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(IsSelected(IO,aSel)) { - // This IO is already in the selection - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - } else { - if(!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - aSel->AddIObject( IO, false ); - } - } - } - } else { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - } else { - if ( SActor && SActor->hasIO() ) { - this->PropPicked++; - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(IsSelected(IO,aSel)) { - // This IO is already in the selection - if(myShiftState) { - aSel->RemoveIObject(IO); - } - } - else { - if(!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - aSel->AddIObject( IO, false ); - } - }else{ - // No selection clear all - this->PropPicked = 0; - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - } - m_Interactor->EndPickCallback(); + int aVtkId = picker->GetPointId(); + if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) { + if ( SActor && SActor->hasIO() ) { + int anObjId = SActor->GetNodeObjId(aVtkId); + if(anObjId >= 0){ + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if(IsSelected(IO,aSel)) { + // This IO is already in the selection + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + } else { + if(!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + aSel->AddIObject( IO, false ); + } + } + } + } else { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + } else { + if ( SActor && SActor->hasIO() ) { + this->PropPicked++; + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if(IsSelected(IO,aSel)) { + // This IO is already in the selection + if(myShiftState) { + aSel->RemoveIObject(IO); + } + } + else { + if(!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + aSel->AddIObject( IO, false ); + } + }else{ + // No selection clear all + this->PropPicked = 0; + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + } + m_Interactor->EndPickCallback(); } else { //processing rectangle selection - QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType(); - if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return; - m_Interactor->StartPickCallback(); - - if (!myShiftState) { - this->PropPicked = 0; - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - - // Compute bounds - // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); - QRect rect(myPoint, myOtherPoint); - rect = rect.normalize(); - int w, h; - m_Interactor->GetSize(w, h); - int x1, y1, x2, y2; - x1 = rect.left(); - y1 = h - rect.top() - 1; - x2 = rect.right(); - y2 = h - rect.bottom() - 1; - - switch (aSelectionMode) { - case NodeSelection: { - if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) { - vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); - aListActors->InitTraversal(); - while (vtkActor* aActor = aListActors->GetNextActor()) { - if (!aActor->GetVisibility()) - continue; - if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) { - if (SActor->hasIO()) { - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if (IO.IsNull()) - continue; - if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType()) - continue; - if (vtkDataSet* aDataSet = SActor->GetInput()) { - SALOME_Selection::TContainerOfId anIndices; - for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) { - float aPoint[3]; - aDataSet->GetPoint(i,aPoint); - if (IsInRect(aPoint,x1,y1,x2,y2)){ - float aDisp[3]; - ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp); - if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){ - if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){ - if(anActorCollection->IsItemPresent(SActor)){ - float aPickedPoint[3]; - aPointPicker->GetMapperPosition(aPickedPoint); - vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint); - if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){ - int anObjId = SActor->GetNodeObjId(aVtkId); - anIndices.insert(anObjId); - } - } - } - } - } - } - if (!anIndices.empty()) { - aSel->AddOrRemoveIndex(IO, anIndices, true, false); - aSel->AddIObject(IO, false); - anIndices.clear(); - }else{ - aSel->RemoveIObject(IO, false); - } - } - } - } - } - } - break; - } - case CellSelection: - case EdgeOfCellSelection: - case EdgeSelection: - case FaceSelection: - case VolumeSelection: - { - vtkSmartPointer picker = VTKViewer_CellRectPicker::New(); - picker->SetTolerance(0.001); - picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); - - vtkActorCollection* aListActors = picker->GetActors(); - aListActors->InitTraversal(); - while(vtkActor* aActor = aListActors->GetNextActor()) { - if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { - if (aSActor->hasIO()) { - Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); - if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType()) - continue; - VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); - if ( !cellList.empty() ) { - SALOME_Selection::TContainerOfId anIndexes; - VTKViewer_CellDataSet::iterator it; - for ( it = cellList.begin(); it != cellList.end(); ++it ) { - int aCellId = (*it).cellId; - - if ( !IsValid( aSActor, aCellId ) ) - continue; - - int anObjId = aSActor->GetElemObjId(aCellId); - if (anObjId != -1){ - if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) { - anIndexes.insert(anObjId); - } - } - } - aSel->AddOrRemoveIndex(aIO, anIndexes, true, false); - aSel->AddIObject(aIO, false); - } - } - } - } - } - break; - case ActorSelection: // objects selection - { - vtkSmartPointer picker = VTKViewer_RectPicker::New(); - picker->SetTolerance(0.001); - picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); - - vtkActorCollection* aListActors = picker->GetActors(); - SALOME_ListIO aListIO; - aListActors->InitTraversal(); - while(vtkActor* aActor = aListActors->GetNextActor()) { - if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { - if (aSActor->hasIO()) { - Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); - if (!IsStored(aIO,aListIO)) - aListIO.Append(aIO); - } - } - } - if (!aListIO.IsEmpty()) { - SALOME_ListIteratorOfListIO It(aListIO); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - this->PropPicked++; - aSel->AddIObject( IOS, false ); - } - } - } // end case 4 - } //end switch - m_Interactor->EndPickCallback(); - } - aActiveStudy->update3dViewers(); + QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType(); + if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return; + m_Interactor->StartPickCallback(); + + if (!myShiftState) { + this->PropPicked = 0; + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + + // Compute bounds + // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + QRect rect(myPoint, myOtherPoint); + rect = rect.normalize(); + int w, h; + m_Interactor->GetSize(w, h); + int x1, y1, x2, y2; + x1 = rect.left(); + y1 = h - rect.top() - 1; + x2 = rect.right(); + y2 = h - rect.bottom() - 1; + + switch (aSelectionMode) { + case NodeSelection: { + if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) { + vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); + aListActors->InitTraversal(); + while (vtkActor* aActor = aListActors->GetNextActor()) { + if (!aActor->GetVisibility()) + continue; + if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) { + if (SActor->hasIO()) { + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if (IO.IsNull()) + continue; + if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType()) + continue; + if (vtkDataSet* aDataSet = SActor->GetInput()) { + SALOME_Selection::TContainerOfId anIndices; + for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) { + float aPoint[3]; + aDataSet->GetPoint(i,aPoint); + if (IsInRect(aPoint,x1,y1,x2,y2)){ + float aDisp[3]; + ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp); + if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){ + if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){ + if(anActorCollection->IsItemPresent(SActor)){ + float aPickedPoint[3]; + aPointPicker->GetMapperPosition(aPickedPoint); + vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint); + if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){ + int anObjId = SActor->GetNodeObjId(aVtkId); + anIndices.insert(anObjId); + } + } + } + } + } + } + if (!anIndices.empty()) { + aSel->AddOrRemoveIndex(IO, anIndices, true, false); + aSel->AddIObject(IO, false); + anIndices.clear(); + }else{ + aSel->RemoveIObject(IO, false); + } + } + } + } + } + } + break; + } + case CellSelection: + case EdgeOfCellSelection: + case EdgeSelection: + case FaceSelection: + case VolumeSelection: + { + vtkSmartPointer picker = VTKViewer_CellRectPicker::New(); + picker->SetTolerance(0.001); + picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); + + vtkActorCollection* aListActors = picker->GetActors(); + aListActors->InitTraversal(); + while(vtkActor* aActor = aListActors->GetNextActor()) { + if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { + if (aSActor->hasIO()) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType()) + continue; + VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); + if ( !cellList.empty() ) { + SALOME_Selection::TContainerOfId anIndexes; + VTKViewer_CellDataSet::iterator it; + for ( it = cellList.begin(); it != cellList.end(); ++it ) { + int aCellId = (*it).cellId; + + if ( !IsValid( aSActor, aCellId ) ) + continue; + + int anObjId = aSActor->GetElemObjId(aCellId); + if (anObjId != -1){ + if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) { + anIndexes.insert(anObjId); + } + } + } + aSel->AddOrRemoveIndex(aIO, anIndexes, true, false); + aSel->AddIObject(aIO, false); + } + } + } + } + } + break; + case ActorSelection: // objects selection + { + vtkSmartPointer picker = VTKViewer_AreaPicker::New(); + picker->SetTolerance(0.001); + picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); + + vtkActorCollection* aListActors = picker->GetActors(); + SALOME_ListIO aListIO; + aListActors->InitTraversal(); + while(vtkActor* aActor = aListActors->GetNextActor()) { + if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { + if (aSActor->hasIO()) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + if (!IsStored(aIO,aListIO)) + aListIO.Append(aIO); + } + } + } + if (!aListIO.IsEmpty()) { + SALOME_ListIteratorOfListIO It(aListIO); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + this->PropPicked++; + aSel->AddIObject( IOS, false ); + } + } + } // end case 4 + } //end switch + m_Interactor->EndPickCallback(); + } + aActiveStudy->update3dViewers(); } } break; @@ -1193,12 +1200,8 @@ void VTKViewer_InteractorStyle::onOperation(QPoint mousePos) } case VTK_INTERACTOR_STYLE_CAMERA_FIT: { - QPainter p(myGUIWindow); - p.setPen(Qt::lightGray); - p.setRasterOp(Qt::XorROP); - p.drawRect(QRect(myPoint, myOtherPoint)); myOtherPoint = mousePos; - p.drawRect(QRect(myPoint, myOtherPoint)); + drawRect(); break; } } @@ -1242,36 +1245,36 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { if ( aVtkId >= 0 ) { int anObjId = SActor->GetElemObjId(aVtkId); if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) { - bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId); - bool aResult = anIsSameObjId; - if(!anIsSameObjId) { - if(aSelectionMode != EdgeOfCellSelection) { - aResult = CheckDimensionId(aSelectionMode,SActor,anObjId); - if(aResult){ - mySelectedActor = SActor; - myElemId = anObjId; - m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor); - } - } - } - if(aSelectionMode == EdgeOfCellSelection){ - int anEdgeId = GetEdgeId(picker,SActor,anObjId); - bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId; - aResult = anIsSameEdgeId; - if(!anIsSameEdgeId) { - aResult = (anEdgeId >= 0); - if (aResult) { - mySelectedActor = SActor; - myEdgeId = anEdgeId; - myElemId = anObjId; - m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor); - } - } - } - if(aResult) { - myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); - myPreSelectionActor->SetVisibility(true); - } + bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId); + bool aResult = anIsSameObjId; + if(!anIsSameObjId) { + if(aSelectionMode != EdgeOfCellSelection) { + aResult = CheckDimensionId(aSelectionMode,SActor,anObjId); + if(aResult){ + mySelectedActor = SActor; + myElemId = anObjId; + m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor); + } + } + } + if(aSelectionMode == EdgeOfCellSelection){ + int anEdgeId = GetEdgeId(picker,SActor,anObjId); + bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId; + aResult = anIsSameEdgeId; + if(!anIsSameEdgeId) { + aResult = (anEdgeId >= 0); + if (aResult) { + mySelectedActor = SActor; + myEdgeId = anEdgeId; + myElemId = anObjId; + m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor); + } + } + } + if(aResult) { + myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); + myPreSelectionActor->SetVisibility(true); + } } } } @@ -1279,44 +1282,44 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { int aVtkId = picker->GetPointId(); if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) { if ( SActor && SActor->hasIO() ) { - int anObjId = SActor->GetNodeObjId(aVtkId); - bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId); - if(!anIsSameObjId) { - mySelectedActor = SActor; - myNodeId = anObjId; - m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor); - } - myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); - myPreSelectionActor->SetVisibility(true); + int anObjId = SActor->GetNodeObjId(aVtkId); + bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId); + if(!anIsSameObjId) { + mySelectedActor = SActor; + myNodeId = anObjId; + m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor); + } + myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); + myPreSelectionActor->SetVisibility(true); } } } else if ( vtkPicker::SafeDownCast(aPicker) ) { if ( SActor ) { if ( myPreViewActor != SActor ) { - if ( myPreViewActor != NULL ) { - myPreViewActor->SetPreSelected( false ); - } - myPreViewActor = SActor; - - if ( SActor->hasIO() ) { - Handle( SALOME_InteractiveObject) IO = SActor->getIO(); - if ( !IsSelected(IO,Sel) ) { + if ( myPreViewActor != NULL ) { + myPreViewActor->SetPreSelected( false ); + } + myPreViewActor = SActor; + + if ( SActor->hasIO() ) { + Handle( SALOME_InteractiveObject) IO = SActor->getIO(); + if ( !IsSelected(IO,Sel) ) { // Find All actors with same IO - vtkActorCollection* theActors = this->CurrentRenderer->GetActors(); - theActors->InitTraversal(); - while( vtkActor *ac = theActors->GetNextActor() ) { - if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) { - if ( anActor->hasIO() ) { - Handle(SALOME_InteractiveObject) IOS = anActor->getIO(); - if(IO->isSame(IOS)) { - anActor->SetPreSelected( true ); - } - } - } - } - } - } + vtkActorCollection* theActors = this->CurrentRenderer->GetActors(); + theActors->InitTraversal(); + while( vtkActor *ac = theActors->GetNextActor() ) { + if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) { + if ( anActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IOS = anActor->getIO(); + if(IO->isSame(IOS)) { + anActor->SetPreSelected( true ); + } + } + } + } + } + } } } else { myPreViewActor = NULL; @@ -1367,17 +1370,17 @@ void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int f { vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); double viewFocus[4], focalDepth, viewPoint[3]; - float newPickPoint[4], oldPickPoint[4], motionVector[3]; + double newPickPoint[4], oldPickPoint[4], motionVector[3]; cam->GetFocalPoint(viewFocus); this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], - viewFocus[2], viewFocus); + viewFocus[2], viewFocus); focalDepth = viewFocus[2]; this->ComputeDisplayToWorld(double(toX), double(toY), - focalDepth, newPickPoint); + focalDepth, newPickPoint); this->ComputeDisplayToWorld(double(fromX),double(fromY), - focalDepth, oldPickPoint); + focalDepth, oldPickPoint); // camera motion is reversed motionVector[0] = oldPickPoint[0] - newPickPoint[0]; @@ -1387,30 +1390,30 @@ void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int f cam->GetFocalPoint(viewFocus); cam->GetPosition(viewPoint); cam->SetFocalPoint(motionVector[0] + viewFocus[0], - motionVector[1] + viewFocus[1], - motionVector[2] + viewFocus[2]); + motionVector[1] + viewFocus[1], + motionVector[2] + viewFocus[2]); cam->SetPosition(motionVector[0] + viewPoint[0], - motionVector[1] + viewPoint[1], - motionVector[2] + viewPoint[2]); + motionVector[1] + viewPoint[1], + motionVector[2] + viewPoint[2]); } /*! Checks: is the given Actor within display coordinates?*/ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor, - const int left, const int top, - const int right, const int bottom) + const int left, const int top, + const int right, const int bottom) { - float* aBounds = theActor->GetBounds(); - float aMin[3], aMax[3]; + double* aBounds = theActor->GetBounds(); + double aMin[3], aMax[3]; ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin); ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax); if (aMin[0] > aMax[0]) { - float aBuf = aMin[0]; + double aBuf = aMin[0]; aMin[0] = aMax[0]; aMax[0] = aBuf; } if (aMin[1] > aMax[1]) { - float aBuf = aMin[1]; + double aBuf = aMin[1]; aMin[1] = aMax[1]; aMax[1] = aBuf; } @@ -1421,20 +1424,20 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor, /*! Checks: is the given Cell within display coordinates?*/ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell, - const int left, const int top, - const int right, const int bottom) + const int left, const int top, + const int right, const int bottom) { - float* aBounds = theCell->GetBounds(); - float aMin[3], aMax[3]; + double* aBounds = theCell->GetBounds(); + double aMin[3], aMax[3]; ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin); ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax); if (aMin[0] > aMax[0]) { - float aBuf = aMin[0]; + double aBuf = aMin[0]; aMin[0] = aMax[0]; aMax[0] = aBuf; } if (aMin[1] > aMax[1]) { - float aBuf = aMin[1]; + double aBuf = aMin[1]; aMin[1] = aMax[1]; aMax[1] = aBuf; } @@ -1443,11 +1446,11 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell, } /*!Checks: is given point \a thePoint in rectangle*/ -bool VTKViewer_InteractorStyle::IsInRect(float* thePoint, - const int left, const int top, - const int right, const int bottom) +bool VTKViewer_InteractorStyle::IsInRect(double* thePoint, + const int left, const int top, + const int right, const int bottom) { - float aPnt[3]; + double aPnt[3]; ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt); return ((aPnt[0]>left) && (aPnt[0]bottom) && (aPnt[1]