Page MenuHomePhabricator

bug3256.diff

Authored By
xplanes
Jan 29 2010, 3:21 PM
Size
11 KB
Referenced Files
None
Subscribers
None

bug3256.diff

Index: Core/Code/Controllers/mitkSliceNavigationController.cpp
===================================================================
--- Core/Code/Controllers/mitkSliceNavigationController.cpp (revision 21081)
+++ Core/Code/Controllers/mitkSliceNavigationController.cpp (working copy)
@@ -55,8 +55,8 @@
m_ViewDirection( Transversal ),
m_DefaultViewDirection( Transversal ),
m_Renderer( NULL ),
- m_Top( false ),
- m_FrontSide( false ),
+ m_Top( true ),
+ m_FrontSide( true ),
m_Rotated( false ),
m_BlockUpdate( false ),
m_SliceLocked( false ),
@@ -81,9 +81,12 @@
m_Slice->SetUnitName( "mm" );
m_Time->SetUnitName( "ms" );
- m_Top = false;
- m_FrontSide = false;
+ m_Top = true;
+ m_FrontSide = true;
m_Rotated = false;
+ m_AngleOfRotation = 180;
+ m_KeepPlanePosition = true;
+ m_OrientationModified = false;
}
@@ -128,23 +131,18 @@
void SliceNavigationController::Update()
{
- if ( !m_BlockUpdate )
+ if ( m_BlockUpdate )
{
- if ( m_ViewDirection == Transversal )
- {
- this->Update( Transversal, false, false, true );
- }
- else
- {
- this->Update( m_ViewDirection );
- }
+ return;
}
+
+ this->Update( GetViewDirection( ), GetTop( ), GetFrontSide( ), GetRotated( ), GetAngleOfRotation( ) );
}
void
SliceNavigationController::Update(
SliceNavigationController::ViewDirection viewDirection,
- bool top, bool frontside, bool rotated )
+ bool top, bool frontside, bool rotated, ScalarType angleOfRotation )
{
const TimeSlicedGeometry* worldTimeSlicedGeometry =
dynamic_cast< const TimeSlicedGeometry * >(
@@ -159,6 +157,17 @@
}
m_BlockUpdate = true;
+
+ // Backup position of the plane geometry
+ bool backupPlanePosition = false;
+ mitk::Vector3D planeNormalBackup;
+ mitk::Point3D planeOriginBackup;
+ if ( m_KeepPlanePosition && GetCurrentPlaneGeometry( ) )
+ {
+ planeNormalBackup = GetCurrentPlaneGeometry( )->GetNormal();
+ planeOriginBackup = GetCurrentPlaneGeometry( )->GetOrigin();
+ backupPlanePosition = true;
+ }
if ( m_LastUpdateTime < m_InputWorldGeometry->GetMTime() )
{
@@ -169,6 +178,7 @@
this->SetTop( top );
this->SetFrontSide( frontside );
this->SetRotated( rotated );
+ this->SetAngleOfRotation( angleOfRotation );
if ( m_LastUpdateTime < GetMTime() )
{
@@ -215,21 +225,21 @@
slicedWorldGeometry = SlicedGeometry3D::New();
slicedWorldGeometry->InitializePlanes(
m_InputWorldGeometry, PlaneGeometry::Transversal,
- top, frontside, rotated );
+ top, frontside, rotated, m_AngleOfRotation );
slicedWorldGeometry->SetSliceNavigationController( this );
break;
case Frontal:
slicedWorldGeometry = SlicedGeometry3D::New();
slicedWorldGeometry->InitializePlanes( m_InputWorldGeometry,
- PlaneGeometry::Frontal, top, frontside, rotated );
+ PlaneGeometry::Frontal, top, frontside, rotated, m_AngleOfRotation );
slicedWorldGeometry->SetSliceNavigationController( this );
break;
case Sagittal:
slicedWorldGeometry = SlicedGeometry3D::New();
slicedWorldGeometry->InitializePlanes( m_InputWorldGeometry,
- PlaneGeometry::Sagittal, top, frontside, rotated );
+ PlaneGeometry::Sagittal, top, frontside, rotated, m_AngleOfRotation );
slicedWorldGeometry->SetSliceNavigationController( this );
break;
default:
@@ -273,6 +283,19 @@
}
}
+ // Restore position of the plane geometry
+ if ( backupPlanePosition && m_InputWorldGeometry.IsNotNull( ) )
+ {
+ // If orientation configuration has been modified, reset normal
+ if ( m_OrientationModified )
+ {
+ planeNormalBackup = GetCurrentPlaneGeometry( )->GetNormal();
+ }
+ ReorientSlices( planeOriginBackup, planeNormalBackup );
+ }
+ m_OrientationModified = false;
+
+
// unblock update; we may do this now, because if m_BlockUpdate was already
// true before this method was entered, then we will never come here.
m_BlockUpdate = false;
@@ -692,5 +715,38 @@
return false;
}
+void SliceNavigationController::SetFrontSide( const bool _arg )
+{
+ itkDebugMacro("setting FrontSide to " << _arg);
+ if (m_FrontSide != _arg)
+ {
+ m_FrontSide = _arg;
+ m_OrientationModified = true;
+ Modified();
+ }
+}
+
+void SliceNavigationController::SetTop( const bool _arg )
+{
+ itkDebugMacro("setting Top to " << _arg);
+ if (m_Top != _arg)
+ {
+ m_Top = _arg;
+ m_OrientationModified = true;
+ Modified();
+ }
+}
+
+void SliceNavigationController::SetAngleOfRotation( const ScalarType _arg )
+{
+ itkDebugMacro("setting m_AngleOfRotation to " << _arg);
+ if (m_AngleOfRotation != _arg)
+ {
+ m_AngleOfRotation = _arg;
+ m_OrientationModified = true;
+ Modified();
+ }
+}
+
} // namespace
Index: Core/Code/Controllers/mitkSliceNavigationController.h
===================================================================
--- Core/Code/Controllers/mitkSliceNavigationController.h (revision 21081)
+++ Core/Code/Controllers/mitkSliceNavigationController.h (working copy)
@@ -202,7 +202,7 @@
*
*/
virtual void Update(ViewDirection viewDirection, bool top = true,
- bool frontside = true, bool rotated = false);
+ bool frontside = true, bool rotated = false, ScalarType angleOfRotation = 0);
/**
* \brief Send the created geometry to the connected
@@ -432,6 +432,25 @@
void AdjustSliceStepperRange();
+ virtual void SetTop (const bool _arg);
+ itkGetMacro(Top, bool);
+ itkBooleanMacro(Top);
+
+ virtual void SetFrontSide (const bool _arg);
+ itkGetMacro(FrontSide, bool);
+ itkBooleanMacro(FrontSide);
+
+ itkSetMacro(Rotated, bool);
+ itkGetMacro(Rotated, bool);
+ itkBooleanMacro(Rotated);
+
+ virtual void SetAngleOfRotation(const ScalarType _arg);
+ itkGetMacro(AngleOfRotation, ScalarType);
+
+ itkSetMacro(KeepPlanePosition, bool);
+ itkGetMacro(KeepPlanePosition, bool);
+ itkBooleanMacro(KeepPlanePosition);
+
protected:
SliceNavigationController(const char * type = NULL);
virtual ~SliceNavigationController();
@@ -476,21 +495,14 @@
mitk::BaseRenderer *m_Renderer;
- itkSetMacro(Top, bool);
- itkGetMacro(Top, bool);
- itkBooleanMacro(Top);
-
- itkSetMacro(FrontSide, bool);
- itkGetMacro(FrontSide, bool);
- itkBooleanMacro(FrontSide);
-
- itkSetMacro(Rotated, bool);
- itkGetMacro(Rotated, bool);
- itkBooleanMacro(Rotated);
-
bool m_Top;
bool m_FrontSide;
bool m_Rotated;
+ ScalarType m_AngleOfRotation;
+ //! Keep position and orientation of the plane after calling Update( )
+ bool m_KeepPlanePosition;
+ //! m_Top or m_FrontSide has been modified and normal cannot be kept
+ bool m_OrientationModified;
bool m_BlockUpdate;
Index: Core/Code/DataManagement/mitkSlicedGeometry3D.cpp
===================================================================
--- Core/Code/DataManagement/mitkSlicedGeometry3D.cpp (revision 21081)
+++ Core/Code/DataManagement/mitkSlicedGeometry3D.cpp (working copy)
@@ -225,13 +225,13 @@
mitk::SlicedGeometry3D::InitializePlanes(
const mitk::Geometry3D *geometry3D,
mitk::PlaneGeometry::PlaneOrientation planeorientation,
- bool top, bool frontside, bool rotated )
+ bool top, bool frontside, bool rotated, ScalarType angleOfRotation )
{
m_ReferenceGeometry = const_cast< Geometry3D * >( geometry3D );
PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New();
planeGeometry->InitializeStandardPlane(
- geometry3D, top, planeorientation, frontside, rotated );
+ geometry3D, top, planeorientation, frontside, rotated, angleOfRotation );
ScalarType viewSpacing = 1;
unsigned int slices = 1;
Index: Core/Code/DataManagement/mitkSlicedGeometry3D.h
===================================================================
--- Core/Code/DataManagement/mitkSlicedGeometry3D.h (revision 21081)
+++ Core/Code/DataManagement/mitkSlicedGeometry3D.h (working copy)
@@ -236,7 +236,7 @@
*/
virtual void InitializePlanes( const mitk::Geometry3D *geometry3D,
mitk::PlaneGeometry::PlaneOrientation planeorientation, bool top=true,
- bool frontside=true, bool rotated=false );
+ bool frontside=true, bool rotated=false, ScalarType angleOfRotation = 0 );
virtual void SetImageGeometry(const bool isAnImageGeometry);
Index: Core/Code/IO/mitkPlaneGeometry.cpp
===================================================================
--- Core/Code/IO/mitkPlaneGeometry.cpp (revision 21081)
+++ Core/Code/IO/mitkPlaneGeometry.cpp (working copy)
@@ -20,6 +20,7 @@
#include "mitkPlaneOperation.h"
#include "mitkInteractionConst.h"
#include "mitkLine.h"
+#include "mitkRotationOperation.h"
#include <vtkTransform.h>
@@ -306,7 +307,7 @@
void
PlaneGeometry::InitializeStandardPlane( const Geometry3D *geometry3D,
PlaneOrientation planeorientation, ScalarType zPosition,
- bool frontside, bool rotated )
+ bool frontside, bool rotated, ScalarType angleOfRotation )
{
this->SetReferenceGeometry( const_cast< Geometry3D * >( geometry3D ) );
@@ -344,7 +345,7 @@
InitializeStandardPlane( width, height,
geometry3D->GetIndexToWorldTransform(),
- planeorientation, zPosition, frontside, rotated );
+ planeorientation, zPosition, frontside, false );
ScalarType bounds[6]= { 0, width, 0, height, 0, 1 };
this->SetBounds( bounds );
@@ -355,12 +356,24 @@
origin = GetOrigin() + originVector;
SetOrigin(origin);
+
+ if ( rotated && angleOfRotation != 0 )
+ {
+ mitk::Point3D center = GetReferenceGeometry( )->GetOrigin( );
+ center[ 0 ] = ( boundsarray[ 0 ] + boundsarray[ 1 ] ) / 2 * GetReferenceGeometry( )->GetSpacing( )[ 0 ];
+ center[ 1 ] = ( boundsarray[ 2 ] + boundsarray[ 3 ] ) / 2 * GetReferenceGeometry( )->GetSpacing( )[ 1 ];
+ center[ 2 ] = ( boundsarray[ 4 ] + boundsarray[ 5 ] ) / 2 * GetReferenceGeometry( )->GetSpacing( )[ 2 ];
+ Vector3D axisOfRotation = GetAxisVector(2);
+ ScalarType angle = angleOfRotation;
+ mitk::RotationOperation op(mitk::OpROTATE, center, axisOfRotation, angle);
+ ExecuteOperation( &op );
+ }
}
void
PlaneGeometry::InitializeStandardPlane( const Geometry3D *geometry3D,
- bool top, PlaneOrientation planeorientation, bool frontside, bool rotated )
+ bool top, PlaneOrientation planeorientation, bool frontside, bool rotated, ScalarType angleOfRotation )
{
ScalarType zPosition;
@@ -380,7 +393,7 @@
}
InitializeStandardPlane( geometry3D, planeorientation,
- zPosition, frontside, rotated );
+ zPosition, frontside, rotated, angleOfRotation );
}
Index: Core/Code/IO/mitkPlaneGeometry.h
===================================================================
--- Core/Code/IO/mitkPlaneGeometry.h (revision 21081)
+++ Core/Code/IO/mitkPlaneGeometry.h (working copy)
@@ -77,7 +77,7 @@
*/
virtual void InitializeStandardPlane( const Geometry3D* geometry3D,
PlaneOrientation planeorientation = Transversal, ScalarType zPosition = 0,
- bool frontside=true, bool rotated=false );
+ bool frontside=true, bool rotated=false, ScalarType angleOfRotation = 0 );
/**
@@ -90,7 +90,7 @@
*/
virtual void InitializeStandardPlane( const Geometry3D* geometry3D, bool top,
PlaneOrientation planeorientation = Transversal,
- bool frontside=true, bool rotated=false );
+ bool frontside=true, bool rotated=false, ScalarType angleOfRotation = 0 );
/**

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
422
Default Alt Text
bug3256.diff (11 KB)