7 #include "visuVTKQt/VtkRenderWindowInteractorManager.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 12 #include <fwData/String.hpp> 14 #include <fwGuiQt/container/QtContainer.hpp> 16 #include <fwRenderVTK/registry/macros.hpp> 17 #include <fwRenderVTK/SRender.hpp> 19 #include <fwTools/UUID.hpp> 24 #include <QSurfaceFormat> 25 #include <QVBoxLayout> 26 #include <QVTKOpenGLWidget.h> 27 #include <vtkGenericOpenGLRenderWindow.h> 28 #include <vtkRenderer.h> 29 #include <vtkRenderWindow.h> 30 #include <vtkRenderWindowInteractor.h> 35 DropFilter(::fwServices::IService::sptr service) :
40 bool eventFilter(QObject* obj, QEvent* event);
43 ::fwServices::IService::wptr m_service;
48 bool DropFilter::eventFilter(QObject* obj, QEvent* event)
50 if( event->type() == QEvent::DragEnter)
52 QDragEnterEvent* dragEvent =
dynamic_cast< QDragEnterEvent*
>(event);
53 if (dragEvent->mimeData()->hasFormat(
"text/plain"))
55 QString data = dragEvent->mimeData()->text();
56 dragEvent->acceptProposedAction();
59 else if (event->type() == QEvent::Drop )
61 QDropEvent* dropEvent =
dynamic_cast< QDropEvent*
>(event);
62 QString data = dropEvent->mimeData()->text();
63 ::fwServices::IService::sptr service = m_service.lock();
65 ::fwRenderVTK::SRender::s_DROPPED_SIG);
66 sig->asyncEmit( data.toStdString() );
71 return QObject::eventFilter(obj, event);
79 ::fwRenderVTK::IVtkRenderWindowInteractorManager::REGISTRY_KEY );
88 VtkRenderWindowInteractorManager::VtkRenderWindowInteractorManager(
95 VtkRenderWindowInteractorManager::~VtkRenderWindowInteractorManager()
101 void VtkRenderWindowInteractorManager::installInteractor( ::fwGui::container::fwContainer::sptr _parent )
104 m_parentContainer = ::fwGuiQt::container::QtContainer::dynamicCast( _parent );
106 QVBoxLayout* layout =
new QVBoxLayout();
107 layout->setContentsMargins(0, 0, 0, 0);
108 m_parentContainer->setLayout(layout);
111 vtkNew<vtkGenericOpenGLRenderWindow> window;
112 m_QVTKOpenGLWidget =
new QVTKOpenGLWidget(m_parentContainer->getQtContainer());
113 m_QVTKOpenGLWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
114 layout->addWidget(m_QVTKOpenGLWidget);
115 m_QVTKOpenGLWidget->SetRenderWindow(window.Get());
118 if(
auto locked = m_renderService.lock())
120 m_QVTKOpenGLWidget->setAcceptDrops(
true);
121 m_QVTKOpenGLWidget->installEventFilter(
new DropFilter(locked));
124 m_interactor = window->GetInteractor();
129 void VtkRenderWindowInteractorManager::uninstallInteractor()
131 m_interactor =
nullptr;
133 delete m_QVTKOpenGLWidget;
134 m_QVTKOpenGLWidget.clear();
136 m_parentContainer->clean();
141 ::vtkRenderWindowInteractor* VtkRenderWindowInteractorManager::getInteractor()
The bundle visuVTKQt contains a vtk Renderer window interactor manager using Qt. It must be set in th...
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Defines a class to manage vtkRenderWindowInteractor in a window.