diff --git a/CMake/mitkSetupVariables.cmake b/CMake/mitkSetupVariables.cmake index 25a9a3e5aa..3555372434 100644 --- a/CMake/mitkSetupVariables.cmake +++ b/CMake/mitkSetupVariables.cmake @@ -1,161 +1,159 @@ if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() set(LIBPOSTFIX "") # MITK_VERSION set(MITK_VERSION_MAJOR "2012") set(MITK_VERSION_MINOR "02") set(MITK_VERSION_PATCH "99") set(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}") if(MITK_VERSION_PATCH STREQUAL "99") set(MITK_VERSION_STRING "${MITK_VERSION_STRING}-${MITK_REVISION_SHORTID}") endif() #----------------------------------- # Configuration of module system #----------------------------------- set(MODULES_CONF_DIRNAME modulesConf) set(MODULES_CONF_DIRS ${MITK_BINARY_DIR}/${MODULES_CONF_DIRNAME}) if(NOT UNIX AND NOT MINGW) set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms") endif() # build the MITK_INCLUDE_DIRS variable set(MITK_INCLUDE_DIRS ${ITK_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} # contains mitkConfig.h and similar files ${MODULES_CONF_DIRS} # contains module *Exports.h files ) set(CORE_DIRECTORIES Common DataManagement Algorithms IO Rendering Interactions Controllers Service) foreach(d ${CORE_DIRECTORIES}) list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Core/Code/${d}) endforeach() #list(APPEND MITK_INCLUDE_DIRS #${ITK_INCLUDE_DIRS} #${VTK_INCLUDE_DIRS} # ) -#foreach(d Utilities Utilities/ipPic Utilities/IIL4MITK Utilities/pic2vtk Utilities/tinyxml Utilities/mbilog) foreach(d Utilities Utilities/ipPic Utilities/pic2vtk Utilities/tinyxml Utilities/mbilog) list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${d}) endforeach() list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/mbilog) if(WIN32) list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipPic/win32) endif() # additional include dirs variables set(ANN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ann/include) set(IPSEGMENTATION_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipSegmentation) # variables containing librariy names set(MITK_CORE_LIBRARIES Mitk) set(VTK_FOR_MITK_LIBRARIES vtkGraphics vtkCommon vtkFiltering vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO vtkParallel vtkRendering vtkVolumeRendering vtkWidgets ${VTK_JPEG_LIBRARIES} ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_EXPAT_LIBRARIES} ${VTK_FREETYPE_LIBRARIES} ) # TODO: maybe solve this with lib depends mechanism of CMake set(UTIL_FOR_MITK_LIBRARIES mitkIpPic mitkIpFunc mbilog) set(LIBRARIES_FOR_MITK_CORE ${UTIL_FOR_MITK_LIBRARIES} ${VTK_FOR_MITK_LIBRARIES} ${ITK_LIBRARIES} ) set(MITK_LIBRARIES ${MITK_CORE_LIBRARIES} ${LIBRARIES_FOR_MITK_CORE} pic2vtk - #IIL4MITK ipSegmentation ann ) # variables used in CMake macros which are called from external projects set(MITK_VTK_LIBRARY_DIRS ${VTK_LIBRARY_DIRS}) set(MITK_ITK_LIBRARY_DIRS ${ITK_LIBRARY_DIRS}) # variables containing link directories set(MITK_LIBRARY_DIRS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) set(MITK_LINK_DIRECTORIES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${ITK_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS} ${GDCM_LIBRARY_DIRS}) # Qt support if(MITK_USE_QT) find_package(Qt4 REQUIRED) set(QMITK_INCLUDE_DIRS ${MITK_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Qmitk ${PROJECT_BINARY_DIR}/Modules/Qmitk ) set(QMITK_LIBRARIES Qmitk ${MITK_LIBRARIES}) set(QMITK_LINK_DIRECTORIES ${MITK_LINK_DIRECTORIES}) endif() if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() # create a list of types for template instantiations of itk image access functions function(_create_type_seq TYPES seq_var seqdim_var) set(_seq ) set(_seq_dim ) string(REPLACE "," ";" _pixeltypes "${TYPES}") foreach(_pixeltype ${_pixeltypes}) set(_seq "${_seq}(${_pixeltype})") set(_seq_dim "${_seq_dim}((${_pixeltype},dim))") endforeach() set(${seq_var} "${_seq}" PARENT_SCOPE) set(${seqdim_var} "${_seq_dim}" PARENT_SCOPE) endfunction() set(MITK_ACCESSBYITK_PIXEL_TYPES ) set(MITK_ACCESSBYITK_PIXEL_TYPES_SEQ ) set(MITK_ACCESSBYITK_TYPES_DIMN_SEQ ) foreach(_type INTEGRAL FLOATING COMPOSITE) set(_typelist "${MITK_ACCESSBYITK_${_type}_PIXEL_TYPES}") if(_typelist) if(MITK_ACCESSBYITK_PIXEL_TYPES) set(MITK_ACCESSBYITK_PIXEL_TYPES "${MITK_ACCESSBYITK_PIXEL_TYPES},${_typelist}") else() set(MITK_ACCESSBYITK_PIXEL_TYPES "${_typelist}") endif() endif() _create_type_seq("${_typelist}" MITK_ACCESSBYITK_${_type}_PIXEL_TYPES_SEQ MITK_ACCESSBYITK_${_type}_TYPES_DIMN_SEQ) set(MITK_ACCESSBYITK_PIXEL_TYPES_SEQ "${MITK_ACCESSBYITK_PIXEL_TYPES_SEQ}${MITK_ACCESSBYITK_${_type}_PIXEL_TYPES_SEQ}") set(MITK_ACCESSBYITK_TYPES_DIMN_SEQ "${MITK_ACCESSBYITK_TYPES_DIMN_SEQ}${MITK_ACCESSBYITK_${_type}_TYPES_DIMN_SEQ}") endforeach() set(MITK_ACCESSBYITK_DIMENSIONS_SEQ ) string(REPLACE "," ";" _dimensions "${MITK_ACCESSBYITK_DIMENSIONS}") foreach(_dimension ${_dimensions}) set(MITK_ACCESSBYITK_DIMENSIONS_SEQ "${MITK_ACCESSBYITK_DIMENSIONS_SEQ}(${_dimension})") endforeach() diff --git a/Core/Code/CMakeLists.txt b/Core/Code/CMakeLists.txt index 64c31b715b..34d1d46016 100644 --- a/Core/Code/CMakeLists.txt +++ b/Core/Code/CMakeLists.txt @@ -1,81 +1,81 @@ #FIND_PACKAGE(OpenGL) #IF(NOT OPENGL_FOUND) # MESSAGE("GL is required for MITK rendering") #ENDIF(NOT OPENGL_FOUND ) # Configure the C++ Micro Services Code for MITK find_package(ITK REQUIRED) include(${ITK_USE_FILE}) set(US_NAMESPACE "mitk") set(US_HEADER_PREFIX "mitk") set(US_BASECLASS_NAME "itk::LightObject") set(US_BASECLASS_HEADER "itkLightObject.h") set(US_BASECLASS_PACKAGE "ITK") set(US_ENABLE_THREADING_SUPPORT 1) set(US_EMBEDDING_LIBRARY Mitk) set(US_BUILD_TESTING ${BUILD_TESTING}) if(BUILD_TESTING) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Testing) set(US_BASECLASS_HEADER "uServicesBaseObject.h") set(US_TEST_LABELS MITK-Core) endif() add_subdirectory(CppMicroServices) include(${CMAKE_CURRENT_BINARY_DIR}/CppMicroServices/CppMicroServicesConfig.cmake) set(TOOL_CPPS "") MITK_CREATE_MODULE( Mitk INCLUDE_DIRS ${CppMicroServices_INCLUDE_DIRS} Algorithms Common DataManagement Controllers Interactions Interfaces IO Rendering ${MITK_BINARY_DIR} INTERNAL_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR} ${IPSEGMENTATION_INCLUDE_DIR} ${ANN_INCLUDE_DIR} ${CppMicroServices_INTERNAL_INCLUDE_DIRS} DEPENDS mbilog tinyxml - DEPENDS_INTERNAL pic2vtk #IIL4MITK + DEPENDS_INTERNAL pic2vtk PACKAGE_DEPENDS ITK VTK EXPORT_DEFINE MITK_CORE_EXPORT WARNINGS_AS_ERRORS ) # this is needed for libraries which link to Mitk and need # symbols from explicitly instantiated templates like # mitk::SurfaceVtkWriter which is referenced in # QmitkCommonFunctionality in the QmitkExt library. if(MINGW) get_target_property(_mitkCore_MINGW_linkflags Mitk LINK_FLAGS) if(NOT _mitkCore_MINGW_linkflags) set(_mitkCore_MINGW_linkflags "") endif(NOT _mitkCore_MINGW_linkflags) set_target_properties(Mitk PROPERTIES LINK_FLAGS "${_mitkCore_MINGW_linkflags} -Wl,--export-all-symbols") endif(MINGW) # replacing Mitk by Mitk [due to removing the PROVIDES macro TARGET_LINK_LIBRARIES(Mitk ${LIBRARIES_FOR_${KITNAME}_CORE} ${IPFUNC_LIBRARY} ipSegmentation ann) #TARGET_LINK_LIBRARIES(Mitk ${OPENGL_LIBRARIES} ) TARGET_LINK_LIBRARIES(Mitk gdcmCommon gdcmIOD gdcmDSED) if(MSVC_IDE OR MSVC_VERSION OR MINGW) target_link_libraries(Mitk psapi.lib) endif(MSVC_IDE OR MSVC_VERSION OR MINGW) # verify ITK has been built with GDCM >= 2.0.14 set(GDCM_FULL_VERSION "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}") set(MITK_REQUIRED_GDCM_VERSION "2.0.14") if(GDCM_FULL_VERSION VERSION_LESS MITK_REQUIRED_GDCM_VERSION) message(SEND_ERROR "Mitk: MITK requires ITK with at least GDCM version ${MITK_REQUIRED_GDCM_VERSION}.\nFound version ${GDCM_FULL_VERSION} (GDCM NOT found if you don't see a version here)") else(GDCM_FULL_VERSION VERSION_LESS MITK_REQUIRED_GDCM_VERSION) message(STATUS "Mitk: Found GDCM version ${GDCM_FULL_VERSION}") endif(GDCM_FULL_VERSION VERSION_LESS MITK_REQUIRED_GDCM_VERSION) # build tests? OPTION(BUILD_TESTING "Build the MITK Core tests." ON) IF(BUILD_TESTING) ENABLE_TESTING() ADD_SUBDIRECTORY(Testing) -ENDIF(BUILD_TESTING) \ No newline at end of file +ENDIF(BUILD_TESTING) diff --git a/Modules/MitkExt/CMakeLists.txt b/Modules/MitkExt/CMakeLists.txt index 7d60b5a2eb..6a6a06c49d 100644 --- a/Modules/MitkExt/CMakeLists.txt +++ b/Modules/MitkExt/CMakeLists.txt @@ -1,28 +1,28 @@ #if(WIN32) # option(MITK_USE_TD_MOUSE "Enable support for 3D Connexion SpaceNavigator" OFF) #endif(WIN32) configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${PROJECT_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${PROJECT_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${PROJECT_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) MITK_CREATE_MODULE( MitkExt INCLUDE_DIRS Algorithms Controllers DataManagement Interactions IO Rendering DEPENDS Mitk LegacyAdaptors IpPicSupport ipSegmentation mitkIpFunc PlanarFigure ImageStatistics - DEPENDS_INTERNAL pic2vtk #IIL4MITK + DEPENDS_INTERNAL pic2vtk ) # this is needed for libraries which link to mitkCoreExt and need # symbols from explicitly instantiated templates like # mitk::UnstructuredGridVtkWriter which is referenced in # mitk::UnstructuredGridVtkWriterTest in the MitkExtTestDriver executable. if(MINGW) get_target_property(_mitkCoreExt_MINGW_linkflags mitkCoreExt LINK_FLAGS) if(NOT _mitkCoreExt_MINGW_linkflags) set(_mitkCoreExt_MINGW_linkflags "") endif(NOT _mitkCoreExt_MINGW_linkflags) set_target_properties(mitkCoreExt PROPERTIES LINK_FLAGS "${_mitkCoreExt_MINGW_linkflags} -Wl,--export-all-symbols") endif(MINGW) add_subdirectory(Testing) diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 327554976f..d66fdcfa51 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -1,49 +1,48 @@ SUPPRESS_ALL_WARNINGS() # most stuff of these uses itk_zlib.h (via mitkIpPic.h) find_package(ITK) include(${ITK_USE_FILE}) # some legacy util files include in the old style with prefixed directory, # like #include include_directories(.) subdirs( ann ipSegmentation - #IIL4MITK pic2vtk tinyxml Poco qwt qxt mbilog glew vecmath qtsingleapplication ) # mbilog is independent of mitk, and cant use mitk macros # configuring happens through mbilog/mbilogConfig.cmake.in set(mbilog_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/mbilog" "${CMAKE_CURRENT_BINARY_DIR}/mbilog") set(mbilog_CONFIG_FILE "${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}/mbilogConfig.cmake" CACHE INTERNAL "Path to module config" FORCE) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mbilog/mbilogConfig.cmake.in" "${mbilog_CONFIG_FILE}") # if(NOT MITK_CHILI_PLUGIN) subdirs(ipPic ipFunc) add_subdirectory(KWStyle) # endif(NOT MITK_CHILI_PLUGIN) set(Poco_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Poco CACHE PATH "top-level directory containing the poco include directories. E.g /usr/local/include/ or c:\\poco\\include\\poco-1.3.2" ) set(Poco_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CACHE PATH "top-level directory containing the poco libraries." ) diff --git a/Utilities/IIL4MITK/CMakeLists.txt b/Utilities/IIL4MITK/CMakeLists.txt deleted file mode 100644 index d6bd1c912c..0000000000 --- a/Utilities/IIL4MITK/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -find_package(VTK) -include(${VTK_USE_FILE}) -# mitkGL.h is in Core/Rendering :( -find_package(OpenGL) -if(NOT OPENGL_FOUND) - message("GL is required for MITK rendering") -endif(NOT OPENGL_FOUND ) -include_directories(${OPENGL_INCLUDE_DIR}) -include_directories(../ipPic) - -add_library(IIL4MITK ${MITK_WIN32_FORCE_STATIC} image.cpp item.cpp picimage.cpp texture.cpp) -target_link_libraries(IIL4MITK ${OPENGL_LIBRARIES} ${IPPIC_LIBRARIES}) -MITK_CREATE_MODULE_CONF(IIL4MITK - DEPENDS mitkIpPic -) - diff --git a/Utilities/IIL4MITK/image.cpp b/Utilities/IIL4MITK/image.cpp deleted file mode 100644 index 6962427af2..0000000000 --- a/Utilities/IIL4MITK/image.cpp +++ /dev/null @@ -1,413 +0,0 @@ -#include -#include -#include "widget.h" -#include "texture.h" -#include "image.h" - -static unsigned int -power2 (const unsigned int x) -{ - unsigned int y = 1; - - while (y < x) - { - y *= 2; - } - return y; -} - -const unsigned int iil4mitkImage::_bytes [] = {1, 2, 3, 4, 3,4}; - -iil4mitkImage::iil4mitkImage (unsigned int size) -: _width (0), _height (0), _rx (0), _ry (0), _rw (0), _rh (0), - _model (INTENSITY), _interpolation (false), _pixels (NULL), - _internal (GL_LUMINANCE), _size(size) -{ - -} - -iil4mitkImage::~iil4mitkImage () -{ - clear (); -} - -void -iil4mitkImage::setImage (const unsigned int width, const unsigned int height, - const int model, unsigned char *data) -{ - assert (width > 0); - assert (height > 0); - - _width = width; - _height = height; - _model = model; - _pixels = data; - invalidateTextures (); -} - -unsigned int -iil4mitkImage::imageWidth() const -{ - return _width; -} - -unsigned int -iil4mitkImage::imageHeight () const -{ - return _height; -} - -void -iil4mitkImage::setRegion (const unsigned int x, const unsigned y, - const unsigned w, const unsigned h) -{ - assert (x + w <= _width); - assert (y + h <= _height); - - if ((_rx != x) || (_ry != y) || (_rw != w) || (_rh != h)) { - _rx = x; _ry = y; _rw = w; _rh = h; - invalidateTextures (); - } -} - -unsigned int -iil4mitkImage::regionX () const -{ - return _rx; -} - -unsigned int -iil4mitkImage::regionY () const -{ - return _ry; -} - -unsigned int -iil4mitkImage::regionWidth () const -{ - return _rw; -} - -unsigned int -iil4mitkImage::regionHeight () const -{ - return _rh; -} - -void -iil4mitkImage::clear () -{ - _width = _height = 0; - _rx = _ry = _rw = _rh = 0; - _model = INTENSITY; - _pixels = NULL; - _internal = GL_LUMINANCE; - - std::map::iterator i; - for (i=_textures.begin(); i!=_textures.end(); ++i) { - for (unsigned int j = 0; j < (*i).second->size (); j++) { - delete (*(*i).second)[j]; - } - delete i->second; - } - _textures.clear (); -} - -float -iil4mitkImage::width () const -{ - return (float) _rw; -} - -float -iil4mitkImage::height () const -{ - return (float) _rh; -} - -int -iil4mitkImage::model () const -{ - return _model; -} - -void -iil4mitkImage::setInterpolation (const bool on) -{ - _interpolation = on; -} - -bool -iil4mitkImage::interpolation () const -{ - return _interpolation; -} - -void -iil4mitkImage::display (iil4mitkWidget* widget) -{ - GLdouble planeX [] = {-1, 0, 0, regionWidth ()}; - GLdouble planeY [] = {0, -1, 0, regionHeight ()}; - - if (!visible () - || (constraint () && (widget != constraint ()))) - { - return; - } - - if (_pixels) - { - assert (_rx + _rw <= _width); - assert (_ry + _rh <= _height); - - GLboolean texturing = glIsEnabled (GL_TEXTURE_2D); - GLboolean blending = glIsEnabled (GL_BLEND); - - glClipPlane (GL_CLIP_PLANE4, planeX); - glEnable (GL_CLIP_PLANE4); - glClipPlane (GL_CLIP_PLANE5, planeY); - glEnable (GL_CLIP_PLANE5); - - if ((_model == INTENSITY_ALPHA) || (_model == COLOR_ALPHA) || (_model == RGB) || (_model == RGBA)) - { - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - glEnable (GL_TEXTURE_2D); - glMatrixMode (GL_MODELVIEW); - glPushMatrix (); - glColor4f (red (), green (), blue (), alpha ()); - glTranslatef (x (), y (), 0.0); - drawTextures (widget); - glPopMatrix (); - - glDisable (GL_CLIP_PLANE4); - glDisable (GL_CLIP_PLANE5); - - if (texturing == GL_FALSE) glDisable (GL_TEXTURE_2D); - if (blending == GL_FALSE) glDisable (GL_BLEND); - } -} - -void iil4mitkImage::drawTextures (iil4mitkWidget* widget) -{ - const unsigned int s = _size; // size of the tiles - unsigned int n, m; // number of the tiles - - n = (unsigned int) ceilf ((float) _rw / (float) (s - 2)); - m = (unsigned int) ceilf ((float) _rh / (float) (s - 2)); - - /* Allocate memory for the textures */ - - Textures* textures; - { - iil4mitkWidget* w; - unsigned int available, total; - - //w = (widget->IsSharing () ? widget->SharedWidget () : widget); - w = (false ? NULL : widget); - std::map::iterator tex_it = _textures.find (w); - if(tex_it!=_textures.end()) - textures = tex_it->second; - else - textures = NULL; - - if (!textures) { - textures = new Textures (); - typedef std::pair * > TexturePair; - _textures.insert (TexturePair(w, textures)); - } - available = textures->size (); - total = n * m; - //textures->resize (total); - int iii; - for (unsigned int i = available; i < total; i++) - { - textures->push_back(new _iil4mitkTexture (w)); - iii=textures->size (); - } - widget->MakeCurrent (); - } - - /* Render the textures */ - - glScalef ((float) (s-2), (float) (s-2), 1.0); - for (unsigned int i = 0; i < n; i++) - { - unsigned int pos [2]; // left-top corner of the region - unsigned int len [2]; // extent of the region - unsigned int tex [2]; // size of the texture - float res [2]; // resolution of the texture - - pos [0] = _rx+i*(s-2); - len [0] = (pos[0]+(s-2)>_rw ? _rw-pos[0] : s-2); - tex [0] = power2(s); - res [0] = 1.0f/tex[0]; - for (unsigned int j = 0; j < m; j++) - { - _iil4mitkTexture* texture; - - texture = (*textures)[i*m+j]; - pos [1] = _ry+j*(s-2); - len [1] = (pos[1]+(s-2)>_rh ? _rh-pos[1] : s-2); - tex [1] = power2(s); - res [1] = 1.0f/tex[1]; - - //if (widget->isVisible (pos [0], pos [1], len [0], len [1])) { - if (true) { - // widget->makeCurrent (); - texture->bind (); - // widget->makeCurrent (); - texture->setSize (tex[0], tex[1]); - texture->setModel (_model); - texture->setInterpolation (_interpolation); - if (!texture->isValid ()) - { - updateTexture (texture, pos[0], pos[1], len[0], len[1]); - } - - glBegin (GL_QUADS); - glTexCoord2f (res[0], res[1]); glVertex3f (0.0, 0.0, 0.0); - glTexCoord2f (1.0-res[0], res[1]); glVertex3f (1.0, 0.0, 0.0); - glTexCoord2f (1.0-res[0], 1.0-res[1]); glVertex3f (1.0, 1.0, 0.0); - glTexCoord2f (res[0], 1.0-res[1]); glVertex3f (0.0, 1.0, 0.0); - glEnd (); - } - glTranslatef (0.0, 1.0, 0.0); - } - glTranslatef (1.0, -((float) m), 0.0); - } -} - -void -iil4mitkImage::remove (iil4mitkWidget* widget) -{ - std::map::iterator i = - _textures.find (widget); - for (unsigned int j = 0; j < (*i).second->size (); j++) - { - delete (*(*i).second)[j]; - } - delete i->second; - _textures.erase(i); -} - -void -iil4mitkImage::invalidateTextures () -{ - std::map::iterator i; - for (i=_textures.begin(); i!=_textures.end(); ++i) - { - for (unsigned int j = 0; j < (*i).second->size (); j++) - { - (*(*i).second)[j]->invalidate (); - } - } -} - -void -iil4mitkImage::updateTexture (_iil4mitkTexture* texture, unsigned int x, unsigned int y, unsigned int w, unsigned int h) -{ - unsigned int p2w = texture->width (); - unsigned int p2h = texture->height (); - unsigned int size = p2w * p2h * _bytes [_model]; - unsigned char *region = (unsigned char *) malloc (size * sizeof (unsigned char)); - unsigned int left = (x == 0 ? 0 : 1); - unsigned int right = (x+w == _rw ? 0 : 1); - unsigned int top = (y == 0 ? 0 : 1); - unsigned int bottom = (y + h == _rh ? 0 : 1); - - if (x == 0) - { - copyImage (x, y-top, 1, h+top+bottom, region, p2w, p2h, 0, 1-top); - } - else - { - copyImage (x-1, y-top, 1, h+top+bottom, region, p2w, p2h, 0, 1-top); - } - if (x+w == _rw) - { - copyImage (x+w-1, y-top, 1, h+top+bottom, region, p2w, p2h, w+1, 1-top); - } - else - { - copyImage (x+w, y-top, 1, h+top+bottom, region, p2w, p2h, w+1, 1-top); - } - if (y == 0) - { - copyImage (x-left, y, w+left+right, 1, region, p2w, p2h, 1-left, 0); - } - else - { - copyImage (x-left, y-1, w+left+right, 1, region, p2w, p2h, 1-left, 0); - } - if (y+h == _rh) - { - copyImage (x-left, y+h-1, w+left+right, 1, region, p2w, p2h, 1-left, h+1); - } - else - { - copyImage (x-left, y+h, w+left+right, 1, region, p2w, p2h, 1-left, h+1); - } - copyImage (x, y, w, h, region, p2w, p2h, 1, 1); - texture->setData (region); - - /* - char filename [255]; - sprintf (filename, "tile_%u_%u.pic", x, y); - mitkIpPicDescriptor* pic = mitkIpPicNew (); - pic->type = mitkIpPicUInt; - pic->bpe = 8; - pic->dim = 2; - pic->n [0] = p2w; - pic->n [1] = p2h; - pic->data = region; - mitkIpPicPut (filename, pic); - pic->data = NULL; - mitkIpPicFree (pic); - */ - - free (region); -} - -void iil4mitkImage::copyImage(unsigned int x, unsigned int y, unsigned int w, - unsigned int h, unsigned char* data, unsigned int width, unsigned int, - unsigned int xoffset, unsigned int yoffset) -{ - const unsigned int bytes = _bytes [_model]; - const unsigned char *src = _pixels + (y * _width + x) * bytes; - unsigned char *dst = data + (yoffset * width + xoffset) * bytes; - - for (unsigned int i = 0; i < h; i++) - { - memcpy (dst, src, w * bytes); - src += _width * bytes; - dst += width * bytes; - } -} - -unsigned int -iil4mitkImage::bpe () -{ - return _bytes [_model] * 8; -} - -unsigned char* -iil4mitkImage::pixels () -{ - return _pixels; -} - -iil4mitkImage* -iil4mitkImage::find (const iil4mitkItem* item) -{ - iil4mitkImage* result = NULL; - - if (!item) return (iil4mitkImage *) NULL; - - if ( dynamic_cast(item)!=NULL ) { - result = const_cast(dynamic_cast(item)); - } - return (iil4mitkImage *) result; -} diff --git a/Utilities/IIL4MITK/image.h b/Utilities/IIL4MITK/image.h deleted file mode 100644 index 7dacf355d7..0000000000 --- a/Utilities/IIL4MITK/image.h +++ /dev/null @@ -1,195 +0,0 @@ -#ifndef _IMAGE_H_ -#define _IMAGE_H_ - -#include -#include "texture.h" -#include "item.h" -#include -#include - -/*! -\todo Manage the texture in a common way for all instances. -\todo Implement scaling of images here. -*/ -class iil4mitkImage : public iil4mitkItem { - -public: - - /*! - \brief The constructor. - */ - iil4mitkImage (unsigned int size = 128); - - /*! - \brief The destructor. - */ - virtual ~iil4mitkImage (); - - /*! - \brief The supported color models. - */ - enum {INTENSITY = 0, INTENSITY_ALPHA, COLOR, COLOR_ALPHA, RGB, RGBA}; - - /*! - \brief Sets the image. - @param width,height the image size. Make sure that the - dimensions have a power of two. Note that the image - size is limited (see \c maxDimensions). - @param model the color model - @param data the data - \note Make sure that the data keeps valid - until this instance is destroyed. - */ - virtual void setImage (const unsigned int width, const unsigned int height, const int model, unsigned char *data); - - /*! - \brief Gets the image size. - */ - unsigned int imageWidth () const; - unsigned int imageHeight () const; - - /*! - \brief Limits the image to the specified region. - @param x,y,w,h the position and size of the region - */ - virtual void setRegion (const unsigned int x, const unsigned y, const unsigned w, const unsigned h); - - /*! - \brief Gets the position and the size of the region. - */ - unsigned int regionX () const; - unsigned int regionY () const; - unsigned int regionWidth () const; - unsigned int regionHeight () const; - - /*! - \brief Clears the image. - */ - virtual void clear (); - - /*! - \brief Gets the maximal size of an image. - */ - // unsigned int maxSize () const; - - /*! - Gets the color model of the image. - */ - int model () const; - - /*! - \brief Switches interpolation for scaled images on or off. - */ - virtual void setInterpolation (const bool on = true); - - /*! - \brief Gets the interpolation method. - */ - bool interpolation () const; - - /*! - \brief Invalidates the content of the textures. - */ - virtual void invalidateTextures (); - -public: - - virtual float width () const; - virtual float height () const; - virtual void display (iil4mitkWidget* widget); - virtual void remove (iil4mitkWidget* widget); - -public: - - /*! - \brief Gets the first image of the item tree. - */ - static iil4mitkImage* find (const iil4mitkItem* item); - -protected: - - /*! - \brief Draws the image by means of the textures. - */ - void drawTextures (iil4mitkWidget* widget); - - /*! - \brief Updates the content of the given texture. - */ - void updateTexture (_iil4mitkTexture* texture, unsigned int x, unsigned int y, unsigned int w, unsigned int h); - - /*! - \brief Copies a specified region of the image. - @param x,y,w,h the geometry of the region - @param data the image data where the region is copied to - @param width,height the geometry of the image data - @param xoffset,yoffset the image point where the region is copied to - */ - virtual void copyImage (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char* data, unsigned int width, unsigned int height, unsigned int xoffset, unsigned int yoffset); - - /*! - \brief Sets the color model of the image. - - \note method needed? - */ - // void setModel (int model); - - /*! - \brief Gets the number of bits per element of the image. - */ - unsigned int bpe (); - - /*! - \brief Gets the pixels of the image. - */ - unsigned char* pixels (); - - -private: - - /*! - \brief The dimensions of the image. - */ - unsigned int _width, _height; - - /*! - \brief The region of the image which will be displayed. - */ - unsigned int _rx, _ry, _rw, _rh; - - /*! - \brief The color model of the image. - */ - int _model; - - /*! - \brief The interpolation method. - */ - bool _interpolation; - - /*! - \brief The bytes per element of the image. - */ - static const unsigned int _bytes [6]; - - /*! - \brief The pixels of the image. - */ - unsigned char *_pixels; - - /*! - \brief The internal color model of the texture. - */ - GLenum _internal; - - /*! - \brief The list of allocated textures. - */ - typedef std::vector<_iil4mitkTexture*> Textures; - std::map _textures; - - unsigned int _size; - -}; - -#endif diff --git a/Utilities/IIL4MITK/item.cpp b/Utilities/IIL4MITK/item.cpp deleted file mode 100644 index 8c27c755d4..0000000000 --- a/Utilities/IIL4MITK/item.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "widget.h" -#include "item.h" - -iil4mitkItem::iil4mitkItem () - : _x (0.0), _y (0.0), _red (1.0), _green (1.0), _blue (1.0), _alpha (1.0), _lineWidth (0.0), _constraint (0), _visible (true), _pickable (false), _scalable (true) -{ -} - -void -iil4mitkItem::remove (iil4mitkWidget* ) -{ -} - -void -iil4mitkItem::move (const float x, const float y) -{ - _x = x; - _y = y; -} - -float -iil4mitkItem::x () const -{ - return _x; -} - -float -iil4mitkItem::y () const -{ - return _y; -} - -float -iil4mitkItem::width () const -{ - return 0.0; -} - -float -iil4mitkItem::height () const -{ - return 0.0; -} - - -void -iil4mitkItem::setColor (const float red, const float green, const float blue, const float alpha) -{ - _red = red; - _green = green; - _blue = blue; - _alpha = alpha; -} - -float -iil4mitkItem::red () const -{ - return _red; -} - -float -iil4mitkItem::green () const -{ - return _green; -} - -float -iil4mitkItem::blue () const -{ - return _blue; -} - -float -iil4mitkItem::alpha () const -{ - return _alpha; -} - -void -iil4mitkItem::setLineWidth (const float width) -{ - _lineWidth = width; -} - -float -iil4mitkItem::lineWidth () const -{ - return _lineWidth; -} - -void -iil4mitkItem::setPickable (const bool on) -{ - _pickable = on; -} - -bool -iil4mitkItem::pickable () const -{ - return _pickable; -} - -iil4mitkItem* -iil4mitkItem::picked (iil4mitkWidget*, const float x, const float y) -{ - if (!pickable () || !visible ()) return NULL; - - bool p = !((x < this->x ()) || (y < this->y ()) || (x > this->x () + this->width ()) || (y > this->y () + this->height ())); - iil4mitkItem* obj = (p ? this : NULL); - return obj; -} - -void -iil4mitkItem::setScalable (const bool scalable) -{ - _scalable = scalable; -} - -bool -iil4mitkItem::scalable () const -{ - return _scalable; -} - -void -iil4mitkItem::setConstraint (iil4mitkWidget* widget) { - _constraint = widget; -} - -iil4mitkWidget* -iil4mitkItem::constraint () const -{ - return _constraint; -} - -void -iil4mitkItem::setVisible (const bool visible) -{ - _visible = visible; -} - -bool -iil4mitkItem::visible () const -{ - return _visible; -} - -void -iil4mitkItem::hide () -{ - setVisible (false); -} - -void -iil4mitkItem::show () -{ - setVisible (true); -} diff --git a/Utilities/IIL4MITK/item.h b/Utilities/IIL4MITK/item.h deleted file mode 100644 index 456657c52b..0000000000 --- a/Utilities/IIL4MITK/item.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef _ITEM_H_ -#define _ITEM_H_ - -#ifdef WIN32 - #include -#endif - -#ifndef __APPLE__ - #include "GL/gl.h" -#else - #include "OpenGL/gl.h" -#endif - - -/*! -\brief The items are objects that can be displayed by -the widget. When the widget demands an update of the display, -each item draws itself into the viewport. If the user wants to -interact with some item, each item provides the information -whether it has been picked by the user. - -\todo Add a scale method. -\todo Add a parameter iil4mitkWidget to the picking method. Done. -*/ - -class iil4mitkItem { - -public: - - /*! - \brief The constructor. - */ - iil4mitkItem(); - - virtual ~iil4mitkItem() {} - - /*! - \brief Displays the item. - \note Make sure that the proper OpenGL context has been - made current. - \todo Should the method return whether something has been - rendered? - */ - virtual void display (iil4mitkWidget* widget) = 0; - - /*! - \brief Frees the resources of the item for the given widget. - \note Make sure that the proper OpenGL context has been - made current. - */ - virtual void remove (iil4mitkWidget* widget); - - /*! - \brief Sets the position of the item. - */ - void move (const float x, const float y); - - /*! - \brief Gets the position of the item. - */ - float x () const; - float y () const; - - /*! - \brief Gets the size of the item. - \note The method may be helpful for picking. - */ - virtual float width () const; - virtual float height () const; - - /*! - \brief Sets the color of the item. - @param red,green,blue the channels of the rgb color model - @param alpha the opacity. If alpha is equal to one, the - item is rendered opaque, otherwise it is rendered - semi-transparent. If alpha is zero, the item won't be visible. - */ - virtual void setColor (const float red, const float green, const float blue, const float alpha); - - /*! - \brief Gets the color channels. - */ - float red () const; - float green () const; - float blue () const; - float alpha () const; - - /*! - \brief Sets the widht of the isocontour. - @param width the line width - */ - void setLineWidth (const float width); - - /*! - \brief Gets the width of the isocontour. - */ - float lineWidth () const; - - /*! - \brief Sets the flag whether the user can pick the item. - */ - void setPickable (const bool on); - - /*! - \brief Checks if the user can pick the item. - @returns If the item is allowed to be picked, true is returned. - */ - bool pickable () const; - - /*! - \brief Checks if the item has been picked by the user. - @param widget the widget which caused an event - @param x,y the point the user has picked - @returns the picked item, or null if no item has been picked - */ - virtual iil4mitkItem* picked (iil4mitkWidget* widget, const float x, const float y); - - /*! - \brief Sets if items should be scaled when the viewport is zoomed. - If so, items will grow as far as the viewport is zoomed. Otherwise, - items will keep its size constant. - */ - void setScalable (const bool scalable); - - /*! - \brief Checks if items will be scaled when the viewport changes. - */ - bool scalable () const; - - /*! - \brief Sets the given widget as a constraint for rendering, i.e., - the contents are rendered only if the widget that demands the - rendering is the same as the given one. - @param widget the widget which the rendering is constraint to. If - null is given, the constraint will be removed. - */ - void setConstraint (iil4mitkWidget* widget); - - /*! - \brief Gets the widget which the rendering is constraint to. - */ - iil4mitkWidget* constraint () const; - - /*! - \brief Makes the item visible or hidden, respectively. - @param visible If true the item is displayed, otherwise it is not. - */ - void setVisible (const bool visible); - - /*! - \brief Checks if the item will be visible. - @returns If the item will be displayed, true is returned. - */ - bool visible () const; - - /*! - \brief Shows the item. - */ - void show (); - - /*! - \brief Hides the item. - */ - void hide (); - -private: - - /*! - \brief The position of the item. - */ - float _x, _y; - - /*! - \brief The color channels. - */ - float _red, _green, _blue, _alpha; - - /*! - \brief The line width. - */ - float _lineWidth; - - /*! - \brief The widget which the rendering is constraint to. - */ - iil4mitkWidget* _constraint; - - /*! - \brief Flags if the item will be displayed during - the next rendering. - */ - bool _visible; - - /*! - \brief Flags if the item is allowed to be picked. - */ - bool _pickable; - - /*! - \brief Flags if the item is scalable. If so, - items will grow as far as the viewport is zoomed. - Otherwise, items will keep its size constant. - */ - bool _scalable; - -}; - -#endif diff --git a/Utilities/IIL4MITK/picimage.cpp b/Utilities/IIL4MITK/picimage.cpp deleted file mode 100644 index 69a5aa75b4..0000000000 --- a/Utilities/IIL4MITK/picimage.cpp +++ /dev/null @@ -1,633 +0,0 @@ -#include -#include "texture.h" -#include "picimage.h" -#include - -iil4mitkPicImage::iil4mitkPicImage (unsigned int size) - : iil4mitkImage(size), _pic (NULL), _min (0.0), _max (0.0), _colors (NULL), _binary (false), _mask (false), _outline(false), _outlineWidth(1.0) -{ -} - -iil4mitkPicImage::~iil4mitkPicImage () -{ -} - -void -iil4mitkPicImage::setPicImage (mitkIpPicDescriptor* pic, int model) -{ - assert (pic); - assert (pic->dim >= 2); - - _pic = pic; - iil4mitkImage::setImage (pic->n[0], pic->n[1], model, (unsigned char *) pic->data); -} - -mitkIpPicDescriptor* -iil4mitkPicImage::image () const -{ - return _pic; -} - -void -iil4mitkPicImage::setExtrema (const float minimum, const float maximum) -{ - // assert (minimum < maximum); - - _min = minimum; - _max = maximum; - invalidateTextures (); -} - -void -iil4mitkPicImage::setWindow (const float level, const float window) -{ - // assert (window > 0); - _min = level - window / 2.0; - _max = _min + window; - invalidateTextures (); -} - -float -iil4mitkPicImage::minimum () const -{ - return _min; -} - -float -iil4mitkPicImage::maximum () const -{ - return _max; -} - -float -iil4mitkPicImage::level () const -{ - return (_min + _max) / 2.0; -} - -float -iil4mitkPicImage::window () const -{ - return (_max - _min); -} - -void - iil4mitkPicImage::setOpacityExtrema (const float minimum, const float maximum) -{ - // assert (minimum < maximum); - - _minOpac = minimum; - _maxOpac = maximum; - invalidateTextures (); -} - -void -iil4mitkPicImage::setOpacityWindow (const float level, const float window) -{ - // assert (window > 0); - _minOpac = level - window / 2.0; - _maxOpac = _minOpac + window; - invalidateTextures (); -} - -float -iil4mitkPicImage::minimumOpacity () const -{ - return _minOpac; -} - -float -iil4mitkPicImage::maximumOpacity () const -{ - return _maxOpac; -} - -float -iil4mitkPicImage::levelOpacity () const -{ - return (_minOpac + _maxOpac) / 2.0; -} - -float -iil4mitkPicImage::windowOpacity () const -{ - return (_maxOpac - _minOpac); -} - -void -iil4mitkPicImage::setColors (const unsigned char* colors) -{ - _colors = colors; -} - -const unsigned char* -iil4mitkPicImage::colors () const -{ - return _colors; -} - -void -iil4mitkPicImage::setBinary (const bool on) -{ - if (_binary != on) { - if (on) { - _mask = false; - } - _binary = on; - invalidateTextures (); - } -} - -bool -iil4mitkPicImage::binary () const -{ - return _binary; -} - -void -iil4mitkPicImage::setOutline (const bool on) -{ - if (_binary) { - _outline = on; - } -} - -void -iil4mitkPicImage::setOutlineWidth(float width) -{ - if (_binary) { - _outlineWidth = width; - } -} - - -bool -iil4mitkPicImage::outline () const -{ - return _outline; -} - -void -iil4mitkPicImage::setMask (const bool on) -{ - if (_mask != on) { - if (on) { - _binary = false; - } - _mask = on; - invalidateTextures (); - } -} - -bool -iil4mitkPicImage::mask () const -{ - return _mask; -} - -void -iil4mitkPicImage::clear () -{ - _pic = NULL; - _min = _max = 0.0; - _minOpac = _maxOpac = 0.0; - _colors = NULL; - _binary = false; - _mask = false; - _outline = false; - iil4mitkImage::clear (); -} - -iil4mitkPicImage* -iil4mitkPicImage::find (const iil4mitkItem* item) -{ - iil4mitkPicImage* result = NULL; - - if (!item) return NULL; - - if ( dynamic_cast(item)!=NULL ) { - result = const_cast(dynamic_cast(item)); - } - return result; -} - -#define MASK_INTENSITIES(TYPE, PIC) \ -{ \ -TYPE* source = (TYPE *) src; \ -unsigned char* dest = dst; \ -register float a; \ -if (model () == INTENSITY) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -*dest = (a > 255.0 ? 0 : (a < 0.0 ? 0 : 255)); \ -source++; \ -dest++; \ -} else \ -if (model () == INTENSITY_ALPHA) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -dest [1] = dest [0] = (a > 255.0 ? 0 : (a < 0.0 ? 0 : 255)); \ -source++; \ -dest += 2; \ -} \ -} - -#define BINARY_INTENSITIES(TYPE, PIC) \ -{ \ -TYPE* source = (TYPE *) src; \ -unsigned char* dest = dst; \ -register float a; \ -if (model () == INTENSITY) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -*dest = (a > 255.0 ? 255 : (a < 0.0 ? 0 : 255)); \ -source++; \ -dest++; \ -} else \ -if (model () == INTENSITY_ALPHA) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -dest [0] = (a > 255.0 ? 255 : (a < 0.0 ? 0 : 255)); \ -dest [1] = (a > 0.0 ? 255 : 0); \ -source++; \ -dest += 2; \ -} \ -} - -#define LIMIT_INTENSITIES(TYPE, PIC) \ -{ \ -TYPE* source = (TYPE *) src; \ -unsigned char* dest = dst; \ -register unsigned int i; \ -register float a,b,c,d; \ -if (model () == INTENSITY) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -*dest = (a > 255.0 ? 255 : (a < 0.0 ? 0 : (unsigned char) a)); \ -source++; \ -dest++; \ -} else \ -if (model () == INTENSITY_ALPHA) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -dest [0] = (a > 255.0 ? 255 : (a < 0.0 ? 0 : (unsigned char) a)); \ -dest [1] = (a > 0.0 ? 255 : 0); \ -source++; \ -dest += 2; \ -} else \ -if ((model () == COLOR) && _colors) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -i = (a > 255.0 ? 255 : (a < 0.0 ? 0 : (unsigned char) a)); \ -dest [0] = _colors [i*3]; \ -dest [1] = _colors [i*3+1]; \ -dest [2] = _colors [i*3+2]; \ -source++; \ -dest += 3; \ -} else \ -if ((model () == COLOR_ALPHA) && _colors) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -i = (a > 255.0 ? 255 : (a < 0.0 ? 0 : (unsigned char) a)); \ -dest [0] = _colors [i*4 ]; \ -dest [1] = _colors [i*4+1]; \ -dest [2] = _colors [i*4+2]; \ -dest [3] = _colors [i*4+3]; \ -source++; \ -dest += 4; \ -} else \ -if ((model () == COLOR) && !_colors) \ -while (dest < eol) { \ -a = source [0] * scale - bias; \ -b = source [slice] * scale - bias; \ -c = source [2*slice] * scale - bias; \ -dest [0] = (a > 255.0 ? 255 : (a < 0.0 ? 0 : (unsigned char) a)); \ -dest [1] = (b > 255.0 ? 255 : (b < 0.0 ? 0 : (unsigned char) b)); \ -dest [2] = (c > 255.0 ? 255 : (c < 0.0 ? 0 : (unsigned char) c)); \ -source++; \ -dest += 3; \ -} \ -if ((model () == COLOR_ALPHA) && !_colors) \ -{ \ -a = source [0] * scale - bias; \ -b = source [slice] * scale - bias; \ -c = source [2*slice] * scale - bias; \ -d = source [3*slice] * scale - bias; \ -dest [0] = (a > 255.0 ? 255 : (a < 0.0 ? 0 : (unsigned char) a)); \ -dest [1] = (b > 255.0 ? 255 : (b < 0.0 ? 0 : (unsigned char) b)); \ -dest [2] = (c > 255.0 ? 255 : (c < 0.0 ? 0 : (unsigned char) c)); \ -dest [3] = (d > 255.0 ? 255 : (d < 0.0 ? 0 : (unsigned char) d)); \ -source++; \ -dest += 4; \ -} \ -} - -// prototype -#ifdef USE_MMX -#define MAXSHORT 32767 -static void extrema (unsigned char* dst, short* src, const unsigned int num, const short minimum, const short maximum) -{ - const short low = -1024; - const short up = MAXSHORT - (maximum - low); - const short down = (minimum - low) + up; - const short scale = (255.0f/(float) (maximum-minimum)) * 256; - const short values [] = { - low, // lowest value - low, - low, - low, - up, // saturate above - up, - up, - up, - down, // saturate below - down, - down, - down, - scale, // scale - scale, - scale, - scale - }; - const unsigned int n = num / 16; - - __asm__ __volatile__ ( - ".align 16 \n\t" - "l1: \n\t" - "prefetcht0 64(%1) \n\t" - - "movq (%1),%%mm0 \n\t" - "movq 8(%1),%%mm1 \n\t" - "psubsw (%2),%%mm0 \n\t" - "psubsw (%2),%%mm1 \n\t" - "paddsw 8(%2),%%mm0 \n\t" - "paddsw 8(%2),%%mm1 \n\t" - "psubusw 16(%2),%%mm0 \n\t" - "psubusw 16(%2),%%mm1 \n\t" - "pmullw 24(%2),%%mm0 \n\t" - "pmullw 24(%2),%%mm1 \n\t" - "psrlw $8,%%mm0 \n\t" - "psrlw $8,%%mm1 \n\t" - "packuswb %%mm1,%%mm0 \n\t" - "movntq %%mm0,(%0) \n\t" - - "movq 16(%1),%%mm2 \n\t" - "movq 24(%1),%%mm3 \n\t" - "psubsw (%2),%%mm2 \n\t" - "psubsw (%2),%%mm3 \n\t" - "paddsw 8(%2),%%mm2 \n\t" - "paddsw 8(%2),%%mm3 \n\t" - "psubusw 16(%2),%%mm2 \n\t" - "psubusw 16(%2),%%mm3 \n\t" - "pmullw 24(%2),%%mm2 \n\t" - "pmullw 24(%2),%%mm3 \n\t" - "psrlw $8,%%mm2 \n\t" - "psrlw $8,%%mm3 \n\t" - "packuswb %%mm3,%%mm2 \n\t" - "movntq %%mm2,8(%0) \n\t" - - "emms \n\t" - "add $16,%0 \n\t" - "add $32,%1 \n\t" - "dec %3 \n\t" - "jnz l1 \n\t" - "emms \n\t" - : - :"r" (dst), "r" (src), "r" (values), "r" (n) - ); -} -#endif - -#ifndef PIC_IMAGE_PI - #define PIC_IMAGE_PI 3.141592653589 -#endif - -// Convert color pixels from (R,G,B) to (H,S,I). -// Reference: "Digital Image Processing, 2nd. edition", R. Gonzalez and R. Woods. Prentice Hall, 2002. -template -void RGBtoHSI(T* RGB, T* HSI) { - T R = RGB[0], - G = RGB[1], - B = RGB[2], - nR = (R<0?0:(R>255?255:R))/255, - nG = (G<0?0:(G>255?255:G))/255, - nB = (B<0?0:(B>255?255:B))/255, - m = nR0) H = (nB<=nG)?theta:360-theta; - if (sum>0) S = 1 - 3/sum*m; - I = sum/3; - HSI[0] = (T)H; - HSI[1] = (T)S; - HSI[2] = (T)I; -} - -// Convert color pixels from (H,S,I) to (R,G,B). -template -void HSItoRGB(T* HSI, T* RGB) { - T H = (T)HSI[0], - S = (T)HSI[1], - I = (T)HSI[2], - a = I*(1-S), - R = 0, G = 0, B = 0; - if (H<120) { - B = a; - R = (T)(I*(1+S*std::cos(H*PIC_IMAGE_PI/180)/std::cos((60-H)*PIC_IMAGE_PI/180))); - G = 3*I-(R+B); - } else if (H<240) { - H-=120; - R = a; - G = (T)(I*(1+S*std::cos(H*PIC_IMAGE_PI/180)/std::cos((60-H)*PIC_IMAGE_PI/180))); - B = 3*I-(R+G); - } else { - H-=240; - G = a; - B = (T)(I*(1+S*std::cos(H*PIC_IMAGE_PI/180)/std::cos((60-H)*PIC_IMAGE_PI/180))); - R = 3*I-(G+B); - } - R*=255; G*=255; B*=255; - RGB[0] = (T)(R<0?0:(R>255?255:R)); - RGB[1] = (T)(G<0?0:(G>255?255:G)); - RGB[2] = (T)(B<0?0:(B>255?255:B)); -} - -void iil4mitkPicImage::copyImage (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char* data, unsigned int width, unsigned int, unsigned int xoffset, unsigned int yoffset) -{ - assert (_pic); - // assert (_min <= _max); - - unsigned int slice = _pic->n[0] * _pic->n[1] * (_pic->bpe / 8); - float scale = (_max -_min > 0 ? 255.0 / (_max - _min) : 0.0); - float bias = _min * scale; - float scaleOpac = (_maxOpac -_minOpac > 0 ? 255.0 / (_maxOpac - _minOpac) : 0.0); - float biasOpac = _minOpac * scaleOpac; - unsigned char *src = (unsigned char *) _pic->data + (y * _pic->n[0] + x) * (_pic->bpe/8); - unsigned char *dst = data + (yoffset * width + xoffset) * (bpe () / 8); - unsigned char *eol = dst + w * (bpe () / 8); - - //printf ("updateTexture: start = (%u/%u), end = (%u/%u), length = (%u/%u)\n", x, y, x+w-1, y+h-1, w, h); - for (unsigned int i = 0; i < h; i++) { - - // copy current line - - if (model () == RGB) - { - unsigned char* source = (unsigned char *) src; - unsigned char* dest = dst; - while (dest < eol) - { - if(_min!=0 || _max!=255) - { - // level/window mechanism for intensity in HSI space - double rgb[3], hsi[3]; - rgb[0] = source[0]; - rgb[1] = source[1]; - rgb[2] = source[2]; - RGBtoHSI(rgb,hsi); - hsi[2] = hsi[2] * 255.0 * scale - bias; - hsi[2] = (hsi[2] > 255.0 ? 255 : (hsi[2] < 0.0 ? 0 : hsi[2])); - hsi[2] /= 255.0; - HSItoRGB(hsi,rgb); - dest[0] = (unsigned char)rgb[0]; - dest[1] = (unsigned char)rgb[1]; - dest[2] = (unsigned char)rgb[2]; - source+=3; - dest+=3; - } - else - { - *dest = *source; - ++source; - ++dest; - } - } - } - else if (model () == RGBA) - { - unsigned char* source = (unsigned char *) src; - unsigned char* dest = dst; - while (dest < eol) - { - if(_min!=0 || _max!=255 || _minOpac!=0 || _maxOpac!=255) - { - double rgb[3], alpha, hsi[3]; - - // level/window mechanism for intensity in HSI space - rgb[0] = source[0]; - rgb[1] = source[1]; - rgb[2] = source[2]; - alpha = source[3]; - RGBtoHSI(rgb,hsi); - hsi[2] = hsi[2] * 255.0 * scale - bias; - hsi[2] = (hsi[2] > 255.0 ? 255 : (hsi[2] < 0.0 ? 0 : hsi[2])); - hsi[2] /= 255.0; - HSItoRGB(hsi,rgb); - - // level/window mechanism for opacity - alpha = alpha * scaleOpac - biasOpac; - alpha = (alpha > 255.0 ? 255 : (alpha < 0.0 ? 0 : alpha)); - - dest[0] = (unsigned char)rgb[0]; - dest[1] = (unsigned char)rgb[1]; - dest[2] = (unsigned char)rgb[2]; - dest[3] = (unsigned char)alpha; - - source+=4; - dest+=4; - } - else - { - *dest = *source; - ++source; - ++dest; - } - } - } else - if (mask ()) { - mitkIpPicFORALL(MASK_INTENSITIES, _pic); - } else - if (binary ()) { - mitkIpPicFORALL(BINARY_INTENSITIES, _pic); - } else { -#ifdef USE_MMX - if (mitkIpPicDR(_pic->type, _pic->bpe) == mitkIpPicDR(mitkIpPicInt, 16)) { - unsigned char* d = dst; - unsigned char* s = src; - if (w / 16) { - extrema (dst, (short *) src, w, (short) _min, (short) _max); - } - if (w % 16) { - mitkIpPicFORALL(LIMIT_INTENSITIES, _pic); - dst = d; - src = s; - } - } else { - mitkIpPicFORALL(LIMIT_INTENSITIES, _pic); - } -#else - mitkIpPicFORALL(LIMIT_INTENSITIES, _pic); -#endif - } - - // go to next line - - src += _pic->n[0] * (_pic->bpe/8); - dst += width * (bpe () / 8); - eol = dst + w * (bpe () / 8); - } -} - - -void -iil4mitkPicImage::display (iil4mitkWidget* widget) -{ - if (!_outline) { - iil4mitkImage::display( widget ); - } - else { - glMatrixMode (GL_MODELVIEW); - glPushMatrix (); - glColor4f ( red(), green(), blue(), alpha() ); - //glColor4f( 1.0, 0.0, 0.0, 1.0 ); - glTranslatef( x(), y(), 0.0 ); - glLineWidth(_outlineWidth); - glBegin( GL_LINES ); - - int line = _pic->n[0]; - float fLine = (float)line; - float x=0.0, y=0.0; - mitkIpInt1_t *current; - mitkIpInt1_t *end = ((mitkIpInt1_t*)_pic->data) + (_pic->n[0]*_pic->n[1]); - int ii = 0, nn = _pic->n[0]*_pic->n[1]; - for (current = (mitkIpInt1_t*)_pic->data; current= line && *(current-line) == 0) { - glVertex3f( x, y, 0.0 ); - glVertex3f( x+1.0, y, 0.0 ); - } - if (ii <= nn-line && *(current+line) == 0) { - glVertex3f( x, y+1.0, 0.0 ); - glVertex3f( x+1.0, y+1.0, 0.0 ); - } - if (ii > 1 && *(current-1) == 0) { - glVertex3f( x, y, 0.0 ); - glVertex3f( x, y+1.0, 0.0 ); - } - if (ii < nn-1 && *(current+1) == 0) { - glVertex3f( x+1.0, y, 0.0 ); - glVertex3f( x+1.0, y+1.0, 0.0 ); - } - } - x += 1.0; - if (x >= fLine) { - x = 0.0; - y += 1.0; - } - } - glEnd (); - glLineWidth(1.0f); - glPopMatrix (); - } -} diff --git a/Utilities/IIL4MITK/picimage.h b/Utilities/IIL4MITK/picimage.h deleted file mode 100644 index 6408df5deb..0000000000 --- a/Utilities/IIL4MITK/picimage.h +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef _PIC_IMAGE_H_ -#define _PIC_IMAGE_H_ - -#include -#include "image.h" - -/*! -\brief The class adds support for PIC images by providing a proper interface -to map the intensity range to the physical one of the display. -*/ -class iil4mitkPicImage : public iil4mitkImage { - -public: - /*! - \brief The constructor. - */ - iil4mitkPicImage (unsigned int size = 128); - - /*! - \brief The destructor. - */ - virtual ~iil4mitkPicImage (); - - /*! - \brief Sets the PIC image. - @param pic the PIC image - @param model the color model - - \note Is the model needed here? - */ - void setPicImage (mitkIpPicDescriptor* pic, int model = INTENSITY); - - /*! - \brief Gets the PIC image. - */ - mitkIpPicDescriptor* image () const; - - /*! - \brief Sets the range of the intensities which will be displayed. - @param minimum the minimal intensity - @param maximum the maximal intensity - */ - void setExtrema (const float minimum, const float maximum); - - /*! - \brief Sets the range of the intensities which will be displayed. - @param level the level of the window - @param window the width of the window - */ - void setWindow (const float level, const float window); - - /*! - \brief Gets the minimal intensity which will be displayed. - */ - float minimum () const; - - /*! - \brief Gets the maximal intensity which will be displayed. - */ - float maximum () const; - - /*! - \brief Gets the level of the window which limits the - displayed intensities. - */ - float level () const; - - /*! - \brief Gets the width of the window which limits the - displayed intensities. - */ - float window () const; - - /*! - \brief Sets the range of opacity values which will be displayed. - @param minimum the minimal opacity - @param maximum the maximal opacity - */ - void setOpacityExtrema (const float minimum, const float maximum); - - /*! - \brief Sets the range of the opacities which will be displayed. - @param level the level of the window - @param window the width of the window - */ - void setOpacityWindow (const float level, const float window); - - /*! - \brief Gets the minimal opacity which will be displayed. - */ - float minimumOpacity () const; - - /*! - \brief Gets the maximal opacity which will be displayed. - */ - float maximumOpacity () const; - - /*! - \brief Gets the level of the window which limits the - displayed opacities. - */ - float levelOpacity () const; - - /*! - \brief Gets the width of the window which limits the - displayed opacities. - */ - float windowOpacity () const; - - /*! - \brief Sets the color map which assigns each intensity - a color according to the color model. - @param colors the array of colors using either the - RGB format or RGBA format which depends on the color - model. - */ - void setColors (const unsigned char* colors); - - /*! - \brief Gets the color map. - */ - const unsigned char* colors () const; - - /*! - \brief Sets the binary flag which forces the data - to be converted into a binary image. - */ - void setBinary (const bool on); - - /*! - \brief Checks if the binary flag is set. - */ - bool binary () const; - - /*! - \brief Sets the outline flag which forces the data - to be displayed as outline. Only possible with binary data! - */ - void setOutline (const bool on); - /*! - \brief Sets the line width used to draw the binary - outline. Requires the outline flag to be set via setOutline(true) first. - */ - void setOutlineWidth (float width); - - /*! - \brief Checks if the outline flag is set. - */ - bool outline () const; - - /*! - \brief Sets the mask flag which ensures that - only pixels are displayed which are in the - intensity window. - */ - void setMask (const bool on); - - /*! - \brief Checks if the mask flag is set. - */ - bool mask () const; - -public: - - virtual void clear (); - virtual void display (iil4mitkWidget* widget); - -public: - - /*! - \brief Gets the first image of the item tree. - */ - static iil4mitkPicImage* find (const iil4mitkItem* item); - -protected: - - virtual void copyImage (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char* data, unsigned int width, unsigned int height, unsigned int xoffset, unsigned int yoffset); - -private: - - /*! - \brief The PIC image. - */ - mitkIpPicDescriptor* _pic; - - /*! - \brief The extremal values. - */ - float _min, _max; - - /*! - \brief The extremal opacity values. - */ - float _minOpac, _maxOpac; - - /*! - \brief The color map. - */ - const unsigned char* _colors; - - /*! - \brief The binary flag. If the flag is set, the data - will be displayed as a binary image. - */ - bool _binary; - - /*! - \brief The mask flag. If the flag is set, the data - which is in the defined intensity window will be shown - as a binary image. In contrast to the binary flag, - the upper values are set to zero. - */ - bool _mask; - - /*! - \brief The outline flag. If the flag is set, the binary data - will be displayed with lines showing the outline. - */ - bool _outline; - /*! - \brief If the outline flag is set, this attribute controls the line width - */ - float _outlineWidth; -}; - -#endif diff --git a/Utilities/IIL4MITK/texture.cpp b/Utilities/IIL4MITK/texture.cpp deleted file mode 100644 index ed4923408b..0000000000 --- a/Utilities/IIL4MITK/texture.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include "texture.h" - -_iil4mitkTexture::_iil4mitkTexture (iil4mitkWidget* aParent) - : _width (0), _height (0), _model (0), _internal (0), _valid (false), _interpolation (false), _red (1.0), _green (1.0), _blue (1.0), _alpha (1.0),parent(aParent) -{ - assert (parent); - - parent->MakeCurrent (); - glGenTextures (1, &_name); - glBindTexture (GL_TEXTURE_2D, _name); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); -} - -/* -Pay attention that the context which the widget share with another widget -will not be deleted. -*/ -_iil4mitkTexture::~_iil4mitkTexture () { - if(parent!=NULL) - parent->MakeCurrent (); - glDeleteTextures (1, &_name); - - // Are the textures deleted automatically? - -} - -void -_iil4mitkTexture::bind () -{ - glBindTexture (GL_TEXTURE_2D, _name); -} - - -void -_iil4mitkTexture::setSize (const unsigned int width, const unsigned int height) -{ - assert (width > 0); - assert (height > 0); - - if ((width != _width) || (height != _height)) { - _valid = false; - } - _width = width; - _height = height; -} - -unsigned int -_iil4mitkTexture::width () const -{ - return _width; -} - -unsigned int -_iil4mitkTexture::height () const -{ - return _height; -} - -void -_iil4mitkTexture::setModel (int model) -{ - switch (model) { - case INTENSITY: - _model = GL_LUMINANCE; - break; - case INTENSITY_ALPHA: - _model = GL_LUMINANCE_ALPHA; - break; - case COLOR: - _model = GL_RGB; - break; - case COLOR_ALPHA: - _model = GL_RGBA; - break; - case RGB: - _model = GL_RGB; - break; - case RGBA: - _model = GL_RGBA; - break; - } - if (_internal != _model) { - _internal = _model; - _valid = false; - } -} - -void -_iil4mitkTexture::setData (const unsigned char* data) -{ - glTexImage2D (GL_TEXTURE_2D, 0, _internal, _width, _height, 0, _model, GL_UNSIGNED_BYTE, data); - _valid = true; -} - -void -_iil4mitkTexture::setInterpolation (const bool on) { - if (on) { - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - _interpolation = on; -} - -void -_iil4mitkTexture::invalidate () -{ - - _valid = false; -} - -bool -_iil4mitkTexture::isValid () -{ - return _valid; -} diff --git a/Utilities/IIL4MITK/texture.h b/Utilities/IIL4MITK/texture.h deleted file mode 100644 index b1c1b17fe2..0000000000 --- a/Utilities/IIL4MITK/texture.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef _TEXTURE_H_ -#define _TEXTURE_H_ - -#include "widget.h" - -/* -The class holds a texture which is associated -to a particular widget. It is not responsible for -the rendering of images. - -\todo Remove the makeCurrent calls -*/ -class _iil4mitkTexture { - -public: - - /*! - \brief The constructor. - \note Make sure that the desired OpenGL context is selected. - */ - _iil4mitkTexture (iil4mitkWidget* parent); - - /*! - \brief The destructor. - - Frees the texture in the OpenGL context, if it is still - \note Make sure that the desired OpenGL context is selected. - existing. - */ - virtual ~_iil4mitkTexture (); - - /*! - \brief Binds the texture to the OpenGL context of the widget. - \note Make sure that the OpenGL context is made current. - */ - void bind (); - - /*! - \brief Sets the size of the texture. - */ - void setSize (const unsigned int width, const unsigned int height); - - /*! - \brief Gets the width of the texture. - */ - unsigned int width () const; - - /*! - \brief Gets the height of the texture. - */ - unsigned int height () const; - - /*! - \brief The color models of the image. - */ - enum {INTENSITY = 0, INTENSITY_ALPHA, COLOR, COLOR_ALPHA, RGB, RGBA}; - - /*! - \brief Sets the color model of the data. If the color is different from white, - the RGBA color model is used. - @param model the color model which is requested - */ - void setModel (int model); - - /*! - \brief Sets the image data for the texture. If some of the above - parameters have been changed, the method brings the texture - to a valid state. - \note Make sure that the OpenGL context is made current and - the texture has been bound. - \see valid() - */ - void setData (const unsigned char* data); - - /*! - \brief Turns the bilinear interpolation of the texture on/off. - \note Make sure that the OpenGL context is made current and - the texture has been bound. - */ - void setInterpolation (const bool on = true); - - /*! - \brief Makes the texture invalid. - */ - void invalidate (); - - /*! - \brief Checks if the texture is still valid. For example, the texture - gets invalid if its parameters are changed without setting new data. - */ - bool isValid (); - -private: - - /*! - \brief The texture name. - */ - GLuint _name; - - /*! - \brief The size of the texture. - */ - unsigned int _width, _height; - - /*! - \brief The color model of the data. - */ - GLenum _model; - - /*! - \brief The data. - */ - const unsigned char* _data; - - /*! - \brief The internal format of the texture. - */ - GLenum _internal; - - /*! - \brief Flags if the texture is valid. - */ - bool _valid; - - /*! - \brief Flags if the texture will be interpolated. - */ - bool _interpolation; - - /*! - \brief The color which is used for intensity images. - */ - float _red, _green, _blue, _alpha; - - iil4mitkWidget* parent; -}; - -#endif diff --git a/Utilities/IIL4MITK/widget.h b/Utilities/IIL4MITK/widget.h deleted file mode 100644 index 54eb3b62e3..0000000000 --- a/Utilities/IIL4MITK/widget.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef IIL_WIDGET_WRAPPER -#define IIL_WIDGET_WRAPPER - -#include -#include -// #include - -#ifdef WIN32 - #include -#endif - -#ifndef __APPLE__ - #include "GL/gl.h" -#else - #include "OpenGL/gl.h" -#endif - - -class iil4mitkItem; - -typedef vtkRenderWindow iil4mitkWidget; - -#endif