fw4spl
Bundles/visu/visuVTKQt/src/visuVTKQt/Plugin.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "visuVTKQt/Plugin.hpp"
8 
9 #include <fwCore/spyLog.hpp>
10 
11 #include <fwRuntime/utils/GenericExecutableFactoryRegistrar.hpp>
12 
13 #include <QApplication>
14 #include <QSurfaceFormat>
15 #include <QVTKOpenGLWidget.h>
16 #include <vtkGenericOpenGLRenderWindow.h>
17 
18 namespace visuVTKQt
19 {
20 
21 //-----------------------------------------------------------------------------
22 
23 static ::fwRuntime::utils::GenericExecutableFactoryRegistrar<Plugin> registrar("visuVTKQt::Plugin");
24 
25 //-----------------------------------------------------------------------------
26 
27 Plugin::Plugin() noexcept
28 {
29  // Since we share the opengl context with Qt, we must set the default QSurfaceFormat before QApplication
30  // to allow QVTKOpenGLWidget to work properly
31  SLM_ASSERT( "QApplication is already created! The default surface format cannot be changed afterward.\n"
32  "This problem can happen when the profile.xml is handwritten and contains 'visuVTKQt' and 'guiQt'.\n"
33  "If that is the case, please ensure that 'visuVTKQt' is started before 'guiQt'.\n"
34  "It could also happen for generated 'profile.xml' files, check it to be sure.",
35  qApp == nullptr );
36 
37  vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(0);
38  QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
39 }
40 
41 //-----------------------------------------------------------------------------
42 
43 Plugin::~Plugin() noexcept
44 {
45 }
46 
47 //-----------------------------------------------------------------------------
48 
50 {
52 }
53 
54 //-----------------------------------------------------------------------------
55 
56 void Plugin::stop() noexcept
57 {
59 }
60 
61 //-----------------------------------------------------------------------------
62 
63 } // namespace visuVTKQt
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
The bundle visuVTKQt contains a vtk Renderer window interactor manager using Qt. It must be set in th...
VISUVTKQT_API void stop() noexcept
Notifies the plugin about its stop.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
VISUVTKQT_API void start()
Notifies the plugin about its start.
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...