Page MenuHomePhabricator

Create possibilites to rotate renderwindows by code
Closed, ResolvedPublic

Description

Currently i can think of 3 ways to rotate the renderwindows to a specific constellation (see below). They all behave different, have bugs and/or are not really working as they should.

We need a CENTRAL place for rotations of the renderwindows.
We need a WELL DEFINED behavior.
We need TESTS for it.

Here the 3 ways i can think of (and that are used in MITK)

Get your renderwindows:

m_RendererTra = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1") );
m_RendererSag = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget2") );
m_RendererCor = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget3") );
m_Renderer3D = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4") );

Possibilitiy 1)
m_RendererTra->GetSliceNavigationController()->ReorientSlices( center, vec );

Maybe Display Geometry is not updated?? Well, renderwindow-planes are kinda rotated, but the display is not oriented to the plane. The look of the result is depending on the previous orientation of your renderwindow:
In the attachement you find two screenshots, where I reoriented the planes with the same lines of code. But one time I rotated the planes manually a little before starting the orientation code.


Possibility 2)

mitk::Vector3D vecUp;
vecUp[0] = 0;
vecUp[1] = 1;
vecUp[2] = 0;
mitk::Point3D center = this->GetRenderWindowPart()->GetSelectedPosition();
mitk::RotationOperation op(mitk::OpROTATE, center, vecUp, 180);
const mitk::Geometry3D *geometry3D = m_RendererTra->GetSliceNavigationController()->GetCurrentGeometry3D();

const_cast< mitk::Geometry3D * >( geometry3D )->ExecuteOperation( &op );
m_RendererTra->GetSliceNavigationController()->SendCreatedWorldGeometryUpdate();

This seems quite dirty due to the const-casts. Also I just rotate the planes here, but i cannot apply a specific orientation defined by axisvectors or matrix. But in contrary to possibilty 1 the renderwindow displays seem to be fit to the planes.


Possibilty 3)
mitk::ILinkedRenderWindowPart* linkedRenderWindow =

dynamic_cast<mitk::ILinkedRenderWindowPart*>(this->GetRenderWindowPart());

mitk::Point3D p;
p[0] = 1;
p[1] = 2;
p[2] = 1;

linkedRenderWindow->GetSlicesRotator()->RotateToPoint(

m_RendererTra->GetSliceNavigationController(),
m_RendererSag->GetSliceNavigationController(),
p, false);

The name implies that some of the input slice will be rotate to include some point. but that is not really happening. Some rotation takes place, but i cannot really figure out how. Code is extremly ugly. No comment or documentation. But propably this would be the "best" solution, since it is done by using the linkedRenderWindow, a quite central unit.

poss1_a.png (1×1 px, 318 KB)

Event Timeline

graser added a subscriber: graser.

Rotated using possibilty 1 (after some manual rotation)

poss1_b.png (1×1 px, 294 KB)

ReorientSlices( center, vec );

is not really distinct. It is changing the normal of a stack of slices (slicedGeometry). Yet, the rotation of the slices around the normal is not well defined. So this can produce strange results.

There is an operation

"AcRestorePlaneOperation" from Andi, that might be used for a good solution to these problems.

The operation "AcRestorePlaneOperation" is not that great, since you need all kind of information for that plane (spacing, extend, etc...)

We need a better possibility to rotate slices.
I extended the "ReorientSlices" Method to accept two axis vectors:
reorientSlices(point, axis0, axis1).

New remote branch pushed: bug-13109-RenderPlaneRotation

Possibilty 3 works for me.

RotateToPoint(

m_RendererSag->GetSliceNavigationController(),
m_RendererCor->GetSliceNavigationController(),
p, false);

means: In the sagittal renderwindow the coronal plane is rotated so that the rotation angle to the point p is minimal. Therefore a change of the orientation of a plane that flips the image in the according renderwindow (for example if the plane is rotated 180°) does not occur.

Could you please shortly summarize what is changed after all? I can see lots of possibilities discussed and a wiki page, which describes one of those changes (ReorientSlices(point, vectorUp, vectorRight). I cannot make much sense of the last comment, however.

The change I mentioned sounds ok, I would just be interested:

  • is the old interface kept? some users might not care about the exact orientation
  • would you please inform mitk-users after the change? I know there are external users depending on the rather recent and useful ReorientSlices
SUMMARY

For rotating the renderwindows, the following "new" method is most appropiate:

/** \brief Re-orients the slice stack so that all planes are oriented according to the given axis vectors. The given Point eventually defines selected slice. */
void mitk::SliceNavigationController::ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &axisVec0, const mitk::Vector3D &axisVec1 );

The "old" ReOrientSlices method is also still available.

/** \brief Re-orients the slice stack. All slices will be oriented to the given normal vector. The given point (world coordinates) defines the selected slice. Careful: The resulting axis vectors are not clearly defined this way. */
void ReorientSlices( const mitk::Point3D &point, const mitk::Vector3D &normal );

The use of SlicesRotator::RotateToPoint(..) has been declared deprecated!

The use of any const_cast stuff is not allowed.

[d62b00]: Merge branch 'bug-13109-RenderPlaneRotation'

Merged commits:

2012-11-08 18:27:07 Bastian Graser [b43805]
added a deprecated warning to RotateToPoint function


2012-11-07 16:11:57 Bastian Graser [addaf5]
Adapted commentary and wrote test for both ReOrientSlices Methods.


2012-11-05 14:08:53 Bastian Graser [e83055]
Extended ReorientSlices Method. Now one Point two axis vectors can be used to define a plane orientation.

[8c5569]: Merge branch 'bug-13109-RenderPlaneRotation'

Merged commits:

2012-11-14 16:33:43 Bastian Graser [9b7550]
COMP Reinitialized Planes is called only once after all rotations are finished