21 #include <vtkRenderWindow.h> 22 #include <vtkRendererCollection.h> 25 #include <itkAffineGeometryFrame.h> 26 #include <itkCommand.h> 27 #include <itkScalableAffineTransform.h> 40 : m_UpdatePending(false),
42 m_LODIncreaseBlocked(false),
43 m_LODAbortMechanismEnabled(false),
44 m_ClippingPlaneEnabled(false),
47 m_ConstrainedPanningZooming(true),
48 m_FocusedRenderWindow(nullptr),
61 RenderWindowVector::iterator it;
64 (*it)->UnRegister(
nullptr);
70 (*it)->RemoveObserver(callbacks_it->second.commands[0u]);
71 (*it)->RemoveObserver(callbacks_it->second.commands[1u]);
72 (*it)->RemoveObserver(callbacks_it->second.commands[2u]);
81 if (RenderingManager::s_RenderingManagerFactory)
94 if (factory ==
nullptr)
101 if (!RenderingManager::s_Instance)
114 if (RenderingManager::s_Instance)
131 renderWindow->Register(
nullptr);
135 vtkCallbackCommand *startCallbackCommand = vtkCallbackCommand::New();
137 renderWindow->AddObserver(vtkCommand::StartEvent, startCallbackCommand);
139 vtkCallbackCommand *progressCallbackCommand = vtkCallbackCommand::New();
141 renderWindow->AddObserver(vtkCommand::AbortCheckEvent, progressCallbackCommand);
143 vtkCallbackCommand *endCallbackCommand = vtkCallbackCommand::New();
145 renderWindow->AddObserver(vtkCommand::EndEvent, endCallbackCommand);
149 callbacks.
commands[0u] = startCallbackCommand;
150 callbacks.
commands[1u] = progressCallbackCommand;
151 callbacks.
commands[2u] = endCallbackCommand;
155 startCallbackCommand->Delete();
156 progressCallbackCommand->Delete();
157 endCallbackCommand->Delete();
168 renderWindow->RemoveObserver(callbacks_it->second.commands[0u]);
169 renderWindow->RemoveObserver(callbacks_it->second.commands[1u]);
170 renderWindow->RemoveObserver(callbacks_it->second.commands[2u]);
180 (*rw_it)->UnRegister(
nullptr);
235 int *size = renderWindow->GetSize();
236 if (0 != size[0] && 0 != size[1])
245 renderWindow->Render();
251 RenderWindowList::const_iterator it;
265 RenderWindowList::const_iterator it;
288 mitk::DataStorage::SetOfObjects::ConstPointer rs = ds->
GetSubset(pred);
300 bool preserveRoughOrientationInWorldSpace)
303 propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(dataGeometry->
Clone().GetPointer()), 1);
304 return InitializeViews(propTimeGeometry, type, preserveRoughOrientationInWorldSpace);
313 bool boundingBoxInitialized =
false;
317 if (dataGeometry !=
nullptr)
319 modifiedGeometry = dataGeometry->
Clone();
322 int warningLevel = vtkObject::GetGlobalWarningDisplay();
323 vtkObject::GlobalWarningDisplayOff();
325 if ((timeGeometry.IsNotNull()) &&
326 (timeGeometry->GetBoundingBoxInWorld()->GetDiagonalLength2() >
mitk::eps))
328 boundingBoxInitialized =
true;
331 if (timeGeometry.IsNotNull())
335 assert(modifiedGeometry.IsNotNull());
336 for (
TimeStepType step = 0; step < modifiedGeometry->CountTimeSteps(); ++step)
339 for (
unsigned int dimension = 0; (2 * dimension) < newBounds.Size(); dimension++)
342 if (
Equal(newBounds[2 * dimension], newBounds[2 * dimension + 1]))
344 newBounds[2 * dimension + 1] += 1;
346 newBounds[2 * dimension],
347 newBounds[2 * dimension + 1]))
349 mitkThrow() <<
"One dimension of object data has zero length, please make sure you're not using numbers " 350 "beyond double precision as coordinates.";
354 modifiedGeometry->GetGeometryForTimeStep(step)->SetBounds(newBounds);
358 timeGeometry = modifiedGeometry;
359 RenderWindowList::const_iterator it;
370 this->InternalViewInitialization(baseRenderer, timeGeometry, boundingBoxInitialized,
id);
374 if (boundingBoxInitialized)
382 vtkObject::SetGlobalWarningDisplay(warningLevel);
385 this->InvokeEvent(mitk::RenderingManagerViewsInitializedEvent());
387 return boundingBoxInitialized;
392 RenderWindowList::const_iterator it;
419 bool initializeGlobalTimeSNC)
422 propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(geometry->
Clone().GetPointer()), 1);
423 return InitializeView(renderWindow, propTimeGeometry, initializeGlobalTimeSNC);
428 bool initializeGlobalTimeSNC)
430 bool boundingBoxInitialized =
false;
432 int warningLevel = vtkObject::GetGlobalWarningDisplay();
433 vtkObject::GlobalWarningDisplayOff();
435 if ((geometry !=
nullptr) &&
438 boundingBoxInitialized =
true;
445 this->InternalViewInitialization(baseRenderer, geometry, boundingBoxInitialized,
id);
447 if (boundingBoxInitialized && initializeGlobalTimeSNC)
455 vtkObject::SetGlobalWarningDisplay(warningLevel);
457 return boundingBoxInitialized;
479 bool boundingBoxInitialized,
487 if (boundingBoxInitialized)
524 RenderWindowList::const_iterator it;
538 auto renderWindow =
dynamic_cast<vtkRenderWindow*
>(caller);
540 if (
nullptr != renderWindow)
543 renderingManager->m_UpdatePending =
false;
550 if (renderingManager->m_LODAbortMechanismEnabled)
552 auto renderWindow =
dynamic_cast<vtkRenderWindow *
>(caller);
554 if (
nullptr != renderWindow)
558 if (
nullptr != renderer && 0 < renderer->GetNumberOfVisibleLODEnabledMappers())
559 renderingManager->DoMonitorRendering();
566 auto renderWindow =
dynamic_cast<vtkRenderWindow*
>(caller);
568 if (
nullptr != renderWindow)
572 if (
nullptr != renderer)
575 renderingManager->m_RenderWindowList[renderer->GetRenderWindow()] =
RENDERING_INACTIVE;
577 if (0 < renderer->GetNumberOfVisibleLODEnabledMappers())
579 if (0 == renderingManager->m_NextLODMap[renderer])
581 renderingManager->StartOrResetTimer();
585 renderingManager->m_NextLODMap[renderer] = 0;
594 RenderWindowList::const_iterator it;
607 RenderWindowList::const_iterator it;
612 it->first->SetAbortRender(
true);
620 if (renderer !=
nullptr)
632 RenderWindowList::const_iterator it;
654 itkWarningMacro(<<
"LOD out of range requested: " << lod <<
" maxLOD: " <<
m_MaxLOD);
664 itkWarningMacro(<<
"LOD out of range requested: " << lod <<
" maxLOD: " <<
m_MaxLOD);
707 if (storage !=
nullptr)
711 RenderingManager::RenderWindowVector::const_iterator iter;
722 if (focusWindow != m_FocusedRenderWindow)
726 m_FocusedRenderWindow = focusWindow;
727 this->InvokeEvent(FocusChangedEvent());
731 MITK_ERROR <<
"Tried to set a RenderWindow that does not exist.";
737 if (m_AntiAliasing != antiAliasing)
740 auto renderWindows = renderingManager->GetAllRegisteredRenderWindows();
742 for (
auto renderWindow : renderWindows)
744 auto renderers = renderWindow->GetRenderers();
746 if (
nullptr != renderers)
748 renderers->InitTraversal();
749 auto renderer = renderers->GetNextItem();
751 while (
nullptr != renderer)
754 renderer = renderers->GetNextItem();
757 renderingManager->RequestUpdate(renderWindow);
761 m_AntiAliasing = antiAliasing;
bool GetClippingPlaneStatus()
virtual void InitializePropertyList()
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
static const RenderingManagerFactory * GetFactory()
mitk::Stepper * GetSlice()
Get the Stepper through the slices.
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
RenderWindowList m_RenderWindowList
static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Data management class that handles 'was created by' relations.
unsigned int GetNumberOfVisibleLODEnabledMappers() const
BoundingBoxType::BoundsArrayType BoundsArrayType
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
itkEventMacroDefinition(FocusChangedEvent, itk::AnyEvent)
void RemoveRenderWindow(vtkRenderWindow *renderWindow)
static RenderingManagerFactory * s_RenderingManagerFactory
RendererBoolMap m_RenderingAbortedMap
static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
static bool IsInstantiated()
void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry)
virtual void GenerateRenderingRequestEvent()=0
virtual void SetConstrainZoomingAndPanning(bool constrain)
bool m_ClippingPlaneEnabled
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of the input objects.
virtual void SetDataStorage(DataStorage *storage)
set the datastorage that will be used for rendering
static RenderingManager::Pointer s_Instance
void SetMaximumLOD(unsigned int max)
virtual void SetViewDirectionToDefault()
std::vector< float > FloatVector
virtual void ExecutePendingRequests()
void SetAntiAliasing(AntiAliasing antiAliasing)
Organizes the rendering process.
PropertyList::Pointer GetPropertyList() const
DataCollection - Class to facilitate loading/accessing structured data.
FloatVector & GetShadingValues()
virtual void SetViewToAnterior()
void SetClippingPlaneStatus(bool status)
RenderWindowVector m_AllRenderWindows
const SliceNavigationController * GetTimeNavigationController() const
itk::SmartPointer< Self > Pointer
Controls the selection of the slice the associated BaseRenderer will display.
bool m_ConstrainedPanningZooming
Abstract base class for properties.
void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
mitk::DataStorage::Pointer m_DataStorage
void SetRenderWindowFocus(vtkRenderWindow *focusWindow)
Sets a flag to the given renderwindow to indicated that it has the focus e.g. has been clicked recent...
Manager for coordinating the rendering process.
RenderWindowCallbacksList m_RenderWindowCallbacksList
void SetShadingValues(float ambient, float diffuse, float specular, float specpower)
static RenderingManager * GetInstance()
virtual CameraController * GetCameraController()
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
returns a set of data objects that meet the given condition(s)
Factory interface for facilitating the usage of a platform-specific mitk::RenderingManager instance...
static Pointer New(const mitk::NodePredicateBase *_arg)
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
DataStoragePointer m_DataStorage
void SetDataStorage(mitk::DataStorage *storage)
Setter / Getter for internal DataStorage.
std::vcl_size_t TimeStepType
virtual void SetPos(unsigned int pos)
void ForceImmediateUpdate(vtkRenderWindow *renderWindow)
std::vector< vtkRenderWindow * > RenderWindowVector
int GetNextLOD(BaseRenderer *renderer)
static Pointer New(const char *_arg)
virtual RenderingManager::Pointer CreateRenderingManager() const =0
Factory method to create platform specific instances of RenderingManager.
BaseProperty * GetProperty(const char *propertyKey) const
RendererIntMap m_NextLODMap
bool GetShading(unsigned int lod)
void RequestUpdate(vtkRenderWindow *renderWindow)
~RenderingManager() override
virtual void PrepareRender()
This methods contains all method neceassary before a VTK Render() call.
void AddRenderWindow(vtkRenderWindow *renderWindow)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
void ForceImmediateUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
void SetShading(bool state, unsigned int lod)
void ExecutePendingHighResRenderingRequest()
PropertyList::Pointer m_PropertyList
FloatVector m_ShadingValues
vtkCallbackCommand * commands[3u]
MITKCORE_EXPORT const ScalarType eps
TestingRenderingManagerFactory renderingManagerFactory
virtual unsigned int GetSteps() const
virtual SliceNavigationController * GetSliceNavigationController()
static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
mitk::SliceNavigationController * m_TimeNavigationController
static void SetFactory(RenderingManagerFactory *factory)
mitk::DataStorage * GetDataStorage()
Setter / Getter for internal DataStorage.
void Fit()
Fit Adjust the camera, so that the world bounding box is fully visible.
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
virtual void Update()
Do the actual creation and send it to the connected observers (renderers)
virtual bool InitializeView(vtkRenderWindow *renderWindow, const BaseGeometry *geometry, bool initializeGlobalTimeSNC=false)
const RenderWindowVector & GetAllRegisteredRenderWindows()
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
itk::SmartPointer< SliceNavigationController > m_TimeNavigationController
BoolVector m_ShadingEnabled