Exemple #1
0
void QmitkSliceWidget::InitWidget(mitk::SliceNavigationController::ViewDirection viewDirection)
{
  m_View = viewDirection;

  mitk::SliceNavigationController *controller = m_RenderWindow->GetSliceNavigationController();

  if (viewDirection == mitk::SliceNavigationController::Axial)
  {
    controller->SetViewDirection(mitk::SliceNavigationController::Axial);
  }
  else if (viewDirection == mitk::SliceNavigationController::Frontal)
  {
    controller->SetViewDirection(mitk::SliceNavigationController::Frontal);
  }
  // init sagittal view
  else
  {
    controller->SetViewDirection(mitk::SliceNavigationController::Sagittal);
  }

  if (m_SlicedGeometry.IsNull())
  {
    return;
  }

  mitk::BaseGeometry::Pointer geometry = static_cast<mitk::BaseGeometry *>(m_SlicedGeometry->Clone().GetPointer());

  const mitk::BoundingBox::Pointer boundingbox = m_DataStorage->ComputeVisibleBoundingBox(GetRenderer(), nullptr);

  if (boundingbox->GetPoints()->Size() > 0)
  {
    // let's see if we have data with a limited live-span ...
    mitk::TimeBounds timebounds = m_DataStorage->ComputeTimeBounds(GetRenderer(), nullptr);

    mitk::ProportionalTimeGeometry::Pointer timeGeometry = mitk::ProportionalTimeGeometry::New();
    timeGeometry->Initialize(geometry, 1);

    {
      timeGeometry->SetFirstTimePoint(timebounds[0]);
      timeGeometry->SetStepDuration(1.0);
    }

    if (timeGeometry->GetBoundingBoxInWorld()->GetDiagonalLength2() >= mitk::eps)
    {
      controller->SetInputWorldTimeGeometry(timeGeometry);
      controller->Update();
    }
  }

  GetRenderer()->GetCameraController()->Fit();
  mitk::RenderingManager::GetInstance()->RequestUpdate(GetRenderer()->GetRenderWindow());
}
Exemple #2
0
void QmitkSliceWidget::InitWidget(
    mitk::SliceNavigationController::ViewDirection viewDirection)
{
  m_View = viewDirection;

  mitk::SliceNavigationController* controller =
      m_RenderWindow->GetSliceNavigationController();

  if (viewDirection == mitk::SliceNavigationController::Axial)
  {
    controller->SetViewDirection(
        mitk::SliceNavigationController::Axial);
  }
  else if (viewDirection == mitk::SliceNavigationController::Frontal)
  {
    controller->SetViewDirection(mitk::SliceNavigationController::Frontal);
  }
  // init sagittal view
  else
  {
    controller->SetViewDirection(mitk::SliceNavigationController::Sagittal);
  }

  int currentPos = 0;
  if (m_RenderWindow->GetSliceNavigationController())
  {
    currentPos = controller->GetSlice()->GetPos();
  }

  if (m_SlicedGeometry.IsNull())
  {
    return;
  }

  // compute bounding box with respect to first images geometry
  const mitk::BoundingBox::BoundsArrayType imageBounds =
      m_SlicedGeometry->GetBoundingBox()->GetBounds();

  //  mitk::SlicedGeometry3D::Pointer correctGeometry = m_SlicedGeometry.GetPointer();
  mitk::Geometry3D::Pointer
      geometry =
          static_cast<mitk::Geometry3D*> (m_SlicedGeometry->Clone().GetPointer());

  const mitk::BoundingBox::Pointer boundingbox =
      m_DataStorage->ComputeVisibleBoundingBox(GetRenderer(), NULL);
  if (boundingbox->GetPoints()->Size() > 0)
  {
    ////geometry = mitk::Geometry3D::New();
    ////geometry->Initialize();
    //geometry->SetBounds(boundingbox->GetBounds());
    //geometry->SetSpacing(correctGeometry->GetSpacing());

    //let's see if we have data with a limited live-span ...
    mitk::TimeBounds timebounds = m_DataStorage->ComputeTimeBounds(
        GetRenderer(), NULL);

    if (timebounds[1] < mitk::ScalarTypeNumericTraits::max())
    {
      mitk::ScalarType duration = timebounds[1] - timebounds[0];

      mitk::TimeSlicedGeometry::Pointer timegeometry =
          mitk::TimeSlicedGeometry::New();

      timegeometry->InitializeEvenlyTimed(geometry.GetPointer(),
          (unsigned int) duration);

      timegeometry->SetTimeBounds(timebounds); //@bug really required? FIXME

      timebounds[1] = timebounds[0] + 1.0f;
      geometry->SetTimeBounds(timebounds);

      geometry = timegeometry;
    }

    if (const_cast<mitk::BoundingBox*> (geometry->GetBoundingBox())->GetDiagonalLength2()
        >= mitk::eps)
    {
      controller->SetInputWorldGeometry(geometry);
      controller->Update();
    }
  }

  GetRenderer()->GetDisplayGeometry()->Fit();
  mitk::RenderingManager::GetInstance()->RequestUpdate(
      GetRenderer()->GetRenderWindow());
  //int w=vtkObject::GetGlobalWarningDisplay();
  //vtkObject::GlobalWarningDisplayOff();
  //vtkRenderer * vtkrenderer = ((mitk::OpenGLRenderer*)(GetRenderer()))->GetVtkRenderer();
  //if(vtkrenderer!=NULL) vtkrenderer->ResetCamera();
  //vtkObject::SetGlobalWarningDisplay(w);
}