//----------------------------------------------------------------------
void vtkResliceCursorLineRepresentation::WidgetInteraction(double e[2])
{
vtkResliceCursor *rc = this->GetResliceCursor();
if (this->ManipulationMode == WindowLevelling)
{
this->WindowLevel(e[0], e[1]);
this->LastEventPosition[0] = e[0];
this->LastEventPosition[1] = e[1];
return;
}
// Depending on the state, different motions are allowed.
if ( this->InteractionState == Outside || ! this->Renderer || !rc )
{
this->LastEventPosition[0] = e[0];
this->LastEventPosition[1] = e[1];
return;
}
if (rc->GetThickMode() &&
this->ManipulationMode ==
vtkResliceCursorRepresentation::ResizeThickness)
{
double sf = 1.0;
// Compute the scale factor
int *size = this->Renderer->GetSize();
double dPos = e[1]-this->LastEventPosition[1];
sf *= (1.0 + 2.0*(dPos / size[1])); //scale factor of 2.0 is arbitrary
double thickness[3];
rc->GetThickness(thickness);
rc->SetThickness( thickness[0] * sf,
thickness[1] * sf,
thickness[2] * sf );
this->LastEventPosition[0] = e[0];
this->LastEventPosition[1] = e[1];
return;
}
// depending on the state, perform different operations
//
// 1. Translation
if ( this->InteractionState == OnCenter && !this->Modifier )
{
// Intersect with the viewing vector. We will use this point and the
// start event point to compute an offset vector to translate the
// center by.
double intersectionPos[3], newCenter[3];
this->Picker->Pick( e, intersectionPos, this->Renderer );
// Offset the center by this vector.
for (int i = 0; i < 3; i++)
{
newCenter[i] = this->StartCenterPosition[i] +
intersectionPos[i] - this->StartPickPosition[i];
}
rc->SetCenter(newCenter);
}
// 2. Rotation of axis 1
if ( this->InteractionState == OnAxis1 && !this->Modifier )
{
this->RotateAxis( e,
this->ResliceCursorActor->GetCursorAlgorithm()->GetPlaneAxis1() );
}
// 3. Rotation of axis 2
if ( this->InteractionState == OnAxis2 && !this->Modifier )
{
this->RotateAxis( e,
this->ResliceCursorActor->GetCursorAlgorithm()->GetPlaneAxis2() );
}
// 4. Rotation of both axes
if ( (this->InteractionState == OnAxis2 ||
this->InteractionState == OnAxis1) && this->Modifier )
{
// Rotate both by the same angle
const double angle = this->RotateAxis( e,
this->ResliceCursorActor->GetCursorAlgorithm()->GetPlaneAxis1() );
this->RotateAxis(
this->ResliceCursorActor->GetCursorAlgorithm()->GetPlaneAxis2(), angle );
}
this->LastEventPosition[0] = e[0];
this->LastEventPosition[1] = e[1];
}