diff --git a/.gitlab/before.sh b/.gitlab/before.sh index 58d24968f43d8111a87a52d605b767d0d0887424..2b284064949aae05e877174e923bfbb03bb37235 100755 --- a/.gitlab/before.sh +++ b/.gitlab/before.sh @@ -61,9 +61,14 @@ else OS_FULL_NAME="Win7" fi QT_VERSION=$(qmake --version | grep Qt | cut -f4 -d" " ) +TIMESTAMP=$(date) # output all information to report file -echo "Docker container id....... $CONTAINER_ID" > /tmp/report.txt +echo > /tmp/report.txt +echo "-------------------------------------------------" >> /tmp/report.txt +echo >> /tmp/report.txt +echo "Time stamp................ $TIMESTAMP" >> /tmp/report.txt +echo "Docker container id....... $CONTAINER_ID" >> /tmp/report.txt echo "Job....................... $CI_JOB_NAME" >> /tmp/report.txt echo "PROJECT_SOURCE_DIR........ $PROJECT_SOURCE_DIR" >> /tmp/report.txt echo "CI_PROJECT_DIR............ $CI_PROJECT_DIR" >> /tmp/report.txt @@ -77,6 +82,9 @@ echo "" >> /tmp/report.txt echo "OS Full Name.............. $OS_FULL_NAME" >> /tmp/report.txt echo "CMake Version............. $CMAKE_VERSION" >> /tmp/report.txt echo "Qt Version................ $QT_VERSION" >> /tmp/report.txt +echo >> /tmp/report.txt +echo "-------------------------------------------------" >> /tmp/report.txt +echo >> /tmp/report.txt # cleanup log directory if [ -d ${PROJECT_LOG_DIR} ] ; then diff --git a/CMakeLists.txt b/CMakeLists.txt index 772a39245656267274f17796e7e5056c1442a516..a62b13ef80444d300fea3e7ba9d869593ce1395b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ set(CAMITK_BINDING_PYTHON CACHE BOOL FALSE) # Consider python binding only if the CMake variable is checked if(CAMITK_BINDING_PYTHON) - add_subdirectory(python_sdk) + add_subdirectory(python) endif() diff --git a/imaging/actions/itkfilters/AnisotropicDiffusion.cpp b/imaging/actions/itkfilters/AnisotropicDiffusion.cpp index b3b9c68838b55e298f23e13c286f71946d392375..5e81a641647dd3355fa652cfaa7ac1e12c7dd9f9 100644 --- a/imaging/actions/itkfilters/AnisotropicDiffusion.cpp +++ b/imaging/actions/itkfilters/AnisotropicDiffusion.cpp @@ -97,8 +97,8 @@ AnisotropicDiffusion::AnisoDiffType AnisotropicDiffusion::getDiffusionType() { // --------------- apply ------------------- Action::ApplyStatus AnisotropicDiffusion::apply() { - foreach (Component* comp, getTargets()) { - ImageComponent* input = dynamic_cast(comp); + for(Component *child : getTargets()) { + ImageComponent* input = dynamic_cast(child); process(input); } return SUCCESS; diff --git a/imaging/actions/itkfilters/CannyEdgeDetection.cpp b/imaging/actions/itkfilters/CannyEdgeDetection.cpp index 5c185a2f2fda5e9beb1cb0022bfa2d47d39553f2..e1818aec2aaf9b6ec1be62047777873955b38eed 100644 --- a/imaging/actions/itkfilters/CannyEdgeDetection.cpp +++ b/imaging/actions/itkfilters/CannyEdgeDetection.cpp @@ -80,7 +80,7 @@ CannyEdgeDetection::~CannyEdgeDetection() { // --------------- apply ------------------- Action::ApplyStatus CannyEdgeDetection::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/ConnectedComponents.cpp b/imaging/actions/itkfilters/ConnectedComponents.cpp index 08193555482bdf55be783bab33ce62f2e985c841..4f2b5cc087f7c1b7af9423dff1f7235240a83364 100644 --- a/imaging/actions/itkfilters/ConnectedComponents.cpp +++ b/imaging/actions/itkfilters/ConnectedComponents.cpp @@ -65,7 +65,7 @@ void ConnectedComponents::setNbConnectedComponents(const int nbConnectedComponen // --------------- apply ------------------- Action::ApplyStatus ConnectedComponents::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/Derivative.cpp b/imaging/actions/itkfilters/Derivative.cpp index d98ed3a70a905479a4cf6150b0a0623e173f7938..09945586d79e22a5ce61e2c0055be394bfb90d7d 100644 --- a/imaging/actions/itkfilters/Derivative.cpp +++ b/imaging/actions/itkfilters/Derivative.cpp @@ -91,7 +91,7 @@ Derivative::~Derivative() { // --------------- apply ------------------- Action::ApplyStatus Derivative::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); this->process(input); } diff --git a/imaging/actions/itkfilters/GaussianFilter.cpp b/imaging/actions/itkfilters/GaussianFilter.cpp index 2e74f50f9dfc0f344a656d2b2fadd9c39df83e6a..de0dc79f4fda6d5557ca1b5367a8ad02765baf17 100644 --- a/imaging/actions/itkfilters/GaussianFilter.cpp +++ b/imaging/actions/itkfilters/GaussianFilter.cpp @@ -87,7 +87,7 @@ GaussianFilter::GaussianType GaussianFilter::getType() { // --------------- apply ------------------- Action::ApplyStatus GaussianFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/GradientMagnitude.cpp b/imaging/actions/itkfilters/GradientMagnitude.cpp index a7db56347b1f1d6bc0da68e5e3059208f3c2a9fb..9f30a3316daab1c9239b255fa4dd508c7aa584ae 100644 --- a/imaging/actions/itkfilters/GradientMagnitude.cpp +++ b/imaging/actions/itkfilters/GradientMagnitude.cpp @@ -52,7 +52,7 @@ GradientMagnitude::GradientMagnitude(ActionExtension* extension) : Action(extens // --------------- apply ------------------- Action::ApplyStatus GradientMagnitude::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp b/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp index 5b918f5978a449924ea67ace8b166873ce431a65..5ae9f3c276ec8fc44c7cfd95102dcc9022f71155 100644 --- a/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp +++ b/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp @@ -74,7 +74,7 @@ GradientMagnitudeRecursiveGaussian::~GradientMagnitudeRecursiveGaussian() { // --------------- apply ------------------- Action::ApplyStatus GradientMagnitudeRecursiveGaussian::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/Laplacian.cpp b/imaging/actions/itkfilters/Laplacian.cpp index 0efeebef5dfade196cd3dbabc985df9de4b04cb8..71d1aa91e4712cbc966824dad453cf75daaed8df 100644 --- a/imaging/actions/itkfilters/Laplacian.cpp +++ b/imaging/actions/itkfilters/Laplacian.cpp @@ -68,7 +68,7 @@ Laplacian::~Laplacian() { // --------------- apply ------------------- Action::ApplyStatus Laplacian::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp b/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp index 5dc9f8f143240fceab433dd5c0a656d47408d58f..740782499ed65aa3b9f82f57cf9487cd150beda4 100644 --- a/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp +++ b/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp @@ -72,7 +72,7 @@ LaplacianRecursiveGaussian::~LaplacianRecursiveGaussian() { // --------------- apply ------------------- Action::ApplyStatus LaplacianRecursiveGaussian::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/LaplacianSharpening.cpp b/imaging/actions/itkfilters/LaplacianSharpening.cpp index d2cee96cc10de173924d30676e588f5930df61f6..f7be56e3c622562aa45113a46e16443f160472ab 100644 --- a/imaging/actions/itkfilters/LaplacianSharpening.cpp +++ b/imaging/actions/itkfilters/LaplacianSharpening.cpp @@ -56,7 +56,7 @@ LaplacianSharpening::LaplacianSharpening(ActionExtension* extension) : Action(ex // --------------- apply ------------------- Action::ApplyStatus LaplacianSharpening::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/MeanFilter.cpp b/imaging/actions/itkfilters/MeanFilter.cpp index c0866b97ba0c976ef12128e9afb826c443c99ff0..21ef14017531c92aa9ca677fa5187851d7e2c954 100644 --- a/imaging/actions/itkfilters/MeanFilter.cpp +++ b/imaging/actions/itkfilters/MeanFilter.cpp @@ -89,7 +89,7 @@ MeanFilter::~MeanFilter() { // --------------- apply ------------------- Action::ApplyStatus MeanFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/MedianFilter.cpp b/imaging/actions/itkfilters/MedianFilter.cpp index 05fc7890ad9195cc7efafc223be6c1424609c4e3..381d67c8133acccfda94a6fbc33bb99c8571c01d 100644 --- a/imaging/actions/itkfilters/MedianFilter.cpp +++ b/imaging/actions/itkfilters/MedianFilter.cpp @@ -89,7 +89,7 @@ MedianFilter::~MedianFilter() { // --------------- apply ------------------- Action::ApplyStatus MedianFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/MorphologicalOperators.cpp b/imaging/actions/itkfilters/MorphologicalOperators.cpp index 3ea1b65bf76ba3a7f3a5c64efd1161500da4219d..8fcfb935e55600fe283a155ab78b12743a8e4719 100644 --- a/imaging/actions/itkfilters/MorphologicalOperators.cpp +++ b/imaging/actions/itkfilters/MorphologicalOperators.cpp @@ -86,7 +86,7 @@ MorphologicalOperators::MorphoOperation MorphologicalOperators::getMorphoOperati // --------------- apply ------------------- Action::ApplyStatus MorphologicalOperators::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/SobelEdgeDetection.cpp b/imaging/actions/itkfilters/SobelEdgeDetection.cpp index c9c13a61fff06a065e99bc89520f35719d2212ec..6b173e7ef4476a27e147b1d1a3bf926d37c14aa5 100644 --- a/imaging/actions/itkfilters/SobelEdgeDetection.cpp +++ b/imaging/actions/itkfilters/SobelEdgeDetection.cpp @@ -60,7 +60,7 @@ SobelEdgeDetection::SobelEdgeDetection(ActionExtension* extension) : Action(exte // --------------- apply ------------------- Action::ApplyStatus SobelEdgeDetection::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itksegmentation/ManualThreshold.cpp b/imaging/actions/itksegmentation/ManualThreshold.cpp index f1e97a61858edd5646c66802406df21cc22845c1..0fbe45c70eb24217ef04907385ffea6edfd8ed50 100644 --- a/imaging/actions/itksegmentation/ManualThreshold.cpp +++ b/imaging/actions/itksegmentation/ManualThreshold.cpp @@ -74,7 +74,7 @@ ManualThreshold::~ManualThreshold() { // --------------- apply ------------------- Action::ApplyStatus ManualThreshold::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itksegmentation/OtsuFilter.cpp b/imaging/actions/itksegmentation/OtsuFilter.cpp index 3917c3c35afdf7a29368f81fcc616dd5310061ed..0befe1d6fb60ac16f7947a1188e58ada4e7c0aa2 100644 --- a/imaging/actions/itksegmentation/OtsuFilter.cpp +++ b/imaging/actions/itksegmentation/OtsuFilter.cpp @@ -79,7 +79,7 @@ OtsuFilter::~OtsuFilter() { // --------------- apply ------------------- Action::ApplyStatus OtsuFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/components/dicom/DicomComponent.cpp b/imaging/components/dicom/DicomComponent.cpp index 180da9dfd810458eea37adb239ed6874dcf45d15..e2d57988fe980c7b05801cce758a8b6676c0f6c6 100644 --- a/imaging/components/dicom/DicomComponent.cpp +++ b/imaging/components/dicom/DicomComponent.cpp @@ -83,7 +83,7 @@ DicomComponent::DicomComponent(DicomSeries* dicomSeries) : ImageComponent("") { // convert this list as a vtkStringArray vtkSmartPointer fileNamesSorted = vtkSmartPointer::New(); - foreach (std::string file, files) { + for (std::string file : files) { fileNamesSorted->InsertNextValue(file.c_str()); } diff --git a/imaging/components/dicom/DicomComponentExtension.cpp b/imaging/components/dicom/DicomComponentExtension.cpp index 4c1a5e21c0dd312aa89ddc36612f610328ab01c4..eaa24ad9d47800b156efc5ec748532e1ab5a70af 100644 --- a/imaging/components/dicom/DicomComponentExtension.cpp +++ b/imaging/components/dicom/DicomComponentExtension.cpp @@ -57,7 +57,7 @@ Component* DicomComponentExtension::open(const QString& path) { seriesParsed = DicomParser::parseDirectory(path); // create a Dialog entry for each series parsed - foreach (DicomSeries* dicomSeries, seriesParsed) { + for (DicomSeries* dicomSeries : seriesParsed) { DicomDialogEntry* entry = new DicomDialogEntry(); entry->setSelected(false); entry->setAcquisitionDate(dicomSeries->getAcquisitionDate()); @@ -77,9 +77,9 @@ Component* DicomComponentExtension::open(const QString& path) { // Open each selected Dicom as a component if (!seriesDialogEntries.isEmpty()) { - foreach (DicomDialogEntry* entry, seriesDialogEntries) { + for (DicomDialogEntry* entry : seriesDialogEntries) { // Find the corresponding Dicom Series in the List - foreach (DicomSeries* series, seriesParsed) { + for (DicomSeries* series : seriesParsed) { if ((series->getStudyName() == entry->getStudyName()) && (series->getSeriesName() == entry->getSeriesName())) { lastOpenedComponent = new DicomComponent(series); diff --git a/imaging/components/dicom/DicomDialog.cpp b/imaging/components/dicom/DicomDialog.cpp index 9b7f4cf48babc494a0f2d5294aface311e2ca388..3d5795bd78e76ca0e36f13d8183104fc0e747d93 100644 --- a/imaging/components/dicom/DicomDialog.cpp +++ b/imaging/components/dicom/DicomDialog.cpp @@ -46,7 +46,7 @@ DicomDialog::DicomDialog(QList elements): QDialog() { int row = 0; int column = 0; - foreach (DicomDialogEntry* item, dicomDialogEntries) { + for (DicomDialogEntry* item : dicomDialogEntries) { column = 0; QTableWidgetItem* selectionItem = new QTableWidgetItem(""); selectionItem->setCheckState(Qt::Unchecked); diff --git a/imaging/components/dicom/DicomParser.cpp b/imaging/components/dicom/DicomParser.cpp index 17d55b28f2715a653a5662bb33570121d78f1f53..4db6003b7908a6f8ec9fc80dba22f27aed189d9c 100644 --- a/imaging/components/dicom/DicomParser.cpp +++ b/imaging/components/dicom/DicomParser.cpp @@ -53,7 +53,7 @@ QList DicomParser::parseDirectory(const QString& directory) { dicomImageScanner.Scan(fileNames); CAMITK_TRACE_ALT(tr("Parsing files for DICOM image files")) - foreach (std::string file, dicomImageScanner.GetFilenames()) { + for (std::string file : dicomImageScanner.GetFilenames()) { // 1st check the file is a valid DICOM file if (dicomImageScanner.IsKey(file.c_str())) { // 2nd check the dicom file is is an image file @@ -85,7 +85,7 @@ QList DicomParser::parseDirectory(const QString& directory) { const std::set< std::string > studyValues = studyScanner.GetValues(); // for each value, build a new DicomStudyComponent given the associated study filenames - foreach (std::string studyName, studyValues) { + for (std::string studyName : studyValues) { // get study associated filenames std::vector< std::string > studyFileNames = studyScanner.GetAllFilenamesFromTagToValue(studyUIDTag, studyName.c_str()); @@ -95,7 +95,7 @@ QList DicomParser::parseDirectory(const QString& directory) { seriesScanner.AddTag(seriesUIDTag); seriesScanner.Scan(studyFileNames); const std::set< std::string > seriesValues = seriesScanner.GetValues(); - foreach (std::string serieName, seriesValues) { + for (std::string serieName : seriesValues) { // get file associated with this series std::vector< std::string > seriesFileNames = seriesScanner.GetAllFilenamesFromTagToValue(seriesUIDTag, serieName.c_str()); @@ -198,7 +198,7 @@ QString DicomParser::getStudyName(const std::vector& seriesFileName // --------------- stdListOfStringToQt ------------------- QList DicomParser::stdListOfStringToQt(const std::vector& inputList) { QList outputFileNames; - foreach (std::string stdFile, inputList) { + for (std::string stdFile : inputList) { outputFileNames.append(QString::fromStdString(stdFile)); } @@ -208,7 +208,7 @@ QList DicomParser::stdListOfStringToQt(const std::vector& // --------------- qtListOfStringToStd ------------------- std::vector< std::string > DicomParser::qtListOfStringToStd(const QList& inputList) { std::vector< std::string > outputFileNames; - foreach (QString qtFile, inputList) { + for (QString qtFile : inputList) { outputFileNames.push_back(qtFile.toStdString()); } diff --git a/modeling/actions/pml/CamiTKPropertyList.cpp b/modeling/actions/pml/CamiTKPropertyList.cpp index 7cf8469333c2e0aac23bf1e672c4a830ae6b1b9a..a46b10119c659ebab895d968311a2e15fc892fc6 100644 --- a/modeling/actions/pml/CamiTKPropertyList.cpp +++ b/modeling/actions/pml/CamiTKPropertyList.cpp @@ -29,7 +29,7 @@ using namespace camitk; // ---------------------- Destructor ---------------------------- CamiTKPropertyList::~CamiTKPropertyList() { // delete all properties - foreach (Property* prop, propertyMap.values()) { + for (Property* prop : propertyMap.values()) { delete prop; } propertyMap.clear(); diff --git a/modeling/actions/pml/CreateSC.h b/modeling/actions/pml/CreateSC.h index ce1a62ab2b8193c868fea650dfec6fe1233dafbe..fe74d2a8297d81f88d2e41fe3f21df5041bb3c7b 100644 --- a/modeling/actions/pml/CreateSC.h +++ b/modeling/actions/pml/CreateSC.h @@ -27,6 +27,8 @@ #define CREATESC_H #include +#include +#include class PMLComponent; diff --git a/modeling/actions/pml/PMLExplorerWidget.cpp b/modeling/actions/pml/PMLExplorerWidget.cpp index 006302c3e2ea6865fa7a4059bb7966b4c20a8bb1..388016ceda5bef40dac8bc0d7223cadb5c62a3cf 100644 --- a/modeling/actions/pml/PMLExplorerWidget.cpp +++ b/modeling/actions/pml/PMLExplorerWidget.cpp @@ -77,7 +77,7 @@ PMLExplorerWidget::~PMLExplorerWidget() { delete objectController; objectController = nullptr; - foreach (QObject* o, widgetPropertiesMap) { + for (QObject* o : widgetPropertiesMap) { delete o; } @@ -219,7 +219,7 @@ void PMLExplorerWidget::selectItems() { // let's find out the corresponding Atom, SC, MC or Cell selected and ask to select them in the 3D structure QList itemsSelected = ui->treeWidget->selectedItems(); - foreach (QTreeWidgetItem* item, itemsSelected) { + for (QTreeWidgetItem* item : itemsSelected) { if (widgetAtomMap.contains(item)) { // Is it an atom ? Atom* atomSelected = widgetAtomMap.value(item); @@ -262,10 +262,10 @@ void PMLExplorerWidget::updateTarget(PMLComponent* comp) { // constructing the tree content). disconnect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(selectItems())); - foreach (QObject* o, widgetPropertiesMap) { + for (QObject* o : widgetPropertiesMap) { delete o; } - foreach (QObject* o, atomPropertiesMap) { + for (QObject* o : atomPropertiesMap) { delete o; } diff --git a/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp b/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp index 6043ecd9227e5b08fcb1478f38a0de02cd349b3b..6ba9a1494756cde1d2c922114d59e4b4f3234df1 100644 --- a/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp +++ b/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp @@ -367,7 +367,7 @@ void XmlHighlighter::highlightBlock(const QString& text) { highlightSubBlock(text, 0, previousBlockState()); //Run the set of inline rules. - foreach (const HighlightingRule& rule, hlRules) { + for (const HighlightingRule& rule : hlRules) { QRegExp expression(rule.pattern); int index = expression.indexIn(text); while (index >= 0) { diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c1a0505bd62973cb87c7f10d65a3e2e5e784e3a9 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,482 @@ +#-------------------------------------------- +# +# CamiTK SDK Python binding +# +# Do not edit this file, unless +# you really (really!) know +# what you're doing +# +#-------------------------------------------- + +# check https://machinekoder.com/pyqt-vs-qt-for-python-pyside2-pyside/ for a comparison between PyQt and PySide + +# TODO add an install target to install the PyCamiTK python module in the right place for system wide installation +# as well as locally + +# cmake ../../src/camitk -DCMAKE_BUILD_TYPE=Debug -DCAMITK_BINDING_PYTHON=TRUE -DCEP_IMAGING=FALSE -DCEP_TUTORIALS=TRUE -DCEP_MODELING=FALSE +# make -j6 +# make camitk-ce-python-package +# python3 ../src/camitk/python/test.py +# gdb bin/camitk-actionstatemachine +# (gdb) r -a -f camitk-history-20190315-132942.scxml -o /tmp + +# check also https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/samplebinding/CMakeLists.txt?h=5.9 +cmake_minimum_required(VERSION 3.1) +cmake_policy(VERSION 3.1) + +# Set CPP standard to C++11 minimum. +set(CMAKE_CXX_STANDARD 11) + +#-------------------------------------------- +# +# Python binding requirements +# +#-------------------------------------------- + +# # Greatly inspired by freecad CMakeLists.txt +# # set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +# # Below are two variables that can be left empty for standard python 3 version, +# # but must be set by the user for different python versions such as 2.7, 3.5 ... +# if (PYTHON_VERSION_MAJOR LESS 3) +# SET(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") +# SET(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") +# else() +# #SET(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") +# #SET(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") +# endif() + +# -- Python3 +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +if(NOT Python3_FOUND) + message(SEND_ERROR "Failed to find Python 3 or greater. This is needed to build CamiTK Python binding.") +endif() +if("${Python3_VERSION}" VERSION_LESS 3.7) + message(FATAL_ERROR "Found Python3 ${Python3_VERSION} version but at least 3.7 is required. Please update your version of Python3.") +endif() +message(STATUS "Found suitable version of Python: ${Python3_VERSION} (required is at least 3.7)") + +# set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +# if(NOT DEFINED PYTHON_VERSION_STRING) +# find_package(PythonLibs REQUIRED) +# else() +#find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT) +# endif() +# +# +# if(NOT PYTHONLIBS_FOUND) +# message(FATAL_ERROR "=================================\n" +# "Python not found, install Python!\n" +# "=================================\n") +# else() +# # prevent python3 lower than 3.7 (not enough utf8<->unicode tools) +# if(PYTHON_VERSION VERSION_LESS 3.7) +# message(FATAL_ERROR "To build CamiTK Python binding, you need at least version python 3.7") +# endif() +# endif() + +# -- Qt +# # List of Qt5 modules that are required in CamiTK +# set(CAMITK_QT_COMPONENTS Core Gui Xml XmlPatterns Widgets Help UiTools OpenGL OpenGLExtensions Test) +# # Find Qt5 +# find_package(Qt5 COMPONENTS ${CAMITK_QT_COMPONENTS} REQUIRED) + +# -- PySide, the Python binding of Qt using Shiboken. +find_package(PySide2 REQUIRED) +if(PYSIDE_INCLUDE_DIR) + message(STATUS "Found PySide2 configuration in ${PySide2_DIR}") + # PySide2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(PYSIDE_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB PYSIDE_CONFIG "${PySide2_DIR}/PySide2Config${PYSIDE_PATTERN}*.cmake") + if (PYSIDE_CONFIG) + get_filename_component(PYSIDE_CONFIG_SUFFIX ${PYSIDE_CONFIG} NAME) + string(SUBSTRING ${PYSIDE_CONFIG_SUFFIX} 13 -1 PYSIDE_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${PYSIDE_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for PySide2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(PySide2 QUIET) + endif() + set(PYSIDE_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.${Python3_VERSION_PATCH}) +endif() +if (NOT PYSIDE_VERSION OR ${PYSIDE_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find PySide2 for Python3. Found version: ${PYSIDE_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of PySide2: ${PYSIDE_VERSION}, path to binary is ${PYSIDE_VERSION}") + + +if(NOT PYSIDE_INCLUDE_DIR) + message(FATAL_ERROR "Failed to find PySide2. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found PySide2") + +# -- Shiboken2, the PySide team C++ to Python wrapper +find_package(Shiboken2 REQUIRED) +if (Shiboken2_FOUND) + # Shiboken2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake") + if (SHIBOKEN_CONFIG) + get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME) + string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for Shiboken2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(Shiboken2 QUIET) + endif() + set(SHIBOKEN_VERSION ${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}.${SHIBOKEN_PYTHON_VERSION_PATCH}) +endif() +if (NOT SHIBOKEN_VERSION OR ${SHIBOKEN_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find Shiboken2 for Python3. Found version: ${SHIBOKEN_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of Shiboken2: ${SHIBOKEN_VERSION}, path to binary is ${SHIBOKEN_BINARY}") + +# +# find_program(SHIBOKEN2 shiboken2 REQUIRED) +# if (NOT SHIBOKEN2) +# message(FATAL_ERROR "Please add Shiboken2 binary in your PATH or manually point to it using the SHIBOKEN2 variable") +# endif() +# +# +# +# find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc) +# if(NOT PYSIDE2_TOOLS_FOUND) +# message("=======================\n" +# "PySide2Tools not found.\n" +# "=======================\n") +# endif() + +# Mini find CamiTK inside SDK +set(CAMITK_DIR ${CMAKE_BINARY_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CAMITK_DIR}/share/${CAMITK_SHORT_VERSION_STRING}/cmake) +include(CamiTKConfig) + + +# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide) +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n" +# "from PySide2 import __version__\n" +# "from PySide2 import __version_info__\n") +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n" +# "#QCoreApplication.CodecForTr=0\n" +# "#QCoreApplication.UnicodeUTF8=1\n") +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n" +# "from PySide2.QtWidgets import *\n" +# "QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n") +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n") +# +# if(APPLE AND NOT BUILD_WITH_CONDA) +# install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide +# DESTINATION MacOS) +# else() +# install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide +# DESTINATION Ext) +# endif() + +# TEST Using VTK dependency +# find_package(VTK REQUIRED) + +#-------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#-------------------------------------------- +# Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted +# set(SHIBOKEN_TYPESYSTEM_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +# set(SHIBOKEN_GLOBAL_H_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# Shiboken command need paths separated by ":" instead of ";" +string(REPLACE ";" ":" SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES "${CAMITK_INCLUDE_DIRECTORIES}") +string(REPLACE ";" ":" SHIBOKEN_VTK_INCLUDE_DIRS "${VTK_INCLUDE_DIRS}") + +# include subdirectories +# add_subdirectory(actions) +# add_subdirectory(applications) +# add_subdirectory(components) +# add_subdirectory(libraries) + +# TODO : Remove once debugged +# message(WARNING "PYSIDE_INCLUDE_DIR = ${PYSIDE_INCLUDE_DIR}") +# message(WARNING "SHIBOKEN_TYPESYSTEM_PATH = ${SHIBOKEN_TYPESYSTEM_PATH}") +# message(WARNING "SHIBOKEN_GLOBAL_H_PATH = ${SHIBOKEN_GLOBAL_H_PATH}") +# message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") +# message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") +# message(FATAL_ERROR "SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES = ${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}") +# message(WARNING "SHIBOKEN_VTK_INCLUDE_DIRS = ${SHIBOKEN_VTK_INCLUDE_DIRS}") + +#-------------------------------------------- +# +# Custom CMake Python binding targets +# +#-------------------------------------------- +# # Shiboken specific paths +# set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN +# ${PYSIDE_INCLUDE_DIR}:${PYSIDE_INCLUDE_DIR}/QtCore:${PYSIDE_INCLUDE_DIR}/QtGui +# #:${PYSIDE_INCLUDE_DIR}/QtHelp:${PYSIDE_INCLUDE_DIR}/QtNetwork:${PYSIDE_INCLUDE_DIR}/QtOpenGL:${PYSIDE_INCLUDE_DIR}/QtScript:${PYSIDE_INCLUDE_DIR}/QtScriptTools:${PYSIDE_INCLUDE_DIR}/QtSql:${PYSIDE_INCLUDE_DIR}/QtSvg:${PYSIDE_INCLUDE_DIR}/QtTest:${PYSIDE_INCLUDE_DIR}/QtUiTools:${PYSIDE_INCLUDE_DIR}/QtWebKit:${PYSIDE_INCLUDE_DIR}/QtXml:${PYSIDE_INCLUDE_DIR}/QtXmlPatterns:${PYSIDE_INCLUDE_DIR}/QtDeclarative +# ) +# +# # TODO : Remove once debugged +# message(WARNING "PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN = ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}") + +# The name of the generated bindings module (as imported in Python). You can change the name +# to something relevant for your project. +set(CAMITK_PYTHON_BIDINGS_MODULE_NAME "PyCamiTK") + +# The header file with all the types and functions for which bindings will be generated. +set(CAMITK_PYTHON_WRAPPED_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.h) + +# The typesystem xml file which defines the relationships between the C++ types / functions +# and the corresponding Python equivalents. +set(CAMITK_PYTHON_TYPESYSTEM_FILE ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.xml) + +# The resulting C++ wrapped classes will be listed in the following CMake variable: +# file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp) + +# Manually specifies the classes to bind +set(CAMITK_PYTHON_CLASS_NAMES Core + ExtensionManager + HistoryComponent + HistoryItem + InterfaceLogger + Log + AbortException + PropertyObject + Property + CamiTKLogger + ObjectController + Application + MainWindow + SettingsDialog + Viewer + Explorer + PropertyExplorer + MedicalImageViewer + ActionViewer + Action + InterfaceNode + InterfaceProperty + InterfaceBitMap + InterfaceGeometry + InterfaceFrame + ComponentExtension + Component + Frame + ImageComponent +# RendererWidget +# InteractiveViewer +) + +# Compute which C++ files will be generated by shiboken. This includes the module wrapper, the namespace wrapper +# and a '.cpp' file per C++ class. These are needed for generating the module shared +# library. +set(CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/pycamitk_module_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_wrapper.cpp +) +foreach(CAMITK_CLASS_NAME ${CAMITK_PYTHON_CLASS_NAMES}) + string(TOLOWER "${CAMITK_CLASS_NAME}" CAMITK_CLASS_NAME_LOWER) + set(CAMITK_PYTHON_GENERATED_SOURCES ${CAMITK_PYTHON_GENERATED_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_${CAMITK_CLASS_NAME_LOWER}_wrapper.cpp) +endforeach() + +# set the dependencies so that if any of these files are modified, the python modules will be +# automatically regenerated +set(CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES ${CAMITK_PYTHON_WRAPPED_HEADER} ${CAMITK_PYTHON_TYPESYSTEM_FILE}) + +# if (CMAKE_COMPILER_IS_GNUCC) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") +# endif() + +# set up the options to pass to shiboken. Check https://doc.qt.io/qtforpython/shiboken2/commandlineoptions.html +set(SHIBOKEN_OPTIONS + --generator-set=shiboken + --enable-parent-ctor-heuristic + --enable-return-value-heuristic + --use-isnull-as-nb_nonzero + --avoid-protected-hack + --enable-pyside-extensions + --api-version=5.11 +# --disable-verbose-error-messages # Disable verbose error messages. Turn the CPython code hard to debug but saves a few kilobytes in the generated binding. + --no-suppress-warnings # Show all warnings. + --debug-level=full + --output-directory=${CMAKE_CURRENT_BINARY_DIR} + --include-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_INCLUDE_DIR}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}:${SHIBOKEN_VTK_INCLUDE_DIRS}:${SHIBOKEN_INCLUDE_DIR} + --typesystem-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} +) + +# Add custom target to run shiboken to generate the binding cpp files. +add_custom_command(OUTPUT ${CAMITK_PYTHON_GENERATED_SOURCES} + COMMAND ${SHIBOKEN_BINARY} + ${SHIBOKEN_OPTIONS} # all required options + ${CAMITK_PYTHON_WRAPPED_HEADER} # wrap header + ${CAMITK_PYTHON_TYPESYSTEM_FILE} # type system + # Hack Shiboken #1: change "unsigned int(0)" to "0" +# COMMAND ${CMAKE_COMMAND} -DCAMITK_PYTHON_BIDINGS_MODULE_NAME=${CAMITK_PYTHON_BIDINGS_MODULE_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/ShibokenHack.cmake + DEPENDS ${CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES} + IMPLICIT_DEPENDS CXX ${CAMITK_PYTHON_WRAPPED_HEADER} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Wrapping CamiTK SDK for Python bindings." +) + +# =============================== CMake target for CamiTK Python binding ============================= + +# Set the cpp files which will be used for the bindings library. +set(${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES ${CAMITK_PYTHON_GENERATED_SOURCES}) + +# message(FATAL_ERROR "value=${CAMITK_CORE_LIBRARIES}") +link_directories(${CAMITK_LINK_DIRECTORIES}) + +# Define and build the bindings library. +add_library(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} MODULE ${${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES}) + +# add add_dependencies to CamiTK core +# Using target_link_libraries(..) is enough to link the extension to the CamiTK core library +if(CAMITK_COMMUNITY_EDITION_BUILD) + add_dependencies(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} ${CAMITK_CORE_TARGET_LIB_NAME}) + # add the dependency to the core automoc target only if inside a SDK build + set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${CAMITK_CORE_TARGET_LIB_NAME}) +endif() + +# Apply relevant include and link flags. +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYTHON3_INCLUDE_DIRS}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}/QtCore) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}/QtGui) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}/QtWidgets) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${SHIBOKEN_INCLUDE_DIR}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CAMITK_INCLUDE_DIRECTORIES}) + +# target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${QT_QTCORE_LIBRARY}) +# target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${QT_QTGUI_LIBRARY}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${VTK_LIBRARIES}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_LIBRARY}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${SHIBOKEN_PYTHON_LIBRARIES}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${SHIBOKEN_LIBRARY}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CAMITK_CORE_LIBRARIES}) + +# message(FATAL_ERROR "lib=${CAMITK_CORE_LIBRARIES}") +# message(WARNING "PYSIDE_LIBRARY = ${PYSIDE_LIBRARY}") +# message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") +# message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") +# message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") +# message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") +# message(WARNING "SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES = ${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}") +# message(WARNING "SHIBOKEN_VTK_INCLUDE_DIRS = ${SHIBOKEN_VTK_INCLUDE_DIRS}") + +# Adjust the name of generated module. +set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY PREFIX "") +set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY OUTPUT_NAME + "${CAMITK_PYTHON_BIDINGS_MODULE_NAME}${PYTHON_EXTENSION_SUFFIX}") + +# Output directory (python is public for now) +if (MSVC) + # With Visual Studio, public libraries are built in build\bin directory, else it's in build\lib + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR} + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR} + ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX}) +else() + # for xcode generation, the postfix should also be used, but "a la" UNIX (lib in /lib etc...) + # no need to check the generator with if(CMAKE_GENERATOR STREQUAL Xcode), as the postfix should + # not affect the other unix generators + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PUBLIC_LIB_DIR} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PUBLIC_LIB_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ) +endif() + +#-- install +# During installation, where to install the python library +install(TARGETS ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} + # TODO proper python lib installation + RUNTIME DESTINATION lib + LIBRARY DESTINATION lib #NAMELINK_ONLY + ARCHIVE DESTINATION lib + COMPONENT ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} +) + +set(PYCAMITK_LIB_FILENAME ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so) +set(PYCAMITK_LIB_PREFIXED_FILENAME lib${PYCAMITK_LIB_FILENAME}) + +# During installation, add a symlink so that C++ actions can link to the Python CamiTK binding lib +if(CMAKE_HOST_UNIX) + if(NOT IS_SYMLINK ${CMAKE_INSTALL_PREFIX}/lib/${PYCAMITK_LIB_PREFIXED_FILENAME}) + install(CODE "execute_process(COMMAND ln -s ${PYCAMITK_LIB_FILENAME} ${PYCAMITK_LIB_PREFIXED_FILENAME} + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)" + CODE "message(STATUS \"Creating install-time symlink to ${PYCAMITK_LIB_PREFIXED_FILENAME}\")" + ) + endif() +endif() + +#-- During build-time install, also add symlink from PyCamiTK.so to libPyCamiTK.so in order to be able to link against libPyCamiTK.so +# (e.g. in action that requires python bindings) +if(CMAKE_HOST_UNIX) + if(NOT IS_SYMLINK ${CAMITK_BUILD_PUBLIC_LIB_DIR}/${PYCAMITK_LIB_PREFIXED_FILENAME}) + # add symlink so that C++ actions can link to the Python CamiTK binding lib + add_custom_command( TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} + POST_BUILD + COMMAND ln -s ${PYCAMITK_LIB_FILENAME} ${PYCAMITK_LIB_PREFIXED_FILENAME} + WORKING_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + COMMENT "Creating build-time symlink to ${PYCAMITK_LIB_PREFIXED_FILENAME}" + VERBATIM + ) + endif() +endif() + +#-- install binding file +# Check for python dir directory +set(PYTHON_TYPESYSTEM_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/python) +set(CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR ${CAMITK_BUILD_DIR}/${PYTHON_TYPESYSTEM_DEST_DIR}) +if (NOT EXISTS ${CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR}) + make_directory( ${CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR} ) +endif() + +# At build-time copy the files to the python typesystem directory +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CAMITK_PYTHON_TYPESYSTEM_FILE} ${CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +# During installation, copy the files to install directory +install(FILES ${CAMITK_PYTHON_TYPESYSTEM_FILE} + DESTINATION ${PYTHON_TYPESYSTEM_DEST_DIR} +) + +#-- install python binding header file +set(PYTHON_HEADER_DEST_DIR include/${CAMITK_SHORT_VERSION_STRING}/python) +set(CAMITK_BUILD_PYTHON_HEADER_DIR ${CAMITK_BUILD_DIR}/${PYTHON_HEADER_DEST_DIR}) +if (NOT EXISTS ${CAMITK_BUILD_PYTHON_HEADER_DIR}) + make_directory(${CAMITK_BUILD_PYTHON_HEADER_DIR}) +endif() + +# At build-time copy the files to the python wrapping header directory +set(CAMITK_PYTHON_WRAPPING_HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/pycamitk_python.h) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CAMITK_PYTHON_WRAPPING_HEADER_FILE} ${CAMITK_BUILD_PYTHON_HEADER_DIR} +# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +# During installation, copy the files to install directory +install(FILES ${CAMITK_PYTHON_WRAPPING_HEADER_FILE} + DESTINATION ${PYTHON_HEADER_DEST_DIR} +) + + + + + diff --git a/python/FindPySide2Tools.cmake b/python/FindPySide2Tools.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a774756e1595a73cce34fb69cc8a60d98d1d0eb9 --- /dev/null +++ b/python/FindPySide2Tools.cmake @@ -0,0 +1,98 @@ +# Originally from freecad +# +# Try to find PySide2 utilities, PYSIDE2UIC and PYSIDE2RCC: +# PYSIDE2UICBINARY - Location of PYSIDE2UIC executable +# PYSIDE2RCCBINARY - Location of PYSIDE2RCC executable +# PYSIDE2_TOOLS_FOUND - PySide2 utilities found. + +# Also provides macro similar to FindQt4.cmake's WRAP_UI and WRAP_RC, +# for the automatic generation of Python code from Qt4's user interface +# ('.ui') and resource ('.qrc') files. These macros are called: +# - PYSIDE_WRAP_UI +# - PYSIDE_WRAP_RC + +IF(PYSIDE2UICBINARY AND PYSIDE2RCCBINARY) + # Already in cache, be silent + set(PYSIDE2_TOOLS_FOUND_QUIETLY TRUE) +ENDIF(PYSIDE2UICBINARY AND PYSIDE2RCCBINARY) + +if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + #pyside2 tools are often in same location as python interpreter + get_filename_component(PYTHON_BIN_DIR ${PYTHON_EXECUTABLE} PATH) + set(PYSIDE_BIN_DIR ${PYTHON_BIN_DIR}) +endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + +FIND_PROGRAM(PYSIDE2UICBINARY NAMES python2-pyside2-uic pyside2-uic pyside2-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR}) +FIND_PROGRAM(PYSIDE2RCCBINARY NAMES pyside2-rcc pyside2-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR}) + +MACRO(PYSIDE_WRAP_UI outfiles) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py) + #ADD_CUSTOM_TARGET(${it} ALL + # DEPENDS ${outfile} + #) + if(WIN32 OR APPLE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${PYSIDE2UICBINARY} ${infile} -o ${outfile} + MAIN_DEPENDENCY ${infile} + ) + else() + # Especially on Open Build Service we don't want changing date like + # pyside2-uic generates in comments at beginning., which is why + # we follow the tool command with in-place sed. + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND "${PYSIDE2UICBINARY}" "${infile}" -o "${outfile}" + COMMAND sed -i "/^# /d" "${outfile}" + MAIN_DEPENDENCY "${infile}" + ) + endif() + list(APPEND ${outfiles} ${outfile}) + ENDFOREACH(it) +ENDMACRO (PYSIDE_WRAP_UI) + +MACRO(PYSIDE_WRAP_RC outfiles) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py") + #ADD_CUSTOM_TARGET(${it} ALL + # DEPENDS ${outfile} + #) + if(WIN32 OR APPLE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${PYSIDE2RCCBINARY} ${infile} -o ${outfile} + MAIN_DEPENDENCY ${infile} + ) + else() + # Especially on Open Build Service we don't want changing date like + # pyside-rcc generates in comments at beginning, which is why + # we follow the tool command with in-place sed. + ADD_CUSTOM_COMMAND(OUTPUT "${outfile}" + COMMAND "${PYSIDE2RCCBINARY}" "${infile}" ${PY_ATTRIBUTE} -o "${outfile}" + COMMAND sed -i "/^# /d" "${outfile}" + MAIN_DEPENDENCY "${infile}" + ) + endif() + list(APPEND ${outfiles} ${outfile}) + ENDFOREACH(it) +ENDMACRO (PYSIDE_WRAP_RC) + +IF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY}) + set(PYSIDE2_TOOLS_FOUND TRUE) +ENDIF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY}) + +if(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) + if (NOT PySide2Tools_FIND_QUIETLY) + message(STATUS "Found PySide2 tools: ${PYSIDE2UICBINARY}, ${PYSIDE2RCCBINARY}") + endif (NOT PySide2Tools_FIND_QUIETLY) +else(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) + if(PySide2Tools_FIND_REQUIRED) + message(FATAL_ERROR "PySide2 tools could not be found, but are required.") + else(PySide2Tools_FIND_REQUIRED) + if (NOT PySide2Tools_FIND_QUIETLY) + message(STATUS "PySide2 tools: not found.") + endif (NOT PySide2Tools_FIND_QUIETLY) + endif(PySide2Tools_FIND_REQUIRED) +endif(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) diff --git a/python/PythonBindings.h b/python/PythonBindings.h new file mode 100644 index 0000000000000000000000000000000000000000..ccb958a99e1b7ffcbb131eea2dcdda91757a3a6d --- /dev/null +++ b/python/PythonBindings.h @@ -0,0 +1,121 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2019 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +#ifndef PYTHON_BINDINGS_H +#define PYTHON_BINDINGS_H + +// Qt Bindings for CamiTK (PyCamiTK) + +// CamiTK core library + +// top dir +#include + +// force redefinition of type as Shiboken does not understand +// the C++11 type aliases +#define ComponentList QList +#define ActionSet QSet +#define ActionList QList + +// requires to be at the end due to Win/OpenGL confusion with ERROR macro +#include + +#include +#include +#include +#include + +// application +#include +#include +#include + +// viewer +#include +#include +// FrameExplorer.h +#include +#include +#include +#include + +// utils +#include +#include +#include +#include +#include +#include +#include +// not needed: +// PlaneC.h +// ConsoleStream.h +// SliderSpinBoxWidget.h +// SliderTextWidget.h + +// action +#include +// ActionExtension.h +// ActionWidget.h + +// component +#include +#include +#include +#include +#include +#include +#include +// SimplisticComponent.h +// Geometry.h +#include +// GeometricObject.h +// Slice.h + +// mesh subdir +// MeshComponent.h +// MeshDataModel.h +// MeshDataView.h +// MeshComponentExtension.h +// MeshSelectionModel.h +// MeshSelectionView.h + +// image subdir +// ItkProgressObserver.h +// SingleImageComponent.h +// itkVTKImageToImageFilter.h +// ImageComponentExtension.h +#include +// ImageOrientationHelper.h +// itkImageToVTKImageFilter.h + +// imageacquisition subdir +// ImageAcquisitionComponent.h +// ImageAcquisitionComponentExtension.h + + + + +#endif // PYTHON_BINDINGS_H diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml new file mode 100644 index 0000000000000000000000000000000000000000..1233717a06e73e5d272a04cac38709235c91f0e2 --- /dev/null +++ b/python/PythonBindings.xml @@ -0,0 +1,658 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ApplicationConstructor(%PYSELF, args, &%0); + + + + + PyObject *empty = PyTuple_New(2); + if (!PyTuple_SetItem(empty, 0, PyList_New(0))) + ApplicationConstructor(%PYSELF, empty, &%0); + + + +static void ApplicationConstructor(PyObject* self, PyObject* pyargv, ApplicationWrapper** cptr) { + static int argc; + static char** argv; + PyObject* stringlist = PyTuple_GET_ITEM(pyargv, 0); + if (Shiboken::listToArgcArgv(stringlist, &argc, &argv, "PyCamiTKApp")) { + *cptr = new ApplicationWrapper(argv[0], argc, argv, true, false); + Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); + } +} + + + +// +// this code is greatly inspired by the Michiel de Hoon post on the PyQt mailing list: +// https://riverbankcomputing.com/pipermail/pyqt/2007-July/016512.html +// Read this link for a complete explaination about the mechanism +// +// see also see https://docs.python.org/3/c-api/veryhigh.html +// for an explaination about the function pointer PyOS_InputHook of Python + +#include <QCoreApplication> +#include <QThread> + +#if defined(Q_OS_WIN) +#include <conio.h> +#include <QTimer> +#else +#include <QSocketNotifier> +#endif + +// Declare the hook in the pure C space +extern "C" { + static int backgroundExec(); +} + +/// Run the Qt event loop while there is no keyboard input +static int backgroundExec() { + // check if the application singleton was instanciated in the currentthread + QCoreApplication *app = QCoreApplication::instance(); + + if (app && app->thread() == QThread::currentThread()) { +#if defined(Q_OS_WIN) + // on Windows, sockets are not directly linked to the console stdin as on Unix + // therefore a specific timer is required + QTimer timer; + QObject::connect(&timer, SIGNAL(timeout()), app, SLOT(quit())); + + while (!_kbhit()) { + // Run exec and wait for input + timer.start(50); + QCoreApplication::exec(); + timer.stop(); + } + + QObject::disconnect(&timer, SIGNAL(timeout()), app, SLOT(quit())); +#else + // file descriptor #0 on unix is stdin + QSocketNotifier notifier(0, QSocketNotifier::Read, 0); + QObject::connect(&notifier, SIGNAL(activated(int)), app, SLOT(quit())); + QCoreApplication::exec(); + QObject::disconnect(&notifier, SIGNAL(activated(int)), app, SLOT(quit())); +#endif + } + + return 0; +} + +/// Remove the input hook in Python +static void pyCamiTKStopBackgroundExec() { + PyOS_InputHook = 0; +} + +// Add the input hook in Python +static void pyCamiTKStartBackgroundExec() { + // Restore the input hook. + PyOS_InputHook = backgroundExec; +} + + + + + pyCamiTKStartBackgroundExec(); + + + + + pyCamiTKStopBackgroundExec(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vtkImageData* imageData = cppSelf->getImageData(); + + PyObject *module_name, *module, *dict, *python_class, *object; + module_name = PyUnicode_DecodeFSDefault("vtk"); + module = PyImport_Import(module_name); + + if (module == nullptr) { + PyErr_Print(); + qDebug() << "Fails to import the vtk module."; + return nullptr; + } + Py_DECREF(module_name); + + // dict is a borrowed reference. + dict = PyModule_GetDict(module); + if (dict == nullptr) { + PyErr_Print(); + qDebug() << "Fails to get the dictionary."; + return nullptr; + } + Py_DECREF(module); + + // Builds the name of a callable class + python_class = PyDict_GetItemString(dict, "vtkObjectBase"); + if (python_class == nullptr) { + PyErr_Print(); + qDebug() << "Fails to get the vtkObjectBase Python class."; + return nullptr; + } + Py_DECREF(dict); + + std::ostringstream oss; + oss << (vtkObjectBase*) imageData; // here don't get address + std::string address_str = oss.str(); + qDebug() << "image data at adress: " << QString::fromStdString(address_str); + + // Creates an instance of the class + if (PyCallable_Check(python_class)) { + Shiboken::AutoDecRef args(PyTuple_New(1)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<std::string>(), &address_str)); + + qDebug() << "Calling instanciation"; + object = PyObject_CallObject(python_class, args); + Py_DECREF(python_class); + } else { + qDebug() << "Cannot instantiate the vtkObjectBase Python class"; + Py_DECREF(python_class); + return nullptr; + } + qDebug() << "Calling instanciation done"; + return object; + + + + + + +vtkImageData* cppImageData = nullptr; +// +// Inspired by https://vtk.org/Wiki/Example_from_and_to_python_converters +// +// This python to C++ converter uses the fact that VTK Python objects have an +// attribute called __this__, which is a string containing the memory address +// of the VTK C++ object and its class name. +// E.g. for a vtkPoints object __this__ might be "_0000000105a64420_p_vtkPoints" +// +//qDebug() << "In setVtkImageData"; + +char thisStr[] = "__this__"; +//first we need to get the __this__ attribute from the Python Object +if (!PyObject_HasAttrString(%PYARG_1, thisStr)) { + qDebug() << "PyArg has not string __this__"; + return nullptr; +} + +PyObject* thisAttr = PyObject_GetAttrString(%PYARG_1, thisStr); +if (thisAttr == nullptr) { + qDebug() << "__this__ is null"; + return nullptr; +} + +PyObject* strUTF8 = PyUnicode_AsUTF8String(thisAttr); +if (strUTF8 == nullptr) { + qDebug() << "Cannot convert to UTF8 string"; + return nullptr; +} + +Py_DECREF(thisAttr); +const char* str = PyBytes_AS_STRING(strUTF8); +qDebug() << "VTK __this__ string: \"" << str << "\""; + +char hex_address[32], *pEnd; +const char *_p_ = strstr(str, "_p_vtk"); +if(_p_ == nullptr) { + qDebug() << "Cannot find \"_p_vtk\" ending string"; + return nullptr; +} +const char *class_name = strstr(_p_, "vtk"); +if(class_name == nullptr) { + qDebug() << "Cannot find \"vtk\" ending string"; + return nullptr; +} +strcpy(hex_address, str+1); +hex_address[_p_-str-1] = '\0'; + +long address = strtol(hex_address, &pEnd, 16); + +//qDebug() << "Ptr address is \"" << hex_address << "\""; + +vtkObjectBase* vtk_object = (vtkObjectBase*)((void*)address); +Py_DECREF(strUTF8); + +if(vtk_object->IsA(class_name)) { + //qDebug() << "PyArg converted to vtkObjectBase"; + cppImageData = vtkImageData::SafeDownCast(vtk_object); + //qDebug() << "PyArg converted to vtkImageData"; +} + + + + + // convert the vtkImageData from Python to C++ + + + + + + + + + + + + + // Not %1 but %out + %CPPSELF->replaceImageData(cppImageData, false); + + + + + + + + + + + + + + + + + + diff --git a/python/ShibokenHack.cmake b/python/ShibokenHack.cmake new file mode 100644 index 0000000000000000000000000000000000000000..91096c1d33d260e38e00d5ae16dcdcd12700347c --- /dev/null +++ b/python/ShibokenHack.cmake @@ -0,0 +1,10 @@ +file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/*.cpp) +foreach(WRAPPER_FILE ${CAMITK_PYTHON_GENERATED_SOURCES}) + message(STATUS "Shiboken Hacking: ${WRAPPER_FILE}") + file(READ ${WRAPPER_FILE} WRAPPER_CODE) + # Hack #1: unsigned int returns are not translated properly +# string(REPLACE "unsigned int(0)" "0" WRAPPER_CODE_HACKED_1 "${WRAPPER_CODE}") + # Hack #2: bug with the return type of "const QVector & InterfaceFrameWrapper::getChildrenFrame() const" +# string(REPLACE "::QVector" "QVector" WRAPPER_CODE_HACKED_2 "${WRAPPER_CODE_HACKED_1}") +# file(WRITE ${WRAPPER_FILE} "${WRAPPER_CODE_HACKED_1}") +endforeach() diff --git a/python_sdk/actions/CMakeLists.txt b/python/actions/CMakeLists.txt similarity index 100% rename from python_sdk/actions/CMakeLists.txt rename to python/actions/CMakeLists.txt diff --git a/python_sdk/actions/application/CMakeLists.txt b/python/actions/application/CMakeLists.txt similarity index 100% rename from python_sdk/actions/application/CMakeLists.txt rename to python/actions/application/CMakeLists.txt diff --git a/python_sdk/actions/application/global_sdk_actions_application.h b/python/actions/application/global_sdk_actions_application.h similarity index 100% rename from python_sdk/actions/application/global_sdk_actions_application.h rename to python/actions/application/global_sdk_actions_application.h diff --git a/python_sdk/actions/application/typesystem_sdk_actions_application.xml b/python/actions/application/typesystem_sdk_actions_application.xml similarity index 100% rename from python_sdk/actions/application/typesystem_sdk_actions_application.xml rename to python/actions/application/typesystem_sdk_actions_application.xml diff --git a/python_sdk/actions/global_sdk_actions.h b/python/actions/global_sdk_actions.h similarity index 100% rename from python_sdk/actions/global_sdk_actions.h rename to python/actions/global_sdk_actions.h diff --git a/python_sdk/actions/image/CMakeLists.txt b/python/actions/image/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/CMakeLists.txt rename to python/actions/image/CMakeLists.txt diff --git a/python_sdk/actions/image/arbitraryslice/CMakeLists.txt b/python/actions/image/arbitraryslice/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/arbitraryslice/CMakeLists.txt rename to python/actions/image/arbitraryslice/CMakeLists.txt diff --git a/python_sdk/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h b/python/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h similarity index 100% rename from python_sdk/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h rename to python/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h diff --git a/python_sdk/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml b/python/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml similarity index 100% rename from python_sdk/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml rename to python/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml diff --git a/python_sdk/actions/image/cropvolume/CMakeLists.txt b/python/actions/image/cropvolume/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/cropvolume/CMakeLists.txt rename to python/actions/image/cropvolume/CMakeLists.txt diff --git a/python_sdk/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h b/python/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h similarity index 100% rename from python_sdk/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h rename to python/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h diff --git a/python_sdk/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml b/python/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml similarity index 100% rename from python_sdk/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml rename to python/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml diff --git a/python_sdk/actions/image/global_sdk_actions_image.h b/python/actions/image/global_sdk_actions_image.h similarity index 100% rename from python_sdk/actions/image/global_sdk_actions_image.h rename to python/actions/image/global_sdk_actions_image.h diff --git a/python_sdk/actions/image/imagelut/CMakeLists.txt b/python/actions/image/imagelut/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/imagelut/CMakeLists.txt rename to python/actions/image/imagelut/CMakeLists.txt diff --git a/python_sdk/actions/image/imagelut/global_sdk_actions_image_imagelut.h b/python/actions/image/imagelut/global_sdk_actions_image_imagelut.h similarity index 100% rename from python_sdk/actions/image/imagelut/global_sdk_actions_image_imagelut.h rename to python/actions/image/imagelut/global_sdk_actions_image_imagelut.h diff --git a/python_sdk/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml b/python/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml similarity index 100% rename from python_sdk/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml rename to python/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml diff --git a/python_sdk/actions/image/multipicking/CMakeLists.txt b/python/actions/image/multipicking/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/multipicking/CMakeLists.txt rename to python/actions/image/multipicking/CMakeLists.txt diff --git a/python_sdk/actions/image/multipicking/global_sdk_actions_image_multipicking.h b/python/actions/image/multipicking/global_sdk_actions_image_multipicking.h similarity index 100% rename from python_sdk/actions/image/multipicking/global_sdk_actions_image_multipicking.h rename to python/actions/image/multipicking/global_sdk_actions_image_multipicking.h diff --git a/python_sdk/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml b/python/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml similarity index 100% rename from python_sdk/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml rename to python/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml diff --git a/python_sdk/actions/image/reconstruction/CMakeLists.txt b/python/actions/image/reconstruction/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/reconstruction/CMakeLists.txt rename to python/actions/image/reconstruction/CMakeLists.txt diff --git a/python_sdk/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h b/python/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h similarity index 100% rename from python_sdk/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h rename to python/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h diff --git a/python_sdk/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml b/python/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml similarity index 100% rename from python_sdk/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml rename to python/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml diff --git a/python_sdk/actions/image/showin3d/CMakeLists.txt b/python/actions/image/showin3d/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/showin3d/CMakeLists.txt rename to python/actions/image/showin3d/CMakeLists.txt diff --git a/python_sdk/actions/image/showin3d/global_sdk_actions_image_showin3d.h b/python/actions/image/showin3d/global_sdk_actions_image_showin3d.h similarity index 100% rename from python_sdk/actions/image/showin3d/global_sdk_actions_image_showin3d.h rename to python/actions/image/showin3d/global_sdk_actions_image_showin3d.h diff --git a/python_sdk/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml b/python/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml similarity index 100% rename from python_sdk/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml rename to python/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml diff --git a/python_sdk/actions/image/typesystem_sdk_actions_image.xml b/python/actions/image/typesystem_sdk_actions_image.xml similarity index 100% rename from python_sdk/actions/image/typesystem_sdk_actions_image.xml rename to python/actions/image/typesystem_sdk_actions_image.xml diff --git a/python_sdk/actions/image/volumerendering/CMakeLists.txt b/python/actions/image/volumerendering/CMakeLists.txt similarity index 100% rename from python_sdk/actions/image/volumerendering/CMakeLists.txt rename to python/actions/image/volumerendering/CMakeLists.txt diff --git a/python_sdk/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h b/python/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h similarity index 100% rename from python_sdk/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h rename to python/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h diff --git a/python_sdk/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml b/python/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml similarity index 100% rename from python_sdk/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml rename to python/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml diff --git a/python_sdk/actions/mesh/CMakeLists.txt b/python/actions/mesh/CMakeLists.txt similarity index 100% rename from python_sdk/actions/mesh/CMakeLists.txt rename to python/actions/mesh/CMakeLists.txt diff --git a/python_sdk/actions/mesh/basicmesh/CMakeLists.txt b/python/actions/mesh/basicmesh/CMakeLists.txt similarity index 100% rename from python_sdk/actions/mesh/basicmesh/CMakeLists.txt rename to python/actions/mesh/basicmesh/CMakeLists.txt diff --git a/python_sdk/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h b/python/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h similarity index 100% rename from python_sdk/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h rename to python/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h diff --git a/python_sdk/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml b/python/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml similarity index 100% rename from python_sdk/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml rename to python/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml diff --git a/python_sdk/actions/mesh/basictopology/CMakeLists.txt b/python/actions/mesh/basictopology/CMakeLists.txt similarity index 100% rename from python_sdk/actions/mesh/basictopology/CMakeLists.txt rename to python/actions/mesh/basictopology/CMakeLists.txt diff --git a/python_sdk/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h b/python/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h similarity index 100% rename from python_sdk/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h rename to python/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h diff --git a/python_sdk/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml b/python/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml similarity index 100% rename from python_sdk/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml rename to python/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml diff --git a/python_sdk/actions/mesh/global_sdk_actions_mesh.h b/python/actions/mesh/global_sdk_actions_mesh.h similarity index 100% rename from python_sdk/actions/mesh/global_sdk_actions_mesh.h rename to python/actions/mesh/global_sdk_actions_mesh.h diff --git a/python_sdk/actions/mesh/meshprocessing/CMakeLists.txt b/python/actions/mesh/meshprocessing/CMakeLists.txt similarity index 100% rename from python_sdk/actions/mesh/meshprocessing/CMakeLists.txt rename to python/actions/mesh/meshprocessing/CMakeLists.txt diff --git a/python_sdk/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h b/python/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h similarity index 100% rename from python_sdk/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h rename to python/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h diff --git a/python_sdk/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml b/python/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml similarity index 100% rename from python_sdk/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml rename to python/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml diff --git a/python_sdk/actions/mesh/typesystem_sdk_actions_mesh.xml b/python/actions/mesh/typesystem_sdk_actions_mesh.xml similarity index 100% rename from python_sdk/actions/mesh/typesystem_sdk_actions_mesh.xml rename to python/actions/mesh/typesystem_sdk_actions_mesh.xml diff --git a/python_sdk/actions/typesystem_sdk_actions.xml b/python/actions/typesystem_sdk_actions.xml similarity index 100% rename from python_sdk/actions/typesystem_sdk_actions.xml rename to python/actions/typesystem_sdk_actions.xml diff --git a/python_sdk/applications/CMakeLists.txt b/python/applications/CMakeLists.txt similarity index 100% rename from python_sdk/applications/CMakeLists.txt rename to python/applications/CMakeLists.txt diff --git a/python_sdk/applications/actionstatemachine/CMakeLists.txt b/python/applications/actionstatemachine/CMakeLists.txt similarity index 100% rename from python_sdk/applications/actionstatemachine/CMakeLists.txt rename to python/applications/actionstatemachine/CMakeLists.txt diff --git a/python_sdk/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h b/python/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h similarity index 100% rename from python_sdk/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h rename to python/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h diff --git a/python_sdk/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml b/python/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml similarity index 100% rename from python_sdk/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml rename to python/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml diff --git a/python_sdk/applications/config/CMakeLists.txt b/python/applications/config/CMakeLists.txt similarity index 100% rename from python_sdk/applications/config/CMakeLists.txt rename to python/applications/config/CMakeLists.txt diff --git a/python_sdk/applications/config/global_sdk_applications_config.h b/python/applications/config/global_sdk_applications_config.h similarity index 100% rename from python_sdk/applications/config/global_sdk_applications_config.h rename to python/applications/config/global_sdk_applications_config.h diff --git a/python_sdk/applications/config/typesystem_sdk_applications_config.xml b/python/applications/config/typesystem_sdk_applications_config.xml similarity index 100% rename from python_sdk/applications/config/typesystem_sdk_applications_config.xml rename to python/applications/config/typesystem_sdk_applications_config.xml diff --git a/python_sdk/applications/global_sdk_applications.h b/python/applications/global_sdk_applications.h similarity index 100% rename from python_sdk/applications/global_sdk_applications.h rename to python/applications/global_sdk_applications.h diff --git a/python_sdk/applications/imp/CMakeLists.txt b/python/applications/imp/CMakeLists.txt similarity index 100% rename from python_sdk/applications/imp/CMakeLists.txt rename to python/applications/imp/CMakeLists.txt diff --git a/python_sdk/applications/imp/global_sdk_applications_imp.h b/python/applications/imp/global_sdk_applications_imp.h similarity index 100% rename from python_sdk/applications/imp/global_sdk_applications_imp.h rename to python/applications/imp/global_sdk_applications_imp.h diff --git a/python_sdk/applications/imp/typesystem_sdk_applications_imp.xml b/python/applications/imp/typesystem_sdk_applications_imp.xml similarity index 100% rename from python_sdk/applications/imp/typesystem_sdk_applications_imp.xml rename to python/applications/imp/typesystem_sdk_applications_imp.xml diff --git a/python_sdk/applications/typesystem_sdk_applications.xml b/python/applications/typesystem_sdk_applications.xml similarity index 100% rename from python_sdk/applications/typesystem_sdk_applications.xml rename to python/applications/typesystem_sdk_applications.xml diff --git a/python_sdk/applications/wizard/CMakeLists.txt b/python/applications/wizard/CMakeLists.txt similarity index 100% rename from python_sdk/applications/wizard/CMakeLists.txt rename to python/applications/wizard/CMakeLists.txt diff --git a/python_sdk/applications/wizard/global_sdk_applications_wizard.h b/python/applications/wizard/global_sdk_applications_wizard.h similarity index 100% rename from python_sdk/applications/wizard/global_sdk_applications_wizard.h rename to python/applications/wizard/global_sdk_applications_wizard.h diff --git a/python_sdk/applications/wizard/typesystem_sdk_applications_wizard.xml b/python/applications/wizard/typesystem_sdk_applications_wizard.xml similarity index 100% rename from python_sdk/applications/wizard/typesystem_sdk_applications_wizard.xml rename to python/applications/wizard/typesystem_sdk_applications_wizard.xml diff --git a/python_sdk/components/CMakeLists.txt b/python/components/CMakeLists.txt similarity index 100% rename from python_sdk/components/CMakeLists.txt rename to python/components/CMakeLists.txt diff --git a/python_sdk/components/global_sdk_components.h b/python/components/global_sdk_components.h similarity index 100% rename from python_sdk/components/global_sdk_components.h rename to python/components/global_sdk_components.h diff --git a/python_sdk/components/msh/CMakeLists.txt b/python/components/msh/CMakeLists.txt similarity index 100% rename from python_sdk/components/msh/CMakeLists.txt rename to python/components/msh/CMakeLists.txt diff --git a/python_sdk/components/msh/global_sdk_components_msh.h b/python/components/msh/global_sdk_components_msh.h similarity index 100% rename from python_sdk/components/msh/global_sdk_components_msh.h rename to python/components/msh/global_sdk_components_msh.h diff --git a/python_sdk/components/msh/typesystem_sdk_components_msh.xml b/python/components/msh/typesystem_sdk_components_msh.xml similarity index 100% rename from python_sdk/components/msh/typesystem_sdk_components_msh.xml rename to python/components/msh/typesystem_sdk_components_msh.xml diff --git a/python_sdk/components/obj/CMakeLists.txt b/python/components/obj/CMakeLists.txt similarity index 100% rename from python_sdk/components/obj/CMakeLists.txt rename to python/components/obj/CMakeLists.txt diff --git a/python_sdk/components/obj/global_sdk_components_obj.h b/python/components/obj/global_sdk_components_obj.h similarity index 100% rename from python_sdk/components/obj/global_sdk_components_obj.h rename to python/components/obj/global_sdk_components_obj.h diff --git a/python_sdk/components/obj/typesystem_sdk_components_obj.xml b/python/components/obj/typesystem_sdk_components_obj.xml similarity index 100% rename from python_sdk/components/obj/typesystem_sdk_components_obj.xml rename to python/components/obj/typesystem_sdk_components_obj.xml diff --git a/python_sdk/components/off/CMakeLists.txt b/python/components/off/CMakeLists.txt similarity index 100% rename from python_sdk/components/off/CMakeLists.txt rename to python/components/off/CMakeLists.txt diff --git a/python_sdk/components/off/global_sdk_components_off.h b/python/components/off/global_sdk_components_off.h similarity index 100% rename from python_sdk/components/off/global_sdk_components_off.h rename to python/components/off/global_sdk_components_off.h diff --git a/python_sdk/components/off/typesystem_sdk_components_off.xml b/python/components/off/typesystem_sdk_components_off.xml similarity index 100% rename from python_sdk/components/off/typesystem_sdk_components_off.xml rename to python/components/off/typesystem_sdk_components_off.xml diff --git a/python_sdk/components/typesystem_sdk_components.xml b/python/components/typesystem_sdk_components.xml similarity index 100% rename from python_sdk/components/typesystem_sdk_components.xml rename to python/components/typesystem_sdk_components.xml diff --git a/python_sdk/components/vrml/CMakeLists.txt b/python/components/vrml/CMakeLists.txt similarity index 100% rename from python_sdk/components/vrml/CMakeLists.txt rename to python/components/vrml/CMakeLists.txt diff --git a/python_sdk/components/vrml/global_sdk_components_vrml.h b/python/components/vrml/global_sdk_components_vrml.h similarity index 100% rename from python_sdk/components/vrml/global_sdk_components_vrml.h rename to python/components/vrml/global_sdk_components_vrml.h diff --git a/python_sdk/components/vrml/typesystem_sdk_components_vrml.xml b/python/components/vrml/typesystem_sdk_components_vrml.xml similarity index 100% rename from python_sdk/components/vrml/typesystem_sdk_components_vrml.xml rename to python/components/vrml/typesystem_sdk_components_vrml.xml diff --git a/python_sdk/components/vtkimage/CMakeLists.txt b/python/components/vtkimage/CMakeLists.txt similarity index 100% rename from python_sdk/components/vtkimage/CMakeLists.txt rename to python/components/vtkimage/CMakeLists.txt diff --git a/python_sdk/components/vtkimage/global_sdk_components_vtkimage.h b/python/components/vtkimage/global_sdk_components_vtkimage.h similarity index 100% rename from python_sdk/components/vtkimage/global_sdk_components_vtkimage.h rename to python/components/vtkimage/global_sdk_components_vtkimage.h diff --git a/python_sdk/components/vtkimage/typesystem_sdk_components_vtkimage.xml b/python/components/vtkimage/typesystem_sdk_components_vtkimage.xml similarity index 100% rename from python_sdk/components/vtkimage/typesystem_sdk_components_vtkimage.xml rename to python/components/vtkimage/typesystem_sdk_components_vtkimage.xml diff --git a/python_sdk/components/vtkmesh/CMakeLists.txt b/python/components/vtkmesh/CMakeLists.txt similarity index 100% rename from python_sdk/components/vtkmesh/CMakeLists.txt rename to python/components/vtkmesh/CMakeLists.txt diff --git a/python_sdk/components/vtkmesh/global_sdk_components_vtkmesh.h b/python/components/vtkmesh/global_sdk_components_vtkmesh.h similarity index 100% rename from python_sdk/components/vtkmesh/global_sdk_components_vtkmesh.h rename to python/components/vtkmesh/global_sdk_components_vtkmesh.h diff --git a/python_sdk/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml b/python/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml similarity index 100% rename from python_sdk/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml rename to python/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml diff --git a/python_sdk/global_sdk.h b/python/global_sdk.h similarity index 100% rename from python_sdk/global_sdk.h rename to python/global_sdk.h diff --git a/python_sdk/libraries/CMakeLists.txt b/python/libraries/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/CMakeLists.txt rename to python/libraries/CMakeLists.txt diff --git a/python_sdk/libraries/core/CMakeLists.txt b/python/libraries/core/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/CMakeLists.txt rename to python/libraries/core/CMakeLists.txt diff --git a/python_sdk/libraries/core/action/CMakeLists.txt b/python/libraries/core/action/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/action/CMakeLists.txt rename to python/libraries/core/action/CMakeLists.txt diff --git a/python_sdk/libraries/core/action/global_sdk_libraries_core_action.h b/python/libraries/core/action/global_sdk_libraries_core_action.h similarity index 100% rename from python_sdk/libraries/core/action/global_sdk_libraries_core_action.h rename to python/libraries/core/action/global_sdk_libraries_core_action.h diff --git a/python_sdk/libraries/core/action/typesystem_sdk_libraries_core_action.xml b/python/libraries/core/action/typesystem_sdk_libraries_core_action.xml similarity index 100% rename from python_sdk/libraries/core/action/typesystem_sdk_libraries_core_action.xml rename to python/libraries/core/action/typesystem_sdk_libraries_core_action.xml diff --git a/python_sdk/libraries/core/application/CMakeLists.txt b/python/libraries/core/application/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/application/CMakeLists.txt rename to python/libraries/core/application/CMakeLists.txt diff --git a/python_sdk/libraries/core/application/global_sdk_libraries_core_application.h b/python/libraries/core/application/global_sdk_libraries_core_application.h similarity index 100% rename from python_sdk/libraries/core/application/global_sdk_libraries_core_application.h rename to python/libraries/core/application/global_sdk_libraries_core_application.h diff --git a/python_sdk/libraries/core/application/typesystem_sdk_libraries_core_application.xml b/python/libraries/core/application/typesystem_sdk_libraries_core_application.xml similarity index 100% rename from python_sdk/libraries/core/application/typesystem_sdk_libraries_core_application.xml rename to python/libraries/core/application/typesystem_sdk_libraries_core_application.xml diff --git a/python_sdk/libraries/core/component/CMakeLists.txt b/python/libraries/core/component/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/component/CMakeLists.txt rename to python/libraries/core/component/CMakeLists.txt diff --git a/python_sdk/libraries/core/component/global_sdk_libraries_core_component.h b/python/libraries/core/component/global_sdk_libraries_core_component.h similarity index 100% rename from python_sdk/libraries/core/component/global_sdk_libraries_core_component.h rename to python/libraries/core/component/global_sdk_libraries_core_component.h diff --git a/python_sdk/libraries/core/component/image/CMakeLists.txt b/python/libraries/core/component/image/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/component/image/CMakeLists.txt rename to python/libraries/core/component/image/CMakeLists.txt diff --git a/python_sdk/libraries/core/component/image/global_sdk_libraries_core_component_image.h b/python/libraries/core/component/image/global_sdk_libraries_core_component_image.h similarity index 100% rename from python_sdk/libraries/core/component/image/global_sdk_libraries_core_component_image.h rename to python/libraries/core/component/image/global_sdk_libraries_core_component_image.h diff --git a/python_sdk/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml b/python/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml similarity index 100% rename from python_sdk/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml rename to python/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml diff --git a/python_sdk/libraries/core/component/mesh/CMakeLists.txt b/python/libraries/core/component/mesh/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/component/mesh/CMakeLists.txt rename to python/libraries/core/component/mesh/CMakeLists.txt diff --git a/python_sdk/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h b/python/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h similarity index 100% rename from python_sdk/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h rename to python/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h diff --git a/python_sdk/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml b/python/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml similarity index 100% rename from python_sdk/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml rename to python/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml diff --git a/python_sdk/libraries/core/component/typesystem_sdk_libraries_core_component.xml b/python/libraries/core/component/typesystem_sdk_libraries_core_component.xml similarity index 100% rename from python_sdk/libraries/core/component/typesystem_sdk_libraries_core_component.xml rename to python/libraries/core/component/typesystem_sdk_libraries_core_component.xml diff --git a/python_sdk/libraries/core/global_sdk_libraries_core.h b/python/libraries/core/global_sdk_libraries_core.h similarity index 100% rename from python_sdk/libraries/core/global_sdk_libraries_core.h rename to python/libraries/core/global_sdk_libraries_core.h diff --git a/python_sdk/libraries/core/typesystem_sdk_libraries_core.xml b/python/libraries/core/typesystem_sdk_libraries_core.xml similarity index 100% rename from python_sdk/libraries/core/typesystem_sdk_libraries_core.xml rename to python/libraries/core/typesystem_sdk_libraries_core.xml diff --git a/python_sdk/libraries/core/utils/CMakeLists.txt b/python/libraries/core/utils/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/utils/CMakeLists.txt rename to python/libraries/core/utils/CMakeLists.txt diff --git a/python_sdk/libraries/core/utils/global_sdk_libraries_core_utils.h b/python/libraries/core/utils/global_sdk_libraries_core_utils.h similarity index 100% rename from python_sdk/libraries/core/utils/global_sdk_libraries_core_utils.h rename to python/libraries/core/utils/global_sdk_libraries_core_utils.h diff --git a/python_sdk/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml b/python/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml similarity index 100% rename from python_sdk/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml rename to python/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml diff --git a/python_sdk/libraries/core/viewer/CMakeLists.txt b/python/libraries/core/viewer/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/core/viewer/CMakeLists.txt rename to python/libraries/core/viewer/CMakeLists.txt diff --git a/python_sdk/libraries/core/viewer/global_sdk_libraries_core_viewer.h b/python/libraries/core/viewer/global_sdk_libraries_core_viewer.h similarity index 100% rename from python_sdk/libraries/core/viewer/global_sdk_libraries_core_viewer.h rename to python/libraries/core/viewer/global_sdk_libraries_core_viewer.h diff --git a/python_sdk/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml b/python/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml similarity index 100% rename from python_sdk/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml rename to python/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml diff --git a/python_sdk/libraries/coreschema/CMakeLists.txt b/python/libraries/coreschema/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/coreschema/CMakeLists.txt rename to python/libraries/coreschema/CMakeLists.txt diff --git a/python_sdk/libraries/coreschema/global_sdk_libraries_coreschema.h b/python/libraries/coreschema/global_sdk_libraries_coreschema.h similarity index 100% rename from python_sdk/libraries/coreschema/global_sdk_libraries_coreschema.h rename to python/libraries/coreschema/global_sdk_libraries_coreschema.h diff --git a/python_sdk/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml b/python/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml similarity index 100% rename from python_sdk/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml rename to python/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml diff --git a/python_sdk/libraries/global_sdk_libraries.h b/python/libraries/global_sdk_libraries.h similarity index 100% rename from python_sdk/libraries/global_sdk_libraries.h rename to python/libraries/global_sdk_libraries.h diff --git a/python_sdk/libraries/qtpropertybrowser/CMakeLists.txt b/python/libraries/qtpropertybrowser/CMakeLists.txt similarity index 100% rename from python_sdk/libraries/qtpropertybrowser/CMakeLists.txt rename to python/libraries/qtpropertybrowser/CMakeLists.txt diff --git a/python_sdk/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h b/python/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h similarity index 100% rename from python_sdk/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h rename to python/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h diff --git a/python_sdk/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml b/python/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml similarity index 100% rename from python_sdk/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml rename to python/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml diff --git a/python_sdk/libraries/typesystem_sdk_libraries.xml b/python/libraries/typesystem_sdk_libraries.xml similarity index 100% rename from python_sdk/libraries/typesystem_sdk_libraries.xml rename to python/libraries/typesystem_sdk_libraries.xml diff --git a/python/pycamitk.py b/python/pycamitk.py new file mode 100644 index 0000000000000000000000000000000000000000..1b36bb85e147fd8917cd509a6bd4a78fdf06489b --- /dev/null +++ b/python/pycamitk.py @@ -0,0 +1,66 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +# In order to use the console +# Either +# 1) cd to where this script is located and type "import pycamitk" in the python3 console +# or +# 2) type "import sys", "sys.pat.append('/path/to/this/script')", "import pycamitk" in the python3 console + +import sys + +## Add the python subdir in order to be able to load PyCamiTK +sys.path.append('.') +sys.path.append('./lib') +sys.path.append('/usr/local/lib') + +## list CamiTK python bindings exported classes +from PyCamiTK import camitk + +from PySide2.QtCore import Qt, QTimer # for Qt.LeftDockWidgetArea +from PySide2.QtWidgets import QApplication, QAction, QMenu, QMainWindow + +print("Setting log...") + +camitk.Log.getLogger().setTimeStampInformation(True) +camitk.Log.getLogger().setMessageBoxLevel(camitk.InterfaceLogger.NONE) +camitk.Log.getLogger().setLogLevel(camitk.InterfaceLogger.TRACE) + +print("CamiTK version: " + camitk.Core.version) + +app = camitk.Application(sys.argv) +app.getMainWindow().setCentralViewer(camitk.MedicalImageViewer.getInstance()) +app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.Explorer.getInstance()) +app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.PropertyExplorer.getInstance()) +app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.ActionViewer.getInstance()) + +fileMenu = QMenu("&File"); +action = camitk.Application.getAction("Open") +fileMenu.addAction(action.getQAction()) +action = camitk.Application.getAction("Close") +fileMenu.addAction(action.getQAction()) +action= camitk.Application.getAction("Quit") +fileMenu.addAction(action.getQAction()) + +## help +helpMenu = QMenu("&Help") +action = camitk.Application.getAction("About...") +helpMenu.addAction(action.getQAction()) + +## add everything in the menu bar +mainWindow = app.getMainWindow() +appMenuBar = mainWindow.menuBar() +appMenuBar.addMenu(fileMenu) +appMenuBar.addSeparator() +appMenuBar.addMenu(helpMenu) + +# show and start exec loop +app.getMainWindow().show() +app.startBackgroundExec() + +print(camitk.Core.getConfig()) + +print("You can start interacting using PyCamiTK:") +print("from PyCamiTK import camitk") +print("comp = camitk.Application.open(camitk.Core.getTestDataDir() + \"/brain.mha\")") + diff --git a/python_sdk/pyside_global.h b/python/pyside_global.h similarity index 100% rename from python_sdk/pyside_global.h rename to python/pyside_global.h diff --git a/python/test.py b/python/test.py new file mode 100644 index 0000000000000000000000000000000000000000..0df0613325b877f816a58bd748234a1da6366243 --- /dev/null +++ b/python/test.py @@ -0,0 +1,236 @@ +#!/usr/bin/python3 +# +# In order to debug a core dump, use: +# gdb python3 core +# and then issue the "where" command +# +# debug +# python3 -m pdb ../src/camitk/python/test.py +# +# Another example is to transfer numpy to VTK +# see https://pyscience.wordpress.com/2014/09/06/numpy-to-vtk-converting-your-numpy-arrays-to-vtk-arrays-and-files/ +# It points out to pyvtk, which is a example of numpy export to VTK +# https://bitbucket.org/somada141/pyevtk/src/08f37a46fadc?at=default +# +import traceback + +# Add the python subdir in order to be able to load PyCamiTK +import sys +sys.path.append('.') +sys.path.append('./lib') + +# list CamiTK python bindings exported classes +from PyCamiTK import camitk +dir(camitk) + +#app = camitk.Application(sys.argv) +#mw = camitk.MainWindow("Python MainWindow") + +#print("CamiTK path:\n" + camitk.Core.getPaths()) +#print("CamiTK config:\n" + camitk.Core.getConfig()) + +#class MyApp(camitk.Application): + #def __init__(self): + #camitk.Application.__init__(self) +import vtk +import math +from PySide2.QtCore import Qt # for Qt.LeftDockWidgetArea +from PySide2.QtWidgets import QMenu + +# Inspired by https://stackoverflow.com/a/46626448 +from vtk.util import vtkImageImportFromArray as vtkutil +import numpy as np + +def generateSphere(imageDimension): + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + return f.GetOutput() + + +if __name__ == "__main__": + print("\nTry...\n") + try: + print("Setting log...") + + camitk.Log.getLogger().setTimeStampInformation(True) + camitk.Log.getLogger().setMessageBoxLevel(camitk.InterfaceLogger.NONE) + camitk.Log.getLogger().setLogLevel(camitk.InterfaceLogger.TRACE) + + print("CamiTK version: " + camitk.Core.version) + + app = camitk.Application(sys.argv) + app.getMainWindow().setCentralViewer(camitk.MedicalImageViewer.getInstance()) + app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.Explorer.getInstance()) + app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.PropertyExplorer.getInstance()) + app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.ActionViewer.getInstance()) + + + fileMenu = QMenu("&File"); + action = camitk.Application.getAction("Open") + fileMenu.addAction(action.getQAction()) + action = camitk.Application.getAction("Close") + fileMenu.addAction(action.getQAction()) + action= camitk.Application.getAction("Quit") + fileMenu.addAction(action.getQAction()) + + # help + helpMenu = QMenu("&Help") + action = camitk.Application.getAction("About...") + helpMenu.addAction(action.getQAction()) + + # add everything in the menu bar + mainWindow = app.getMainWindow() + appMenuBar = mainWindow.menuBar() + appMenuBar.addMenu(fileMenu) + appMenuBar.addSeparator() + appMenuBar.addMenu(helpMenu) + + print("Class name:" + app.metaObject().className()) + print("Starting application: \"" + app.getName() + "\"") + print("Is there any modified components: " + str(app.hasModified())) + print("Arguments: " + str(app.arguments())) + print("Testdata dir:" + camitk.Core.getTestDataDir()) + print("Platform name: " + app.platformName()) + print("Main window is: " + str(app.getMainWindow())) + #print("Font: " + str(app.font())) + + comp = camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") + + + #print("Name of component: " + comp.getName()) + + #imageDimension = eval(comp.property("Image Dimensions")) # dim + #print("Original image dimension: " + str(imageDimension)) + #print("Voxel type: " + comp.property("Voxel Data Type")) + + ##imageData = vtk.vtkImageData() + ##imageData.SetDimensions(dim[0], dim[1], dim[2]) + ##imageData.AllocateScalars(vtk.VTK_UNSIGNED_CHAR, 1) + + ##dims = imageData.GetDimensions() + ##radius = math.sqrt(dims[2]*dims[2] + dims[1]*dims[1] + dims[0]*dims[0])/4.0 + ##print("Image half size radius:" + str(radius)) + ##halfDims = [x / 2 for x in dims] + + ## Fill every entry of the image data with '2.0' + ##inside = 0 + ##outside = 1 + ##i = 0 + ##for z in range(dims[2]): + ##for y in range(dims[1]): + ##for x in range(dims[0]): + ##pos = [x-halfDims[0],y-halfDims[1],z-halfDims[2]] + ##posSquare = math.sqrt(pos[2]*pos[2] + pos[1]*pos[1] + pos[0]*pos[0]) + ##if (posSquare < radius): + ##inside+=1 + ##value = -127.0 + ##else: + ##outside+=1 + ##value = 127.0 + ##i+=1 + ###imageData.SetScalarComponentFromDouble(x, y, z, 0, value) + ##imageData.GetPointData().GetScalars().SetTuple1(i, value) + ###imageData.SetScalarComponentFromDouble(x, y, z, 0, 42.0) + + + ##imageData = generateSphere(imageDimension) + + ## compute radius and center from imageDimension + #radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + #center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + ## 3D array + #semisizes = (radius,) * 3 + + ## generate the grid for the support points + ## centered at the position indicated by center + #grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + #center = np.ogrid[grid] + ## calculate the distance of all points from center + ## scaled by the radius + #arr = np.zeros(imageDimension, dtype=float) + #for x_i, semisize in zip(center, semisizes): + #arr += (np.abs(x_i / semisize) ** 2) + ## the inner part of the sphere will have distance below 1 + ##return arr <= 1.0 + + ## generate vtkImage from an array + #f = vtkutil.vtkImageImportFromArray() + #f.SetArray( arr ) + ##f.SetDataOrigin( ... ) + ##f.SetDataSpacing( ... ) + ##f.SetDataExtent( ... ) + #f.Update() + #imageData = f.GetOutput() + + ##print("inside=" + str(inside) + ", outside=" + str(outside) + ", inside/outside=" + str(inside/outside)) + ##print("imageData=" + str(imageData)) + #print("imageData.__this__=" + str(imageData.__this__)) +##print("comp=" + str(comp)) + + #backupImageData = comp.getImageData() + #print("backup image data =" + str(backupImageData)) + + #comp.replaceImageData(imageData) #setVtkImageData + + ## add a new component + + + + #print("Number of opened top level components: " + str(len(app.getTopLevelComponents()))) + + #comp.setSelected(True) + app.refresh() + sys.exit(app.exec_()) + + except Exception: + print(traceback.format_exc()) + # or + print(sys.exc_info()[0]) + +#from PySide2.QtWidgets import QApplication, QLabel + +#if __name__ == "__main__": + #app = QApplication(sys.argv) + #label = QLabel("Hello World") + #label.show() + #sys.exit(app.exec_()) + +# Minimal +# import sys +# sys.path.append('.') +# sys.path.append('./python') +# from PyCamiTK import camitk +# app = camitk.Application(sys.argv) + +#fileMenu = QMenu("&Python"); +#action = camitk.Application.getAction("Open") +#fileMenu.addAction(action.getQAction()) +#mainWindow = app.getMainWindow() +#appMenuBar = mainWindow.menuBar() +#appMenuBar.addMenu(fileMenu) + diff --git a/python_sdk/typesystem_sdk.xml b/python/typesystem_sdk.xml similarity index 95% rename from python_sdk/typesystem_sdk.xml rename to python/typesystem_sdk.xml index 9649581ce170fbe8cc91817c21a2d8b9e9caf4e0..c79a810837ff12db1f52ff15a33d2e88a6779498 100644 --- a/python_sdk/typesystem_sdk.xml +++ b/python/typesystem_sdk.xml @@ -1,8 +1,9 @@ - + + diff --git a/python_sdk/CMakeLists.txt b/python_sdk/CMakeLists.txt deleted file mode 100644 index daa3666f0afaff6166d8d0aeb7487bf4a1a00f7a..0000000000000000000000000000000000000000 --- a/python_sdk/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -#-------------------------------------------- -# -# CamiTK SDK Python binding -# -# Do not edit this file, unless -# you really (really!) know -# what you're doing -# -#-------------------------------------------- - - -#-------------------------------------------- -# -# Python binding requirements -# -#-------------------------------------------- -# First of all needs : Python -find_package(PythonLibs REQUIRED) -# Then the Shiboken tool, the PySide team C++ to Python wrapper -find_package(Shiboken REQUIRED) -find_program(CAMITK_BINDING_PYTHON_GENERATOR shiboken REQUIRED) -if (NOT CAMITK_BINDING_PYTHON_GENERATOR) - message(FATAL_ERROR "Please add Shiboken binary in your PATH or manually point to it using the CAMITK_BINDING_PYTHON_GENERATOR variable") -endif() - -# And of course Qt and PySide, the Python binding of Qt (4.8) using Shiboken. -find_package(Qt4 REQUIRED) -find_package(PySide REQUIRED) - -# TEST Using VTK dependency -find_package(VTK REQUIRED) - -#-------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#-------------------------------------------- -# Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# include subdirectories -add_subdirectory(actions) -add_subdirectory(applications) -add_subdirectory(components) -add_subdirectory(libraries) - -# TODO : Remove once debugged -# message(WARNING "PYSIDE_INCLUDE_DIR = ${PYSIDE_INCLUDE_DIR}") -# message(WARNING "SHIBOKEN_TYPESYSTEM_PATH = ${SHIBOKEN_TYPESYSTEM_PATH}") -# message(WARNING "SHIBOKEN_GLOBAL_H_PATH = ${SHIBOKEN_GLOBAL_H_PATH}") -# message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") -# message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") -# message(WARNING "SHIBOKEN_CAMITK_SDK_PATH = ${SHIBOKEN_CAMITK_SDK_PATH}") -# message(WARNING "VTK_INCLUDE_DIRS = ${VTK_INCLUDE_DIRS}") - -#-------------------------------------------- -# -# Custom CMake Python binding targets -# -#-------------------------------------------- -# Shiboken specific paths -set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN - ${PYSIDE_INCLUDE_DIR}:${PYSIDE_INCLUDE_DIR}/QtCore:${PYSIDE_INCLUDE_DIR}/QtGui - #:${PYSIDE_INCLUDE_DIR}/QtHelp:${PYSIDE_INCLUDE_DIR}/QtNetwork:${PYSIDE_INCLUDE_DIR}/QtOpenGL:${PYSIDE_INCLUDE_DIR}/QtScript:${PYSIDE_INCLUDE_DIR}/QtScriptTools:${PYSIDE_INCLUDE_DIR}/QtSql:${PYSIDE_INCLUDE_DIR}/QtSvg:${PYSIDE_INCLUDE_DIR}/QtTest:${PYSIDE_INCLUDE_DIR}/QtUiTools:${PYSIDE_INCLUDE_DIR}/QtWebKit:${PYSIDE_INCLUDE_DIR}/QtXml:${PYSIDE_INCLUDE_DIR}/QtXmlPatterns:${PYSIDE_INCLUDE_DIR}/QtDeclarative -) - -# TODO : Remove once debugged -# message(WARNING "PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN = ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}") - -# Wrap the CamiTK SDK. Wrapping uses Shiboken (PySide binding tool) -# It means it decorates the specified C++ classes to Python by adding -# information in order to convert it into a CPython extension -# Shiboken parses the typesystem.xml files to detect which C++ classes to expose to Python -# For each of them, it create a CPython C++ decorated class in the build directory -add_custom_target( camitk-sdk-wrap-to-python -# OUTPUT ${lib_python_SRC} - COMMAND ${CMAKE_COMMAND} -E echo "Cleaning C++ classes generated from previous wrapping." - COMMAND ${CMAKE_COMMAND} -E remove_directory camitk_sdk - COMMAND ${CMAKE_COMMAND} -E echo "Wrapping CamiTK SDK for Python exposure." - COMMAND ${CAMITK_BINDING_PYTHON_GENERATOR} --enable-parent-ctor-heuristic --enable-return-value-heuristic --enable-pyside-extensions #--debug-level=full - ${CMAKE_CURRENT_SOURCE_DIR}/global_sdk.h - --include-paths=${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_SDK_PATH}:${VTK_INCLUDE_DIRS} - --typesystem-paths=${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} - --output-directory=${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sdk.xml -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -# COMMENT "Running generator for ${PROJECT_NAME}:" - COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK wrapped." - ) - -# The resulting C++ wrapped classes will be listed in the following CMake variable: -file(GLOB_RECURSE SDK_WRAPPED_CLASSES ${CMAKE_BINARY_DIR}/python_sdk/camitk_sdk/*.cpp ) - -# We list the CamiTK SDK generated dynamic libraries for linking the python package -# TODO do not manually list those libraries, but dynamically create this list at configuration -# step, using CamiTK CMake macros -file(GLOB_RECURSE CAMITK_SDK_LIBRARIES ${CMAKE_BINARY_DIR}/*.so) -# message(WARNING "CAMITK_SDK_LIBRARIES = ${CAMITK_SDK_LIBRARIES}") - -# This CMake target aims at compiling the C++ Python-wrapped classes of CamiTK and link them against -# the original CamiTK SDK libraries. -# WARNING Do not manually run this target, it requires another configure step wich is run by the camitk-sdk-package-to-python -# CMake target. -if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create camitk_sdk target if camitk sdk has been wrapped - set(PROJECT_NAME camitk_sdk) # the name of the camitk sdk package once compiled - string(REPLACE ":" ";" CAMITK_SDK_INCLUDE_DIR ${SHIBOKEN_CAMITK_SDK_PATH}) # deduce the list of include directories of CamiTK SDK - string(REPLACE ":" ";" PYSIDE_INCLUDE_ALL_DIR ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}) #deduce the list of include directories provided from PySide / Shiboken - # Qt libraries dependencies - set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}") -# message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}") - set(CAMITK_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sdk/libraries/core - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/mesh/basicmesh - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/arbitraryslice ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/cropvolume - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/imagelut - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/multipicking ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/reconstruction - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/volumerendering - ) #build directories required for ui wrapping includes ! - - include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CAMITK_BUILD_DIR}) - add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) - # # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") - set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") - target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${CAMITK_SDK_LIBRARIES}) - # WARNING check VTK dependency -# message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") -# message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") - # add_dependencies(${PROJECT_NAME} camitkcore) -endif() - - -# Create the Python package of CamiTK SDK -# This package is compiled from the generated C++ classes of the camitk-sdk-wrap-to-python target -# and link against the CamiTK SDK libraries. -# Build the custom camitk-sdk-package-to-python target in order to compile the wrapped C++ classes and link against -# CamiTK SDK dynamic libraries. -add_custom_target( camitk-sdk-package-to-python - COMMAND ${CMAKE_COMMAND} -E echo "Creating Python package of CamiTK SDK." - COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target camitk_sdk - COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." - ) -add_dependencies(camitk-sdk-package-to-python camitk-sdk-wrap-to-python) # need to wrapp before creating the package diff --git a/sdk/actions/application/CloseAction.cpp b/sdk/actions/application/CloseAction.cpp index 23142ee828c89baecd04c9bfb534b30168d75227..4dea6552916509b02c6019c97b6cd2f007bc6755 100644 --- a/sdk/actions/application/CloseAction.cpp +++ b/sdk/actions/application/CloseAction.cpp @@ -62,18 +62,19 @@ Action::ApplyStatus CloseAction::apply() { QSet allTopLevel; // fill the toplevel component set - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { allTopLevel.insert(comp->getTopLevelComponent()); } - // close all - QSet::const_iterator it = allTopLevel.constBegin(); - - while (it != allTopLevel.constEnd() && Application::close(*it)) { - it++; + // close 'em all + ComponentList allUniqueTopLevel = allTopLevel.toList(); + bool continueClosing = true; + while (continueClosing && allUniqueTopLevel.size() > 0) { + Component* comp = allUniqueTopLevel.takeFirst(); + continueClosing = Application::close(comp); } - - if (it == allTopLevel.constEnd()) { + + if (continueClosing) { return SUCCESS; } else { diff --git a/sdk/actions/application/OpenAction.cpp b/sdk/actions/application/OpenAction.cpp index db022c88e67b918db27f0f35f0ed990a114059b6..559c660201051756bb5e1bd28829c3c65c17142f 100644 --- a/sdk/actions/application/OpenAction.cpp +++ b/sdk/actions/application/OpenAction.cpp @@ -73,7 +73,7 @@ Action::ApplyStatus OpenAction::apply() { filter += QString("All known files (*.") + ExtensionManager::getFileExtensions().join(" *.") + ");;"; // add the extension of loaded and valid plugins - foreach (ComponentExtension* ext, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* ext : ExtensionManager::getComponentExtensionsList()) { filter += ext->getName() + " (*." + ext->getFileExtensions().join(" *.") + ");;"; } diff --git a/sdk/actions/application/OpenFile.cpp b/sdk/actions/application/OpenFile.cpp index 8e50d66c57f804a2e78784b02b770b86be1de09d..a8cd6eecfed5b56ac227c425b71a973e27b60517 100644 --- a/sdk/actions/application/OpenFile.cpp +++ b/sdk/actions/application/OpenFile.cpp @@ -136,7 +136,7 @@ void OpenFile::selectFile() { filter += QString("All known files (*.") + ExtensionManager::getFileExtensions().join(" *.") + ");;"; // add the extension of loaded and valid plugins - foreach (ComponentExtension* ext, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* ext : ExtensionManager::getComponentExtensionsList()) { filter += ext->getName() + " (*." + ext->getFileExtensions().join(" *.") + ");;"; } diff --git a/sdk/actions/application/SaveAction.cpp b/sdk/actions/application/SaveAction.cpp index cf610bc377cf256ca4e01105507c802796c6846c..ae1430aedbba47e2ce18e22c1823539da71cbfc9 100644 --- a/sdk/actions/application/SaveAction.cpp +++ b/sdk/actions/application/SaveAction.cpp @@ -62,7 +62,7 @@ QWidget* SaveAction::getWidget() { Action::ApplyStatus SaveAction::apply() { QSet allTopLevel; // fill the toplevel component set - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { allTopLevel.insert(comp->getTopLevelComponent()); } diff --git a/sdk/actions/application/SaveAsAction.cpp b/sdk/actions/application/SaveAsAction.cpp index b3b754d148333ca46d811292f7cc0a5517c6ce74..1dbb6f030b9e56e1915b85120a0828b7a77088f5 100644 --- a/sdk/actions/application/SaveAsAction.cpp +++ b/sdk/actions/application/SaveAsAction.cpp @@ -82,7 +82,7 @@ Action::ApplyStatus SaveAsAction::apply() { // if no extension is found, look for the export of plugins which write directories if (!compfileName.isEmpty() && extension.isEmpty() && comp->isTopLevel()) { - foreach (QString cpName, ExtensionManager::getDataDirectoryExtNames()) { + for (QString cpName :ExtensionManager::getDataDirectoryExtNames()) { const ComponentExtension* cp = ExtensionManager::getComponentExtension(cpName); filter += cpName + cp->getFileExtensions().join(" "); } @@ -92,12 +92,12 @@ Action::ApplyStatus SaveAsAction::apply() { const ImageComponent* compAsImg = dynamic_cast(comp); if (compAsImg) { - foreach (ComponentExtension* pl, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* pl : ExtensionManager::getComponentExtensionsList()) { const ImageComponentExtension* imageExt = dynamic_cast(pl); if (imageExt) { QString imgFilter = imageExt->getName() + " ("; - foreach (QString ext, imageExt->getFileExtensions()) { + for (QString ext : imageExt->getFileExtensions()) { imgFilter += "*." + ext + " "; } imgFilter += ")"; @@ -110,12 +110,12 @@ Action::ApplyStatus SaveAsAction::apply() { const MeshComponent* compAsMesh = dynamic_cast(comp); if (compAsMesh) { - foreach (ComponentExtension* pl, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* pl : ExtensionManager::getComponentExtensionsList()) { const ComponentExtension* meshExt = dynamic_cast(pl); if (meshExt) { QString meshFilter = meshExt->getName() + " ("; - foreach (QString ext, meshExt->getFileExtensions()) { + for (QString ext : meshExt->getFileExtensions()) { meshFilter += "*." + ext + " "; } meshFilter += ")"; @@ -126,7 +126,7 @@ Action::ApplyStatus SaveAsAction::apply() { else { // the selected component is neither ImageComponent or MeshComponent, just // ask the component that instantiated it - foreach (QString ext, ExtensionManager::getComponentExtension(extension)->getFileExtensions()) { + for (QString ext : ExtensionManager::getComponentExtension(extension)->getFileExtensions()) { filter += ExtensionManager::getComponentExtension(ext)->getName() + " (*." + ext + ")"; } } diff --git a/sdk/actions/application/SelectLastInstantiatedAction.cpp b/sdk/actions/application/SelectLastInstantiatedAction.cpp index a7302f7af2f133cdc2d64695d263cc713ad81cf0..e6be37799642bdcde796de6bb5692da4426a96eb 100644 --- a/sdk/actions/application/SelectLastInstantiatedAction.cpp +++ b/sdk/actions/application/SelectLastInstantiatedAction.cpp @@ -27,6 +27,7 @@ // CamiTK #include #include +#include using namespace camitk; diff --git a/sdk/actions/frame/editframes/FrameEditor.cpp b/sdk/actions/frame/editframes/FrameEditor.cpp index c6b9de37382ac09303190897b8c1bfb7afea073c..e8f115bcb3b403e42128a1f1b8ae54532cc97bed 100644 --- a/sdk/actions/frame/editframes/FrameEditor.cpp +++ b/sdk/actions/frame/editframes/FrameEditor.cpp @@ -169,7 +169,7 @@ void FrameEditor::initializeDialogWithCurrentComponent() { ui.parentFrameComboBox->clear(); ui.parentFrameComboBox->addItem("World"); ComponentList allComps = Application::getAllComponents(); - foreach (Component* comp, allComps) { + for (Component* comp : allComps) { if (comp != currentComponent) { ui.parentFrameComboBox->addItem(comp->getName()); } diff --git a/sdk/actions/image/imageresampling/ResampleAction.cpp b/sdk/actions/image/imageresampling/ResampleAction.cpp index 3b986b2a1bf036bfcbe9575417a2c46b990b5164..92df4987907fc07c9b8d5133b393c42323cfc3f1 100644 --- a/sdk/actions/image/imageresampling/ResampleAction.cpp +++ b/sdk/actions/image/imageresampling/ResampleAction.cpp @@ -79,7 +79,7 @@ ResampleAction::~ResampleAction() { // --------------- apply ------------------- Action::ApplyStatus ResampleAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/image/reorientimage/ReorientImage.h b/sdk/actions/image/reorientimage/ReorientImage.h index 9ce4b3c20c689205cc24dfb6630b7ea268218b3e..e35b68d76a65b87e0c5cc60535cccbc315f4dc0d 100644 --- a/sdk/actions/image/reorientimage/ReorientImage.h +++ b/sdk/actions/image/reorientimage/ReorientImage.h @@ -33,6 +33,9 @@ class vtkTransform; class vtkAnnotatedCubeActor; +class vtkAxesActor; +#include + namespace camitk { class Geometry; class ImageComponent; diff --git a/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp b/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp index 91345d5b4d109c63e7d852cd2737a808471154c2..c187e14b1df449c5c30a16a15e05ae686dfd9f63 100644 --- a/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp @@ -56,7 +56,7 @@ QWidget* ShowArbitrarySliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowArbitrarySliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getArbitrarySlices()->setViewSliceIn3D(! img->getArbitrarySlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp b/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp index 41bb3b32fb2772f0e02fc217da4abf9aabce57ef..d9ff8a0a49f6a7f616dbd438e9d764e7e4d445d6 100644 --- a/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp @@ -56,7 +56,7 @@ QWidget* ShowAxialSliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowAxialSliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getAxialSlices()->setViewSliceIn3D(! img->getAxialSlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp b/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp index 8091245494fc7953753fb4273ec37902455375f6..1ded382cd7d4f433059088bb49f458339bf29aac 100644 --- a/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp @@ -56,7 +56,7 @@ QWidget* ShowCoronalSliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowCoronalSliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getCoronalSlices()->setViewSliceIn3D(! img->getCoronalSlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/showin3d/ShowImageIn3D.cpp b/sdk/actions/image/showin3d/ShowImageIn3D.cpp index b90a7b8f92bd33306b44055d7245d1674004c46c..8b432b0382a388b1d4c7eeda857f1109135e897e 100644 --- a/sdk/actions/image/showin3d/ShowImageIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowImageIn3D.cpp @@ -65,7 +65,7 @@ QWidget* ShowImageIn3D::getWidget() { Action::ApplyStatus ShowImageIn3D::apply() { // fill the toplevel component set - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { bool isDisplayedIn3D = img->property("Display Image in 3D Viewer").toBool(); diff --git a/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp b/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp index dc8d750d720dcb8e1f132f7aa22df1fd685c8aca..d20d656a98bdcf3f09ee606a97f329976bb10387 100644 --- a/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp @@ -55,7 +55,7 @@ QWidget* ShowSagittalSliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowSagittalSliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getSagittalSlices()->setViewSliceIn3D(! img->getSagittalSlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp b/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp index 4d59d47092de7d370a8cb34094de17c17e8527a3..34c4a5f11602d432fb01db74ded9d81ed9359b83 100644 --- a/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp +++ b/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp @@ -102,7 +102,7 @@ QWidget* VolumeRenderingAction::getWidget() { // --------------- apply ------------------- Action::ApplyStatus VolumeRenderingAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/InitImagerAction.cpp b/sdk/actions/imageacquisition/InitImagerAction.cpp index 6c48c6305970cc4f50109a1dd17b9b7d6459022a..fbaf8f29268bcfec8daa0ca6c5e8380fdf86d8ef 100644 --- a/sdk/actions/imageacquisition/InitImagerAction.cpp +++ b/sdk/actions/imageacquisition/InitImagerAction.cpp @@ -59,7 +59,7 @@ InitImagerAction::~InitImagerAction() { // --------------- apply ------------------- Action::ApplyStatus InitImagerAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp b/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp index ea716a378e9591a4b8fabff436cf974b5ec6446a..12ef20a67a7f580247b4e0041db4af329498d8a2 100644 --- a/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp +++ b/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp @@ -59,7 +59,7 @@ SingleAcquisition2DAction::~SingleAcquisition2DAction() { // --------------- apply ------------------- Action::ApplyStatus SingleAcquisition2DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp b/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp index 768085bcb0b878759b2f37066a964c7e4d996901..9a503336564d436e25961a0a4c172b394077419b 100644 --- a/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp +++ b/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp @@ -59,7 +59,7 @@ SingleAcquisition3DAction::~SingleAcquisition3DAction() { // --------------- apply ------------------- Action::ApplyStatus SingleAcquisition3DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StartImaging2DAction.cpp b/sdk/actions/imageacquisition/StartImaging2DAction.cpp index b2e1d498042d3d6704a67f5bdaf22c630d84ae04..1ebc2ab6342bbb86a1b6f155f7f40e81a3acd071 100644 --- a/sdk/actions/imageacquisition/StartImaging2DAction.cpp +++ b/sdk/actions/imageacquisition/StartImaging2DAction.cpp @@ -59,7 +59,7 @@ StartImaging2DAction::~StartImaging2DAction() { // --------------- apply ------------------- Action::ApplyStatus StartImaging2DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StartImaging3DAction.cpp b/sdk/actions/imageacquisition/StartImaging3DAction.cpp index 1ae6a4ce670514f9faa2d885895162c595cb4ad3..07a7d6339c80acb8846c9a98db5e71b13f038de8 100644 --- a/sdk/actions/imageacquisition/StartImaging3DAction.cpp +++ b/sdk/actions/imageacquisition/StartImaging3DAction.cpp @@ -59,7 +59,7 @@ StartImaging3DAction::~StartImaging3DAction() { // --------------- apply ------------------- Action::ApplyStatus StartImaging3DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StopImaging2DAction.cpp b/sdk/actions/imageacquisition/StopImaging2DAction.cpp index 63d9843772e35208989d5dd9fcf2fb6e5b5b9a95..911d1d9d72de7df47e56d87b4c2d21b575252b70 100644 --- a/sdk/actions/imageacquisition/StopImaging2DAction.cpp +++ b/sdk/actions/imageacquisition/StopImaging2DAction.cpp @@ -59,7 +59,7 @@ StopImaging2DAction::~StopImaging2DAction() { // --------------- apply ------------------- Action::ApplyStatus StopImaging2DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StopImaging3DAction.cpp b/sdk/actions/imageacquisition/StopImaging3DAction.cpp index 85a8ac58b1f77d6ff85433627309e4206870afb4..9a856838e5425c87f6101e684a3bdb4d48dd3969 100644 --- a/sdk/actions/imageacquisition/StopImaging3DAction.cpp +++ b/sdk/actions/imageacquisition/StopImaging3DAction.cpp @@ -59,7 +59,7 @@ StopImaging3DAction::~StopImaging3DAction() { // --------------- apply ------------------- Action::ApplyStatus StopImaging3DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/basicmesh/ChangeColor.cpp b/sdk/actions/mesh/basicmesh/ChangeColor.cpp index 2f72b4891d2fcc6ef52d60fd3c9443f178f5a3a5..b3dbecb7b3e5b82de4e4c189638240f10a3b1cc5 100644 --- a/sdk/actions/mesh/basicmesh/ChangeColor.cpp +++ b/sdk/actions/mesh/basicmesh/ChangeColor.cpp @@ -61,7 +61,7 @@ Action::ApplyStatus ChangeColor::apply() { actorColor[3] = newColor.alphaF(); // change the color for the selected Component modes - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { comp->setActorColor(comp->getRenderingModes(), actorColor); } diff --git a/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp b/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp index 938c6e8331628baa029661cad34eff8fe5d382ad..5dea4c65800844f2ffc50011c008b43a29ca044b 100644 --- a/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp +++ b/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp @@ -81,7 +81,7 @@ MeshToImageStencil::~MeshToImageStencil() { // --------------- apply ------------------- Action::ApplyStatus MeshToImageStencil::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); ApplyStatus status = process(input); // abort if one of the selecteed component processing is not successful diff --git a/sdk/actions/mesh/basicmesh/RenderingOption.cpp b/sdk/actions/mesh/basicmesh/RenderingOption.cpp index 0fdea1ce4f43dc7fded6ab7f0ba1ed55be1b2de7..0c48c3169943d49483981d78571d6bc3a3554044 100644 --- a/sdk/actions/mesh/basicmesh/RenderingOption.cpp +++ b/sdk/actions/mesh/basicmesh/RenderingOption.cpp @@ -127,7 +127,7 @@ Action::ApplyStatus RenderingOption::apply() { } // update the rendering mode of selected - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { comp->setRenderingModes(m); // set the additional prop visibility comp->getProp("glyph")->SetVisibility(property("Glyph representation?").toBool()); diff --git a/sdk/actions/mesh/basicmesh/RigidTransform.cpp b/sdk/actions/mesh/basicmesh/RigidTransform.cpp index 972c90462d8401a3d4401fddea936f8f79ee1914..e26157892f4b43f24d6df471d2d89c29f90cf08d 100644 --- a/sdk/actions/mesh/basicmesh/RigidTransform.cpp +++ b/sdk/actions/mesh/basicmesh/RigidTransform.cpp @@ -114,7 +114,7 @@ QWidget* RigidTransform::getWidget() { //-- connect the custom pipeline to the selected Component filterList.clear(); - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { filterList.append(vtkSmartPointerTransformFilter::New()); filterList.last()->SetTransform(transformation); filterList.last()->SetInputConnection(comp->getDataPort()); @@ -194,7 +194,7 @@ Action::ApplyStatus RigidTransform::apply() { // apply the transformation unsigned int i = 0; - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { // get the result from the corresponding filter vtkSmartPointer result = vtkPointSet::SafeDownCast(filterList[i]->GetOutputDataObject(0)); if (result) { @@ -216,7 +216,7 @@ Action::ApplyStatus RigidTransform::apply() { //--------------- close ------------ void RigidTransform::close() { //--disconnect the selected Component - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { comp->setDataConnection(NULL); } // hide the dialog diff --git a/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp b/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp index 3c1f9bd7117c3580a063f1d9d7efb7321b01f739..b1540713bf43411132461691176dcff70b1c2666 100644 --- a/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp +++ b/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp @@ -114,7 +114,7 @@ void ExportAsMDL::outputFileChanged(const QString& ofile) { Action::ApplyStatus ExportAsMDL::apply() { Action::ApplyStatus returnStatus = SUCCESS; - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); if (input != nullptr) { returnStatus = process(input); diff --git a/sdk/actions/mesh/meshprocessing/InvertMesh.cpp b/sdk/actions/mesh/meshprocessing/InvertMesh.cpp index be96d2433bf8299723ea99b1452fb44417609a7b..53475b84d297013018f3333d308ac3af222a708a 100644 --- a/sdk/actions/mesh/meshprocessing/InvertMesh.cpp +++ b/sdk/actions/mesh/meshprocessing/InvertMesh.cpp @@ -56,7 +56,7 @@ InvertMesh::~InvertMesh() { // --------------- apply ------------------- Action::ApplyStatus InvertMesh::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp b/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp index 8a6d29a439b7f4d25dc62ed21e3b68ebaeb9b787..badd063d3873cdca77da85bae60b8f0cd61c8471 100644 --- a/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp +++ b/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp @@ -72,7 +72,7 @@ void LoadTextureFromBMP::loadBMP() { // --------------- apply ------------------- Action::ApplyStatus LoadTextureFromBMP::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp b/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp index 74e4833e030ceb6e99aadb03e5eda3eacd10cf64..f6a95fa1a3a07ace7c29faf16260ebf6ac403b07 100644 --- a/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp +++ b/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp @@ -77,7 +77,7 @@ void LoadTransformation::openTransformation() { // --------------- apply ------------------- Action::ApplyStatus LoadTransformation::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); loadTransformationFile(); } diff --git a/sdk/actions/mesh/meshprocessing/MeshClipping.cpp b/sdk/actions/mesh/meshprocessing/MeshClipping.cpp index 773a4ce4b7cde679727a67e7e40dc3a2cceb9632..8ef8d05ec81166c100bccd60b7aff72b3e62a7b8 100644 --- a/sdk/actions/mesh/meshprocessing/MeshClipping.cpp +++ b/sdk/actions/mesh/meshprocessing/MeshClipping.cpp @@ -145,8 +145,7 @@ Action::ApplyStatus MeshClipping::apply() { //-- Clipping the targeted components if (list.size() != 0) { //-- Clipping - Component* candidate; - foreach (candidate, list) { + for (Component* candidate : list) { if (candidate->isInstanceOf("MeshComponent")) { if (allComponents || candidate->isSelected()) { ApplyStatus clipStatus = clipMesh(dynamic_cast < MeshComponent* >(candidate), plane); @@ -239,8 +238,7 @@ void MeshClipping::updateBox(bool refreshViewer) { double currentBounds[6]; ComponentList list = Application::getTopLevelComponents(); (*list.begin())->getBounds(limBounds); - Component* currentComponent; - foreach (currentComponent, list) { + for (Component* currentComponent : list) { currentComponent->getBounds(currentBounds); if (currentBounds[0] < limBounds[0]) { limBounds[0] = currentBounds[0]; @@ -355,8 +353,7 @@ Action::ApplyStatus MeshClipping::clipMesh(MeshComponent* mesh, vtkSmartPointer // --------------- restoreMeshes ------------------- void MeshClipping::restoreMeshes() { - Component* candidate; - foreach (candidate, list) { + for (Component* candidate : list) { candidate->setDataConnection(candidate->getDataPort()); } list.clear(); @@ -406,8 +403,7 @@ void MeshClipping::changeAllComponents() { } else { button->setText(tr("Clip All Components")); - Component* candidate; - foreach (candidate, list) { + for (Component* candidate : list) { candidate->setDataConnection(candidate->getDataPort()); } } diff --git a/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp b/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp index 62553d150bde6225f86dba113ac9eba2e9ca8993..ea0004989d15a64f7370fd8a1f35ac198d40d755 100644 --- a/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp +++ b/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp @@ -99,7 +99,7 @@ QWidget* SaveDisplacementFromTransformation::getWidget() { // --------------- apply ------------------- Action::ApplyStatus SaveDisplacementFromTransformation::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp b/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp index 37905de1aaa19417c974b035d31e2116f6e2bb8e..962f3ed8b1322ec02cc7039e4e2ba9d9969b7b4a 100644 --- a/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp +++ b/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp @@ -93,7 +93,7 @@ SmoothFilter::~SmoothFilter() { // --------------- apply ------------------- Action::ApplyStatus SmoothFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/WarpOut.cpp b/sdk/actions/mesh/meshprocessing/WarpOut.cpp index f2a14cd93e4e72de73aebd4dcfb751b17122c599..045e5359b00e7f70fb85f27f7b2d802ec3fdc742 100644 --- a/sdk/actions/mesh/meshprocessing/WarpOut.cpp +++ b/sdk/actions/mesh/meshprocessing/WarpOut.cpp @@ -189,7 +189,12 @@ Action::ApplyStatus WarpOut::apply() { for (vtkIdType i = 0; i < connectivityFilter->GetOutput()->GetNumberOfPoints(); i++) { // get the id of the point in the original point set +#if ( VTK_MAJOR_VERSION >= 7 && VTK_MINOR_VERSION >=1) || VTK_MAJOR_VERSION >= 8 + pointId->GetTypedTuple(i, &id); +#else pointId->GetTupleValue(i, &id); +#endif + // get the initial point position resultPointSet->GetPoint(id, pos); // get the normal diff --git a/sdk/applications/actionstatemachine/ActionState.cpp b/sdk/applications/actionstatemachine/ActionState.cpp index 71c9e913c427694375c993e6824ce4712bf1b192..0648d6960f4c165f615d8bfb8aa069e1d9dc0e2d 100644 --- a/sdk/applications/actionstatemachine/ActionState.cpp +++ b/sdk/applications/actionstatemachine/ActionState.cpp @@ -273,7 +273,7 @@ void ActionState::onEntry(QEvent* event) { myAction->setInputComponents(inputComps); //-- reset modification flags on input components to avoid mismatching output component - foreach (Component* inputComponent, inputComps) { + for (Component* inputComponent : inputComps) { inputComponent->setModified(false); } diff --git a/sdk/applications/actionstatemachine/ActionStateMachine.cpp b/sdk/applications/actionstatemachine/ActionStateMachine.cpp index 0009fdcb80679ac9ec4d21e56c8aa9cd2fb00317..bb7ce7474f7b2bdc228da213fef3885a392fb313 100644 --- a/sdk/applications/actionstatemachine/ActionStateMachine.cpp +++ b/sdk/applications/actionstatemachine/ActionStateMachine.cpp @@ -310,7 +310,7 @@ void ActionStateMachine::createAllActionStates(QDomNodeList nodeList) { QMap outputNames; QMap ::const_iterator it = statesMap->constBegin(); while (it != statesMap->constEnd()) { - foreach (QString inputCompName, it.value()->getInputComponents().keys()) { + for (QString inputCompName : it.value()->getInputComponents().keys()) { if (inputNames.values().contains(inputCompName)) { CAMITK_WARNING(tr("Warning: same input \"%1\" for more than one state. It might be wrong.\n").arg(inputCompName)) } @@ -318,7 +318,7 @@ void ActionStateMachine::createAllActionStates(QDomNodeList nodeList) { inputNames.insert(it.value(), inputCompName); } } - foreach (QString outputCompName, it.value()->getOutputComponents().keys()) { + for (QString outputCompName : it.value()->getOutputComponents().keys()) { if (outputNames.values().contains(outputCompName)) { QString msg = tr("Error: same output name \"%1\" for more than one state. Please rename the output of \"%2\"").arg(outputCompName, it.value()->getName()); CAMITK_ERROR(msg) diff --git a/sdk/applications/actionstatemachine/main.cpp b/sdk/applications/actionstatemachine/main.cpp index d7c897358612538326f47ed33030d0f13a3ba3c2..d4d34d08a930822bf64efb243e25d4d5ac54e650 100644 --- a/sdk/applications/actionstatemachine/main.cpp +++ b/sdk/applications/actionstatemachine/main.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "CommandLineOptions.hxx" using namespace camitk; @@ -76,7 +78,7 @@ int main(int argc, char** argv) { } } catch (const cli::exception& e) { - cerr << e << endl; + std::cerr << e << std::endl; usage(argv[0]); return EXIT_FAILURE; } diff --git a/sdk/applications/imp/ImpMainWindow.cpp b/sdk/applications/imp/ImpMainWindow.cpp index e48154e88eecd628f41a1ec1326b7cf2114b1eaa..1d4502225fca75871c5239fa9321a3f5b7f4cc35 100644 --- a/sdk/applications/imp/ImpMainWindow.cpp +++ b/sdk/applications/imp/ImpMainWindow.cpp @@ -244,7 +244,7 @@ void ImpMainWindow::initMenuBar() { fileMenu->addAction(saveHistory); fileMenu->addAction(recentDocumentSeparator); - foreach (QAction* recentAction, recentDocumentActions) { + for (QAction* recentAction : recentDocumentActions) { fileMenu->addAction(recentAction); } @@ -336,7 +336,7 @@ void ImpMainWindow::updateActionStates() { else { // add all generic actions ActionList allActions = Application::getActions(NULL); - foreach (Action* action, allActions) { + for (Action* action : allActions) { actionMenu->addAction(action->getQAction()); actionMenu->setEnabled(true); } @@ -428,7 +428,7 @@ void ImpMainWindow::updateOpenDirectoryMenu() { fileOpenDataDirectoryMenu->clear(); fileOpenDataDirectoryMenu->setEnabled(false); - foreach (QString name, ExtensionManager::getDataDirectoryExtNames()) { + for (QString name : ExtensionManager::getDataDirectoryExtNames()) { nrOfDataDirectoryManager++; QAction* openDirectory = new QAction(name, this); openDirectory->setStatusTip(tr(QString("Opens data directory for " + name).toStdString().c_str())); @@ -481,7 +481,7 @@ void ImpMainWindow::updateViewMenu() { viewMenu->clear(); // insert viewers menu - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { QMenu* viewerMenu = v->getMenu(); if (viewerMenu) { @@ -516,7 +516,7 @@ void ImpMainWindow::editSettings() { settingsDialog.editSettings(dynamic_cast(qApp)->getPropertyObject()); // edit all viewers that have properties - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { QObject* viewerProp = v->getPropertyObject(); if (viewerProp) { diff --git a/sdk/applications/wizard/ActionAddParameterState.cpp b/sdk/applications/wizard/ActionAddParameterState.cpp index e29e00fad1d89b11441ef8b5a9e6a603d5c4b66b..c3ff5c516ff6893f4cd0584af0aad63ff243523a 100644 --- a/sdk/applications/wizard/ActionAddParameterState.cpp +++ b/sdk/applications/wizard/ActionAddParameterState.cpp @@ -67,7 +67,7 @@ void ActionAddParameterState::addDomParameters() { if (parameterWidgets.size() > 0) { cepcoreschema::Parameters domParameters; - foreach (ActionParameterWidget* p, parameterWidgets) { + for (ActionParameterWidget* p : parameterWidgets) { QString name = p->getName(); QString type = p->getType(); QString defValue = p->getDefaultValue(); diff --git a/sdk/applications/wizard/ActionAddParameterWidget.cpp b/sdk/applications/wizard/ActionAddParameterWidget.cpp index 2049821efee13f20c8896abf58a123ba89ad68b6..48fd4db819a076fb03eaccfaa015b47287f8ed13 100644 --- a/sdk/applications/wizard/ActionAddParameterWidget.cpp +++ b/sdk/applications/wizard/ActionAddParameterWidget.cpp @@ -104,7 +104,7 @@ bool ActionAddParameterWidget::isOneNonAsciiParameter() { void ActionAddParameterWidget::setToDefault() { // Remove existing parameters - foreach (ActionParameterWidget* widget, list) { + for (ActionParameterWidget* widget : list) { ui.parametersLayout->removeWidget(widget); if (widget != NULL) { delete widget; diff --git a/sdk/applications/wizard/ActionClassificationState.cpp b/sdk/applications/wizard/ActionClassificationState.cpp index d61e53e98c17492032be36a04fe755ae2f77c8ce..9935472cec6462e8f8762dca7a002d7ae5a2fd44 100644 --- a/sdk/applications/wizard/ActionClassificationState.cpp +++ b/sdk/applications/wizard/ActionClassificationState.cpp @@ -66,7 +66,7 @@ void ActionClassificationState::onExit(QEvent* event) { aClassification.itkFilter(domAction->classification().itkFilter()); } - foreach (ActionTagWidget* tagWidget, tagWidgets) { + for (ActionTagWidget* tagWidget : tagWidgets) { QString tag = tagWidget->getTag(); aClassification.tag().push_back(tag.toStdString().c_str()); } diff --git a/sdk/applications/wizard/ActionClassificationWidget.cpp b/sdk/applications/wizard/ActionClassificationWidget.cpp index a8eae60806d1dacb6fb616d53db48d672492bb2d..7630146706d79835de5c8cf19a4db58bf9725157 100644 --- a/sdk/applications/wizard/ActionClassificationWidget.cpp +++ b/sdk/applications/wizard/ActionClassificationWidget.cpp @@ -43,7 +43,7 @@ void ActionClassificationWidget::setToDefault() { ui.requiredLabel->setStyleSheet(normalStyle); // Empty Tags - foreach (ActionTagWidget* tag, list) { + for (ActionTagWidget* tag : list) { ui.actionTagsLayout->removeWidget(tag); if (tag != NULL) { delete tag; diff --git a/sdk/applications/wizard/ActionSummaryWidget.cpp b/sdk/applications/wizard/ActionSummaryWidget.cpp index 55f43e1f656ac11c377305e868d25709b6a5b84c..c34f7ebc8ae89f71239baac36b5069f9c55cdf64 100644 --- a/sdk/applications/wizard/ActionSummaryWidget.cpp +++ b/sdk/applications/wizard/ActionSummaryWidget.cpp @@ -60,13 +60,13 @@ void ActionSummaryWidget::setSummary(QString name, QString description, QString text = text.replace(QRegExp("@FAMILY@"), family); QString parametersList = ""; - foreach (QString el, parameters) { + for (QString el : parameters) { parametersList += "
  • " + el + "
  • \n"; } text = text.replace(QRegExp("@PARAMETERS_LIST@"), parametersList); QString tagsList = ""; - foreach (QString dep, tags) { + for (QString dep : tags) { tagsList += "
  • " + dep + "
  • \n"; } text = text.replace(QRegExp("@TAGS_LIST@"), tagsList); diff --git a/sdk/applications/wizard/ComponentAddPropertyState.cpp b/sdk/applications/wizard/ComponentAddPropertyState.cpp index 607ee783ce4131901bc2ab93a77e064e8022732d..0c3461d1a9aa975eff3dc2d2f790df11f0d3998e 100644 --- a/sdk/applications/wizard/ComponentAddPropertyState.cpp +++ b/sdk/applications/wizard/ComponentAddPropertyState.cpp @@ -67,7 +67,7 @@ void ComponentAddPropertyState::addDomParameters() { if (parameterWidgets.size() > 0) { cepcoreschema::Parameters domParameters; - foreach (ComponentPropertyWidget* p, parameterWidgets) { + for (ComponentPropertyWidget* p : parameterWidgets) { QString name = p->getName(); QString type = p->getType(); QString defValue = p->getDefaultValue(); diff --git a/sdk/applications/wizard/ComponentAddPropertyWidget.cpp b/sdk/applications/wizard/ComponentAddPropertyWidget.cpp index c502e6d29c022dd7a9da5ecf65c5a8814bcef776..bd7527e93d25a5c2171120972ded45d1eade1ddf 100644 --- a/sdk/applications/wizard/ComponentAddPropertyWidget.cpp +++ b/sdk/applications/wizard/ComponentAddPropertyWidget.cpp @@ -105,7 +105,7 @@ bool ComponentAddPropertyWidget::isOneNonAsciiParameter() { void ComponentAddPropertyWidget::setToDefault() { // Remove existing properties - foreach (ComponentPropertyWidget* widget, list) { + for (ComponentPropertyWidget* widget : list) { ui.propertiesLayout->removeWidget(widget); if (widget != NULL) { delete widget; diff --git a/sdk/applications/wizard/ComponentSummaryWidget.cpp b/sdk/applications/wizard/ComponentSummaryWidget.cpp index 4faf4a3a1bb1700f4b2a3224206355bb7881c21b..45724d6723691cc3f5b58ccb5abd558b3d6b65c6 100644 --- a/sdk/applications/wizard/ComponentSummaryWidget.cpp +++ b/sdk/applications/wizard/ComponentSummaryWidget.cpp @@ -58,7 +58,7 @@ void ComponentSummaryWidget::setSummary(QString name, QString description, QStri text = text.replace(QRegExp("@REPRESENTATION@"), representation); QString parametersList = ""; - foreach (QString el, properties) { + for (QString el : properties) { parametersList += "
  • " + el + "
  • \n"; } text = text.replace(QRegExp("@PROPERTIES_LIST@"), parametersList); diff --git a/sdk/applications/wizard/DependenciesState.cpp b/sdk/applications/wizard/DependenciesState.cpp index 677f6d85d4f38e70aed2dc4815aeb20e1ece0668..14f25cd4639aeea2826e32fe8d61068bc1e8c42a 100644 --- a/sdk/applications/wizard/DependenciesState.cpp +++ b/sdk/applications/wizard/DependenciesState.cpp @@ -111,19 +111,19 @@ cepcoreschema::Dependencies* DependenciesState::getDependencies() { if (dependenciesWidget != nullptr) { // Get Internal CEP dependencies QStringList cepLibraries = dependenciesWidget->getCEPLibrariesDependencies(); - foreach (QString lib, cepLibraries) { + for (QString lib : cepLibraries) { QString libName = ClassNameHandler::getDirectoryName(lib); cepcoreschema::Dependency dep("cepLibrary", libName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList cepComponents = dependenciesWidget->getCEPComponentsDependencies(); - foreach (QString comp, cepComponents) { + for (QString comp : cepComponents) { QString compName = ClassNameHandler::getDirectoryName(comp); cepcoreschema::Dependency dep("component", compName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList cepActions = dependenciesWidget->getCEPActionsDependencies(); - foreach (QString action, cepActions) { + for (QString action : cepActions) { QString actionName = ClassNameHandler::getDirectoryName(action); cepcoreschema::Dependency dep("action", actionName.toStdString()); domDependencies->dependency().push_back(dep); @@ -131,19 +131,19 @@ cepcoreschema::Dependencies* DependenciesState::getDependencies() { // Get CamiTK dependencies QStringList camitkLibraries = dependenciesWidget->getCamiTKLibrariesDependencies(); - foreach (QString lib, camitkLibraries) { + for (QString lib : camitkLibraries) { QString libName = ClassNameHandler::getDirectoryName(lib); cepcoreschema::Dependency dep("cepLibrary", libName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList camitkComponents = dependenciesWidget->getCamiTKComponentsDependencies(); - foreach (QString comp, camitkComponents) { + for (QString comp : camitkComponents) { QString compName = ClassNameHandler::getDirectoryName(comp); cepcoreschema::Dependency dep("component", compName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList camitkActions = dependenciesWidget->getCamiTKActionsDependencies(); - foreach (QString action, camitkActions) { + for (QString action : camitkActions) { QString actionName = ClassNameHandler::getDirectoryName(action); cepcoreschema::Dependency dep("action", actionName.toStdString()); domDependencies->dependency().push_back(dep); @@ -151,7 +151,7 @@ cepcoreschema::Dependencies* DependenciesState::getDependencies() { // Get Other libraries dependencies QStringList externalLibs = dependenciesWidget->getExternalLibsDependencies(); - foreach (QString lib, externalLibs) { + for (QString lib : externalLibs) { cepcoreschema::Dependency dep("library", lib.toStdString()); domDependencies->dependency().push_back(dep); } diff --git a/sdk/applications/wizard/DependenciesWidget.cpp b/sdk/applications/wizard/DependenciesWidget.cpp index f20da2fdcca56aeb148dcccd2a7487c8f8227390..294ab43b259f532913acf371f542fdf03c763997 100644 --- a/sdk/applications/wizard/DependenciesWidget.cpp +++ b/sdk/applications/wizard/DependenciesWidget.cpp @@ -34,21 +34,21 @@ DependenciesWidget::DependenciesWidget(QWidget* parent) : QWidget(parent) { void DependenciesWidget::setToDefault() { // Remove exisiting Libraries Check Boxes - foreach (QCheckBox* cb, cepLibrariesCheckBox) { + for (QCheckBox* cb : cepLibrariesCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } cepLibrariesCheckBox.clear(); // Remove exisiting Components Check Boxes - foreach (QCheckBox* cb, cepComponentsCheckBox) { + for (QCheckBox* cb : cepComponentsCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } cepComponentsCheckBox.clear(); // Remove exisiting Actions Check Boxes - foreach (QCheckBox* cb, cepActionsCheckBox) { + for (QCheckBox* cb : cepActionsCheckBox) { ui.cepActionsLayout->removeWidget(cb); delete cb; } @@ -106,7 +106,7 @@ void DependenciesWidget::setElement(QString element) { questionMarks.append(ui.camitkComponentsQM); questionMarks.append(ui.camitkActionsQM); - foreach (QLabel* qm, questionMarks) { + for (QLabel* qm : questionMarks) { text = qm->toolTip(); text.replace(QRegExp("@ELEMENT@"), element); qm->setToolTip(text); @@ -116,7 +116,7 @@ void DependenciesWidget::setElement(QString element) { void DependenciesWidget::updateCEPLibraries(QStringList cepLibraries) { // Remove exisiting Check Boxes - foreach (QCheckBox* cb, cepLibrariesCheckBox) { + for (QCheckBox* cb : cepLibrariesCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } @@ -129,7 +129,7 @@ void DependenciesWidget::updateCEPLibraries(QStringList cepLibraries) { else { int row = 0; int col = 0; - foreach (QString lib, cepLibraries) { + for (QString lib : cepLibraries) { QCheckBox* checkBox = new QCheckBox(); checkBox->setText(lib); checkBox->setChecked(false); @@ -148,7 +148,7 @@ void DependenciesWidget::updateCEPLibraries(QStringList cepLibraries) { void DependenciesWidget::updateCEPComponents(QMap cepComponents) { // Remove exisiting Check Boxes - foreach (QCheckBox* cb, cepComponentsCheckBox) { + for (QCheckBox* cb : cepComponentsCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } @@ -186,7 +186,7 @@ void DependenciesWidget::updateCEPComponents(QMap cepComponents) void DependenciesWidget::updateCEPActions(QStringList cepActions) { // Remove exisiting Check Boxes - foreach (QCheckBox* cb, cepActionsCheckBox) { + for (QCheckBox* cb : cepActionsCheckBox) { ui.cepActionsLayout->removeWidget(cb); delete cb; } @@ -199,7 +199,7 @@ void DependenciesWidget::updateCEPActions(QStringList cepActions) { else { int row = 0; int col = 0; - foreach (QString action, cepActions) { + for (QString action : cepActions) { QCheckBox* checkBox = new QCheckBox(); checkBox->setText(action); checkBox->setChecked(false); @@ -218,7 +218,7 @@ void DependenciesWidget::updateCEPActions(QStringList cepActions) { QStringList DependenciesWidget::getCEPLibrariesDependencies() { QStringList cepLibs; - foreach (QCheckBox* cb, cepLibrariesCheckBox) { + for (QCheckBox* cb : cepLibrariesCheckBox) { if (cb->isChecked()) { cepLibs.append(cb->text()); } @@ -229,7 +229,7 @@ QStringList DependenciesWidget::getCEPLibrariesDependencies() { QStringList DependenciesWidget::getCEPComponentsDependencies() { QStringList cepComps; - foreach (QCheckBox* cb, cepComponentsCheckBox) { + for (QCheckBox* cb : cepComponentsCheckBox) { if (cb->isChecked()) { cepComps.append(cb->text()); } @@ -240,7 +240,7 @@ QStringList DependenciesWidget::getCEPComponentsDependencies() { QStringList DependenciesWidget::getCEPActionsDependencies() { QStringList cepActions; - foreach (QCheckBox* cb, cepActionsCheckBox) { + for (QCheckBox* cb : cepActionsCheckBox) { if (cb->isChecked()) { cepActions.append(cb->text()); } diff --git a/sdk/applications/wizard/ExtensionSummaryWidget.cpp b/sdk/applications/wizard/ExtensionSummaryWidget.cpp index b086f1960177036229559e6f1267d8a35bfdf55e..171ec673492e5c0775b0fc27ba49f9e06905777b 100644 --- a/sdk/applications/wizard/ExtensionSummaryWidget.cpp +++ b/sdk/applications/wizard/ExtensionSummaryWidget.cpp @@ -72,13 +72,13 @@ void ExtensionSummaryWidget::setSummary(QString name, QString description, QStri text = text.replace(QRegExp("@DESCRIPTION@"), description); QString elementsList = ""; - foreach (QString el, elements) { + for (QString el : elements) { elementsList += "
  • " + el + "
  • \n"; } text = text.replace(QRegExp("@ELEMENTS_LIST@"), elementsList); QString dependenciesList = ""; - foreach (QString dep, dependencies) { + for (QString dep : dependencies) { dependenciesList += "
  • " + dep + "
  • \n"; } text = text.replace(QRegExp("@DEPENDENCIES_LIST@"), dependenciesList); diff --git a/sdk/applications/wizard/GeneratingCEPState.cpp b/sdk/applications/wizard/GeneratingCEPState.cpp index 53578b2ac6de0ca1a730858698d3df332e31d7ac..0763f3f2de3bb6d9e9019f1e0326159aae0504f3 100644 --- a/sdk/applications/wizard/GeneratingCEPState.cpp +++ b/sdk/applications/wizard/GeneratingCEPState.cpp @@ -99,7 +99,7 @@ void GeneratingCEPState::onEntry(QEvent* event) { std::cout << "cpeDirName: " << cepDirName.toStdString() << ", libraryName: " << libraryName.toStdString() << std::endl; - foreach (QString totalFileName, totalFileNamesList) { + for (QString totalFileName : totalFileNamesList) { QFileInfo fileInfo(totalFileName); QString shortFileName = fileInfo.fileName(); diff --git a/sdk/applications/wizard/LibraryCopyFilesState.cpp b/sdk/applications/wizard/LibraryCopyFilesState.cpp index 81ff78ba7b95d236e70e8da73b2089d304abd4ed..661276e60473af9aa928c569617f6cef66e82737 100644 --- a/sdk/applications/wizard/LibraryCopyFilesState.cpp +++ b/sdk/applications/wizard/LibraryCopyFilesState.cpp @@ -55,7 +55,7 @@ void LibraryCopyFilesState::onEntry(QEvent* event) { if (domLibrary != nullptr) { QString libraryName = domLibrary->name().c_str(); QStringList files = libraryFilesMap->value(libraryName); - foreach (QString file, files) { + for (QString file : files) { libraryCopyFilesWidget->addFile(file); } } diff --git a/sdk/applications/wizard/LibraryCopyFilesWidget.cpp b/sdk/applications/wizard/LibraryCopyFilesWidget.cpp index 544d6079d51a9fc653fb5cd25f8c084fa8ca8f2b..51c15b869312845c1b4a84e9bf83a3a2c869ced2 100644 --- a/sdk/applications/wizard/LibraryCopyFilesWidget.cpp +++ b/sdk/applications/wizard/LibraryCopyFilesWidget.cpp @@ -65,7 +65,7 @@ void LibraryCopyFilesWidget::addFile(QString file) { void LibraryCopyFilesWidget::addFileClicked() { QStringList filesList = QFileDialog::getOpenFileNames(this, tr("Select one or more files"), "/home"); - foreach (QString fileName, filesList) { + for (QString fileName : filesList) { addLibraryName(fileName); } } diff --git a/sdk/applications/wizard/main.cpp b/sdk/applications/wizard/main.cpp index 8e4980b6ce6a24b1e853378443708860a068fc73..c8942ae65892dec0a28444e3e48271375eb8293f 100644 --- a/sdk/applications/wizard/main.cpp +++ b/sdk/applications/wizard/main.cpp @@ -27,6 +27,7 @@ // CamiTK stuff #include +#include //Imports from Qt #include @@ -42,7 +43,7 @@ void usage(char* appName) { std::cerr << "Usage: " << appName << " [options]" << std::endl; std::cerr << "Build using " << camitk::Core::version << std::endl; std::cerr << std::endl; - std::cerr << "Options:" << endl; + std::cerr << "Options:" << std::endl; options::print_usage(std::cerr); } diff --git a/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake b/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake index c7628f0e80a2cf9843049f8df7e9355c8c503153..75a60d67d3714a0a48c6e48c287a1431936ddb02 100644 --- a/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake +++ b/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake @@ -52,6 +52,25 @@ #! \param INCLUDE_DIRECTORIES additional include directories #! \param EXTERNAL_LIBRARIES external libraries to add to the link command #! \param EXTRA_TRANSLATE_LANGUAGE Additionnal extra language to translate the application +#! +#! \note If you need to add any extra/custom CMake command after this macro, you can use ${APPLICATION_TARGET_NAME} +#! to specify the current target. +#! +#! For example: +#! \code +#! camitk_application( +#! ... +#! ) +#! +#! message(STATUS "Adding tests for target ${APPLICATION_TARGET_NAME}") +#! camitk_init_test(${APPLICATION_TARGET_NAME}) +#! # testing the application with no arguments, should print a message and exit success +#! camitk_add_test(PROJECT_NAME ${APPLICATION_TARGET_NAME} TEST_SUFFIX "-") +#! \endcode +#! + + + macro(camitk_application) # Instruct CMake to run moc automatically when needed. diff --git a/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake b/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake index 49e3298364c3f8ea4ccbef15b39807d3276268a0..9dd232116042f38cb79cbf0990b02493edb20bce 100644 --- a/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake +++ b/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake @@ -94,9 +94,21 @@ #! a file called "asm-input.scxml" and at least one file name "output-*.*") #! Check the wiki for more information about integration test #! +#! \note If you need to add any extra/custom CMake command after this macro, you can use the name of the extension +#! produced by the macro: #! +#! - ${ACTION_TARGET_NAME} is the name of the target for action +#! - ${COMPONENT_TARGET_NAME} is the name of the target for component #! +#! E.g., in a CMakeLists.txt of an action: +#! \code +#! camitk_extension(ACTION_EXTENSION +#! ... +#! ) #! +#! message(STATUS "The name of the current target is: ${ACTION_TARGET_NAME}") +#! \endcode +#! macro(camitk_extension) diff --git a/sdk/libraries/cepgenerator/ClassNameHandler.cpp b/sdk/libraries/cepgenerator/ClassNameHandler.cpp index b5654b3993bc6a110e022cdd644371d84505e2c0..fe99748a338fed4d55c9a34f76f83c5d9788ae4a 100644 --- a/sdk/libraries/cepgenerator/ClassNameHandler.cpp +++ b/sdk/libraries/cepgenerator/ClassNameHandler.cpp @@ -49,7 +49,7 @@ QString ClassNameHandler::getClassName(QString genericName) { } // uppercase the first letter of each word and concatenate - foreach (QString s, cppNameList) { + for (QString s : cppNameList) { className += s.left(1).toUpper() + s.mid(1).toLower(); } className = className.left(1).toUpper() + className.mid(1); diff --git a/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp b/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp index 6a33876c35c27c1bae265ea761905af618f5e28c..6cf220bfca5144d9a75de6335f007d1b6731725d 100644 --- a/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp +++ b/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp @@ -164,7 +164,7 @@ void ComponentExtensionGenerator::writeCFile(QString directory) { suffixesList << componentSuffixes; } - foreach (QString s, suffixesList) { + for (QString s : suffixesList) { std::cout << "Found suffix in XML: " << s.toStdString() << std::endl; } diff --git a/sdk/libraries/cepgenerator/ParameterGenerator.cpp b/sdk/libraries/cepgenerator/ParameterGenerator.cpp index ddc58fd813bdd5713212f0fdc0e7b65dcfd56ca7..6840ab0584ac929b3c940954cda07d6e61bbf91b 100644 --- a/sdk/libraries/cepgenerator/ParameterGenerator.cpp +++ b/sdk/libraries/cepgenerator/ParameterGenerator.cpp @@ -158,7 +158,7 @@ QString ParameterGenerator::getCppName() const { } // uppercase the first letter of each word and concatenate - foreach (QString s, cppNameList) { + for (QString s : cppNameList) { cppName += s.left(1).toUpper() + s.mid(1).toLower(); } diff --git a/sdk/libraries/cepgenerator/resources/Action.cpp.in b/sdk/libraries/cepgenerator/resources/Action.cpp.in index 7e8809c3c668b350e50fac1dd207cb1f56d7b348..51d7eef4d32b38d2d794c56a14e3eaf375f5412a 100644 --- a/sdk/libraries/cepgenerator/resources/Action.cpp.in +++ b/sdk/libraries/cepgenerator/resources/Action.cpp.in @@ -74,7 +74,7 @@ Action::ApplyStatus @ACTIONCLASSNAME@::apply() { @ELSEIF_NOCOMP@ - foreach (Component *comp, getTargets()) { + for (Component *comp : getTargets()) { @IF_DEFCOMPONENT@ @COMPONENTNAME@ * input = dynamic_cast<@COMPONENTNAME@ *> ( comp ); process(input); diff --git a/sdk/libraries/core/CMakeLists.txt b/sdk/libraries/core/CMakeLists.txt index 998afd67b4de9e2b35d4890d97c38d39cedcff20..b1b35c1eca2c76071a37aaed3fc74bbeac022d6e 100644 --- a/sdk/libraries/core/CMakeLists.txt +++ b/sdk/libraries/core/CMakeLists.txt @@ -62,7 +62,7 @@ set_target_properties(${CAMITK_CORE_LIB_TARGET_NAME} PROPERTIES ${CAMITKCORE_LIB if (WIN32 AND MSVC) # property required for camitk file association on windows platform compilation with Visual Studio set_target_properties(${CAMITK_CORE_LIB_TARGET_NAME} PROPERTIES COMPILE_FLAGS "/Zc:wchar_t-" - DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX} + DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX} ) endif() @@ -126,7 +126,7 @@ export_headers(${${CAMITK_CORE_LIB_TARGET_NAME}_INSTALL_H} # change the output library name (without the prefix 'library') set_target_properties(${CAMITK_CORE_LIB_TARGET_NAME} - PROPERTIES OUTPUT_NAME ${CAMITK_CORE_LIB_NAME} + PROPERTIES OUTPUT_NAME ${CAMITK_CORE_LIB_NAME} ) # lib installation diff --git a/sdk/libraries/core/Core.cpp b/sdk/libraries/core/Core.cpp index 5be7431f2f01b94a15c736358306ac02a7a3f4b1..fdcdea63222cb5a198c037ce379e707485d5daaf 100644 --- a/sdk/libraries/core/Core.cpp +++ b/sdk/libraries/core/Core.cpp @@ -147,7 +147,7 @@ const QString Core::getConfig() { // regular component extensions const QList< ComponentExtension* >& allCE = ExtensionManager::getComponentExtensionsList(); - foreach (ComponentExtension* ce, allCE) { + for (ComponentExtension* ce : allCE) { installationDirectory = ExtensionManager::getInstallationString(ce->getLocation(), globalDir, userDir, currentWorkingDir); components << " - " + installationDirectory + " " + ce->getName().leftJustified(35, '.') + " " + ce->getFileExtensions().join(", "); // to get more information, use ce->getDescription(); @@ -169,7 +169,7 @@ const QString Core::getConfig() { // directory extensions const QList< ComponentExtension* >& allDCE = ExtensionManager::getDataDirectoryComponentsList(); - foreach (ComponentExtension* ce, allDCE) { + for (ComponentExtension* ce : allDCE) { installationDirectory = ExtensionManager::getInstallationString(ce->getLocation(), globalDir, userDir, currentWorkingDir); components << " - " + installationDirectory + " " + ce->getName().leftJustified(35, '.') + " directory"; @@ -198,7 +198,7 @@ const QString Core::getConfig() { QStringList actions; const QList< ActionExtension* >& allActions = ExtensionManager::getActionExtensionsList(); - foreach (ActionExtension* ae, allActions) { + for (ActionExtension* ae : allActions) { QStringList actionNames; for (Action* a : ae->getActions()) { actionNames << a->getName(); diff --git a/sdk/libraries/core/Core.h b/sdk/libraries/core/Core.h index 17f054c5a0ab87c3e074dac52f06978315f087a0..153db96f43ad3f7b5d97e66b06863ff257e5ae0a 100644 --- a/sdk/libraries/core/Core.h +++ b/sdk/libraries/core/Core.h @@ -26,16 +26,8 @@ #ifndef CAMITKCORE_H #define CAMITKCORE_H - - // -- Core stuff #include "CamiTKAPI.h" -#include "HistoryItem.h" - -// -- Qt stuff -#include - - namespace camitk { /** diff --git a/sdk/libraries/core/ExtensionManager.cpp b/sdk/libraries/core/ExtensionManager.cpp index f76067df2105f4a911601159217361eb06f69e17..ea60d073bcc682e212dd13008ef0ef15dd83ba6b 100644 --- a/sdk/libraries/core/ExtensionManager.cpp +++ b/sdk/libraries/core/ExtensionManager.cpp @@ -64,10 +64,10 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) { QStringList extensionFileNames; QStringList extensionAbsoluteFileNames; QMap extensionUniqueDir; - foreach (QString dirName, extensionDir) { + for (QString dirName : extensionDir) { QDir dir(dirName); QStringList pluginFileNames = getPluginFileNames(dir); - foreach (QString pluginFile, pluginFileNames) { + for (QString pluginFile : pluginFileNames) { QString pluginAbsoluteFileName = dir.absoluteFilePath(pluginFile); if (!extensionFileNames.contains(pluginFile)) { extensionFileNames.append(pluginFile); @@ -110,7 +110,7 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) { if (extensionAbsoluteFileNames.size() > 0) { // get the messages from Qt QStringList errorStrings; - foreach (QString fileName, extensionAbsoluteFileNames) { + for (QString fileName : extensionAbsoluteFileNames) { QPluginLoader pluginLoader(fileName); QObject* plugin = pluginLoader.instance(); @@ -153,7 +153,7 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) { } settings.endGroup(); - foreach (QString userRegisteredExtensionFile, userRegisteredExtensions) { + for (QString userRegisteredExtensionFile : userRegisteredExtensions) { loadExtension(type, userRegisteredExtensionFile); } @@ -205,7 +205,7 @@ bool ExtensionManager::loadExtension(ExtensionManager::ExtensionType type, QStri } else { // (cannot do that in the constructor because the virtual symbol table seems to be confused!) - foreach (QString ext, cp->getFileExtensions()) { + for (QString ext : cp->getFileExtensions()) { ComponentExtension* existingComponentExtension = getComponentExtensionMap().value(ext); if (existingComponentExtension != nullptr) { CAMITK_INFO_ALT(tr("Extension Manager: duplicate extension management: component extension \"%1\" (in file \"%2\") declares management of \"%3\" file extension while \"%4\" extension (loaded from file \"%5\") is already managing \"%6\".\nUsing extension in \"%7\" instead (higher priority) as only one component extension can manage a give file extension.") @@ -440,7 +440,7 @@ QStringList ExtensionManager::getPluginFileNames(QDir extensionsDir) { } else { // remove debug dll one by one - foreach (QString debugDLL, pluginFileNamesDebugMSVC) { + for (QString debugDLL : pluginFileNamesDebugMSVC) { pluginFileNames.removeAll(debugDLL); } return pluginFileNames; @@ -456,7 +456,7 @@ bool ExtensionManager::unloadActionExtension(QString fileName) { if (getActionExtensionMap().contains(fileName)) { ActionExtension* ext = getActionExtensionMap().value(fileName); //-- unregister all actions - foreach (Action* action, ext->getActions()) { + for (Action* action : ext->getActions()) { getActionExtensionMap().remove(action->getName()); } //-- unregister extension diff --git a/sdk/libraries/core/HistoryComponent.h b/sdk/libraries/core/HistoryComponent.h index 2a398f617828f16e881b433dd5b22ecde1f8449f..a54a3b21db7b9004d143ce21cde90863d3286e0a 100644 --- a/sdk/libraries/core/HistoryComponent.h +++ b/sdk/libraries/core/HistoryComponent.h @@ -29,11 +29,12 @@ // Qt stuffs #include -// CamiTK stuffs -#include +// CamiTK stuff +#include "CamiTKAPI.h" namespace camitk { +class Component; /** * @ingroup group_sdk_libraries_core diff --git a/sdk/libraries/core/HistoryItem.h b/sdk/libraries/core/HistoryItem.h index 2865efcf3f53fb761dc18293c93eb42cdf8b583b..aae740b9acab854fa529b1eb32401782c87d71a2 100644 --- a/sdk/libraries/core/HistoryItem.h +++ b/sdk/libraries/core/HistoryItem.h @@ -32,7 +32,6 @@ #include // CamiTK stuffs -#include #include "HistoryComponent.h" namespace camitk { diff --git a/sdk/libraries/core/action/Action.cpp b/sdk/libraries/core/action/Action.cpp index a3a5bc4ead718a7b40cb8c7670f9d798f10332e2..5abf559fc0109fcaadda84d4cc59d9aa2e9f0c62 100644 --- a/sdk/libraries/core/action/Action.cpp +++ b/sdk/libraries/core/action/Action.cpp @@ -49,7 +49,7 @@ Action::Action(ActionExtension* extension) : QObject() { // -------------------- destructor -------------------- Action::~Action() { // delete all properties - foreach (Property* prop, parameterMap.values()) { + for (Property* prop : parameterMap.values()) { delete prop; } parameterMap.clear(); @@ -176,7 +176,7 @@ Action::ApplyStatus Action::trigger(QWidget* parent) { targetComponents.clear(); ComponentList selComp = Application::getSelectedComponents(); - foreach (Component* comp, selComp) { + for (Component* comp : selComp) { // check compatibility if (comp->isInstanceOf(this->getComponent())) { targetComponents.append(comp); @@ -266,7 +266,7 @@ Action::ApplyStatus Action::applyInPipeline() { void Action::setInputComponents(ComponentList inputs) { //-- build the list of valid targets targetComponents.clear(); - foreach (Component* comp, inputs) { + for (Component* comp : inputs) { // check compatibility if (comp->isInstanceOf(this->getComponent())) { targetComponents.append(comp); @@ -314,7 +314,7 @@ void Action::preProcess() { // We will select the one selected as input of the current action this->topLevelSelectedComponents.clear(); QList topLevelSelectedHistoryComponents; - foreach (Component* comp, this->aliveBeforeComponents) { + for (Component* comp : this->aliveBeforeComponents) { if (comp->isSelected()) { this->topLevelSelectedComponents.append(comp); topLevelSelectedHistoryComponents.append(HistoryComponent(comp)); @@ -340,7 +340,7 @@ void Action::postProcess() { ComponentList topLevelComponentCreated; QList topLevelHistoryComponentCreated; topLevelHistoryComponentCreated.clear(); - foreach (Component* comp, Application::getTopLevelComponents()) { + for (Component* comp : Application::getTopLevelComponents()) { if (!this->aliveBeforeComponents.contains(comp)) { topLevelComponentCreated.append(comp); topLevelHistoryComponentCreated.append(HistoryComponent(comp)); @@ -352,7 +352,7 @@ void Action::postProcess() { // Add the action's parameters to the history item // get back all the properties dynamically added to the action using Qt meta object - foreach (QByteArray propertyName, dynamicPropertyNames()) { + for (QByteArray propertyName : dynamicPropertyNames()) { item->addProperty(propertyName, property(propertyName)); } @@ -365,7 +365,7 @@ void Action::postProcess() { void Action::postProcessInPipeline() { outputComponents.clear(); ComponentList allComp = Application::getAllComponents(); - foreach (Component* comp, allComp) { + for (Component* comp : allComp) { if (!aliveBeforeComponents.contains(comp) || comp->getModified()) { outputComponents.append(comp); } diff --git a/sdk/libraries/core/action/Action.h b/sdk/libraries/core/action/Action.h index e1953cb320f6159c9dd74e7ec23096dfa49ddb34..476246c3ff079cae4ba51b3772c04c99a794b5c9 100644 --- a/sdk/libraries/core/action/Action.h +++ b/sdk/libraries/core/action/Action.h @@ -235,7 +235,7 @@ public: ///@return the QString equivalement of the given status static QString getStatusAsString(ApplyStatus); -public slots: +public Q_SLOTS: /** * This method triggers the action. * The parent widget is used if the action is embedded, see class description for more information about the algorithm. diff --git a/sdk/libraries/core/action/ActionWidget.cpp b/sdk/libraries/core/action/ActionWidget.cpp index 357afd7c52eb9b9e6b61ca1a9b3f5addacb63139..5db4fde928673204a6c48ec35e05e28aa386e790 100644 --- a/sdk/libraries/core/action/ActionWidget.cpp +++ b/sdk/libraries/core/action/ActionWidget.cpp @@ -160,7 +160,7 @@ void ActionWidget::update() { QString ActionWidget::getTargetLabel() { QString targetNames = "
      "; - foreach (Component* comp, myAction->getTargets()) { + for (Component* comp : myAction->getTargets()) { targetNames += "
    • " + comp->getName() + " (" + comp->metaObject()->className() + ") " + "
    • "; } diff --git a/sdk/libraries/core/application/Application.cpp b/sdk/libraries/core/application/Application.cpp index d5fe1c9e29bef9b0df3f24294b891b67f640f55f..6eacbe5faa7a742da3175f98f03c6e0c85ea458e 100644 --- a/sdk/libraries/core/application/Application.cpp +++ b/sdk/libraries/core/application/Application.cpp @@ -104,7 +104,7 @@ Application::Application(QString name, int& theArgc, char** theArgv, bool autolo QStringList recentDoc = settings.value("recentDocuments").toStringList(); recentDocuments.clear(); - foreach (QString fileName, recentDoc) { + for (QString fileName : recentDoc) { recentDocuments.append(fileName); } @@ -130,7 +130,7 @@ Application::Application(QString name, int& theArgc, char** theArgv, bool autolo fileExtensionForbidden.append("tif"); fileExtensionForbidden.append("tiff"); - foreach (QString extensionFile, ExtensionManager::getFileExtensions()) { + for (QString extensionFile : ExtensionManager::getFileExtensions()) { // check the application can handle new file type if (!fileExtensionsAlreadyRegistered.contains(extensionFile) && !fileExtensionForbidden.contains(extensionFile)) { newFileExtensions.append(extensionFile); @@ -153,7 +153,7 @@ Application::Application(QString name, int& theArgc, char** theArgv, bool autolo if (msgBox.exec() == QMessageBox::Yes) { // user agrees : register each new file type - foreach (QString fileExtensionToRegister, newFileExtensions) { + for (QString fileExtensionToRegister : newFileExtensions) { ExtensionManager::registerFileExtension(fileExtensionToRegister); } } @@ -193,6 +193,14 @@ Application::~Application() { delete propertyObject; } + if (translator) { + delete translator; //delete instance of internationalization support + } + + // delete all actions (they are instantiated when the extension is loaded) + CAMITK_INFO(tr("Unloading actions...")) + ExtensionManager::unloadAllActionExtensions(); + // finish all logging properly CAMITK_INFO(tr("Exiting application...")) } @@ -206,13 +214,6 @@ QString Application::getName() { void Application::quitting() { // this is connect to the aboutToQuit signal from QApplication // it should contain all the code that frees the resources - - // delete all actions (they are instantiated when the extension is loaded) - ExtensionManager::unloadAllActionExtensions(); - - if (translator) { - delete translator; //delete instance of internationalization support - } } // ----------------- notify -------------------- @@ -711,7 +712,7 @@ const ActionList Application::getActions() { int Application::registerAllActions(ActionExtension* ext) { int registered = 0; - foreach (Action* action, ext->getActions()) { + for (Action* action : ext->getActions()) { // check if an action with same name was not already registered if (getActionMap().contains(action->getName())) { CAMITK_ERROR_ALT(tr("Cannot register action: %1 (extension: %2, family: %3, description: \"%4\")\n" @@ -735,7 +736,7 @@ int Application::registerAllActions(ActionExtension* ext) { int Application::unregisterAllActions(ActionExtension* ext) { int registered = 0; - foreach (Action* action, ext->getActions()) { + for (Action* action : ext->getActions()) { getActionMap().remove(action->getName()); registered++; } @@ -770,14 +771,14 @@ ActionList Application::getActions(Component* component) { if (component) { QStringList componentHierarchy = component->getHierarchy(); - foreach (Action* currentAct, Application::getActions()) { + for (Action* currentAct : Application::getActions()) { if (componentHierarchy.contains(currentAct->getComponent())) { actions.insert(currentAct); } } } else { - foreach (Action* currentAct, Application::getActions()) { + for (Action* currentAct : Application::getActions()) { if (currentAct->getComponent().isEmpty()) { actions.insert(currentAct); } @@ -796,7 +797,7 @@ ActionList Application::getActions(ComponentList cList) { else { ActionSet actions; - foreach (Component* currentComp, cList) { + for (Component* currentComp : cList) { actions += getActions(currentComp).toSet(); } @@ -812,7 +813,7 @@ ActionList Application::getActions(ComponentList selComp, QString tag) { // now check possibleActions considering the tag value ActionList actions; - foreach (Action* action, possibleActions) { + for (Action* action : possibleActions) { if (action->getTag().contains(tag)) { actions.append(action); } @@ -910,10 +911,10 @@ void Application::setSelected(Component* component, bool isSelected) { // -------------------- clearSelectedComponents -------------------- void Application::clearSelectedComponents() { - foreach (Component* comp, getSelectedComponentList()) { + for (Component* comp : getSelectedComponentList()) { comp->setSelected(false); } - + getSelectedComponentList().clear(); } @@ -1016,7 +1017,7 @@ void Application::saveHistoryAsSXML() { actionElement.appendChild(parametersElement); if (!action->dynamicPropertyNames().isEmpty()) { - foreach (QByteArray actionParameter, action->dynamicPropertyNames()) { + for (QByteArray actionParameter : action->dynamicPropertyNames()) { QDomElement parameterElement = doc.createElement("camitk:parameter"); parameterElement.setAttribute("name", QString(actionParameter)); parameterElement.setAttribute("type", QVariant::typeToName(action->property(actionParameter).type())); @@ -1125,7 +1126,7 @@ void Application::saveHistoryAsSXML() { QDomElement closeElement = doc.createElement("camitk:close"); onTransitionElement.appendChild(closeElement); - foreach (HistoryComponent outputHistoryComponent, previousItem.getOutputHistoryComponents()) { + for (HistoryComponent outputHistoryComponent : previousItem.getOutputHistoryComponents()) { QDomElement backTransitionComponentElement = doc.createElement("camitk:component"); closeElement.appendChild(backTransitionComponentElement); @@ -1187,7 +1188,7 @@ void Application::saveHistoryAsSXML() { QDomElement finalEltTransition_close = doc.createElement("camitk:close"); finalEltTransition_onTransition.appendChild(finalEltTransition_close); - foreach (HistoryComponent createdComponent, allCreatedComponents) { + for (HistoryComponent createdComponent : allCreatedComponents) { QDomElement finalEltTransition_comp = doc.createElement("camitk:component"); finalEltTransition_close.appendChild(finalEltTransition_comp); diff --git a/sdk/libraries/core/application/Application.h b/sdk/libraries/core/application/Application.h index f051c48040d835225a0c49d3af5078a8bf508362..cb6f0ee614d8c4dfcc31b1b93a8d7700628e9a7e 100644 --- a/sdk/libraries/core/application/Application.h +++ b/sdk/libraries/core/application/Application.h @@ -354,9 +354,10 @@ public: */ static PropertyObject* getPropertyObject(); ///}@ - -private slots: - void quitting(); + +private Q_SLOTS: + /// This slot is connected to the aboutToQuit() signal and cleanup before quitting + static void quitting(); private: /// name of the CamiTK application (used to differentiate settings between CamiTK applications) @@ -370,7 +371,7 @@ private: /// argv given from command line static char** argv; - + /// @name Recent document management ///@{ /// list of all the remembered recent documents (last opened is last inserted!) @@ -516,6 +517,7 @@ protected: * Each time a property has dynamically changed, this method is called. */ bool eventFilter(QObject* object, QEvent* event) override; + }; diff --git a/sdk/libraries/core/application/MainWindow.cpp b/sdk/libraries/core/application/MainWindow.cpp index 82c6c52da99282a86768e0c1aee2e28ca0d83522..c87f525d0cad607e90f9119f62336a56df615210 100644 --- a/sdk/libraries/core/application/MainWindow.cpp +++ b/sdk/libraries/core/application/MainWindow.cpp @@ -208,7 +208,7 @@ bool MainWindow::removeViewer(Viewer* viewer) { } // tell all component not to be visible anymore in this viewer - foreach (Component* comp, Application::getAllComponents()) { + for (Component* comp : Application::getAllComponents()) { comp->setVisibility(viewer, false); } @@ -229,7 +229,7 @@ void MainWindow::showViewer(Viewer* theViewer, bool visible) { // -------------------- refreshViewers -------------------- void MainWindow::refreshViewers() { - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { v->refresh(); } } @@ -280,7 +280,7 @@ const Viewer& MainWindow::getCentralViewer() const { // ------------- refresh ----------------- void MainWindow::refresh() { Viewer* whoIsAsking = qobject_cast (sender()); - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { if (v != whoIsAsking) { v->refresh(); } diff --git a/sdk/libraries/core/application/SettingsDialog.cpp b/sdk/libraries/core/application/SettingsDialog.cpp index 52069ab39222f4159663f249e45cb872ad219711..3007e920d24c8c8cbf999d7d40d7bb1cd03a1447 100644 --- a/sdk/libraries/core/application/SettingsDialog.cpp +++ b/sdk/libraries/core/application/SettingsDialog.cpp @@ -181,7 +181,7 @@ void SettingsDialog::updateActionExtensionList() { // loop over all ActionExtensions unsigned int actionId = 0; - foreach (ActionExtension* ae, aeList) { + for (ActionExtension* ae : aeList) { // create table row for (int i = 0; i < ae->getActions().size(); i++) { Action* action = ae->getActions().at(i); @@ -340,7 +340,7 @@ void SettingsDialog::on_removeActionExtensionButton_released() { if (actions.size() > 1) { QString actionName = myUI->actionExtensionList->item(myUI->actionExtensionList->currentRow(), 0)->text(); QStringList actionNames; - foreach (Action* a, actions) { + for (Action* a : actions) { if (a->getName() != actionName) { actionNames << a->getName(); } diff --git a/sdk/libraries/core/component/Component.cpp b/sdk/libraries/core/component/Component.cpp index 44faba92a5634bac0292db301833bd4b9ab05711..086982051b0a869c3781dce6ba5b9ba071268531 100644 --- a/sdk/libraries/core/component/Component.cpp +++ b/sdk/libraries/core/component/Component.cpp @@ -99,7 +99,7 @@ Component::~Component() { } // delete all properties - foreach (Property* prop, propertyMap.values()) { + for (Property* prop : propertyMap.values()) { delete prop; } propertyMap.clear(); @@ -348,7 +348,7 @@ QMenu* Component::getActionMenu() { //-- add all actions sorted by family ActionList allActions = Application::getActions(this); QMap familyMap; - foreach (Action* action, allActions) { + for (Action* action : allActions) { ActionSet* familySet = familyMap.value(action->getFamily().toLower()); if (!familySet) { familySet = new ActionSet; @@ -358,13 +358,13 @@ QMenu* Component::getActionMenu() { } //-- create one sub menu per family (unless there is only one action) - foreach (ActionSet* familySet, familyMap.values()) { + for (ActionSet* familySet : familyMap.values()) { // sort actions by name ActionList familyList = familySet->toList(); qSort(familyList.begin(), familyList.end(), actionLessThan); if (familyList.size() >= 1) { QMenu* familyMenu = actionsMenu->addMenu(familyList.first()->getFamily()); - foreach (Action* action, familyList) { + for (Action* action : familyList) { familyMenu->addAction(action->getQAction()); } } @@ -401,7 +401,7 @@ const InterfaceGeometry::RenderingModes Component::getRenderingModes() const { // else return the added rendering mode of all children if (childrenComponent.size() > 0) { InterfaceGeometry::RenderingModes m = InterfaceGeometry::None; - foreach (Component* childComponent, childrenComponent) { + for (Component* childComponent : childrenComponent) { m |= childComponent->getRenderingModes(); } return m; @@ -442,7 +442,7 @@ void Component::getBounds(double* bounds) { bounds[0] = bounds[2] = bounds[4] = 0.0; bounds[1] = bounds[3] = bounds[5] = 1.0; // compute bounds using the children's - foreach (Component* childComponent, childrenComponent) { + for (Component* childComponent : childrenComponent) { double childBounds[6]; //xmin,xmax, ymin,ymax, zmin,zmax // get child bounds childComponent->getBounds(childBounds); @@ -470,7 +470,7 @@ double Component::getBoundingRadius() { else { // compute bounding radius using the children's double radius = 0.0; - foreach (Component* childComponent, childrenComponent) { + for (Component* childComponent : childrenComponent) { double childRadius = childComponent->getBoundingRadius(); if (childRadius > radius) { radius = childRadius; @@ -536,7 +536,7 @@ void Component::setSelected(const bool b, const bool recursive) { isSelectedFlag = b; // maintain the children selection state as well if (recursive) { - foreach (Component* child, childrenComponent) { + for (Component* child : childrenComponent) { child->setSelected(b, recursive); } } @@ -568,12 +568,12 @@ void Component::removeChild(InterfaceNode* childNode) { void Component::deleteChildren() { // calling clear() on a QSet does not delete the instances // (the destuctor of points is not called, the Component are not deleted from the memory) - foreach (Component* childComp, childrenComponent) { + while(childrenComponent.size() > 0) { + Component* childComp = childrenComponent.takeFirst(); if (Application::isAlive(childComp)) { delete childComp; } } - childrenComponent.clear(); } // -------------------- setGlyphType -------------------- diff --git a/sdk/libraries/core/component/Component.h b/sdk/libraries/core/component/Component.h index 27467213aed4a0b1da0b8caf3b8eae4d65aa03ff..24cb05fa764635c95216af7b00f369832e02419c 100644 --- a/sdk/libraries/core/component/Component.h +++ b/sdk/libraries/core/component/Component.h @@ -118,27 +118,27 @@ if (HANDLER) \ * Call a given METHOD eventually with PARAM for all childrenComponent */ #define invokeChildren0(METHOD) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(); \ } #define invokeChildren1(METHOD,PARAM) \ -foreach (Component *child, childrenComponent) { \ - child->METHOD(PARAM); \ - } +for(Component *child : childrenComponent) { \ + child->METHOD(PARAM); \ +} #define invokeChildren2(METHOD,PARAM1,PARAM2) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(PARAM1,PARAM2); \ } #define invokeChildren3(METHOD,PARAM1,PARAM2,PARAM3) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(PARAM1,PARAM2,PARAM3); \ } #define invokeChildren4(METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(PARAM1,PARAM2,PARAM3,PARAM4); \ } @@ -558,9 +558,10 @@ public: if (myGeometry) { return myGeometry->getProp(param); } - else if (mySlice) { - return mySlice->getProp(param); - } + else + if (mySlice) { + return mySlice->getProp(param); + } return nullptr; } @@ -568,9 +569,10 @@ public: if (myGeometry) { return myGeometry->getNumberOfProp(); } - else if (mySlice) { - return mySlice->getNumberOfProp(); - } + else + if (mySlice) { + return mySlice->getNumberOfProp(); + } return 0; } @@ -578,9 +580,10 @@ public: if (myGeometry) { return myGeometry->getProp(index); } - else if (mySlice) { - return mySlice->getProp(index); - } + else + if (mySlice) { + return mySlice->getProp(index); + } return nullptr; } @@ -588,9 +591,10 @@ public: if (myGeometry) { return myGeometry->addProp(name, prop); } - else if (mySlice) { - return mySlice->addProp(name, prop); - } + else + if (mySlice) { + return mySlice->addProp(name, prop); + } return false; } @@ -599,9 +603,10 @@ public: if (myGeometry) { return myGeometry->removeProp(name); } - else if (mySlice) { - return mySlice->removeProp(name); - } + else + if (mySlice) { + return mySlice->removeProp(name); + } return false; } // END TODO diff --git a/sdk/libraries/core/component/Frame.cpp b/sdk/libraries/core/component/Frame.cpp index 58b993a6d07b39f714c2032126d7c1f37284c6d4..8f0f15a49dbc9a0950fdbf2b39280fca293ba40d 100644 --- a/sdk/libraries/core/component/Frame.cpp +++ b/sdk/libraries/core/component/Frame.cpp @@ -84,7 +84,7 @@ Frame::~Frame() { } // Declare my children as orpheans - foreach (InterfaceFrame* f, childrenFrame) { + for (InterfaceFrame* f : childrenFrame) { f->setParentFrame(nullptr); } @@ -128,7 +128,7 @@ void Frame::setParentFrame(InterfaceFrame* parent, bool keepTransform) { // compute all the descendants of the current frame QVector descendants = computeDescendants(this); // check if one of the descendant if the checked parent - foreach (InterfaceFrame* descendant, descendants) { + for (InterfaceFrame* descendant : descendants) { if (descendant->getFrameName() == checkedParent->getFrameName()) { //remove the new parent in the list of children removeFrameChild(checkedParent); @@ -421,7 +421,7 @@ QVector Frame::computeDescendants(InterfaceFrame* frame) { QVector descendants; // recursively call to get all the descendants of 'frame' - foreach (InterfaceFrame* child, frame->getChildrenFrame()) { + for (InterfaceFrame* child : frame->getChildrenFrame()) { descendants.append(child); descendants += computeDescendants(child); } diff --git a/sdk/libraries/core/component/image/ImageComponent.cpp b/sdk/libraries/core/component/image/ImageComponent.cpp index 7cbb8490036f5474dc16cc8948d658eaf98f2c57..278b91172019284d4f916c0dedb6f8e55bd6f3fc 100644 --- a/sdk/libraries/core/component/image/ImageComponent.cpp +++ b/sdk/libraries/core/component/image/ImageComponent.cpp @@ -405,31 +405,31 @@ void ImageComponent::initLookupTable() { // -------------------- replaceImageData -------------------- void ImageComponent::replaceImageData(vtkSmartPointer anImageData, bool copy, ImageOrientationHelper::PossibleImageOrientations initialOrientation) { // Delete ImageComponents - if (axialSlices) { + if (axialSlices != nullptr) { removeChild(axialSlices); delete axialSlices; axialSlices = nullptr; } - if (coronalSlices) { + if (coronalSlices != nullptr) { removeChild(coronalSlices); delete coronalSlices; coronalSlices = nullptr; } - if (sagittalSlices) { + if (sagittalSlices != nullptr) { removeChild(sagittalSlices); delete sagittalSlices; sagittalSlices = nullptr; } - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { removeChild(arbitrarySlices); delete arbitrarySlices; arbitrarySlices = nullptr; } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { removeChild(volumeRenderingChild); delete volumeRenderingChild; volumeRenderingChild = nullptr; @@ -510,45 +510,45 @@ void ImageComponent::update3DViewer() { bool viewIn3D = property("Display Image in 3D Viewer").toBool(); if (viewIn3D) { - if (axialSlices) { + if (axialSlices != nullptr) { axialSlices->setViewSliceIn3D(true); } - if (coronalSlices) { + if (coronalSlices != nullptr) { coronalSlices->setViewSliceIn3D(true); } - if (sagittalSlices) { + if (sagittalSlices != nullptr) { sagittalSlices->setViewSliceIn3D(true); } - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { // by default not visible in 3D arbitrarySlices->setViewSliceIn3D(false); } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { volumeRenderingChild->setVisibility(InteractiveViewer::get3DViewer(), true); } } else { - if (axialSlices) { + if (axialSlices != nullptr) { axialSlices->setViewSliceIn3D(false); } - if (coronalSlices) { + if (coronalSlices != nullptr) { coronalSlices->setViewSliceIn3D(false); } - if (sagittalSlices) { + if (sagittalSlices != nullptr) { sagittalSlices->setViewSliceIn3D(false); } - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { arbitrarySlices->setViewSliceIn3D(false); } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { volumeRenderingChild->setVisibility(InteractiveViewer::get3DViewer(), false); } } @@ -557,25 +557,25 @@ void ImageComponent::update3DViewer() { // -------------------- buildImageComponents -------------------- void ImageComponent::buildImageComponents() { - if (!axialSlices) { + if (axialSlices == nullptr) { axialSlices = new SingleImageComponent(this, Slice::AXIAL, "Axial view", lut); } if (this->originalImageData->GetDataDimension() == 3) { - if (!coronalSlices) { + if (coronalSlices == nullptr) { coronalSlices = new SingleImageComponent(this, Slice::CORONAL, "Coronal view", lut); } - if (!sagittalSlices) { + if (sagittalSlices == nullptr) { sagittalSlices = new SingleImageComponent(this, Slice::SAGITTAL, "Sagittal view", lut); } - if (!arbitrarySlices) { + if (arbitrarySlices == nullptr) { // TODO implement arbitrary slice orientation - arbitrarySlices = nullptr; // new SingleImageComponent(this, Slice::ARBITRARY, "Arbitrary view", lut); + //arbitrarySlices = new SingleImageComponent(this, Slice::ARBITRARY, "Arbitrary view", lut); } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { delete volumeRenderingChild; } @@ -587,25 +587,25 @@ void ImageComponent::buildImageComponents() { } else { - if (coronalSlices) { + if (coronalSlices != nullptr) { delete coronalSlices; } coronalSlices = nullptr; - if (sagittalSlices) { + if (sagittalSlices != nullptr) { delete sagittalSlices; } sagittalSlices = nullptr; - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { delete arbitrarySlices; } arbitrarySlices = nullptr; - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { delete volumeRenderingChild; } @@ -652,7 +652,7 @@ void ImageComponent::pixelPicked(double x, double y, double z, SingleImageCompon getLastPointPickedWorldCoords(&wx, &wy, &wz); // Update each child even the one who is asking i order to display correctly the pixel pixed. - foreach (Component* dc, getChildren()) { + for (Component* dc : getChildren()) { SingleImageComponent* child = dynamic_cast(dc); if (child) { @@ -729,7 +729,7 @@ vtkSmartPointer ImageComponent::getLut() { // -------------------- setSelected -------------------- void ImageComponent::setSelected(const bool b, const bool) { - foreach (Component* dc, getChildren()) { + for (Component* dc : getChildren()) { SingleImageComponent* child = dynamic_cast(dc); if (child) { @@ -772,7 +772,7 @@ void ImageComponent::getLastPointPickedWorldCoords(double* x, double* y, double* // -------------------- refresh -------------------- void ImageComponent::refresh() const { - foreach (const Component* dc, childrenComponent) { + for (const Component* dc : childrenComponent) { dc->refresh(); } } diff --git a/sdk/libraries/core/component/image/ImageComponent.h b/sdk/libraries/core/component/image/ImageComponent.h index 549f2b7e30690feeeeda49949079f08c36a87eb1..1eb4958691446c1bf9f20cf6c021928d74e83978 100644 --- a/sdk/libraries/core/component/image/ImageComponent.h +++ b/sdk/libraries/core/component/image/ImageComponent.h @@ -27,8 +27,8 @@ #define IMAGE_COMPONENT_H // -- Core image component stuff -#include "SingleImageComponent.h" #include "CamiTKAPI.h" +#include "SingleImageComponent.h" #include "ImageOrientationHelper.h" // -- vtk stuff @@ -91,7 +91,7 @@ public: ImageComponent(vtkSmartPointer anImageData, const QString& name, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI); /// Destructor - ~ImageComponent() override; + virtual ~ImageComponent() override; /// set selected will select all the Image components (axial, sagittal and coronal). void setSelected(const bool b, const bool recursive = false) override; diff --git a/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp b/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp index fa8af613da3300fd52c05f4a562e256ea7b00b9f..3d959ecadbdef9b6a580b14ebf518de88e3fd46a 100644 --- a/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp +++ b/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp @@ -41,7 +41,7 @@ QStringList ImageAcquisitionComponentExtension::getImagerList() { //-- get componentextension list QList compExt = ExtensionManager::getComponentExtensionsList(); QStringList listImageAcqui; - foreach (ComponentExtension* ce, compExt) { + for (ComponentExtension* ce : compExt) { if (dynamic_cast(ce)) { // a new ImageAcquisitionComponentExtension:: we add to the list auto* im = dynamic_cast(ce); diff --git a/sdk/libraries/core/component/mesh/MeshComponent.cpp b/sdk/libraries/core/component/mesh/MeshComponent.cpp index e696f79e318823a3a3da2bc7c0317f1b23046ef4..7b8207bfe195904f84eba9afb50ec3cdeb9158c6 100644 --- a/sdk/libraries/core/component/mesh/MeshComponent.cpp +++ b/sdk/libraries/core/component/mesh/MeshComponent.cpp @@ -524,19 +524,16 @@ void MeshComponent::changeSelectedSelection(const QItemSelection& selected, cons // remove all the selection nodes from the selection currentSelection->RemoveAllNodes(); - // do not use selected since it contains only the new selected selections - // QModelIndexList items = selected.indexes(); - QModelIndex index; - QModelIndexList items = selectionView->selectionModel()->selectedRows(); - // Select the PropertyExplorer 'Selection' tab for the currently selected component if (!Application::getSelectedComponents().isEmpty()) { Component* currentComponent = Application::getSelectedComponents().last(); currentComponent->setIndexOfPropertyExplorerTab(1); } + // do not use selected since it contains only the new selected selections + // QModelIndexList items = selected.indexes(); // add each selected selection nodes to the current selection - foreach (index, items) { + for (QModelIndex index : selectionView->selectionModel()->selectedRows()) { currentSelection->Union(selectionList.at(index.row())); } @@ -789,7 +786,6 @@ bool MeshComponent::getDataRepresentationVisibility(FieldType field, const QStri } } - // -------------------- setDataRepresentationOff -------------------- void MeshComponent::setDataRepresentationOff(int dataType) { @@ -842,7 +838,8 @@ void MeshComponent::setDataRepresentationOff(int dataType) { // refresh the property tab and 3D dataModel->refresh(); - refresh(); + if (dataRepresentationVisibility.size()>0) + refresh(); } diff --git a/sdk/libraries/core/utils/ObjectController.cpp b/sdk/libraries/core/utils/ObjectController.cpp index 9fd889e5cf71d9621f2a4f74dc8143074160ae7f..ac661d3d986758c1b849098a458292ec858d4b9e 100644 --- a/sdk/libraries/core/utils/ObjectController.cpp +++ b/sdk/libraries/core/utils/ObjectController.cpp @@ -409,7 +409,7 @@ void ObjectControllerPrivate::addDynamicProperties(QObject* edited) { } // loop on all property attributes and transfer the values to subProperty - foreach (QString attributeName, camitkProp->getAttributeList()) { + for (QString attributeName : camitkProp->getAttributeList()) { subProperty->setAttribute(attributeName, camitkProp->getAttribute(attributeName)); // if this is an enum, setting the enumNames will reset the value to 0 // in case there is not a direct match between names and enum diff --git a/sdk/libraries/core/utils/Property.h b/sdk/libraries/core/utils/Property.h index a2a27c835e31d19903939bfd1a5668f50ff18a66..82077cf4d68ea711f34e51b0d9003124d8290f29 100644 --- a/sdk/libraries/core/utils/Property.h +++ b/sdk/libraries/core/utils/Property.h @@ -347,7 +347,7 @@ public: * CAMITK_INFO(tr("myProp does not have an attribute 'bad' (or this attribute is still equals to the default value)")) * } * - * It is recommended to only use this method inside a foreach(QString s: getAttributeList()) + * It is recommended to only use this method inside a "for (QString s : getAttributeList())" loop */ QVariant getAttribute(QString attName); diff --git a/sdk/libraries/core/utils/PropertyObject.cpp b/sdk/libraries/core/utils/PropertyObject.cpp index ace58d75f2eabba74521d8598832278397650765..b52364ff285ac1579213bf43b5aee0ccd958cb52 100644 --- a/sdk/libraries/core/utils/PropertyObject.cpp +++ b/sdk/libraries/core/utils/PropertyObject.cpp @@ -43,7 +43,7 @@ PropertyObject::PropertyObject(QString name) : QObject() { // -------------------- Destructor -------------------- PropertyObject::~PropertyObject() { // delete all properties - foreach (Property* prop, propertiesMap.values()) { + for (Property* prop : propertiesMap.values()) { delete prop; } propertiesMap.clear(); diff --git a/sdk/libraries/core/viewer/ActionViewer.cpp b/sdk/libraries/core/viewer/ActionViewer.cpp index 35df1bb4fde73d227b485cc7a2870daf8872096a..cadd61351138997a821e5eb29c77375fc825e8a7 100644 --- a/sdk/libraries/core/viewer/ActionViewer.cpp +++ b/sdk/libraries/core/viewer/ActionViewer.cpp @@ -204,7 +204,7 @@ void ActionViewer::updateActionViewer(UpdateReason reason) { possibleActions = Application::getActions(nullptr); } - foreach (Action* action, possibleActions) { + for (Action* action : possibleActions) { if (action->getFamily() == familyComboBox->currentText() || familyComboBox->currentText() == QString("-- Select Family --")) { nameComboBox->addItem(action->getName()); } @@ -235,7 +235,7 @@ void ActionViewer::updateActionViewer(UpdateReason reason) { else { nameComboBox->clear(); nameComboBox->addItem("-- Select Action --"); - foreach (Action* action, actionset) { + for (Action* action : actionset) { nameComboBox->addItem(action->getName()); } } @@ -266,14 +266,14 @@ void ActionViewer::updateActionViewer(UpdateReason reason) { else { // no selection => select only empty component actions possibleActions = Application::getActions(nullptr); } // Complete family and action lists depending of the last selected component - foreach (Action* action, possibleActions) { + for (Action* action : possibleActions) { if (familyComboBox->findText(action->getFamily()) == -1) { familyComboBox->addItem(action->getFamily()); } if (nameComboBox->findText(action->getName()) == -1) { nameComboBox->addItem(action->getName()); } - foreach (QString tag, action->getTag()) { + for (QString tag : action->getTag()) { if (!wordList.contains(tag)) { wordList.append(tag); } diff --git a/sdk/libraries/core/viewer/Explorer.cpp b/sdk/libraries/core/viewer/Explorer.cpp index cffa07dc2a01177f18f45f7c51404fac102fb0f4..db5e7e660368ec4883708f64822312963745b565 100644 --- a/sdk/libraries/core/viewer/Explorer.cpp +++ b/sdk/libraries/core/viewer/Explorer.cpp @@ -59,7 +59,7 @@ Explorer::~Explorer() { //----------------------- getInstance ------------------------ Explorer* Explorer::getInstance() { - // static instantiation, static method variable + // static instanciation, static method variable static Explorer* explorer = nullptr; if (!explorer) { explorer = new Explorer(); @@ -135,18 +135,18 @@ void Explorer::refresh(Viewer* whoIsAsking) { if (whoIsAsking != this) { //-- check the top-level component number ComponentList topLevelCpt = Application::getTopLevelComponents(); - ComponentList viewedcomp = itemCompMap.uniqueKeys(); + ComponentList viewedcomp = topLevelCompItemMap.uniqueKeys(); if (viewedcomp.size() != topLevelCpt.size()) { // remove the closed/deleted top-level component - foreach (Component* comp, viewedcomp) { + for (Component* comp : viewedcomp) { if (!topLevelCpt.contains(comp)) { - remove(comp); + removeTopLevel(comp); } } // add the new top-level component - foreach (Component* comp, topLevelCpt) { + for (Component* comp : topLevelCpt) { if (!viewedcomp.contains(comp)) { - add(comp); + addTopLevel(comp); } } } @@ -155,7 +155,7 @@ void Explorer::refresh(Viewer* whoIsAsking) { explorerTree->blockSignals(true); explorerTree->clearSelection(); if (!Application::getSelectedComponents().isEmpty()) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { if (comp->isSelected()) { QTreeWidgetItem* selected = getItem(comp); if (selected) { @@ -217,6 +217,7 @@ QTreeWidgetItem* Explorer::getNewItem(QTreeWidgetItem* parent, Component* abstra // add the pixmap tw->setIcon(0, abstractNode->getIcon()); } + // check the italic property QFont f = tw->font(0); f.setItalic(abstractNode->inItalic()); @@ -227,6 +228,24 @@ QTreeWidgetItem* Explorer::getNewItem(QTreeWidgetItem* parent, Component* abstra return tw; } +//----------------------- addTopLevel ------------------------ +void Explorer::addTopLevel(Component* comp, int index) { + if (!comp->getParent()) { + // create the items + QTreeWidgetItem* compItem = add(nullptr, comp); + + // add to / insert in the tree + if (index < 0) { + explorerTree->addTopLevelItem(compItem); + } + else { + explorerTree->insertTopLevelItem(index, compItem); + } + + // insert top-level component in the map + topLevelCompItemMap.insert(comp, compItem); + } +} //----------------------- add ------------------------ QTreeWidgetItem* Explorer::add(QTreeWidgetItem* parent, Component* abstractNode) { @@ -240,25 +259,13 @@ QTreeWidgetItem* Explorer::add(QTreeWidgetItem* parent, Component* abstractNode) abstractNode->setVisibility(this, true); //-- add children recursively - foreach (Component* comp, abstractNode->getChildren()) { + for (Component* comp : abstractNode->getChildren()) { add(tw, comp); } return tw; } -//----------------------- add ------------------------ -void Explorer::add(Component* comp) { - if (!comp->getParent()) { - // create the items - QTreeWidgetItem* compItem = add(nullptr, comp); - explorerTree->addTopLevelItem(compItem); - - // insert top-level component in the map - itemCompMap.insert(comp, compItem); - } -} - //----------------------- refreshInterfaceNode ------------------------ void Explorer::refreshInterfaceNode(Component* comp) { QTreeWidgetItem* toDelete = getItem(comp); @@ -267,30 +274,28 @@ void Explorer::refreshInterfaceNode(Component* comp) { // get the index in the parent list QTreeWidgetItem* parentTW = toDelete->parent(); int index = -1; - if (parentTW == nullptr) + if (parentTW == nullptr) { // if no parent, it means toDelete is at top level, get its index - { index = explorerTree->indexOfTopLevelItem(toDelete); } - else + else { // if the parent exists, then get the index of the child - { index = parentTW->indexOfChild(toDelete); } // remove from the list and from the explorer explorerTree->blockSignals(true); - remove(toDelete); // recreate and add at the same place - if (parentTW == nullptr) - // if there is no parent, then add at the correct index on the top level - { - explorerTree->insertTopLevelItem(index, add(nullptr, comp)); + if (parentTW == nullptr) { + // if there is no parent, first remove from the map + removeTopLevel(comp); + // and then add at the correct index on the top level + addTopLevel(comp, index); } - else + else { // add where it was deleted in the parent index - { + remove(toDelete); parentTW->insertChild(index, add(nullptr, comp)); } explorerTree->blockSignals(false); @@ -298,16 +303,16 @@ void Explorer::refreshInterfaceNode(Component* comp) { } -//----------------------- remove ------------------------ -void Explorer::remove(Component* comp) { - QTreeWidgetItem* toDelete = itemCompMap.value(comp); +//----------------------- removeTopLevel ------------------------ +void Explorer::removeTopLevel(Component* comp) { + QTreeWidgetItem* toDelete = topLevelCompItemMap.value(comp); if (toDelete != nullptr) { explorerTree->blockSignals(true); // remove from the explorer remove(toDelete); explorerTree->blockSignals(false); // remove from the map - itemCompMap.remove(comp); + topLevelCompItemMap.remove(comp); } } diff --git a/sdk/libraries/core/viewer/Explorer.h b/sdk/libraries/core/viewer/Explorer.h index aaf4935c40d75585daa3d413d9bacd6f64f0769b..fcb73c34ec92f05cb26d3f30122626c2bdccec60 100644 --- a/sdk/libraries/core/viewer/Explorer.h +++ b/sdk/libraries/core/viewer/Explorer.h @@ -124,7 +124,7 @@ private: QMap itemComponentMap; /// the map to get the QTreeWidgetItem corresponding to a parentComp - QMap itemCompMap; + QMap topLevelCompItemMap; /// Return the QTreeWidgetItem of a given Component (return NULL if not found) QTreeWidgetItem* getItem(Component*); @@ -132,7 +132,7 @@ private: /// @name QTreeWidget and QTreeWidgetItem management ///@{ - /// instantiate a new QTreeWidgetItem using names and properties from the InterfaceNode, and using parent + /// instanciate a new QTreeWidgetItem using names and properties from the InterfaceNode, and using parent QTreeWidgetItem* getNewItem(QTreeWidgetItem* parent, Component*); /// recursively add the Component in the tree explorer and return the QTreeWidgetItem of the InterfaceNode @@ -141,7 +141,7 @@ private: /** Add the given Component to the explorer (at top level) and automatically create children Component items. * @param comp The Component to add in the tree view. */ - void add(Component* comp); + void addTopLevel(Component* comp, int index = -1); /// remove a given item from the explorer (return its index in the parent item list) void remove(QTreeWidgetItem*); @@ -149,7 +149,7 @@ private: /** Remove the Component (its Component and its sub-item) from the explorer list (if present). * The Component itself is of course not deleted here. */ - void remove(Component* comp); + void removeTopLevel(Component* comp); /// the list view diff --git a/sdk/libraries/core/viewer/FrameExplorer.cpp b/sdk/libraries/core/viewer/FrameExplorer.cpp index 7548555db82de3f8f871108ed5d040a02a090c7d..eb4074437106294daa92e8259600a62932f8858e 100644 --- a/sdk/libraries/core/viewer/FrameExplorer.cpp +++ b/sdk/libraries/core/viewer/FrameExplorer.cpp @@ -94,7 +94,7 @@ void FrameExplorer::refresh(Viewer* whoIsAsking) { remove(); // rebuild the explorer tree - foreach (Component* comp, cptList) { + for (Component* comp : cptList) { add(comp); } @@ -113,9 +113,9 @@ QTreeWidgetItem* FrameExplorer::getNewItem(QTreeWidgetItem* parent, Component* a tw->setText(1, abstractNode->getName()); //-- add children recursively - foreach (InterfaceFrame* intFrame, (abstractNode->getFrame()->getChildrenFrame())) { + for (InterfaceFrame* intFrame : (abstractNode->getFrame()->getChildrenFrame())) { ComponentList cptlst = Application::getAllComponents(); - foreach (Component* cp, cptlst) { + for (Component* cp : cptlst) { if (cp->getFrame()->getFrameName() == intFrame->getFrameName()) { getNewItem(tw, cp); } @@ -142,9 +142,9 @@ QTreeWidgetItem* FrameExplorer::add(QTreeWidgetItem* parent, Component* abstract abstractNode->setVisibility(this, true); //-- add children - foreach (InterfaceFrame* intFrame, abstractNode->getFrame()->getChildrenFrame()) { + for (InterfaceFrame* intFrame : abstractNode->getFrame()->getChildrenFrame()) { ComponentList cptlst = Application::getAllComponents(); - foreach (Component* cp, cptlst) { + for (Component* cp : cptlst) { if (cp->getFrame()->getFrameName() == intFrame->getFrameName()) { getNewItem(tw, cp); } diff --git a/sdk/libraries/core/viewer/InteractiveViewer.cpp b/sdk/libraries/core/viewer/InteractiveViewer.cpp index 791f1a92356ff44ce12c505ca45dfd136c4e5f9b..0619d64a8d60dbdfe7b575f8c1be1ef346040682 100644 --- a/sdk/libraries/core/viewer/InteractiveViewer.cpp +++ b/sdk/libraries/core/viewer/InteractiveViewer.cpp @@ -512,7 +512,7 @@ void InteractiveViewer::refresh(Viewer* v) { if (v != this) { //-- check all present QList compRendered = actorMap.keys(); - foreach (Component* comp, compRendered) { + for (Component* comp : compRendered) { if (!Application::isAlive(comp)) { // remove from the renderer and map removeAllActors(comp); @@ -526,7 +526,7 @@ void InteractiveViewer::refresh(Viewer* v) { switch (myType) { case GEOMETRY_VIEWER: // check all Components - foreach (Component* comp, allComponents) { + for (Component* comp : allComponents) { // remove from the renderer and map removeAllActors(comp); @@ -572,7 +572,7 @@ void InteractiveViewer::refresh(Viewer* v) { case SLICE_VIEWER: // remove all from the renderer and map QList compRendered = actorMap.keys(); - foreach (Component* comp, compRendered) { + for (Component* comp : compRendered) { removeAllActors(comp); } @@ -671,7 +671,7 @@ void InteractiveViewer::refreshRenderer() { // ---------------------- removeAllActors ---------------------------- void InteractiveViewer::removeAllActors(Component* comp) { QList > actorRendered = actorMap.values(comp); - foreach (vtkSmartPointer a, actorRendered) { + for (vtkSmartPointer a : actorRendered) { rendererWidget->removeProp(a); } // remove from the list @@ -1132,7 +1132,7 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { // addWhatsThisItem("Alt+P", "Toggle point rendering"); if (e->modifiers() == Qt::AltModifier) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { // check if the Component is to be displayed here if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->setRenderingModes(comp->getRenderingModes() ^ InterfaceGeometry::Points); //XOR @@ -1154,7 +1154,7 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { // addWhatsThisItem("Alt+S", "Toggle surface rendering"); if (e->modifiers() == Qt::AltModifier) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { // check if the Component is to be displayed here if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->setRenderingModes(comp->getRenderingModes() ^ InterfaceGeometry::Surface); //XOR @@ -1183,7 +1183,7 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { // addWhatsThisItem("Alt+W", "Toggle wireframe rendering"); if (e->modifiers() == Qt::AltModifier) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { // check if the Component is to be displayed here if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->setRenderingModes(comp->getRenderingModes() ^ InterfaceGeometry::Wireframe); //XOR @@ -1366,14 +1366,14 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { debugStream << endl; debugStream << "== Component vtkProp ==" << endl; - foreach (Component* c, actorMap.keys().toSet()) { + for (Component* c : actorMap.keys().toSet()) { debugStream << "- Component: \"" << c->getName() << "\" of type \"" << c->metaObject()->className() << "\" has " << actorMap.values(c).size() << " vtkProp:" << endl; std::list > allActors = actorMap.values(c).toStdList(); allActors.sort(); allActors.unique(); - foreach (vtkSmartPointer p, allActors) { + for (vtkSmartPointer p : allActors) { // get more information by comparing with the getActor/getProp method of c bool found = false; switch (myType) { @@ -1609,7 +1609,7 @@ void InteractiveViewer::getBoundsOfSelected(double* bounds) { } // check the bound of all selected Component in the InteractiveViewer - foreach (Component* comp, actorMap.keys()) { + for (Component* comp : actorMap.keys()) { if (comp->isSelected()) { //if we are in this loop that is 1 element at least is selected then oneElementSelected = true; @@ -1649,7 +1649,7 @@ void InteractiveViewer::setSideFrameVisible(bool visibility) { //------------------------- toggleInterpolation ---------------------------- void InteractiveViewer::toggleInterpolation() { - foreach (Component* comp, actorMap.keys()) { + for (Component* comp : actorMap.keys()) { if (comp->getRepresentation() == Component::SLICE) { bool state = comp->get2DImageActor()->GetInterpolate(); comp->get2DImageActor()->SetInterpolate(!state); @@ -1929,7 +1929,7 @@ void InteractiveViewer::renderingActorsChanged() { } // update the rendering mode of selected - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { comp->setRenderingModes(m); } @@ -2043,7 +2043,7 @@ void InteractiveViewer::toggleCopyright(bool c) { // ------------- setLabel ----------------- void InteractiveViewer::setLabel(bool b) { // update the rendering mode of selected - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->getProp("label")->SetVisibility(b); } @@ -2055,7 +2055,7 @@ void InteractiveViewer::setLabel(bool b) { // ------------- setGlyph ----------------- void InteractiveViewer::setGlyph(bool b) { // update the rendering mode of selected - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->getProp("glyph")->SetVisibility(b); } diff --git a/sdk/libraries/core/viewer/InteractiveViewer.h b/sdk/libraries/core/viewer/InteractiveViewer.h index c9a041da38a37f39cc9a7abbf6b984b5a59685ed..09f0ad01bea24a4dca0962d7d4c46ff51a319d0a 100644 --- a/sdk/libraries/core/viewer/InteractiveViewer.h +++ b/sdk/libraries/core/viewer/InteractiveViewer.h @@ -248,7 +248,7 @@ public: /// call this method to take a screenshot using the given filename (the extension must be a supported format extension, see class RendererWindow) void screenshot(QString); -public slots: +public Q_SLOTS: /// call this method to take a screenshot in various format and write the resulting image to a file void screenshot(); /// @} @@ -263,7 +263,7 @@ public: /** @name Viewing/Interaction Property */ ///@{ -public slots: +public Q_SLOTS: /// set the backface culling mode (default is true). void setBackfaceCulling(bool); @@ -274,7 +274,7 @@ public: /// get the backface current culling mode. // bool getBackfaceCulling() const; -public slots: +public Q_SLOTS: /** Update the visualization of lines (for all the InterfaceGeometry of the scene). * * \note it is only possible to transform lines to tubes if @@ -333,7 +333,7 @@ public: void setSideFrameVisible(bool); ///@} -public slots: +public Q_SLOTS: /** Slot called when the InteractiveViewer slider has been changed. If there is a InterfaceBitMap in the scene, * set the slice index with the new slider value. */ @@ -616,7 +616,7 @@ protected: ///@} -protected slots: +protected Q_SLOTS: /** * @name All the slots called by the menu actions */ diff --git a/sdk/libraries/core/viewer/MedicalImageViewer.cpp b/sdk/libraries/core/viewer/MedicalImageViewer.cpp index 2b77687046c3db674b125f890942ef694f0dfdb6..d6797a1a9a27be92301933a2c5b065d1721154ec 100644 --- a/sdk/libraries/core/viewer/MedicalImageViewer.cpp +++ b/sdk/libraries/core/viewer/MedicalImageViewer.cpp @@ -85,7 +85,7 @@ unsigned int MedicalImageViewer::numberOfViewedComponent() { // -------------------- refresh -------------------- void MedicalImageViewer::refresh(Viewer* whoIsAsking) { // just tell everyone to update! - foreach (Viewer* v, viewers.values()) { + for (Viewer* v : viewers.values()) { v->refresh(this); } @@ -155,7 +155,7 @@ QWidget* MedicalImageViewer::getWidget(QWidget* parent) { //-- connect - foreach (LayoutVisibility v, viewerVisibility) { + for (LayoutVisibility v : viewerVisibility) { if (viewers.value(v)) { // prevent ALL connect(viewers.value(v), SIGNAL(selectionChanged()), this, SLOT(synchronizeSelection())); } @@ -257,7 +257,7 @@ void MedicalImageViewer::updateLayout() { void MedicalImageViewer::synchronizeSelection() { auto* whoIsAsking = qobject_cast(sender()); - foreach (Viewer* v, viewers.values()) { + for (Viewer* v : viewers.values()) { if (v != whoIsAsking) { v->refresh(whoIsAsking); } diff --git a/sdk/libraries/core/viewer/RendererWidget.cpp b/sdk/libraries/core/viewer/RendererWidget.cpp index b853e8c6f349469dadd8f9db970cda836f07ea46..eb9fcb997809568503d7e8ef1b2ef310d5880cbd 100644 --- a/sdk/libraries/core/viewer/RendererWidget.cpp +++ b/sdk/libraries/core/viewer/RendererWidget.cpp @@ -708,7 +708,7 @@ RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKWidget(p //---------------------- Destructor ------------------------ RendererWidget::~RendererWidget() { // delete all properties - foreach (ScreenshotFormatInfo* sfi, screenshotMap.values()) { + for (ScreenshotFormatInfo* sfi : screenshotMap.values()) { delete sfi; } screenshotMap.clear(); diff --git a/sdk/libraries/core/viewer/RendererWidget.h b/sdk/libraries/core/viewer/RendererWidget.h index aca75bf843ba6ce816994a333db644bab0bb267e..0de17f7bfe219054f3920eb0ce79f2c7d92efa59 100644 --- a/sdk/libraries/core/viewer/RendererWidget.h +++ b/sdk/libraries/core/viewer/RendererWidget.h @@ -417,7 +417,7 @@ public : -protected slots: +protected Q_SLOTS: ///@name picking and interaction ///@{ /// manage left mouse click interactions @@ -437,7 +437,7 @@ protected slots: ///@} -signals : +Q_SIGNALS : ///@name picking and interaction ///@{ diff --git a/sdk/libraries/core/viewer/Viewer.cpp b/sdk/libraries/core/viewer/Viewer.cpp index ef44e0f09c45204b1466082a93275b0fd7849cc9..bd8d31430a908cc8e7897e21bd57e2387dd6fd00 100644 --- a/sdk/libraries/core/viewer/Viewer.cpp +++ b/sdk/libraries/core/viewer/Viewer.cpp @@ -36,7 +36,7 @@ Viewer::Viewer(QString name): QObject() { //---------------------- selectionChanged ------------------------ void Viewer::selectionChanged(camitk::ComponentList& compSet) { - foreach (Component* comp, compSet) { + for (Component* comp : compSet) { comp->setSelected(true); } emit selectionChanged(); diff --git a/sdk/libraries/core/viewer/Viewer.h b/sdk/libraries/core/viewer/Viewer.h index 9d68720e895803d0a4b637435580986c94a28b69..ce5ac47f385ae6f5ce063fabc750b506c7c106e1 100644 --- a/sdk/libraries/core/viewer/Viewer.h +++ b/sdk/libraries/core/viewer/Viewer.h @@ -90,7 +90,7 @@ public: /// Is actually useful (and defined) in Explorer. virtual void refreshInterfaceNode(Component* comp) {}; -signals: +Q_SIGNALS: /// this signal is emitted when the current selection was changed by the viewer void selectionChanged(); diff --git a/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp b/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp index e2edb8b728c49076e131729633e6da6ceef28ecb..7db40688f50f98920b4d21c28956983fd8a3cdb3 100644 --- a/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp +++ b/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp @@ -58,7 +58,7 @@ ComputeNeighborValueAction::~ComputeNeighborValueAction() { // --------------- apply ------------------- Action::ApplyStatus ComputeNeighborValueAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/tutorials/actions/meshpointdata/ShowPointData.cpp b/tutorials/actions/meshpointdata/ShowPointData.cpp index dc7bb39b308ee608f28c0799cf079095fede2866..e250170ba3824a9e82b04d7618a9e3b35a85ec18 100644 --- a/tutorials/actions/meshpointdata/ShowPointData.cpp +++ b/tutorials/actions/meshpointdata/ShowPointData.cpp @@ -69,7 +69,7 @@ ShowPointData::~ShowPointData() { // --------------- apply ------------------- Action::ApplyStatus ShowPointData::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); diff --git a/tutorials/actions/properties/AddDynamicProperty.cpp b/tutorials/actions/properties/AddDynamicProperty.cpp index 69c24caf2d171a6a5dcaaa2a182d0601a3701b48..eeeebefa9425bf864326f55fb014376ca5f0041b 100644 --- a/tutorials/actions/properties/AddDynamicProperty.cpp +++ b/tutorials/actions/properties/AddDynamicProperty.cpp @@ -73,7 +73,7 @@ Action::ApplyStatus AddDynamicProperty::apply() { QString description = property("Description").toString(); QString unit = property("Unit").toString(); QString name = property("Name").toByteArray().constData(); - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { if (comp->getProperty(name)) { // the property already exits, modify its value switch (currentType) { diff --git a/tutorials/actions/properties/PropAction.cpp b/tutorials/actions/properties/PropAction.cpp index 6932cc5bb60c5c4b050f08750c80bfd522b352ef..4ff102910b185f5ce64bc5542e20b8f5088d0c2f 100644 --- a/tutorials/actions/properties/PropAction.cpp +++ b/tutorials/actions/properties/PropAction.cpp @@ -30,6 +30,8 @@ #include #include +#include + using namespace camitk; @@ -122,7 +124,7 @@ Action::ApplyStatus PropAction::apply() { // loop on all dynamic properties of this action (i.e. the action parameters) and // add each of them as a property of the currently selected components - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { QList dynProp = dynamicPropertyNames(); // loop on all dynamic properties @@ -143,7 +145,7 @@ Action::ApplyStatus PropAction::apply() { // copy all attributes newProp->setReadOnly(actionParam->getReadOnly()); - foreach (QString attributeName, actionParam->getAttributeList()) { + for (QString attributeName : actionParam->getAttributeList()) { newProp->setAttribute(attributeName, actionParam->getAttribute(attributeName)); } newProp->setEnumTypeName(actionParam->getEnumTypeName(), this); diff --git a/tutorials/actions/pythonscripting/CMakeLists.txt b/tutorials/actions/pythonscripting/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7283683daa13c9898f2ccb4c46b954d2545dd19c --- /dev/null +++ b/tutorials/actions/pythonscripting/CMakeLists.txt @@ -0,0 +1,91 @@ +# Only available if CamiTK Python is available +# TODO add a "NEEDS_PYTHON" flag in camitk_extension CamiTK macros +if(CAMITK_BINDING_PYTHON) + +# -- Python3 +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +if(NOT Python3_FOUND) + message(SEND_ERROR "Failed to find Python 3 or greater. This is needed to build CamiTK Python binding.") +endif() +if("${Python3_VERSION}" VERSION_LESS 3.7) + message(FATAL_ERROR "Found Python3 ${Python3_VERSION} version but at least 3.7 is required. Please update your version of Python3.") +endif() +message(STATUS "Found suitable version of Python: ${Python3_VERSION} (required is at least 3.7)") + + + +# -- PySide, the Python binding of Qt using Shiboken. +find_package(PySide2 REQUIRED) +if(PYSIDE_INCLUDE_DIR) + message(STATUS "Found PySide2 configuration in ${PySide2_DIR}") + # PySide2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(PYSIDE_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB PYSIDE_CONFIG "${PySide2_DIR}/PySide2Config${PYSIDE_PATTERN}*.cmake") + if (PYSIDE_CONFIG) + get_filename_component(PYSIDE_CONFIG_SUFFIX ${PYSIDE_CONFIG} NAME) + string(SUBSTRING ${PYSIDE_CONFIG_SUFFIX} 13 -1 PYSIDE_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${PYSIDE_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for PySide2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(PySide2 QUIET) + endif() + set(PYSIDE_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.${Python3_VERSION_PATCH}) +endif() +if (NOT PYSIDE_VERSION OR ${PYSIDE_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find PySide2 for Python3. Found version: ${PYSIDE_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of PySide2: ${PYSIDE_VERSION}, path to binary is ${PYSIDE_VERSION}") + + +if(NOT PYSIDE_INCLUDE_DIR) + message(FATAL_ERROR "Failed to find PySide2. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found PySide2") + +# -- Shiboken2, the PySide team C++ to Python wrapper +find_package(Shiboken2 REQUIRED) +if (Shiboken2_FOUND) + # Shiboken2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake") + if (SHIBOKEN_CONFIG) + get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME) + string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for Shiboken2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(Shiboken2 QUIET) + endif() + set(SHIBOKEN_VERSION ${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}.${SHIBOKEN_PYTHON_VERSION_PATCH}) +endif() +if (NOT SHIBOKEN_VERSION OR ${SHIBOKEN_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find Shiboken2 for Python3. Found version: ${SHIBOKEN_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of Shiboken2: ${SHIBOKEN_VERSION}, path to binary is ${SHIBOKEN_BINARY}") + +# Enable rpaths so that the example can be executed from the build dir. +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ${PYSIDE_TYPESYSTEMS} ${SHIBOKEN_TYPESYSTEM_PATH}) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +camitk_extension(ACTION_EXTENSION + INCLUDE_DIRECTORIES ${PYTHON3_INCLUDE_DIRS} ${PYSIDE_INCLUDE_DIR} ${PYSIDE_INCLUDE_DIR}/QtCore ${SHIBOKEN_INCLUDE_DIR} + EXTERNAL_LIBRARIES ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} + # to avoid syntax errors in Python object.h due to the usage of the word "slot" (Same as CONFIG += no_keywords) + DEFINES QT_NO_KEYWORDS +) + +# TODO add a "NEEDS_PYCAMITK" option flag to the camitk_extension +if(CAMITK_COMMUNITY_EDITION_BUILD) + # Because we are in the same CEP set, use the target instead of the find_library(..) + set(CAMITK_PYTHON_BIDINGS_MODULE_NAME "PyCamiTK") + target_link_libraries(${ACTION_TARGET_NAME} $) + add_dependencies(${ACTION_TARGET_NAME} ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}) +endif() + +endif() # CAMITK_BINDING_PYTHON diff --git a/tutorials/actions/pythonscripting/PythonScripting.cpp b/tutorials/actions/pythonscripting/PythonScripting.cpp new file mode 100644 index 0000000000000000000000000000000000000000..165b2e384c47a7b35b3ef3acfc9398c7193c682c --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScripting.cpp @@ -0,0 +1,567 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3w + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +#include "PythonScripting.h" + +#include +#include +#include +#include +#include +using namespace camitk; + +// Qt +#include +#include // from QtWidgets +#include // from QtCore + +// Python binding (shiboken2) +#include +#include +#include + +// -------------------- PythonScripting -------------------- +PythonScripting::PythonScripting(ActionExtension* extension) : Action(extension) { + setName("Python Image Scripting"); + setDescription("Tutorial action to demonstrate the python scripting ability of CamiTK"); + setComponent("ImageComponent"); + + setFamily("Tutorial"); + addTag("Python"); + addTag("Scripting"); + addTag("Image Processing"); + + //-- widget lazy instantiation + scriptTextEdit = nullptr; + + //-- init Python module + pythonScriptingIsAvailable = false; + pythonInitialized = false; +} + +// --------------- getWidget ------------------- +QWidget* PythonScripting::getWidget() { + + if (!scriptTextEdit) { + // customize existing widget + QWidget* defaultWidget = Action::getWidget(); + QLayout* informationFrameLayout = defaultWidget->layout(); + + //-- the frame + QString defaultScript = "print(target)\n"; + scriptTextEdit = new QPlainTextEdit(defaultScript); + + informationFrameLayout->addWidget(scriptTextEdit); + + defaultWidget->setLayout(informationFrameLayout); + } + + return Action::getWidget(); +} + +// --------------- destructor ------------------- +PythonScripting::~PythonScripting() { + + if (pythonInitialized) { + // Only do this if the python scripting was initialized + // As we are not using qAddPostRoutine(cleanup) in initPython() + // just call this manually here + + Py_Finalize(); + } + +} + +// --------------- apply ------------------- +Action::ApplyStatus PythonScripting::apply() { + + // get the last selected image component + ImageComponent* imageComponent = dynamic_cast(getTargets().last()); + + // update the information label + if (scriptTextEdit != nullptr) { + // set waiting cursor (not really needed here as the action is very fast, but after all this is a demo) + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + +/* + * + * Demo 1 + * + from PySide2.QtWidgets import QMenu +from PySide2.QtGui import * +from PySide2.QtCore import Qt + +app = camitk.Application.instance() #QApplication.instance() + +print("PyCamiTK version: " + camitk.Core.version) +print(app) + +# comp = camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") + +#fileMenu = QMenu("&Python"); +#action = camitk.Application.getAction("Open") +#fileMenu.addAction(action.getQAction()) +#mainWindow = app.getMainWindow() +#appMenuBar = mainWindow.menuBar() +#appMenuBar.addMenu(fileMenu) + +#app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.PropertyExplorer.getInstance()) + +#app.getMainWindow().dockWidgetMap[camitk.PropertyExplorer.getInstance()].hide() + +app.getMainWindow().showViewer(camitk.PropertyExplorer.getInstance(), True) + +*/ + +/** + * Demo 2 + * + * CPP object is visible from python + * + +print("PyCamiTK version: " + camitk.Core.version) +print(target) +imageDimension = eval(target.property("Image Dimensions")) # dim +print("Original image dimension: " + str(imageDimension)) +print("Voxel type: " + target.property("Voxel Data Type")) +*/ + + +/** + * Demo 3 + * + * + +backupImageData = target.getImageData() +print("backup image data =" + str(backupImageData)) +comp2 = camitk.ImageComponent("test from scratch") +comp2.replaceImageData(backupImageData) +comp2.setSelected(True) +camitk.Application.refresh() + +*/ + +/* + * Demo 4 + * + * +import vtk +import math +from vtk.util import vtkImageImportFromArray as vtkutil +import numpy as np + +def generateSphere(imageDimension): + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + return f.GetOutput() + + +imageDimension = eval(target.property("Image Dimensions")) +# compute radius and center from imageDimension +radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 +center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + +# 3D array +semisizes = (radius,) * 3 + +# generate the grid for the support points +# centered at the position indicated by center +grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] +center = np.ogrid[grid] +# calculate the distance of all points from center +# scaled by the radius +arr = np.zeros(imageDimension, dtype=float) +for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) +# the inner part of the sphere will have distance below 1 + +# generate vtkImage from an array +f = vtkutil.vtkImageImportFromArray() +f.SetArray( arr ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +target.replaceImageData(imageData) +camitk.Application.refresh() +*/ + +/* Demo 5 + * + * +import vtk +import math +from vtk.util import vtkImageImportFromArray as vtkutil +import numpy as np + +def generateSphere(imageDimension): + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + return f.GetOutput() + + +imageDimension = eval(target.property("Image Dimensions")) +# compute radius and center from imageDimension +radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 +center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + +# 3D array +semisizes = (radius,) * 3 + +# generate the grid for the support points +# centered at the position indicated by center +grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] +center = np.ogrid[grid] +# calculate the distance of all points from center +# scaled by the radius +arr = np.zeros(imageDimension, dtype=float) +for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) +# the inner part of the sphere will have distance below 1 +#return arr <= 1.0 + +# generate vtkImage from an array +f = vtkutil.vtkImageImportFromArray() +f.SetArray( arr ) +#f.SetDataOrigin( ... ) +#f.SetDataSpacing( ... ) +#f.SetDataExtent( ... ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +newComponent = camitk.ImageComponent("test from scratch") +newComponent.replaceImageData(imageData) +newComponent.setSelected(True) + +camitk.Application.refresh() +*/ + +/** + * Demo 6 + * + * + * +import itk +import numpy as np +itkImage = itk.imread(camitk.Core.getTestDataDir() + "/brain.mha") +print(itkImage) + +dimension = 3 +pixelType = itk.UC +imageType = itk.Image[pixelType, dimension] + +meanFilter = itk.MeanImageFilter[imageType, imageType].New() +meanFilter.SetInput(itkImage) +meanFilter.SetRadius(5) + +outputItkImage = meanFilter.GetOutput() + +print("---------------") +print(outputItkImage) + +numpyArray = itk.GetArrayFromImage(outputItkImage) + +# Back to vtk +import vtk +from vtk.util import vtkImageImportFromArray as vtkutil +f = vtkutil.vtkImageImportFromArray() +f.SetArray( numpyArray ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +newComponent = camitk.ImageComponent("test from scratch") +newComponent.replaceImageData(imageData) +newComponent.setSelected(True) + +camitk.Application.refresh() + + +*/ + +/** + * Demo 7 + * + * +import numpy as np +import vtk +from vtk.util.numpy_support import vtk_to_numpy +vtkImage = target.getImageData() +dim1,dim2,dim3 = vtkImage.GetDimensions() +vtkArray = vtkImage.GetPointData().GetScalars() +components = vtkArray.GetNumberOfComponents() + +arr = vtk_to_numpy(vtkArray).reshape(dim3,dim2,dim1) + +# to itk +import itk +itkImage = itk.GetImageFromArray(arr) + +# filter +dimension = 3 +pixelType = itk.UC +imageType = itk.Image[pixelType, dimension] +meanFilter = itk.MeanImageFilter[imageType, imageType].New() +meanFilter.SetInput(itkImage) +meanFilter.SetRadius(5) + +outputItkImage = meanFilter.GetOutput() +numpyArray = itk.GetArrayFromImage(outputItkImage) + +# Back to vtk +import vtk +from vtk.util import vtkImageImportFromArray as vtkutil +f = vtkutil.vtkImageImportFromArray() +f.SetArray( numpyArray ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +# Back to CamiTK +newComponent = camitk.ImageComponent("test from scratch") +newComponent.replaceImageData(imageData) +newComponent.setSelected(True) + +camitk.Application.refresh() + +*/ + + const QStringList pythonScript = scriptTextEdit->toPlainText().trimmed().split(QLatin1Char('\n'), QString::SkipEmptyParts); + bool result = runScript(pythonScript); + + // restore the normal cursor + QApplication::restoreOverrideCursor(); + + return (result) ? SUCCESS : ERROR; + } + + return SUCCESS; +} + + +// --------------- initPython ------------------- +void PythonScripting::initPython() { + + if (!pythonScriptingIsAvailable) { + // If there is an active python virtual environment, use that environment's packages location. + QByteArray virtualEnvPath = qgetenv("VIRTUAL_ENV"); + if (!virtualEnvPath.isEmpty()) + qputenv("PYTHONHOME", virtualEnvPath); + + Py_Initialize(); + + pythonInitialized = true; + + const bool pyErrorOccurred = PyErr_Occurred() != nullptr; + if (pythonInitialized && !pyErrorOccurred) { + pythonScriptingIsAvailable = true; + CAMITK_INFO(tr("Python environment initialized.")) + } + else { + if (pyErrorOccurred) { + PyErr_Print(); + } + pythonScriptingIsAvailable = false; + CAMITK_WARNING(tr("Failed to initialize the Python module. Python scripting not available.")) + } + } +} + +// --------------- runScript ------------------- +bool PythonScripting::runScript(const QStringList& script) { + + initPython(); + + if (!pythonScriptingIsAvailable) { + return false; + } + + CAMITK_INFO(tr("Script:\n=========\n%1\n=========").arg(script.join("\n"))) + + // Concatenating all the lines + QString content; + QTextStream ss(&content); + ss << "import traceback\n"; + ss << "try:\n"; + for (const QString& line : script) + ss << " " << line << "\n"; + ss << "except Exception:\n"; + ss << " print(\"Exception in \" + sys.argv[0] + \":\")\n"; + ss << " print(sys.exc_info()[0])\n"; + ss << " print()\n"; + ss << " print(traceback.format_exc())\n"; + ss << " print(sys.exc_info()[0])\n"; + + // import doc + // https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html + + //this is python code to redirect stdout/stderr, see extending FAQ https://docs.python.org/3/faq/extending.html and https://stackoverflow.com/q/46632488 + std::string stdOutErr = + "import sys\n" + "class PythonOutputCatcher:\n" + " def __init__(self):\n" + " self.value = ''\n" + " def write(self, text):\n" + " self.value += text\n" + "pythonOutput = PythonOutputCatcher()\n" + "sys.stdout = pythonOutput\n" + "sys.stderr = pythonOutput\n" + "import traceback\n" + "import sys\n" + "print(\"Adding Python library path: " + Core::getInstallDirectories("lib").at(0).toStdString() + "\")\n" + // "sys.path.append('.')\n" + "sys.path.append('" + Core::getInstallDirectories("lib").at(0).toStdString() + "')\n" + + "from PyCamiTK import camitk\n"; + + PyObject* pythonModule = PyImport_AddModule("__main__"); //create main module + + PyRun_SimpleString(stdOutErr.c_str()); // invoke code to redirect + + static SbkConverter* converter = Shiboken::Conversions::getConverter("ImageComponent"); + if (!converter) { + CAMITK_WARNING("Failed to create converter for ImageComponent") + return false; + } + + PyObject *pythonImageComponent = Shiboken::Conversions::pointerToPython(converter, getTargets().last()); + + if (pythonImageComponent == nullptr) { + CAMITK_WARNING("Failed to create wrapper for ImageComponent") + return false; + } + Py_INCREF(pythonImageComponent); + + if (PyModule_AddObject(pythonModule, "target", pythonImageComponent) < 0) { + if (PyErr_Occurred()) + PyErr_Print(); + CAMITK_WARNING("Failed add object \"target\" to __main__") + return false; + } + + // Executing the whole script as one line + const QByteArray line = content.toUtf8(); + int runResult = PyRun_SimpleString(line.constData()); + + PyObject* pythonOutput = PyObject_GetAttrString(pythonModule, "pythonOutput"); + + if (pythonOutput == nullptr) { + CAMITK_WARNING("Cannot get pythonOutput object.") + return false; + } + + PyObject* pythonOutputValue = PyObject_GetAttrString(pythonOutput, "value"); + if (pythonOutputValue == nullptr) { + CAMITK_WARNING("Cannot get pythonStdOuput data.") + return false; + } + + char* catcherData; + if (PyUnicode_Check(pythonOutputValue)) { + // Convert string to bytes. + // strdup() bytes into my_result. + PyObject* temp_bytes = PyUnicode_AsEncodedString(pythonOutputValue, "utf-8", "strict"); // Owned reference + if (temp_bytes != NULL) { + catcherData = PyBytes_AsString(temp_bytes); // Borrowed pointer + catcherData = strdup(catcherData); + Py_DECREF(temp_bytes); + } + else { + // TODO: Handle encoding error. + CAMITK_WARNING("Encoding error.") + return false; + } + } + else { + if (PyBytes_Check(pythonOutputValue)) { + // strdup() bytes into my_result. + catcherData = PyBytes_AS_STRING(pythonOutputValue); // Borrowed pointer + catcherData = strdup(catcherData); + } + else { + // Convert into your favorite string representation. + // Convert string to bytes if it is not already. + // strdup() bytes into my_result. + CAMITK_WARNING("Importing string error. Not implemented") + return false; + } + } + + CAMITK_INFO(tr("Python Output:\n=========\n%1=========").arg(QString(catcherData))) + return true; + +} diff --git a/tutorials/actions/pythonscripting/PythonScripting.h b/tutorials/actions/pythonscripting/PythonScripting.h new file mode 100644 index 0000000000000000000000000000000000000000..803cbd6180a78f0b0ce772a2df40b2bac01a416d --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScripting.h @@ -0,0 +1,70 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +#ifndef PYTHON_SCRIPTING_H +#define PYTHON_SCRIPTING_H + +#include +class QPlainTextEdit; + +/** + * Demonstrates how to get information from image picking. + * This is an embedded action (it is shown in the ActionViewer) + */ +class PythonScripting : public camitk::Action { + +public: + /// the constructor + PythonScripting(camitk::ActionExtension*); + + /// the destructor + virtual ~PythonScripting(); + + /// method called when the action when the action is triggered (i.e. started) + virtual QWidget* getWidget(); + +public Q_SLOTS: + /// method called when the action is applied + virtual ApplyStatus apply(); + +private: + /// the script editor + QPlainTextEdit* scriptTextEdit; + + /// initialize python environment, set the state of python scripting to true if everything + /// went well, otherwise set it to false + void initPython(); + + /// current state of python + bool pythonScriptingIsAvailable; + + /// is python environment initialized + bool pythonInitialized; + + /// run the script in python (each python line of code is an QString in the list) + bool runScript(const QStringList &); +}; + +#endif // PYTHON_SCRIPTING_H diff --git a/tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2d746929fa125b65840b5537a419acf215b5b9e --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp @@ -0,0 +1,32 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#include "PythonScriptingActionExtension.h" +#include "PythonScripting.h" + +// -------------------- init -------------------- +void PythonScriptingActionExtension::init() { + registerNewAction(PythonScripting); +} + diff --git a/tutorials/actions/pythonscripting/PythonScriptingActionExtension.h b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.h new file mode 100644 index 0000000000000000000000000000000000000000..696420035506a44b3f14f401f644a8db0b6d29a4 --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.h @@ -0,0 +1,62 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + + +#ifndef PYTHON_SCRIPTING_ACTION_EXTENSION_H +#define PYTHON_SCRIPTING_ACTION_EXTENSION_H + +#include +#include +#include + +/// a simple action extension containing two actions: one for mesh picking, one for image picking +class PythonScriptingActionExtension : public camitk::ActionExtension { + Q_OBJECT + Q_INTERFACES(camitk::ActionExtension) + Q_PLUGIN_METADATA(IID "fr.imag.camitk.tutorials.action.python") + +public: + /// the constructor + PythonScriptingActionExtension() : ActionExtension() {}; + + /// the destructor + virtual ~PythonScriptingActionExtension() = default; + + /// initialize all the actions + virtual void init(); + + /// Method that return the action extension name + virtual QString getName() { + return "Python Scripting Tutorial"; + }; + + /// Method that return the action extension descrption + virtual QString getDescription() { + return "This is a basic demo of python scripting in an action."; + }; + +}; + +#endif // PYTHON_SCRIPTING_ACTION_EXTENSION_H diff --git a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp index 14b1a1911405e3506f0c6855e30c763ac7f3a704..16e3e09b2ce4b26583d963b4c3447c31a52a8d13 100644 --- a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp +++ b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp @@ -60,7 +60,7 @@ WorkingWhenSleepingLinear::~WorkingWhenSleepingLinear() { // --------------- apply ------------------- Action::ApplyStatus WorkingWhenSleepingLinear::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp index 03478382fce7fdcb3f8fde76f69aca79327d7c1e..67d40e51bfa077b1b84e6acf51d1566c909c0a75 100644 --- a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp +++ b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp @@ -60,7 +60,7 @@ WorkingWhenSleepingRandom::~WorkingWhenSleepingRandom() { // --------------- apply ------------------- Action::ApplyStatus WorkingWhenSleepingRandom::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/tutorials/applications/testlogger/log-default-linux.log b/tutorials/applications/testlogger/log-default-linux.log index 4d609493456159ee5d7347070022badc4ad08d41..63cc857ba56b17ca6f0f9269cfce4250b2e8c853 100644 --- a/tutorials/applications/testlogger/log-default-linux.log +++ b/tutorials/applications/testlogger/log-default-linux.log @@ -40,9 +40,9 @@ WARNING message: WARNING_IF(true) message: WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -69,14 +69,14 @@ INFO message: INFO_IF(true) message: INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -102,19 +102,19 @@ TRACE message: TRACE_IF(true) message: TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -141,24 +141,24 @@ Log level "TRACE": begin test... With debug information: [TRACE ] [virtual void camitk::CamiTKLogger::setDebugInformation(bool)@CamiTKLogger.cpp:223] Logging debug information: true TRACE message: -[TRACE ] [printLog@main.cpp:43] Test Log: TRACE +[TRACE ] [printLog@main.cpp:44] Test Log: TRACE TRACE_IF(true) message: -[TRACE ] [printLog@main.cpp:46] Test Log: TRACE_IF +[TRACE ] [printLog@main.cpp:47] Test Log: TRACE_IF TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: [TRACE ] Logging debug information: false diff --git a/tutorials/applications/testlogger/log-default-win.log b/tutorials/applications/testlogger/log-default-win.log index 8b58414014119b0631c488ddeb0228acae4ffebe..ac19eb29de93ef86c903efc46f79b6d1b080bfec 100644 --- a/tutorials/applications/testlogger/log-default-win.log +++ b/tutorials/applications/testlogger/log-default-win.log @@ -40,9 +40,9 @@ WARNING message: WARNING_IF(true) message: WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -69,14 +69,14 @@ INFO message: INFO_IF(true) message: INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -102,19 +102,19 @@ TRACE message: TRACE_IF(true) message: TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -141,24 +141,24 @@ Log level "TRACE": begin test... With debug information: [TRACE ] [void __cdecl camitk::CamiTKLogger::setDebugInformation(bool)@CamiTKLogger.cpp:223] Logging debug information: true TRACE message: -[TRACE ] [printLog@main.cpp:43] Test Log: TRACE +[TRACE ] [printLog@main.cpp:44] Test Log: TRACE TRACE_IF(true) message: -[TRACE ] [printLog@main.cpp:46] Test Log: TRACE_IF +[TRACE ] [printLog@main.cpp:47] Test Log: TRACE_IF TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: [TRACE ] Logging debug information: false diff --git a/tutorials/applications/testlogger/main.cpp b/tutorials/applications/testlogger/main.cpp index 676534e6f604b6873caa1c89a3b9a89a8e1405b3..45e843ed2ad2d3a282ab4199504874063038fb18 100644 --- a/tutorials/applications/testlogger/main.cpp +++ b/tutorials/applications/testlogger/main.cpp @@ -26,6 +26,7 @@ // -- Core stuff #include #include +#include #include #include diff --git a/tutorials/applications/testloggercrash/main.cpp b/tutorials/applications/testloggercrash/main.cpp index ee79f3d27c6361dbef280c338e0244b19b4c62e5..6cb5ce94e8e26d9dd19b29578cde09771d0cd3b0 100644 --- a/tutorials/applications/testloggercrash/main.cpp +++ b/tutorials/applications/testloggercrash/main.cpp @@ -26,6 +26,7 @@ // -- Core stuff #include #include +#include #include #include