33 #include <vtkCamera.h> 34 #include <vtkLinearTransform.h> 35 #include <vtkRenderWindow.h> 36 #include <vtkRenderer.h> 39 #include <vtkPolyDataMapper.h> 40 #include <vtkProperty.h> 48 if ((*mapit).first == renWin)
49 return (*mapit).second;
56 if (renWin ==
nullptr || baseRenderer ==
nullptr)
62 baseRendererMap.insert(BaseRendererMapType::value_type(renWin, baseRenderer));
76 if ((*mapit).second->m_Name == name)
77 return (*mapit).second;
86 if ((*mapit).second->m_Name == name)
87 return (*mapit).first;
93 vtkRenderWindow *renWin)
102 m_WorldTimeGeometry(nullptr),
103 m_CurrentWorldGeometry(nullptr),
104 m_CurrentWorldPlaneGeometry(nullptr),
107 m_CurrentWorldPlaneGeometryUpdateTime(),
108 m_TimeStepUpdateTime(),
109 m_KeepDisplayedRegion(true),
130 m_Name =
"unnamed renderer";
131 itkWarningMacro(<<
"Created unnamed renderer. Bad for serialization. Please choose a name.");
134 if (renWin !=
nullptr)
141 itkWarningMacro(<<
"Created mitkBaseRenderer without vtkRenderWindow present.");
166 sliceNavigationController->SetRenderer(
this);
167 sliceNavigationController->ConnectGeometrySliceEvent(
this);
168 sliceNavigationController->ConnectGeometryUpdateEvent(
this);
169 sliceNavigationController->ConnectGeometryTimeEvent(
this,
false);
212 if (m_BindDispatcherInteractor !=
nullptr)
214 delete m_BindDispatcherInteractor;
226 this->InvokeEvent(mitk::BaseRenderer::RendererResetEvent());
228 std::list<mitk::BaseLocalStorageHandler *>::iterator it;
230 (*it)->ClearLocalStorage(
this,
false);
303 if (m_Slice != slice)
306 if (m_WorldTimeGeometry.IsNotNull())
310 dynamic_cast<SlicedGeometry3D *
>(m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep).GetPointer());
311 if (slicedWorldGeometry !=
nullptr)
314 if (m_Slice >= slicedWorldGeometry->
GetSlices())
316 m_Slice = slicedWorldGeometry->
GetSlices() - 1;
328 if (m_TimeStep != timeStep)
330 m_TimeStep = timeStep;
331 m_TimeStepUpdateTime.Modified();
333 if (m_WorldTimeGeometry.IsNotNull())
335 if (m_TimeStep >= m_WorldTimeGeometry->CountTimeSteps())
336 m_TimeStep = m_WorldTimeGeometry->CountTimeSteps() - 1;
338 dynamic_cast<SlicedGeometry3D *
>(m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep).GetPointer());
339 if (slicedWorldGeometry !=
nullptr)
361 if (m_WorldTimeGeometry.IsNull())
368 if (timeInMS == itk::NumericTraits<mitk::ScalarType>::NonpositiveMin())
377 assert(geometry !=
nullptr);
379 itkDebugMacro(
"setting WorldTimeGeometry to " << geometry);
380 if (m_WorldTimeGeometry != geometry)
385 m_WorldTimeGeometry = geometry;
386 itkDebugMacro(
"setting WorldTimeGeometry to " << m_WorldTimeGeometry);
388 if (m_TimeStep >= m_WorldTimeGeometry->CountTimeSteps())
389 m_TimeStep = m_WorldTimeGeometry->CountTimeSteps() - 1;
392 geometry3d = m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep);
399 itkDebugMacro(
"setting WorldGeometry3D to " << geometry);
407 if (slicedWorldGeometry !=
nullptr)
409 if (m_Slice >= slicedWorldGeometry->
GetSlices() && (m_Slice != 0))
410 m_Slice = slicedWorldGeometry->
GetSlices() - 1;
412 if (geometry2d.IsNull())
415 plane->InitializeStandardPlane(slicedWorldGeometry);
423 if (geometry2d.IsNull())
426 plane->InitializeStandardPlane(geometry);
433 if (m_CurrentWorldPlaneGeometry.IsNull())
434 itkWarningMacro(
"m_CurrentWorldPlaneGeometry is nullptr");
439 if (m_CurrentWorldPlaneGeometry != geometry2d)
441 m_CurrentWorldPlaneGeometry = geometry2d->
Clone();
443 m_CurrentWorldPlaneGeometryUpdateTime.Modified();
450 m_CurrentWorldPlaneGeometryUpdateTime.Modified();
465 m_CurrentWorldGeometry = geometry;
466 if (geometry ==
nullptr)
477 BoundingBox::Pointer boundingBox = m_CurrentWorldGeometry->CalculateBoundingBoxRelativeToTransform(
nullptr);
485 if (boundingBox->GetDiagonalLength2() <=
mitk::eps)
493 const auto *sendEvent =
496 assert(sendEvent !=
nullptr);
502 const auto *updateEvent =
505 if (updateEvent ==
nullptr)
508 if (m_CurrentWorldGeometry.IsNotNull())
510 auto *slicedWorldGeometry =
dynamic_cast<const SlicedGeometry3D *
>(m_CurrentWorldGeometry.GetPointer());
511 if (slicedWorldGeometry)
513 PlaneGeometry *geometry2D = slicedWorldGeometry->GetPlaneGeometry(m_Slice);
522 const auto *sliceEvent =
525 assert(sliceEvent !=
nullptr);
531 const auto *timeEvent =
534 assert(timeEvent !=
nullptr);
545 MITK_INFO <<
"BaseRenderer::DrawOverlayMouse()- should be inconcret implementation OpenGLRenderer." << std::endl;
569 if (SlicenavigationController ==
nullptr)
574 SlicenavigationController->
Update();
596 double *displayCoord;
600 this->
GetVtkRenderer()->GetActiveCamera()->GetFocalPoint(cameraFP);
602 this->
GetVtkRenderer()->SetWorldPoint(cameraFP[0], cameraFP[1], cameraFP[2], cameraFP[3]);
607 display[0] = displayPoint[0];
608 display[1] = displayPoint[1];
609 display[2] = displayCoord[2];
615 for (
int i = 0; i < 3; i++)
617 worldIndex[i] = world[i] / world[3];
636 this->m_CurrentWorldPlaneGeometry->Map(worldPoint, planePointInMM);
640 MITK_WARN <<
"No conversion possible with 3D mapper.";
651 world[0] = worldIndex[0];
652 world[1] = worldIndex[1];
653 world[2] = worldIndex[2];
660 displayPoint[0] = display[0];
661 displayPoint[1] = display[1];
668 double world[4], *view;
670 world[0] = worldIndex[0];
671 world[1] = worldIndex[1];
672 world[2] = worldIndex[2];
678 this->
GetVtkRenderer()->ViewToNormalizedViewport(view[0], view[1], view[2]);
689 this->m_CurrentWorldPlaneGeometry->Map(planePointInMM, worldPoint);
698 this->m_CurrentWorldPlaneGeometry->Map(planePointInMM, worldPoint);
737 Point2D displayGeometryOriginInMM;
739 return displayGeometryOriginInMM;
761 os << indent <<
" MapperID: " <<
m_MapperID << std::endl;
762 os << indent <<
" Slice: " << m_Slice << std::endl;
763 os << indent <<
" TimeStep: " << m_TimeStep << std::endl;
765 os << indent <<
" CurrentWorldPlaneGeometry: ";
766 if (m_CurrentWorldPlaneGeometry.IsNull())
767 os <<
"nullptr" << std::endl;
769 m_CurrentWorldPlaneGeometry->Print(os, indent);
771 os << indent <<
" CurrentWorldPlaneGeometryUpdateTime: " << m_CurrentWorldPlaneGeometryUpdateTime << std::endl;
774 Superclass::PrintSelf(os, indent);
std::map< vtkRenderWindow *, BaseRenderer * > BaseRendererMapType
PlaneGeometryData::Pointer m_CurrentWorldPlaneGeometryData
void DisplayToWorld(const Point2D &displayPoint, Point3D &worldIndex) const
This method converts a display point to the 3D world index using the geometry of the renderWindow...
virtual const mitk::TimeGeometry * GetCreatedWorldGeometry()
Access the created geometry.
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
BaseRenderer(const char *name=nullptr, vtkRenderWindow *renWin=nullptr)
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
Data management class that handles 'was created by' relations.
unsigned int GetNumberOfVisibleLODEnabledMappers() const
This Class is used to connect a DataStorage with the Dispatcher.
void SetSliceNavigationController(SliceNavigationController *SlicenavigationController)
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
static vtkRenderWindow * GetRenderWindowByName(const std::string &name)
void InsertSceneRenderer(vtkSmartPointer< vtkRenderer > renderer)
Base of all data objects.
vtkRenderer * GetVtkRenderer() const
void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry)
virtual void SetConstrainZoomingAndPanning(bool constrain)
virtual void SetDataStorage(DataStorage *storage)
set the datastorage that will be used for rendering
Point2D GetDisplaySizeInMM() const
virtual void Resize(int w, int h)
Called to inform the renderer that the RenderWindow has been resized.
bool m_ConstrainZoomingAndPanning
void PlaneToView(const Point2D &planePointInMM, Point2D &viewPoint) const
This method converts a 2D plane coordinate to the point on the viewport using the geometry of the ren...
Organizes the rendering process.
virtual void SetWorldTimeGeometry(const mitk::TimeGeometry *geometry)
double GetScaleFactorMMPerDisplayUnit() const
void ForceImmediateUpdate()
virtual unsigned int GetSlices() const
Get the number of slices.
std::list< mitk::BaseLocalStorageHandler * > m_RegisteredLocalStorageHandlers
virtual void SetTimeStep(unsigned int timeStep)
Set/Get m_TimeStep which defines together with m_Slice the 2D geometry stored in m_WorldTimeGeometry ...
Interface for accessing (templated) LocalStorageHandler instances.
void DisplayToPlane(const Point2D &displayPoint, Point2D &planePointInMM) const
This method converts a display point to the 2D world index, mapped onto the display plane using the g...
virtual void SetWorldGeometry3D(const BaseGeometry *geometry)
Set/Get the WorldGeometry (m_WorldGeometry) for 3D and 2D rendering, that describing the (maximal) ar...
static const MapperSlotId defaultMapper
Default mapper id to use.
Constants for most interaction classes, due to the generic StateMachines.
virtual int * GetSize() const
CameraRotationController::Pointer m_CameraRotationController
void PlaneToDisplay(const Point2D &planePointInMM, Point2D &displayPoint) const
This method converts a 2D plane coordinate to the display point using the geometry of the renderWindo...
unsigned long m_LastUpdateTime
Timestamp of last call of Update().
void WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
This method converts a 3D world index to the display point using the geometry of the renderWindow...
Controls the selection of the slice the associated BaseRenderer will display.
static void AddInstance(vtkSmartPointer< vtkRenderWindow > renWin, vtkSmartPointer< vtkRenderer > mitkSceneRenderer)
virtual mitk::PlaneGeometry * GetPlaneGeometry(int s) const
Returns the PlaneGeometry of the slice (s).
void SetDataStorage(DataStorage::Pointer dataStorage)
virtual void SetGeometrySlice(const itk::EventObject &geometrySliceEvent)
SetSlice is called according to the geometrySliceEvent, which is supposed to be a SliceNavigationCont...
const double * GetBounds() const
virtual void UpdateGeometry(const itk::EventObject &geometrySliceEvent)
UpdateWorldGeometry is called to re-read the 2D geometry from the slice navigation controller...
int GetSizeX() const
get the x_size of the RendererWindow
static VtkLayerController * GetInstance(vtkSmartPointer< vtkRenderWindow > renWin)
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
virtual void SetSlice(unsigned int slice)
Set/Get m_Slice which defines together with m_TimeStep the 2D geometry stored in m_WorldTimeGeometry ...
Dispatcher::Pointer GetDispatcher() const
int MapperSlotId
MapperSlotId defines which kind of mapper (e.g. 2D or 3D) should be used.
static RenderingManager * GetInstance()
virtual unsigned int GetTimeStep() const
virtual TimeStepType TimePointToTimeStep(TimePointType timePoint) const =0
Converts a time point to the corresponding time step.
virtual CameraController * GetCameraController()
static BaseRendererMapType baseRendererMap
virtual void InitSize(int w, int h)
Set the initial size. Called by RenderWindow after it has become visible for the first time...
unsigned long m_CurrentWorldPlaneGeometryTransformTime
test only
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
vtkRenderer * m_VtkRenderer
vtkRenderWindow * m_RenderWindow
virtual int * GetViewportSize() const
virtual void SetGeometry(const itk::EventObject &geometrySliceEvent)
SetWorldGeometry is called according to the geometrySliceEvent, which is supposed to be a SliceNaviga...
void ForceImmediateUpdate(vtkRenderWindow *renderWindow)
virtual void Paint()
Do the rendering and flush the result.
unsigned int m_NumberOfVisibleLODEnabledMappers
Describes the geometry of a data object consisting of slices.
virtual void PickWorldPoint(const Point2D &diplayPosition, Point3D &worldPosition) const =0
Perform a picking: find the x,y,z world coordinate of a display x,y coordinate.
void RequestUpdate(vtkRenderWindow *renderWindow)
DataStorage::Pointer m_DataStorage
The DataStorage that is used for rendering.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
Dispatcher::Pointer GetDispatcher() const
Returns the Dispatcher which handles Events for this BaseRenderer.
Point2D GetOriginInMM() const
virtual void SetGeometryTime(const itk::EventObject &geometryTimeEvent)
SetTimeStep is called according to the geometrySliceEvent, which is supposed to be a SliceNavigationC...
void RegisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh)
virtual void Initialize()
Initialize the RenderWindow. Should only be called from RenderWindow.
static BaseRenderer * GetByName(const std::string &name)
MITKCORE_EXPORT const ScalarType eps
virtual void SetCurrentWorldPlaneGeometry(const PlaneGeometry *geometry2d)
Sets m_CurrentWorldPlaneGeometry.
Point2D GetViewportSizeInMM() const
void RemoveAllLocalStorages()
Describes a two-dimensional, rectangular plane.
DataNode::Pointer m_CurrentWorldPlaneGeometryNode
static void RemoveInstance(vtkRenderWindow *renWin)
itk::SmartPointer< CameraController > m_CameraController
CameraController for 3D rendering.
void AdjustCameraToPlane()
AdjustCameraToPlane Moves the camera of a 2D Renderwindow without panning or zooming, eg. only rotate the camera.
MapperSlotId m_MapperID
MapperSlotId to use. Defines which kind of mapper (e.g., 2D or 3D) shoud be used. ...
virtual void Update()
Do the actual creation and send it to the connected observers (renderers)
void WorldToView(const Point3D &worldIndex, Point2D &viewPoint) const
This method converts a 3D world index to the point on the viewport using the geometry of the renderWi...
virtual Point3D Map2DRendererPositionTo3DWorldPosition(const Point2D &mousePosition) const
Provides (1) world coordinates for a given mouse position and (2) translates mousePosition to Display...
bool m_EmptyWorldGeometry
SliceNavigationController::Pointer m_SliceNavigationController
void SendUpdateSlice()
Sets timestamp of CurrentWorldPlaneGeometry and forces so reslicing in that renderwindow.
static void AddInstance(vtkRenderWindow *renWin, BaseRenderer *baseRenderer)
virtual void SetCurrentWorldGeometry(const BaseGeometry *geometry)
Sets m_CurrentWorldGeometry.
virtual void InitRenderer(vtkRenderWindow *renderwindow)
Initialize the renderer with a RenderWindow (renderwindow).
BaseGeometry Describes the geometry of a data object.
const char * GetName() const
get the name of the Renderer
int GetSizeY() const
get the y_size of the RendererWindow
static void RemoveInstance(vtkSmartPointer< vtkRenderWindow > renWin)
BoundingBoxType::BoundsArrayType BoundsArrayType
berry::Display * display
[MinimalApplicationClass_StartMethod]
virtual void DrawOverlayMouse(Point2D &p2d)
Draws a point on the widget. Should be used during conferences to show the position of the remote mou...
virtual const BoundingBoxType * GetBoundingBox()
void UnregisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh)