25 #include <vtkCamera.h>
26 #include <vtkRenderWindowInteractor.h>
34 : m_InteractionFilePath(interactionXmlFilePath)
42 TiXmlDocument document(interactionXmlFilePath);
43 bool loadOkay = document.LoadFile();
60 const char *rendererName =
67 int viewDirectionNum =
83 size[0] = size[1] = size[2] = 0;
101 if (size[0] != 0 && size[1] != 0)
103 rw->SetSize(size[0], size[1]);
104 rw->GetRenderer()->Resize(size[0], size[1]);
111 rw->GetSliceNavigationController()->SetDefaultViewDirection(viewDirection);
114 rw->GetRenderer()->SetMapperID(mapperID);
116 rw->GetRenderer()->PrepareRender();
125 double cameraFocalPoint[3];
127 cameraFocalPoint[0] =
129 cameraFocalPoint[1] =
131 cameraFocalPoint[2] =
133 rw->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetFocalPoint(cameraFocalPoint);
138 double cameraPosition[3];
143 rw->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetPosition(cameraPosition);
153 rw->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetViewUp(viewUp);
157 rw->GetVtkRenderWindow()->Render();
158 rw->GetVtkRenderWindow()->WaitForCompletion();
165 m_RenderWindowList.push_back(rw);
178 mitkThrow() <<
"Can not load interaction xml file <" << m_InteractionFilePath <<
">";
190 InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin();
191 InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end();
193 for (; it != end; ++it)
199 rm->RemoveAllObservers();
211 this->Set3dCameraSettings();
218 if (m_Events.empty())
219 this->LoadInteraction();
221 InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin();
222 InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end();
223 for (; it != end; ++it)
225 (*it)->GetRenderer()->PrepareRender();
227 (*it)->GetVtkRenderWindow()->Render();
228 (*it)->GetVtkRenderWindow()->WaitForCompletion();
232 it = m_RenderWindowList.begin();
233 for (; it != end; ++it)
235 (*it)->GetVtkRenderWindow()->Render();
236 (*it)->GetVtkRenderWindow()->WaitForCompletion();
241 for (
unsigned long i = 0; i < m_Events.size(); ++i)
244 m_Events.at(i)->GetSender()->GetDispatcher()->ProcessEvent(m_Events.at(i));
249 (*it)->GetVtkRenderWindow()->GetInteractor()->Start();
256 std::ifstream xmlStream(m_InteractionFilePath.c_str());
258 m_Events = parser.GetInteractions();
261 parser.SetReferenceCount(0);
268 bool timeStepIsvalid =
280 InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin();
281 InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end();
283 for (; it != end; ++it)
285 if (name.compare((*it)->GetRenderer()->GetName()) == 0)
286 return (*it).GetPointer();
295 InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin();
296 InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end();
298 for (; it != end; ++it)
300 if (viewDirection == (*it)->GetSliceNavigationController()->GetDefaultViewDirection())
301 return (*it).GetPointer();
309 if (index < m_RenderWindowList.size())
311 return m_RenderWindowList.at(index).GetPointer();
333 for (
auto it : m_RenderWindowList)
346 planeNode1->SetProperty(
"layer", layer);
347 planeNode1->SetColor(1.0, 0.0, 0.0);
356 TiXmlDocument document(m_InteractionFilePath);
357 bool loadOkay = document.LoadFile();
368 const char *rendererName =
384 for (
auto it : m_RenderWindowList)
386 if (strcmp(it->GetRenderer()->GetName(), rendererName) == 0)
388 namedRenderer = it.GetPointer();
393 if (namedRenderer ==
nullptr)
395 MITK_ERROR <<
"No match for render window was found.";
402 double cameraFocalPoint[3];
404 cameraFocalPoint[0] =
406 cameraFocalPoint[1] =
408 cameraFocalPoint[2] =
415 double cameraPosition[3];
static const std::string xmlCameraPositionZ()
virtual const mitk::TimeGeometry * GetCreatedWorldGeometry()
Access the created geometry.
static const std::string xmlViewUpX()
const SliceNavigationController * GetTimeNavigationController() const
void Disconnect(T *receiver)
virtual vtkRenderWindow * GetVtkRenderWindow() override
void Set3dCameraSettings()
static const std::string xmlEventPropertyRendererName()
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
void AddDisplayPlaneSubTree()
void PlaybackInteraction()
PlaybackInteraction playback loaded interaction by passing events to the dispatcher.
static const std::string xmlTagConfigRoot()
static const std::string xmlTagInteractions()
static const std::string xmlEventPropertyMapperID()
static const std::string xmlCameraFocalPointZ()
void SetTimeStep(int newTimeStep)
SetTimeStep Sets timesteps of all SliceNavigationControllers to given timestep.
static const std::string xmlCameraFocalPointX()
static const std::string xmlCameraFocalPointY()
static const std::string xmlRenderSizeX()
virtual ~InteractionTestHelper()
void ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent=true)
mitk::DataStorage::Pointer m_DataStorage
int MapperSlotId
MapperSlotId defines which kind of mapper (e.g., 2D or 3D) shoud be used.
Manager for coordinating the rendering process.
static const std::string xmlRenderSizeY()
void AddDisplayPlaneSubTree()
AddDisplayPlaneSubTree.
static RenderingManager * GetInstance()
virtual mitk::VtkPropRenderer * GetRenderer()
static const std::string xmlEventPropertyViewDirection()
virtual void SetPos(unsigned int pos)
RenderWindow * GetRenderWindowByDefaultViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection)
GetRenderWindowByDefaultViewDirection Get a renderWindow by its default viewdirection.
static const std::string xmlTagRenderer()
void Initialize(const std::string &interactionXmlFilePath)
Initialize Internal method to initialize the renderwindow and set the datastorage.
RenderWindow * GetRenderWindowByName(const std::string &name)
GetRenderWindowByName Get renderWindow by the name of its renderer.
static const std::string xmlViewUpY()
RenderWindow * GetRenderWindow(unsigned int index)
GetRenderWindow Get renderWindow at position 'index'.
virtual void PrepareRender()
This methods contains all method neceassary before a VTK Render() call.
static const std::string xmlCameraPositionX()
void LoadInteraction()
LoadInteraction loads events from xml file.
mitkRenderWindow integrates the MITK rendering mechanism into VTK and is NOT QT dependent ...
static const std::string xmlCameraPositionY()
static const std::string xmlRenderSizeZ()
mitk::Stepper * GetTime()
Get the Stepper through the time.
static void RemoveInstance(vtkRenderWindow *renWin)
vtkRenderer * GetVtkRenderer() const
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...
static const std::string xmlViewUpZ()
void AddNodeToStorage(mitk::DataNode::Pointer node)
AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering...
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.
InteractionTestHelper(const std::string &interactionXmlFilePath)
InteractionTestHelper set up all neseccary objects by calling Initialize.
mitk::DataStorage::Pointer GetDataStorage()
Returns the datastorage, in order to modify the data inside a rendering test.