Difference between revisions of "Documentation/4.1/Developers/DisplayableManagers"

From Slicer Wiki
Jump to: navigation, search
(Created page with '=Displayable Managers= To be written. =How a view is refreshed= It's the 3D view (ctkVTKAbstractView) that controls WHEN the vtkRenderWindow::Render is called. There are 2 ways …')
 
(Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
<noinclude>{{documentation/versioncheck}}</noinclude>
 
=Displayable Managers=
 
=Displayable Managers=
 
To be written.
 
To be written.
 +
 +
==Build==
 +
Displayable managers are instantiated from their class name by the displayable manager groups. An instantiator must be included in the library containing the displayable manager. To do so, add in your CMakeLists.txt:
 +
set(displayable_manager_SRCS
 +
  vtkMRMXYZDisplayableManager.cxx
 +
  )
 +
set(VTK_USE_INSTANTIATOR_NEW 1)
 +
VTK_MAKE_INSTANTIATOR3("${MODULE_NAME}Instantiator"
 +
  displayable_manager_instantiator_SRCS
 +
  "${displayable_manager_SRCS}"
 +
  "${${KIT}_EXPORT_DIRECTIVE}"
 +
  ${CMAKE_CURRENT_BINARY_DIR}
 +
  "${KIT}Export.h"
 +
  )
 +
set(${KIT}_SRCS
 +
  ${displayable_manager_instantiator_SRCS}
 +
  ${displayable_manager_SRCS}
 +
  ...
 +
  )
 +
 +
==Register==
 +
Displayable managers must be registered as early as possible (before the first view is created.
 +
Therefore, displayable managers should be registered when modules are setup.
 +
void qSlicerXYZModule::setup()
 +
{
 +
  ...
 +
  // If the displayable manager is for 3D views:
 +
  vtkMRMLThreeDViewDisplayableManagerFactory::GetInstance()->RegisterDisplayableManager(
 +
      "vtkMRMLXYZDisplayableManager");
 +
  // If the displayable manager is for 2D views:
 +
  vtkMRMLSliceViewDisplayableManagerFactory::GetInstance()->RegisterDisplayableManager(
 +
      "vtkMRMLXYZDisplayableManager");
 +
  ...
 +
  }
  
 
=How a view is refreshed=
 
=How a view is refreshed=

Latest revision as of 07:25, 14 June 2013

Home < Documentation < 4.1 < Developers < DisplayableManagers


For the latest Slicer documentation, visit the read-the-docs.


Displayable Managers

To be written.

Build

Displayable managers are instantiated from their class name by the displayable manager groups. An instantiator must be included in the library containing the displayable manager. To do so, add in your CMakeLists.txt:

set(displayable_manager_SRCS
 vtkMRMXYZDisplayableManager.cxx
 )
set(VTK_USE_INSTANTIATOR_NEW 1)
VTK_MAKE_INSTANTIATOR3("${MODULE_NAME}Instantiator"
  displayable_manager_instantiator_SRCS
  "${displayable_manager_SRCS}"
  "${${KIT}_EXPORT_DIRECTIVE}"
  ${CMAKE_CURRENT_BINARY_DIR}
  "${KIT}Export.h"
  )
set(${KIT}_SRCS
  ${displayable_manager_instantiator_SRCS}
  ${displayable_manager_SRCS}
  ...
  )

Register

Displayable managers must be registered as early as possible (before the first view is created. Therefore, displayable managers should be registered when modules are setup.

void qSlicerXYZModule::setup()
{
  ...
  // If the displayable manager is for 3D views:
  vtkMRMLThreeDViewDisplayableManagerFactory::GetInstance()->RegisterDisplayableManager(
     "vtkMRMLXYZDisplayableManager");
  // If the displayable manager is for 2D views:
  vtkMRMLSliceViewDisplayableManagerFactory::GetInstance()->RegisterDisplayableManager(
     "vtkMRMLXYZDisplayableManager");
  ...
 }

How a view is refreshed

It's the 3D view (ctkVTKAbstractView) that controls WHEN the vtkRenderWindow::Render is called. There are 2 ways to tell the view to re-render:

  1. vtkRenderWindowInteractor::Render() is called (by vtkInteractorStyle when the mouse is moved or by some vtkWidgets that call it internally). The request is blocked and ctkAbstractView::scheduleRender() is called on the view.
  2. or it is done by the vtkMRMLDisplayableManagers (e.g. vtkMRMLVolumeRenderingDisplayableManager) by the RequestRender() calls. They call vtkMRMLDisplayableManagerGroup::RequestRender() which fires a vtkCommand::UpdateEvent. The Qt view (e.g. qMRMLThreeDView) observes the UpdateEvent and calls ctkVTKAbstractView::scheduleRender().

The CTK view compacts the render requests and ensure the FPS (vtkRenderWindow::GetDesiredUpdateRate()) is respected.

 vtkInteractorStyle ---------------------------\
 vtkWidget -------------------------------------> vtkRenderWindowInteractor::Render() ------------------------------\
 vtkMRML???DisplayableManager::RequestRender() -> vtkMRML???DisplayableManagerGroup::RequestRender() -> UpdateEvent -> ctkVTKAbstractView::scheduleRender()