connect(m_Controls.m_XWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged()));
void QmitkImageNavigatorView::OnMillimetreCoordinateValueChanged()
{
if (m_IRenderWindowPart)
{
mitk::TimeGeometry::ConstPointer geometry = m_IRenderWindowPart->GetActiveQmitkRenderWindow()->GetSliceNavigationController()->GetInputWorldTimeGeometry();
if (geometry.IsNotNull())
{
mitk::Point3D positionInWorldCoordinates;
positionInWorldCoordinates[0] = m_Controls.m_XWorldCoordinateSpinBox->value();
positionInWorldCoordinates[1] = m_Controls.m_YWorldCoordinateSpinBox->value();
positionInWorldCoordinates[2] = m_Controls.m_ZWorldCoordinateSpinBox->value();
m_IRenderWindowPart->SetSelectedPosition(positionInWorldCoordinates);
}
}
}
class ORG_MITK_GUI_QT_STDMULTIWIDGETEDITOR QmitkStdMultiWidgetEditor
: public QmitkAbstractRenderEditor, public mitk::ILinkedRenderWindowPart
void QmitkStdMultiWidgetEditor::SetSelectedPosition(const mitk::Point3D &pos, const QString &/*id*/)
{
d->m_StdMultiWidget->MoveCrossToPosition(pos);
}
void QmitkStdMultiWidget::MoveCrossToPosition(const mitk::Point3D &newPosition)
{
mitkWidget1->GetSliceNavigationController()->SelectSliceByPoint(newPosition);
mitkWidget2->GetSliceNavigationController()->SelectSliceByPoint(newPosition);
mitkWidget3->GetSliceNavigationController()->SelectSliceByPoint(newPosition);
m_RenderingManager->RequestUpdateAll();
}
void SliceNavigationController::SelectSliceByPoint(const Point3D &point)
{
if (m_CreatedWorldGeometry.IsNull())
{
return;
}
//@todo add time to PositionEvent and use here!!
SlicedGeometry3D *slicedWorldGeometry = dynamic_cast<SlicedGeometry3D *>(
m_CreatedWorldGeometry->GetGeometryForTimeStep(this->GetTime()->GetPos()).GetPointer());
if (slicedWorldGeometry)
{
int bestSlice = -1;
double bestDistance = itk::NumericTraits<double>::max();
int s, slices;
slices = slicedWorldGeometry->GetSlices();
if (slicedWorldGeometry->GetEvenlySpaced())
{
mitk::PlaneGeometry *plane = slicedWorldGeometry->GetPlaneGeometry(0);
const Vector3D &direction = slicedWorldGeometry->GetDirectionVector();
Point3D projectedPoint;
plane->Project(point, projectedPoint);
// Check whether the point is somewhere within the slice stack volume;
// otherwise, the default slice (0) will be selected
if (direction[0] * (point[0] - projectedPoint[0]) + direction[1] * (point[1] - projectedPoint[1]) +
direction[2] * (point[2] - projectedPoint[2]) >=
0)
{
bestSlice = (int)(plane->Distance(point) / slicedWorldGeometry->GetSpacing()[2] + 0.5);
}
}
else
{
Point3D projectedPoint;
for (s = 0; s < slices; ++s)
{
slicedWorldGeometry->GetPlaneGeometry(s)->Project(point, projectedPoint);
const Vector3D distance = projectedPoint - point;
ScalarType currentDistance = distance.GetSquaredNorm();
if (currentDistance < bestDistance)
{
bestDistance = currentDistance;
bestSlice = s;
}
}
}
if (bestSlice >= 0)
{
this->GetSlice()->SetPos(bestSlice);
}
else
{
this->GetSlice()->SetPos(0);
}
this->SendCreatedWorldGeometryUpdate();
}
}