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);
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();
}
}
//====================================================================
-// function:OnRightButtonDown
+// function:OnMiddleButtonDown
// purpose:
//====================================================================
-void VISU_SphereWidget::OnRightButtonDown()
+void VISU_SphereWidget::OnMiddleButtonDown()
{
int X = Interactor->GetEventPosition()[0];
int Y = Interactor->GetEventPosition()[1];
Interactor->Render();
}
//====================================================================
-// function:OnRightButtonUp
+// function:OnMiddleButtonUp
// purpose:
//====================================================================
-void VISU_SphereWidget::OnRightButtonUp()
+void VISU_SphereWidget::OnMiddleButtonUp()
{
if ( myState == VISU_SphereWidget::Outside ) {
return;
// 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 (aR1<myRmin){
aR1=myRmin;
{
this->Superclass::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 (aR1<myRmin){
+ aR1=myRmin;
+ }
+ mySphereSource->SetRadius(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);
+}
+*/