The qvtkwidget control is used in QT’s interface. When clicking the close button in the upper right corner of the window, an error is reported: wglmakecurrent failed in makecurrent(), error: the handle is invalid .
Solution:
By overriding the void closeevent (qcloseevent * event) function, manually delete all qvtkwidget type controls, and then close the window.
Example
The qvtkwidget type controls in the QT design interface are as follows:
mymainwindow. H
class MyMainWindow : public QMainWindow
{
Q_OBJECT
public:
MyMainWindow(QWidget *parent = Q_NULLPTR);
protected:
void closeEvent(QCloseEvent *event);
private:
Ui::MainWindow ui;
};
a medical image processing, registration and segmentation packages td>
used in 3 d computer graphics, image processing and visualization software system td> tr>
language td>
ITK are implemented in c + +, can cross platform, can use a variety of different programming languages to develop td>
VTK is on the basis of the principle of object-oriented design and implementation, The kernel is built in C++ and can be used in different languages using
tr> <>> build <>d>
to>ge the build>cess with CMake to ensure the build process is platform-independent. TD>
es CMake to manage the build process to ensure that the build process is platform independent. td> tr>
thought td>
extreme programming (core characteristics is communication and test) td>
visualization of pipeline is to achieve the organization form of data to display the results td> tr> tbody> table>
Installation steps
Cmake-3.9.3-win64-x64 -itk: InsightToolkit-4.12.2/VTK: vtk-8.0.1 The following installations are based on Windows 10, Visual Studio 2015 development platform
1. Create the installation directory . CMake 3. . Configuration ITK/VTK
Problems encountered
Error configuration process, project files may be invalid
CMAKE is not used to select the version of VS on your machine. This is not used to select the version of VS 14 2015 Win64 on your machine. This is not used to select the version of VS 14 2015 Win64 on your machine
The Value cannot be null is still being learned
After setting up the basic VTK environment, the learning process follows. But I had a bunch of problems in the first example. Here’s how to solve them. Fill in a bunch of holes first.
1. Problem introduction
I follow: Dongling VTK tutorial series navigation learning. > > > > > > > > >
The first is the cmake code:
ror configuration process, project files may be invalid.>r> error configuration process, project files may be invalid
2. Problem solving:
Error Configuration Process: The Project Files may be invalid method did not work. Here’s a little bit about this approach.
2.1 No use of CMAKE to select the version of VS on the corresponding machine.
When generating the corresponding VS solution with the CMAKE configuration, you need to correspond to the correct VS version. This is the same version that you used when installing VTK.
2.2 Previous error cache is not cleaned
| click on the top left corner of the file - & gt; Delete cathe to clear the cache.
2. 3 cmake list programming problems
Following the above description did not solve our problem, so we had to continue to Google. We saw us have similar questions on several StackOverflow posts.
VTK + Cmake -> USE_VTK_RENDERING erroCMake error: ‘Target is not built by this project’ Cmake link liabray target link errorCMake OpenCV Cannot Specify link Libraries
According to the above, compared with our CMMakelists code, we tried one code after another, and finally found a very hidden error, that is, we must pay attention to the space in CMMakelists!!
To be specific,
is the first line: rsion a> code>2.8>e> have a space> The third line: VTKd r>red has a s> on line 9, testvtkinstal>cpp has a space on line> In line 11, we change the previous vtkRendering vtkCommon $>tk_libraries} with a>e before. There is nothing wrong with cmake, though, if you simply add a space. However, when VS is compiled later, the following error will occur, so it will be fine to fix it.
3. Run in VS
After cmake has no errors, we configure, then generate. Open VS2017 as an administrator. Open the file we compiled. > compile l_build >>ck on F7 or build it. If there are no errors, right-click TestVTKInstall and set it as a startup item, then click F5, or run to get the correct results.
Over
Tutorial for http://blog.sina.com.cn/s/blog_5e3b04ee0102w296.html; The inside of the”
The working directory \bin\Debug “refers to the folder in the project after Cmake.
Unable to debug normal program after installation:
Project Properties ->; The linker – & gt; Input where it inherits from the parent.
Error resolution occurred while CMake Vtk
Problem description
Problem description:
If you use CMake to compile the VTK source code, the following error is reported:
error configuration process, project files may be invalid
Solution:
https://blog.csdn.net/hk_5788/article/details/70145517 solution is the net friend meet, modify the config parameters
But I still can’t solve the problem, and find the following method can solve it
Solution 2: click on the File click Delete Cache, clear the Cache, might be because before setting results in failure
This error is caused by not compiling with CMAKE, so some macro definitions and configurations are not initialized, resulting in the factory function of the class being used being unusable. So based on my experience in these days:
first of all, the example programs such as cone, attribute macro definition in c + + preprocessor “copy” to their own projects; If this error occurs again, use such as VTK_MODULE_INIT(vtkrenderingVolumeOpenGL); Initialize the required modules.
To summarize some errors in using VTK:
1. Uncompiled error
These errors are not caused by you using the VTK class incorrectly or by logic problems, but by missing some initialized header files
We need to add the initialization header file in main:
#include <vtkAutoInit.h>
VTK Error: No Override found for ‘VTKVolumetTextureMapper2D ‘.
Error: no override found for ‘vtkRayCastImageDisplayHelper’.
In the main function add:
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL)
Error: No Override found for ‘VTKImageMapper ‘.
In the main function add:
VTK_MODULE_INIT(vtkRenderingOpenGL)
Error:Could not locate vtkTextRenderer object.
In the main function add:
VTK_MODULE_INIT(vtkRenderingFreeType)
Error: Link to vtkinteractionstyle
In the main function add:
VTK_MODULE_INIT(vtkInteractionStyle)
VTK6.3.0:Error: No Override found for ‘VTKContextDevice2D’
Add to the main function
VTK_MODULE_INIT(vtkRenderingContextOpenGL)
Incorrect use of VTK classes
1, the ERROR: In D: \ VTK, VTK – 6.3.0, Rendering, OpenGL \ vtkOpenGLDisplayListPainter CXX, line 188
vtkOpenGLDisplayListPainter (000001AC0C582AE0): failed after RenderInternal 1 OpenGL errors detected
0 : (1282) Invalid operation
Test resolved: remove vtkRender ->; Render () function. The unexplained guess is that the render function is called repeatedly
The VTK documentation describes this function:
virtual void vtkRenderer: : Render td>
( td>
td>
td>
[virtual] td> tr> tbody> table>
CALLED BY vtkrenderWindow only. end-user pass your way and call vtkrenderWindow ::Render(). Create an image.
So I’m calling VTKRenderWindow’s render function.
2,
Cause of the problem: Actor is not removed when switching the reconstruction model
Renderer-> RemoveActor removes the old actor before adding a new one
3, the ERROR:
vtkOpenGLExtensionManager (00000232ABF21E00): Extension GL_VERSION_1_2 could not be loaded.
Where the problem occurs: using 3D texture mapping to implement weight building, a bug pops up at runtime,
VTK 3D texture mapping class: VTK VolumetTexturemapper 3D only supports two graphics cards NVIDIA and ATI; The computer’s default graphics card uses an integrated graphics card (which, of course, is not configured to support OpenGL very well) rather than a standalone display. Manually switch to independent display. Detailed switching method: dual graphics card switching
Compile VTK source code with CMKAE
1. Install Cmake
Download the installation package: http://www.cmake.org/download/
Select the.exe file to download and install it on your local computer.
2. Get the VTK source code
2.1 source url: http://www.vtk.org/download/
Download vtk-6.2.0.zip (VTK source code) vtkdata-6.2.0.zip (data) vtkdochtml-6.2.0.tar.gz (help document)
2.2 Unzip to local folder
Unzip vtk-6.2.0.zip to F:\vtk_6.2\ VTK
Unzip vtkdata-6.2.0.zip to F:\vtk_6.2\ VTKData
Unzip vtkdochtml-6.2.0.tar. gz to F:\vtk_6.2\vtkDocHtml
3. Run cmake to compile
Select the Source Code directory as F:\vtk_6.2\ VTK
Select the bin directory after build as F:\vtk_6.2\bin
Click the Configure button, the selection compiler pops up, I chose Visual Studio 2010, automatically scan the required files.
4. Modify Cmake parameter (On is ticked)
4.1 BUILD_EXAMPLES Select ON, which you can use to learn about VTK examples
4.2 BUILD_SHARED_LIBS Select ON to generate dynamic link library DLLs
4.3 MODULE_VTKGUISUPPORTQT Select ON to support QT interface (click Advanced parameters, this option will appear)
4.4 CNAJE_INSTALL_PREFIX = C: \ ProgramFiles \ VTK
Then, click the Configure button again and let CMake scan the configuration file again. When it runs successfully, the red color will disappear from the page. If it still has red color, see what else needs to be selected on the red TAB
At the end of the scan, click the Generate button to Generate the VS project of VTK.
5. Open the VS project of VTK and compile it
Open the vtk.sln project in the F:\vtk_6.2\bin directory
The first step is to select the type of file to output, Debug or Release for ALL_BUILD and INSTALL, as shown in the figure below.
The default Files are in the C: Program Files\VTK folder. Copy it into an environment variable and program it
0 error description
Error in VTK-6.3.0 using VTKVolumerayCastMapper for volume rendering:
Generic Warning: In D:\VTK\VTK-6.3.0\Rendering\Volume\vtkRayCastImageDisplayHelper.cxx, line 20
Error: no override found for 'vtkRayCastImageDisplayHelper'.
1 Solutions
At the beginning of main() add:
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL);
2. Solution Process
How do you know the above VTKrenderingVolumeOpenGL?In VTK Error: No Override Founds for ‘VTKVolumetTextureMapper2D’, a method is already provided, but there are some difficulties in practice. Here is a better method. Here are the detailed steps.
(1) Find a case of VTKVolumerayCastMapper through the help document of VTK-6.3.0:
(2) Find the directory of Medical4.cxx (VTK-6.3.0/Examples/Medical/) in the VTK-6.3.0 source code. There is a cMakelists.txt file in it:
(3) Open the above cmakelist.txt file and find the contents of the find_package section:
VTKRenderingVolume $(VTK_Rendering_Backend) is the module required for VTKVolumerayCastMapper. So what is the value of VTK_RENDERING_BACKEND?
(4) open the VTK 6.3.0/Rendering/Volume/CMakeList. TXT, in its final value judgment about VTK_RENDERING_BACKEND:
So you can guess that VTK_RENDERING_BACKEND refers to a version of OpenGL, either OpenGL or OpenGL2. OpenGL is used by default in VTK-6.3.0 (VTK-7.0.0 has been changed to OpenGL2), so the value of VTK_RENDERING_BACKEND is OpenGL or OpenGL2, and the former is chosen in this paper.
Software preparation:
1. Download the source code compression package VTK-7.0.0.zip from the VTK official website and extract it.
2. Download the installation package QT-Opensource-Windows-x86-MSVC2012_OpenGL-5.3.2. exe from the Qt official website, and install it by default.
3. Download the installation package cmake-3.0.2-win32-x86.exe from the official website of CMake, and install it by default.
Cmake set
1. Check Groupd and Advanced, and set the source code directory and build directory.
2. Press the Configure button, select VisualStudio 11 2012, click OK, and wait for the configuration to complete.
3. At the VTK node, locate and check VTK_GROUP_QT. Press the Configure button and wait for the configuration to complete. When done, CMake will report an error and click OK.
4. In the UngroundedEntries node with a red background, locate and change the value of VTK_QT_VERSION to 5. Set the value of QT_QMAKE_EXECUTABLE to C:/Qt/Qt5.3.2/5.3/msvc2012_opengl/bin/qmake. Exe. Press the Configure button and wait for the configuration to complete. When done, CMake will report an error and click OK.
5. In the UngroundedEntries node with red background, set the value of Qt5_DIR to C:/Qt/ qt5.3.2/5.3/msvc2012_opengl/lib/cmake/Qt5. Press the Configure button and wait for the configuration to complete. When done, CMake will no longer report errors.
6. On the CMAKE node, locate the CMAKE_INSTALL_PREFIX node and use the default Settings. This value is the installation directory of the VTK after compilation.
7. Click Add Entry button, set Name to CMAKE_DEBUG_POSTFIX, Type to STRING, Value to -GD, and click OK after setting. Press the Configure button and wait for the configuration to complete. Set this to ensure that the debug version of lib, DLL and release version of lib, the DLL name is different, to prevent later installation, both overwrite.
8. Click the Generate button and wait for the project VS file to be generated.
9. Locate the plugininstall. cmake file in the GUISupport\Qt folder of the build directory. Open it with Notepad and take line 5
SET (VTK_INSTALL_QT_PLUGIN_FILE QVTKWidgetPlugin. DLL)
Replace with
IF(BUILD_TYPE MATCHES Debug)
SET (VTK_INSTALL_QT_PLUGIN_FILE “QVTKWidgetPlugin – gd. DLL)”
ELSE()
SET (VTK_INSTALL_QT_PLUGIN_FILE QVTKWidgetPlugin. DLL)
ENDIF()
Note: Make sure that qvtkwidgetPlugin-gd.dll and qvtkwidgetPlugin.dll are surrounded by double quotation marks after substitution. Otherwise, subsequent compilation will return an error.
Save. This modification can prevent the QVTKWidgetPlugin file from being found when installing Qt plugin during debugging.
VS2012 compilation
1. Run VS as an administrator, click File, Open, and the dialog box pops up. Find the vtk.sln file in the path and open it.
2. In Solution Manager, go to ALL_BUILD, right-click, and click Build. Wait for VS to compile. When finished, find Install, click the right mouse button, and click Create.
3. Change the solution configuration to Release. In Solution Manager, go to ALL_BUILD, right-click, and click Build. Wait for VS to compile. When finished, find Install, click the right mouse button, and click Create.
4. After the above steps are completed, the compiled file will be in the path set by CMAKE_INSTALL_PREFIX.
Sudo apt-get install libvtk5.2 libvtk5-qt4-dev sudo apt-get install libvtk5.2 libvtk5-qt4-dev
Different Ubuntu versions support different versions of VTK, here is Ubuntu 10.04, followed by QT4 support.
two
1. Download source code
Address: http://www.vtk.org/VTK/resources/software.html
The version is the latest
2. Unzip
The tar ZXVF… .
A VTK folder is created in the current directory
3. Install OpenGL
apt-get install mesa-common-dev libgl1-mesa-dev
4. Install ccmake
sudo apt-get install cmake-curses-gui
5.cd VTK
6.mkdir VTK-build
7.cd VTK-build
8.ccmake .. /
9. Press C to start the configuration and set VTK_USE_QT to ON. BUILD_SHARED_LIBS is set to ON
10. Press T to enter detailed setup, then locate QT_QMake_Executable, press ENTER to modify, and change QMAKE
The path of the input, for example:/home/zhang/QtSDK/Desktop/Qt/4.8.0/GCC/bin/qmake. Confirm and press Enter to exit the modification.
11. Press C to check the Settings.
12. Confirm by C.
13. Press G to generate makefile and exit CCMAKE automatically
14.make
15.sudo make install.
Add (.pro file) to the project
INCLUDEPATH =/usr/local/include/VTK to 5.10
LIBS + = L/usr/local/lib/VTK – 5.10 \
5.2
INCLUDEPATH =/usr/include/VTK to 5.2
LIBS += -L/usr/lib \
Select as needed at the end
-lvtkCommon -lvtksys -lQVTK -lvtkViews -lvtkWidgets -lvtkInfovis -lvtkRendering -lvtkGraphics -lvtkImaging -lvtkIO -lvtkFiltering -lvtklibxml2 -lvtkDICOMParser -lvtkpng -lvtkpng -lvtktiff -lvtkzlib -lvtkjpeg -lvtkalglib -lvtkexpat -lvtkverdict -lvtkmetaio -lvtkNetCDF -lvtksqlite -lvtkexoIIc -lvtkftgl -lvtkfreetype -lvtkHybrid
visual studio 2013
DXSDK_Jun10
Cmake – 3.3.2 rainfall distribution on 10-12 – win32 – x86
Qt5.7
Qt – v – system.addin – 1 – opensource
TBB (Thread Building Blocks)
VTK 7.1
1. Install Visual Studio 2013 Community
Download https://www.visualstudio.com/downloads/download-visual-studio-vs
Select Visual Studio 2013 ->; Community 2013
Download and install community default locations and default optional features (takes about half an hour to complete)