25 #include <vtkRenderWindow.h>
28 #include <itkAffineGeometryFrame.h>
29 #include <itkCommand.h>
30 #include <itkScalableAffineTransform.h>
39 RenderingManager::
Pointer RenderingManager::s_Instance = 0;
40 RenderingManagerFactory *RenderingManager::s_RenderingManagerFactory = 0;
43 : m_UpdatePending(false),
45 m_LODIncreaseBlocked(false),
46 m_LODAbortMechanismEnabled(false),
47 m_ClippingPlaneEnabled(false),
50 m_ConstrainedPanningZooming(true),
51 m_FocusedRenderWindow(
nullptr)
53 m_ShadingEnabled.assign(3,
false);
54 m_ShadingValues.assign(4, 0.0);
56 InitializePropertyList();
63 RenderWindowVector::iterator it;
66 (*it)->UnRegister(NULL);
72 (*it)->RemoveObserver(callbacks_it->second.commands[0u]);
73 (*it)->RemoveObserver(callbacks_it->second.commands[1u]);
74 (*it)->RemoveObserver(callbacks_it->second.commands[2u]);
133 renderWindow->Register(NULL);
139 renderWindow->AddObserver(vtkCommand::StartEvent, startCallbackCommand);
143 renderWindow->AddObserver(vtkCommand::AbortCheckEvent, progressCallbackCommand);
147 renderWindow->AddObserver(vtkCommand::EndEvent, endCallbackCommand);
151 callbacks.
commands[0u] = startCallbackCommand;
152 callbacks.
commands[1u] = progressCallbackCommand;
153 callbacks.
commands[2u] = endCallbackCommand;
157 startCallbackCommand->Delete();
158 progressCallbackCommand->Delete();
159 endCallbackCommand->Delete();
170 renderWindow->RemoveObserver(callbacks_it->second.commands[0u]);
171 renderWindow->RemoveObserver(callbacks_it->second.commands[1u]);
172 renderWindow->RemoveObserver(callbacks_it->second.commands[2u]);
176 RenderWindowVector::iterator rw_it =
182 (*rw_it)->UnRegister(NULL);
237 int *size = renderWindow->GetSize();
238 if (0 != size[0] && 0 != size[1])
247 renderWindow->Render();
253 RenderWindowList::const_iterator it;
267 RenderWindowList::const_iterator it;
302 bool preserveRoughOrientationInWorldSpace)
305 propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(dataGeometry->
Clone().GetPointer()), 1);
306 return InitializeViews(propTimeGeometry, type, preserveRoughOrientationInWorldSpace);
315 bool boundingBoxInitialized =
false;
319 if (dataGeometry != NULL)
321 modifiedGeometry = dataGeometry->
Clone();
324 int warningLevel = vtkObject::GetGlobalWarningDisplay();
325 vtkObject::GlobalWarningDisplayOff();
327 if ((timeGeometry.IsNotNull()) &&
328 (const_cast<mitk::BoundingBox *>(timeGeometry->GetBoundingBoxInWorld())->GetDiagonalLength2() >
mitk::eps))
330 boundingBoxInitialized =
true;
333 if (timeGeometry.IsNotNull())
337 assert(modifiedGeometry.IsNotNull());
338 for (
TimeStepType step = 0; step < modifiedGeometry->CountTimeSteps(); ++step)
341 for (
unsigned int dimension = 0; (2 * dimension) < newBounds.Size(); dimension++)
344 if (
Equal(newBounds[2 * dimension], newBounds[2 * dimension + 1]))
346 newBounds[2 * dimension + 1] += 1;
348 newBounds[2 * dimension],
349 newBounds[2 * dimension + 1]))
351 mitkThrow() <<
"One dimension of object data has zero length, please make sure you're not using numbers "
352 "beyond double precision as coordinates.";
356 modifiedGeometry->GetGeometryForTimeStep(step)->SetBounds(newBounds);
360 timeGeometry = modifiedGeometry;
361 RenderWindowList::const_iterator it;
372 this->InternalViewInitialization(baseRenderer, timeGeometry, boundingBoxInitialized,
id);
376 if (boundingBoxInitialized)
384 vtkObject::SetGlobalWarningDisplay(warningLevel);
387 this->InvokeEvent(mitk::RenderingManagerViewsInitializedEvent());
389 return boundingBoxInitialized;
394 RenderWindowList::const_iterator it;
421 bool initializeGlobalTimeSNC)
424 propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(geometry->
Clone().GetPointer()), 1);
425 return InitializeView(renderWindow, propTimeGeometry, initializeGlobalTimeSNC);
430 bool initializeGlobalTimeSNC)
432 bool boundingBoxInitialized =
false;
434 int warningLevel = vtkObject::GetGlobalWarningDisplay();
435 vtkObject::GlobalWarningDisplayOff();
437 if ((geometry != NULL) &&
440 boundingBoxInitialized =
true;
447 this->InternalViewInitialization(baseRenderer, geometry, boundingBoxInitialized,
id);
449 if (boundingBoxInitialized && initializeGlobalTimeSNC)
457 vtkObject::SetGlobalWarningDisplay(warningLevel);
459 return boundingBoxInitialized;
481 bool boundingBoxInitialized,
489 if (boundingBoxInitialized)
526 RenderWindowList::const_iterator it;
539 vtkRenderWindow *renderWindow =
dynamic_cast<vtkRenderWindow *
>(caller);
553 vtkRenderWindow *renderWindow =
dynamic_cast<vtkRenderWindow *
>(caller);
558 vtkRenderWindow *renderWindow =
dynamic_cast<vtkRenderWindow *
>(caller);
572 vtkRenderWindow *renderWindow =
dynamic_cast<vtkRenderWindow *
>(caller);
590 if (nextLODMap[renderer] == 0)
593 nextLODMap[renderer] = 0;
601 RenderWindowList::const_iterator it;
614 RenderWindowList::const_iterator it;
619 it->first->SetAbortRender(
true);
627 if (renderer != NULL)
639 RenderWindowList::const_iterator it;
661 itkWarningMacro(<<
"LOD out of range requested: " << lod <<
" maxLOD: " <<
m_MaxLOD);
671 itkWarningMacro(<<
"LOD out of range requested: " << lod <<
" maxLOD: " <<
m_MaxLOD);
718 RenderingManager::RenderWindowVector::const_iterator iter;
729 if (focusWindow != m_FocusedRenderWindow)
733 m_FocusedRenderWindow = focusWindow;
734 this->InvokeEvent(FocusChangedEvent());
738 MITK_ERROR <<
"Tried to set a RenderWindow that does not exist.";
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.
RenderWindowList m_RenderWindowList
static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Data management class that handles 'was created by' relations.
const SliceNavigationController * GetTimeNavigationController() const
itk::SmartPointer< Self > Pointer
PropertyList::Pointer GetPropertyList() const
itkEventMacroDefinition(OverlayAddEvent, itk::AnyEvent) OverlayManager
virtual void DoMonitorRendering()
BoundingBoxType::BoundsArrayType BoundsArrayType
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
void RemoveRenderWindow(vtkRenderWindow *renderWindow)
RendererBoolMap m_RenderingAbortedMap
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
unsigned int GetNumberOfVisibleLODEnabledMappers() const
static bool IsInstantiated()
void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry)
virtual void GenerateRenderingRequestEvent()=0
virtual void SetConstrainZoomingAndPanning(bool constrain)
bool m_ClippingPlaneEnabled
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()
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
FloatVector & GetShadingValues()
virtual void SetViewToAnterior()
virtual ~RenderingManager()
static RenderingManagerFactory * s_RenderingManagerFactory
void SetClippingPlaneStatus(bool status)
RenderWindowVector m_AllRenderWindows
virtual void StartOrResetTimer()
Controls the selection of the slice the associated BaseRenderer will display.
bool m_ConstrainedPanningZooming
itk::SmartPointer< const Self > ConstPointer
virtual unsigned int GetSteps() const
Abstract base class for properties.
void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
mitk::DataStorage::Pointer m_DataStorage
virtual mitk::RenderingManager * GetRenderingManager() const
Setter for the RenderingManager that handles this instance of BaseRenderer.
void SetRenderWindowFocus(vtkRenderWindow *focusWindow)
Sets a flag to the given renderwindow to indicated that it has the focus e.g. has been clicked recent...
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
returns a set of data objects that meet the given condition(s)
Manager for coordinating the rendering process.
RenderWindowCallbacksList m_RenderWindowCallbacksList
void SetShadingValues(float ambient, float diffuse, float specular, float specpower)
static RenderingManager * GetInstance()
std::map< vtkRenderWindow *, int > RenderWindowList
virtual CameraController * GetCameraController()
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.
std::map< BaseRenderer *, unsigned int > RendererIntMap
RendererIntMap m_NextLODMap
bool GetShading(unsigned int lod)
mitk::TimeGeometry::Pointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const mitk::BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of the input objects.
void RequestUpdate(vtkRenderWindow *renderWindow)
bool m_LODAbortMechanismEnabled
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 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()
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
BaseProperty * GetProperty(const char *propertyKey) const
itk::SmartPointer< SliceNavigationController > m_TimeNavigationController
BoolVector m_ShadingEnabled
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.