42 #include <itkCommand.h> 51 m_ViewDirection(Axial),
52 m_DefaultViewDirection(Axial),
54 m_Renderer( nullptr ),
60 m_SliceRotationLocked(false),
63 typedef itk::SimpleMemberCommand<SliceNavigationController> SNCCommandType;
64 SNCCommandType::Pointer sliceStepperChangedCommand, timeStepperChangedCommand;
66 sliceStepperChangedCommand = SNCCommandType::New();
67 timeStepperChangedCommand = SNCCommandType::New();
73 m_Slice->AddObserver(itk::ModifiedEvent(), sliceStepperChangedCommand);
74 m_Time->AddObserver(itk::ModifiedEvent(), timeStepperChangedCommand);
87 if ( geometry !=
nullptr )
91 itkWarningMacro(
"setting an empty bounding-box");
105 if ( geometry !=
nullptr )
109 itkWarningMacro(
"setting an empty bounding-box");
124 const char *viewDirectionString;
128 viewDirectionString =
"Axial";
132 viewDirectionString =
"Sagittal";
136 viewDirectionString =
"Coronal";
140 viewDirectionString =
"Original";
144 viewDirectionString =
"No View Direction Available";
147 return viewDirectionString;
181 ((worldTimeGeometry.IsNotNull()) && (worldTimeGeometry->CountTimeSteps() == 0)))
196 this->SetViewDirection(viewDirection);
217 switch (viewDirection)
220 if (worldTimeGeometry.IsNotNull())
229 if (slicedWorldGeometry.IsNotNull())
236 const auto *worldSlicedGeometry =
239 if ( worldSlicedGeometry !=
nullptr )
241 slicedWorldGeometry =
static_cast<SlicedGeometry3D *
>(currentGeometry->Clone().GetPointer());
246 slicedWorldGeometry->InitializePlanes(currentGeometry,
PlaneGeometry::None, top, frontside, rotated);
247 slicedWorldGeometry->SetSliceNavigationController(
this);
252 slicedWorldGeometry->InitializePlanes(currentGeometry,
PlaneGeometry::Axial, top, frontside, rotated);
253 slicedWorldGeometry->SetSliceNavigationController(
this);
259 slicedWorldGeometry->SetSliceNavigationController(
this);
265 slicedWorldGeometry->SetSliceNavigationController(
this);
268 itkExceptionMacro(
"unknown ViewDirection");
272 m_Slice->SetSteps((
int)slicedWorldGeometry->GetSlices());
274 if ( worldTimeGeometry.IsNull() )
277 createdTimeGeometry->Initialize( slicedWorldGeometry, 1 );
282 m_Time->InvalidateRange();
287 m_Time->SetSteps(worldTimeGeometry->CountTimeSteps());
290 const TimeBounds &timeBounds = worldTimeGeometry->GetTimeBounds();
291 m_Time->SetRange(timeBounds[0], timeBounds[1]);
295 const auto currentTemporalPosition = this->
GetTime()->
GetPos();
296 assert( worldTimeGeometry->GetGeometryForTimeStep( currentTemporalPosition ).IsNotNull() );
298 if ( dynamic_cast<const mitk::ProportionalTimeGeometry*>( worldTimeGeometry.GetPointer() ) !=
nullptr )
301 worldTimeGeometry->TimeStepToTimePoint( currentTemporalPosition );
304 worldTimeGeometry->TimeStepToTimePoint( currentTemporalPosition + 1 ) - minimumTimePoint;
307 createdTimeGeometry->Initialize( slicedWorldGeometry, worldTimeGeometry->CountTimeSteps() );
308 createdTimeGeometry->SetFirstTimePoint( minimumTimePoint );
309 createdTimeGeometry->SetStepDuration( stepDuration );
316 const TimeStepType numberOfTimeSteps = worldTimeGeometry->CountTimeSteps();
317 createdTimeGeometry->ReserveSpaceForGeometries( numberOfTimeSteps );
322 const auto bounds = worldTimeGeometry->GetTimeBounds( i );
323 createdTimeGeometry->AppendNewTimeStep( clonedGeometry,
324 bounds[0], bounds[1]);
326 createdTimeGeometry->Update();
397 const auto *timeEvent =
399 assert( timeEvent !=
nullptr );
401 TimeGeometry *timeGeometry = timeEvent->GetTimeGeometry();
402 assert( timeGeometry !=
nullptr );
404 auto timeStep = (int)timeEvent->GetPos();
413 const auto *sliceEvent =
415 assert(sliceEvent!=
nullptr);
431 if (slicedWorldGeometry)
437 slices = slicedWorldGeometry->
GetSlices();
445 plane->
Project(point, projectedPoint);
449 if (direction[0] * (point[0] - projectedPoint[0]) + direction[1] * (point[1] - projectedPoint[1]) +
450 direction[2] * (point[2] - projectedPoint[2]) >=
453 bestSlice = (int)(plane->
Distance(point) / slicedWorldGeometry->
GetSpacing()[2] + 0.5);
459 for (s = 0; s < slices; ++s)
462 const Vector3D distance = projectedPoint - point;
463 ScalarType currentDistance = distance.GetSquaredNorm();
465 if (currentDistance < bestDistance)
467 bestDistance = currentDistance;
528 const auto *slicedGeometry =
534 return planeGeometry;
546 const auto *slicedGeometry =
549 const Vector3D &direction = slicedGeometry->GetDirectionVector();
553 for (i = 0; i < 3; ++i)
555 if (fabs(direction[i]) < 0.000000001)
596 if (po && po->GetIndex() == -1)
601 po->GetIndex() != -1)
virtual const mitk::TimeGeometry * GetCreatedWorldGeometry()
Access the created geometry.
virtual void SendCreatedWorldGeometry()
Send the created geometry to the connected observers (renderers)
mitk::Stepper * GetSlice()
Get the Stepper through the slices.
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
ViewDirection m_DefaultViewDirection
void SelectSliceByPoint(const mitk::Point3D &point)
Positions the SNC according to the specified point.
itk::FixedArray< ScalarType, 2 > TimeBounds
Standard typedef for time-bounds.
itk::SmartPointer< Self > Pointer
Baseclass for renderer slice-/camera-control.
Base class of all Operation-classes.
void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry)
mitk::TimeGeometry::Pointer m_CreatedWorldGeometry
ViewDirection m_ViewDirection
virtual void SetViewDirectionToDefault()
void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &normal)
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. If you want to define them clearly, use ReorientSlices (const mitk::Point3D &point, const mitk::Vector3D &axisVec0, const mitk::Vector3D &axisVec1).
Organizes the rendering process.
virtual unsigned int GetSlices() const
Get the number of slices.
DataCollection - Class to facilitate loading/accessing structured data.
Constants for most interaction classes, due to the generic StateMachines.
virtual void SetRotated(bool _arg)
virtual const mitk::Vector3D & GetDirectionVector() const
virtual void SetFrontSide(bool _arg)
unsigned long m_LastUpdateTime
virtual bool Project(const mitk::Point3D &pt3d_mm, mitk::Point3D &projectedPt3d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 3D point in mm (projec...
void ExecuteOperation(Operation *operation) override
virtual bool GetEvenlySpaced() const
Set/Get whether the SlicedGeometry3D is evenly-spaced (m_EvenlySpaced)
virtual mitk::PlaneGeometry * GetPlaneGeometry(int s) const
Returns the PlaneGeometry of the slice (s).
~SliceNavigationController() override
virtual void SetTop(bool _arg)
virtual void SetGeometryTime(const itk::EventObject &geometryTimeEvent)
To connect multiple SliceNavigationController, we can act as an observer ourselves: implemented inter...
Message1< mitk::Point3D > SetCrosshairEvent
virtual void SendSlice()
Send the currently selected slice to the connected observers (renderers)
mitk::BaseRenderer * m_Renderer
const char * GetViewDirectionAsString() const
Manager for coordinating the rendering process.
static RenderingManager * GetInstance()
virtual void SetGeometry(const itk::EventObject &geometrySliceEvent)
To connect multiple SliceNavigationController, we can act as an observer ourselves: implemented inter...
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...
void SetRenderer(BaseRenderer *renderer)
Sets the BaseRenderer associated with this SNC (if any). While the BaseRenderer is not directly used ...
const mitk::PlaneGeometry * GetCurrentPlaneGeometry()
Returns the currently selected Plane in the current BaseGeometry (if existent).
virtual TimePointType TimeStepToTimePoint(TimeStepType timeStep) const =0
Converts a time step to a time point.
Operation that handles all actions on one Point.
Operation for setting a plane (defined by its origin and normal)
mitk::ScalarType TimePointType
std::vcl_size_t TimeStepType
virtual void SetPos(unsigned int pos)
itk::SmartPointer< Self > Pointer
Describes the geometry of a data object consisting of slices.
virtual void SendCreatedWorldGeometryUpdate()
Tell observers to re-read the currently selected 2D geometry.
void AdjustSliceStepperRange()
Adjusts the numerical range of the slice stepper according to the current geometry orientation of thi...
const mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
mitk::BaseGeometry::ConstPointer m_InputWorldGeometry3D
mitk::TimeGeometry::ConstPointer m_InputWorldTimeGeometry
itk::SmartPointer< const Self > ConstPointer
SliceNavigationController()
MITKCORE_EXPORT const ScalarType eps
ScalarType Distance(const Point3D &pt3d_mm) const
Distance of the point from the geometry (bounding-box not considered)
mitk::Stepper * GetTime()
Get the Stepper through the time.
virtual unsigned int GetPos() const
Describes a two-dimensional, rectangular plane.
const mitk::BaseGeometry * GetCurrentGeometry3D()
Returns the BaseGeometry of the currently selected time step.
virtual void SetGeometrySlice(const itk::EventObject &geometrySliceEvent)
To connect multiple SliceNavigationController, we can act as an observer ourselves: implemented inter...
itk::SmartPointer< const Self > ConstPointer
BaseRenderer * GetRenderer() const
Gets the BaseRenderer associated with this SNC (if any). While the BaseRenderer is not directly used ...
OperationType GetOperationType()
void SetInputWorldGeometry3D(const mitk::BaseGeometry *geometry)
Set the input world geometry3D out of which the geometries for slicing will be created.
virtual void Update()
Do the actual creation and send it to the connected observers (renderers)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
virtual const BoundingBoxType * GetBoundingBox()
virtual void SendTime()
Send the currently selected time to the connected observers (renderers)