From: Leonardo Flórez-Valencia Date: Mon, 12 Sep 2016 20:01:31 +0000 (-0500) Subject: Medialness filters updated. X-Git-Tag: v0.1~116 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f77263a8b9bbfb4d3f2f179b1da79cf5c55faed3;p=cpPlugins.git Medialness filters updated. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c7e166..85fe564 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) ## ======================== ## == Project definition == diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index da6aca4..cc05c08 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -1,6 +1,7 @@ SUBDIRS( bash examples + PipelineEditor ) ## eof - $RCSfile$ diff --git a/appli/PipelineEditor/CMakeLists.txt b/appli/PipelineEditor/CMakeLists.txt new file mode 100644 index 0000000..d36b67c --- /dev/null +++ b/appli/PipelineEditor/CMakeLists.txt @@ -0,0 +1,8 @@ +IF(Qt4_FOUND) + AppFromDir(_app_name ${CMAKE_CURRENT_SOURCE_DIR}) + IF(_app_name) + TARGET_LINK_LIBRARIES(${_app_name} ${cpBaseQtApplication_LIB}) + ENDIF(_app_name) +ENDIF(Qt4_FOUND) + +## eof - $RCSfile$ diff --git a/appli/PipelineEditor/PipelineEditorMainWindow.cxx b/appli/PipelineEditor/PipelineEditorMainWindow.cxx new file mode 100644 index 0000000..ddabd0e --- /dev/null +++ b/appli/PipelineEditor/PipelineEditorMainWindow.cxx @@ -0,0 +1,36 @@ +#include +#include + +// ------------------------------------------------------------------------- +PipelineEditorMainWindow:: +PipelineEditorMainWindow( + int argc, char* argv[], QApplication* app, QWidget* parent + ) + : Superclass( argc, argv, app, parent ), + m_UI( new Ui::PipelineEditorMainWindow ) +{ + // Basic UI configuration + this->m_UI->setupUi( this ); + this->_configure( + this->m_UI->Navigator, + this->m_UI->MPR, + this->m_UI->Canvas->editor( ) + ); + + // Slots <-> signals + cpBaseQtApplication_ConnectAction( ActionOpen, _loadWorkspace ); + cpBaseQtApplication_ConnectAction( ActionSave, _saveWorkspace ); + cpBaseQtApplication_ConnectAction( ActionShowPlugins, _showPlugins ); + cpBaseQtApplication_ConnectAction( ActionAddEnvironmentPath, _addEnvironmentPaths ); + cpBaseQtApplication_ConnectAction( ActionLoadPluginFile, _loadPlugins ); + cpBaseQtApplication_ConnectAction( ActionLoadPluginDirectory, _loadPluginsFromPath ); +} + +// ------------------------------------------------------------------------- +PipelineEditorMainWindow:: +~PipelineEditorMainWindow( ) +{ + delete this->m_UI; +} + +// eof - $RCSfile$ diff --git a/appli/PipelineEditor/PipelineEditorMainWindow.h b/appli/PipelineEditor/PipelineEditorMainWindow.h new file mode 100644 index 0000000..b4018c1 --- /dev/null +++ b/appli/PipelineEditor/PipelineEditorMainWindow.h @@ -0,0 +1,36 @@ +#ifndef __PIPELINEEDITORMAINWINDOW__H__ +#define __PIPELINEEDITORMAINWINDOW__H__ + +#include + +// ------------------------------------------------------------------------- +namespace Ui +{ + class PipelineEditorMainWindow; +} + +/** + */ +class PipelineEditorMainWindow + : public cpBaseQtApplication::MainWindow +{ + Q_OBJECT; +public: + typedef PipelineEditorMainWindow Self; + typedef cpBaseQtApplication::MainWindow Superclass; + +public: + explicit PipelineEditorMainWindow( + int argc, char* argv[], + QApplication* app, + QWidget* parent = NULL + ); + virtual ~PipelineEditorMainWindow( ); + +private: + Ui::PipelineEditorMainWindow* m_UI; +}; + +#endif // __PIPELINEEDITORMAINWINDOW__H__ + +// eof - $RCSfile$ diff --git a/appli/PipelineEditor/PipelineEditorMainWindow.ui b/appli/PipelineEditor/PipelineEditorMainWindow.ui new file mode 100644 index 0000000..8e257be --- /dev/null +++ b/appli/PipelineEditor/PipelineEditorMainWindow.ui @@ -0,0 +1,189 @@ + + + PipelineEditorMainWindow + + + + 0 + 0 + 640 + 480 + + + + MainWindow + + + + + + + Qt::Vertical + + + + + 60 + 60 + + + + + + Qt::Horizontal + + + + + 60 + 60 + + + + + + + 60 + 60 + + + + + + + + + + + + 0 + 0 + 640 + 22 + + + + + &File + + + + + + + + + + &Plugins + + + + + + + + + + + + + + &Open + + + Ctrl+O + + + + + &Save + + + Ctrl+S + + + + + E&xit + + + + + &Close + + + Ctrl+Shift+C + + + + + Load &file + + + Ctrl+Shift+P + + + + + Load &directory + + + Ctrl+Shift+D + + + + + &Show + + + Ctrl+Shift+S + + + + + &Manage enviroment paths + + + Ctrl+F9 + + + + + + cpExtensions::QT::SimpleMPRWidget + QWidget +
cpExtensions/QT/SimpleMPRWidget.h
+ 1 +
+ + cpBaseQtApplication::Canvas + QWidget +
cpBaseQtApplication/Canvas.h
+ 1 +
+ + cpBaseQtApplication::PluginsNavigator + QTreeWidget +
cpBaseQtApplication/PluginsNavigator.h
+
+
+ + + + ActionExit + triggered() + PipelineEditorMainWindow + close() + + + -1 + -1 + + + 212 + 190 + + + + +
diff --git a/appli/PipelineEditor/main.cxx b/appli/PipelineEditor/main.cxx new file mode 100644 index 0000000..a675420 --- /dev/null +++ b/appli/PipelineEditor/main.cxx @@ -0,0 +1,7 @@ +#include +#include + +cpBaseQtApplication_Main( PipelineEditorMainWindow ); +cpBaseQtApplication_MainComplement; + +// eof - $RCSfile$ diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index d1ecd6a..5465875 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -2,38 +2,10 @@ ## == Find cpPlugins-cmake tools == ## ================================ -SET( - _cmake_tools - DetectOS - Functions - Restrictions - KitwareTools - ) IF("@Qt4_FOUND@" STREQUAL "TRUE") SET(USE_QT4 ON) - SET( - _cmake_tools - ${_cmake_tools} - Qt4Tools - ) ENDIF("@Qt4_FOUND@" STREQUAL "TRUE") -FOREACH(_t ${_cmake_tools}) - SET(_tool "cpPlugins_${_t}.cmake") - FIND_FILE( - ${_tool} - NAMES ${_tool} - HINTS /usr/share/cmake /usr/local/share/cmake - PATHS @CMAKE_INSTALL_PREFIX@/share/cmake @PROJECT_SOURCE_DIR@/cmake - DOC "Where is \"${_tool}\"?" - ) - IF(NOT ${_tool}) - MESSAGE(FATAL_ERROR "Where is \"${_tool}\"?") - ENDIF(NOT ${_tool}) - MARK_AS_ADVANCED(FORCE ${_tool}) - INCLUDE(${${_tool}}) -ENDFOREACH(_t) - ## ==================== ## == Find libraries == ## ==================== diff --git a/dependencies/cpPlugins_Install_CMAKE.sh b/dependencies/cpPlugins_Install_CMAKE.sh new file mode 100755 index 0000000..191927c --- /dev/null +++ b/dependencies/cpPlugins_Install_CMAKE.sh @@ -0,0 +1,198 @@ +#!/bin/bash + +## ------------------------------------------------------------------------- +function abspath() +{ + pushd . > /dev/null + if [ -d "$1" ]; then + cd "$1" + dirs -l +0 + else + cd "`dirname \"$1\"`" + cur_dir=`dirs -l +0` + if [ "$cur_dir" == "/" ]; then + echo "$cur_dir`basename \"$1\"`" + else + echo "$cur_dir/`basename \"$1\"`" + fi + fi + popd > /dev/null +} + +## ------------------------------------------------------------------------- +function get_file_extension +{ + valid_extensions=("zip" "tar" "tar.gz" "tar.bz2") + actual_file=`abspath $1` + actual_ext="" + for ext in ${valid_extensions[@]}; do + test_str=`dirname $actual_file`/`basename $actual_file $ext` + if [ $test_str != $actual_file ]; then + actual_ext=$ext + fi + done + echo "$actual_ext" +} + +## ------------------------------------------------------------------------- +function print_help() +{ + echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-p=instalation_prefix] [-q=qmake_executable]" +} + +## ------------------------------------------------------------------------- +## Analyze command-line arguments +if [ $# -eq 0 ]; then + print_help + exit 1 +fi +prefix="${HOME}/local" +for i in "$@"; do + case $i in + -f=*|--file=*) + source_file="${i#*=}" + shift + ;; + -c=*|--source_dir=*) + source_dir="${i#*=}" + shift + ;; + -b=*|--build_dir=*) + build_dir="${i#*=}" + shift + ;; + -p=*|--prefix=*) + prefix="${i#*=}" + shift + ;; + -q=*|--qmake=*) + qmake_exec="${i#*=}" + shift + ;; + *) + ;; + esac +done + +## Check command line arguments +if [ "x$source_dir" == "x" ]; then + if [ "x$source_file" != "x" ]; then + base_path=`abspath $source_file` + base_ext=`get_file_extension $base_path` + base_dir=`dirname $base_path` + if [ "x$base_ext" != "x" ]; then + source_dir="$base_dir"/`basename $base_path .$base_ext` + else + echo "Error: Input compressed file extension not recognized." + exit 1 + fi + else + print_help + exit 1 + fi +fi +if [ "x$build_dir" == "x" ]; then + if [ "x$source_dir" != "x" ]; then + base_dir=$source_dir + if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then + base_dir=`echo $source_dir | rev | cut -c 2- | rev` + fi + build_dir="$base_dir-build" + else + print_help + exit 1 + fi +fi + +# Locate qmake executable +if [ "x$qmake_exec" == "x" ]; then + qmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin") + for loc in ${qmake_locations[@]}; do + qmake_file="$loc/qmake" + if [ -x $qmake_file ]; then + version=`$qmake_file --version | grep Using\ Qt\ version | cut -d ' ' -f 4` + if [ "${version:0:3}" == "4.8" ]; then + qmake_exec=$qmake_file + fi + fi + done +fi +qmake_exec=`abspath $qmake_exec` +if [ -x $qmake_exec ]; then + qt_options="--qt-gui --qt-qmake=$qmake_exec" +else + qt_options="--no-qt-gui" +fi + +## Other configuration variables +platform=`uname` +number_of_cores=`grep -c ^processor /proc/cpuinfo` +number_of_threads=`expr $number_of_cores / 2` +if [ "x$source_file" != "x" ]; then + source_file=`abspath $source_file` +fi +source_dir=`abspath $source_dir` +build_dir=`abspath $build_dir` + +echo "=====================================================================" +echo "==> Source file : $source_file" +echo "==> Source dir : $source_dir" +echo "==> Build dir : $build_dir" +echo "==> Prefix : $prefix" +echo "==> qmake : $qmake_exec" +echo "==> Qt options : $qt_options" +echo "==> Platform : $platform" +echo "==> Number of cores : $number_of_cores" +echo "==> Number of threads : $number_of_threads" +echo "=====================================================================" +read -n1 -r -p "Continue? [Y/N]... " key +echo +if [ "$key" != 'Y' -a "$key" != 'y' ] ; then + exit 1 +fi + +## Create paths +if [ "x$source_file" != "x" ]; then + echo -n "==> Cleaning directories... " + rm -rf $source_dir + rm -rf $build_dir + echo "done." + echo -n "==> Creating directories... " + mkdir -p $source_dir + mkdir -p $build_dir + echo "done." +fi + +## Extract source code +if [ "x$source_file" != "x" ]; then + echo -n "==> Extracting sources... " + base_path=`abspath $source_file` + base_ext=`get_file_extension $base_path` + if [ "$base_ext" == "zip" ]; then + echo unzip $base_path + elif [ "$base_ext" == "tar" ]; then + tar xf $base_path -C $source_dir --strip-components=1 + elif [ "$base_ext" == "tar.gz" ]; then + tar xzf $base_path -C $source_dir --strip-components=1 + elif [ "$base_ext" == "tar.bz2" ]; then + tar xjf $base_path -C $source_dir --strip-components=1 + fi + echo "done." +fi + +echo "==> Configuring sources... " +cd $build_dir +$source_dir/bootstrap --prefix=$prefix $qt_options +echo "==> Configuring sources... done." + +echo "==> Compiling sources..." +cd $build_dir +make -j$number_of_threads +echo "==> Compiling sources... done." + +echo "==> Installing package..." +cd $build_dir +make -j install +echo "==> Installing package... done." + +## eof - $RCSfile$ diff --git a/dependencies/cpPlugins_Install_ITK.sh b/dependencies/cpPlugins_Install_ITK.sh new file mode 100755 index 0000000..d4b90c5 --- /dev/null +++ b/dependencies/cpPlugins_Install_ITK.sh @@ -0,0 +1,216 @@ +#!/bin/bash + +## ------------------------------------------------------------------------- +function abspath() +{ + pushd . > /dev/null + if [ -d "$1" ]; then + cd "$1" + dirs -l +0 + else + cd "`dirname \"$1\"`" + cur_dir=`dirs -l +0` + if [ "$cur_dir" == "/" ]; then + echo "$cur_dir`basename \"$1\"`" + else + echo "$cur_dir/`basename \"$1\"`" + fi + fi + popd > /dev/null +} + +## ------------------------------------------------------------------------- +function get_file_extension +{ + valid_extensions=("zip" "tar" "tar.gz" "tar.bz2") + actual_file=`abspath $1` + actual_ext="" + for ext in ${valid_extensions[@]}; do + test_str=`dirname $actual_file`/`basename $actual_file $ext` + if [ $test_str != $actual_file ]; then + actual_ext=$ext + fi + done + echo "$actual_ext" +} + +## ------------------------------------------------------------------------- +function print_help() +{ + echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-p=instalation_prefix] [-m=cmake_executable] [-t=build_type[MinSizeRel/Debug/Release]]" +} + +## ------------------------------------------------------------------------- +## Analyze command-line arguments +if [ $# -eq 0 ]; then + print_help + exit 1 +fi +prefix="${HOME}/local" +build_type="MinSizeRel" +for i in "$@"; do + case $i in + -f=*|--file=*) + source_file="${i#*=}" + shift + ;; + -c=*|--source_dir=*) + source_dir="${i#*=}" + shift + ;; + -b=*|--build_dir=*) + build_dir="${i#*=}" + shift + ;; + -t=*|--build_type=*) + build_type="${i#*=}" + shift + ;; + -p=*|--prefix=*) + prefix="${i#*=}" + shift + ;; + -m=*|--cmake=*) + cmake_exec="${i#*=}" + shift + ;; + *) + ;; + esac +done + +## Check command line arguments +if [ "x$source_dir" == "x" ]; then + if [ "x$source_file" != "x" ]; then + base_path=`abspath $source_file` + base_ext=`get_file_extension $base_path` + base_dir=`dirname $base_path` + if [ "x$base_ext" != "x" ]; then + source_dir="$base_dir"/`basename $base_path .$base_ext` + else + echo "Error: Input compressed file extension not recognized." + exit 1 + fi + else + print_help + exit 1 + fi +fi +if [ "x$build_dir" == "x" ]; then + if [ "x$source_dir" != "x" ]; then + base_dir=$source_dir + if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then + base_dir=`echo $source_dir | rev | cut -c 2- | rev` + fi + build_dir="$base_dir-build" + else + print_help + exit 1 + fi +fi + +## Locate cmake executable +if [ "x$cmake_exec" == "x" ]; then + cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin") + cmake_ver="" + for loc in ${cmake_locations[@]}; do + cmake_file="$loc/cmake" + if [ -x $cmake_file ]; then + str=`$cmake_file --version | grep version` + version=${str:14} + if [ "$cmake_ver" \< "$version" ]; then + cmake_ver=$version + cmake_exec=$cmake_file + fi + fi + done +fi +if [ ! -x $cmake_exec ]; then + echo "ERROR: no valid cmake found." + exit 1 +fi +cmake_exec=`abspath $cmake_exec` + +## Other configuration variables +platform=`uname` +number_of_cores=`grep -c ^processor /proc/cpuinfo` +number_of_threads=`expr $number_of_cores / 2` +if [ "x$source_file" != "x" ]; then + source_file=`abspath $source_file` +fi +source_dir=`abspath $source_dir` +build_dir=`abspath $build_dir` + +echo "=====================================================================" +echo "==> Source file : $source_file" +echo "==> Source dir : $source_dir" +echo "==> Build dir : $build_dir" +echo "==> Build type : $build_type" +echo "==> Prefix : $prefix" +echo "==> cmake : $cmake_exec" +echo "==> Platform : $platform" +echo "==> Number of cores : $number_of_cores" +echo "==> Number of threads : $number_of_threads" +echo "=====================================================================" +read -n1 -r -p "Continue? [Y/N]... " key +echo +if [ "$key" != 'Y' -a "$key" != 'y' ] ; then + exit 1 +fi + +## Create paths +if [ "x$source_file" != "x" ]; then + echo -n "==> Cleaning directories... " + rm -rf $source_dir + rm -rf $build_dir + echo "done." + echo -n "==> Creating directories... " + mkdir -p $source_dir + mkdir -p $build_dir + echo "done." +fi + +## Extract source code +if [ "x$source_file" != "x" ]; then + echo -n "==> Extracting sources... " + base_path=`abspath $source_file` + base_ext=`get_file_extension $base_path` + if [ "$base_ext" == "zip" ]; then + echo unzip $base_path + elif [ "$base_ext" == "tar" ]; then + tar xf $base_path -C $source_dir --strip-components=1 + elif [ "$base_ext" == "tar.gz" ]; then + tar xzf $base_path -C $source_dir --strip-components=1 + elif [ "$base_ext" == "tar.bz2" ]; then + tar xjf $base_path -C $source_dir --strip-components=1 + fi + echo "done." +fi + +echo "==> Configuring sources... " +cd $build_dir +$cmake_exec \ + -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \ + -DBUILD_DOCUMENTATION:BOOL=OFF \ + -DBUILD_EXAMPLES:BOOL=OFF \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DBUILD_TESTING:BOOL=OFF \ + -DCMAKE_BUILD_TYPE:STRING=$build_type \ + -DModule_ITKReview:BOOL=ON \ + -DModule_ITKVtkGlue:BOOL=OFF \ + -DModule_ParabolicMorphology:BOOL=ON \ + -DCMAKE_INSTALL_PREFIX:PATH=$prefix \ + ${source_dir} +echo "==> Configuring sources... done." + +echo "==> Compiling sources..." +cd $build_dir +make -j$number_of_threads +echo "==> Compiling sources... done." + +echo "==> Installing package..." +cd $build_dir +make -j install +echo "==> Installing package... done." + +## eof - $RCSfile$ diff --git a/dependencies/cpPlugins_Install_VTK.sh b/dependencies/cpPlugins_Install_VTK.sh new file mode 100755 index 0000000..9c5776a --- /dev/null +++ b/dependencies/cpPlugins_Install_VTK.sh @@ -0,0 +1,256 @@ +#!/bin/bash + +## ------------------------------------------------------------------------- +function abspath() +{ + pushd . > /dev/null + if [ -d "$1" ]; then + cd "$1" + dirs -l +0 + else + cd "`dirname \"$1\"`" + cur_dir=`dirs -l +0` + if [ "$cur_dir" == "/" ]; then + echo "$cur_dir`basename \"$1\"`" + else + echo "$cur_dir/`basename \"$1\"`" + fi + fi + popd > /dev/null +} + +## ------------------------------------------------------------------------- +function get_file_extension +{ + valid_extensions=("zip" "tar" "tar.gz" "tar.bz2") + actual_file=`abspath $1` + actual_ext="" + for ext in ${valid_extensions[@]}; do + test_str=`dirname $actual_file`/`basename $actual_file $ext` + if [ $test_str != $actual_file ]; then + actual_ext=$ext + fi + done + echo "$actual_ext" +} + +## ------------------------------------------------------------------------- +function print_help() +{ + echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-p=instalation_prefix] [-q=qmake_executable] [-m=cmake_executable] [-t=build_type[MinSizeRel/Debug/Release]]" +} + +## ------------------------------------------------------------------------- +## Analyze command-line arguments +if [ $# -eq 0 ]; then + print_help + exit 1 +fi +prefix="${HOME}/local" +build_type="MinSizeRel" +for i in "$@"; do + case $i in + -f=*|--file=*) + source_file="${i#*=}" + shift + ;; + -c=*|--source_dir=*) + source_dir="${i#*=}" + shift + ;; + -b=*|--build_dir=*) + build_dir="${i#*=}" + shift + ;; + -t=*|--build_type=*) + build_type="${i#*=}" + shift + ;; + -p=*|--prefix=*) + prefix="${i#*=}" + shift + ;; + -m=*|--cmake=*) + cmake_exec="${i#*=}" + shift + ;; + -q=*|--qmake=*) + qmake_exec="${i#*=}" + shift + ;; + *) + ;; + esac +done + +## Check command line arguments +if [ "x$source_dir" == "x" ]; then + if [ "x$source_file" != "x" ]; then + base_path=`abspath $source_file` + base_ext=`get_file_extension $base_path` + base_dir=`dirname $base_path` + if [ "x$base_ext" != "x" ]; then + source_dir="$base_dir"/`basename $base_path .$base_ext` + else + echo "Error: Input compressed file extension not recognized." + exit 1 + fi + else + print_help + exit 1 + fi +fi +if [ "x$build_dir" == "x" ]; then + if [ "x$source_dir" != "x" ]; then + base_dir=$source_dir + if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then + base_dir=`echo $source_dir | rev | cut -c 2- | rev` + fi + build_dir="$base_dir-build" + else + print_help + exit 1 + fi +fi + +## Locate cmake executable +if [ "x$cmake_exec" == "x" ]; then + cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin") + cmake_ver="" + for loc in ${cmake_locations[@]}; do + cmake_file="$loc/cmake" + if [ -x $cmake_file ]; then + str=`$cmake_file --version | grep version` + version=${str:14} + if [ "$cmake_ver" \< "$version" ]; then + cmake_ver=$version + cmake_exec=$cmake_file + fi + fi + done +fi +if [ ! -x $cmake_exec ]; then + echo "ERROR: no valid cmake found." + exit 1 +fi +cmake_exec=`abspath $cmake_exec` + +# Locate qmake executable +if [ "x$qmake_exec" == "x" ]; then + qmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin") + for loc in ${qmake_locations[@]}; do + qmake_file="$loc/qmake" + if [ -x $qmake_file ]; then + version=`$qmake_file --version | grep Using\ Qt\ version | cut -d ' ' -f 4` + if [ "${version:0:3}" == "4.8" ]; then + qmake_exec=$qmake_file + fi + fi + done +fi +qmake_exec=`abspath $qmake_exec` +if [ -x $qmake_exec ]; then + use_qt="1" +else + use_qt="0" +fi + +## Other configuration variables +platform=`uname` +number_of_cores=`grep -c ^processor /proc/cpuinfo` +number_of_threads=`expr $number_of_cores / 2` +if [ "x$source_file" != "x" ]; then + source_file=`abspath $source_file` +fi +source_dir=`abspath $source_dir` +build_dir=`abspath $build_dir` + +echo "=====================================================================" +echo "==> Source file : $source_file" +echo "==> Source dir : $source_dir" +echo "==> Build dir : $build_dir" +echo "==> Build type : $build_type" +echo "==> Prefix : $prefix" +echo "==> cmake : $cmake_exec" +echo "==> qmake : $qmake_exec" +echo "==> Use Qt : $use_qt" +echo "==> Platform : $platform" +echo "==> Number of cores : $number_of_cores" +echo "==> Number of threads : $number_of_threads" +echo "=====================================================================" +read -n1 -r -p "Continue? [Y/N]... " key +echo +if [ "$key" != 'Y' -a "$key" != 'y' ] ; then + exit 1 +fi + +## Create paths +if [ "x$source_file" != "x" ]; then + echo -n "==> Cleaning directories... " + rm -rf $source_dir + rm -rf $build_dir + echo "done." + echo -n "==> Creating directories... " + mkdir -p $source_dir + mkdir -p $build_dir + echo "done." +fi + +## Extract source code +if [ "x$source_file" != "x" ]; then + echo -n "==> Extracting sources... " + base_path=`abspath $source_file` + base_ext=`get_file_extension $base_path` + if [ "$base_ext" == "zip" ]; then + echo unzip $base_path + elif [ "$base_ext" == "tar" ]; then + tar xf $base_path -C $source_dir --strip-components=1 + elif [ "$base_ext" == "tar.gz" ]; then + tar xzf $base_path -C $source_dir --strip-components=1 + elif [ "$base_ext" == "tar.bz2" ]; then + tar xjf $base_path -C $source_dir --strip-components=1 + fi + echo "done." +fi + +echo "==> Configuring sources... " +cd $build_dir +if [ "$use_qt" == "1" ]; then + $cmake_exec \ + -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \ + -DBUILD_DOCUMENTATION:BOOL=OFF \ + -DBUILD_EXAMPLES:BOOL=OFF \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DBUILD_TESTING:BOOL=OFF \ + -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exec \ + -DCMAKE_BUILD_TYPE:STRING=$build_type \ + -DModule_vtkGUISupportQt:BOOL=ON \ + -DModule_vtkGUISupportQtOpenGL:BOOL=ON \ + -DModule_vtkGUISupportQtSQL:BOOL=OFF \ + -DModule_vtkGUISupportQtWebkit:BOOL=OFF \ + -DCMAKE_INSTALL_PREFIX:PATH=$prefix \ + ${source_dir} +else + $cmake_exec \ + -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \ + -DBUILD_DOCUMENTATION:BOOL=OFF \ + -DBUILD_EXAMPLES:BOOL=OFF \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DBUILD_TESTING:BOOL=OFF \ + -DCMAKE_BUILD_TYPE:STRING=$build_type \ + -DCMAKE_INSTALL_PREFIX:PATH=$prefix \ + ${source_dir} +fi +echo "==> Configuring sources... done." + +echo "==> Compiling sources..." +cd $build_dir +make -j$number_of_threads +echo "==> Compiling sources... done." + +echo "==> Installing package..." +cd $build_dir +make -j install +echo "==> Installing package... done." + +## eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/FluxMedialness.h b/lib/cpExtensions/Algorithms/FluxMedialness.h index dd5a3f2..c25f5f4 100644 --- a/lib/cpExtensions/Algorithms/FluxMedialness.h +++ b/lib/cpExtensions/Algorithms/FluxMedialness.h @@ -9,15 +9,15 @@ namespace cpExtensions { /** */ - template< class _TGradient > + template< class _TGradient, class _TMask = itk::Image< unsigned char, _TGradient::ImageDimension > > class FluxMedialness - : public GradientImageFunctionBase< _TGradient > + : public GradientImageFunctionBase< _TGradient, _TMask > { public: - typedef FluxMedialness Self; - typedef GradientImageFunctionBase< _TGradient > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef FluxMedialness Self; + typedef GradientImageFunctionBase< _TGradient, _TMask > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; itkStaticConstMacro( Dimension, unsigned int, Superclass::Dimension ); diff --git a/lib/cpExtensions/Algorithms/FluxMedialness.hxx b/lib/cpExtensions/Algorithms/FluxMedialness.hxx index f4d8b9c..4412292 100644 --- a/lib/cpExtensions/Algorithms/FluxMedialness.hxx +++ b/lib/cpExtensions/Algorithms/FluxMedialness.hxx @@ -6,8 +6,8 @@ #include // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::FluxMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::FluxMedialness< _TGradient, _TMask >:: FluxMedialness( ) : Superclass( ), m_MinRadius( double( 0 ) ), @@ -18,16 +18,16 @@ FluxMedialness( ) } // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::FluxMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::FluxMedialness< _TGradient, _TMask >:: ~FluxMedialness( ) { } // ------------------------------------------------------------------------- -template< class _TGradient > -typename cpExtensions::Algorithms::FluxMedialness< _TGradient >:: -TOutput cpExtensions::Algorithms::FluxMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +typename cpExtensions::Algorithms::FluxMedialness< _TGradient, _TMask >:: +TOutput cpExtensions::Algorithms::FluxMedialness< _TGradient, _TMask >:: _Evaluate( const TIndex& i ) const { itk::Object::GlobalWarningDisplayOff( ); diff --git a/lib/cpExtensions/Algorithms/GradientImageFunctionBase.h b/lib/cpExtensions/Algorithms/GradientImageFunctionBase.h index bc6bd36..f6d3e5c 100644 --- a/lib/cpExtensions/Algorithms/GradientImageFunctionBase.h +++ b/lib/cpExtensions/Algorithms/GradientImageFunctionBase.h @@ -10,16 +10,19 @@ namespace cpExtensions /** * Base class to compute values based on image gradients (vector). */ - template< class _TGradient > + template< class _TGradient, class _TMask = itk::Image< unsigned char, _TGradient::ImageDimension > > class GradientImageFunctionBase : public itk::ImageFunction< _TGradient, typename _TGradient::PixelType::ValueType, typename _TGradient::PixelType::ValueType > { public: // Types from input arguments typedef _TGradient TGradient; + typedef _TMask TMask; typedef typename _TGradient::PixelType TVector; typedef typename TVector::ValueType TScalar; - itkStaticConstMacro( Dimension, unsigned int, _TGradient::ImageDimension ); + itkStaticConstMacro( + Dimension, unsigned int, _TGradient::ImageDimension + ); // Standard itk types typedef GradientImageFunctionBase Self; @@ -37,6 +40,9 @@ namespace cpExtensions public: itkTypeMacro( GradientImageFunctionBase, itkImageFunction ); + itkGetConstObjectMacro( Mask, TMask ); + itkSetConstObjectMacro( Mask, TMask ); + public: virtual void Prepare( ) const; virtual TOutput Evaluate( const TPoint& p ) const cpExtensions_OVERRIDE; @@ -53,6 +59,9 @@ namespace cpExtensions // Purposely not implemented. GradientImageFunctionBase( const Self& ); void operator=( const Self& ); + + protected: + typename _TMask::ConstPointer m_Mask; }; } // ecapseman diff --git a/lib/cpExtensions/Algorithms/GradientImageFunctionBase.hxx b/lib/cpExtensions/Algorithms/GradientImageFunctionBase.hxx index f4cb928..95681bd 100644 --- a/lib/cpExtensions/Algorithms/GradientImageFunctionBase.hxx +++ b/lib/cpExtensions/Algorithms/GradientImageFunctionBase.hxx @@ -2,16 +2,19 @@ #define __CPEXTENSIONS__ALGORITHMS__GRADIENTIMAGEFUNCTIONBASE__HXX__ // ------------------------------------------------------------------------- -template< class _TGradient > -void cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: +template< class _TGradient, class _TMask > +void +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: Prepare( ) const { } // ------------------------------------------------------------------------- -template< class _TGradient > -typename cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: -TOutput cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: +template< class _TGradient, class _TMask > +typename +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: +TOutput +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: Evaluate( const TPoint& p ) const { TIndex i; @@ -20,18 +23,28 @@ Evaluate( const TPoint& p ) const } // ------------------------------------------------------------------------- -template< class _TGradient > -typename cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: -TOutput cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: +template< class _TGradient, class _TMask > +typename +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: +TOutput +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: EvaluateAtIndex( const TIndex& i ) const { - return( this->_Evaluate( i ) ); + bool eval = true; + if( this->m_Mask.IsNotNull( ) ) + eval = ( ( unsigned long )( this->m_Mask->GetPixel( i ) ) > 0 ); + if( eval ) + return( this->_Evaluate( i ) ); + else + return( TOutput( 0 ) ); } // ------------------------------------------------------------------------- -template< class _TGradient > -typename cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: -TOutput cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: +template< class _TGradient, class _TMask > +typename +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: +TOutput +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: EvaluateAtContinuousIndex( const TContIndex& i ) const { TPoint p; @@ -40,16 +53,16 @@ EvaluateAtContinuousIndex( const TContIndex& i ) const } // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: GradientImageFunctionBase( ) : Superclass( ) { } // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::GradientImageFunctionBase< _TGradient, _TMask >:: ~GradientImageFunctionBase( ) { } diff --git a/lib/cpExtensions/Algorithms/GulsunTekMedialness.h b/lib/cpExtensions/Algorithms/GulsunTekMedialness.h index 979c41f..15add9e 100644 --- a/lib/cpExtensions/Algorithms/GulsunTekMedialness.h +++ b/lib/cpExtensions/Algorithms/GulsunTekMedialness.h @@ -9,15 +9,15 @@ namespace cpExtensions { /** */ - template< class _TGradient > + template< class _TGradient, class _TMask = itk::Image< unsigned char, _TGradient::ImageDimension > > class GulsunTekMedialness - : public GradientImageFunctionBase< _TGradient > + : public GradientImageFunctionBase< _TGradient, _TMask > { public: - typedef GulsunTekMedialness Self; - typedef GradientImageFunctionBase< _TGradient > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef GulsunTekMedialness Self; + typedef GradientImageFunctionBase< _TGradient, _TMask > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; itkStaticConstMacro( Dimension, unsigned int, Superclass::Dimension ); diff --git a/lib/cpExtensions/Algorithms/GulsunTekMedialness.hxx b/lib/cpExtensions/Algorithms/GulsunTekMedialness.hxx index 941a37c..fc59929 100644 --- a/lib/cpExtensions/Algorithms/GulsunTekMedialness.hxx +++ b/lib/cpExtensions/Algorithms/GulsunTekMedialness.hxx @@ -6,8 +6,8 @@ #include // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::GulsunTekMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::GulsunTekMedialness< _TGradient, _TMask >:: GulsunTekMedialness( ) : Superclass( ), m_MinRadius( double( 0 ) ), @@ -18,16 +18,16 @@ GulsunTekMedialness( ) } // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::GulsunTekMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::GulsunTekMedialness< _TGradient, _TMask >:: ~GulsunTekMedialness( ) { } // ------------------------------------------------------------------------- -template< class _TGradient > -typename cpExtensions::Algorithms::GulsunTekMedialness< _TGradient >:: -TOutput cpExtensions::Algorithms::GulsunTekMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +typename cpExtensions::Algorithms::GulsunTekMedialness< _TGradient, _TMask >:: +TOutput cpExtensions::Algorithms::GulsunTekMedialness< _TGradient, _TMask >:: _Evaluate( const TIndex& i ) const { itk::Object::GlobalWarningDisplayOff( ); diff --git a/lib/cpExtensions/Algorithms/MFluxMedialness.h b/lib/cpExtensions/Algorithms/MFluxMedialness.h index 6726276..97bc44f 100644 --- a/lib/cpExtensions/Algorithms/MFluxMedialness.h +++ b/lib/cpExtensions/Algorithms/MFluxMedialness.h @@ -9,15 +9,15 @@ namespace cpExtensions { /** */ - template< class _TGradient > + template< class _TGradient, class _TMask = itk::Image< unsigned char, _TGradient::ImageDimension > > class MFluxMedialness - : public GradientImageFunctionBase< _TGradient > + : public GradientImageFunctionBase< _TGradient, _TMask > { public: - typedef MFluxMedialness Self; - typedef GradientImageFunctionBase< _TGradient > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef MFluxMedialness Self; + typedef GradientImageFunctionBase< _TGradient, _TMask > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; itkStaticConstMacro( Dimension, unsigned int, Superclass::Dimension ); diff --git a/lib/cpExtensions/Algorithms/MFluxMedialness.hxx b/lib/cpExtensions/Algorithms/MFluxMedialness.hxx index 20e7f15..bc5db37 100644 --- a/lib/cpExtensions/Algorithms/MFluxMedialness.hxx +++ b/lib/cpExtensions/Algorithms/MFluxMedialness.hxx @@ -6,8 +6,8 @@ #include // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::MFluxMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::MFluxMedialness< _TGradient, _TMask >:: MFluxMedialness( ) : Superclass( ), m_MinRadius( double( 0 ) ), @@ -18,16 +18,16 @@ MFluxMedialness( ) } // ------------------------------------------------------------------------- -template< class _TGradient > -cpExtensions::Algorithms::MFluxMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +cpExtensions::Algorithms::MFluxMedialness< _TGradient, _TMask >:: ~MFluxMedialness( ) { } // ------------------------------------------------------------------------- -template< class _TGradient > -typename cpExtensions::Algorithms::MFluxMedialness< _TGradient >:: -TOutput cpExtensions::Algorithms::MFluxMedialness< _TGradient >:: +template< class _TGradient, class _TMask > +typename cpExtensions::Algorithms::MFluxMedialness< _TGradient, _TMask >:: +TOutput cpExtensions::Algorithms::MFluxMedialness< _TGradient, _TMask >:: _Evaluate( const TIndex& i ) const { itk::Object::GlobalWarningDisplayOff( ); diff --git a/lib/cpExtensions/QT/ImageWidget.cxx b/lib/cpExtensions/QT/ImageWidget.cxx index 7804fe7..0978844 100644 --- a/lib/cpExtensions/QT/ImageWidget.cxx +++ b/lib/cpExtensions/QT/ImageWidget.cxx @@ -247,12 +247,26 @@ GetImageInterpolation( ) const void cpExtensions::QT::ImageWidget:: SetScalarRange( double r[ 2 ] ) { + auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); + if( actor != NULL ) + { + actor->ConfigureWindowLevel( r[ 0 ], r[ 1 ] ); + this->Render( ); + + } // fi } // ------------------------------------------------------------------------- void cpExtensions::QT::ImageWidget:: SetWindowLevel( double wl[ 2 ] ) { + auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); + if( actor != NULL ) + { + actor->SetWindowLevel( wl[ 0 ], wl[ 1 ] ); + this->Render( ); + + } // fi } // ------------------------------------------------------------------------- @@ -272,6 +286,20 @@ SetImageOpacity( double o ) void cpExtensions::QT::ImageWidget:: SetImageInterpolation( unsigned char i ) { + auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); + if( actor != NULL ) + { + int int_type = 0; + switch( i ) + { + case 'L': int_type = VTK_LINEAR_INTERPOLATION; break; + case 'C': int_type = VTK_CUBIC_INTERPOLATION; break; + default : int_type = VTK_NEAREST_INTERPOLATION; break; + } // hctiws + actor->GetProperty( )->SetInterpolationType( int_type ); + this->Render( ); + + } // fi } #endif // cpExtensions_QT4 diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index 53fcb7f..80390b6 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -373,12 +373,20 @@ GetImageInterpolation( ) const void cpExtensions::QT::SimpleMPRWidget:: SetScalarRange( double r[ 2 ] ) { + this->m_XImage->SetScalarRange( r ); + this->m_YImage->SetScalarRange( r ); + this->m_ZImage->SetScalarRange( r ); + this->m_3DView->SetScalarRange( r ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: SetWindowLevel( double wl[ 2 ] ) { + this->m_XImage->SetWindowLevel( wl ); + this->m_YImage->SetWindowLevel( wl ); + this->m_ZImage->SetWindowLevel( wl ); + this->m_3DView->SetWindowLevel( wl ); } // ------------------------------------------------------------------------- @@ -395,6 +403,10 @@ SetImageOpacity( double o ) void cpExtensions::QT::SimpleMPRWidget:: SetImageInterpolation( unsigned char i ) { + this->m_XImage->SetImageInterpolation( i ); + this->m_YImage->SetImageInterpolation( i ); + this->m_ZImage->SetImageInterpolation( i ); + this->m_3DView->SetImageInterpolation( i ); } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx b/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx index ca1c3c1..c865f55 100644 --- a/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx +++ b/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx @@ -35,6 +35,10 @@ setData( SimpleMPRWidget* data ) this->m_Data->GetWindowLevel( win_lev ); // Intensity range + this->m_UI->MinimumBox->setMinimum( -1000000 ); + this->m_UI->MinimumBox->setMaximum( 1000000 ); + this->m_UI->MaximumBox->setMinimum( -1000000 ); + this->m_UI->MaximumBox->setMaximum( 1000000 ); this->m_UI->MinimumBox->setValue( range[ 0 ] ); this->m_UI->MaximumBox->setValue( range[ 1 ] ); @@ -77,13 +81,7 @@ setData( SimpleMPRWidget* data ) default : this->m_UI->InterpolatorBox->setCurrentIndex( 0 ); break; } // hctiws - /* TODO - this->connect( - this->m_UI->Top, SIGNAL( splitterMoved( int, int ) ), - this, SLOT( _SyncBottom( int, int ) ) - ); - */ - + // Slots <-> signals this->connect( this->m_UI->MaximumBox, SIGNAL( valueChanged( int ) ), this, SLOT( _maximumValue( int ) ) @@ -124,24 +122,88 @@ setData( SimpleMPRWidget* data ) void cpExtensions::QT::WindowLevelImageConfiguration:: _maximumValue( int v ) { + double range[ 2 ]; + range[ 0 ] = double( this->m_UI->MinimumBox->value( ) ); + range[ 1 ] = double( v ); + this->m_Data->SetScalarRange( range ); } // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: _minimumValue( int v ) { + double range[ 2 ]; + range[ 0 ] = double( v ); + range[ 1 ] = double( this->m_UI->MaximumBox->value( ) ); + this->m_Data->SetScalarRange( range ); } // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: _levelValue( int v ) { + double r[ 2 ]; + double l, s; + + this->m_Data->GetScalarRange( r ); + if( this->sender( ) == this->m_UI->LevelSlider ) + { + s = double( v ) / double( this->m_UI->LevelSlider->maximum( ) ); + l = ( ( r[ 1 ] - r[ 0 ] ) * s ) + r[ 0 ]; + } + else + { + l = double( v ); + s = ( l - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] ); + + } // fi + s *= this->m_UI->LevelSlider->maximum( ); + + bool b = this->m_UI->LevelSlider->blockSignals( true ); + this->m_UI->LevelSlider->setValue( s ); + this->m_UI->LevelSlider->blockSignals( b ); + b = this->m_UI->LevelBox->blockSignals( true ); + this->m_UI->LevelBox->setValue( l ); + this->m_UI->LevelBox->blockSignals( b ); + + double wl[ 2 ]; + this->m_Data->GetWindowLevel( wl ); + wl[ 1 ] = l; + this->m_Data->SetWindowLevel( wl ); } // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: _windowValue( int v ) { + double r[ 2 ]; + double w, s; + + this->m_Data->GetScalarRange( r ); + if( this->sender( ) == this->m_UI->WindowSlider ) + { + s = double( v ) / double( this->m_UI->WindowSlider->maximum( ) ); + w = ( ( r[ 1 ] - r[ 0 ] ) * s ) + r[ 0 ]; + } + else + { + w = double( v ); + s = ( w - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] ); + + } // fi + s *= this->m_UI->WindowSlider->maximum( ); + + bool b = this->m_UI->WindowSlider->blockSignals( true ); + this->m_UI->WindowSlider->setValue( s ); + this->m_UI->WindowSlider->blockSignals( b ); + b = this->m_UI->WindowBox->blockSignals( true ); + this->m_UI->WindowBox->setValue( w ); + this->m_UI->WindowBox->blockSignals( b ); + + double wl[ 2 ]; + this->m_Data->GetWindowLevel( wl ); + wl[ 0 ] = w; + this->m_Data->SetWindowLevel( wl ); } // ------------------------------------------------------------------------- @@ -164,6 +226,12 @@ _opacityValue( int v ) void cpExtensions::QT::WindowLevelImageConfiguration:: _interpolatorValue( int v ) { + switch( v ) + { + case 1 : this->m_Data->SetImageInterpolation( 'L' ); break; + case 2 : this->m_Data->SetImageInterpolation( 'C' ); break; + default : this->m_Data->SetImageInterpolation( 'N' ); break; + } // hctiws } #endif // cpExtensions_QT4 diff --git a/lib/cpExtensions/QT/WindowLevelImageConfiguration.h b/lib/cpExtensions/QT/WindowLevelImageConfiguration.h index e6910c0..665e741 100644 --- a/lib/cpExtensions/QT/WindowLevelImageConfiguration.h +++ b/lib/cpExtensions/QT/WindowLevelImageConfiguration.h @@ -29,7 +29,9 @@ namespace cpExtensions typedef QWidget Superclass; public: - explicit WindowLevelImageConfiguration( QWidget* parent = NULL, Qt::WindowFlags f = 0 ); + explicit WindowLevelImageConfiguration( + QWidget* parent = NULL, Qt::WindowFlags f = 0 + ); virtual ~WindowLevelImageConfiguration( ); void setData( SimpleMPRWidget* data ); diff --git a/lib/cpExtensions/QT/WindowLevelImageConfiguration.ui b/lib/cpExtensions/QT/WindowLevelImageConfiguration.ui index a066f2e..65d066e 100644 --- a/lib/cpExtensions/QT/WindowLevelImageConfiguration.ui +++ b/lib/cpExtensions/QT/WindowLevelImageConfiguration.ui @@ -6,387 +6,210 @@ 0 0 - 342 - 148 + 313 + 322 + + + 313 + 322 + + Form - - - - 2 - 7 - 50 - 14 - - - - - 50 - 14 - - - - - 50 - 14 - - - - Window: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 58 - 2 - 79 - 24 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - -100000 - - - 100000 - - - - - - 143 - 6 - 84 - 16 - - - - 1000 - - - Qt::Horizontal - - - - - - 2 - 39 - 35 - 14 - - - - - 35 - 14 - - - - - 35 - 14 - - - - Level: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 43 - 34 - 79 - 24 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - -100000 - - - 100000 - - - - - - 128 - 38 - 84 - 16 - - - - 1000 - - - Qt::Horizontal - - - - - - 3 - 82 - 61 - 14 - - - - - 61 - 14 - - - - - 61 - 14 - - - - Maximum: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 70 - 77 - 79 - 24 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - -100000 - - - 100000 - - - - - - 157 - 82 - 84 - 14 - - - - - 84 - 14 - - - - - 84 - 14 - - - - Interpolation: - - - - - - 247 - 77 - 81 - 24 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - - Nearest - - + - - Linear - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + Window: + + + + + + + + + + + + 1000 + + + 100 + + + Qt::Horizontal + + + + + + + + + + + + + Level: + + + + + + + + + + + + 1000 + + + 100 + + + Qt::Horizontal + + + + + + + + + + + Minimum: + + + + + + + + + + Maximum: + + + + + + + + + + - - Cubic - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 0 + + + + + + + + 16777215 + 16777215 + + + + Interpolation: + + + + + + + + Nearest + + + + + Linear + + + + + Cubic + + + + + + + + + + + + Opacity: + + + + + + + 100 + + + Qt::Horizontal + + + + + + + + + - - - - - 3 - 116 - 58 - 14 - - - - - 58 - 14 - - - - - 58 - 14 - - - - Minimum: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 67 - 111 - 79 - 24 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - -100000 - - - 100000 - - - - - - 154 - 112 - 49 - 14 - - - - - 49 - 14 - - - - - 49 - 14 - - - - Opacity: - - - - - - 209 - 111 - 84 - 16 - - - - - 0 - 16 - - - - - 16777215 - 16 - - - - 100 - - - 5 - - - Qt::Horizontal - - + + label + label_2 + label_3 + label_4 + label_5 + label_6 + InterpolatorBox + WindowSlider + LevelSlider + OpacitySlider + MinimumBox + MaximumBox + WindowSlider + frame + frame_2 diff --git a/plugins/ImageGradientFilters/FluxImageFilter.cxx b/plugins/ImageGradientFilters/FluxImageFilter.cxx index 9e91a15..806703d 100644 --- a/plugins/ImageGradientFilters/FluxImageFilter.cxx +++ b/plugins/ImageGradientFilters/FluxImageFilter.cxx @@ -15,6 +15,7 @@ FluxImageFilter( ) : Superclass( ) { this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Mask", false, false ); this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); this->m_Parameters.ConfigureAsReal( "MinRadius" ); diff --git a/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx b/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx index 76a9bff..b707d00 100644 --- a/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx +++ b/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx @@ -15,6 +15,7 @@ GulsunTekImageFilter( ) : Superclass( ) { this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Mask", false, false ); this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); this->m_Parameters.ConfigureAsReal( "MinRadius" ); @@ -47,9 +48,49 @@ _GenerateData( ) template< class _TImage > void cpPluginsImageGradientFilters::GulsunTekImageFilter:: _GD0( _TImage* image ) +{ + typedef itk::Image< char, _TImage::ImageDimension > _TChar; + typedef itk::Image< short, _TImage::ImageDimension > _TShort; + typedef itk::Image< int, _TImage::ImageDimension > _TInt; + typedef itk::Image< long, _TImage::ImageDimension > _TLong; + typedef itk::Image< float, _TImage::ImageDimension > _TFloat; + typedef itk::Image< double, _TImage::ImageDimension > _TDouble; + typedef itk::Image< unsigned char, _TImage::ImageDimension > _TUChar; + typedef itk::Image< unsigned short, _TImage::ImageDimension > _TUShort; + typedef itk::Image< unsigned int, _TImage::ImageDimension > _TUInt; + typedef itk::Image< unsigned long, _TImage::ImageDimension > _TULong; + + auto m = this->GetInput( "Mask" ); + auto ci = m->GetITK< _TChar >( ); + auto si = m->GetITK< _TShort >( ); + auto ii = m->GetITK< _TInt >( ); + auto li = m->GetITK< _TLong >( ); + auto fi = m->GetITK< _TFloat >( ); + auto di = m->GetITK< _TDouble >( ); + auto uci = m->GetITK< _TUChar >( ); + auto usi = m->GetITK< _TUShort >( ); + auto uii = m->GetITK< _TUInt >( ); + auto uli = m->GetITK< _TULong >( ); + if ( ci != NULL ) this->_GD1( image, ci ); + else if( si != NULL ) this->_GD1( image, si ); + else if( ii != NULL ) this->_GD1( image, ii ); + else if( li != NULL ) this->_GD1( image, li ); + else if( fi != NULL ) this->_GD1( image, fi ); + else if( di != NULL ) this->_GD1( image, di ); + else if( uci != NULL ) this->_GD1( image, uci ); + else if( usi != NULL ) this->_GD1( image, usi ); + else if( uii != NULL ) this->_GD1( image, uii ); + else if( uli != NULL ) this->_GD1( image, uli ); + else this->_GD1( image, ci ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TMask > +void cpPluginsImageGradientFilters::GulsunTekImageFilter:: +_GD1( _TImage* image, _TMask* mask ) { typedef typename _TImage::PixelType _TGradient; - typedef cpExtensions::Algorithms::GulsunTekMedialness< _TImage > _TFunction; + typedef cpExtensions::Algorithms::GulsunTekMedialness< _TImage, _TMask > _TFunction; typedef typename _TFunction::TOutput _TScalar; typedef itk::Image< _TScalar, _TImage::ImageDimension > _TOutputImage; typedef cpExtensions::Algorithms::ImageFunctionFilter< _TImage, _TOutputImage, _TFunction > _TFilter; @@ -67,6 +108,8 @@ _GD0( _TImage* image ) function->SetProfileSampling( this->m_Parameters.GetUint( "ProfileSampling" ) ); function->SetRadialSampling( this->m_Parameters.GetUint( "RadialSampling" ) ); filter->SetInput( image ); + if( mask != NULL ) + function->SetMask( mask ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } diff --git a/plugins/ImageGradientFilters/GulsunTekImageFilter.h b/plugins/ImageGradientFilters/GulsunTekImageFilter.h index abd995b..aafa51f 100644 --- a/plugins/ImageGradientFilters/GulsunTekImageFilter.h +++ b/plugins/ImageGradientFilters/GulsunTekImageFilter.h @@ -20,6 +20,9 @@ namespace cpPluginsImageGradientFilters protected: template< class _TImage > inline void _GD0( _TImage* image ); + + template< class _TImage, class _TMask > + inline void _GD1( _TImage* image, _TMask* mask ); }; } // ecapseman diff --git a/plugins/ImageGradientFilters/MFluxImageFilter.cxx b/plugins/ImageGradientFilters/MFluxImageFilter.cxx index b02701a..d166118 100644 --- a/plugins/ImageGradientFilters/MFluxImageFilter.cxx +++ b/plugins/ImageGradientFilters/MFluxImageFilter.cxx @@ -2,10 +2,10 @@ #include #include -#include +#include #include -#include +#include #include #include @@ -15,6 +15,7 @@ MFluxImageFilter( ) : Superclass( ) { this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Mask", false, false ); this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); this->m_Parameters.ConfigureAsReal( "MinRadius" ); @@ -49,7 +50,7 @@ void cpPluginsImageGradientFilters::MFluxImageFilter:: _GD0( _TImage* image ) { typedef typename _TImage::PixelType _TGradient; - typedef cpExtensions::Algorithms::FluxMedialness< _TImage > _TFunction; + typedef cpExtensions::Algorithms::MFluxMedialness< _TImage > _TFunction; typedef typename _TFunction::TOutput _TScalar; typedef itk::Image< _TScalar, _TImage::ImageDimension > _TOutputImage; typedef cpExtensions::Algorithms::ImageFunctionFilter< _TImage, _TOutputImage, _TFunction > _TFilter;