Commit f01d1a33 authored by SCHMITT Louise-Amelie's avatar SCHMITT Louise-Amelie

Merge branch '18-center-view' into 'develop'

Resolve "Center view on landmark when selected"

Closes #18

See merge request lschmitt/OptimDBS!8
parents bf9a4b72 580b537d
......@@ -32,6 +32,7 @@
#include <vtkDataSetAttributes.h>
#include <vtkVolumePicker.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
#include <QtGui>
......@@ -174,6 +175,12 @@ void ODBSPredictionToolBoxPrivate::refreshView()
ODBSLandmark* item = dynamic_cast<ODBSLandmark*>(ACPCManager->topLevelItem(j));
item->setInteractor(interactor);
}
size = BrainLandmarksManager->topLevelItemCount();
for (int j = 0; j < size; ++j)
{
ODBSLandmark* item = dynamic_cast<ODBSLandmark*>(BrainLandmarksManager->topLevelItem(j));
item->setInteractor(interactor);
}
if (size != 0)
{
......@@ -216,7 +223,24 @@ void ODBSPredictionToolBoxPrivate::focusOnMarker(ODBSLandmark* item,
if (!is3d)
{
vtkImageView2D* view2d = getView2d(view);
// Moves to the right slice
view2d->SetCurrentPoint(item->coordinates());
// Gotta center the camera on the landmark too
vtkCamera* activeCam = view2d->GetRenderer()->GetActiveCamera();
double* pos = activeCam->GetPosition();
double* foc = activeCam->GetFocalPoint();
if (foc[0] != pos[0]) {
activeCam->SetPosition(pos[0], item->coordinates()[1], item->coordinates()[2]);
activeCam->SetFocalPoint(foc[0], item->coordinates()[1], item->coordinates()[2]);
}
else if (foc[1] != pos[1]) {
activeCam->SetPosition(item->coordinates()[0], pos[1], item->coordinates()[2]);
activeCam->SetFocalPoint(item->coordinates()[0], foc[1], item->coordinates()[2]);
}
else {
activeCam->SetPosition(item->coordinates()[0], item->coordinates()[1], pos[2]);
activeCam->SetFocalPoint(item->coordinates()[0], item->coordinates()[1], foc[2]);
}
}
item->focus();
view->render();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment