[Insight-users] Re: wxWidgets with ITK/VTK?

Wilbur C.K. Wong wilburckwong at gmail.com
Thu Jul 21 23:30:15 EDT 2005


Hi Ricardo,

> Does anybody know if there is a simple example available in somewhere
> about how to use wxWidgets with ITK/VTK?

The wxVTKRenderWindowInteractor (available at
http://wxvtk.sourceforge.net/) would help to you connect the VTK
renderer output to the wxWidgets framework.  This is what I've been
using for my research work.

I suggest you to use the CMake to generate the makefile/project file
that has the information of all the libraries which you need for the
software development.

Below is an example, hope this can help.

PROJECT( MyProject )

# Set useful directories path.
SET(WXWINDOWS_ROOT C:/wxWindows-2.4.2)
SET(WXWINDOWS_CONTRIBUTION_ROOT ${WXWINDOWS_ROOT}/contrib/)
SET(WXWINDOWS_LIBRARY_ROOT ${WXWINDOWS_ROOT}/lib)

# Find a wxWidgets installation.
INCLUDE(${CMAKE_ROOT}/Modules/FindwxWidgets.cmake)
IF(WXWINDOWS_INCLUDE_DIR)
   INCLUDE_DIRECTORIES(${WXWINDOWS_INCLUDE_DIR})
ENDIF(WXWINDOWS_INCLUDE_DIR)
IF( WXWINDOWS_LINK_DIRECTORIES )
    LINK_DIRECTORIES( ${WXWINDOWS_LINK_DIRECTORIES} )
ENDIF( WXWINDOWS_LINK_DIRECTORIES )

# Find an ITK installation.
INCLUDE(${CMAKE_ROOT}/Modules/FindITK.cmake) 
IF(ITK_USE_FILE)   
   INCLUDE(${ITK_USE_FILE}) 
ENDIF(ITK_USE_FILE)

# Find an OpenGL installation.
INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake) 
INCLUDE(${CMAKE_ROOT}/Modules/FindGLU.cmake)

# Find a VTK installation.
INCLUDE(${CMAKE_ROOT}/Modules/FindVTK.cmake) 
IF(VTK_USE_FILE)   
   INCLUDE(${VTK_USE_FILE}) 
ENDIF(VTK_USE_FILE)
IF( VTK_INCLUDE_DIRS )
    INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
ENDIF( VTK_INCLUDE_DIRS )
IF( VTK_LIBRARY_DIRS )
    LINK_DIRECTORIES( ${VTK_LIBRARY_DIRS} )
ENDIF( VTK_LIBRARY_DIRS )

# Set WIN32 related information.
IF( WIN32 )
   SET( WIN32_EXECUTABLE WIN32 )
ENDIF( WIN32 )

INCLUDE_DIRECTORIES(
    ${MYPROJECT_SOURCE_DIR}
    ${MYPROJECT_SOURCE_DIR}/Src
    C:/InsightApplications-1.8.0/vtkITK/Common
    )

ADD_EXECUTABLE(
    MyProject
    ${WIN32_EXECUTABLE}
    Src/MyProject.cpp
    Src/MyProject.rc
    )

# The VTK libraries to be linked to the target.
IF( VTK_FOUND )
    SET(VTK_LIBRARIES vtkRendering vtkGraphics vtkHybrid vtkImaging
        vtkIO vtkFiltering vtkCommon vtkPatented)
ENDIF( VTK_FOUND )

# The ITK libraries to be linked to the target.
IF( ITK_FOUND )
	SET( ITK_LIBRARIES ITKBasicFilters ITKCommon ITKIO ITKNumerics ITKMetaIO 
		 ITKAlgorithms ITKStatistics )
ENDIF( ITK_FOUND )

SET(WXWINDOWS_CONTRIBUTION_LIBRARIES ${WXWINDOWS_LIBRARY_ROOT}/plotd)
INCLUDE_DIRECTORIES(${WXWINDOWS_CONTRIBUTION_ROOT}/include)

TARGET_LINK_LIBRARIES(
    MyProject
    ${OPENGL_LIBRARY}
    ${GLU_LIBRARY}
    ${WXWINDOWS_LIBRARIES}
    ${WXWINDOWS_CONTRIBUTION_LIBRARIES}
    ${VTK_LIBRARIES}
    ${ITK_LIBRARIES}
    )

Best,
Wilbur C. K. Wong
Ph.D. Student 

Lo Kwee-Seong Medical Image Analysis Laboratory
Computer Science - Hong Kong University of Science & Technology
cswilbur "AT" ust "DOT" hk | wilburckwong "AT" gmail "DOT" com
http://www.cs.ust.hk/~cswilbur | http://www.wilburwong.ws

Medical Image Processing and Analysis | Computer-aided Endovascular
Treatment Project


More information about the Insight-users mailing list