An update will be applied December 9th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit a417bb11 authored by Alexis Girault's avatar Alexis Girault
Browse files

ENH: implement VTKViewer::setVtkRenderWindow

- This calls `VTKRenderer::setRenderWindow`. Needed to use a
vtkRenderWindow from another instance (example : for a QT
application, use QVTKWidget renderwindow)
- Rename `VTKViewer::getRenderWindow` to `getVtkRenderWindow`
- Use internal functions in `getVtkCamera` and `getVtkRenderer`
parent 07f651cf
......@@ -342,7 +342,7 @@ void add2DOverlay(std::shared_ptr<VTKViewer> vtkViewer,
imageActor->SetPosition(0.5, 0.5);
// Renderer
vtkRenderer* rendererVtk = vtkViewer->getRenderWindow()->GetRenderers()->GetFirstRenderer();
vtkRenderer* rendererVtk = vtkViewer->getVtkRenderer();
rendererVtk->AddActor2D(imageActor.GetPointer());
}
......@@ -432,7 +432,7 @@ int main()
// not to erase the changes on the observers made to the
// interactor in vtkViewer::addRenderer()
vtkNew<ScreenCaptureInteractorStyle> style;
style->initialize(vtkViewer->getRenderWindow());
style->initialize(vtkViewer->getVtkRenderWindow());
vtkViewer->getVtkRenderWindowInteractor()->SetInteractorStyle(style.GetPointer());
style->SetCurrentRenderer(vtkViewer->getVtkRenderer());
......
......@@ -49,7 +49,6 @@ public:
timerId(-1),
viewer(activeViewer)
{
}
VTKRenderer(){}
......@@ -91,6 +90,18 @@ public:
return this->renderWindow.GetPointer();
}
///
/// \brief Set the render window
///
void *setRenderWindow(vtkSmartPointer<vtkRenderWindow> renWin)
{
this->renderWindow = renWin;
if(this->renderWindow->GetInteractor())
{
this->renderWindowInteractor = this->renderWindow->GetInteractor();
}
}
///
/// \brief Render scene
///
......@@ -165,7 +176,17 @@ public:
///
void addRenderer()
{
// Create a new renderer and add actors to it.
// Check if renderWindow and interactor exist
if(this->renderWindow == nullptr)
{
this->renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
}
if(this->renderWindowInteractor == nullptr)
{
this->renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
}
// Create a new renderer
vtkNew<vtkRenderer> renderer;
// The actors are obtained from VTKRenderDelegates
......@@ -285,8 +306,8 @@ public:
public:
int timerId;
VTKViewer *viewer;
vtkNew<vtkRenderWindow> renderWindow;
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
vtkSmartPointer<vtkRenderWindow> renderWindow;
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor;
};
VTKViewer::VTKViewer() : renderer(Core::make_unique<VTKRenderer> (this))
......@@ -317,20 +338,24 @@ void VTKViewer::render()
this->endModule();
}
vtkRenderWindow* VTKViewer::getRenderWindow() const
vtkRenderWindow* VTKViewer::getVtkRenderWindow() const
{
return this->renderer->getRenderWindow();
}
void VTKViewer::setVtkRenderWindow(vtkSmartPointer<vtkRenderWindow> renWin)
{
this->renderer->setRenderWindow(renWin);
}
vtkCamera* VTKViewer::getVtkCamera()
{
return this->renderer->getRenderWindow()->GetRenderers()->
GetFirstRenderer()->GetActiveCamera();
return this->getVtkRenderer()->GetActiveCamera();
}
vtkRenderer* VTKViewer::getVtkRenderer()
{
return this->renderer->getRenderWindow()->GetRenderers()->GetFirstRenderer();
return this->getVtkRenderWindow()->GetRenderers()->GetFirstRenderer();
}
vtkRenderWindowInteractor* VTKViewer::getVtkRenderWindowInteractor()
......
......@@ -102,7 +102,8 @@ public:
///
void addChartActor(vtkContextActor* chartActor, vtkContextScene* chartScene);
vtkRenderWindow* getRenderWindow() const;
vtkRenderWindow* getVtkRenderWindow() const;
void setVtkRenderWindow(vtkSmartPointer<vtkRenderWindow> renWin);
protected:
///
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment