From: pkv Date: Fri, 25 Nov 2005 11:48:54 +0000 (+0000) Subject: change the control buttons for sphere widget X-Git-Tag: TG-D5-38-2003_D2005-20-12~108 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=310283068cab19ff29ef3316d436e79ee5da5d1e;p=modules%2Fvisu.git change the control buttons for sphere widget --- diff --git a/src/PIPELINE/VISU_SphereWidget.cxx b/src/PIPELINE/VISU_SphereWidget.cxx index c2b46a61..f242513c 100755 --- a/src/PIPELINE/VISU_SphereWidget.cxx +++ b/src/PIPELINE/VISU_SphereWidget.cxx @@ -294,10 +294,10 @@ void VISU_SphereWidget::SetEnabled(int enabling) Interactor->AddObserver(vtkCommand::LeftButtonReleaseEvent, EventCallbackCommand, Priority); - Interactor->AddObserver(vtkCommand::RightButtonPressEvent, + Interactor->AddObserver(vtkCommand::MiddleButtonPressEvent, EventCallbackCommand, Priority); - Interactor->AddObserver(vtkCommand::RightButtonReleaseEvent, + Interactor->AddObserver(vtkCommand::MiddleButtonReleaseEvent, EventCallbackCommand, Priority); @@ -365,11 +365,11 @@ void VISU_SphereWidget::ProcessEvents(vtkObject* vtkNotUsed(object), case vtkCommand::LeftButtonReleaseEvent: self->OnLeftButtonUp(); break; - case vtkCommand::RightButtonPressEvent: - self->OnRightButtonDown(); + case vtkCommand::MiddleButtonPressEvent: + self->OnMiddleButtonDown(); break; - case vtkCommand::RightButtonReleaseEvent: - self->OnRightButtonUp(); + case vtkCommand::MiddleButtonReleaseEvent: + self->OnMiddleButtonUp(); break; case vtkCommand::MouseMoveEvent: self->OnMouseMove(); @@ -379,10 +379,10 @@ void VISU_SphereWidget::ProcessEvents(vtkObject* vtkNotUsed(object), } } //==================================================================== -// function:OnRightButtonDown +// function:OnMiddleButtonDown // purpose: //==================================================================== -void VISU_SphereWidget::OnRightButtonDown() +void VISU_SphereWidget::OnMiddleButtonDown() { int X = Interactor->GetEventPosition()[0]; int Y = Interactor->GetEventPosition()[1]; @@ -473,10 +473,10 @@ void VISU_SphereWidget::OnMouseMove() Interactor->Render(); } //==================================================================== -// function:OnRightButtonUp +// function:OnMiddleButtonUp // purpose: //==================================================================== -void VISU_SphereWidget::OnRightButtonUp() +void VISU_SphereWidget::OnMiddleButtonUp() { if ( myState == VISU_SphereWidget::Outside ) { return; @@ -589,21 +589,24 @@ void VISU_SphereWidget::Translate(double *p1, double *p2) // purpose: //==================================================================== void VISU_SphereWidget::Scale(double *p1, double *p2, - int , int ) + int aX, int aY) { - float aC[3], aR, d1, d2, sf, aR1; + double v[3]; + v[0] = p2[0] - p1[0]; + v[1] = p2[1] - p1[1]; + v[2] = p2[2] - p1[2]; // + float aC[3], aR, sf, aR1; aR=mySphereSource->GetRadius(); mySphereSource->GetCenter(aC); - d1=sqrt((p1[0]-aC[0])*(p1[0]-aC[0])+ - (p1[1]-aC[1])*(p1[1]-aC[1])+ - (p1[2]-aC[2])*(p1[2]-aC[2])); - - d2=sqrt((p2[0]-aC[0])*(p2[0]-aC[0])+ - (p2[1]-aC[1])*(p2[1]-aC[1])+ - (p2[2]-aC[2])*(p2[2]-aC[2])); - - sf=1.+(d2-d1)/aR; + sf=vtkMath::Norm(v)/aR; + int aCoordLast[2], iDX, iDY, iSign; + Interactor->GetLastEventPosition(aCoordLast); + // + iDX=aX-aCoordLast[0]; + iDY=aCoordLast[1]-aY; + iSign=(iDX+iDY>0)? 1 : -1; + sf=1.+iSign*sf; aR1=sf*aR; if (aR1Superclass::PrintSelf(os,indent); } +/* +//==================================================================== +// function:Scale +// purpose: +//==================================================================== +void VISU_SphereWidget::Scale(double *p1, double *p2, + int , int ) +{ + float aC[3], aR, d1, d2, sf, aR1; + // + aR=mySphereSource->GetRadius(); + mySphereSource->GetCenter(aC); + d1=sqrt((p1[0]-aC[0])*(p1[0]-aC[0])+ + (p1[1]-aC[1])*(p1[1]-aC[1])+ + (p1[2]-aC[2])*(p1[2]-aC[2])); + + d2=sqrt((p2[0]-aC[0])*(p2[0]-aC[0])+ + (p2[1]-aC[1])*(p2[1]-aC[1])+ + (p2[2]-aC[2])*(p2[2]-aC[2])); + + sf=1.+(d2-d1)/aR; + aR1=sf*aR; + if (aR1SetRadius(aR1); + mySphere->SetCenter(mySphereSource->GetCenter()); + mySphere->SetRadius(mySphereSource->GetRadius()); + // + int i; + float aCH[3]; + // + myHandleSource->GetCenter(aCH); + for (i=0; i<3; ++i){ + aCH[i]=aC[i]+aR1*(aCH[i]-aC[i])/aR; + } + myHandleSource->SetCenter(aCH); + myHandleActor->SetCenter(aCH); +} +*/ diff --git a/src/PIPELINE/VISU_SphereWidget.hxx b/src/PIPELINE/VISU_SphereWidget.hxx index 09515a41..7373e4be 100755 --- a/src/PIPELINE/VISU_SphereWidget.hxx +++ b/src/PIPELINE/VISU_SphereWidget.hxx @@ -79,8 +79,8 @@ protected: // ProcessEvents() dispatches to these methods. void OnLeftButtonDown(); void OnLeftButtonUp(); - void OnRightButtonDown(); - void OnRightButtonUp(); + void OnMiddleButtonDown(); + void OnMiddleButtonUp(); void OnMouseMove(); void HighlightSphere(int highlight);