diff --git a/Documentation/Cookbook/rst/Installation.rst b/Documentation/Cookbook/rst/Installation.rst index e37fd817b6046e39319e6502f05f4825a9e7c4da..6058b155e95676de923b69e2649dbd86d0a0ef90 100644 --- a/Documentation/Cookbook/rst/Installation.rst +++ b/Documentation/Cookbook/rst/Installation.rst @@ -28,7 +28,6 @@ Linux x86_64 .. include:: Installation_Linux.txt - MacOS X ------- diff --git a/Documentation/Cookbook/rst/Installation_Linux.txt b/Documentation/Cookbook/rst/Installation_Linux.txt index 2f3e127104c4eba1aeb41316996177f8d27a94aa..3ca41e0b28b92d2953e5f05fa034bde6a23b0209 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.txt +++ b/Documentation/Cookbook/rst/Installation_Linux.txt @@ -33,24 +33,31 @@ archive is extracted, the directory structure consists of: - ``lib``: A folder containing all shared libraries and OTB applications. +- ``include``: A folder containing all the necessary headers to compile OTB + based projects. + - ``share``: A folder containing common resources and copyright mentions. - ``tool``: A folder containing usefull scripts to test the installation or to uninstall OTB libraries and headers while keeping all the depedencies. -In order to run the command line launchers, this package doesn’t require -any special library that is not present in most modern Linux -distributions. There is a small caveat for "expat" though as these binaries depend -on "libexpat.so", which can be supplied by most package managers (apt, yum, ...). -Note that this problem only affects versions 6.0 and older. -If not already present, it is necessary to install one of the following packages: +The applications can be launched from the Mapla launcher. If you want to +use the otbcli and otbgui launchers, you can initialize your environment +with ``source otbenv.profile``. -:: +The package can be used to compile other projects using OTB (binaries, libraries +and headers are included). If you want to build OTB from source using this +package, you should first uninstall the specific OTB files from the package to +leave only the dependencies (what we call an XDK). You can do it using the +supplied script ``tools/uninstall_otb.sh``. - libexpat-dev libexpat1-dev +System dependencies +~~~~~~~~~~~~~~~~~~~ -The graphical executable (otbgui launchers, Monteverdi +In order to run the command line launchers, this package doesn’t require +any special library that is not present in most modern Linux +distributions. The graphical executable (otbgui launchers, Monteverdi and Mapla) use the X11 libraries, which are widely used in a lot of distributions: @@ -58,13 +65,21 @@ distributions: libx11-6 libxext6 libxau6 libxxf86vm1 libxdmcp6 libdrm2 -Monteverdi also requires the standard graphics libraries libgl1 and -libglu1. Make sure you have at least one version of them installed +Monteverdi also requires the standard graphics libraries **libgl1** and +**libglu1**. Make sure you have at least one version of them installed in your system. -The applications can be launched from the Mapla launcher. If you want to -use the otbcli and otbgui launchers, you can initialize your environment -with ``source otbenv.profile``. +Caveat on OTB 6.0 +~~~~~~~~~~~~~~~~~ + +In OTB 6.0 binaries, there is a small caveat for "expat" as the supplied binaries +depend on "libexpat.so", which is not contained in the package. It can be +supplied by most package managers (apt, yum, ...). If not already present, it is +necessary to install one of the following packages: + +:: + + libexpat-dev libexpat1-dev Python bindings ~~~~~~~~~~~~~~~ @@ -112,7 +127,7 @@ A: This is due to a conflict with system Qt4 (usually seen on KDE) and Qt4 + gtk Q: Monteverdi and Mapla applications look different from my other applications. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -A: In versions 6.0 and older, Monteverdi, Mapla and otbapplication (otbgui\_\*) +A: In versions 6.0, Monteverdi, Mapla and otbapplication (otbgui\_\*) use the system gtk theme. If you can't install GTK on your system you can use the one distributed with the OTB package. Note that using system GTK is the preferred way with the OTB standalone package as the distributed version of GTK do not @@ -124,8 +139,8 @@ To use the distributed GTK libraries you need to set the OTB_USE_LOCAL_GTK: export OTB_USE_LOCAL_GTK=1 -And now start ``monteverdi.sh`` or ``mapla.sh`` from OTB-|release|-Linux64 +And now start ``monteverdi.sh`` or ``mapla.sh`` from OTB-6.0.0-Linux64 To get back default behaviour, unset OTB_USE_LOCAL_GTK=1 or set OTB_USE_LOCAL_GTK=0 -In version 6.2, the Linux binaries are built without GTK support to cut some +In version 6.2 and older, the Linux binaries are built without GTK support to cut some dependencies. diff --git a/Documentation/Cookbook/rst/Installation_Macx.txt b/Documentation/Cookbook/rst/Installation_Macx.txt index 7389c07754cdfabbbda4154feb49ee32db0cb0f8..a3ad2d568f6e1fd84e001fb10860e0d04011bc78 100644 --- a/Documentation/Cookbook/rst/Installation_Macx.txt +++ b/Documentation/Cookbook/rst/Installation_Macx.txt @@ -22,12 +22,25 @@ Contents of OTB-|release|-Darwin64 is briefly listed below: - ``lib``: A folder containing all shared libraries and OTB applications. +- ``include``: A folder containing all the necessary headers to compile OTB + based projects. + - ``share``: A folder containing common resources and copyright mentions. - ``tool``: A folder containing usefull scripts to test the installation or to uninstall OTB libraries and headers while keeping all the depedencies. +The applications can be launched from the Mapla launcher. If you want to +use the otbcli and otbgui launchers, you can initialize your environment +with ``source otbenv.profile``. + +The package can be used to compile other projects using OTB (binaries, libraries +and headers are included). If you want to build OTB from source using this +package, you should first uninstall the specific OTB files from the package to +leave only the dependencies (what we call an XDK). You can do it using the +supplied script ``tools/uninstall_otb.sh``. + Python bindings ~~~~~~~~~~~~~~~ diff --git a/Documentation/Cookbook/rst/Installation_Windows.txt b/Documentation/Cookbook/rst/Installation_Windows.txt index 8f4741c77d19e0b127ea75b1de5464ad41c07f95..004238b4e46b6a511b6b61a8d71133afeeedfd23 100644 --- a/Documentation/Cookbook/rst/Installation_Windows.txt +++ b/Documentation/Cookbook/rst/Installation_Windows.txt @@ -18,6 +18,9 @@ and their launchers (both command line and graphical launchers are provided): - ``lib``: A folder containing application DLLs. +- ``include``: A folder containing all the necessary headers to compile OTB + based projects. + - ``tool``: A folder containing usefull scripts to test the installation or to uninstall OTB libraries and headers while keeping all the depedencies. @@ -25,6 +28,18 @@ The applications can be launched from the Mapla launcher. If you want to use the otbcli and otbgui launchers, you can initialize a command prompt with ``otbenv.bat``. +The package can be used to compile other projects using OTB (binaries, libraries +and headers are included). If you want to build OTB from source using this +package, you should first uninstall the specific OTB files from the package to +leave only the dependencies (what we call an XDK). You can do it using the +supplied script ``tools/uninstall_otb.bat``. + +In the package you also have a template project for Visual 2015 +``OTB Project.zip``. This template can be placed in your user Visual 2015 template +directory : ``%USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates``. +The script ``start_devenv.bat`` allows to copy the template in that folder and +start Visual Studio. + Python bindings ~~~~~~~~~~~~~~~ diff --git a/Documentation/Latex/style_for_html.cfg b/Documentation/Latex/style_for_html.cfg new file mode 100644 index 0000000000000000000000000000000000000000..549bc81508e35e4eb035a8f59ca9034ee612b513 --- /dev/null +++ b/Documentation/Latex/style_for_html.cfg @@ -0,0 +1,4 @@ +\Preamble{html} +\Css{body{margin: 0 auto; max-width: 900px;}} +\begin{document} +\EndPreamble diff --git a/Documentation/SoftwareGuide/Art/Cube_HPX.eps b/Documentation/SoftwareGuide/Art/Cube_HPX.eps index 2a1ef4d844449823325efbc733e223033984c799..e7ec9db08dd3639cd4dd3cc8c8d6bb4bb93497ea 100644 Binary files a/Documentation/SoftwareGuide/Art/Cube_HPX.eps and b/Documentation/SoftwareGuide/Art/Cube_HPX.eps differ diff --git a/Documentation/SoftwareGuide/Latex/CMakeLists.txt b/Documentation/SoftwareGuide/Latex/CMakeLists.txt index 5b04644722c4da5fa9b35047d32813fecc19db2d..099e91e0b24d7c7f57b5c4cd5b9c8f26d6b107a7 100644 --- a/Documentation/SoftwareGuide/Latex/CMakeLists.txt +++ b/Documentation/SoftwareGuide/Latex/CMakeLists.txt @@ -89,7 +89,7 @@ SET(DVIPS_CONVERTER_OPTIONS -D600) # Option for html generation -SET(TEX4HT_OPTIONS "html,2,sections+ \"\" \"\" -shell-escape") +SET(TEX4HT_OPTIONS "style_for_html,2,sections+ \"\" \"\" -shell-escape") SET (HTML_OUTPUT "SoftwareGuide-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}") # Copy RELEASE_NOTES.txt from OTB source tree to Software Guide build directory diff --git a/Documentation/SoftwareGuide/Latex/Installation.tex b/Documentation/SoftwareGuide/Latex/Installation.tex index a5521be83db8be2685853792a2dadc55017cd4a9..6c1531dc647cd109b5ebb1a094f7f078d06eb9b7 100644 --- a/Documentation/SoftwareGuide/Latex/Installation.tex +++ b/Documentation/SoftwareGuide/Latex/Installation.tex @@ -220,6 +220,14 @@ If you do not know which method to use and just want to compile OTB with all its \end{tiny} \end{center} +If you want to use a standalone binary package, a lot of dependencies are already +supplied in it. In this case, it is advised to use all of the dependencies from +that package. Mixing system libraries with libraries from OTB package may not +be safe. When you call the \textit{otbenv} script in the package, it will add +an environment variable \texttt{CMAKE\_PREFIX\_PATH}, pointing to the root of the +OTB package. This variable is used by CMake as a hint to detect the dependencies +location. + \subsection{SuperBuild: Build OTB and all dependencies} \label{sec:installation-linux-superbuild} diff --git a/Examples/DataRepresentation/Image/Image4.cxx b/Examples/DataRepresentation/Image/Image4.cxx index 269524c5ab6f638deb9c5bd71223c310d8c2667f..d085b71633da5a06cd5209b1793d9efc3acfea95 100644 --- a/Examples/DataRepresentation/Image/Image4.cxx +++ b/Examples/DataRepresentation/Image/Image4.cxx @@ -114,20 +114,20 @@ int main(int, char *[]) // Software Guide : BeginLatex // // The array can be assigned to the image using - // the \code{SetSpacing()} method. + // the \code{SetSignedSpacing()} method. // - // \index{otb::Image!SetSpacing()} + // \index{otb::Image!SetSignedSpacing()} // // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex // // The spacing information can be retrieved from an image by using the - // \code{GetSpacing()} method. This method returns a reference to a + // \code{GetSignedSpacing()} method. This method returns a reference to a // \code{FixedArray}. The returned object can then be used to read the // contents of the array. Note the use of the \code{const} keyword to indicate // that the array will not be modified. @@ -135,7 +135,7 @@ int main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - const ImageType::SpacingType& sp = image->GetSpacing(); + const ImageType::SpacingType& sp = image->GetSignedSpacing(); std::cout << "Spacing = "; std::cout << sp[0] << ", " << sp[1] << std::endl; diff --git a/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx b/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx index da850ee075530c0e07ab862130136f76042ab7c3..0847b7d7b03445c1f32daff941d95262ff01446a 100644 --- a/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx +++ b/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx @@ -99,7 +99,7 @@ int main(int argc, char * argv[]) ImagePointType origin = image->GetOrigin(); - ImageType::SpacingType spacing = image->GetSpacing(); + ImageType::SpacingType spacing = image->GetSignedSpacing(); ImageType::SizeType size = image->GetBufferedRegion().GetSize(); ImagePointType point; diff --git a/Examples/DisparityMap/SimpleDisparityMapEstimationExample.cxx b/Examples/DisparityMap/SimpleDisparityMapEstimationExample.cxx index 22d646b2318a164692edff8bdd7dc99f7b71f166..ff70de113d0319739fe2c31093fdf1177111488a 100644 --- a/Examples/DisparityMap/SimpleDisparityMapEstimationExample.cxx +++ b/Examples/DisparityMap/SimpleDisparityMapEstimationExample.cxx @@ -374,7 +374,7 @@ int main(int argc, char* argv[]) // Software Guide : BeginCodeSnippet generator->SetOutputOrigin(fixedReader->GetOutput()->GetOrigin()); - generator->SetOutputSpacing(fixedReader->GetOutput()->GetSpacing()); + generator->SetOutputSpacing(fixedReader->GetOutput()->GetSignedSpacing()); generator->SetOutputSize(fixedReader->GetOutput() ->GetLargestPossibleRegion().GetSize()); // Software Guide : EndCodeSnippet @@ -439,7 +439,7 @@ int main(int argc, char* argv[]) warper->SetInput(movingReader->GetOutput()); warper->SetDisplacementField(generator->GetOutput()); warper->SetOutputOrigin(fixedReader->GetOutput()->GetOrigin()); - warper->SetOutputSpacing(fixedReader->GetOutput()->GetSpacing()); + warper->SetOutputSpacing(fixedReader->GetOutput()->GetSignedSpacing()); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx index 04eaaf308ad0151cca3ff9ea8185cd2976fc0689..453ebe11707ce965d177faa4ce1b880d390eb721 100644 --- a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx +++ b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx @@ -179,7 +179,7 @@ int main(int argc, char * argv[]) vectorDataRenderer->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize()); vectorDataRenderer->SetOrigin(reader->GetOutput()->GetOrigin()); - vectorDataRenderer->SetSpacing(reader->GetOutput()->GetSpacing()); + vectorDataRenderer->SetSpacing(reader->GetOutput()->GetSignedSpacing()); vectorDataRenderer->SetRenderingStyleType(VectorDataRendererType::Binary); blendingFilter->SetInput1(reader->GetOutput()); diff --git a/Examples/FeatureExtraction/SURFExample.cxx b/Examples/FeatureExtraction/SURFExample.cxx index 8259160148a8316352b3f3de789708f9a6ed89ad..f9432cdad32919ff75f2fa64eaee1bfd294c37e2 100644 --- a/Examples/FeatureExtraction/SURFExample.cxx +++ b/Examples/FeatureExtraction/SURFExample.cxx @@ -237,7 +237,7 @@ int main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); + ImageType::SpacingType spacing = reader->GetOutput()->GetSignedSpacing(); ImageType::PointType origin = reader->GetOutput()->GetOrigin(); //OutputImageType::SizeType size = outputImage->GetLargestPossibleRegion().GetSize(); diff --git a/Examples/IO/MetadataExample.cxx b/Examples/IO/MetadataExample.cxx index a77e107145fc0e12697f34b5d4451d18186fa8a8..cfd2158c3d271489156ab2a9d329ee2442cf90ae 100644 --- a/Examples/IO/MetadataExample.cxx +++ b/Examples/IO/MetadataExample.cxx @@ -116,7 +116,7 @@ int main(int itkNotUsed(argc), char* argv[]) // SoftwareGuide: EndLatex // SoftwareGuide : BeginCodeSnippet - file << "Spacing " << image->GetSpacing() << std::endl; + file << "Spacing " << image->GetSignedSpacing() << std::endl; file << "Origin " << image->GetOrigin() << std::endl; file << "Projection REF " << image->GetProjectionRef() << std::endl; diff --git a/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx b/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx index e1d40f7d48054db500a031ab59c5b6652cacedd6..a18ffe3abbeaca77bb9d90638d9930072ba34892 100644 --- a/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx +++ b/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) Index4DType index4D = region4D.GetIndex(); Size4DType size4D = region4D.GetSize(); - Spacing4DType spacing4D = image4D->GetSpacing(); + Spacing4DType spacing4D = image4D->GetSignedSpacing(); Origin4DType origin4D = image4D->GetOrigin(); for (unsigned int i = 0; i < 3; ++i) @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) origin3D[i] = origin4D[i]; } - image3D->SetSpacing(spacing3D); + image3D->SetSignedSpacing(spacing3D); image3D->SetOrigin(origin3D); Region3DType region3D; diff --git a/Examples/Iterators/ImageRegionIterator.cxx b/Examples/Iterators/ImageRegionIterator.cxx index 06441e2f3f4b29927166f154604f39050ee03470..11eed0204f652462e68832ddd72510a94c737b30 100644 --- a/Examples/Iterators/ImageRegionIterator.cxx +++ b/Examples/Iterators/ImageRegionIterator.cxx @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) // Software Guide : BeginCodeSnippet ImageType::Pointer outputImage = ImageType::New(); outputImage->SetRegions(outputRegion); - const ImageType::SpacingType& spacing = reader->GetOutput()->GetSpacing(); + const ImageType::SpacingType& spacing = reader->GetOutput()->GetSignedSpacing(); const ImageType::PointType& inputOrigin = reader->GetOutput()->GetOrigin(); double outputOrigin[Dimension]; @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i]; } - outputImage->SetSpacing(spacing); + outputImage->SetSignedSpacing(spacing); outputImage->SetOrigin(outputOrigin); outputImage->Allocate(); // Software Guide : EndCodeSnippet diff --git a/Examples/Patented/EstimateAffineTransformationExample.cxx b/Examples/Patented/EstimateAffineTransformationExample.cxx index 0ad58c9dabfc900ffda4519684418402271687d5..40554e544f8029c0b6522d1aa43715f4771bb3a0 100644 --- a/Examples/Patented/EstimateAffineTransformationExample.cxx +++ b/Examples/Patented/EstimateAffineTransformationExample.cxx @@ -321,7 +321,7 @@ int main(int argc, char* argv[]) resampler->SetTransform(estimator->GetAffineTransform()); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); - resampler->SetOutputSpacing(fixedImage->GetSpacing()); + resampler->SetOutputSpacing(fixedImage->GetSignedSpacing()); resampler->SetDefaultPixelValue(100); // Software Guide : EndCodeSnippet diff --git a/Examples/Patented/SIFTDisparityMapEstimation.cxx b/Examples/Patented/SIFTDisparityMapEstimation.cxx index 0bc424d7284038ea4989836b4746fd883f012482..f6799c4d929aff2fd3c9aca7dbfdd18059fa17e4 100644 --- a/Examples/Patented/SIFTDisparityMapEstimation.cxx +++ b/Examples/Patented/SIFTDisparityMapEstimation.cxx @@ -304,7 +304,7 @@ int main(int argc, char* argv[]) // Software Guide : BeginCodeSnippet ImageType::ConstPointer fixedImage = fixedReader->GetOutput(); - deformer->SetOutputSpacing(fixedImage->GetSpacing()); + deformer->SetOutputSpacing(fixedImage->GetSignedSpacing()); deformer->SetOutputOrigin(fixedImage->GetOrigin()); deformer->SetOutputRegion(fixedImage->GetLargestPossibleRegion()); // Software Guide : EndCodeSnippet diff --git a/Examples/Patented/SIFTExample.cxx b/Examples/Patented/SIFTExample.cxx index 5936983a5051e2fbdbdf6238283656708687ee04..a7cf97e230de8d4e99326c82233eeac5dea3022d 100644 --- a/Examples/Patented/SIFTExample.cxx +++ b/Examples/Patented/SIFTExample.cxx @@ -234,7 +234,7 @@ int main(int argc, char * argv[]) } PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin(); - ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); + ImageType::SpacingType spacing = reader->GetOutput()->GetSignedSpacing(); ImageType::PointType origin = reader->GetOutput()->GetOrigin(); OutputImageType::SizeType size = outputImage->GetLargestPossibleRegion().GetSize(); diff --git a/Examples/Patented/SIFTFastExample.cxx b/Examples/Patented/SIFTFastExample.cxx index 9c5eefbdb62e1ea0294d0fdf9813811808049ed4..22b3b43a60c21b33779b0e1024bdaae1c4cddf90 100644 --- a/Examples/Patented/SIFTFastExample.cxx +++ b/Examples/Patented/SIFTFastExample.cxx @@ -239,7 +239,7 @@ int main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); + ImageType::SpacingType spacing = reader->GetOutput()->GetSignedSpacing(); ImageType::PointType origin = reader->GetOutput()->GetOrigin(); // Software Guide : EndCodeSnippet diff --git a/Examples/Projections/GeometriesProjectionExample.cxx b/Examples/Projections/GeometriesProjectionExample.cxx index ce5ed38823e1248ce97fcbef6924ed936afc4a2a..023c869be74713768056be44afeec8653dc0f2d8 100644 --- a/Examples/Projections/GeometriesProjectionExample.cxx +++ b/Examples/Projections/GeometriesProjectionExample.cxx @@ -129,7 +129,7 @@ int main(int argc, char* argv[]) // necessary for sensors filter->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); // necessary for sensors - filter->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + filter->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); // ~ wkt filter->SetOutputProjectionRef( imageReader->GetOutput()->GetProjectionRef()); // Software Guide : EndCodeSnippet diff --git a/Examples/Projections/SensorModelExample.cxx b/Examples/Projections/SensorModelExample.cxx index 5fd771eef3ff3e951d2f3c206644147c9f167629..2fab615191b2a6c4e6d749856f038bb4a97aa66f 100644 --- a/Examples/Projections/SensorModelExample.cxx +++ b/Examples/Projections/SensorModelExample.cxx @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) reader->GenerateOutputInformation(); std::cout << "Original input imagine spacing: " << - reader->GetOutput()->GetSpacing() << std::endl; + reader->GetOutput()->GetSignedSpacing() << std::endl; // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -197,7 +197,7 @@ int main(int argc, char* argv[]) outputImage->SetOrigin(origin); outputImage->SetRegions(region); - outputImage->SetSpacing(spacing); + outputImage->SetSignedSpacing(spacing); outputImage->Allocate(); // Software Guide : EndCodeSnippet diff --git a/Examples/Projections/VectorDataExtractROIExample.cxx b/Examples/Projections/VectorDataExtractROIExample.cxx index 5bd357e55273955b1b5fdcddd675dd80174d4649..dfe15526aabbeb6dec0aec8ae53ae69b449850d8 100644 --- a/Examples/Projections/VectorDataExtractROIExample.cxx +++ b/Examples/Projections/VectorDataExtractROIExample.cxx @@ -105,13 +105,13 @@ int main(int argc, char* argv[]) TypedRegion::IndexType index; size[0] = imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[0] - * imageReader->GetOutput()->GetSpacing()[0]; + * imageReader->GetOutput()->GetSignedSpacing()[0]; size[1] = imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[1] - * imageReader->GetOutput()->GetSpacing()[1]; + * imageReader->GetOutput()->GetSignedSpacing()[1]; index[0] = imageReader->GetOutput()->GetOrigin()[0] - - 0.5 * imageReader->GetOutput()->GetSpacing()[0]; + - 0.5 * imageReader->GetOutput()->GetSignedSpacing()[0]; index[1] = imageReader->GetOutput()->GetOrigin()[1] - - 0.5 * imageReader->GetOutput()->GetSpacing()[1]; + - 0.5 * imageReader->GetOutput()->GetSignedSpacing()[1]; region.SetSize(size); region.SetOrigin(index); diff --git a/Examples/Projections/VectorDataProjectionExample.cxx b/Examples/Projections/VectorDataProjectionExample.cxx index 685960fc46ccdefc977d3720731afabdfedcb6e8..46cc784f315298c3444e444a71ca4a4cf891b8e1 100644 --- a/Examples/Projections/VectorDataProjectionExample.cxx +++ b/Examples/Projections/VectorDataProjectionExample.cxx @@ -143,7 +143,7 @@ int main(int argc, char* argv[]) vectorDataProjection->SetOutputOrigin( imageReader->GetOutput()->GetOrigin()); vectorDataProjection->SetOutputSpacing( - imageReader->GetOutput()->GetSpacing()); + imageReader->GetOutput()->GetSignedSpacing()); vectorDataProjection->SetOutputProjectionRef( imageReader->GetOutput()->GetProjectionRef()); // Software Guide : EndCodeSnippet diff --git a/Examples/Registration/ImageRegistration1.cxx b/Examples/Registration/ImageRegistration1.cxx index 9bbc67bd289093b75c85132aa65e705448952795..06b17312620374ce4bb8254ef32e5913e19c865a 100644 --- a/Examples/Registration/ImageRegistration1.cxx +++ b/Examples/Registration/ImageRegistration1.cxx @@ -596,7 +596,7 @@ int main(int argc, char *argv[]) FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); - resampler->SetOutputSpacing(fixedImage->GetSpacing()); + resampler->SetOutputSpacing(fixedImage->GetSignedSpacing()); resampler->SetDefaultPixelValue(100); // Software Guide : EndCodeSnippet diff --git a/Examples/Registration/ImageRegistration2.cxx b/Examples/Registration/ImageRegistration2.cxx index 92924c5537f9c186563e983c1d10f8d11fbb8022..497e3cf9ea0685cd8f390334371bb2a2ffd433a6 100644 --- a/Examples/Registration/ImageRegistration2.cxx +++ b/Examples/Registration/ImageRegistration2.cxx @@ -481,7 +481,7 @@ int main(int argc, char *argv[]) resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); - resample->SetOutputSpacing(fixedImage->GetSpacing()); + resample->SetOutputSpacing(fixedImage->GetSignedSpacing()); resample->SetDefaultPixelValue(100); typedef unsigned char OutputPixelType; diff --git a/Examples/Registration/ImageRegistration5.cxx b/Examples/Registration/ImageRegistration5.cxx index 6585c8b8f272ec2a22b917b7f275ae9669e3bed5..cc5ef6d67434588d5d60d866fde36a5a6158668b 100644 --- a/Examples/Registration/ImageRegistration5.cxx +++ b/Examples/Registration/ImageRegistration5.cxx @@ -277,7 +277,7 @@ int main(int argc, char *argv[]) // Software Guide : BeginCodeSnippet FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); - const SpacingType fixedSpacing = fixedImage->GetSpacing(); + const SpacingType fixedSpacing = fixedImage->GetSignedSpacing(); const OriginType fixedOrigin = fixedImage->GetOrigin(); const RegionType fixedRegion = fixedImage->GetLargestPossibleRegion(); const SizeType fixedSize = fixedRegion.GetSize(); @@ -297,7 +297,7 @@ int main(int argc, char *argv[]) // Software Guide : BeginCodeSnippet MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); - const SpacingType movingSpacing = movingImage->GetSpacing(); + const SpacingType movingSpacing = movingImage->GetSignedSpacing(); const OriginType movingOrigin = movingImage->GetOrigin(); const RegionType movingRegion = movingImage->GetLargestPossibleRegion(); const SizeType movingSize = movingRegion.GetSize(); @@ -528,7 +528,7 @@ int main(int argc, char *argv[]) resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); - resample->SetOutputSpacing(fixedImage->GetSpacing()); + resample->SetOutputSpacing(fixedImage->GetSignedSpacing()); resample->SetDefaultPixelValue(100); typedef otb::ImageFileWriter<FixedImageType> WriterFixedType; diff --git a/Examples/Registration/ImageRegistration9.cxx b/Examples/Registration/ImageRegistration9.cxx index 1a063f3840b7ccd632f4d35a4c117ed5b7b1910d..87e62f7239fa606a89b48c74b2e04e3f5bcde709 100644 --- a/Examples/Registration/ImageRegistration9.cxx +++ b/Examples/Registration/ImageRegistration9.cxx @@ -544,7 +544,7 @@ int main(int argc, char *argv[]) resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); - resampler->SetOutputSpacing(fixedImage->GetSpacing()); + resampler->SetOutputSpacing(fixedImage->GetSignedSpacing()); resampler->SetDefaultPixelValue(100); typedef unsigned char OutputPixelType; diff --git a/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx b/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx index e34a2f1ee8cc3ee30647bc37b6079407b15b140b..89f457dc9ca5bd5fae76a1798f7e4a8b994d368c 100644 --- a/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx +++ b/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx @@ -211,11 +211,13 @@ SetWorkingDir( const QString & filepath ) QFileInfo finfo( filepath ); #if 0 - return QDir::setCurrent( - finfo.isDir() - ? filepath - : finfo.path() - ); + return + QDir::setCurrent( + finfo.isDir() + ? filepath + : finfo.path() + ); + #else // TODO : add mutex if needed QString dir = finfo.isDir() ? filepath : finfo.path(); @@ -223,6 +225,7 @@ SetWorkingDir( const QString & filepath ) return false; RecentDirectory = finfo.isDir() ? filepath : finfo.path(); return true; + #endif } diff --git a/Modules/Applications/AppChangeDetection/app/CMakeLists.txt b/Modules/Applications/AppChangeDetection/app/CMakeLists.txt index cf5f9c2576be1ec30679d4089befb78c9d21d6e3..71af979dcafc61ea4904dfa0c4b7e604d1b75e1c 100644 --- a/Modules/Applications/AppChangeDetection/app/CMakeLists.txt +++ b/Modules/Applications/AppChangeDetection/app/CMakeLists.txt @@ -18,11 +18,6 @@ # limitations under the License. # -set(OTBAppChangeDetection_LINK_LIBS - ${OTBApplicationEngine_LIBRARIES} - ${OTBChangeDetection_LIBRARIES} -) - otb_create_application( NAME MultivariateAlterationDetector SOURCES otbMultivariateAlterationDetector.cxx diff --git a/Modules/Applications/AppClassification/app/CMakeLists.txt b/Modules/Applications/AppClassification/app/CMakeLists.txt index cfa104e5902c882cb2634b2f9269b8f86b54bd14..d72dd40b28904567e09309d1e5022c56ea479f74 100644 --- a/Modules/Applications/AppClassification/app/CMakeLists.txt +++ b/Modules/Applications/AppClassification/app/CMakeLists.txt @@ -18,33 +18,6 @@ # limitations under the License. # -set(OTBAppClassification_LINK_LIBS - ${OTBVectorDataBase_LIBRARIES} - ${OTBConversion_LIBRARIES} - ${OTBStatistics_LIBRARIES} - ${OTBColorMap_LIBRARIES} - ${OTBBoost_LIBRARIES} - ${OTBInterpolation_LIBRARIES} - ${OTBMajorityVoting_LIBRARIES} - ${OTBVectorDataIO_LIBRARIES} - ${OTBSOM_LIBRARIES} - ${OTBSVMLearning_LIBRARIES} - ${OTBLearningBase_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBIndices_LIBRARIES} - ${OTBMathParser_LIBRARIES} - ${OTBDempsterShafer_LIBRARIES} - ${OTBGdalAdapters_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBIOXML_LIBRARIES} - ${OTBVectorDataManipulation_LIBRARIES} - ${OTBStreaming_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBObjectList_LIBRARIES} - ${OTBCommon_LIBRARIES} -) - otb_create_application( NAME ComputeOGRLayersFeaturesStatistics SOURCES otbComputeOGRLayersFeaturesStatistics.cxx diff --git a/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx b/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx index 385a97c9f264dacaf128f3ab47d576a29c592072..1e098e7846e0bd13aa19f2cb61fd07d05ca0cdde 100644 --- a/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx +++ b/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx @@ -219,10 +219,10 @@ private: TransformType::ParametersType params; params.SetSize(6); - params[0] = inImage->GetSpacing()[0]; + params[0] = inImage->GetSignedSpacing()[0]; params[1] = 0; params[2] = 0; - params[3] = inImage->GetSpacing()[1]; + params[3] = inImage->GetSignedSpacing()[1]; params[4] = inImage->GetOrigin()[0]; params[5] = inImage->GetOrigin()[1]; @@ -250,7 +250,7 @@ private: vproj->SetOutputKeywordList(inImage->GetImageKeywordlist()); vproj->SetOutputProjectionRef(inImage->GetProjectionRef()); vproj->SetOutputOrigin(inImage->GetOrigin()); - vproj->SetOutputSpacing(inImage->GetSpacing()); + vproj->SetOutputSpacing(inImage->GetSignedSpacing()); // Setup the DEM Handler otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); diff --git a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx index 0140e5f8d1bc0526f2db915c78ef571cc83dceab..e1ea2d673d24db7ff5391ad40eed73bda1cd34ba 100644 --- a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx @@ -117,53 +117,74 @@ void DoInit() ITK_OVERRIDE "lists are built such that their size is inferior to maximum bounds given " "by the user, and the proportion corresponds to the balance parameter. " "Several classifier parameters can be set depending on the chosen " - "classifier. In the validation process, the mean square error is computed\n" + "classifier. In the validation process, the mean square error is computed " + "between the ground truth and the estimated model.\n" " This application is based on LibSVM and on OpenCV Machine Learning " "classifiers, and is compatible with OpenCV 2.3.1 and later."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); - SetDocSeeAlso("OpenCV documentation for machine learning http://docs.opencv.org/modules/ml/doc/ml.html "); + SetDocSeeAlso("OpenCV documentation for machine learning " + "http://docs.opencv.org/modules/ml/doc/ml.html "); //Group IO - AddParameter(ParameterType_Group, "io", "Input and output data"); - SetParameterDescription("io", "This group of parameters allows setting input and output data."); - AddParameter(ParameterType_InputImageList, "io.il", "Input Image List"); - SetParameterDescription("io.il", "A list of input images. First (n-1) bands should contain the predictor. The last band should contain the output value to predict."); - AddParameter(ParameterType_InputFilename, "io.csv", "Input CSV file"); - SetParameterDescription("io.csv","Input CSV file containing the predictors, and the output values in last column. Only used when no input image is given"); - MandatoryOff("io.csv"); - - AddParameter(ParameterType_InputFilename, "io.imstat", "Input XML image statistics file"); - MandatoryOff("io.imstat"); - SetParameterDescription("io.imstat", - "Input XML file containing the mean and the standard deviation of the input images."); - AddParameter(ParameterType_OutputFilename, "io.out", "Output regression model"); - SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); - - AddParameter(ParameterType_Float,"io.mse","Mean Square Error"); - SetParameterDescription("io.mse","Mean square error computed with the validation predictors"); - SetParameterRole("io.mse",Role_Output); - DisableParameter("io.mse"); + AddParameter( ParameterType_Group , "io" , "Input and output data" ); + SetParameterDescription("io" , + "This group of parameters allows setting input and output data." ); + AddParameter( ParameterType_InputImageList , "io.il", "Input Image List" ); + SetParameterDescription( "io.il" , + "A list of input images. First (n-1) bands should contain the predictor. " + "The last band should contain the output value to predict." ); + AddParameter( ParameterType_InputFilename , "io.csv" , "Input CSV file" ); + SetParameterDescription( "io.csv" , + "Input CSV file containing the predictors, and the output values in last " + "column. Only used when no input image is given" ); + MandatoryOff( "io.csv" ); + + AddParameter( ParameterType_InputFilename , "io.imstat" , + "Input XML image statistics file" ); + MandatoryOff( "io.imstat" ); + SetParameterDescription( "io.imstat", + "Input XML file containing the mean and the standard deviation of the " + "input images." ); + AddParameter( ParameterType_OutputFilename , "io.out" , + "Output regression model" ); + SetParameterDescription( "io.out" , + "Output file containing the model estimated (.txt format)." ); + + AddParameter( ParameterType_Float , "io.mse" , "Mean Square Error" ); + SetParameterDescription( "io.mse" , + "Mean square error computed with the validation predictors" ); + SetParameterRole( "io.mse" , Role_Output ); + DisableParameter( "io.mse" ); //Group Sample list - AddParameter(ParameterType_Group, "sample", "Training and validation samples parameters"); - SetParameterDescription("sample", - "This group of parameters allows you to set training and validation sample lists parameters."); - - AddParameter(ParameterType_Int, "sample.mt", "Maximum training predictors"); + AddParameter( ParameterType_Group , "sample" , + "Training and validation samples parameters" ); + SetParameterDescription( "sample" , + "This group of parameters allows you to set training and validation sample " + "lists parameters." ); + + AddParameter( ParameterType_Int , "sample.mt" , + "Maximum training predictors"); //MandatoryOff("mt"); - SetDefaultParameterInt("sample.mt", 1000); - SetParameterDescription("sample.mt", "Maximum number of training predictors (default = 1000) (no limit = -1)."); + SetDefaultParameterInt( "sample.mt" , 1000 ); + SetParameterDescription( "sample.mt" , + "Maximum number of training predictors (default = 1000) (no limit = -1)."); - AddParameter(ParameterType_Int, "sample.mv", "Maximum validation predictors"); + AddParameter( ParameterType_Int , "sample.mv" , + "Maximum validation predictors"); // MandatoryOff("mv"); - SetDefaultParameterInt("sample.mv", 1000); - SetParameterDescription("sample.mv", "Maximum number of validation predictors (default = 1000) (no limit = -1)."); - - AddParameter(ParameterType_Float, "sample.vtr", "Training and validation sample ratio"); - SetParameterDescription("sample.vtr", - "Ratio between training and validation samples (0.0 = all training, 1.0 = all validation) (default = 0.5)."); - SetParameterFloat("sample.vtr",0.5, false); + SetDefaultParameterInt( "sample.mv" , 1000 ); + SetParameterDescription( "sample.mv" , + "Maximum number of validation predictors (default = 1000) " + "(no limit = -1)."); + + AddParameter( ParameterType_Float , "sample.vtr" , + "Training and validation sample ratio"); + SetParameterDescription( "sample.vtr" , + "Ratio between training and validation samples (0.0 = all training, " + "1.0 = all validation) (default = 0.5)."); + SetParameterFloat( "sample.vtr" , 0.5 , false ); Superclass::DoInit(); diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx index 1d1d387c131d3c49fe9402f108e6f1880dd24792..f37eb3020f4934146d3ad4cfa9d402c19d058026 100644 --- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx @@ -57,11 +57,13 @@ protected: void DoInit() { SetName( "TrainVectorClassifier" ); - SetDescription( "Train a classifier based on labeled geometries and a list of features to consider." ); + SetDescription( "Train a classifier based on labeled geometries and a " + "list of features to consider." ); SetDocName( "Train Vector Classifier" ); SetDocLongDescription( "This application trains a classifier based on " - "labeled geometries and a list of features to consider for classification." ); + "labeled geometries and a list of features to consider for " + "classification." ); SetDocLimitations( " " ); SetDocAuthors( "OTB Team" ); SetDocSeeAlso( " " ); diff --git a/Modules/Applications/AppDescriptors/app/CMakeLists.txt b/Modules/Applications/AppDescriptors/app/CMakeLists.txt index 648fa7cc39b50355d5db2ef4b2563be6467f10b5..8942e2ded5ffe7a620980059c140f6f1f4cef50b 100644 --- a/Modules/Applications/AppDescriptors/app/CMakeLists.txt +++ b/Modules/Applications/AppDescriptors/app/CMakeLists.txt @@ -18,15 +18,6 @@ # limitations under the License. # -set(OTBAppDescriptors_LINK_LIBS - ${OTBGdalAdapters_LIBRARIES} - ${OTBDescriptors_LIBRARIES} - ${OTBTransform_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBGDAL_LIBRARIES} -) - otb_create_application( NAME HomologousPointsExtraction SOURCES otbHomologousPointsExtraction.cxx diff --git a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx index f186df01d8a091296296cc324f627a4de605c7a4..073e53727f6b194b27e49887c4cf8c70469c537f 100644 --- a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx +++ b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx @@ -281,7 +281,7 @@ private: pprime1 = rsTransform->TransformPoint(point1); error = vcl_sqrt((point2[0]-pprime1[0])*(point2[0]-pprime1[0])+(point2[1]-pprime1[1])*(point2[1]-pprime1[1])); - if(error>GetParameterFloat("precision")*vcl_sqrt(vcl_abs(im2->GetSpacing()[0]*im2->GetSpacing()[1]))) + if(error>GetParameterFloat("precision")*vcl_sqrt(vcl_abs(im2->GetSignedSpacing()[0]*im2->GetSignedSpacing()[1]))) { filtered = true; } diff --git a/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt index fcde242bb1d0c10c63ec70156b8ba7908d459720..63c4a2105666056a75d4f7b02a8a1dbac75a2e50 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt +++ b/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppDimensionalityReduction_LINK_LIBS - ${OTBImageManipulation_LIBRARIES} - ${OTBStatistics_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBDimensionalityReduction_LIBRARIES} -) - otb_create_application( NAME DimensionalityReduction SOURCES otbDimensionalityReduction.cxx diff --git a/Modules/Applications/AppEdge/app/CMakeLists.txt b/Modules/Applications/AppEdge/app/CMakeLists.txt index 31a9f46fef1cbb59eaf501b9608552abbde85991..e72b1e45ec61d472bf04d9d12af8c818df844a7f 100644 --- a/Modules/Applications/AppEdge/app/CMakeLists.txt +++ b/Modules/Applications/AppEdge/app/CMakeLists.txt @@ -18,15 +18,6 @@ # limitations under the License. # -set(OTBAppEdge_LINK_LIBS - ${OTBStatistics_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBEdge_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} -) - otb_create_application( NAME LineSegmentDetection SOURCES otbLineSegmentDetection.cxx diff --git a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx index b9eccc12eb2f02004ffe1f2156ebd65bdb55d53f..45bc66c51d3562a5850bf83c269f8102e87828e0 100644 --- a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx +++ b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx @@ -185,7 +185,7 @@ private: vproj->SetInput(vd); vproj->SetInputKeywordList(GetParameterImage("in")->GetImageKeywordlist()); //vproj->SetInputOrigin(GetParameterImage("in")->GetOrigin()); - //vproj->SetInputSpacing(GetParameterImage("in")->GetSpacing()); + //vproj->SetInputSpacing(GetParameterImage("in")->GetSignedSpacing()); // Setup the DEM Handler otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); diff --git a/Modules/Applications/AppFiltering/app/CMakeLists.txt b/Modules/Applications/AppFiltering/app/CMakeLists.txt index 32a81d8dde02b4bca65fbb60d43c0d3cf0400ffc..fdd85cc2c869229032e0f6d299bf7703487b223b 100644 --- a/Modules/Applications/AppFiltering/app/CMakeLists.txt +++ b/Modules/Applications/AppFiltering/app/CMakeLists.txt @@ -18,14 +18,6 @@ # limitations under the License. # -set(OTBAppFiltering_LINK_LIBS - ${OTBImageNoise_LIBRARIES} - ${OTBContrast_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageBase_LIBRARIES} -) - otb_create_application( NAME Smoothing SOURCES otbSmoothing.cxx diff --git a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx index e80df1eea21a22aaa0c9473aaa0bda8b8efe2421..a31dc933881f65e3e50618d151f880fc87c90e9c 100644 --- a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx +++ b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx @@ -57,70 +57,81 @@ public: private: void DoInit() ITK_OVERRIDE { - SetName("Smoothing"); - SetDescription("Apply a smoothing filter to an image"); - - SetDocName("Smoothing"); - SetDocLongDescription("This application applies smoothing filter to an image." - " Either gaussian, mean, or anisotropic diffusion are available."); - SetDocLimitations("None"); - SetDocAuthors("OTB-Team"); + SetName( "Smoothing" ); + SetDescription( "Apply a smoothing filter to an image" ); + + SetDocName( "Smoothing" ); + SetDocLongDescription( "This application applies a smoothing filter to an " + "image. Three methodes can be used : a gaussian filter , a mean filter " + ", or an anisotropic diffusion using the Perona-Malik algorithm." ); + SetDocLimitations( "None") ; + SetDocAuthors( "OTB-Team" ); SetDocSeeAlso(" "); AddDocTag(Tags::Filter); - AddParameter(ParameterType_InputImage, "in", "Input Image"); - SetParameterDescription("in", "Input image to smooth."); - AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription("out", "Output smoothed image."); + AddParameter( ParameterType_InputImage , "in" , "Input Image" ); + SetParameterDescription( "in", "Input image to smooth." ); + AddParameter( ParameterType_OutputImage , "out" , "Output Image" ); + SetParameterDescription( "out" , "Output smoothed image." ); AddRAMParameter(); - AddParameter(ParameterType_Choice, "type", "Smoothing Type"); - SetParameterDescription("type", "Smoothing kernel to apply"); + AddParameter( ParameterType_Choice, "type" , "Smoothing Type" ); + SetParameterDescription( "type", "Smoothing kernel to apply" ); - AddChoice("type.mean", "Mean"); + AddChoice( "type.mean" , "Mean" ); - AddParameter(ParameterType_Radius, "type.mean.radius", "Radius"); - SetParameterDescription("type.mean.radius", "Mean radius (in pixels)"); - SetDefaultParameterInt("type.mean.radius", 2); + AddParameter( ParameterType_Radius , "type.mean.radius" , "Radius" ); + SetParameterDescription( "type.mean.radius" , + "Kernel's radius (in pixels)" ); + SetDefaultParameterInt( "type.mean.radius" , 2 ); - AddChoice("type.gaussian", "Gaussian"); + AddChoice( "type.gaussian" , "Gaussian" ); - AddParameter(ParameterType_Float, "type.gaussian.radius", "Radius"); - SetParameterDescription("type.gaussian.radius", "Gaussian radius (in pixels)"); - SetDefaultParameterFloat("type.gaussian.radius", 2.0); + AddParameter( ParameterType_Float, "type.gaussian.radius" , "Radius" ); + SetParameterDescription( "type.gaussian.radius", + "Standard deviation of the gaussian kernel used to filter the image"); + SetDefaultParameterFloat( "type.gaussian.radius" , 2.0 ); + // TODO rename this parameter - AddChoice("type.anidif", "Anisotropic Diffusion"); + AddChoice( "type.anidif" , "Anisotropic Diffusion" ); - AddParameter(ParameterType_Float, "type.anidif.timestep", "Time Step"); - SetParameterDescription("type.anidif.timestep", "Diffusion equation time step"); - AddParameter(ParameterType_Int, "type.anidif.nbiter", "Nb Iterations"); - SetParameterDescription("type.anidif.nbiter", "Number of iterations"); + AddParameter( ParameterType_Float , "type.anidif.timestep", "Time Step" ); + SetParameterDescription( "type.anidif.timestep" , + "Time step that will be used to discretize the diffusion equation" ); - AddParameter(ParameterType_Float, "type.anidif.conductance", "Conductance"); - SetParameterDescription("type.anidif.nbiter", "Controls the sensitivity of the conductance term"); + AddParameter( ParameterType_Int , "type.anidif.nbiter" , "Nb Iterations" ); + SetParameterDescription( "type.anidif.nbiter" , + "Number of iterations needed to get the result" ); - SetDefaultParameterFloat("type.anidif.timestep", 0.125); - SetDefaultParameterInt("type.anidif.nbiter", 10); - SetDefaultParameterInt("type.anidif.conductance", 1.); + AddParameter( ParameterType_Float , "type.anidif.conductance" , + "Conductance" ); + SetParameterDescription( "type.anidif.conductance" , + "Controls the sensitivity of the conductance term in the diffusion " + "equation. The lower it is the stronger the features will be preserved" ); - SetParameterString("type", "anidif", false); + SetDefaultParameterFloat( "type.anidif.timestep" , 0.125 ); + SetDefaultParameterInt( "type.anidif.nbiter" , 10 ); + SetDefaultParameterInt( "type.anidif.conductance" , 1. ); + + SetParameterString( "type" , "anidif" , false ); // Doc example parameter settings - SetExampleComment("Image smoothing using a mean filter.", 0); - SetDocExampleParameterValue("in", "Romania_Extract.tif"); - SetDocExampleParameterValue("out", "smoothedImage_mean.png uchar"); - SetDocExampleParameterValue("type", "mean"); - - unsigned int exId = AddExample( "Image smoothing using an anisotropic diffusion filter." ); - SetDocExampleParameterValue("in", "Romania_Extract.tif", exId); - SetDocExampleParameterValue("out", "smoothedImage_ani.png float", exId); - SetDocExampleParameterValue("type", "anidif", exId); - SetDocExampleParameterValue("type.anidif.timestep", "0.1", exId); - SetDocExampleParameterValue("type.anidif.nbiter", "5", exId); - SetDocExampleParameterValue("type.anidif.conductance", "1.5", exId); + SetExampleComment( "Image smoothing using a mean filter." , 0 ); + SetDocExampleParameterValue( "in" , "Romania_Extract.tif" ); + SetDocExampleParameterValue( "out" , "smoothedImage_mean.png uchar" ); + SetDocExampleParameterValue( "type" , "mean"); + + unsigned int exId = AddExample( "Image smoothing using an anisotropic " + "diffusion filter." ); + SetDocExampleParameterValue( "in" , "Romania_Extract.tif" , exId ); + SetDocExampleParameterValue( "out" , "smoothedImage_ani.png float" , exId ); + SetDocExampleParameterValue( "type" , "anidif" , exId ); + SetDocExampleParameterValue( "type.anidif.timestep" , "0.1" , exId ); + SetDocExampleParameterValue( "type.anidif.nbiter" , "5" , exId ); + SetDocExampleParameterValue( "type.anidif.conductance" , "1.5" , exId ); SetOfficialDocLink(); } diff --git a/Modules/Applications/AppFusion/app/CMakeLists.txt b/Modules/Applications/AppFusion/app/CMakeLists.txt index 1e7a0eb91559fd30e65a87870e8af08f661c6307..62a40faa238e9396899b495d060b9993603ac90c 100644 --- a/Modules/Applications/AppFusion/app/CMakeLists.txt +++ b/Modules/Applications/AppFusion/app/CMakeLists.txt @@ -18,14 +18,6 @@ # limitations under the License. # -set(OTBAppFusion_LINK_LIBS - ${OTBImageBase_LIBRARIES} - ${OTBInterpolation_LIBRARIES} - ${OTBPanSharpening_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBProjection_LIBRARIES} -) - otb_create_application( NAME BundleToPerfectSensor SOURCES otbBundleToPerfectSensor.cxx diff --git a/Modules/Applications/AppHyperspectral/app/CMakeLists.txt b/Modules/Applications/AppHyperspectral/app/CMakeLists.txt index 6256b8b601317f5708d4b56a3975ebc16e987fb6..a8e5d488799fbcb946cdd0ddf76a35d0a0c27071 100644 --- a/Modules/Applications/AppHyperspectral/app/CMakeLists.txt +++ b/Modules/Applications/AppHyperspectral/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppHyperspectral_LINK_LIBS - ${OTBStatistics_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBEndmembersExtraction_LIBRARIES} - ${OTBUnmixing_LIBRARIES} -) - otb_create_application( NAME HyperspectralUnmixing SOURCES otbHyperspectralUnmixing.cxx diff --git a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx index 4fe87620f4a2aa88bf6eb1ba246b9b5e99402e71..68c99058b4ea89e0ab2bdd1c1dd399f971708c39 100644 --- a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx @@ -50,16 +50,28 @@ private: void DoInit() ITK_OVERRIDE { SetName("VertexComponentAnalysis"); - SetDescription("Find endmembers in hyperspectral images with Vertex Component Analysis"); + SetDescription("Given a set of mixed spectral vectors, estimate" + "reference subtances also known as endmembers using the Vertex" + "Component Analysis algorithm."); // Documentation SetDocName("Vertex Component Analysis"); - SetDocLongDescription("Applies the Vertex Component Analysis to an hyperspectral image to extract endmembers"); + SetDocLongDescription("Apply the Vertex Component Analysis [1] to" + "an hyperspectral image to extract endmembers. Given a set of mixed" + "spectral vectors (multispectral or hyperspectral), the application" + "estimates the spectral signature of reference subtances also known" + "as endmembers."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); - SetDocSeeAlso(" "); - - AddDocTag("Miscellaneous"); + SetDocSeeAlso("[1] J. M. P. Nascimento and J. M. B. Dias, Vertex" + "component analysis: a fast algorithm to unmix hyperspectral data," + "in IEEE Transactions on Geoscience and Remote Sensing, vol. 43," + "no. 4, pp. 898-910, April 2005.J. M. P. Nascimento and" + "J. M. B. Dias, Vertex component analysis: a fast algorithm to" + "unmix hyperspectral data, in IEEE Transactions on Geoscience and" + "Remote Sensing, vol. 43, no. 4, pp. 898-910, April 2005."); + + AddDocTag("Miscellaneous"); AddDocTag(Tags::Hyperspectral); AddDocTag(Tags::DimensionReduction); @@ -67,12 +79,15 @@ private: SetParameterDescription("in","Input hyperspectral data cube"); AddParameter(ParameterType_Int, "ne", "Number of endmembers"); - SetParameterDescription("ne","The number of endmembers to extract from the data cube"); + SetParameterDescription("ne","The number of endmembers to extract from the hyperspectral image."); SetParameterInt("ne",1, false); MandatoryOn("ne"); AddParameter(ParameterType_OutputImage, "outendm", "Output Endmembers"); - SetParameterDescription("outendm","The endmebers, stored in a one-line multi-spectral image, each pixel representing an endmember"); + SetParameterDescription("outendm","Endmembers, stored in a" + "one-line multi-spectral image.Each pixel corresponds to one" + "endmembers and each band values corresponds to the spectral" + "signature of the corresponding endmember."); MandatoryOn("outendm"); AddRANDParameter(); diff --git a/Modules/Applications/AppImageUtils/app/CMakeLists.txt b/Modules/Applications/AppImageUtils/app/CMakeLists.txt index 369b82f06e3f199282eb456458539235c275094e..fe9bab84a533763ce162911ff230ec617a33c86d 100644 --- a/Modules/Applications/AppImageUtils/app/CMakeLists.txt +++ b/Modules/Applications/AppImageUtils/app/CMakeLists.txt @@ -18,24 +18,6 @@ # limitations under the License. # -set(OTBAppImageUtils_LINK_LIBS - ${OTBStatistics_LIBRARIES} - ${OTBColorMap_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBTransform_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBStreaming_LIBRARIES} - ${OTBCarto_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBCurlAdapters_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBMathParser_LIBRARIES} - ${OTBCommon_LIBRARIES} - ${OTBInterpolation_LIBRARIES} - ${OTBOSSIMAdapters_LIBRARIES} - ${OTBObjectList_LIBRARIES} -) - otb_create_application( NAME DownloadSRTMTiles SOURCES otbDownloadSRTMTiles.cxx diff --git a/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx b/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx index 5ebe69ddb418378e02d3808e4fd129ed4c51537c..185872b828b9299a1e807ee02d48b5da26f67931 100644 --- a/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx @@ -61,10 +61,12 @@ private: // Documentation SetDocName("Images Concatenation"); - SetDocLongDescription("This application performs images channels concatenation. It will walk the input image list (single or multi-channel) and generates a single multi-channel image. The channel order is the one of the list."); + SetDocLongDescription("This application performs images channels concatenation. " + "It reads the input image list (single or multi-channel) " + "and generates a single multi-channel image. The channel order is the same as the list."); SetDocLimitations("All input images must have the same size."); SetDocAuthors("OTB-Team"); - SetDocSeeAlso("Rescale application, Convert"); + SetDocSeeAlso("Rescale application, Convert, SplitImage"); AddDocTag(Tags::Manip); AddDocTag("Concatenation"); @@ -75,10 +77,10 @@ private: m_ImageList = ImageListType::New(); AddParameter(ParameterType_InputImageList, "il", "Input images list"); - SetParameterDescription("il", "The list of images to concatenate"); + SetParameterDescription("il", "The list of images to concatenate, must have the same size."); AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription("out", "The concatenated output image"); + SetParameterDescription("out", "The concatenated output image."); AddRAMParameter(); diff --git a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx index 62857abd2bbbd6d000f8e3cace1acc599d4df260..74bb9c42dadb51c605f164d14c228f5a6e5602c3 100644 --- a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx +++ b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx @@ -316,8 +316,8 @@ private: ossOutput << "\tOrigin : [" << GetParameterFloat("originx") << "," << GetParameterFloat("originy") << "]" << std::endl; //Get image spacing - SetParameterFloat("spacingx",inImage->GetSpacing()[0], false); - SetParameterFloat("spacingy",inImage->GetSpacing()[1], false); + SetParameterFloat("spacingx",inImage->GetSignedSpacing()[0], false); + SetParameterFloat("spacingy",inImage->GetSignedSpacing()[1], false); ossOutput << "\tSpacing : [" << GetParameterFloat("spacingx") << "," << GetParameterFloat("spacingy") << "]" << std::endl; //Estimate ground spacing diff --git a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx index ece8b815a3b7252b5d243833bf327c1b08842195..e23eaa57eb5697fc6805aeac63725d69c76f342c 100644 --- a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx +++ b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx @@ -52,13 +52,16 @@ private: void DoInit() ITK_OVERRIDE { SetName("SplitImage"); - SetDescription("Split a N multiband image into N images"); + SetDescription("Split a N multiband image into N images."); SetDocName("Split Image"); - SetDocLongDescription("This application splits a N-bands image into N mono-band images. The output images filename will be generated from the output parameter. Thus if the input image has 2 channels, and the user has set an output outimage.tif, the generated images will be outimage_0.tif and outimage_1.tif"); + SetDocLongDescription("This application splits a N-bands image into N mono-band images. " + "The output images filename will be generated from the output parameter. " + "Thus, if the input image has 2 channels, and the user has set as output parameter, outimage.tif, " + "the generated images will be outimage_0.tif and outimage_1.tif."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); - SetDocSeeAlso(" "); + SetDocSeeAlso("ConcatenateImages"); AddDocTag(Tags::Manip); @@ -66,8 +69,10 @@ private: SetParameterDescription("in","Input multiband image filename."); AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription("out", - "Output filename that will be used to get the prefix and the extension of the output images to write"); + SetParameterDescription("out", "The output filename will be used to get the prefix " + "an the extension of the output written's image. For example with outimage.tif as output filename, " + "the generated images will had an indice (corresponding at each bands) " + "between the prefix and the extension, such as: outimage_0.tif and outimage_1.tif (if 2 bands)."); AddRAMParameter(); diff --git a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx index a3f6a688aebd5402ef489e07e8c4e28311b6b4a7..5dd80bc10e6bc37c46f3302b8978272a6be973e7 100644 --- a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx +++ b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx @@ -52,7 +52,7 @@ private: // Documentation SetDocName("Image Tile Fusion"); - SetDocLongDescription("Concatenate several tile files into a single image file."); + SetDocLongDescription("Automatically mosaic a set of non overlapping tile files into a single image. Images must have a matching number of bands and they must be listed in lexicographic order."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); SetDocSeeAlso(" "); @@ -60,7 +60,7 @@ private: AddDocTag(Tags::Manip); AddParameter(ParameterType_InputImageList, "il", "Input Tile Images"); - SetParameterDescription("il", "Input tiles to concatenate (in lexicographic order : (0,0) (1,0) (0,1) (1,1))."); + SetParameterDescription("il", "Input images to concatenate (in lexicographic order, for instance : (0,0) (1,0) (0,1) (1,1))."); AddParameter(ParameterType_Int, "cols", "Number of tile columns"); SetParameterDescription("cols", "Number of columns in the tile array"); diff --git a/Modules/Applications/AppIndices/app/CMakeLists.txt b/Modules/Applications/AppIndices/app/CMakeLists.txt index 188bcf79d508d3230dbc263c6de7cc53f0c622cc..e17b73ed10c4f7cd1850358dbf75cd2910fc2177 100644 --- a/Modules/Applications/AppIndices/app/CMakeLists.txt +++ b/Modules/Applications/AppIndices/app/CMakeLists.txt @@ -18,12 +18,6 @@ # limitations under the License. # -set(OTBAppIndices_LINK_LIBS - ${OTBIndices_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBObjectList_LIBRARIES} -) - otb_create_application( NAME RadiometricIndices SOURCES otbRadiometricIndices.cxx diff --git a/Modules/Applications/AppKMZ/app/CMakeLists.txt b/Modules/Applications/AppKMZ/app/CMakeLists.txt index 2ac1d7b88c302f0b13b132ad7e44f1a8bf9a4f2c..40a4c3f9ac5ff1cc1a2def616a9d063129507eb6 100644 --- a/Modules/Applications/AppKMZ/app/CMakeLists.txt +++ b/Modules/Applications/AppKMZ/app/CMakeLists.txt @@ -18,10 +18,6 @@ # limitations under the License. # -set(OTBAppImageUtils_LINK_LIBS - ${OTBKMZWriter_LIBRARIES} -) - otb_create_application( NAME KmzExport SOURCES otbKmzExport.cxx diff --git a/Modules/Applications/AppMathParser/app/CMakeLists.txt b/Modules/Applications/AppMathParser/app/CMakeLists.txt index de42c60d71dd4aef1a0aba7af01475fd8fc2b6cf..516906753324c80e6cb057f9eed3f309b8ac6aa8 100644 --- a/Modules/Applications/AppMathParser/app/CMakeLists.txt +++ b/Modules/Applications/AppMathParser/app/CMakeLists.txt @@ -18,14 +18,6 @@ # limitations under the License. # -set(OTBAppMathParser_LINK_LIBS - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBMathParser_LIBRARIES} - ${OTBObjectList_LIBRARIES} - ) - - otb_create_application( NAME BandMath SOURCES otbBandMath.cxx diff --git a/Modules/Applications/AppMathParserX/app/CMakeLists.txt b/Modules/Applications/AppMathParserX/app/CMakeLists.txt index fef444d2f158a957e8f7d66725f1d989fed49bb8..e36ba79b11ffde240a868683aeaeef2c24627be5 100644 --- a/Modules/Applications/AppMathParserX/app/CMakeLists.txt +++ b/Modules/Applications/AppMathParserX/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppMathParserX_LINK_LIBS - ${OTBApplicationEngine_LIBRARIES} - ${OTBMathParserX_LIBRARIES} - ${OTBObjectList_LIBRARIES} - ) - - otb_create_application( NAME BandMathX SOURCES otbBandMathX.cxx diff --git a/Modules/Applications/AppMoments/app/CMakeLists.txt b/Modules/Applications/AppMoments/app/CMakeLists.txt index 8a59214f5f9267d8ab2cfc4232d1cf60022d55c5..197588da6415128386119acf3dd1243a40748ac8 100644 --- a/Modules/Applications/AppMoments/app/CMakeLists.txt +++ b/Modules/Applications/AppMoments/app/CMakeLists.txt @@ -18,12 +18,6 @@ # limitations under the License. # -set(OTBAppMoments_LINK_LIBS - ${OTBMoments_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} -) - otb_create_application( NAME LocalStatisticExtraction SOURCES otbLocalStatisticExtraction.cxx diff --git a/Modules/Applications/AppMorphology/app/CMakeLists.txt b/Modules/Applications/AppMorphology/app/CMakeLists.txt index dd1d8c9aecfd5ab0b29e5c5414dd1cd9e7858d27..dbb2b77582ae97e0becc11567eb5dea8d12a0c52 100644 --- a/Modules/Applications/AppMorphology/app/CMakeLists.txt +++ b/Modules/Applications/AppMorphology/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppMorphology_LINK_LIBS - ${OTBImageBase_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBObjectList_LIBRARIES} - ${OTBMorphologicalProfiles_LIBRARIES} -) - otb_create_application( NAME BinaryMorphologicalOperation SOURCES otbBinaryMorphologicalOperation.cxx diff --git a/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx b/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx index 486dd179452aca498030c435bea314084c3ac8f6..5db8cd97566d36c60d9c342068aa73bc8b4de699 100644 --- a/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx +++ b/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx @@ -78,77 +78,101 @@ private: void DoInit() ITK_OVERRIDE { -SetName("BinaryMorphologicalOperation"); -SetDescription("Performs morphological operations on an input image channel"); +SetName( "BinaryMorphologicalOperation" ); +SetDescription( "Performs morphological operations on an input image channel" ); // Documentation -SetDocName("Binary Morphological Operation"); -SetDocLongDescription("This application performs binary morphological operations on a mono band image"); -SetDocLimitations("None"); -SetDocAuthors("OTB-Team"); -SetDocSeeAlso("itkBinaryDilateImageFilter, itkBinaryErodeImageFilter, itkBinaryMorphologicalOpeningImageFilter and itkBinaryMorphologicalClosingImageFilter classes"); +SetDocName( "Binary Morphological Operation" ); +SetDocLongDescription( "This application performs binary morphological " + "operations on a mono band image or a channel of the input." ); +SetDocLimitations( "None" ); +SetDocAuthors( "OTB-Team" ); +SetDocSeeAlso( "itkBinaryDilateImageFilter, itkBinaryErodeImageFilter, " + "itkBinaryMorphologicalOpeningImageFilter and " + "itkBinaryMorphologicalClosingImageFilter classes." ); AddDocTag(Tags::FeatureExtraction); AddDocTag("Morphology"); -AddParameter(ParameterType_InputImage, "in", "Input Image"); -SetParameterDescription("in", "The input image to be filtered."); +AddParameter( ParameterType_InputImage , "in" , "Input Image" ); +SetParameterDescription( "in" , "The input image to be filtered." ); -AddParameter(ParameterType_OutputImage, "out", "Feature Output Image"); -SetParameterDescription("out", "Output image containing the filtered output image."); +AddParameter( ParameterType_OutputImage , "out" , "Output Image" ); +SetParameterDescription( "out" , "Output image" ); -AddParameter(ParameterType_Int, "channel", "Selected Channel"); -SetParameterDescription("channel", "The selected channel index"); -SetDefaultParameterInt("channel", 1); -SetMinimumParameterIntValue("channel", 1); +AddParameter( ParameterType_Int , "channel" , "Selected Channel" ); +SetParameterDescription( "channel" , "The selected channel index" ); +SetDefaultParameterInt( "channel" , 1 ); +SetMinimumParameterIntValue( "channel" , 1 ); AddRAMParameter(); -AddParameter(ParameterType_Choice, "structype", "Structuring Element Type"); -SetParameterDescription("structype", "Choice of the structuring element type"); +AddParameter( ParameterType_Choice , "structype" , + "Type of structuring element" ); +SetParameterDescription( "structype" , + "Choice of the structuring element type"); //Ball -AddChoice("structype.ball", "Ball"); -AddParameter(ParameterType_Int, "structype.ball.xradius", "The Structuring Element X Radius"); -SetParameterDescription("structype.ball.xradius", "The Structuring Element X Radius"); -SetDefaultParameterInt("structype.ball.xradius", 5); -AddParameter(ParameterType_Int, "structype.ball.yradius", "The Structuring Element Y Radius"); -SetParameterDescription("structype.ball.yradius", "The Structuring Element Y Radius"); -SetDefaultParameterInt("structype.ball.yradius", 5); +AddChoice( "structype.ball" , "Ball" ); +AddParameter( ParameterType_Int , "structype.ball.xradius" , + "Structuring element X radius" ); +SetParameterDescription( "structype.ball.xradius" , + "The structuring element radius along the X axis." ); +SetDefaultParameterInt( "structype.ball.xradius" , 5 ); +AddParameter( ParameterType_Int , "structype.ball.yradius" , + "Structuring element Y radiuss" ); +SetParameterDescription( "structype.ball.yradius" , + "The structuring element radius along the y axis." ); +SetDefaultParameterInt( "structype.ball.yradius" , 5 ); //Cross -AddChoice("structype.cross", "Cross"); +AddChoice( "structype.cross" , "Cross" ); AddParameter(ParameterType_Choice, "filter", "Morphological Operation"); SetParameterDescription("filter", "Choice of the morphological operation"); //Dilate -AddChoice("filter.dilate", "Dilate"); -AddParameter(ParameterType_Float, "filter.dilate.foreval", "Foreground Value"); -SetParameterDescription("filter.dilate.foreval", "The Foreground Value"); -SetDefaultParameterFloat("filter.dilate.foreval", 1.0); -AddParameter(ParameterType_Float, "filter.dilate.backval", "Background Value"); -SetParameterDescription("filter.dilate.backval", "The Background Value"); -SetDefaultParameterFloat("filter.dilate.backval", 0.0); +AddChoice( "filter.dilate" , "Dilate" ); +AddParameter( ParameterType_Float , "filter.dilate.foreval" , + "Foreground value" ); +SetParameterDescription( "filter.dilate.foreval" , + "Set the foreground value, default is 1.0." ); +SetDefaultParameterFloat( "filter.dilate.foreval" , 1.0 ); +AddParameter( ParameterType_Float , "filter.dilate.backval" , + "Background value" ); +SetParameterDescription( "filter.dilate.backval" , + "Set the background value, default is 0.0." ); +SetDefaultParameterFloat( "filter.dilate.backval" , 0.0 ); //Erode -AddChoice("filter.erode", "Erode"); -AddParameter(ParameterType_Float, "filter.erode.foreval", "Foreground Value"); -SetParameterDescription("filter.erode.foreval", "The Foreground Value"); -SetDefaultParameterFloat("filter.erode.foreval", 1.0); -AddParameter(ParameterType_Float, "filter.erode.backval", "Background Value"); -SetParameterDescription("filter.erode.backval", "The Background Value"); +AddChoice( "filter.erode" , "Erode" ); +AddParameter( ParameterType_Float , "filter.erode.foreval" , + "Foreground value" ); +SetParameterDescription( "filter.erode.foreval" , + "Set the foreground value, default is 1.0." ); +SetDefaultParameterFloat( "filter.erode.foreval" , 1.0 ); +AddParameter( ParameterType_Float , "filter.erode.backval" , + "Background value" ); +SetParameterDescription("filter.erode.backval", + "Set the background value, default is 0.0." ); SetDefaultParameterFloat("filter.erode.backval", 0.0); + //Opening -AddChoice("filter.opening", "Opening"); -AddParameter(ParameterType_Float, "filter.opening.foreval", "Foreground Value"); -SetParameterDescription("filter.opening.foreval", "The Foreground Value"); +AddChoice( "filter.opening" , "Opening" ); +AddParameter( ParameterType_Float , "filter.opening.foreval" , + "Foreground value" ); +SetParameterDescription( "filter.opening.foreval" , + "Set the foreground value, default is 1.0." ); SetDefaultParameterFloat("filter.opening.foreval", 1.0); -AddParameter(ParameterType_Float, "filter.opening.backval", "Background Value"); -SetParameterDescription("filter.opening.backval", "The Background Value"); -SetDefaultParameterFloat("filter.opening.backval", 0.0); +AddParameter( ParameterType_Float , "filter.opening.backval" , + "Background value" ); +SetParameterDescription( "filter.opening.backval" , + "Set the background value, default is 0.0." ); +SetDefaultParameterFloat( "filter.opening.backval" , 0.0 ); //Closing -AddChoice("filter.closing", "Closing"); -AddParameter(ParameterType_Float, "filter.closing.foreval", "Foreground Value"); -SetParameterDescription("filter.closing.foreval", "The Foreground Value"); -SetDefaultParameterFloat("filter.closing.foreval", 1.0); +AddChoice( "filter.closing" , "Closing" ); +AddParameter( ParameterType_Float , "filter.closing.foreval" , + "Foreground value" ); +SetParameterDescription( "filter.closing.foreval" , + "Set the foreground value, default is 1.0." ); +SetDefaultParameterFloat( "filter.closing.foreval" , 1.0 ); // Doc example parameter settings SetDocExampleParameterValue("in", "qb_RoadExtract.tif"); diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx index 3e6d338a0979dade558c2e19ee6278ee93c097fc..4bc606ac3fcc3e5f385f94e5b9d8540df40317c2 100644 --- a/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx @@ -74,64 +74,75 @@ private: void DoInit() ITK_OVERRIDE { SetName( "MorphologicalClassification" ); - SetDescription( "Performs morphological convex, concave and flat classification on an input image channel" ); + SetDescription( "Performs morphological convex, concave and flat " + "classification on an input image channel" ); // Documentation SetDocName( "Morphological Classification" ); - SetDocLongDescription( "This algorithm is based on the following publication:\n" - "\n" - "Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: A new approach\n" - "for the morphological segmentation of high resolution satellite imagery.\n" - "IEEE Transactions on geoscience and remote sensing, vol. 39, NO. 2,\n" - "February 2001, p. 309-320.\n" - "\n" - "This application perform the following decision rule to classify a pixel\n" - "between the three classes Convex, Concave and Flat. Let :math:`f` denote\n" - "the input image and :math:`\\psi_{N}(f)` the geodesic leveling of\n" - ":math:`f` with a structuring element of size :math:`N`. One can derive\n" - "the following decision rule to classify :math:`f` into Convex (label\n" - ":math:`\\stackrel{\\smile}{k}`), Concave (label\n" - ":math:`\\stackrel{\\frown}{k}`) and Flat (label :math:`\\bar{k}`): \n" - "\n" - ":math:`f(n) = \\begin{cases} \\stackrel{\\smile}{k} & : f-\\psi_{N}(f)>\\sigma \\\\ \\stackrel{\\frown}{k} & : \\psi_{N}(f)-f>\\sigma \\\\ \\bar{k} & : \\mid f - \\psi_{N}(f) \\mid \\leq \\sigma \\end{cases}`" - "\n\n" - "This output is a labeled image (0 : Flat, 1 : Convex, 2 : Concave)" ); - SetDocLimitations( "Generation of the morphological classification is not streamable, pay attention to this fact when setting the radius size of the structuring element." ); + SetDocLongDescription( + "This algorithm is based on the following publication:\n" + "Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: A new approach " + "for the morphological segmentation of high resolution satellite imagery.\n" + "IEEE Transactions on geoscience and remote sensing, vol. 39, NO. 2, " + "February 2001, p. 309-320.\n" + "\n" + "This application perform the following decision rule to classify a pixel " + "between the three classes Convex, Concave and Flat. Let :math:`f` denote " + "the input image and :math:`\\psi_{N}(f)` the geodesic leveling of " + ":math:`f` with a structuring element of size :math:`N`. One can derive " + "the following decision rule to classify :math:`f` into Convex (label " + ":math:`\\stackrel{\\smile}{k}`), Concave (label " + ":math:`\\stackrel{\\frown}{k}`) and Flat (label :math:`\\bar{k}`): " + "\n" + ":math:`f(n) = \\begin{cases} \\stackrel{\\smile}{k} & : f-\\psi_{N}(f)>\\sigma \\\\ \\stackrel{\\frown}{k} & : \\psi_{N}(f)-f>\\sigma \\\\ \\bar{k} & : \\mid f - \\psi_{N}(f) \\mid \\leq \\sigma \\end{cases}`" + "\n\n" + "The output is a labeled image (0 : Flat, 1 : Convex, 2 : Concave)" ); + SetDocLimitations( + "Generation of the morphological classification is not streamable, " + "pay attention to this fact when setting the radius size of the " + "structuring element." ); SetDocAuthors( "OTB-Team" ); SetDocSeeAlso( "otbConvexOrConcaveClassificationFilter class" ); - AddDocTag(Tags::FeatureExtraction); - AddDocTag("Morphology"); + AddDocTag( Tags::FeatureExtraction ); + AddDocTag( "Morphology" ); - AddParameter( ParameterType_InputImage, "in", "Input Image" ); - SetParameterDescription( "in", "The input image to be classified." ); + AddParameter( ParameterType_InputImage , "in" , "Input Image" ); + SetParameterDescription( "in" , "The input image to be classified." ); - AddParameter( ParameterType_OutputImage, "out", "Output Image" ); + AddParameter( ParameterType_OutputImage , "out" , "Output Image" ); SetParameterDescription( "out", - "The output classified image with 3 different values (0 : Flat, 1 : Convex, 2 : Concave)" ); + "The output classified image with 3 different values (0 : Flat, " + "1 : Convex, 2 : Concave)" ); - AddParameter( ParameterType_Int, "channel", "Selected Channel" ); - SetParameterDescription( "channel", "The selected channel index for input image" ); - SetDefaultParameterInt( "channel", 1 ); - SetMinimumParameterIntValue( "channel", 1 ); + AddParameter( ParameterType_Int , "channel" , "Selected Channel" ); + SetParameterDescription( "channel" , + "The selected channel index for input image" ); + SetDefaultParameterInt( "channel" , 1 ); + SetMinimumParameterIntValue( "channel" , 1 ); AddRAMParameter(); // Structuring Element (Ball | Cross) - AddParameter( ParameterType_Choice, "structype", "Structuring Element Type" ); - SetParameterDescription( "structype", "Choice of the structuring element type" ); - AddChoice( "structype.ball", "Ball" ); - AddChoice( "structype.cross", "Cross" ); - - AddParameter( ParameterType_Int, "radius", "Radius" ); - SetParameterDescription( "radius", "Radius of the structuring element (in pixels)" ); - SetDefaultParameterInt( "radius", 5 ); - SetMinimumParameterIntValue( "radius", 1 ); - - AddParameter( ParameterType_Float, "sigma", "Sigma value for leveling tolerance" ); - SetParameterDescription( "sigma", "Sigma value for leveling tolerance" ); - SetDefaultParameterFloat( "sigma", 0.5 ); - SetMinimumParameterFloatValue( "sigma", 0 ); + AddParameter( ParameterType_Choice , "structype" , + "Structuring Element Type" ); + SetParameterDescription( "structype" , + "Choice of the structuring element type" ); + AddChoice( "structype.ball" , "Ball" ); + AddChoice( "structype.cross" , "Cross" ); + + AddParameter( ParameterType_Int , "radius" , "Radius" ); + SetParameterDescription( "radius" , + "Radius of the structuring element (in pixels), default value is 5." ); + SetDefaultParameterInt( "radius" , 5 ); + SetMinimumParameterIntValue( "radius" , 1 ); + + AddParameter( ParameterType_Float , "sigma" , + "Sigma value for leveling tolerance" ); + SetParameterDescription( "sigma" , + "Sigma value for leveling tolerance, default value is 0.5." ); + SetDefaultParameterFloat( "sigma" , 0.5 ); + SetMinimumParameterFloatValue( "sigma" , 0 ); SetDocExampleParameterValue( "in", "ROI_IKO_PAN_LesHalles.tif" ); SetDocExampleParameterValue( "channel", "1" ); diff --git a/Modules/Applications/AppOpticalCalibration/app/CMakeLists.txt b/Modules/Applications/AppOpticalCalibration/app/CMakeLists.txt index 083697c509fa2ef9fabef4b64c345b99a862a323..736e1fb6f6ff31a60f203b224532708cd5316652 100644 --- a/Modules/Applications/AppOpticalCalibration/app/CMakeLists.txt +++ b/Modules/Applications/AppOpticalCalibration/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppOpticalCalibration_LINK_LIBS - ${OTBOpticalCalibration_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} -) - otb_create_application( NAME OpticalCalibration SOURCES otbOpticalCalibration.cxx diff --git a/Modules/Applications/AppProjection/app/CMakeLists.txt b/Modules/Applications/AppProjection/app/CMakeLists.txt index e072604c7104aaa9bc4d9b8d9bb80e1c4c8a29c0..059348c84016c794400ddc9f3a29c808e021feb6 100644 --- a/Modules/Applications/AppProjection/app/CMakeLists.txt +++ b/Modules/Applications/AppProjection/app/CMakeLists.txt @@ -18,21 +18,6 @@ # limitations under the License. # -set(OTBAppProjection_LINK_LIBS - ${OTBGdalAdapters_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBTransform_LIBRARIES} - ${OTBOSSIMAdapters_LIBRARIES} - ${OTBCarto_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBMathParser_LIBRARIES} - ${OTBCommon_LIBRARIES} - ${OTBGDAL_LIBRARIES} - ${OTBInterpolation_LIBRARIES} -) - otb_create_application( NAME OrthoRectification SOURCES otbOrthoRectification.cxx diff --git a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx index 1d9642aa01d6577af4743d7da28310d63d52c3db..dfecb742eab6f21f8bbeb72794f15aa68c5c849b 100644 --- a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx @@ -53,11 +53,11 @@ private: void DoInit() ITK_OVERRIDE { SetName("ConvertCartoToGeoPoint"); - SetDescription("Convert cartographic coordinates to geographic one."); + SetDescription("Convert cartographic coordinates to geographic ones."); // Documentation SetDocName("Cartographic to geographic coordinates conversion"); - SetDocLongDescription("This application computes the geographic coordinates from a cartographic one. User has to give the X and Y coordinate and the cartographic projection (UTM/LAMBERT/LAMBERT2/LAMBERT93/SINUS/ECKERT4/TRANSMERCATOR/MOLLWEID/SVY21)."); + SetDocLongDescription("This application computes the geographic coordinates from cartographic ones. User has to give the X and Y coordinate and the cartographic projection (see mapproj parameter for details)."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); SetDocSeeAlso(" "); @@ -67,20 +67,20 @@ private: AddParameter(ParameterType_Group, "carto", "Input cartographic coordinates"); AddParameter(ParameterType_Float, "carto.x", "X cartographic coordinates"); - SetParameterDescription("carto.x", "X cartographic coordinates in the specified projection."); + SetParameterDescription("carto.x", "X cartographic coordinates in the projection defined by mapproj parameter"); AddParameter(ParameterType_Float, "carto.y", "Y cartographic coordinates"); - SetParameterDescription("carto.y", "Y cartographic coordinates in the specified projection."); + SetParameterDescription("carto.y", "Y cartographic coordinates in the projection defined by mapproj parameter"); // Add the MapProjectionParameters MapProjectionParametersHandler::AddMapProjectionParameters(this, "mapproj"); AddParameter(ParameterType_Float, "long", "Output long"); - SetParameterDescription("long", "Point longitude coordinates."); + SetParameterDescription("long", "Point longitude coordinates in decimal degrees."); SetParameterRole("long", Role_Output); AddParameter(ParameterType_Float, "lat", "Output lat"); - SetParameterDescription("lat", "Point latitude coordinates."); + SetParameterDescription("lat", "Point latitude coordinates in decimal degrees."); SetParameterRole("lat", Role_Output); // Doc example parameter settings diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index 2dc6a6119f70ce75cd81e2483d32392e10933fc6..4d3c9cb2abbc631ef6fde7bb034f4b183d27a342 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -91,17 +91,18 @@ private: { SetName("OrthoRectification"); std::ostringstream oss; - oss << "This application allows ortho-rectification of optical and radar images from supported sensors." << std::endl; + oss << "This application allows to ortho-rectify optical and radar images from supported sensors." << std::endl; SetDescription(oss.str()); // Documentation SetDocName("Ortho-rectification"); oss.str(""); - oss<<"An inverse sensor model is built from the input image metadata to convert geographical to raw geometry coordinates. "; - oss<<"This inverse sensor model is then combined with the chosen map projection to build a global coordinate mapping grid. Last, this grid is used to resample using the chosen interpolation algorithm. "; - oss<<"A Digital Elevation Model can be specified to account for terrain deformations. "<<std::endl; + oss<<"This application uses inverse sensor modelling combined with a choice of interpolation functions to resample a sensor geometry image into a ground geometry regular grid. "; + oss<<"The ground geometry regular grid is defined with respect to a map projection (see map parameter). The application offers several modes to estimate the output grid parameters (origin and ground sampling distance), including automatic estimation of image size, ground sampling distance, or both, from image metadata, user-defined ROI corners, or another ortho-image."; + oss<<"A digital Elevation Model along with a geoid file can be specified to account for terrain deformations."; oss<<"In case of SPOT5 images, the sensor model can be approximated by an RPC model in order to speed-up computation."; + SetDocLongDescription(oss.str()); - SetDocLimitations("Supported sensors (both optical and radar) are: GeoEye, Ikonos, Pleiades, Quickbird, RadarSat, Sentinel-1, SPOT5 (TIF format), SPOT6/7, TerraSAR-X, Worldview 1/2/3."); + SetDocLimitations("Supported sensors (both optical and radar) are: GeoEye, Ikonos, Pleiades, Quickbird, RadarSat, Sentinel-1, SPOT5 (TIF format), SPOT6/7, TerraSAR-X, Worldview 1/2/3, and any TIF image with embedded RPC tags.\n Also note that the opt.gridspacing default value may not be suitable for all sensors. In particular, if this value is lower than the target ground sampling distance, the processing time may increase a lot. A warning is issued in this case. Typical values should be half the DEM ground sampling distance."); SetDocAuthors("OTB-Team"); SetDocSeeAlso("Ortho-rectification chapter from the OTB Software Guide"); @@ -533,7 +534,7 @@ private: FloatVectorImageType::Pointer inOrtho = GetParameterImage("outputs.ortho"); ResampleFilterType::OriginType orig = inOrtho->GetOrigin(); - ResampleFilterType::SpacingType spacing = inOrtho->GetSpacing(); + ResampleFilterType::SpacingType spacing = inOrtho->GetSignedSpacing(); ResampleFilterType::SizeType size = inOrtho->GetLargestPossibleRegion().GetSize(); SetParameterInt("outputs.sizex",size[0]); diff --git a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx index f1941b5e9a4637fdd3d8318c34129cf079b9c870..7b6da7d245c8e9b2d37f7191e56867903a2a76af 100644 --- a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx +++ b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx @@ -234,7 +234,7 @@ private: scale[1] = 1.0 / GetParameterFloat("transform.type.id.scaley"); // Evaluate spacing - FloatVectorImageType::SpacingType spacing = inputImage->GetSpacing(); + FloatVectorImageType::SpacingType spacing = inputImage->GetSignedSpacing(); FloatVectorImageType::SpacingType OutputSpacing; OutputSpacing[0] = spacing[0] * scale[0]; OutputSpacing[1] = spacing[1] * scale[1]; @@ -279,7 +279,7 @@ private: scale[1] = 1.0 / GetParameterFloat("transform.type.translation.scaley"); // Evaluate spacing - FloatVectorImageType::SpacingType spacing = inputImage->GetSpacing(); + FloatVectorImageType::SpacingType spacing = inputImage->GetSignedSpacing(); FloatVectorImageType::SpacingType OutputSpacing; OutputSpacing[0] = spacing[0] * scale[0]; OutputSpacing[1] = spacing[1] * scale[1]; @@ -312,7 +312,7 @@ private: ScalableTransformType::Pointer transform = ScalableTransformType::New(); FloatVectorImageType::SizeType inSize = inputImage->GetLargestPossibleRegion().GetSize(); - FloatVectorImageType::SpacingType spacing = inputImage->GetSpacing(); + FloatVectorImageType::SpacingType spacing = inputImage->GetSignedSpacing(); itk::ContinuousIndex<double,2> ULindex(inputImage->GetLargestPossibleRegion().GetIndex()); ULindex[0] += -0.5; diff --git a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx index 95ed2a5e93dd031c513799aa44337b027240a18f..1d1018e8fc74a755fa8b425a86369e4c0afc7d22 100644 --- a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx +++ b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx @@ -214,7 +214,7 @@ private: otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); // Set up output image information - FloatVectorImageType::SpacingType spacing = refImage->GetSpacing(); + FloatVectorImageType::SpacingType spacing = refImage->GetSignedSpacing(); FloatVectorImageType::IndexType start = refImage->GetLargestPossibleRegion().GetIndex(); FloatVectorImageType::SizeType size = refImage->GetLargestPossibleRegion().GetSize(); FloatVectorImageType::PointType origin = refImage->GetOrigin(); @@ -278,7 +278,7 @@ private: m_BasicResampler->SetOutputOrigin(origin); - FloatVectorImageType::SpacingType xsSpacing = GetParameterImage("inm")->GetSpacing(); + FloatVectorImageType::SpacingType xsSpacing = GetParameterImage("inm")->GetSignedSpacing(); xsSpacing*=0.25; m_BasicResampler->SetOutputSpacing(xsSpacing); diff --git a/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx b/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx index 82efac5377770e0e18f83f83c18170784f1def27..fe9e070a8b592c14e2fc63b6d8f16a65e79cd2a7 100644 --- a/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx +++ b/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx @@ -144,7 +144,7 @@ private: { FloatVectorImageType::Pointer inImage = GetParameterFloatVectorImage("in.kwl"); m_GeometriesProjFilter->SetInputOrigin(inImage->GetOrigin()); // nec qd capteur - m_GeometriesProjFilter->SetInputSpacing(inImage->GetSpacing()); // nec qd capteur + m_GeometriesProjFilter->SetInputSpacing(inImage->GetSignedSpacing()); // nec qd capteur m_GeometriesProjFilter->SetInputKeywordList(inImage->GetImageKeywordlist()); //otbAppLogINFO(<<"kwl."<<std::endl); } @@ -156,7 +156,7 @@ private: if (outImage) { m_GeometriesProjFilter->SetOutputOrigin(outImage->GetOrigin()); // nec qd capteur - m_GeometriesProjFilter->SetOutputSpacing(outImage->GetSpacing()); // nec qd capteur + m_GeometriesProjFilter->SetOutputSpacing(outImage->GetSignedSpacing()); // nec qd capteur m_OutputProjectionRef = outImage->GetProjectionRef(); // ~ wkt if (m_OutputProjectionRef.empty()) { diff --git a/Modules/Applications/AppSARCalibration/app/CMakeLists.txt b/Modules/Applications/AppSARCalibration/app/CMakeLists.txt index ee25f98ec2671127a0a8f63a0dcdd0b7942096ef..4360104d2a87f0b4995f15c2a36fde004f786096 100644 --- a/Modules/Applications/AppSARCalibration/app/CMakeLists.txt +++ b/Modules/Applications/AppSARCalibration/app/CMakeLists.txt @@ -18,11 +18,6 @@ # limitations under the License. # -set(OTBAppSARCalibration_LINK_LIBS - ${OTBSARCalibration_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} -) - otb_create_application( NAME SARCalibration SOURCES otbSARCalibration.cxx diff --git a/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt index 10c7ea39fc7ef8bd57dd9ffd4f17c7566aeffe98..4c34d6135075efc2173d4e4f5b67c733a3d2e4dd 100644 --- a/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt +++ b/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppFiltering_LINK_LIBS - ${OTBPolarimetry_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageBase_LIBRARIES} -) - otb_create_application( NAME SARDecompositions SOURCES otbSARDecompositions.cxx diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt index dd8715afe8f96d0dfed7b29025338b4ed98103d7..e3fd251eb1eac06523a8c16d485b4d99ce562f18 100644 --- a/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppFiltering_LINK_LIBS - ${OTBPolarimetry_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageBase_LIBRARIES} -) - otb_create_application( NAME SARPolarMatrixConvert SOURCES otbSARPolarMatrixConvert.cxx diff --git a/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt index 5390d9a85ab88cf05ee5f9696edce6d95e02f81f..ce4c55e0c86d7165726e99ef81de74078f9f3639 100644 --- a/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt +++ b/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt @@ -18,13 +18,6 @@ # limitations under the License. # -set(OTBAppFiltering_LINK_LIBS - ${OTBPolarimetry_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageBase_LIBRARIES} -) - otb_create_application( NAME SARPolarSynth SOURCES otbSARPolarSynth.cxx diff --git a/Modules/Applications/AppSARUtils/app/CMakeLists.txt b/Modules/Applications/AppSARUtils/app/CMakeLists.txt index 6f0e019f716c745c675961dc0e61923595171dd3..2c43cc4d8841fc95d6ffa09ccb5d9586f12ad73b 100644 --- a/Modules/Applications/AppSARUtils/app/CMakeLists.txt +++ b/Modules/Applications/AppSARUtils/app/CMakeLists.txt @@ -1,10 +1,22 @@ -set(OTBAppSARUtils_LINK_LIBS - ${OTBSARUtils_LIBRARIES} - {OTBImageNoise_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBITK_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} -) +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# otb_create_application( NAME ComputeModulusAndPhase diff --git a/Modules/Applications/AppSegmentation/app/CMakeLists.txt b/Modules/Applications/AppSegmentation/app/CMakeLists.txt index f55ae3d7f91d607359b5024a17f89136428edf76..b6003d6cace04f209ae9d30ab53ee13a4ee9f500 100644 --- a/Modules/Applications/AppSegmentation/app/CMakeLists.txt +++ b/Modules/Applications/AppSegmentation/app/CMakeLists.txt @@ -18,29 +18,6 @@ # limitations under the License. # -set(OTBAppSegmentation_LINK_LIBS - ${OTBVectorDataBase_LIBRARIES} - ${OTBLabelMap_LIBRARIES} - ${OTBConversion_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBImageIO_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBWatersheds_LIBRARIES} - ${OTBGdalAdapters_LIBRARIES} - ${OTBSmoothing_LIBRARIES} - ${OTBMetrics_LIBRARIES} - ${OTBOGRProcessing_LIBRARIES} - ${OTBStatistics_LIBRARIES} - ${OTBMeanShift_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBCCOBIA_LIBRARIES} - ${OTBMathParser_LIBRARIES} - ${OTBMorphologicalProfiles_LIBRARIES} - ${OTBTransform_LIBRARIES} - ${OTBCommon_LIBRARIES} -) - otb_create_application( NAME Segmentation SOURCES otbSegmentation.cxx diff --git a/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx index c141e8c8c942be5c797726e0efa3fd7bdd1db252..b9bc876f11d21efe230cbbea773c60e99cd78c55 100644 --- a/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx @@ -173,7 +173,7 @@ private: m_Vproj->SetInput(m_Connected->GetFilter()->GetOutputVectorData()); m_Vproj->SetInputKeywordList(inputImage->GetImageKeywordlist()); //m_Vproj->SetInputOrigin(inputImage->GetOrigin()); - //m_Vproj->SetInputSpacing(inputImage->GetSpacing()); + //m_Vproj->SetInputSpacing(inputImage->GetSignedSpacing()); // Setup the DEM Handler otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); diff --git a/Modules/Applications/AppStereo/app/CMakeLists.txt b/Modules/Applications/AppStereo/app/CMakeLists.txt index 3bcccffde447914bc3a4a9ab637d02832eb190ae..8fc636a98354c957ff234da94a2319eef8c8963f 100644 --- a/Modules/Applications/AppStereo/app/CMakeLists.txt +++ b/Modules/Applications/AppStereo/app/CMakeLists.txt @@ -18,21 +18,6 @@ # limitations under the License. # -set(OTBAppStereo_LINK_LIBS - ${OTBStereo_LIBRARIES} - ${OTBStatistics_LIBRARIES} - ${OTBImageIO_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBInterpolation_LIBRARIES} - ${OTBTransform_LIBRARIES} - ${OTBDisplacementField_LIBRARIES} - ${OTBDisparityMap_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} - ${OTBMathParser_LIBRARIES} - ${OTBObjectList_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} -) - otb_create_application( NAME StereoFramework SOURCES otbStereoFramework.cxx diff --git a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx index 312cff69e50867b3ac2ee6d0b5c4ce9bce98b4b5..279c09ad2f9734bf45a95cb612408edb36efb8b8 100644 --- a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx @@ -313,47 +313,66 @@ private: void DoInit() ITK_OVERRIDE { + // TODO : implement this application as a CompositeApplication... SetName("StereoFramework"); SetDescription("Compute the ground elevation based on one or multiple stereo pair(s)"); SetDocName("Stereo Framework"); - SetDocLongDescription("Compute the ground elevation with a stereo block matching algorithm " - "between one or multiple stereo pair in sensor geometry. The output is projected in " - "desired geographic or cartographic map projection (UTM by default). The pipeline is made of the following steps:\n" - "for each sensor pair :\n\n" - "\t- compute the epipolar displacement grids from the stereo pair (direct and inverse)\n" - "\t- resample the stereo pair into epipolar geometry using BCO interpolation\n" - "\t- create masks for each epipolar image : remove black borders and resample" - " input masks\n" - "\t- compute horizontal disparities with a block matching algorithm\n" - "\t- refine disparities to sub-pixel precision with a dichotomy algorithm\n" - "\t- apply an optional median filter\n" - "\t- filter disparities based on the correlation score and exploration bounds\n" - "\t- translate disparities in sensor geometry\n" - "\t convert disparity to 3D Map.\n\n" - "Then fuse all 3D maps to produce DSM."); + SetDocLongDescription( + "Compute the ground elevation with a stereo block matching algorithm " + "between one or multiple stereo pair in sensor geometry. The output is " + "projected in desired geographic or cartographic map projection (WGS84 by" + " default).\n\n" + "This application is chaining different processing steps. Some of them " + "are also performed by other applications in the stereo-reconstruction " + "framework:\n" + " * StereoRectificationGridGenerator [1] : for the generation of deformation grids\n" + " * GridBasedImageResampling [2] : resampling into epipolar geometry\n" + " * BlockMatching [3] : estimation of dense disparity maps\n\n" + "The pipeline executes the following steps on each stereo pair:\n" + " - compute the epipolar displacement grids from the stereo pair (direct and inverse)\n" + " - resample the stereo pair into epipolar geometry using BCO interpolation\n" + " - create masks for each epipolar image : remove black borders and resample" + " input masks\n" + " - compute horizontal disparities with a block matching algorithm\n" + " - refine disparities to sub-pixel precision with a dichotomy algorithm\n" + " - apply an optional median filter\n" + " - filter disparities based on the correlation score and exploration bounds\n" + " - translate disparities in sensor geometry\n" + " - convert disparity to 3D Map.\n\n" + "Then all 3D maps are fused to produce DSM. The fusion method in each " + "DEM cell can be chosen between maximum, minimum and average."); SetDocLimitations(" "); SetDocAuthors("OTB-Team"); - SetDocSeeAlso(" "); + SetDocSeeAlso("[1] StereoRectificationGridGenerator\n" + "[2] GridBasedImageResampling\n" + "[3] BlockMatching"); AddDocTag(Tags::Stereo); // Add the output parameters in a group AddParameter(ParameterType_Group, "input", "Input parameters"); - SetParameterDescription("input","This group of parameters allows one to parametrize input data."); + SetParameterDescription("input","This group of parameters allows one to set input data."); - AddParameter(ParameterType_InputImageList, "input.il", "Input images list"); - SetParameterDescription("input.il", "The list of images."); + AddParameter(ParameterType_InputImageList, "input.il", "Input images list"); + SetParameterDescription("input.il", "List of images corresponding to " + "multiple views on a single scene, in sensor geometry."); AddParameter(ParameterType_String, "input.co", "Couples list"); - SetParameterDescription("input.co","List of index of couples im image list. Couples must be separated by a comma. (index start at 0). for example : 0 1,1 2 will process a first couple composed of the first and the second image in image list, then the first and the third image\n. note that images are handled by pairs." - " if left empty couples are created from input index i.e. a first couple will be composed of the first and second image, a second couple with third and fourth image etc. (in this case image list must be even)."); + SetParameterDescription("input.co","List of index of couples im image list." + " Couples must be separated by a comma (index start at 0). For example :" + " 0 1,1 2 will process a first couple composed of the first and the" + " second image in image list, then the second and the third image\n. " + "Note that images are handled by pairs. If left empty, couples are " + "created from input index i.e. a first couple will be composed of the " + "first and second image, a second couple with third and fourth image etc." + " (in this case image list must be even)."); MandatoryOff("input.co"); SetParameterString("input.co","", false); DisableParameter("input.co"); - AddParameter(ParameterType_Int, "input.channel", "Image channel used for the block matching"); - SetParameterDescription("input.channel", "Used channel for block matching (used for all images)"); + AddParameter(ParameterType_Int, "input.channel", "Input Image channel"); + SetParameterDescription("input.channel", "Channel used for block matching (the same for all images)"); SetDefaultParameterInt("input.channel", 1); SetMinimumParameterIntValue("input.channel", 1); @@ -380,10 +399,18 @@ private: // UserDefined values AddParameter(ParameterType_Choice, "output.fusionmethod", "Method to fuse measures in each DSM cell"); SetParameterDescription("output.fusionmethod","This parameter allows one to choose the method used to fuse elevation measurements in each output DSM cell"); - AddChoice("output.fusionmethod.max", "The cell is filled with the maximum measured elevation values"); - AddChoice("output.fusionmethod.min", "The cell is filled with the minimum measured elevation values"); - AddChoice("output.fusionmethod.mean","The cell is filled with the mean of measured elevation values"); - AddChoice("output.fusionmethod.acc", "accumulator mode. The cell is filled with the the number of values (for debugging purposes)."); + AddChoice("output.fusionmethod.max", "Maximum"); + SetParameterDescription("output.fusionmethod.max","The cell is filled with" + " the maximum measured elevation values"); + AddChoice("output.fusionmethod.min", "Minimum"); + SetParameterDescription("output.fusionmethod.min", "The cell is filled with" + " the minimum measured elevation values"); + AddChoice("output.fusionmethod.mean","Mean"); + SetParameterDescription("output.fusionmethod.mean","The cell is filled with" + " the mean of measured elevation values"); + AddChoice("output.fusionmethod.acc", "Accumulator"); + SetParameterDescription("output.fusionmethod.acc", "Accumulator mode. The" + " cell is filled with the the number of values (for debugging purposes)."); AddParameter(ParameterType_OutputImage,"output.out","Output DSM"); SetParameterDescription("output.out","Output elevation image"); @@ -396,55 +423,76 @@ private: SetParameterDescription("output.mode.user","This mode allows you to fully modify default values."); // Upper left point coordinates AddParameter(ParameterType_Float, "output.mode.user.ulx", "Upper Left X "); - SetParameterDescription("output.mode.user.ulx","Cartographic X coordinate of upper-left corner (meters for cartographic projections, degrees for geographic ones)"); + SetParameterDescription("output.mode.user.ulx","Cartographic X coordinate " + "of upper-left corner (meters for cartographic projections, degrees for" + " geographic ones)"); AddParameter(ParameterType_Float, "output.mode.user.uly", "Upper Left Y "); - SetParameterDescription("output.mode.user.uly","Cartographic Y coordinate of the upper-left corner (meters for cartographic projections, degrees for geographic ones)"); + SetParameterDescription("output.mode.user.uly","Cartographic Y coordinate " + "of the upper-left corner (meters for cartographic projections, degrees " + "for geographic ones)"); // Size of the output image AddParameter(ParameterType_Int, "output.mode.user.sizex", "Size X "); - SetParameterDescription("output.mode.user.sizex","Size of projected image along X (in pixels)"); + SetParameterDescription("output.mode.user.sizex","Size of projected image" + " along X (in pixels)"); AddParameter(ParameterType_Int, "output.mode.user.sizey", "Size Y "); - SetParameterDescription("output.mode.user.sizey","Size of projected image along Y (in pixels)"); + SetParameterDescription("output.mode.user.sizey","Size of projected image" + " along Y (in pixels)"); // Spacing of the output image AddParameter(ParameterType_Float, "output.mode.user.spacingx", "Pixel Size X "); - SetParameterDescription("output.mode.user.spacingx","Size of each pixel along X axis (meters for cartographic projections, degrees for geographic ones)"); + SetParameterDescription("output.mode.user.spacingx","Size of each pixel " + "along X axis (meters for cartographic projections, degrees for geographic ones)"); AddParameter(ParameterType_Float, "output.mode.user.spacingy", "Pixel Size Y "); - SetParameterDescription("output.mode.user.spacingy","Size of each pixel along Y axis (meters for cartographic projections, degrees for geographic ones)"); + SetParameterDescription("output.mode.user.spacingy","Size of each pixel " + "along Y axis (meters for cartographic projections, degrees for geographic ones)"); // Add the output parameters in a group AddParameter(ParameterType_Group, "stereorect", "Stereorectification Grid parameters"); - SetParameterDescription("stereorect","This group of parameters allows one to choose direct and inverse grid subsampling. These parameters are very useful to tune time and memory consumption."); + SetParameterDescription("stereorect","This group of parameters allows one " + "to choose direct and inverse grid subsampling. These parameters are very" + " useful to tune time and memory consumption."); AddParameter(ParameterType_Int,"stereorect.fwdgridstep","Step of the displacement grid (in pixels)"); - SetParameterDescription("stereorect.fwdgridstep","Stereo-rectification displacement grid only varies slowly. Therefore, it is recommended to use a coarser grid (higher step value) in case of large images"); + SetParameterDescription("stereorect.fwdgridstep","Stereo-rectification " + "displacement grid only varies slowly. Therefore, it is recommended to " + "use a coarser grid (higher step value) in case of large images"); SetDefaultParameterInt("stereorect.fwdgridstep",16); MandatoryOff("stereorect.fwdgridstep"); AddParameter(ParameterType_Int, "stereorect.invgridssrate", "Sub-sampling rate for epipolar grid inversion"); - SetParameterDescription("stereorect.invgridssrate","Grid inversion is an heavy process that implies spline regression on control points. To avoid eating to much memory, this parameter allows one to first sub-sample the field to invert."); + SetParameterDescription("stereorect.invgridssrate","Grid inversion is an " + "heavy process that implies spline regression on control points. To avoid" + " eating to much memory, this parameter allows one to first sub-sample " + "the field to invert."); SetDefaultParameterInt("stereorect.invgridssrate",10); SetMinimumParameterIntValue("stereorect.invgridssrate",1); MandatoryOff("stereorect.invgridssrate"); AddParameter(ParameterType_Group,"bm","Block matching parameters"); - SetParameterDescription("bm","This group of parameters allow tuning the block-matching behavior"); + SetParameterDescription("bm","This group of parameters allow tuning the " + "block-matching behavior"); AddParameter(ParameterType_Choice, "bm.metric", "Block-matching metric"); + SetParameterDescription("bm.metric", "Metric used to compute matching score"); //SetDefaultParameterInt("bm.metric",3); AddChoice("bm.metric.ssdmean","Sum of Squared Distances divided by mean of block"); - SetParameterDescription("bm.metric.ssdmean","derived version of Sum of Squared Distances between pixels value in the metric window (SSD divided by mean over window)"); + SetParameterDescription("bm.metric.ssdmean","derived version of Sum of " + "Squared Distances between pixels value in the metric window (SSD divided" + " by mean over window)"); AddChoice("bm.metric.ssd","Sum of Squared Distances"); - SetParameterDescription("bm.metric.ssd","Sum of squared distances between pixels value in the metric window"); + SetParameterDescription("bm.metric.ssd","Sum of squared distances between " + "pixels value in the metric window"); AddChoice("bm.metric.ncc","Normalized Cross-Correlation"); - SetParameterDescription("bm.metric.ncc","Normalized Cross-Correlation between the left and right windows"); + SetParameterDescription("bm.metric.ncc","Normalized Cross-Correlation " + "between the left and right windows"); AddChoice("bm.metric.lp","Lp pseudo-norm"); SetParameterDescription("bm.metric.lp","Lp pseudo-norm between the left and right windows"); @@ -454,20 +502,22 @@ private: SetDefaultParameterFloat("bm.metric.lp.p", 1.0); SetMinimumParameterFloatValue("bm.metric.lp.p", 0.0); - AddParameter(ParameterType_Int,"bm.radius","Radius of blocks for matching filter (in pixels)"); + AddParameter(ParameterType_Int,"bm.radius","Correlation window radius (in pixels)"); SetParameterDescription("bm.radius","The radius of blocks in Block-Matching (in pixels)"); SetDefaultParameterInt("bm.radius",2); SetMinimumParameterIntValue("bm.radius",1); MandatoryOff("bm.radius"); AddParameter(ParameterType_Float,"bm.minhoffset","Minimum altitude offset (in meters)"); - SetParameterDescription("bm.minhoffset","Minimum altitude below the selected elevation source (in meters)"); + SetParameterDescription("bm.minhoffset","Minimum altitude below the " + "selected elevation source (in meters)"); //MandatoryOff("bm.minhoffset"); SetDefaultParameterFloat("bm.minhoffset",-20.0); DisableParameter("bm.minhoffset"); AddParameter(ParameterType_Float,"bm.maxhoffset","Maximum altitude offset (in meters)"); - SetParameterDescription("bm.maxhoffset","Maximum altitude above the selected elevation source (in meters)"); + SetParameterDescription("bm.maxhoffset","Maximum altitude above the " + "selected elevation source (in meters)"); //MandatoryOff("bm.maxhoffset"); SetDefaultParameterFloat("bm.maxhoffset",20.0); DisableParameter("bm.maxhoffset"); @@ -475,19 +525,25 @@ private: AddParameter(ParameterType_Group,"postproc","Postprocessing parameters"); SetParameterDescription("postproc","This group of parameters allow use optional filters."); - AddParameter(ParameterType_Empty,"postproc.bij","Use bijection consistency in block matching strategy"); - SetParameterDescription("postproc.bij","use bijection consistency. Right to Left correlation is computed to validate Left to Right disparities. If bijection is not found pixel is rejected."); + AddParameter(ParameterType_Empty,"postproc.bij","Use bijection consistency" + " in block matching strategy"); + SetParameterDescription("postproc.bij","Use bijection consistency. " + "Right to Left correlation is computed to validate Left to Right " + "disparities. If bijection is not found, the disparity is rejected."); MandatoryOff("postproc.bij"); EnableParameter("postproc.bij"); AddParameter(ParameterType_Empty,"postproc.med","Use median disparities filtering"); - SetParameterDescription("postproc.med","disparities output can be filtered using median post filtering (disabled by default)."); + SetParameterDescription("postproc.med","Disparity map can be filtered using" + " median post filtering (disabled by default)."); MandatoryOff("postproc.med"); DisableParameter("postproc.med"); AddParameter(ParameterType_Float,"postproc.metrict","Correlation metric threshold"); - SetParameterDescription("postproc.metrict","Use block matching metric output to discard pixels with low correlation value (disabled by default, float value)"); + SetParameterDescription("postproc.metrict","Use block matching metric " + "output to discard pixels with low correlation value (disabled by " + "default, float value)"); MandatoryOff("postproc.metrict"); SetDefaultParameterFloat("postproc.metrict",0.6); DisableParameter("postproc.metrict"); @@ -495,24 +551,28 @@ private: AddParameter(ParameterType_Group,"mask","Masks"); AddParameter(ParameterType_InputImage, "mask.left","Input left mask"); - SetParameterDescription("mask.left","Mask for left input image"); + SetParameterDescription("mask.left","Mask for left input image. Pixel with" + " a null mask value are discarded."); MandatoryOff("mask.left"); DisableParameter("mask.left"); AddParameter(ParameterType_InputImage, "mask.right","Input right mask"); - SetParameterDescription("mask.right","Mask for right input image"); + SetParameterDescription("mask.right","Mask for right input image. Pixel " + "with a null mask value are discarded."); MandatoryOff("mask.right"); DisableParameter("mask.right"); - AddParameter(ParameterType_Float,"mask.variancet","Discard pixels with low local variance"); - SetParameterDescription("mask.variancet","This parameter allows one to discard pixels whose local variance is too small (the size of the neighborhood is given by the radius parameter)"); + AddParameter(ParameterType_Float,"mask.variancet","Discard pixels with low" + " local variance"); + SetParameterDescription("mask.variancet","This parameter allows one to " + "discard pixels whose local variance is too small (the size of the " + "neighborhood is given by the correlation window radius)"); MandatoryOff("mask.variancet"); SetDefaultParameterFloat("mask.variancet",50.); //DisableParameter("mask.variancet"); AddRAMParameter(); - SetDocExampleParameterValue("input.il","sensor_stereo_left.tif sensor_stereo_right.tif"); SetDocExampleParameterValue("elev.default","200"); SetDocExampleParameterValue("stereorect.fwdgridstep", "8"); @@ -688,8 +748,8 @@ private: epipolarGridSource->Update(); FloatImageType::SpacingType epiSpacing; - epiSpacing[0] = 0.5 * (vcl_abs(inleft->GetSpacing()[0]) + vcl_abs(inleft->GetSpacing()[1])); - epiSpacing[1] = 0.5 * (vcl_abs(inleft->GetSpacing()[0]) + vcl_abs(inleft->GetSpacing()[1])); + epiSpacing[0] = 0.5 * (vcl_abs(inleft->GetSignedSpacing()[0]) + vcl_abs(inleft->GetSignedSpacing()[1])); + epiSpacing[1] = 0.5 * (vcl_abs(inleft->GetSignedSpacing()[0]) + vcl_abs(inleft->GetSignedSpacing()[1])); FloatImageType::SizeType epiSize; epiSize = epipolarGridSource->GetRectifiedImageSize(); @@ -721,7 +781,7 @@ private: leftInverseDisplacementFieldFilter->SetInput(leftDisplacement); FloatVectorImageType::PointType lorigin = inleft->GetOrigin(); - FloatVectorImageType::SpacingType lspacing = inleft->GetSpacing(); + FloatVectorImageType::SpacingType lspacing = inleft->GetSignedSpacing(); FloatVectorImageType::SizeType lsize = inleft->GetLargestPossibleRegion().GetSize(); double gridStep = epipolarGridSource->GetGridStep(); lspacing[0] *= gridStep; diff --git a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx index ed0d0fddb05a79d64082bdbbf236409064f02a03..111dea621f106dfc47f36a4b3e3319b81ce1e0d3 100644 --- a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx @@ -102,11 +102,28 @@ private: void DoInit() ITK_OVERRIDE { SetName("StereoRectificationGridGenerator"); - SetDescription("Generates two deformation fields to stereo-rectify (i.e. resample in epipolar geometry) a pair of stereo images up to the sensor model precision"); + SetDescription("Generates two deformation fields to resample in epipolar " + "geometry, a pair of stereo images up to the sensor model precision"); SetDocName("Stereo-rectification deformation grid generator"); - SetDocLongDescription("This application generates a pair of deformation grid to stereo-rectify a pair of stereo images according to sensor modelling and a mean elevation hypothesis. The deformation grids can be passed to the GridBasedImageResampling application for actual resampling in epipolar geometry."); - SetDocLimitations("Generation of the deformation grid is not streamable, pay attention to this fact when setting the grid step."); + SetDocLongDescription("This application generates a pair of deformation " + "grid to stereo-rectify a pair of stereo images according to sensor " + "modelling and a mean elevation hypothesis.\n\n" + "This application is the first part of the stereo reconstruction " + "framework. The output deformation grids can be passed to the " + "GridBasedImageResampling application for actual resampling into epipolar" + " geometry.\n\n" + "There are several ways to set the elevation source:\n" + " * An arbitrary constant elevation\n" + " * A DEM directoy\n" + " * Compute an average elevation from a DEM\n\n" + "If needed, the application can compute inverse resampling grids (from " + "epipolar to original sensor geometry). Don't forget to check the other " + "outputs from the application. For instance, the application gives the " + "X and Y size of the rectified images, along with an estimated baseline " + "ratio."); + SetDocLimitations("Generation of the deformation grid is not streamable, " + "pay attention to this fact when setting the grid step."); SetDocAuthors("OTB-Team"); AddDocTag(Tags::Stereo); @@ -116,16 +133,20 @@ private: AddParameter(ParameterType_Group,"io","Input and output data"); SetParameterDescription("io","This group of parameters allows setting the input and output images."); AddParameter(ParameterType_InputImage,"io.inleft","Left input image"); - SetParameterDescription("io.inleft","The left input image to resample"); + SetParameterDescription("io.inleft","The left image from the stereo pair," + " in sensor geometry."); AddParameter(ParameterType_InputImage,"io.inright","Right input image"); - SetParameterDescription("io.inright","The right input image to resample"); + SetParameterDescription("io.inright","The right image from the stereo pair," + " in sensor geometry."); AddParameter(ParameterType_OutputImage, "io.outleft", "Left output deformation grid"); - SetParameterDescription("io.outleft","The output deformation grid to be used to resample the left input image"); + SetParameterDescription("io.outleft","The deformation grid to resample the" + " left image from sensor geometry to epipolar geometry."); AddParameter(ParameterType_OutputImage, "io.outright", "Right output deformation grid"); - SetParameterDescription("io.outright","The output deformation grid to be used to resample the right input image"); + SetParameterDescription("io.outright","The deformation grid to resample the" + " right image from sensor geometry to epipolar geometry."); AddParameter(ParameterType_Group,"epi","Epipolar geometry and grid parameters"); SetParameterDescription("epi","Parameters of the epipolar geometry and output grids"); @@ -148,48 +169,73 @@ private: DisableParameter("epi.elevation.avgdem.value"); AddParameter(ParameterType_Float,"epi.elevation.avgdem.mindisp","Minimum disparity from DEM"); - SetParameterDescription("epi.elevation.avgdem.mindisp","Disparity corresponding to estimated minimum elevation over the left image"); + SetParameterDescription("epi.elevation.avgdem.mindisp","Disparity " + "corresponding to estimated minimum elevation over the left image"); SetParameterRole("epi.elevation.avgdem.mindisp",Role_Output); DisableParameter("epi.elevation.avgdem.mindisp"); AddParameter(ParameterType_Float,"epi.elevation.avgdem.maxdisp","Maximum disparity from DEM"); - SetParameterDescription("epi.elevation.avgdem.maxdisp","Disparity corresponding to estimated maximum elevation over the left image"); + SetParameterDescription("epi.elevation.avgdem.maxdisp","Disparity " + "corresponding to estimated maximum elevation over the left image"); SetParameterRole("epi.elevation.avgdem.maxdisp",Role_Output); DisableParameter("epi.elevation.avgdem.maxdisp"); AddParameter(ParameterType_Float,"epi.scale","Scale of epipolar images"); - SetParameterDescription("epi.scale","The scale parameter allows generating zoomed-in (scale < 1) or zoomed-out (scale > 1) epipolar images."); + SetParameterDescription("epi.scale","The scale parameter allows generating" + " zoomed-in (scale < 1) or zoomed-out (scale > 1) epipolar images."); SetDefaultParameterFloat("epi.scale",1.); AddParameter(ParameterType_Int,"epi.step","Step of the deformation grid (in nb. of pixels)"); - SetParameterDescription("epi.step","Stereo-rectification deformation grid only varies slowly. Therefore, it is recommended to use a coarser grid (higher step value) in case of large images"); + SetParameterDescription("epi.step","Stereo-rectification deformation grid " + "only varies slowly. Therefore, it is recommended to use a coarser grid " + "(higher step value) in case of large images"); SetDefaultParameterInt("epi.step",1); AddParameter(ParameterType_Int,"epi.rectsizex","Rectified image size X"); - SetParameterDescription("epi.rectsizex","The application computes the optimal rectified image size so that the whole left input image fits into the rectified area. However, due to the scale and step parameter, this size may not match the size of the deformation field output. In this case, one can use these output values."); + SetParameterDescription("epi.rectsizex","The application computes the " + "optimal rectified image size so that the whole left input image fits " + "into the rectified area. However, due to the scale and step parameter, " + "this size may not match the size of the deformation field output. In " + "this case, one can use these output values."); SetParameterRole("epi.rectsizex", Role_Output); AddParameter(ParameterType_Int,"epi.rectsizey","Rectified image size Y"); - SetParameterDescription("epi.rectsizey","The application computes the optimal rectified image size so that the whole left input image fits into the rectified area. However, due to the scale and step parameter, this size may not match the size of the deformation field output. In this case, one can use these output values."); + SetParameterDescription("epi.rectsizey","The application computes the " + "optimal rectified image size so that the whole left input image fits " + "into the rectified area. However, due to the scale and step parameter, " + "this size may not match the size of the deformation field output. In " + "this case, one can use these output values."); SetParameterRole("epi.rectsizey", Role_Output); AddParameter(ParameterType_Float,"epi.baseline","Mean baseline ratio"); - SetParameterDescription("epi.baseline","This parameter is the mean value, in pixels.meters^-1, of the baseline to sensor altitude ratio. It can be used to convert disparities to physical elevation, since a disparity of one pixel will correspond to an elevation offset of the invert of this value with respect to the mean elevation."); + SetParameterDescription("epi.baseline","This parameter is the mean value, " + "in pixels.meters^-1, of the baseline to sensor altitude ratio. It can be" + " used to convert disparities to physical elevation, since a disparity of" + " one pixel will correspond to an elevation offset of the invert of this" + " value with respect to the mean elevation."); SetParameterRole("epi.baseline", Role_Output); AddParameter(ParameterType_Group,"inverse","Write inverse fields"); - SetParameterDescription("inverse","This group of parameter allows generating the inverse fields as well"); + SetParameterDescription("inverse","This group of parameter allows " + "generating the inverse fields as well"); AddParameter(ParameterType_OutputImage, "inverse.outleft", "Left inverse deformation grid"); - SetParameterDescription("inverse.outleft","The output deformation grid to be used to resample the epipolar left image"); + SetParameterDescription("inverse.outleft","The deformation grid to resample" + " the left image from the epipolar geometry back into its original sensor" + " geometry."); MandatoryOff("inverse.outleft"); AddParameter(ParameterType_OutputImage, "inverse.outright", "Right inverse deformation grid"); - SetParameterDescription("inverse.outright","The output deformation grid to be used to resample the epipolar right image"); + SetParameterDescription("inverse.outright","The output deformation grid to" + " resample the right image from the epipolar geometry back into its " + "original sensor geometry."); MandatoryOff("inverse.outright"); AddParameter(ParameterType_Int, "inverse.ssrate", "Sub-sampling rate for inversion"); - SetParameterDescription("inverse.ssrate","Grid inversion is an heavy process that implies spline regression on control points. To avoid eating to much memory, this parameter allows one to first sub-sample the field to invert."); + SetParameterDescription("inverse.ssrate","Grid inversion is an heavy " + "process that implies spline regression on control points. To avoid " + "eating to much memory, this parameter allows one to first sub-sample " + "the field to invert."); SetDefaultParameterInt("inverse.ssrate",16); SetMinimumParameterIntValue("inverse.ssrate",1); @@ -229,7 +275,7 @@ private: { FloatImageType::PointType origin = GetParameterImage("io.inleft")->GetOrigin(); FloatImageType::SizeType size = GetParameterImage("io.inleft")->GetLargestPossibleRegion().GetSize(); - FloatImageType::SpacingType spacing = GetParameterImage("io.inleft")->GetSpacing(); + FloatImageType::SpacingType spacing = GetParameterImage("io.inleft")->GetSignedSpacing(); size[0]/=GetParameterInt("epi.elevation.avgdem.step"); size[1]/=GetParameterInt("epi.elevation.avgdem.step"); @@ -289,7 +335,7 @@ private: m_LeftInvertDisplacementFieldFilter->SetInput(m_LeftDisplacementFieldCaster->GetOutput()); FloatVectorImageType::PointType lorigin = GetParameterImage("io.inleft")->GetOrigin(); - FloatVectorImageType::SpacingType lspacing = GetParameterImage("io.inleft")->GetSpacing(); + FloatVectorImageType::SpacingType lspacing = GetParameterImage("io.inleft")->GetSignedSpacing(); FloatVectorImageType::SizeType lsize = GetParameterImage("io.inleft")->GetLargestPossibleRegion().GetSize(); if (lsize[0]*lsize[1]>256*256) @@ -331,7 +377,7 @@ private: m_RightInvertDisplacementFieldFilter->SetInput(m_RightDisplacementFieldCaster->GetOutput()); FloatVectorImageType::PointType rorigin = GetParameterImage("io.inright")->GetOrigin(); - FloatVectorImageType::SpacingType rspacing = GetParameterImage("io.inright")->GetSpacing(); + FloatVectorImageType::SpacingType rspacing = GetParameterImage("io.inright")->GetSignedSpacing(); FloatVectorImageType::SizeType rsize = GetParameterImage("io.inright")->GetLargestPossibleRegion().GetSize(); if (rsize[0]*rsize[1]>256*256) diff --git a/Modules/Applications/AppTest/app/CMakeLists.txt b/Modules/Applications/AppTest/app/CMakeLists.txt index 6de8cbe0340c03d057187e568ffe059b88c3e1a4..44d54be96b09f488538771a820f73ffb7048df87 100644 --- a/Modules/Applications/AppTest/app/CMakeLists.txt +++ b/Modules/Applications/AppTest/app/CMakeLists.txt @@ -18,10 +18,6 @@ # limitations under the License. # -set(OTBAppTest_LINK_LIBS - ${OTBApplicationEngine_LIBRARIES} -) - otb_create_application( NAME TestApplication SOURCES otbTestApplication.cxx diff --git a/Modules/Applications/AppTest/app/otbTestApplication.cxx b/Modules/Applications/AppTest/app/otbTestApplication.cxx index 662529c4ca81f854c1b9482fef5dcc133fdb7f8e..a2e9ee940da3b473f8e69fbd152eda675c66256d 100644 --- a/Modules/Applications/AppTest/app/otbTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbTestApplication.cxx @@ -20,6 +20,7 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" +#include "otbWrapperInputFilenameListParameter.h" namespace otb { @@ -46,7 +47,6 @@ private: SetName("TestApplication"); SetDescription("This application helps developers to test parameters types"); - SetDocName("Test"); SetDocLongDescription("The purpose of this application is to test parameters types."); SetDocLimitations("None"); @@ -76,7 +76,6 @@ private: AddParameter(ParameterType_Float, "choice.choice3.floatchoice3", "Float of choice3"); SetDefaultParameterFloat("choice.choice3.floatchoice3", 5.0); - AddParameter(ParameterType_Group, "ingroup", "Input Group"); MandatoryOff("ingroup"); AddParameter(ParameterType_Float, "ingroup.integer", "Integer of Group"); @@ -89,6 +88,15 @@ private: AddParameter(ParameterType_InputImageList, "il", "Input image list"); MandatoryOff("il"); + AddParameter( ParameterType_InputFilenameList, "fl", "Input filename list" ); + MandatoryOff( "fl" ); + + AddParameter( ParameterType_InputVectorDataList, "vdl", "Input vector-data list" ); + MandatoryOff( "vdl" ); + + AddParameter( ParameterType_StringList, "sl", "Input string list" ); + MandatoryOff( "sl" ); + AddParameter(ParameterType_ListView, "cl", "Output Image channels"); AddChoice("cl.choice1", "Choice1"); AddChoice("cl.choice2", "Choice2"); @@ -105,19 +113,62 @@ private: } void DoUpdateParameters() ITK_OVERRIDE + {} + + void DoExecute() ITK_OVERRIDE { - //std::cout << "TestApplication::DoUpdateParameters" << std::endl; + if( HasValue("il") && IsParameterEnabled("il") ) + { + FloatVectorImageListType * imgList = GetParameterImageList( "il" ); + SetParameterOutputImage( + "outgroup.outputimage", + imgList->GetNthElement( 0 ) + ); + } + else if (HasValue("ingroup.images.inputimage") && IsParameterEnabled("ingroup") ) + { + SetParameterOutputImage("outgroup.outputimage", + GetParameterImage("ingroup.images.inputimage")); + } + else + { + otbAppLogFATAL("Waiting at least one input image"); + } + + SetParameterComplexOutputImage( + "cout", + GetParameterComplexImage( "cin" ) + ); + + PrintStrings( "fl" ); } - void DoExecute() ITK_OVERRIDE +private: + void PrintStrings( const std::string & key ) const { - FloatVectorImageListType* imgList = GetParameterImageList("il"); - SetParameterOutputImage("outgroup.outputimage", imgList->GetNthElement(0)); - SetParameterComplexOutputImage("cout", GetParameterComplexImage("cin")); - //std::cout << "TestApplication::DoExecute" << std::endl; + if( !IsParameterEnabled(key) ) + return; + + const Parameter * p = GetParameterByKey( key ); + assert( p!=nullptr ); + const StringListInterface * sli = + dynamic_cast< const StringListInterface * >(p); + assert( sli!=nullptr ); + + StringListInterface::StringVector strings; + + sli->GetStrings( strings ); + + std::cout << "{" << std::endl; + { + for( auto s : strings ) + std::cout << "'" << s << "'" << std::endl; + } + std::cout << "}"<< std::endl; } }; -} -} -OTB_APPLICATION_EXPORT(otb::Wrapper::TestApplication) +} // end of namespace Wrapper +} // end of namespace otb + +OTB_APPLICATION_EXPORT( otb::Wrapper::TestApplication ) diff --git a/Modules/Applications/AppTextures/app/CMakeLists.txt b/Modules/Applications/AppTextures/app/CMakeLists.txt index 8f05f8dc9a7020bd6b205cced2605eba83429ebc..c25a67ff856c465a383439eb1068479c5d7a5d9d 100644 --- a/Modules/Applications/AppTextures/app/CMakeLists.txt +++ b/Modules/Applications/AppTextures/app/CMakeLists.txt @@ -18,14 +18,6 @@ # limitations under the License. # -set(OTBAppTextures_LINK_LIBS - ${OTBTextures_LIBRARIES} - ${OTBImageBase_LIBRARIES} - ${OTBObjectList_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBImageManipulation_LIBRARIES} -) - otb_create_application( NAME HaralickTextureExtraction SOURCES otbHaralickTextureExtraction.cxx diff --git a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx index cdde4cc990a6c8db672160ddb5be2ec955755722..43e6b0b0e1e69e44a6eac18428c299e2bbe5e316 100644 --- a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx +++ b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx @@ -70,14 +70,34 @@ private: void DoInit() ITK_OVERRIDE { SetName("HaralickTextureExtraction"); -SetDescription("Computes textures on every pixel of the input image selected channel"); +SetDescription("Computes Haralick textural features on the selected channel of the input image"); // Documentation SetDocName("Haralick Texture Extraction"); -SetDocLongDescription("This application computes Haralick, advanced and higher order textures on a mono band image"); -SetDocLimitations("None"); +SetDocLongDescription("This application computes three sets of Haralick features [1][2].\n" + " * simple: a set of 8 local Haralick features: Energy (texture uniformity) , " + "Entropy (measure of randomness of intensity image), Correlation (how " + "correlated a pixel is to its neighborhood), Inverse Difference Moment (measures " + "the texture homogeneity), Inertia (intensity contrast between a pixel and its " + "neighborhood), Cluster Shade, Cluster Prominence, Haralick Correlation;\n" + " * advanced: a set of 10 advanced Haralick features : Mean, Variance (measures the " + "texture heterogeneity), Dissimilarity, Sum Average, Sum Variance, Sum Entropy, " + "Difference of Entropies, Difference of Variances, IC1, IC2;\n" + " * higher: a set of 11 higher Haralick features : Short Run Emphasis (measures the " + "texture sharpness), Long Run Emphasis (measures the texture roughness), Grey-Level " + "Nonuniformity, Run Length Nonuniformity, Run Percentage (measures the texture " + "sharpness homogeneity), Low Grey-Level Run Emphasis, High Grey-Level Run Emphasis, " + "Short Run Low Grey-Level Emphasis, Short Run High Grey-Level Emphasis, Long Run Low " + "Grey-Level Emphasis and Long Run High Grey-Level Emphasis."); +SetDocLimitations("The computation of the features is based on a Gray Level Co-occurrence " + "matrix (GLCM) from the quantized input image. Consequently the quantization " + "parameters (min, max, nbbin) must be appropriate to the range of the pixel values."); SetDocAuthors("OTB-Team"); -SetDocSeeAlso("otbScalarImageToTexturesFilter, otbScalarImageToAdvancedTexturesFilter and otbScalarImageToHigherOrderTexturesFilter classes"); +SetDocSeeAlso("[1] HARALICK, Robert M., SHANMUGAM, Karthikeyan, et al. " + "Textural features for image classification. IEEE Transactions on systems, " + "man, and cybernetics, 1973, no 6, p. 610-621.\n" + "[2] otbScalarImageToTexturesFilter, otbScalarImageToAdvancedTexturesFilter and " + "otbScalarImageToHigherOrderTexturesFilter classes"); AddDocTag(Tags::FeatureExtraction); AddDocTag("Textures"); @@ -100,7 +120,8 @@ MandatoryOff("step"); AddRAMParameter(); AddParameter(ParameterType_Group, "parameters", "Texture feature parameters"); -SetParameterDescription("parameters","This group of parameters allows one to define texture parameters."); +SetParameterDescription("parameters","This group of parameters allows one to define " + "texture parameters."); AddParameter(ParameterType_Int,"parameters.xrad","X Radius"); SetParameterDescription("parameters.xrad", "X Radius"); @@ -134,20 +155,25 @@ AddParameter(ParameterType_Choice, "texture", "Texture Set Selection"); SetParameterDescription("texture", "Choice of The Texture Set"); AddChoice("texture.simple", "Simple Haralick Texture Features"); -SetParameterDescription("texture.simple","This group of parameters defines the 8 local Haralick texture feature output image.\ - The image channels are: Energy, Entropy, Correlation, Inverse Difference Moment,\ - Inertia, Cluster Shade, Cluster Prominence and Haralick Correlation"); +SetParameterDescription("texture.simple", "This group of parameters defines " + "the 8 local Haralick texture feature output image. The image channels are: " + "Energy, Entropy, Correlation, Inverse Difference Moment, Inertia, Cluster " + "Shade, Cluster Prominence and Haralick Correlation"); AddChoice("texture.advanced", "Advanced Texture Features"); -SetParameterDescription("texture.advanced","This group of parameters defines the 10 advanced texture feature output image.\ - The image channels are: Mean, Variance, Dissimilarity, Sum Average, Sum Variance,\ - Sum Entropy, Difference of Entropies, Difference of Variances, IC1 and IC2"); +SetParameterDescription("texture.advanced", "This group of parameters defines " + "the 10 advanced texture feature output image. The image channels are: Mean, " + "Variance, Dissimilarity, Sum Average, Sum Variance, Sum Entropy, Difference " + "of Entropies, Difference of Variances, IC1 and IC2"); AddChoice("texture.higher", "Higher Order Texture Features"); -SetParameterDescription("texture.higher","This group of parameters defines the 11 higher order texture feature output image.\ - The image channels are: Short Run Emphasis, Long Run Emphasis, Grey-Level Nonuniformity, Run Length Nonuniformity, Run Percentage, \ - Low Grey-Level Run Emphasis, High Grey-Level Run Emphasis, Short Run Low Grey-Level Emphasis, Short Run High Grey-Level Emphasis, \ - Long Run Low Grey-Level Emphasis and Long Run High Grey-Level Emphasis"); +SetParameterDescription("texture.higher", "This group of parameters defines the " + "11 higher order texture feature output image. The image channels are: " + "Short Run Emphasis, Long Run Emphasis, Grey-Level Nonuniformity, " + "Run Length Nonuniformity, Run Percentage, Low Grey-Level Run Emphasis, " + "High Grey-Level Run Emphasis, Short Run Low Grey-Level Emphasis, " + "Short Run High Grey-Level Emphasis, Long Run Low Grey-Level Emphasis and " + "Long Run High Grey-Level Emphasis"); AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image containing the selected texture features."); diff --git a/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx index 14fb6df2b3ee8499943cc14dbb27a34a6bcd5c51..0475acab406aed600a156d82cc568c73bf0baaa3 100644 --- a/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx +++ b/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx @@ -61,14 +61,24 @@ private: void DoInit() ITK_OVERRIDE { SetName("SFSTextureExtraction"); -SetDescription("Computes Structural Feature Set textures on every pixel of the input image selected channel"); +SetDescription("Computes Structural Feature Set textures on every pixel of the " + "input image selected channel"); // Documentation SetDocName("SFS Texture Extraction"); -SetDocLongDescription("This application computes SFS textures on a mono band image"); +SetDocLongDescription("Structural Feature Set [1] are based on the histograms of " + "the pixels in multiple directions of the image. The SFSTextureExtraction application " + "computes the 6 following features: SFS'Length, SFS'Width, SFS'PSI, SFS'W-Mean, " + "SFS'Ratio and SFS'SD (Standard Deviation). The texture indices are computed from " + "the neighborhood of each pixel. It is possible to change the length of the calculation " + "line (spatial threshold), as well as the maximum difference between a pixel of the line " + "and the pixel at the center of the neighborhood (spectral threshold) [2]."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); -SetDocSeeAlso("otbSFSTexturesImageFilter class"); +SetDocSeeAlso("[1] HUANG, Xin, ZHANG, Liangpei, et LI, Pingxiang. Classification and extraction " + "of spatial features in urban areas using high-resolution multispectral imagery. " + "IEEE Geoscience and Remote Sensing Letters, 2007, vol. 4, no 2, p. 260-264.\n" + "[2] otbSFSTexturesImageFilter class"); AddDocTag(Tags::FeatureExtraction); AddDocTag("Textures"); @@ -84,9 +94,9 @@ SetMinimumParameterIntValue("channel", 1); AddRAMParameter(); AddParameter(ParameterType_Group, "parameters", "Texture feature parameters"); -SetParameterDescription("parameters","This group of parameters allows one to define SFS texture parameters.\ - The available texture features are SFS'Length, SFS'Width, SFS'PSI, SFS'W-Mean, SFS'Ratio and SFS'SD.\ - They are provided in this exact order in the output image."); +SetParameterDescription("parameters","This group of parameters allows one to define SFS texture " + "parameters. The available texture features are SFS'Length, SFS'Width, SFS'PSI, SFS'W-Mean, " + "SFS'Ratio and SFS'SD. They are provided in this exact order in the output image."); AddParameter(ParameterType_Float,"parameters.spethre","Spectral Threshold"); SetParameterDescription("parameters.spethre", "Spectral Threshold"); diff --git a/Modules/Applications/AppVectorDataTranslation/app/CMakeLists.txt b/Modules/Applications/AppVectorDataTranslation/app/CMakeLists.txt index 6f67792bb763d50dc6ae805d9268e0bc47d0e948..23f81580cb0b8721aa6e16927c58eeb7e7956b6a 100644 --- a/Modules/Applications/AppVectorDataTranslation/app/CMakeLists.txt +++ b/Modules/Applications/AppVectorDataTranslation/app/CMakeLists.txt @@ -18,12 +18,6 @@ # limitations under the License. # -set(OTBAppVectorDataTranslation_LINK_LIBS - ${OTBConversion_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} - ${OTBTransform_LIBRARIES} -) - otb_create_application( NAME Rasterization SOURCES otbRasterization.cxx diff --git a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx index 7e35f67165e2ac5108cc54e1dcaf20f2a21b12b8..748d8f27be36f75205398bcbf7114b4b66343856 100644 --- a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx +++ b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx @@ -233,7 +233,7 @@ private: origin = referenceImage->GetOrigin(); - spacing = referenceImage->GetSpacing(); + spacing = referenceImage->GetSignedSpacing(); } else if (HasValue("spx") && HasValue("spy")) { diff --git a/Modules/Applications/AppVectorUtils/app/CMakeLists.txt b/Modules/Applications/AppVectorUtils/app/CMakeLists.txt index 4782c35a9bbc4b559b51a0838a0c5f3a01bb7a5e..b3a40811ab74c12a9de9578926f12f26d7d74bb1 100644 --- a/Modules/Applications/AppVectorUtils/app/CMakeLists.txt +++ b/Modules/Applications/AppVectorUtils/app/CMakeLists.txt @@ -18,15 +18,6 @@ # limitations under the License. # -set(OTBAppVectorUtils_LINK_LIBS - ${OTBVectorDataBase_LIBRARIES} - ${OTBProjection_LIBRARIES} - ${OTBVectorDataManipulation_LIBRARIES} - ${OTBCarto_LIBRARIES} - ${OTBCommon_LIBRARIES} - ${OTBApplicationEngine_LIBRARIES} -) - otb_create_application( NAME VectorDataTransform SOURCES otbVectorDataTransform.cxx diff --git a/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx b/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx index 0710b1bf50ff0772fa6ce96ec4eda04879edb969..92b972eafc02587d0636bdfaf3771625b8824beb 100644 --- a/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx @@ -50,22 +50,28 @@ private: void DoInit() ITK_OVERRIDE { SetName("ConcatenateVectorData"); - SetDescription("Concatenate VectorDatas"); - - SetDocName("Concatenate"); - SetDocLongDescription("This application concatenates a list of VectorData to produce a unique VectorData as output." - "Note that the VectorDatas must be of the same type (Storing polygons only, lines only, or points only)"); - SetDocLimitations("None"); + SetDescription("Concatenate vector data files"); + + SetDocName("Concatenate Vector Data"); + SetDocLongDescription("This application concatenates a list of vector data " + "files to produce a unique vector data output file.\n\n" + "This application will gather all the geometries from the input files and" + " write them into an output vector data file. Any format supported by OGR" + " can be used. Ideally, all inputs should have the same set of fields and" + " the same spatial reference system."); + SetDocLimitations("The vector data must be contain the same type of " + "geometries (point / lines / polygons). The fields present in the output " + "file are the ones from the first input."); SetDocAuthors("OTB-Team"); SetDocSeeAlso(" "); AddDocTag(Tags::Vector); - AddParameter(ParameterType_InputVectorDataList, "vd", "Input VectorDatas to concatenate"); - SetParameterDescription("vd", "VectorData files to be concatenated in an unique VectorData"); + AddParameter(ParameterType_InputVectorDataList, "vd", "Input vector files"); + SetParameterDescription("vd", "Vector data files to be concatenated."); - AddParameter(ParameterType_OutputVectorData, "out", "Concatenated VectorData"); - SetParameterDescription("out", "Output conctenated VectorData"); + AddParameter(ParameterType_OutputVectorData, "out", "Concatenated output"); + SetParameterDescription("out", "Output conctenated vector data file."); // Doc example parameter settings SetDocExampleParameterValue("vd", "ToulousePoints-examples.shp ToulouseRoad-examples.shp"); diff --git a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx index 0cc82f51d11a29ae4f492af0f1c7dbe1f3541bc8..d55626ed0bb0f79d3696a4a2940c59a870038217 100644 --- a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx @@ -53,40 +53,55 @@ private: void DoInit() ITK_OVERRIDE { SetName("OSMDownloader"); - SetDescription("Generate a vector data from OSM on the input image extend"); + SetDescription("Download vector data from OSM and store it to file"); // Documentation - SetDocName("Open Street Map layers importations applications"); - SetDocLongDescription("Generate a vector data from Open Street Map data. A DEM could be use. By default, the entire layer is downloaded, an image can be use as support for the OSM data. The application can provide also available classes in layers . This application required an Internet access. Information about the OSM project : http://www.openstreetmap.fr/"); - SetDocLimitations("None"); + SetDocName("Open Street Map layers import"); + SetDocLongDescription("The application connects to Open Street Map server" + ", downloads the data corresponding to the spatial extent of the support" + " image, and filters the geometries based on OSM tags to produce a vector" + " data file.\n\n" + "This application can be used to download reference data to perform the " + "training of a machine learning model (see for instance [1]).\n\n" + "By default, the entire layer is downloaded. The application has a " + "special mode to provide the list of available classes in the layers. " + "The downloaded features are filtered by giving an OSM tag 'key'. In " + "addition, the user can also choose what 'value' this key should have. " + "More information about the OSM project at [2]."); + SetDocLimitations("This application requires an Internet access."); SetDocAuthors("OTB-Team"); - SetDocSeeAlso("Conversion"); + SetDocSeeAlso("[1] TrainImagesClassifier \n" + "[2] http://www.openstreetmap.fr/"); AddDocTag("Miscellaneous"); AddDocTag(Tags::Meta); AddDocTag(Tags::Vector); - AddParameter(ParameterType_OutputVectorData, "out", "Output vector data"); - SetParameterDescription("out", "Generated output vector data path"); + AddParameter(ParameterType_OutputVectorData, "out", "Output vector data"); + SetParameterDescription("out", "Vector data file to store downloaded features"); - AddParameter(ParameterType_InputImage, "support", "Support image"); - SetParameterDescription("support", "Image used as support to estimate the models"); + AddParameter(ParameterType_InputImage, "support", "Support image"); + SetParameterDescription("support", "Image used to derive the spatial extent" + " to be requested from OSM server (the bounding box of the extent is " + "used). Be aware that a request with a large extent may be rejected by " + "the server."); AddParameter(ParameterType_String, "key", "OSM tag key"); - SetParameterDescription("key", "OSM tag key to extract (highway, building...)"); + SetParameterDescription("key", "OSM tag key to extract (highway, building" + "...). It defines a category to select features."); MandatoryOff("key"); AddParameter(ParameterType_String, "value", "OSM tag value"); - SetParameterDescription("value", "OSM tag value to extract (motorway, footway...)"); + SetParameterDescription("value", "OSM tag value to extract (motorway, " + "footway...). It defines the type of feature to select inside a category."); MandatoryOff("value"); // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); - AddParameter(ParameterType_Empty, "printclasses", "option to display available key/value classes"); - std::ostringstream oss; - oss << "Print the key/value classes available for the bounding box of the input image "<<std::endl; - oss << "\t\t\t\t ** If not used : Note that the options OSMKey (-key) and Output (-out) become mandatory"; - SetParameterDescription("printclasses", oss.str().c_str()); + AddParameter(ParameterType_Empty, "printclasses", "Displays available key/value classes"); + SetParameterDescription("printclasses","Print the key/value classes " + "available for the selected support image. If enabled, the OSM tag Key " + "(-key) and the output (-out) become optional" ); MandatoryOff("printclasses"); // Doc example parameter settings diff --git a/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx b/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx index 8dc890b605564e56f7dc813f114fed0e97a53823..566ca5a34d305d7731a3df7567fc0d4f3d95ee9a 100644 --- a/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx @@ -60,46 +60,64 @@ private: SetDescription("Apply a transform to each vertex of the input VectorData"); SetDocName("Vector Data Transformation"); - SetDocLongDescription("This application performs a transformation of an input vector data transforming each vertex in the vector data. The applied transformation manages translation, rotation and scale, and can be centered or not."); + SetDocLongDescription("This application iterates over each vertex in the " + "input vector data file and performs a transformation on this vertex.\n\n" + "It is the equivalent of [1] that transforms images. For instance, if you" + " extract the envelope of an image with [2], and you transform this image" + " with [1], you may want to use this application to operate the same " + "transform on the envelope.\n\n" + "The applied transformation is a 2D similarity. It manages translation, " + "rotation, scaling, and can be centered or not. Note that the support " + "image is used to define the reference coordinate system in which the " + "transform is applied. For instance the input vector data can have WGS84" + " coordinates, the support image is in UTM, so a translation of 1 pixel " + "along X corresponds to the X pixel size of the input image along the " + "X axis of the UTM coordinates frame. This image can also be in sensor " + "geometry."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); - SetDocSeeAlso(" "); + SetDocSeeAlso("[1] RigidTransformResample\n" + "[2] ImageEnvelope"); AddDocTag(Tags::Vector); AddParameter(ParameterType_InputVectorData, "vd", "Input Vector data"); - SetParameterDescription("vd", "Input vector data to transform"); + SetParameterDescription("vd", "Input vector data file to transform"); AddParameter(ParameterType_OutputVectorData,"out","Output Vector data"); - SetParameterDescription("out", "Output transformed vector data"); + SetParameterDescription("out", "Output vector data with "); AddParameter(ParameterType_InputImage, "in", "Support image"); - SetParameterDescription("in","Image needed as a support to the vector data"); + SetParameterDescription("in","Image defining the reference coordinate " + "system in which the tranform is applied. Both projected and sensor " + "images are supported."); // Transform Group AddParameter(ParameterType_Group, "transform", "Transform parameters"); SetParameterDescription("transform", "Group of parameters to define the transform"); - AddParameter(ParameterType_Float, "transform.tx", "Translation X"); + AddParameter(ParameterType_Float, "transform.tx", "X Translation"); SetParameterDescription("transform.tx","Translation in the X direction (in pixels)"); - AddParameter(ParameterType_Float, "transform.ty", "Translation Y"); + AddParameter(ParameterType_Float, "transform.ty", "Y Translation"); SetParameterDescription("transform.ty","Translation in the Y direction (in pixels)"); SetDefaultParameterFloat("transform.tx", 0.); SetDefaultParameterFloat("transform.ty", 0.); AddParameter(ParameterType_Float, "transform.ro", "Rotation Angle"); - SetParameterDescription("transform.ro","Angle of the rotation to apply in degrees"); + SetParameterDescription("transform.ro","Angle of the rotation (in degrees)"); SetDefaultParameterFloat("transform.ro", 0.); AddParameter(ParameterType_Float, "transform.centerx", "Center X"); - SetParameterDescription("transform.centerx","X coordinate of the rotation center (in physical units)"); + SetParameterDescription("transform.centerx","X coordinate of the rotation " + "and scaling center (in physical units)"); AddParameter(ParameterType_Float, "transform.centery", "Center Y"); - SetParameterDescription("transform.centery","Y coordinate of the rotation center (in physical units)"); + SetParameterDescription("transform.centery","Y coordinate of the rotation " + "and scaling center (in physical units)"); SetDefaultParameterFloat("transform.centerx", 0.); SetDefaultParameterFloat("transform.centery", 0.); AddParameter(ParameterType_Float, "transform.scale", "Scale"); - SetParameterDescription("transform.scale","The scale to apply"); + SetParameterDescription("transform.scale","The scale coefficient to apply"); SetDefaultParameterFloat("transform.scale", 1.); // Doc example parameter settings @@ -140,8 +158,8 @@ private: parameters[1] = CONST_PI * GetParameterFloat("transform.ro")/180.; parameters[2] = GetParameterFloat("transform.centerx"); parameters[3] = GetParameterFloat("transform.centery"); - parameters[4] = inImage->GetSpacing()[0] * GetParameterFloat("transform.tx"); - parameters[5] = vcl_abs(inImage->GetSpacing()[1]) * GetParameterFloat("transform.ty"); + parameters[4] = inImage->GetSignedSpacing()[0] * GetParameterFloat("transform.tx"); + parameters[5] = vcl_abs(inImage->GetSignedSpacing()[1]) * GetParameterFloat("transform.ty"); // Set the parameters to the transform m_Transform->SetParameters(parameters); diff --git a/Modules/Core/Common/include/otbImportImageFilter.h b/Modules/Core/Common/include/otbImportImageFilter.h index 7c322b6ab1baffc2063b63b4c4858994bfc72825..9f21873c3c5c8a57fe4f5132577a3737f551c519 100644 --- a/Modules/Core/Common/include/otbImportImageFilter.h +++ b/Modules/Core/Common/include/otbImportImageFilter.h @@ -113,7 +113,7 @@ public: } /** Set the spacing (size of a pixel) of the image. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ itkSetVectorMacro(Spacing, const double, OutputImageType::ImageDimension); itkSetVectorMacro(Spacing, const float, OutputImageType::ImageDimension); diff --git a/Modules/Core/Common/include/otbImportImageFilter.txx b/Modules/Core/Common/include/otbImportImageFilter.txx index a28fc33d6ddce04617c5d7131b5d505d9f818de3..204899ac41aefa6bc1fd99c169d1aeb09d88b475 100644 --- a/Modules/Core/Common/include/otbImportImageFilter.txx +++ b/Modules/Core/Common/include/otbImportImageFilter.txx @@ -169,7 +169,7 @@ ImportImageFilter<TOutputImage> // we need to compute the output spacing, the output origin, the // output image size, and the output image start index - outputPtr->SetSpacing(m_Spacing); + outputPtr->SetSignedSpacing(m_Spacing); outputPtr->SetOrigin(m_Origin); outputPtr->SetDirection(m_Direction); outputPtr->SetLargestPossibleRegion(m_Region); diff --git a/Modules/Core/Common/include/otbImportVectorImageFilter.h b/Modules/Core/Common/include/otbImportVectorImageFilter.h index 899651a7e019d9bd2de7806d4dbc9bb079e74bf5..c7db035c2581d9d555eab57be384e855b71a48c6 100644 --- a/Modules/Core/Common/include/otbImportVectorImageFilter.h +++ b/Modules/Core/Common/include/otbImportVectorImageFilter.h @@ -114,7 +114,7 @@ public: } /** Set the spacing (size of a pixel) of the image. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ itkSetVectorMacro(Spacing, const double, OutputImageType::ImageDimension); itkSetVectorMacro(Spacing, const float, OutputImageType::ImageDimension); diff --git a/Modules/Core/Common/include/otbImportVectorImageFilter.txx b/Modules/Core/Common/include/otbImportVectorImageFilter.txx index 49c95abc232b6889af1d934b29c07050546fd848..1db74621750ddc78adb71512d17a6bc27a63437c 100644 --- a/Modules/Core/Common/include/otbImportVectorImageFilter.txx +++ b/Modules/Core/Common/include/otbImportVectorImageFilter.txx @@ -170,7 +170,7 @@ ImportVectorImageFilter<TOutputImage> // we need to compute the output spacing, the output origin, the // output image size, and the output image start index - outputPtr->SetSpacing(m_Spacing); + outputPtr->SetSignedSpacing(m_Spacing); outputPtr->SetOrigin(m_Origin); outputPtr->SetDirection(m_Direction); outputPtr->SetLargestPossibleRegion(m_Region); diff --git a/Modules/Core/ImageBase/include/otbExtractROIBase.txx b/Modules/Core/ImageBase/include/otbExtractROIBase.txx index b7c6e0e2a8add6e95b77f025053555c25c1a3f37..78f546387ffad9fd276030426eaf6abb1529480d 100644 --- a/Modules/Core/ImageBase/include/otbExtractROIBase.txx +++ b/Modules/Core/ImageBase/include/otbExtractROIBase.txx @@ -247,7 +247,7 @@ ExtractROIBase<TInputImage, TOutputImage> // This logic needs to be augmented with logic that select which // dimensions to copy const typename InputImageType::SpacingType& - inputSpacing = inputPtr->GetSpacing(); + inputSpacing = inputPtr->GetSignedSpacing(); const typename InputImageType::DirectionType& inputDirection = inputPtr->GetDirection(); const typename InputImageType::PointType& @@ -304,7 +304,7 @@ ExtractROIBase<TInputImage, TOutputImage> } // set the spacing and origin - outputPtr->SetSpacing(outputSpacing); + outputPtr->SetSignedSpacing(outputSpacing); outputPtr->SetDirection(outputDirection); outputPtr->SetOrigin(outputOrigin); diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index c13d9b9c72021ba2dbcab2ea2300db2d2d983952..3bec599c720a7fbbfc72ecae5d44a537517a4826 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -32,6 +32,49 @@ #include "otbImageMetadataInterfaceBase.h" +namespace otb +{ +namespace internal +{ + template < class ImageType > + typename ImageType::SpacingType GetSignedSpacing( const ImageType * input) + { + typename ImageType::SpacingType spacing = input->GetSpacing(); + typename ImageType::DirectionType direction = input->GetDirection(); + for ( unsigned int i = 0 ; i < ImageType::ImageDimension ; i++ ) + { + spacing[i] *= direction[i][i] ; + } + return spacing; + } + + template < class InputImage , typename SpacingType > + void SetSignedSpacing( InputImage input , SpacingType spacing ) + { + // TODO check for spacing size ==> error + typename InputImage::DirectionType direction = input->GetDirection(); + for ( unsigned int i = 0 ; i < InputImage::VImageDimension ; i++ ) + { + // TODO check if spacing[i] = 0 ==> error + if ( spacing[ i ] < 0 ) + { + if ( direction[i][i] > 0 ) + { + for ( unsigned int j = 0 ; j < InputImage::VImageDimension ; j++ ) + { + direction[j][i] = - direction[j][i]; + } + } + spacing[i] = -spacing[i]; + } + } + input->SetDirection( direction ); + input->SetSpacing( spacing ); + } +} +} + + namespace otb { /** \class Image @@ -174,6 +217,21 @@ public: /** Get the six coefficients of affine geoTtransform. */ virtual VectorType GetGeoTransform(void) const; + /** Get signed spacing */ + SpacingType GetSignedSpacing() const; + + // SpacingType GetSpacing() const + // { + // PixelType a; + // a.toto(); + // SpacingType t = this->GetSignedSpacing(); + // return t ; + // }; + + /** Set signed spacing */ + virtual void SetSignedSpacing( SpacingType spacing ); + virtual void SetSignedSpacing( double spacing[ VImageDimension ] ); + /** Get image corners. */ virtual VectorType GetUpperLeftCorner(void) const; virtual VectorType GetUpperRightCorner(void) const; diff --git a/Modules/Core/ImageBase/include/otbImage.txx b/Modules/Core/ImageBase/include/otbImage.txx index 09e3e054e6009853ae71a38584ed2ff16298ddb3..096a7259605c8dc9adabe7c9c058fdd27490332d 100644 --- a/Modules/Core/ImageBase/include/otbImage.txx +++ b/Modules/Core/ImageBase/include/otbImage.txx @@ -148,6 +148,51 @@ Image<TPixel, VImageDimension>::GetLowerRightCorner(void) const return (this->GetMetaDataInterface()->GetLowerRightCorner()); } +template <class TPixel, unsigned int VImageDimension> +typename Image<TPixel, VImageDimension>::SpacingType +Image<TPixel, VImageDimension>::GetSignedSpacing() const +{ + auto spacing = this->GetSpacing(); + for ( unsigned int i = 0; i < Image::ImageDimension; ++i ) + { + if (this->m_Direction[i][i] < 0 ) + spacing[i] = - spacing[i]; + } + return spacing; +} + +template <class TPixel, unsigned int VImageDimension> +void Image<TPixel, VImageDimension> +::SetSignedSpacing( SpacingType spacing) +{ + + for ( unsigned int i = 0; i < VImageDimension; i++ ) + { + if ( spacing[i] < 0.0 ) + { + if ( this->m_Direction[i][i] > 0 ) + { + for ( unsigned j = 0; j < VImageDimension; ++j ) + { + this->m_Direction[j][i] = - this->m_Direction[j][i]; + } + } + spacing[i] = - spacing[i]; + } + } + this->SetSpacing(spacing); + this->ComputeIndexToPhysicalPointMatrices(); + this->Modified(); +} + +template <class TPixel, unsigned int VImageDimension> +void Image<TPixel, VImageDimension> +::SetSignedSpacing( double spacing[ VImageDimension ]) +{ + SpacingType s(spacing); + this->SetSignedSpacing(s); +} + template <class TPixel, unsigned int VImageDimension> typename Image<TPixel, VImageDimension>::ImageKeywordlistType Image<TPixel, VImageDimension>::GetImageKeywordlist(void) diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h index d867f4875750c1138c882602145dffc6a4261326..2fa39e599a1811ef98b7930931c37a5031e19cd9 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.h +++ b/Modules/Core/ImageBase/include/otbVectorImage.h @@ -144,6 +144,13 @@ public: /** Get the six coefficients of affine geoTtransform. */ virtual VectorType GetGeoTransform(void) const; + /** Get signed spacing */ + SpacingType GetSignedSpacing() const; + + /** Set signed spacing */ + virtual void SetSignedSpacing( SpacingType spacing ); + virtual void SetSignedSpacing( double spacing[ VImageDimension ] ); + /** Get image corners. */ virtual VectorType GetUpperLeftCorner(void) const; virtual VectorType GetUpperRightCorner(void) const; diff --git a/Modules/Core/ImageBase/include/otbVectorImage.txx b/Modules/Core/ImageBase/include/otbVectorImage.txx index ef89e660d6b0ff3f079c4d08d2d1de6c03e2bcf0..f6123af5845fc49c321a84febdd28be828ee21bc 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.txx +++ b/Modules/Core/ImageBase/include/otbVectorImage.txx @@ -150,6 +150,51 @@ VectorImage<TPixel, VImageDimension>::GetLowerRightCorner(void) const return (this->GetMetaDataInterface()->GetLowerRightCorner()); } +template <class TPixel, unsigned int VImageDimension> +typename VectorImage<TPixel, VImageDimension>::SpacingType +VectorImage<TPixel, VImageDimension>::GetSignedSpacing() const +{ + auto spacing = this->GetSpacing(); + for ( unsigned int i = 0; i < VImageDimension; ++i ) + { + if (this->m_Direction[i][i] < 0 ) + spacing[i] = - spacing[i]; + } + return spacing; +} + +template <class TPixel, unsigned int VImageDimension> +void VectorImage<TPixel, VImageDimension> +::SetSignedSpacing( SpacingType spacing) +{ + + for ( unsigned int i = 0; i < VImageDimension; i++ ) + { + if ( spacing[i] < 0.0 ) + { + if ( this->m_Direction[i][i] > 0 ) + { + for ( unsigned j = 0; j < VImageDimension; ++j ) + { + this->m_Direction[j][i] = - this->m_Direction[j][i]; + } + } + spacing[i] = - spacing[i]; + } + } + this->SetSpacing(spacing); + this->ComputeIndexToPhysicalPointMatrices(); + this->Modified(); +} + +template <class TPixel, unsigned int VImageDimension> +void VectorImage<TPixel, VImageDimension> +::SetSignedSpacing( double spacing[ VImageDimension ]) +{ + SpacingType s(spacing); + this->SetSignedSpacing(s); +} + template <class TPixel, unsigned int VImageDimension> typename VectorImage<TPixel, VImageDimension>::ImageKeywordlistType VectorImage<TPixel, VImageDimension>::GetImageKeywordlist(void) diff --git a/Modules/Core/ImageBase/test/otbImageTest.cxx b/Modules/Core/ImageBase/test/otbImageTest.cxx index ab3036a1290d176ec5d3461d33e7f7de3bfbea8f..f95afb8448e924d2956414d2dc9f04148fdad8c6 100644 --- a/Modules/Core/ImageBase/test/otbImageTest.cxx +++ b/Modules/Core/ImageBase/test/otbImageTest.cxx @@ -61,7 +61,7 @@ int otbImageTest(int itkNotUsed(argc), char* argv[]) std::cout << "---------------------" << std::endl; file << "------ IMAGE --------" << std::endl; - file << "Spacing " << image->GetSpacing() << std::endl; + file << "Spacing " << image->GetSignedSpacing() << std::endl; file << "Origin " << image->GetOrigin() << std::endl; file << "Projection REF " << image->GetProjectionRef() << std::endl; file << "GCP Projection " << image->GetGCPProjection() << std::endl; diff --git a/Modules/Core/ImageBase/test/otbVectorImageTest.cxx b/Modules/Core/ImageBase/test/otbVectorImageTest.cxx index 00d7f377cba40e2e9e03fc196a7f7b7557c56532..5fa76642d72f70cacea2814608ccd216df77c314 100644 --- a/Modules/Core/ImageBase/test/otbVectorImageTest.cxx +++ b/Modules/Core/ImageBase/test/otbVectorImageTest.cxx @@ -63,7 +63,7 @@ int otbVectorImageLegacyTest(int argc, char* argv[]) std::cout << "---------------------" << std::endl; file << "------ IMAGE --------" << std::endl; - file << "Spacing " << image->GetSpacing() << std::endl; + file << "Spacing " << image->GetSignedSpacing() << std::endl; file << "Origin " << image->GetOrigin() << std::endl; file << "Projection REF " << image->GetProjectionRef() << std::endl; file << "GCP Projection " << image->GetGCPProjection() << std::endl; diff --git a/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.txx b/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.txx index b6a8c96c046809d0dd6ec6eb1b1380f01cb90ebc..28b393767d0858adddb8bc86341e59b289444a82 100644 --- a/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.txx +++ b/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.txx @@ -245,7 +245,7 @@ BSplineInterpolateImageFunction<TImageType, TCoordRep, TCoefficientType> } derivativeValue[n] += m_Coefficients->GetPixel(coefficientIndex) * tempValue; } - derivativeValue[n] /= this->GetInputImage()->GetSpacing()[n]; // take spacing into account + derivativeValue[n] /= this->GetInputImage()->GetSignedSpacing()[n]; // take spacing into account } return (derivativeValue); diff --git a/Modules/Core/Interpolation/test/otbProlateValidationTest.cxx b/Modules/Core/Interpolation/test/otbProlateValidationTest.cxx index 2964cde1c7a7814de146eb38e5a365115c81c88e..b45a5d60a35c4a29a61da747f22361b54b66f86b 100644 --- a/Modules/Core/Interpolation/test/otbProlateValidationTest.cxx +++ b/Modules/Core/Interpolation/test/otbProlateValidationTest.cxx @@ -54,7 +54,7 @@ int otbProlateValidationTest(int itkNotUsed(argc), char * argv[]) reader->UpdateOutputInformation(); ImageType::PointType origin = reader->GetOutput()->GetOrigin(); - ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); + ImageType::SpacingType spacing = reader->GetOutput()->GetSignedSpacing(); ImageType::SpacingType newSpacing; newSpacing[0] = spacing[0] * factor; newSpacing[1] = spacing[1] * factor; diff --git a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.txx b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.txx index a2cb2079707c34a0d4b70cc553e6823945a8ef97..6393feda9648887753000a6a38cefc85d8d1428c 100644 --- a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.txx +++ b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.txx @@ -205,13 +205,13 @@ ShapeAttributesLabelObjectFunctor<TLabelObject, TLabelImage> double sizePerPixel = 1; for (DimensionType i = 0; i < LabelObjectType::ImageDimension; ++i) { - sizePerPixel *= vcl_abs(m_LabelImage->GetSpacing()[i]); + sizePerPixel *= vcl_abs(m_LabelImage->GetSignedSpacing()[i]); } typename std::vector<double> sizePerPixelPerDimension; for (DimensionType i = 0; i < LabelObjectType::ImageDimension; ++i) { - sizePerPixelPerDimension.push_back(sizePerPixel / vcl_abs(m_LabelImage->GetSpacing()[i])); + sizePerPixelPerDimension.push_back(sizePerPixel / vcl_abs(m_LabelImage->GetSignedSpacing()[i])); } // compute the max the index on the border of the image @@ -367,7 +367,7 @@ ShapeAttributesLabelObjectFunctor<TLabelObject, TLabelImage> // get the physical position and the spacing - they are used several times later typename TLabelImage::PointType physicalPosition; m_LabelImage->TransformIndexToPhysicalPoint(idx, physicalPosition); - const typename TLabelImage::SpacingType& spacing = m_LabelImage->GetSpacing(); + const typename TLabelImage::SpacingType& spacing = m_LabelImage->GetSignedSpacing(); // the sum of x positions, also reused several times double sumX = length * (physicalPosition[0] + (spacing[0] * (length - 1)) / 2.0); // the real job - the sum of square of x positions @@ -406,7 +406,7 @@ ShapeAttributesLabelObjectFunctor<TLabelObject, TLabelImage> { centroid[i] /= size; regionSize[i] = maxs[i] - mins[i] + 1; - double s = regionSize[i] * vcl_abs(m_LabelImage->GetSpacing()[i]); + double s = regionSize[i] * vcl_abs(m_LabelImage->GetSignedSpacing()[i]); minSize = std::min(s, minSize); maxSize = std::max(s, maxSize); for (DimensionType j = 0; j < LabelObjectType::ImageDimension; ++j) @@ -550,7 +550,7 @@ ShapeAttributesLabelObjectFunctor<TLabelObject, TLabelImage> SimplifyPolygonFunctorType simplifyFunctor; polygonFunctor.SetStartIndex(m_LabelImage->GetLargestPossibleRegion().GetIndex()); polygonFunctor.SetOrigin(m_LabelImage->GetOrigin()); - polygonFunctor.SetSpacing(m_LabelImage->GetSpacing()); + polygonFunctor.SetSpacing(m_LabelImage->GetSignedSpacing()); typename PolygonType::Pointer polygon = simplifyFunctor(polygonFunctor(lo)); lo->SetPolygon(polygon); } @@ -622,7 +622,7 @@ ShapeAttributesLabelObjectFunctor<TLabelObject, TLabelImage> double length = 0; for (DimensionType i = 0; i < LabelObjectType::ImageDimension; ++i) { - length += vcl_pow((iIt1->operator[] (i) - iIt2->operator[] (i)) * m_LabelImage->GetSpacing()[i], 2); + length += vcl_pow((iIt1->operator[] (i) - iIt2->operator[] (i)) * m_LabelImage->GetSignedSpacing()[i], 2); } if (feretDiameter < length) { @@ -853,7 +853,7 @@ ShapeAttributesLabelObjectFunctor<TLabelObject, TLabelImage> } // compute the perimeter based on the intercept counts - double perimeter = PerimeterFromInterceptCount( intercepts, m_LabelImage->GetSpacing() ); + double perimeter = PerimeterFromInterceptCount( intercepts, m_LabelImage->GetSignedSpacing() ); return perimeter; } diff --git a/Modules/Core/LabelMap/test/otbLabelObjectMapVectorizer.cxx b/Modules/Core/LabelMap/test/otbLabelObjectMapVectorizer.cxx index dbefe32e1d964ef677a353649673601dba3e80fd..588a8902319d3489613f72fbda0ecbc2f72b2ac3 100644 --- a/Modules/Core/LabelMap/test/otbLabelObjectMapVectorizer.cxx +++ b/Modules/Core/LabelMap/test/otbLabelObjectMapVectorizer.cxx @@ -135,7 +135,7 @@ int otbLabelObjectMapVectorizer(int argc, char * argv[]) VectorDataFilterType::Pointer vectorDataProjection = VectorDataFilterType::New(); vectorDataProjection->SetInputOrigin(lreader->GetOutput()->GetOrigin()); - vectorDataProjection->SetInputSpacing(lreader->GetOutput()->GetSpacing()); + vectorDataProjection->SetInputSpacing(lreader->GetOutput()->GetSignedSpacing()); vectorDataProjection->SetInput(data); writer->SetFileName(outfname); diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index 9d6babaef3980cf72eef00df15380c0e1b5afccc..b9db494becf30b3c3bf956c318f28c0d9a1cbc9a 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -200,7 +200,6 @@ public: Iterator lIter(m_Iter + i); return lIter; } - /** * Remove */ @@ -209,6 +208,20 @@ public: Iterator lIter(m_Iter - i); return lIter; } + /** + */ + Iterator + operator += ( int i ) + { + return m_Iter + i; + } + /** + */ + Iterator + operator -= ( int i ) + { + return m_Iter - i; + } /** * Difference comparison operator. */ diff --git a/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.txx b/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.txx index 9d2615fd04167902c30d89e94e3aac3ab3f78058..70991ea19196d1e20f55038517944e013c92451e 100644 --- a/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.txx +++ b/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.txx @@ -362,11 +362,11 @@ SpatialObjectToImageDrawingFilter<TInputSpatialObject, TOutputImage> if (specified) { - OutputImage->SetSpacing(this->m_Spacing); // set spacing + OutputImage->SetSignedSpacing(this->m_Spacing); // set spacing } else { - OutputImage->SetSpacing(InputObject->GetIndexToObjectTransform()->GetScaleComponent()); // set spacing + OutputImage->SetSignedSpacing(InputObject->GetIndexToObjectTransform()->GetScaleComponent()); // set spacing m_Spacing[0] = InputObject->GetIndexToObjectTransform()->GetScaleComponent()[0]; m_Spacing[1] = InputObject->GetIndexToObjectTransform()->GetScaleComponent()[1]; } diff --git a/Modules/Core/Transform/include/otbGenericRSTransform.h b/Modules/Core/Transform/include/otbGenericRSTransform.h index 09a8ed37867f476b0e28c6632680a437f712748a..aac8f9468435e2b2b8e57508fcabcaa4278d316a 100644 --- a/Modules/Core/Transform/include/otbGenericRSTransform.h +++ b/Modules/Core/Transform/include/otbGenericRSTransform.h @@ -142,7 +142,7 @@ public: itkGetConstReferenceMacro(InputOrigin, OriginType); /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ itkSetMacro(InputSpacing, SpacingType); itkGetConstReferenceMacro(InputSpacing, SpacingType); @@ -152,7 +152,7 @@ public: itkGetConstReferenceMacro(OutputOrigin, OriginType); /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ itkSetMacro(OutputSpacing, SpacingType); itkGetConstReferenceMacro(OutputSpacing, SpacingType); diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h index ee6c50cf54cadde092cdb603e7020d74aa92bf6b..97a32a5701e1dabd1e78ba1aaf5f2aa7d8eb2fa2 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h @@ -72,6 +72,7 @@ public: typedef typename OutputImageType::PointType PointType; typedef typename OutputImageType::IndexType IndexType; typedef typename OutputImageType::PixelType PixelType; + typedef typename OutputImageType::SpacingType SpacingType; typedef typename OutputImageType::Pointer OutputImagePointerType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef TDisplacementField DisplacementFieldType; @@ -83,6 +84,14 @@ public: itkSetMacro(MaximumDisplacement, DisplacementValueType); itkGetConstReferenceMacro(MaximumDisplacement, DisplacementValueType); + const SpacingType & GetOutputSpacing() const override + { + return m_OutputSignedSpacing; + }; + + void SetOutputSpacing( const SpacingType OutputSpacing ) override ; + void SetOutputSpacing( const double *values ) override ; + protected: /** Constructor */ StreamingWarpImageFilter(); @@ -108,6 +117,10 @@ private: StreamingWarpImageFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented + //Because of itk positive spacing we need this member to be compliant with otb + //signed spacing + SpacingType m_OutputSignedSpacing; + // Assessment of the maximum displacement for streaming DisplacementValueType m_MaximumDisplacement; }; diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx index 60dc825d3db73c67f68d62713a93e9c5b82c3ec6..1d9bf6e7bcd05972ab8e469aa02f28995db3cb77 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx @@ -37,8 +37,51 @@ StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> { // Fill the default maximum displacement m_MaximumDisplacement.Fill(1); + m_OutputSignedSpacing = this->Superclass::GetOutputSpacing(); } + +template<class TInputImage, class TOutputImage, class TDisplacementField> +void +StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> +::SetOutputSpacing( const SpacingType outputSpacing ) +{ + m_OutputSignedSpacing = outputSpacing; + SpacingType spacing = outputSpacing; + typename TInputImage::DirectionType direction = + this->GetOutput()->GetDirection(); + for( unsigned int i = 0 ; i < TInputImage::ImageDimension ; ++i ) + { + if ( spacing[i] < 0 ) + { + if ( direction[i][i] > 0 ) + { + for( unsigned int j = 0 ; j < TInputImage::ImageDimension ; ++j ) + { + direction[j][i] = - direction[j][i]; + } + } + spacing[i] = - spacing[i]; + } + } + this->Superclass::SetOutputSpacing( spacing ); + this->Superclass::SetOutputDirection( direction ); + this->Modified(); +} + +template<class TInputImage, class TOutputImage, class TDisplacementField> +void +StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> +::SetOutputSpacing( const double *values ) +{ + SpacingType s; + for(unsigned int i = 0; i < TInputImage::ImageDimension; ++i) + { + s[i] = static_cast< typename SpacingType::ValueType >(values[i]); + } + this->SetOutputSpacing(s); +} + template<class TInputImage, class TOutputImage, class TDisplacementField> void StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> diff --git a/Modules/Core/VectorDataBase/include/otbVectorData.h b/Modules/Core/VectorDataBase/include/otbVectorData.h index 54ea18cada267dff810fef1d34882184ae2998a2..0a1b8968e07179d3c599dc99374c16e38dea897e 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorData.h +++ b/Modules/Core/VectorDataBase/include/otbVectorData.h @@ -103,7 +103,7 @@ public: /** Set the spacing of the vector data to put it in the corresponding * image coordinates - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetSpacing(const SpacingType& spacing); virtual void SetSpacing(const double spacing[2]); virtual void SetSpacing(const float spacing[2]); diff --git a/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.txx b/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.txx index bb839227755d888a68e22d671ee94a7b1623efb7..32d2638ea98e9874e1f29761f3cf685922ed4c68 100644 --- a/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.txx +++ b/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.txx @@ -82,7 +82,7 @@ GenericRoadExtractionFilter<TInputImage, TOutputPath> ::BeforeGenerateData() { /** Calculation of resolution value */ - typename InputImageType::SpacingType spacing = this->GetInput()->GetSpacing(); + typename InputImageType::SpacingType spacing = this->GetInput()->GetSignedSpacing(); // Getting x Spacing for the resolution m_Resolution = static_cast<double>(spacing[0]); if (m_Resolution == 0.) diff --git a/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.txx b/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.txx index 10c0d816f58c904eac673a72fca69898880a223f..459b09310f7322a71d252756955835d74f7daaf8 100644 --- a/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.txx +++ b/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.txx @@ -239,7 +239,7 @@ ImageToPathListAlignFilter<TInputImage, TOutputPath> region.SetIndex(IndexOut); m_AngleImage->SetRegions(region); m_AngleImage->SetOrigin(InputImage->GetOrigin()); - m_AngleImage->SetSpacing(InputImage->GetSpacing()); + m_AngleImage->SetSignedSpacing(InputImage->GetSignedSpacing()); m_AngleImage->Allocate(); n = Taille[0]; diff --git a/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.txx b/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.txx index f007b11bc3d7c87baf8f0792dfe5af4379cdf672..e08c7e52bbd8f7063498a2a4f413b66f29b4cb11 100644 --- a/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.txx +++ b/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.txx @@ -70,7 +70,7 @@ KeyPointDensityImageFilter<TInputImage, TOutputImage, TDetector> /** Applying the pointsetTodensityImageFilter*/ m_PointSetToDensityImageFilter->SetInput(m_Detector->GetOutput()); m_PointSetToDensityImageFilter->SetRadius(m_NeighborhoodRadius); - m_PointSetToDensityImageFilter->SetSpacing(ptr->GetSpacing()); + m_PointSetToDensityImageFilter->SetSpacing(ptr->GetSignedSpacing()); m_PointSetToDensityImageFilter->SetSize(ptr->GetLargestPossibleRegion().GetSize()); m_PointSetToDensityImageFilter->SetOrigin(ptr->GetOrigin()); m_PointSetToDensityImageFilter->Update(); diff --git a/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.txx b/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.txx index 474c6b1283f06437e3bf7cfe6f3f5ebd5050cf0a..09c672b71555e2a5c95f5f786dc24f38e3789afd 100644 --- a/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.txx +++ b/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.txx @@ -113,7 +113,7 @@ PointSetToDensityImageFilter<TInputPointSet, TOutputImage, TDensityFunction> region.SetIndex(start); outputPtr->SetOrigin(this->GetOrigin()); - outputPtr->SetSpacing(this->GetSpacing()); + outputPtr->SetSignedSpacing(this->GetSpacing()); outputPtr->SetRegions(region); } diff --git a/Modules/Feature/Density/test/otbPointSetToDensityImageFilterTest.cxx b/Modules/Feature/Density/test/otbPointSetToDensityImageFilterTest.cxx index 773a117ce13478df29d68b21de28711862ad873d..937d64a7d442ee744f1b3cf007e2c7a7a99f038f 100644 --- a/Modules/Feature/Density/test/otbPointSetToDensityImageFilterTest.cxx +++ b/Modules/Feature/Density/test/otbPointSetToDensityImageFilterTest.cxx @@ -63,7 +63,7 @@ int otbPointSetToDensityImageFilterTest(int itkNotUsed(argc), char* argv[]) /** PointSetImageToDensity ImageFilter*/ filter->SetInput(detector->GetOutput()); filter->SetRadius(radius); - filter->SetSpacing(reader->GetOutput()->GetSpacing()); + filter->SetSpacing(reader->GetOutput()->GetSignedSpacing()); filter->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize()); filter->SetOrigin(reader->GetOutput()->GetOrigin()); diff --git a/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.txx b/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.txx index 4871b8fd2adc5c5694ab00af7508ff143e6058d6..9d48d66ff2b2b05216781442a8623f8d158fd47a 100644 --- a/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.txx +++ b/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.txx @@ -81,7 +81,7 @@ ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension> // Compute centre of the transform SizeType inputSize = this->GetInput()->GetLargestPossibleRegion().GetSize(); - SpacingType inputSpacing = this->GetInput()->GetSpacing(); + SpacingType inputSpacing = this->GetInput()->GetSignedSpacing(); itk::ContinuousIndex<double,2> centre; centre[0] = -0.5 + 0.5 * static_cast<double>(inputSize[0]); centre[1] = -0.5 + 0.5 * static_cast<double>(inputSize[1]); diff --git a/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.txx b/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.txx index 8c3d0e721720030ef314a58038b54326b4506ba5..e34a5a8ba4de886670793a0fb20fce5907bf176b 100644 --- a/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.txx +++ b/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.txx @@ -144,7 +144,7 @@ ImageToSIFTKeyPointSetFilter<TInputImage, TOutputPointSet> input = m_ShrinkFilter->GetOutput(); typename InputImageType::PointType origin1; - typename InputImageType::SpacingType spacing = input->GetSpacing(); + typename InputImageType::SpacingType spacing = input->GetSignedSpacing(); origin1[0] = origin0[0] + spacing[0] * 0.25; origin1[1] = origin0[1] + spacing[1] * 0.25; @@ -181,7 +181,7 @@ ImageToSIFTKeyPointSetFilter<TInputImage, TOutputPointSet> typename InputImageType::PointType origin0 = this->GetInput()->GetOrigin(); typename InputImageType::PointType origin1; - typename InputImageType::SpacingType spacing = m_ExpandFilter->GetOutput()->GetSpacing(); + typename InputImageType::SpacingType spacing = m_ExpandFilter->GetOutput()->GetSignedSpacing(); origin1[0] = origin0[0] - spacing[0] * 0.5; origin1[1] = origin0[1] - spacing[1] * 0.5; @@ -213,8 +213,8 @@ ImageToSIFTKeyPointSetFilter<TInputImage, TOutputPointSet> // // with multiply by spacing before filtering, length sigma gaussian // is compute in pixel - double xsigman = vcl_abs(input->GetSpacing()[0]) * m_Sigma0; - double ysigman = vcl_abs(input->GetSpacing()[1]) * m_Sigma0; + double xsigman = vcl_abs(input->GetSignedSpacing()[0]) * m_Sigma0; + double ysigman = vcl_abs(input->GetSignedSpacing()[1]) * m_Sigma0; for (lScale = 0; lScale != m_ScalesNumber + 2; lScale++) { @@ -276,7 +276,7 @@ ImageToSIFTKeyPointSetFilter<TInputImage, TOutputPointSet> typename ImageListType::Iterator lIterDoG = m_DoGList->Begin() + 1; unsigned int lScale = 1; OutputPointSetPointerType outputPointSet = this->GetOutput(); - typename InputImageType::SpacingType spacing = lIterDoG.Get()->GetSpacing(); + typename InputImageType::SpacingType spacing = lIterDoG.Get()->GetSignedSpacing(); while ((lIterDoG + 1) != m_DoGList->End()) { diff --git a/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.txx b/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.txx index 4c7ffe0d6c5735afa0213acd8c9d7fa7353650b5..4221e4ba0c7bbc1215715cf7ab07ae6387c67ba5 100644 --- a/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.txx +++ b/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.txx @@ -94,7 +94,7 @@ ImageToSURFKeyPointSetFilter<TInputImage, TOutputPointSet> sigma_in = 2.; m_ImageList = ImageListType::New(); - spacing = this->GetInput()->GetSpacing(); + spacing = this->GetInput()->GetSignedSpacing(); /*-------------------------------------------------------- Octave per octave diff --git a/Modules/Feature/Descriptors/test/otbFourierMellinDescriptors.cxx b/Modules/Feature/Descriptors/test/otbFourierMellinDescriptors.cxx index 1d0e44e2f7a6d5e90cc88953ed5794263a4f81a0..675f83184903ed54499e0fff55338b1f907867c9 100644 --- a/Modules/Feature/Descriptors/test/otbFourierMellinDescriptors.cxx +++ b/Modules/Feature/Descriptors/test/otbFourierMellinDescriptors.cxx @@ -218,7 +218,7 @@ int otbFourierMellinDescriptorsRotationInvariant(int itkNotUsed(argc), char * ar filter->SetInterpolator(interpolator); filter->SetDefaultPixelValue( 100 ); - const InputImageType::SpacingType & spacing = reader->GetOutput()->GetSpacing(); + const InputImageType::SpacingType & spacing = reader->GetOutput()->GetSignedSpacing(); const InputImageType::PointType & origin = reader->GetOutput()->GetOrigin(); InputImageType::SizeType size = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); diff --git a/Modules/Feature/Descriptors/test/otbHistogramOfOrientedGradientCovariantImageFunction.cxx b/Modules/Feature/Descriptors/test/otbHistogramOfOrientedGradientCovariantImageFunction.cxx index 66538c9d1fbbbe1438e2a7cefe53c9bc24648d96..1732f66d59f15abdfda9afde43628549d5abc1fa 100644 --- a/Modules/Feature/Descriptors/test/otbHistogramOfOrientedGradientCovariantImageFunction.cxx +++ b/Modules/Feature/Descriptors/test/otbHistogramOfOrientedGradientCovariantImageFunction.cxx @@ -60,6 +60,7 @@ int otbHistogramOfOrientedGradientCovariantImageFunction(int itkNotUsed(argc), c GradientFilterType::Pointer gradient = GradientFilterType::New(); gradient->SetInput(reader->GetOutput()); gradient->SetUseImageSpacing(false); + gradient->SetUseImageDirection(false); gradient->Update(); // Instantiating object diff --git a/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterDistanceMap.cxx b/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterDistanceMap.cxx index d9741eeaed6b55c8bad6cd43ff6cc73b42bd7b21..afbedddd9be159bb2af146ff9a2b482bf3aab706 100644 --- a/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterDistanceMap.cxx +++ b/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterDistanceMap.cxx @@ -74,7 +74,7 @@ OutputImageType::Pointer sift(ImageType::Pointer input, pointSetFilter->SetOutsideValue(0); pointSetFilter->SetInsideValue(255); pointSetFilter->SetSize(input->GetLargestPossibleRegion().GetSize()); - pointSetFilter->SetSpacing(input->GetSpacing()); + pointSetFilter->SetSpacing(input->GetSignedSpacing()); pointSetFilter->SetOrigin(input->GetOrigin()); pointSetFilter->Update(); @@ -116,7 +116,7 @@ ImageType::Pointer rotate(ImageType::Pointer input, TransformType::OutputVectorType translation1; TransformType::OutputVectorType translation2; - const ImageType::SpacingType& spacing = input->GetSpacing(); + const ImageType::SpacingType& spacing = input->GetSignedSpacing(); const ImageType::PointType& origin = input->GetOrigin(); ImageType::SizeType size = input->GetLargestPossibleRegion().GetSize(); @@ -155,7 +155,7 @@ OutputImageType::Pointer invRotate(OutputImageType::Pointer input, TransformType::OutputVectorType translation1; TransformType::OutputVectorType translation2; - const ImageType::SpacingType& spacing = input->GetSpacing(); + const ImageType::SpacingType& spacing = input->GetSignedSpacing(); const ImageType::PointType& origin = input->GetOrigin(); ImageType::SizeType size = input->GetLargestPossibleRegion().GetSize(); diff --git a/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterOutputImage.cxx b/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterOutputImage.cxx index e8e5671474e22626c90f3e9077d892179b3e55f8..355dc8d46a877a1087528445561029e1dd307f1d 100644 --- a/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterOutputImage.cxx +++ b/Modules/Feature/Descriptors/test/otbImageToSIFTKeyPointSetFilterOutputImage.cxx @@ -116,7 +116,7 @@ int otbImageToSIFTKeyPointSetFilterOutputImage(int itkNotUsed(argc), char * argv std::cout << "Copy Input image in Output image" << std::endl; PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin(); - ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); + ImageType::SpacingType spacing = reader->GetOutput()->GetSignedSpacing(); ImageType::PointType origin = reader->GetOutput()->GetOrigin(); //OutputImageType::SizeType size = outputImage->GetLargestPossibleRegion().GetSize(); diff --git a/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.txx b/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.txx index a9c1e8822602a5af376701339eab07f7e790c12b..7f8aa38e98e2a90329f9ee98e483dc72fd73bb1b 100644 --- a/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.txx +++ b/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.txx @@ -195,7 +195,7 @@ HoughTransform2DLinesImageFilter<TInputPixelType, TOutputPixelType> m_SimplifyAccumulator = OutputImageType::New(); m_SimplifyAccumulator->SetRegions(outputImage->GetLargestPossibleRegion()); m_SimplifyAccumulator->SetOrigin(inputImage->GetOrigin()); - m_SimplifyAccumulator->SetSpacing(inputImage->GetSpacing()); + m_SimplifyAccumulator->SetSignedSpacing(inputImage->GetSignedSpacing()); m_SimplifyAccumulator->Allocate(); m_SimplifyAccumulator->FillBuffer(0); diff --git a/Modules/Feature/Edge/include/otbLineSegmentDetector.txx b/Modules/Feature/Edge/include/otbLineSegmentDetector.txx index aecdb8b29f6097ff5a04ed17bcab06e3e4e096df..c06344e1831c17e0f9c07448a40f7ceb1b154155 100644 --- a/Modules/Feature/Edge/include/otbLineSegmentDetector.txx +++ b/Modules/Feature/Edge/include/otbLineSegmentDetector.txx @@ -323,7 +323,7 @@ LineSegmentDetector<TInputImage, TPrecision> this->GetOutput(0)->GetDataTree()->Add(folder, document); this->GetOutput(0)->SetProjectionRef(this->GetInput()->GetProjectionRef()); - SpacingType spacing = this->GetInput()->GetSpacing(); + SpacingType spacing = this->GetInput()->GetSignedSpacing(); OriginType origin = this->GetInput()->GetOrigin(); /** store the lines*/ diff --git a/Modules/Feature/Edge/include/otbLocalHoughFilter.txx b/Modules/Feature/Edge/include/otbLocalHoughFilter.txx index 0d78f6879d0e074818e248b1ed3e967a62c0172d..a3b0d6e6be609527145600c5024aa0f8ffec19a3 100644 --- a/Modules/Feature/Edge/include/otbLocalHoughFilter.txx +++ b/Modules/Feature/Edge/include/otbLocalHoughFilter.txx @@ -195,7 +195,7 @@ LocalHoughFilter<TInputImage> region.SetIndex(index); localImage->SetRegions(region); localImage->SetOrigin(filterImage->GetOrigin()); - localImage->SetSpacing(filterImage->GetSpacing()); + localImage->SetSignedSpacing(filterImage->GetSignedSpacing()); localImage->Allocate(); typedef itk::ImageRegionIteratorWithIndex<InputImageType> LocalIteratorType; diff --git a/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.txx b/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.txx index fec32eb248e115e6fcef077828610b9f3e2332a5..8f80efc20018234a3bf13da7ca95f8e9fddb691b 100644 --- a/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.txx +++ b/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.txx @@ -115,7 +115,7 @@ TouziEdgeDetectorImageFilter<TInputImage, TOutputImage, TOutputImageDirection> region.SetIndex(output->GetRequestedRegion().GetIndex()); direction->SetRegions(region); direction->SetOrigin(output->GetOrigin()); - direction->SetSpacing(output->GetSpacing()); + direction->SetSignedSpacing(output->GetSignedSpacing()); direction->Allocate(); } diff --git a/Modules/Feature/Moments/test/otbFlusserMomentsImageFunction.cxx b/Modules/Feature/Moments/test/otbFlusserMomentsImageFunction.cxx index bdeef7475fc61dabd7d5b3274f41381b0db1c5b9..e2e5c387e1826fd8e37c9b2e0155c3518bbca81a 100644 --- a/Modules/Feature/Moments/test/otbFlusserMomentsImageFunction.cxx +++ b/Modules/Feature/Moments/test/otbFlusserMomentsImageFunction.cxx @@ -205,7 +205,7 @@ int otbFlusserMomentsImageFunctionRotationInvariant(int itkNotUsed(argc), char * filter->SetInterpolator(interpolator); filter->SetDefaultPixelValue( 100 ); - const InputImageType::SpacingType & spacing = reader->GetOutput()->GetSpacing(); + const InputImageType::SpacingType & spacing = reader->GetOutput()->GetSignedSpacing(); const InputImageType::PointType & origin = reader->GetOutput()->GetOrigin(); InputImageType::SizeType size = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); diff --git a/Modules/Feature/Moments/test/otbHuMomentsImageFunction.cxx b/Modules/Feature/Moments/test/otbHuMomentsImageFunction.cxx index eceb2d338e52b158bc80f2c3d457ab4bdb607064..3a1da3fc5269011ccc3443bea34734473f82697f 100644 --- a/Modules/Feature/Moments/test/otbHuMomentsImageFunction.cxx +++ b/Modules/Feature/Moments/test/otbHuMomentsImageFunction.cxx @@ -204,7 +204,7 @@ int otbHuMomentsImageFunctionRotationInvariant(int itkNotUsed(argc), char * argv filter->SetInterpolator(interpolator); filter->SetDefaultPixelValue( 100 ); - const InputImageType::SpacingType & spacing = reader->GetOutput()->GetSpacing(); + const InputImageType::SpacingType & spacing = reader->GetOutput()->GetSignedSpacing(); const InputImageType::PointType & origin = reader->GetOutput()->GetOrigin(); InputImageType::SizeType size = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); diff --git a/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.txx b/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.txx index d43274f8fc2ac1062acbfcda385dc162b5aa2246..506f894347ff4f8a4e5f9bf23754bf20a7de116a 100644 --- a/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.txx +++ b/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.txx @@ -226,7 +226,7 @@ AddCarvingPathFilter<TInputImage, TInputPath, TOutputImage> // we need to compute the output spacing, the output image size, and the // output image start index const typename TInputImage::SpacingType& - inputSpacing = inputPtr->GetSpacing(); + inputSpacing = inputPtr->GetSignedSpacing(); const typename TInputImage::SizeType& inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); const typename TInputImage::IndexType& inputStartIndex @@ -245,7 +245,7 @@ AddCarvingPathFilter<TInputImage, TInputPath, TOutputImage> // we remove one column of the image outputSize[dir0] = inputSize[dir0] + 1; - outputPtr->SetSpacing(outputSpacing); + outputPtr->SetSignedSpacing(outputSpacing); typename TOutputImage::RegionType outputLargestPossibleRegion; outputLargestPossibleRegion.SetSize(outputSize); diff --git a/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.txx b/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.txx index ceed579d6f8b0aa271749d21a8247fb9071ce800..5052be60db0810c7898812ff3459c9c1654e6c85 100644 --- a/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.txx +++ b/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.txx @@ -191,7 +191,7 @@ RemoveCarvingPathFilter<TInputImage, TInputPath, TOutputImage> // we need to compute the output spacing, the output image size, and the // output image start index const typename TInputImage::SpacingType& - inputSpacing = inputPtr->GetSpacing(); + inputSpacing = inputPtr->GetSignedSpacing(); const typename TInputImage::SizeType& inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); const typename TInputImage::IndexType& inputStartIndex @@ -210,7 +210,7 @@ RemoveCarvingPathFilter<TInputImage, TInputPath, TOutputImage> // we remove one column of the image outputSize[dir0] = inputSize[dir0] - 1; - outputPtr->SetSpacing(outputSpacing); + outputPtr->SetSignedSpacing(outputSpacing); typename TOutputImage::RegionType outputLargestPossibleRegion; outputLargestPossibleRegion.SetSize(outputSize); diff --git a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx index 94a5cbf4c149a63da4940ce89c8e7c31e1db7de2..43ab8ca08e686e0e123541ed0a8fc2fb7854b54e 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx +++ b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx @@ -212,7 +212,7 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); - typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSpacing(); + typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSignedSpacing(); outSpacing[0] *= m_SubsampleFactor[0]; outSpacing[1] *= m_SubsampleFactor[1]; @@ -224,7 +224,7 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> OutputImagePointerType outputPtr = this->GetOutput(i); outputPtr->SetLargestPossibleRegion(outputRegion); outputPtr->SetOrigin(outOrigin); - outputPtr->SetSpacing(outSpacing); + outputPtr->SetSignedSpacing(outSpacing); } } diff --git a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx index abeba22eabcf6237a6bd634c02fdb499761549a0..9c7aed6895d64d8b61dc327331e6347361a34f9d 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx +++ b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx @@ -254,7 +254,7 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); - typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSpacing(); + typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSignedSpacing(); outSpacing[0] *= m_SubsampleFactor[0]; outSpacing[1] *= m_SubsampleFactor[1]; @@ -266,7 +266,7 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> OutputImagePointerType outputPtr = this->GetOutput(i); outputPtr->SetLargestPossibleRegion(outputRegion); outputPtr->SetOrigin(outOrigin); - outputPtr->SetSpacing(outSpacing); + outputPtr->SetSignedSpacing(outSpacing); } } diff --git a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx index 59396979f31834ba3b4de57bdce58f7926bd0861..e7473f705ae6ffbe8151d71305445ec7d42eb5b6 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx +++ b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx @@ -187,7 +187,7 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); - typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSpacing(); + typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSignedSpacing(); outSpacing[0] *= m_SubsampleFactor[0]; outSpacing[1] *= m_SubsampleFactor[1]; @@ -199,7 +199,7 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> OutputImagePointerType outputPtr = this->GetOutput(i); outputPtr->SetLargestPossibleRegion(outputRegion); outputPtr->SetOrigin(outOrigin); - outputPtr->SetSpacing(outSpacing); + outputPtr->SetSignedSpacing(outSpacing); } } diff --git a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h index 04ad63740fcbbd8d0e04e5c7a38360dbcdb8c5e8..26464e39fc79babb9f8dfdf92412ca42886550d7 100644 --- a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h +++ b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h @@ -165,7 +165,7 @@ public: template <class TImageType> void SetOutputParametersFromImage(const TImageType * image) { this->SetOutputOrigin ( image->GetOrigin() ); - this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputSpacing ( image->GetSignedSpacing() ); //this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() ); this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() ); this->SetOutputProjectionRef(image->GetProjectionRef()); diff --git a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.txx b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.txx index c87816bf07bdc67c39076955690c9a36ff2c8c0c..140fd20416acd50bd9b706a8228068fb740cb8ed 100644 --- a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.txx +++ b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.txx @@ -63,7 +63,7 @@ void DEMToImageGenerator<TDEMImage> largestPossibleRegion.SetIndex(start); output->SetLargestPossibleRegion(largestPossibleRegion); - output->SetSpacing(m_OutputSpacing); + output->SetSignedSpacing(m_OutputSpacing); output->SetOrigin(m_OutputOrigin); diff --git a/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.txx index 423b57cee7a10a43068d2c40294c05af37a01f7c..dced764cd856e4ef25f864712c22208237a362f0 100644 --- a/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.txx @@ -24,6 +24,7 @@ #include "otbGridResampleImageFilter.h" #include "otbStreamingTraits.h" +#include "otbImage.h" #include "itkNumericTraits.h" #include "itkProgressReporter.h" @@ -68,7 +69,7 @@ GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision> ::SetOutputParametersFromImage(const ImageBaseType * image) { this->SetOutputOrigin ( image->GetOrigin() ); - this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputSpacing ( internal::GetSignedSpacing( image ) ); this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() ); this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() ); } @@ -95,7 +96,7 @@ GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision> outputLargestPossibleRegion.SetIndex(m_OutputStartIndex); outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); - outputPtr->SetSpacing(m_OutputSpacing); + outputPtr->SetSignedSpacing(m_OutputSpacing); outputPtr->SetOrigin(m_OutputOrigin); // TODO: Report no data value here @@ -266,8 +267,8 @@ GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision> this->GetInput()->TransformIndexToPhysicalPoint(inUL,inULp); this->GetInput()->TransformIndexToPhysicalPoint(inLR,inLRp); - inULp-=0.5*this->GetInput()->GetSpacing(); - inLRp+=0.5*this->GetInput()->GetSpacing(); + inULp-=0.5*this->GetInput()->GetSignedSpacing(); + inLRp+=0.5*this->GetInput()->GetSignedSpacing(); ContinuousInputIndexType outUL; ContinuousInputIndexType outLR; @@ -340,9 +341,9 @@ GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision> InterpolatorOutputType interpolatorValue; //(this->GetOutput()->GetNumberOfComponentsPerPixel()); OutputPixelType outputValue; //(this->GetOutput()->GetNumberOfComponentsPerPixel()); - // TODO: assert outputPtr->GetSpacing() != 0 here - assert(outputPtr->GetSpacing()[0]!=0&&"Null spacing will cause division by zero."); - const double delta = outputPtr->GetSpacing()[0]/inputPtr->GetSpacing()[0]; + // TODO: assert outputPtr->GetSignedSpacing() != 0 here + assert(outputPtr->GetSignedSpacing()[0]!=0&&"Null spacing will cause division by zero."); + const double delta = outputPtr->GetSignedSpacing()[0]/inputPtr->GetSignedSpacing()[0]; // Iterate through the output region outIt.GoToBegin(); diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h index b5c58704be6d626e6b027d90788c2608da5f1862..d42cea94c96426b7843395bba5a5726afa8eced8 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h @@ -117,15 +117,12 @@ public: otbGetObjectMemberConstMacro(DisplacementFilter, Transform, const TransformType*); /** The Displacement field spacing & size */ - void SetDisplacementFieldSpacing(const SpacingType & spacing) - { - m_DisplacementFilter->SetOutputSpacing(spacing); - this->Modified(); - } + void SetDisplacementFieldSpacing( SpacingType spacing); + const SpacingType & GetDisplacementFieldSpacing() const { - return m_DisplacementFilter->GetOutputSpacing(); - } + return m_SignedOutputSpacing; + }; /** The resampled image parameters */ // Output Origin @@ -193,6 +190,10 @@ private: StreamingResampleImageFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented + //We need this to respect ConstRef macro and to be compliant with itk positive + //spacing + SpacingType m_SignedOutputSpacing; + typename DisplacementFieldGeneratorType::Pointer m_DisplacementFilter; typename WarpImageFilterType::Pointer m_WarpFilter; }; diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx index 71b4327b910cee8e0fb56d6f20c4c74ae1be4433..003425a9e3dddf0168b4390168b34dea493e6e0c 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx @@ -23,6 +23,7 @@ #include "otbStreamingResampleImageFilter.h" #include "itkProgressAccumulator.h" +#include "otbImage.h" namespace otb { @@ -34,7 +35,7 @@ StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionTy // internal filters instantiation m_DisplacementFilter = DisplacementFieldGeneratorType::New(); m_WarpFilter = WarpImageFilterType::New(); - + m_SignedOutputSpacing = m_DisplacementFilter->GetOutputSpacing(); // Initialize the displacement field spacing to zero : inconsistent // value this->SetDisplacementFieldSpacing(itk::NumericTraits<SpacingType>::ZeroValue()); @@ -121,11 +122,36 @@ StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionTy ::SetOutputParametersFromImage(const ImageBaseType * image) { this->SetOutputOrigin ( image->GetOrigin() ); - this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputSpacing ( internal::GetSignedSpacing( image ) ); this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() ); this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() ); } +template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType> +void +StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType> +::SetDisplacementFieldSpacing( SpacingType outputSpacing ) +{ + m_SignedOutputSpacing = outputSpacing; + typename TInputImage::DirectionType direction = this->m_DisplacementFilter->GetOutputDirection(); + for(unsigned int i = 0; i < TInputImage::ImageDimension; ++i) + { + if ( outputSpacing[i] < 0 ) + { + if ( direction[i][i] > 0 ) + { + for(unsigned int j = 0; j < TInputImage::ImageDimension; ++j) + { + direction[j][i] = - direction[j][i]; + } + } + outputSpacing[i] = - outputSpacing[i]; + } + } + this->m_DisplacementFilter->SetOutputSpacing( outputSpacing ); + this->m_DisplacementFilter->SetOutputDirection( direction ); + this->Modified(); +} template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType> void diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.txx index 68a55f3646fea880d2c270e5d627758dd09246e3..124f20e116d73ceddb3a065e54ba882f10809750 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.txx @@ -125,7 +125,7 @@ PersistentShrinkImageFilter<TInputImage, TOutputImage> m_ShrunkOutput->CopyInformation(inputPtr); const typename InputImageType::SpacingType& - inputSpacing = inputPtr->GetSpacing(); + inputSpacing = inputPtr->GetSignedSpacing(); const typename InputImageType::SizeType& inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); const typename InputImageType::IndexType& inputIndex @@ -154,7 +154,7 @@ PersistentShrinkImageFilter<TInputImage, TOutputImage> shrunkOutputStartIndex[i] = 0; } - m_ShrunkOutput->SetSpacing(shrunkOutputSpacing); + m_ShrunkOutput->SetSignedSpacing(shrunkOutputSpacing); m_ShrunkOutput->SetOrigin(shrunkOutputOrigin); shrunkOutputLargestPossibleRegion.SetSize(shrunkOutputSize); diff --git a/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.txx index 4159907e2f6b9cc0c489c8c929ff71a9ea5ca388..3a67aa469e4229a782c7d3db49c972c0b5b40daf 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.txx @@ -62,7 +62,7 @@ TileImageFilter<TImage> itkExceptionMacro(<<"Layout has "<<numberOfImages<<" tiles, but only "<<this->GetNumberOfInputs()<<" inputs are found."); } - typename ImageType::SpacingType spacing = this->GetInput()->GetSpacing(); + typename ImageType::SpacingType spacing = this->GetInput()->GetSignedSpacing(); unsigned int nbComp = this->GetInput()->GetNumberOfComponentsPerPixel(); m_ColumnsSizes.clear(); @@ -94,7 +94,7 @@ TileImageFilter<TImage> itkExceptionMacro(<<"Inconsistent sizes in layout detected!"); } - if(spacing != currentTile->GetSpacing()) + if(spacing != currentTile->GetSignedSpacing()) { itkExceptionMacro(<<"Inconsistent spacings in layout detected!"); } diff --git a/Modules/Filtering/ImageManipulation/test/otbGridResampleImageFilter.cxx b/Modules/Filtering/ImageManipulation/test/otbGridResampleImageFilter.cxx index 8dbe679c15f499f942b180c83a3478c2a41a69e1..c18e6cf7f19778395b6369f9184731fe589e6bf4 100644 --- a/Modules/Filtering/ImageManipulation/test/otbGridResampleImageFilter.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbGridResampleImageFilter.cxx @@ -88,6 +88,22 @@ int otbGridResampleImageFilter(int itkNotUsed(argc), char * itkNotUsed(argv)[]) origin[1]=17; ImageType::SizeType outSize; outSize.Fill(103); + ImageType::DirectionType direction; + direction.SetIdentity(); + ImageType::SpacingType uspacing; + for ( unsigned int i = 0 ; i < ImageType::ImageDimension ; i++ ) + { + if ( spacing[i] < 0 ) + { + uspacing[i] = -spacing[i]; + for (unsigned int j = 0 ; j < ImageType::ImageDimension ; j++) + { + direction[j][i] = -direction[j][i]; + } + } + else + uspacing[i] = spacing[i]; + } filter->SetOutputSize(outSize); filter->SetOutputOrigin(origin); @@ -95,7 +111,8 @@ int otbGridResampleImageFilter(int itkNotUsed(argc), char * itkNotUsed(argv)[]) refFilter->SetSize(outSize); refFilter->SetOutputOrigin(origin); - refFilter->SetOutputSpacing(spacing); + refFilter->SetOutputSpacing(uspacing); + refFilter->SetOutputDirection(direction); typedef otb::DifferenceImageFilter<ImageType,ImageType> ComparisonFilterType; typedef itk::StreamingImageFilter<ImageType,ImageType> StreamingFilterType; diff --git a/Modules/Filtering/MathParser/include/otbBandMathImageFilter.txx b/Modules/Filtering/MathParser/include/otbBandMathImageFilter.txx index 0a03bc57a88487448aa0196909143a841ebdc4bf..919894cc95ca74f603d885179acdc8f5c0158343 100644 --- a/Modules/Filtering/MathParser/include/otbBandMathImageFilter.txx +++ b/Modules/Filtering/MathParser/include/otbBandMathImageFilter.txx @@ -181,7 +181,7 @@ void BandMathImageFilter<TImage> } // Store images specs - m_Spacing = this->GetNthInput(0)->GetSpacing(); + m_Spacing = this->GetNthInput(0)->GetSignedSpacing(); m_Origin = this->GetNthInput(0)->GetOrigin(); // Allocate and initialize the thread temporaries diff --git a/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx b/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx index b1ebc4da0ad65457ccbdd40f52691200ed1837cd..366e84ba0aaa3d3ea7061dd3a57c4783c1300f4f 100644 --- a/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx +++ b/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx @@ -237,11 +237,11 @@ int otbBandMathImageFilterWithIdx( int itkNotUsed(argc), char* argv[]) IteratorType it3(image3, region); image1->SetOrigin(origin); - image1->SetSpacing(spacing); + image1->SetSignedSpacing(spacing); image2->SetOrigin(origin); - image2->SetSpacing(spacing); + image2->SetSignedSpacing(spacing); image3->SetOrigin(origin); - image3->SetSpacing(spacing); + image3->SetSignedSpacing(spacing); for (it1.GoToBegin(), it2.GoToBegin(), it3.GoToBegin(); !it1.IsAtEnd(); ++it1, ++it2, ++it3) { diff --git a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.txx b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.txx index 9407dba601ee8b81594227f39ec2b153062f990e..11da024a2be740df77acbf5fd42d442987de1420 100644 --- a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.txx +++ b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.txx @@ -665,13 +665,13 @@ void BandMathXImageFilter<TImage> if (m_AImage[i][j].type == 2) //imiPhyX { - SpacingType spacing = this->GetNthInput(m_AImage[i][j].info[0])->GetSpacing(); + SpacingType spacing = this->GetNthInput(m_AImage[i][j].info[0])->GetSignedSpacing(); m_AImage[i][j].value = ValueType(static_cast<double>(spacing[0])); } if (m_AImage[i][j].type == 3) //imiPhyY { - SpacingType spacing = this->GetNthInput(m_AImage[i][j].info[0])->GetSpacing(); + SpacingType spacing = this->GetNthInput(m_AImage[i][j].info[0])->GetSignedSpacing(); m_AImage[i][j].value = ValueType(static_cast<double>(spacing[1])); } diff --git a/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx b/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx index d48b558ba47f02b96e6fe35a9aec627d6401f74a..111441bcb50b9ecea3244474eb997a2ab39c6cd8 100644 --- a/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx +++ b/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx @@ -520,11 +520,11 @@ int otbBandMathXImageFilterWithIdx( int itkNotUsed(argc), char* argv[]) IteratorType it3(image3, region); image1->SetOrigin(origin); - image1->SetSpacing(spacing); + image1->SetSignedSpacing(spacing); image2->SetOrigin(origin); - image2->SetSpacing(spacing); + image2->SetSignedSpacing(spacing); image3->SetOrigin(origin); - image3->SetSpacing(spacing); + image3->SetSignedSpacing(spacing); for (it1.GoToBegin(), it2.GoToBegin(), it3.GoToBegin(); !it1.IsAtEnd(); ++it1, ++it2, ++it3) { diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.txx b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.txx index 2146f7bac3a248c9e0ea72358681183e1bea8148..b1fad675a31606f2a78aaf95ff497c7169bf010a 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.txx +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.txx @@ -96,7 +96,7 @@ Resampler<TInputImage, TOutputImage> } unsigned int i; // Computing output spacing, size and index from input data - const typename InputImageType::SpacingType& inputSpacing = inputPtr->GetSpacing(); + const typename InputImageType::SpacingType& inputSpacing = inputPtr->GetSignedSpacing(); const typename InputImageType::IndexType& inputStartIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); typename OutputImageType::IndexType outputStartIndex; typename OutputImageType::SpacingType spacing; @@ -105,7 +105,7 @@ Resampler<TInputImage, TOutputImage> outputStartIndex[i] = inputStartIndex[i]; } - outputPtr->SetSpacing(inputSpacing); + outputPtr->SetSignedSpacing(inputSpacing); typename OutputImageType::RegionType outputLargestPossibleRegion; outputLargestPossibleRegion.SetSize(this->GetSize()); outputLargestPossibleRegion.SetIndex(outputStartIndex); @@ -134,7 +134,7 @@ Resampler<TInputImage, TOutputImage> // Scale parameters computation typename TransformType::InputVectorType scales; typename InputImageType::SizeType inputSize = this->GetInput()->GetLargestPossibleRegion().GetSize(); - typename InputImageType::SpacingType inputSpacing = this->GetInput()->GetSpacing(); + typename InputImageType::SpacingType inputSpacing = this->GetInput()->GetSignedSpacing(); scales[0] = static_cast<double>(inputSize[0]) / static_cast<double>(m_Size[0]); scales[1] = static_cast<double>(inputSize[1]) / static_cast<double>(m_Size[1]); transform->SetScale(scales); @@ -150,7 +150,8 @@ Resampler<TInputImage, TOutputImage> resampler->SetInterpolator(interpolator); resampler->SetOutputOrigin(this->GetInput()->GetOrigin()); resampler->SetSize(this->GetSize()); - resampler->SetOutputSpacing(inputSpacing); + resampler->SetOutputSpacing( this->GetInput()->GetSpacing() ); + resampler->SetOutputDirection( this->GetInput()->GetDirection() ); resampler->ReleaseDataFlagOn(); // Progress accumulator diff --git a/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.txx b/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.txx index 4b32e9d737b15c5a9e1f344332a263d5ade2ea0e..abb678bebee4c3b00a24c2db31cb6679962b896e 100644 --- a/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.txx +++ b/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.txx @@ -82,7 +82,7 @@ RegionImageToRectangularPathListFilter<TInputImage, TOutputPath> typename InputImageType::PointType origin; typename InputImageType::SpacingType spacing; origin = InputImage->GetOrigin(); - spacing = InputImage->GetSpacing(); + spacing = InputImage->GetSignedSpacing(); std::cout << "Image origin : " << origin << std::endl; std::cout << "Image spacing : " << spacing << std::endl; diff --git a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx index 4a5c0edc8fbac16935c9d63b4d02505e6f84a528..923a07fadbd8b726196a977730765abc87581652 100644 --- a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx +++ b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx @@ -87,7 +87,7 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage, TOutputImage, TFunction> // dimensions to copy unsigned int i, j; const typename InputImageType::SpacingType& - inputSpacing = inputPtr->GetSpacing(); + inputSpacing = inputPtr->GetSignedSpacing(); const typename InputImageType::PointType& inputOrigin = inputPtr->GetOrigin(); const typename InputImageType::DirectionType& @@ -133,7 +133,7 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage, TOutputImage, TFunction> } // set the spacing and origin - outputPtr->SetSpacing(outputSpacing); + outputPtr->SetSignedSpacing(outputSpacing); outputPtr->SetOrigin(outputOrigin); outputPtr->SetDirection(outputDirection); diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx index ac6c36280fbe0f70816a70384ad15dfcee9f5571..7635cdcea7c215848a90ae60efb5a119bc58d1a4 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx @@ -225,7 +225,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> const InputImageType * src = dynamic_cast<const InputImageType*>(image); this->SetOutputOrigin ( src->GetOrigin() ); - this->SetOutputSpacing ( src->GetSpacing() ); + this->SetOutputSpacing ( src->GetSignedSpacing() ); this->SetOutputStartIndex ( src->GetLargestPossibleRegion().GetIndex() ); this->SetOutputSize ( src->GetLargestPossibleRegion().GetSize() ); this->SetOutputProjectionRef(src->GetProjectionRef()); @@ -243,7 +243,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> ::SetOutputParametersFromImage(const TImageType * image) { this->SetOutputOrigin ( image->GetOrigin() ); - this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputSpacing ( image->GetSignedSpacing() ); this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() ); this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() ); this->SetOutputProjectionRef(image->GetProjectionRef()); diff --git a/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.txx b/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.txx index bd152c5f74e2ad96e57534c161e983ff11792bec..acc92106b5ca9d9caf0bc3964631b4e1a8b8f2fe 100644 --- a/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.txx +++ b/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.txx @@ -131,7 +131,7 @@ GroundSpacingImageFunction<TInputImage, TCoordRep> const itk::MetaDataDictionary& inputDict = this->GetInputImage()->GetMetaDataDictionary(); transform->SetInputDictionary(inputDict); transform->SetInputOrigin(this->GetInputImage()->GetOrigin()); - transform->SetInputSpacing(this->GetInputImage()->GetSpacing()); + transform->SetInputSpacing(this->GetInputImage()->GetSignedSpacing()); transform->InstantiateTransform(); return transform->TransformPoint(inputPoint); diff --git a/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.txx b/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.txx index 1b0cf01992e82b507c9bc0b04fadff2e5f62005a..35e9ba8682a8a3e14948858f8af5024928b3b366 100644 --- a/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.txx +++ b/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.txx @@ -102,7 +102,7 @@ ImportGeoInformationImageFilter<TImage, TSourceImage> // outputPtr->CopyInformation(sourcePtr); // // Don't forget to copy also the origin and spacing, not handled by the CopyInformation method. // outputPtr->SetOrigin(sourcePtr->GetOrigin()); -// outputPtr->SetSpacing(sourcePtr->GetSpacing()); +// outputPtr->SetSignedSpacing(sourcePtr->GetSignedSpacing()); // } /** diff --git a/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.txx b/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.txx index 2f8e542c056944cf1a7561da2ecedcc74ac76910..01c10488d008f36d6c6cde98977f4aaef2223a82 100644 --- a/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.txx +++ b/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.txx @@ -81,8 +81,8 @@ PhysicalToRPCSensorModelImageFilter<TImage> for(unsigned int py = 0; py<m_GridSize[1]; ++py) { PointType inputPoint = input->GetOrigin(); - inputPoint[0] += (px * gridSpacingX + 0.5) * input->GetSpacing()[0]; - inputPoint[1] += (py * gridSpacingY + 0.5) * input->GetSpacing()[1]; + inputPoint[0] += (px * gridSpacingX + 0.5) * input->GetSignedSpacing()[0]; + inputPoint[1] += (py * gridSpacingY + 0.5) * input->GetSignedSpacing()[1]; PointType outputPoint = rsTransform->TransformPoint(inputPoint); m_GCPsToSensorModelFilter->AddGCP(inputPoint, outputPoint); } diff --git a/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h b/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h index b55573f92cf701f9c7e97bb194b6a2f978173463..b86c9c78acaf19896ba659b549bde48962987a9d 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h +++ b/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h @@ -93,7 +93,7 @@ public: itkGetConstReferenceMacro(OutputOrigin, OriginType); /** Set the spacing (size of a pixel) of the output vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetOutputSpacing(const SpacingType& spacing); virtual void SetOutputSpacing(const double spacing[2]); virtual void SetOutputSpacing(const float spacing[2]); diff --git a/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.txx b/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.txx index b38ec9fcec32b97f827d9ef573387e06a1d136dd..ccf2dc45ec5aa943fb0f31d58febcee6ce35ef22 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.txx +++ b/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.txx @@ -128,7 +128,7 @@ VectorDataIntoImageProjectionFilter<TInputVectorData, TInputImage> itkExceptionMacro("Invalid input image."); } - /*std::cout << "Spacing of the input image: "<< m_InputImage->GetSpacing() << std::endl; + /*std::cout << "Spacing of the input image: "<< m_InputImage->GetSignedSpacing() << std::endl; std::cout << "Origin of the input image: "<< m_InputImage->GetOrigin() << std::endl; std::cout << "Size of the input image: "<< m_InputImage->GetLargestPossibleRegion() << std::endl; std::cout << "ProjRef of the input image: "<< m_InputImage->GetProjectionRef() << std::endl; @@ -203,7 +203,7 @@ VectorDataIntoImageProjectionFilter<TInputVectorData, TInputImage> if (m_UseOutputSpacingAndOriginFromImage) { m_VdProjFilter->SetOutputOrigin(m_InputImage->GetOrigin()); - m_VdProjFilter->SetOutputSpacing(m_InputImage->GetSpacing()); + m_VdProjFilter->SetOutputSpacing(m_InputImage->GetSignedSpacing()); } else { diff --git a/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h b/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h index 18fc93404ae46febf4fcd730c942ce0c76720a63..3178d4c71af131efc3ac3e171984fad42abb1a39 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h +++ b/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h @@ -150,7 +150,7 @@ public: itkGetConstReferenceMacro(InputOrigin, OriginType); /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetInputSpacing(const SpacingType& spacing); virtual void SetInputSpacing(const double spacing[2]); virtual void SetInputSpacing(const float spacing[2]); @@ -166,7 +166,7 @@ public: itkGetConstReferenceMacro(OutputOrigin, OriginType); /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetOutputSpacing(const SpacingType& spacing); virtual void SetOutputSpacing(const double spacing[2]); virtual void SetOutputSpacing(const float spacing[2]); diff --git a/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromGeoToMap.cxx b/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromGeoToMap.cxx index decd1d354fe75352a35b38977b3a9a7732cfa7d3..b4ea5eb5fe7d8ecabe5522293b7dbe28f6fa1ff8 100644 --- a/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromGeoToMap.cxx +++ b/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromGeoToMap.cxx @@ -65,7 +65,7 @@ int otbGeometriesProjectionFilterFromGeoToMap(int argc, char * argv[]) filter->SetOutput(out_set); filter->SetOutputProjectionRef(imageReader->GetOutput()->GetProjectionRef()); filter->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); - filter->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + filter->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); filter->Update(); diff --git a/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToImage.cxx b/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToImage.cxx index bbca57fa39457cb873deff1ee0f51397a196769d..da3833bf1c4f012153f2e03545b9943178a05852 100644 --- a/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToImage.cxx +++ b/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToImage.cxx @@ -65,7 +65,7 @@ int otbGeometriesProjectionFilterFromMapToImage(int argc, char * argv[]) filter->SetOutput(out_set); filter->SetOutputProjectionRef(imageReader->GetOutput()->GetProjectionRef()); filter->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); - filter->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + filter->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); filter->Update(); diff --git a/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToSensor.cxx b/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToSensor.cxx index 1d86a408fcc7bb66c835ee762b3f78ea2f00138e..ec0a201c47ced1d145e7ec9add1f8aa0d03090a4 100644 --- a/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToSensor.cxx +++ b/Modules/Filtering/Projection/test/otbGeometriesProjectionFilterFromMapToSensor.cxx @@ -65,7 +65,7 @@ int otbGeometriesProjectionFilterFromMapToSensor(int argc, char * argv[]) filter->SetOutput(out_set); filter->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist()); filter->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); - filter->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + filter->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); filter->Update(); diff --git a/Modules/Filtering/Projection/test/otbImportGeoInformationImageFilter.cxx b/Modules/Filtering/Projection/test/otbImportGeoInformationImageFilter.cxx index ea687e9a3ddcbd78b512066f340abc409ef0b10d..a8d11a849de2449c5cd6c781d8d7479299eec2b0 100644 --- a/Modules/Filtering/Projection/test/otbImportGeoInformationImageFilter.cxx +++ b/Modules/Filtering/Projection/test/otbImportGeoInformationImageFilter.cxx @@ -56,7 +56,7 @@ int otbImportGeoInformationImageFilter(int itkNotUsed(argc), char * argv[]) std::cout << "black: " << black->GetLargestPossibleRegion() << std::endl; black->SetOrigin(reader->GetOutput()->GetOrigin()); - black->SetSpacing(reader->GetOutput()->GetSpacing()); + black->SetSignedSpacing(reader->GetOutput()->GetSignedSpacing()); import->SetInput(black); import->SetSource(reader->GetOutput()); diff --git a/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx b/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx index 13d39b4fc3e06fe0b7f5d260445b17cf7e8a95e2..9e2a16f1ca2a0bc9047bd528a44f7bddeb5a029b 100644 --- a/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx +++ b/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx @@ -67,9 +67,9 @@ int otbTileImageFilterRSTransformTest(int argc, char * argv[]) // Compute tile center PointType center = reader->GetOutput()->GetOrigin(); - center[0] += reader->GetOutput()->GetSpacing()[0] + center[0] += reader->GetOutput()->GetSignedSpacing()[0] * reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0]/2; - center[1] += reader->GetOutput()->GetSpacing()[1] + center[1] += reader->GetOutput()->GetSignedSpacing()[1] * reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1]/2; points.push_back(center); diff --git a/Modules/Filtering/Projection/test/otbVectorDataIntoImageProjectionFilterTest.cxx b/Modules/Filtering/Projection/test/otbVectorDataIntoImageProjectionFilterTest.cxx index e7efcbff64cca8ad7d83d58a4bf39b64528a7586..be39753484d4ea49e85f4f946f43d62951e87c45 100644 --- a/Modules/Filtering/Projection/test/otbVectorDataIntoImageProjectionFilterTest.cxx +++ b/Modules/Filtering/Projection/test/otbVectorDataIntoImageProjectionFilterTest.cxx @@ -227,7 +227,7 @@ int otbVectorDataIntoImageProjectionFilterCompareImplTest(int itkNotUsed(argc), vproj->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist()); vproj->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef()); vproj->SetOutputOrigin(reader->GetOutput()->GetOrigin()); - vproj->SetOutputSpacing(reader->GetOutput()->GetSpacing()); + vproj->SetOutputSpacing(reader->GetOutput()->GetSignedSpacing()); //---------- // WRITE diff --git a/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToImage.cxx b/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToImage.cxx index 6f4946be82d326ed448cd7d48172fb4adb48fd23..6971f7fe0f0036f69a26d4ab5c97e055e666ffd1 100644 --- a/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToImage.cxx +++ b/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToImage.cxx @@ -60,7 +60,7 @@ int otbVectorDataProjectionFilterFromMapToImage(int argc, char * argv[]) vectorDataProjection->SetOutputProjectionRef(imageReader->GetOutput()->GetProjectionRef()); vectorDataProjection->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); - vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); typedef otb::VectorDataFileWriter<OutputVectorDataType> VectorDataFileWriterType; VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New(); diff --git a/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToSensor.cxx b/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToSensor.cxx index 888f0965c00bcb7bd5c1866848a3aa8dffad5926..299a14db3d6c83c241b58f5df7d3b10e97423baf 100644 --- a/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToSensor.cxx +++ b/Modules/Filtering/Projection/test/otbVectorDataProjectionFilterFromMapToSensor.cxx @@ -60,7 +60,7 @@ int otbVectorDataProjectionFilterFromMapToSensor(int argc, char * argv[]) vectorDataProjection->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist()); vectorDataProjection->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); - vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); typedef otb::VectorDataFileWriter<OutputVectorDataType> VectorDataFileWriterType; VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New(); diff --git a/Modules/Filtering/Projection/test/otbVectorDataTransformFilter.cxx b/Modules/Filtering/Projection/test/otbVectorDataTransformFilter.cxx index d4b30d199cd90144e05b6f03c9aef0a16b068126..e0f5ee5ee81c7c0c1e2e668c610afe13b1b663cf 100644 --- a/Modules/Filtering/Projection/test/otbVectorDataTransformFilter.cxx +++ b/Modules/Filtering/Projection/test/otbVectorDataTransformFilter.cxx @@ -75,7 +75,7 @@ int otbVectorDataTransformFilter (int itkNotUsed(argc), char * argv[]) TransformType::Pointer transform = TransformType::New(); TranslationParamType translationParam; translationParam[0] = 0; - translationParam[1] = 8. * reader->GetOutput()->GetSpacing()[1]; + translationParam[1] = 8. * reader->GetOutput()->GetSignedSpacing()[1]; transform->SetTranslation(translationParam); VectorDataTransformType::Pointer transformFilter = VectorDataTransformType::New(); diff --git a/Modules/Filtering/Statistics/include/otbListSampleGenerator.txx b/Modules/Filtering/Statistics/include/otbListSampleGenerator.txx index 995e1099c570d5f917da07b032692bc4966a0053..d1fc246236b624f03391a57636655edfb5aeb22e 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleGenerator.txx +++ b/Modules/Filtering/Statistics/include/otbListSampleGenerator.txx @@ -435,7 +435,7 @@ double ListSampleGenerator<TImage, TVectorData> ::GetPolygonAreaInPixelsUnits(DataNodeType* polygonDataNode, ImageType* image) { - const double pixelArea = vcl_abs(image->GetSpacing()[0] * image->GetSpacing()[1]); + const double pixelArea = vcl_abs(image->GetSignedSpacing()[0] * image->GetSignedSpacing()[1]); // Compute area of exterior ring in pixels PolygonPointerType exteriorRing = polygonDataNode->GetPolygonExteriorRing(); diff --git a/Modules/Filtering/Statistics/test/otbContinuousMinimumMaximumImageCalculatorTest.cxx b/Modules/Filtering/Statistics/test/otbContinuousMinimumMaximumImageCalculatorTest.cxx index bd2431cb34b173ecba7054873752ac8f18130d45..d8ab360d4bd4aa70d44c2df41a896fe3b28457ff 100644 --- a/Modules/Filtering/Statistics/test/otbContinuousMinimumMaximumImageCalculatorTest.cxx +++ b/Modules/Filtering/Statistics/test/otbContinuousMinimumMaximumImageCalculatorTest.cxx @@ -54,7 +54,7 @@ otbContinuousMinimumMaximumImageCalculatorTest(int, char *[]) // Set origin and spacing of physical coordinates image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); PixelType minimum = -52; PixelType maximum = 103; diff --git a/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.h b/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.h index 976b04172ffcdbe1442c7d5b4e525439c00bea28..57beb9ef2fa2671d535963cbff31dad13ced4f12 100644 --- a/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.h +++ b/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.h @@ -152,7 +152,7 @@ public: itkGetConstReferenceMacro(Origin, OriginType); /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetSpacing(const SpacingType& spacing); virtual void SetSpacing(const double spacing[2]); virtual void SetSpacing(const float spacing[2]); diff --git a/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.txx b/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.txx index 62a651e75ec431a219fe7165f138f493d8a8062b..24e660e535e1773e117da0ea21c2e653e8bb9338 100644 --- a/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.txx +++ b/Modules/Filtering/VectorDataRendering/include/otbVectorDataToMapFilter.txx @@ -182,9 +182,12 @@ VectorDataToMapFilter<TVectorData, TImage> outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); // Set spacing and origin - outputPtr->SetSpacing(m_Spacing); + outputPtr->SetSignedSpacing(m_Spacing); outputPtr->SetOrigin(m_Origin); - outputPtr->SetDirection(m_Direction); + // outputPtr->SetDirection(m_Direction); + // As the direction cannot be changed in this filter there is no need to set + // the direction in the output image. Moreover, setting the direction to + // identity no that we enforce positive spacing leads to incoherences itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary(); itk::EncapsulateMetaData<std::string> (dict, MetaDataKey::ProjectionRefKey, diff --git a/Modules/Filtering/VectorDataRendering/test/otbVectorDataToMapFilterSensorModel.cxx b/Modules/Filtering/VectorDataRendering/test/otbVectorDataToMapFilterSensorModel.cxx index 845c3941ccdc32fe55fb2e7353fd03606ed5cbff..bbe6a7afe719991388f4e7686986c377c63cb1f5 100644 --- a/Modules/Filtering/VectorDataRendering/test/otbVectorDataToMapFilterSensorModel.cxx +++ b/Modules/Filtering/VectorDataRendering/test/otbVectorDataToMapFilterSensorModel.cxx @@ -65,7 +65,7 @@ int otbVectorDataToMapFilterSensorModel(int argc, char * argv []) projection->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist()); projection->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); - projection->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); + projection->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing()); //Convert the vector data into an image typedef itk::RGBAPixel<unsigned char> PixelType; diff --git a/Modules/IO/ExtendedFilename/test/otbExtendedFilenameTest.cxx b/Modules/IO/ExtendedFilename/test/otbExtendedFilenameTest.cxx index 137e5ee65669436c4931be1eb826692ec47f5573..f2e6cf1c79cfff1df00e8e93a7f97163ae4fa9b7 100644 --- a/Modules/IO/ExtendedFilename/test/otbExtendedFilenameTest.cxx +++ b/Modules/IO/ExtendedFilename/test/otbExtendedFilenameTest.cxx @@ -55,7 +55,7 @@ int otbImageFileReaderWithExtendedFilename(int itkNotUsed(argc), char* argv[]) file2 << "ProjRef: " << reader->GetOutput()->GetProjectionRef() << std::endl; file2 << "Origin: " << reader->GetOutput()->GetOrigin() << std::endl; - file2 << "Spacing: " << reader->GetOutput()->GetSpacing() << std::endl; + file2 << "Spacing: " << reader->GetOutput()->GetSignedSpacing() << std::endl; return EXIT_SUCCESS; } diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 812c938e6b86b6dd5005abc9939e5275b639f8e5..28d6700f5221625e7e31a09540404f444941802c 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1686,8 +1686,8 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) if (projectionRef.empty() && (vcl_abs(m_Origin[0] - 0.5) > Epsilon || vcl_abs(m_Origin[1] - 0.5) > Epsilon - || vcl_abs(m_Spacing[0] - 1.0) > Epsilon - || vcl_abs(m_Spacing[1] - 1.0) > Epsilon) ) + || vcl_abs(m_Spacing[0] * m_Direction[0][0] - 1.0) > Epsilon + || vcl_abs(m_Spacing[1] * m_Direction[1][1] - 1.0) > Epsilon) ) { // See issue #303 : // If there is no ProjectionRef, and the GeoTransform is not the identity, @@ -1768,18 +1768,18 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) /* -------------------------------------------------------------------- */ if ( vcl_abs(m_Origin[0] - 0.5) > Epsilon || vcl_abs(m_Origin[1] - 0.5) > Epsilon - || vcl_abs(m_Spacing[0] - 1.0) > Epsilon - || vcl_abs(m_Spacing[1] - 1.0) > Epsilon ) + || vcl_abs(m_Spacing[0] * m_Direction[0][0] - 1.0) > Epsilon + || vcl_abs(m_Spacing[1] * m_Direction[1][1] - 1.0) > Epsilon ) { // Only set the geotransform if it is not identity (it may erase GCP) itk::VariableLengthVector<double> geoTransform(6); /// Reporting origin and spacing // Beware : GDAL origin is at the corner of the top-left pixel // whereas OTB/ITK origin is at the centre of the top-left pixel - geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0]; - geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1]; - geoTransform[1] = m_Spacing[0]; - geoTransform[5] = m_Spacing[1]; + geoTransform[0] = m_Origin[0] - 0.5 * m_Spacing[0] * m_Direction[0][0]; + geoTransform[3] = m_Origin[1] - 0.5 * m_Spacing[1] * m_Direction[1][1]; + geoTransform[1] = m_Spacing[0] * m_Direction[0][0]; + geoTransform[5] = m_Spacing[1] * m_Direction[1][1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters geoTransform[2] = 0.; diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 966fe434b9ebf1ab7fd58711e55f9e171d7575f3..98a37bf87b51b5caade4258ab231a45b1f39c87a 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -324,13 +324,18 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> double origin[TOutputImage::ImageDimension]; typename TOutputImage::DirectionType direction; std::vector<double> axis; + int spacing_sign (0); for (unsigned int i = 0; i < TOutputImage::ImageDimension; ++i) { if (i < this->m_ImageIO->GetNumberOfDimensions()) { dimSize[i] = this->m_ImageIO->GetDimensions(i); - spacing[i] = this->m_ImageIO->GetSpacing(i); + if ( this->m_ImageIO->GetSpacing(i) < 0 ) + spacing_sign = -1; + else + spacing_sign = 1; + spacing[i] = spacing_sign * this->m_ImageIO->GetSpacing(i); origin[i] = this->m_ImageIO->GetOrigin(i); // Please note: direction cosines are stored as columns of the // direction matrix @@ -339,7 +344,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> { if (j < this->m_ImageIO->GetNumberOfDimensions()) { - direction[j][i] = axis[j]; + direction[j][i] = spacing_sign * axis[j]; } else { @@ -385,10 +390,10 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> } } - output->SetSpacing(spacing); // Set the image spacing output->SetOrigin(origin); // Set the image origin output->SetDirection(direction); // Set the image direction cosines - + output->SetSpacing(spacing); // Set the image spacing + if(!m_KeywordListUpToDate && !m_FilenameHelper->GetSkipGeom()) { diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 37bb644ed2731560caa13bc13851954290027b58..b1472291f1ae216f302757ad00b69bfd161b3630 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -557,12 +557,16 @@ ImageFileWriter<TInputImage> const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); const typename TInputImage::PointType& origin = inputPtr->GetOrigin(); const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); - + int direction_sign(0); for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i) { + if ( direction[i][i] < 0 ) + direction_sign = -1; + else + direction_sign = 1; // Final image size m_ImageIO->SetDimensions(i, inputRegion.GetSize(i)); - m_ImageIO->SetSpacing(i, spacing[i]); + m_ImageIO->SetSpacing(i, direction_sign * spacing[i]); m_ImageIO->SetOrigin(i, origin[i] + static_cast<double>(inputRegion.GetIndex()[i]) * spacing[i]); vnl_vector<double> axisDirection(TInputImage::ImageDimension); @@ -570,7 +574,7 @@ ImageFileWriter<TInputImage> // direction matrix for (unsigned int j = 0; j < TInputImage::ImageDimension; ++j) { - axisDirection[j] = direction[j][i]; + axisDirection[j] = direction_sign * direction[j][i]; } m_ImageIO->SetDirection(i, axisDirection); } diff --git a/Modules/IO/ImageIO/test/negativespacing.cxx b/Modules/IO/ImageIO/test/negativespacing.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0bd4b7554766064dedc6edfc61c63d2277a710f9 --- /dev/null +++ b/Modules/IO/ImageIO/test/negativespacing.cxx @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbImageIOFactory.h" +#include "itkMacro.h" +#include <iostream> + +#include "otbImageFileWriter.h" +#include "otbImageFileReader.h" +#include "otbImage.h" +#include "otbVectorImage.h" + + +int negativespacing(int itkNotUsed(argc), char * itkNotUsed(argv) []) +{ + typedef float InputPixelType; + const unsigned int Dimension = 2; + + typedef otb::Image< InputPixelType , Dimension > OTBInputImageType; + + typedef otb::ImageFileReader< OTBInputImageType > OTBReaderType; + typedef otb::ImageFileWriter< OTBInputImageType > OTBWriterType; + + OTBReaderType::Pointer otbReader ( OTBReaderType::New() ); + OTBWriterType::Pointer otbWriter ( OTBWriterType::New() ); + otbReader->SetFileName( "/home/antoine/dev/my_data/spacing/input_negat_spacing.tif" ); + otbWriter->SetFileName( "/home/antoine/dev/my_data/spacing/input_negat_spacing_result.tif" ); + otbReader->UpdateOutputInformation(); + + otbReader->Update(); + OTBInputImageType::Pointer otbinput = otbReader->GetOutput(); + + std::cout<<otbinput->GetSpacing()<<std::endl; + auto spacing = otbinput->GetSpacing(); + // spacing[0] = -spacing[0]; + otbinput->SetSignedSpacing(spacing); + std::cout<<otbinput->GetSpacing()<<std::endl; + std::cout<<otbinput->GetSignedSpacing()<<std::endl; + otbWriter->SetInput( otbReader->GetOutput() ); + otbWriter->Update(); + std::cout<<"OTBWriter"<<std::endl; + + return EXIT_SUCCESS; +} diff --git a/Modules/IO/ImageIO/test/otbImageFileReaderMSTAR.cxx b/Modules/IO/ImageIO/test/otbImageFileReaderMSTAR.cxx index ad551085fe1df4ba62980d325ba607f4f5573d5e..b44e4c4b7e493f57a28db0394d4741ea4ccdd918 100644 --- a/Modules/IO/ImageIO/test/otbImageFileReaderMSTAR.cxx +++ b/Modules/IO/ImageIO/test/otbImageFileReaderMSTAR.cxx @@ -74,7 +74,7 @@ int otbImageFileReaderMSTAR(int itkNotUsed(argc), char* argv[]) InternalImageType::Pointer magnitude = InternalImageType::New(); magnitude->SetRegions(inputRegion); - const InternalImageType::SpacingType& spacing = reader->GetOutput()->GetSpacing(); + const InternalImageType::SpacingType& spacing = reader->GetOutput()->GetSignedSpacing(); const InternalImageType::PointType& inputOrigin = reader->GetOutput()->GetOrigin(); double outputOrigin[InputDimension]; @@ -83,7 +83,7 @@ int otbImageFileReaderMSTAR(int itkNotUsed(argc), char* argv[]) outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i]; } - magnitude->SetSpacing(spacing); + magnitude->SetSignedSpacing(spacing); magnitude->SetOrigin(outputOrigin); magnitude->Allocate(); diff --git a/Modules/IO/ImageIO/test/otbImageFileWriterTestWithoutInput.cxx b/Modules/IO/ImageIO/test/otbImageFileWriterTestWithoutInput.cxx index 8d67754a390fdb4c73e49c290c78025539d608e2..cca2bf2fb9ba12aeb081a2368fb3ede198ae1128 100644 --- a/Modules/IO/ImageIO/test/otbImageFileWriterTestWithoutInput.cxx +++ b/Modules/IO/ImageIO/test/otbImageFileWriterTestWithoutInput.cxx @@ -68,7 +68,7 @@ int otbImageScalarFileWriterTestWithoutInputGeneric(int itkNotUsed(argc), char* SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->Allocate(); @@ -146,7 +146,7 @@ int otbImageComplexFileWriterTestWithoutInputGeneric(int itkNotUsed(argc), char* SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->Allocate(); diff --git a/Modules/IO/ImageIO/test/otbImageStreamingFileWriterTestWithoutInput.cxx b/Modules/IO/ImageIO/test/otbImageStreamingFileWriterTestWithoutInput.cxx index 822c710c5e759e59cf7da0ac823c0904eb0e8755..858141455b1ba3b0382ded9610655547c4cd7854 100644 --- a/Modules/IO/ImageIO/test/otbImageStreamingFileWriterTestWithoutInput.cxx +++ b/Modules/IO/ImageIO/test/otbImageStreamingFileWriterTestWithoutInput.cxx @@ -69,7 +69,7 @@ int otbImageScalarStreamingFileWriterTestWithoutInputGeneric(int itkNotUsed(argc SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->Allocate(); @@ -148,7 +148,7 @@ int otbImageComplexStreamingFileWriterTestWithoutInputGeneric(int itkNotUsed(arg SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->Allocate(); diff --git a/Modules/IO/ImageIO/test/otbVectorImageFileWriterTestWithoutInput.cxx b/Modules/IO/ImageIO/test/otbVectorImageFileWriterTestWithoutInput.cxx index 6c822d2e99fa1e1b426e115955c812304f98eba9..7c9fa1b6582cc01f5efa00fac262f34baed8dce3 100644 --- a/Modules/IO/ImageIO/test/otbVectorImageFileWriterTestWithoutInput.cxx +++ b/Modules/IO/ImageIO/test/otbVectorImageFileWriterTestWithoutInput.cxx @@ -77,7 +77,7 @@ int otbVectorImageFileWriterScalarTestWithoutInputGeneric(int argc, char* argv[] SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->SetNumberOfComponentsPerPixel(atoi(argv[3])); @@ -180,7 +180,7 @@ int otbVectorImageFileWriterComplexTestWithoutInputGeneric(int argc, char* argv[ SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->SetNumberOfComponentsPerPixel(atoi(argv[3])); diff --git a/Modules/IO/ImageIO/test/otbVectorImageStreamingFileWriterTestWithoutInput.cxx b/Modules/IO/ImageIO/test/otbVectorImageStreamingFileWriterTestWithoutInput.cxx index b4623bc5dc65fa48d29e80c82fd6fca1fb8bafda..e95ba584eb513fab20d015fcd1b361cce08896ab 100644 --- a/Modules/IO/ImageIO/test/otbVectorImageStreamingFileWriterTestWithoutInput.cxx +++ b/Modules/IO/ImageIO/test/otbVectorImageStreamingFileWriterTestWithoutInput.cxx @@ -77,7 +77,7 @@ int otbVectorImageStreamingFileWriterScalarTestWithoutInputGeneric(int argc, cha SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->SetNumberOfComponentsPerPixel(atoi(argv[3])); @@ -180,7 +180,7 @@ int otbVectorImageStreamingFileWriterComplexTestWithoutInputGeneric(int argc, ch SpacingType spacing; spacing.Fill(1.0); image->SetOrigin(origin); - image->SetSpacing(spacing); + image->SetSignedSpacing(spacing); image->SetRegions(region); image->SetNumberOfComponentsPerPixel(atoi(argv[3])); diff --git a/Modules/IO/TestKernel/src/otbTestHelper.cxx b/Modules/IO/TestKernel/src/otbTestHelper.cxx index 9c1559a7138dbd3da2f5917ee6d2fe66d4dae441..a7c84deb0925cdb9c00a20dfc763e1f081360aea 100644 --- a/Modules/IO/TestKernel/src/otbTestHelper.cxx +++ b/Modules/IO/TestKernel/src/otbTestHelper.cxx @@ -1529,11 +1529,11 @@ int TestHelper::RegressionTestMetaData(const char *testImageFilename, const char } // test spacing - if (blImPtr->GetSpacing() != testImPtr->GetSpacing()) + if (blImPtr->GetSignedSpacing() != testImPtr->GetSignedSpacing()) { std::cerr << "The spacing of the baseline image and Test image do not match!" << std::endl; - std::cerr << "baseline image: " << baselineImageFilename << " has spacing " << blImPtr->GetSpacing() << std::endl; - std::cerr << "Test image: " << testImageFilename << " has spacing " << testImPtr->GetSpacing() << std::endl; + std::cerr << "baseline image: " << baselineImageFilename << " has spacing " << blImPtr->GetSignedSpacing() << std::endl; + std::cerr << "Test image: " << testImageFilename << " has spacing " << testImPtr->GetSignedSpacing() << std::endl; errcount++; } diff --git a/Modules/IO/VectorDataIO/test/otbVectorDataFileGeoReaderWriter.cxx b/Modules/IO/VectorDataIO/test/otbVectorDataFileGeoReaderWriter.cxx index 5f3cc1c3742f1ef2b07e663926cac883ef0a1e3f..77b1f26360858f51a275e3e130d36a049c790263 100644 --- a/Modules/IO/VectorDataIO/test/otbVectorDataFileGeoReaderWriter.cxx +++ b/Modules/IO/VectorDataIO/test/otbVectorDataFileGeoReaderWriter.cxx @@ -42,7 +42,7 @@ int otbVectorDataFileGeoReaderWriter(int itkNotUsed(argc), char * argv[]) vectorDataReader->SetFileName(argv[1]); // vectorData->SetOrigin(m_Reader->GetOutput()->GetOrigin()); -// vectorData->SetSpacing(m_Reader->GetOutput()->GetSpacing()); +// vectorData->SetSignedSpacing(m_Reader->GetOutput()->GetSignedSpacing()); std::string projectionRef; itk::ExposeMetaData<std::string>( diff --git a/Modules/Learning/SOM/test/otbSOMClassifier.cxx b/Modules/Learning/SOM/test/otbSOMClassifier.cxx index 4e0e7ef5d10c5a0d235ecf7742e0cb47c1180132..9e72e426205f69df8266319bcb34272b9c259fc7 100644 --- a/Modules/Learning/SOM/test/otbSOMClassifier.cxx +++ b/Modules/Learning/SOM/test/otbSOMClassifier.cxx @@ -90,7 +90,7 @@ int otbSOMClassifier(int argc, char* argv[]) OutputImageType::Pointer outputImage = OutputImageType::New(); outputImage->SetRegions(reader->GetOutput()->GetLargestPossibleRegion()); outputImage->SetOrigin(reader->GetOutput()->GetOrigin()); - outputImage->SetSpacing(reader->GetOutput()->GetSpacing()); + outputImage->SetSignedSpacing(reader->GetOutput()->GetSignedSpacing()); outputImage->Allocate(); ClassifierType::OutputType* membershipSample = classifier->GetOutput(); diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx index 7fa8822ec670b416ed36e9b7eab478afca57fccb..35723e178dcc6796b68d2690419f509ba0443cf0 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx @@ -135,7 +135,7 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> { itkGenericExceptionMacro("Mask and input image have a different origin!"); } - if (mask->GetSpacing() != input->GetSpacing()) + if (mask->GetSignedSpacing() != input->GetSignedSpacing()) { itkGenericExceptionMacro("Mask and input image have a different spacing!"); } @@ -472,7 +472,7 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> TMaskImage* mask = const_cast<TMaskImage*>(this->GetMask()); typename TInputImage::IndexType imgIndex; typename TInputImage::PointType imgPoint; - typename TInputImage::SpacingType imgAbsSpacing = img->GetSpacing(); + typename TInputImage::SpacingType imgAbsSpacing = img->GetSignedSpacing(); if (imgAbsSpacing[0] < 0) imgAbsSpacing[0] = -imgAbsSpacing[0]; if (imgAbsSpacing[1] < 0) imgAbsSpacing[1] = -imgAbsSpacing[1]; diff --git a/Modules/Learning/Sampling/test/otbOGRDataToClassStatisticsFilterTest.cxx b/Modules/Learning/Sampling/test/otbOGRDataToClassStatisticsFilterTest.cxx index 178585784e245ab3a6562e3da505c24c0e60cfc9..47da4c0553e90b795d09f6d8f959033573b1429e 100644 --- a/Modules/Learning/Sampling/test/otbOGRDataToClassStatisticsFilterTest.cxx +++ b/Modules/Learning/Sampling/test/otbOGRDataToClassStatisticsFilterTest.cxx @@ -69,7 +69,7 @@ int otbOGRDataToClassStatisticsFilter(int argc, char* argv[]) inputImage->SetNumberOfComponentsPerPixel(3); inputImage->SetLargestPossibleRegion(region); inputImage->SetOrigin(origin); - inputImage->SetSpacing(spacing); + inputImage->SetSignedSpacing(spacing); // Don't allocate the input image, the filter should not need it //inputImage->Allocate(); //inputImage->FillBuffer(pixel); @@ -77,7 +77,7 @@ int otbOGRDataToClassStatisticsFilter(int argc, char* argv[]) MaskImageType::Pointer mask = MaskImageType::New(); mask->SetRegions(region); mask->SetOrigin(origin); - mask->SetSpacing(spacing); + mask->SetSignedSpacing(spacing); mask->Allocate(); itk::ImageRegionIterator<MaskImageType> it(mask,region); unsigned int count = 0; diff --git a/Modules/Learning/Sampling/test/otbOGRDataToSamplePositionFilterTest.cxx b/Modules/Learning/Sampling/test/otbOGRDataToSamplePositionFilterTest.cxx index 68403ff09ff42bcd463ae450d39daf8574ce00e3..91994335eacc01e13db9269632815a368b59ffe7 100644 --- a/Modules/Learning/Sampling/test/otbOGRDataToSamplePositionFilterTest.cxx +++ b/Modules/Learning/Sampling/test/otbOGRDataToSamplePositionFilterTest.cxx @@ -179,7 +179,7 @@ int otbOGRDataToSamplePositionFilter(int argc, char* argv[]) inputImage->SetNumberOfComponentsPerPixel(3); inputImage->SetLargestPossibleRegion(region); inputImage->SetOrigin(origin); - inputImage->SetSpacing(spacing); + inputImage->SetSignedSpacing(spacing); // Don't allocate the input image, the filter should not need it //inputImage->Allocate(); //inputImage->FillBuffer(pixel); @@ -187,7 +187,7 @@ int otbOGRDataToSamplePositionFilter(int argc, char* argv[]) MaskImageType::Pointer mask = MaskImageType::New(); mask->SetRegions(region); mask->SetOrigin(origin); - mask->SetSpacing(spacing); + mask->SetSignedSpacing(spacing); mask->Allocate(); itk::ImageRegionIterator<MaskImageType> it(mask,region); unsigned int count = 0; @@ -263,7 +263,7 @@ int otbOGRDataToSamplePositionFilterPattern(int argc, char* argv[]) inputImage->SetNumberOfComponentsPerPixel(3); inputImage->SetLargestPossibleRegion(region); inputImage->SetOrigin(origin); - inputImage->SetSpacing(spacing); + inputImage->SetSignedSpacing(spacing); // Don't allocate the input image, the filter should not need it //inputImage->Allocate(); //inputImage->FillBuffer(pixel); @@ -271,7 +271,7 @@ int otbOGRDataToSamplePositionFilterPattern(int argc, char* argv[]) MaskImageType::Pointer mask = MaskImageType::New(); mask->SetRegions(region); mask->SetOrigin(origin); - mask->SetSpacing(spacing); + mask->SetSignedSpacing(spacing); mask->Allocate(); itk::ImageRegionIterator<MaskImageType> it(mask,region); unsigned int count = 0; diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx index 5895959f3b05cf231d108e6b5db1d3be1049eea6..e54081c300bbf84b0d387377ad33c128ee3902d6 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx @@ -546,12 +546,12 @@ SimpleParallelTiffWriter<TInputImage> { // Set geotransform double geotransform[6]; - geotransform[0] = inputPtr->GetOrigin()[0] - 0.5*inputPtr->GetSpacing()[0]; - geotransform[1] = inputPtr->GetSpacing()[0]; + geotransform[0] = inputPtr->GetOrigin()[0] - 0.5*inputPtr->GetSignedSpacing()[0]; + geotransform[1] = inputPtr->GetSignedSpacing()[0]; geotransform[2] = 0.0; - geotransform[3] = inputPtr->GetOrigin()[1] - 0.5*inputPtr->GetSpacing()[1]; + geotransform[3] = inputPtr->GetOrigin()[1] - 0.5*inputPtr->GetSignedSpacing()[1]; geotransform[4] = 0.0; - geotransform[5] = inputPtr->GetSpacing()[1]; + geotransform[5] = inputPtr->GetSignedSpacing()[1]; // Call SPTW routine that creates the output raster SPTW_ERROR sperr = create_generic_raster(m_FileName, diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h index 899c56a723a2d684f113782cb139c6b0f1948ede..ecec379e6d0cdaab2a6b39817b61ccd1a533c524 100644 --- a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h +++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h @@ -210,12 +210,12 @@ template <typename TImage> void WriteMPI(TImage *img, const std::string &output, // Set GeoTransform double gt[6]; - gt[0] = img->GetOrigin()[0] - 0.5*img->GetSpacing()[0]; - gt[1] = img->GetSpacing()[0]; + gt[0] = img->GetOrigin()[0] - 0.5*img->GetSignedSpacing()[0]; + gt[1] = img->GetSignedSpacing()[0]; gt[2] = 0.0; - gt[3] = img->GetOrigin()[1] - 0.5*img->GetSpacing()[1]; + gt[3] = img->GetOrigin()[1] - 0.5*img->GetSignedSpacing()[1]; gt[4] = 0.0; - gt[5] = img->GetSpacing()[1]; + gt[5] = img->GetSignedSpacing()[1]; VRTOutput->SetGeoTransform(gt); // Set projection diff --git a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx index ef9c1638a8b00694cb36e2dbf0f807f6196ac659..372bc8affd2fd42273a9e6113a32f524575fc6d1 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx +++ b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx @@ -48,7 +48,7 @@ SarDeburstImageFilter<TImage>::GenerateOutputInformation() ImageType * outputPtr = this->GetOutput(); // Check that azimuth spacing has not been modified - if(vcl_abs(inputPtr->GetSpacing()[1]-1.)>=std::numeric_limits<double>::epsilon()) + if(vcl_abs(inputPtr->GetSignedSpacing()[1]-1.)>=std::numeric_limits<double>::epsilon()) itkExceptionMacro("Can not perform deburst if input image azimuth spacing is not 1."); // Check that the azimuth sampling grid has not been modified diff --git a/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx b/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx index d42b05f94bf4b7f26ee2a361f424c30801a514d7..60a23d17ef51b493c7c0ec2d496275cbe9bf67e4 100644 --- a/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx +++ b/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx @@ -185,7 +185,7 @@ ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSim FTMFilter->SetInterpolator(interpolator); // FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize()); FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize()); - FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing()); + FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSignedSpacing()); FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin()); FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput()); FTMFilter->Update(); @@ -246,7 +246,7 @@ ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSim // FTMFilter->SetInterpolator(interpolator); // // FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize()); // FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize()); -// FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing()); +// FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSignedSpacing()); // FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin()); // FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput()); // FTMFilter->Update(); diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.txx b/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.txx index cadaf1c6007fc9a6ebe51f6261ad58a453a4a71d..0f185825088aa67c6fe5907c84ab0bef6bd06649 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.txx +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.txx @@ -189,9 +189,9 @@ DisparityMapEstimationMethod<TFixedImage, TMovingImage, TPointSet> movingExtractor->Update(); // std::cout<<"Fixed extract origin: "<<fixedExtractor->GetOutput()->GetOrigin()<<std::endl; -// std::cout<<"Fixed extract spacing: "<<fixedExtractor->GetOutput()->GetSpacing()<<std::endl; +// std::cout<<"Fixed extract spacing: "<<fixedExtractor->GetOutput()->GetSignedSpacing()<<std::endl; // std::cout<<"Moving extract origin: "<<movingExtractor->GetOutput()->GetOrigin()<<std::endl; -// std::cout<<"Moving extract spacing: "<<movingExtractor->GetOutput()->GetSpacing()<<std::endl; +// std::cout<<"Moving extract spacing: "<<movingExtractor->GetOutput()->GetSignedSpacing()<<std::endl; // typedef otb::ImageFileWriter<FixedImageType> FixedWriterType; // typedef otb::ImageFileWriter<MovingImageType> MovingWriterType; diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.txx b/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.txx index b97423284516b6351e8c1588bb9c7a51b4a09db5..8a90738d4ac1291df6562959663d7e0061833647 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.txx @@ -177,7 +177,7 @@ DisparityMapTo3DFilter<TDisparityImage,TOutputImage,TEpipolarGridImage,TMaskImag // copy also origin and spacing outputPtr->SetOrigin(horizDisp->GetOrigin()); - outputPtr->SetSpacing(horizDisp->GetSpacing()); + outputPtr->SetSignedSpacing(horizDisp->GetSignedSpacing()); } template <class TDisparityImage, class TOutputImage, diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.txx b/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.txx index 3bdf6bcc34835ed215d494775f03f5ffea519a84..96965071cfab0f5b6470b0c80c6e805567f07688 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.txx @@ -339,7 +339,7 @@ DisparityMapToDEMFilter<TDisparityImage,TInputImage,TOutputDEMImage,TEpipolarGri typename TOutputDEMImage::SpacingType outSpacing; outSpacing[0] = 57.295779513 * m_DEMGridStep / (6378137.0 * vcl_cos((box_ymin + box_ymax) * 0.5 * 0.01745329251)); outSpacing[1] = -57.295779513 * m_DEMGridStep / 6378137.0; - outputPtr->SetSpacing(outSpacing); + outputPtr->SetSignedSpacing(outSpacing); // Choose origin typename TOutputDEMImage::PointType outOrigin; @@ -381,7 +381,7 @@ DisparityMapToDEMFilter<TDisparityImage,TInputImage,TOutputDEMImage,TEpipolarGri typename DEMImageType::RegionType outRegion = outputDEM->GetRequestedRegion(); typename DEMImageType::PointType outOrigin = outputDEM->GetOrigin(); - typename DEMImageType::SpacingType outSpacing = outputDEM->GetSpacing(); + typename DEMImageType::SpacingType outSpacing = outputDEM->GetSignedSpacing(); RSTransformType::Pointer groundToLeftTransform = RSTransformType::New(); groundToLeftTransform->SetOutputKeywordList(leftSensor->GetImageKeywordlist()); diff --git a/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.txx b/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.txx index 1261e6baf10ec446c3f790c33ff01dcd23575dbc..b19bcedfb10e6f718e82fbefce62a57b837e9017 100644 --- a/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.txx @@ -145,7 +145,7 @@ FineRegistrationImageFilter<TInputImage, TOutputCorrelation, TOutputDisplacement // Update size and spacing according to grid step InputImageRegionType largestRegion = outputPtr->GetLargestPossibleRegion(); SizeType outputSize = largestRegion.GetSize(); - SpacingType outputSpacing = outputPtr->GetSpacing(); + SpacingType outputSpacing = outputPtr->GetSignedSpacing(); for(unsigned int dim = 0; dim < TOutputCorrelation::ImageDimension; ++dim) { @@ -154,8 +154,8 @@ FineRegistrationImageFilter<TInputImage, TOutputCorrelation, TOutputDisplacement } // Set spacing - outputPtr->SetSpacing(outputSpacing); - outputFieldPtr->SetSpacing(outputSpacing); + outputPtr->SetSignedSpacing(outputSpacing); + outputFieldPtr->SetSignedSpacing(outputSpacing); // Set largest region size largestRegion.SetSize(outputSize); @@ -406,7 +406,7 @@ FineRegistrationImageFilter<TInputImage, TOutputCorrelation, TOutputDisplacement SpacingType localOffset = m_InitialOffset; // Get fixed image spacing - SpacingType fixedSpacing = fixedPtr->GetSpacing(); + SpacingType fixedSpacing = fixedPtr->GetSignedSpacing(); // Walk the images diff --git a/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.txx b/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.txx index 125285d1a63d3cf0f2110d9aa7735a09ec9a0d27..511538896ba3cce58010166c71de44577ab047bb 100644 --- a/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.txx @@ -216,10 +216,10 @@ MultiDisparityMapTo3DFilter<TDisparityImage,TOutputImage,TMaskImage,TResidueImag // copy also origin and spacing outputPtr->SetOrigin(horizDisp->GetOrigin()); - outputPtr->SetSpacing(horizDisp->GetSpacing()); + outputPtr->SetSignedSpacing(horizDisp->GetSignedSpacing()); residuePtr->SetOrigin(horizDisp->GetOrigin()); - residuePtr->SetSpacing(horizDisp->GetSpacing()); + residuePtr->SetSignedSpacing(horizDisp->GetSignedSpacing()); if (this->m_ReferenceKeywordList.GetSize() > 0) { diff --git a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.txx b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.txx index 893eba21355f6822bd90cc493e0b75ceb78f8026..eb5f1093370b549ac58458e2e3133235cd1a6ad3 100644 --- a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.txx +++ b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.txx @@ -101,7 +101,7 @@ NCCRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField> } // cache fixed image information - m_FixedImageSpacing = this->m_FixedImage->GetSpacing(); + m_FixedImageSpacing = this->m_FixedImage->GetSignedSpacing(); m_FixedImageOrigin = this->m_FixedImage->GetOrigin(); // setup gradient calculator diff --git a/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.txx b/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.txx index fd1333e0de3649ec43c9d291514597a99abb0454..69041e41e2bfbfd8b1dcd0b253d1e2af77754cfc 100644 --- a/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.txx @@ -343,17 +343,17 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> outVDispPtr->SetLargestPossibleRegion(outputLargest); // Adapt spacing - SpacingType outSpacing = inLeftPtr->GetSpacing(); + SpacingType outSpacing = inLeftPtr->GetSignedSpacing(); outSpacing[0] *= static_cast<double>(this->m_Step); outSpacing[1] *= static_cast<double>(this->m_Step); - outMetricPtr->SetSpacing(outSpacing); - outHDispPtr->SetSpacing(outSpacing); - outVDispPtr->SetSpacing(outSpacing); + outMetricPtr->SetSignedSpacing(outSpacing); + outHDispPtr->SetSignedSpacing(outSpacing); + outVDispPtr->SetSignedSpacing(outSpacing); // Adapt origin PointType outOrigin = inLeftPtr->GetOrigin(); - SpacingType inSpacing = inLeftPtr->GetSpacing(); + SpacingType inSpacing = inLeftPtr->GetSignedSpacing(); outOrigin[0] += inSpacing[0] * static_cast<double>(this->m_GridIndex[0]); outOrigin[1] += inSpacing[1] * static_cast<double>(this->m_GridIndex[1]); diff --git a/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.txx b/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.txx index 72346289ec9036e4e70a43fc6f1ed0c0577f3a79..a8b9426849f1f271692c9e9087cbf4dce2930dda 100644 --- a/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.txx @@ -429,8 +429,8 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> outVDispPtr->CopyInformation(inHDispPtr); // Check the size of the input disparity maps (possible subsampled grid) - SpacingType leftSpacing = inLeftPtr->GetSpacing(); - SpacingType dispSpacing = inHDispPtr->GetSpacing(); + SpacingType leftSpacing = inLeftPtr->GetSignedSpacing(); + SpacingType dispSpacing = inHDispPtr->GetSignedSpacing(); PointType leftOrigin = inLeftPtr->GetOrigin(); PointType dispOrigin = inHDispPtr->GetOrigin(); diff --git a/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.txx b/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.txx index 75c837693780c772d4cb2111f141a509290608c1..66009e3ff6b84b8a6265d3495ec49a6889835e63 100644 --- a/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.txx +++ b/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.txx @@ -76,7 +76,7 @@ PointSetToDisplacementFieldGenerator<TPointSet, TDisplacementField> index.Fill(0); largest.SetIndex(index); outputPtr->SetRegions(largest); - outputPtr->SetSpacing(m_OutputSpacing); + outputPtr->SetSignedSpacing(m_OutputSpacing); outputPtr->SetOrigin(m_OutputOrigin); // Force the displacement field to have vector pixel of size 2. outputPtr->SetNumberOfComponentsPerPixel(2); diff --git a/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx b/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx index 488826d45f00d0bb15499446e45119f7b009b054..fca8ff2a53c711a2dcb7d6f68fd32dc231a17933 100644 --- a/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx +++ b/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx @@ -182,12 +182,12 @@ AdhesionCorrectionFilter<TImage, TMask> ImageRegionType largestRegion = outputPtr->GetLargestPossibleRegion(); SizeType outputSize = largestRegion.GetSize(); m_ImageSize = outputSize; - SpacingType outputSpacing = outputPtr->GetSpacing(); + SpacingType outputSpacing = outputPtr->GetSignedSpacing(); // Set spacing - outputPtr->SetSpacing(outputSpacing); - outputMaskPtr->SetSpacing(outputSpacing); - outputriskedgesPtr->SetSpacing(outputSpacing); + outputPtr->SetSignedSpacing(outputSpacing); + outputMaskPtr->SetSignedSpacing(outputSpacing); + outputriskedgesPtr->SetSignedSpacing(outputSpacing); // Set largest region size largestRegion.SetSize(outputSize); diff --git a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx index 4d0a45c5d715f1c8843433567132884b8526c402..811a24f35b4cdf5d7151b7e7aed6826b86f03483 100644 --- a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx +++ b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx @@ -242,7 +242,7 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::SetOutputPara //std::cout<<" GrisStep "<<m_DEMGridStep<<std::endl; outSpacing[0] = 57.295779513 * m_DEMGridStep / (6378137.0 * vcl_cos((box_ymin + box_ymax) * 0.5 * 0.01745329251)); outSpacing[1] = -57.295779513 * m_DEMGridStep / 6378137.0; - outputPtr->SetSpacing(outSpacing); + outputPtr->SetSignedSpacing(outSpacing); // Choose origin typename TOutputDEMImage::PointType outOrigin; @@ -278,7 +278,7 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::SetOutputPara // genericRSEstimator->SetInputProjectionRef( static_cast<std::string>(otb::GeoInformationConversion::ToWKT(4326))); genericRSEstimator->SetOutputProjectionRef(m_ProjectionRef); genericRSEstimator->Compute(); - outputPtr->SetSpacing(genericRSEstimator->GetOutputSpacing()); + outputPtr->SetSignedSpacing(genericRSEstimator->GetOutputSpacing()); outputPtr->SetOrigin(genericRSEstimator->GetOutputOrigin()); // Compute output size @@ -311,7 +311,7 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::GenerateOutpu if (this->m_OutputParametersFrom3DMap == -2) { outputPtr->SetOrigin(m_OutputOrigin); - outputPtr->SetSpacing(m_OutputSpacing); + outputPtr->SetSignedSpacing(m_OutputSpacing); typename TOutputDEMImage::RegionType outRegion; outRegion.SetIndex(m_OutputStartIndex); @@ -357,7 +357,7 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::GenerateInput typename TOutputDEMImage::RegionType outRegion = outputDEM->GetRequestedRegion(); typename TOutputDEMImage::PointType outOrigin = outputDEM->GetOrigin(); - typename TOutputDEMImage::SpacingType outSpacing = outputDEM->GetSpacing(); + typename TOutputDEMImage::SpacingType outSpacing = outputDEM->GetSignedSpacing(); // up left at elevation min TDPointType corners[8]; @@ -402,12 +402,12 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::GenerateInput RSTransformType::Pointer groundToSensorTransform = RSTransformType::New(); //groundToSensorTransform->SetInputKeywordList(outputDEM->GetImageKeywordlist()); //groundToSensorTransform->SetInputOrigin(outputDEM->GetOrigin()); - //groundToSensorTransform->SetInputSpacing(outputDEM->GetSpacing()); + //groundToSensorTransform->SetInputSpacing(outputDEM->GetSignedSpacing()); groundToSensorTransform->SetInputProjectionRef(m_ProjectionRef); groundToSensorTransform->SetOutputKeywordList(imgPtr->GetImageKeywordlist()); groundToSensorTransform->SetOutputOrigin(imgPtr->GetOrigin()); - groundToSensorTransform->SetOutputSpacing(imgPtr->GetSpacing()); + groundToSensorTransform->SetOutputSpacing(imgPtr->GetSignedSpacing()); groundToSensorTransform->InstantiateTransform(); typename T3DImage::RegionType mapRegion = imgPtr->GetLargestPossibleRegion(); @@ -568,7 +568,7 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::ThreadedGener typename OutputImageType::PointType pointRefStep; typename OutputImageType::RegionType requestedRegion = outputPtr->GetRequestedRegion(); -// typename TOutputDEMImage::SpacingType step = outputPtr->GetSpacing(); +// typename TOutputDEMImage::SpacingType step = outputPtr->GetSignedSpacing(); //convert requested region to Long/Lat @@ -606,7 +606,7 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::ThreadedGener typename InputMapType::PointType origin; origin = imgPtr->GetOrigin(); typename InputMapType::SpacingType spacing; - spacing = imgPtr->GetSpacing(); + spacing = imgPtr->GetSignedSpacing(); if (static_cast<unsigned int> (threadId) < m_NumberOfSplit[k]) { diff --git a/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.txx b/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.txx index 94c7c434d8c1c123fd8a8093dd34348f8b55962f..3806958e493543fa82a298a2f660a91d99a0dd18 100644 --- a/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.txx +++ b/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.txx @@ -159,9 +159,9 @@ StereorectificationDisplacementFieldSource<TInputImage, TOutputImage> // First, spacing : choose a square spacing, SpacingType outputSpacing; outputSpacing.Fill(m_Scale * m_GridStep); - double mean_spacing=0.5*(vcl_abs(m_LeftImage->GetSpacing()[0])+vcl_abs(m_LeftImage->GetSpacing()[1])); - //double ratio_x = mean_spacing / vcl_abs(m_LeftImage->GetSpacing()[0]); - //double ratio_y = mean_spacing / vcl_abs(m_LeftImage->GetSpacing()[1]); + double mean_spacing=0.5*(vcl_abs(m_LeftImage->GetSignedSpacing()[0])+vcl_abs(m_LeftImage->GetSignedSpacing()[1])); + //double ratio_x = mean_spacing / vcl_abs(m_LeftImage->GetSignedSpacing()[0]); + //double ratio_y = mean_spacing / vcl_abs(m_LeftImage->GetSignedSpacing()[1]); outputSpacing[0]*=mean_spacing; outputSpacing[1]*=mean_spacing; @@ -240,14 +240,14 @@ StereorectificationDisplacementFieldSource<TInputImage, TOutputImage> // First we compute coordinates of the 4 corners (we omit ulx which // coordinates are {0,0}) - double urx = ux * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSpacing()[0]; - double ury = vx * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSpacing()[0]; - double llx = uy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSpacing()[1]; - double lly = vy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSpacing()[1]; - double lrx = ux * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSpacing()[0] - + uy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSpacing()[1]; - double lry = vx * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSpacing()[0] - + vy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSpacing()[1]; + double urx = ux * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSignedSpacing()[0]; + double ury = vx * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSignedSpacing()[0]; + double llx = uy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSignedSpacing()[1]; + double lly = vy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSignedSpacing()[1]; + double lrx = ux * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSignedSpacing()[0] + + uy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSignedSpacing()[1]; + double lry = vx * m_LeftImage->GetLargestPossibleRegion().GetSize()[0] * m_LeftImage->GetSignedSpacing()[0] + + vy * m_LeftImage->GetLargestPossibleRegion().GetSize()[1] * m_LeftImage->GetSignedSpacing()[1]; // Bounding box (this time we do not omit ulx) double minx = std::min(std::min(std::min(urx,llx),lrx),0.); @@ -279,8 +279,8 @@ StereorectificationDisplacementFieldSource<TInputImage, TOutputImage> leftDFPtr->SetLargestPossibleRegion(outputLargestRegion); rightDFPtr->SetLargestPossibleRegion(outputLargestRegion); - leftDFPtr->SetSpacing(outputSpacing); - rightDFPtr->SetSpacing(outputSpacing); + leftDFPtr->SetSignedSpacing(outputSpacing); + rightDFPtr->SetSignedSpacing(outputSpacing); leftDFPtr->SetNumberOfComponentsPerPixel(2); rightDFPtr->SetNumberOfComponentsPerPixel(2); @@ -333,7 +333,7 @@ StereorectificationDisplacementFieldSource<TInputImage, TOutputImage> double localElevation = otb::DEMHandler::Instance()->GetDefaultHeightAboveEllipsoid(); // Use the mean spacing as before - double mean_spacing=0.5*(vcl_abs(m_LeftImage->GetSpacing()[0])+vcl_abs(m_LeftImage->GetSpacing()[1])); + double mean_spacing=0.5*(vcl_abs(m_LeftImage->GetSignedSpacing()[0])+vcl_abs(m_LeftImage->GetSignedSpacing()[1])); // Initialize currentPoint1 = m_OutputOriginInLeftImage; diff --git a/Modules/Remote/Mosaic.remote.cmake b/Modules/Remote/Mosaic.remote.cmake index 035a5bc8101097fe9adbd3b7fc852198abba7a92..d26b730b8a570a38b6c611128021e27782f717d9 100644 --- a/Modules/Remote/Mosaic.remote.cmake +++ b/Modules/Remote/Mosaic.remote.cmake @@ -5,5 +5,5 @@ A more detailed description can be found on the project website: https://github.com/remicres/otb-mosaic " GIT_REPOSITORY https://github.com/remicres/otb-mosaic.git - GIT_TAG 56426908db01f33a5b96311e2a7eaac30ecd8e5d + GIT_TAG 1d557e3c69cb11428f5dbf7c7039dc966dd8c51e ) diff --git a/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.txx b/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.txx index 19901747c48983d2d454b2f545e709917e4742b5..1556cc70e6a4488307d9b5f7669db731aba55892 100644 --- a/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.txx +++ b/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.txx @@ -138,10 +138,10 @@ PersistentConnectedComponentSegmentationOBIAToVectorDataFilter<TVImage, TLabelIm typename TransformType::ParametersType params; params.SetSize(6); - params[0] = this->GetInput()->GetSpacing()[0]; + params[0] = this->GetInput()->GetSignedSpacing()[0]; params[1] = 0; params[2] = 0; - params[3] = this->GetInput()->GetSpacing()[1]; + params[3] = this->GetInput()->GetSignedSpacing()[1]; params[4] = this->GetInput()->GetOrigin()[0]; params[5] = this->GetInput()->GetOrigin()[1]; diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.txx b/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.txx index 8bce44f877fd70e0f168c407eca4381cc66f5022..7bfeed219da832ca95fbe648759fec1df2a89d16 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.txx @@ -187,10 +187,10 @@ LabelImageToOGRDataSourceFilter<TInputImage> IndexType bufferIndexOrigin = this->GetInput()->GetBufferedRegion().GetIndex(); OriginType bufferOrigin; this->GetInput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInput()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInput()->GetSpacing()[1]; - geoTransform[1] = this->GetInput()->GetSpacing()[0]; - geoTransform[5] = this->GetInput()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInput()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInput()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetInput()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetInput()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters if (projSize == 0) { @@ -257,10 +257,10 @@ LabelImageToOGRDataSourceFilter<TInputImage> // the spacing is unchanged, the origin is relative to the buffered region bufferIndexOrigin = this->GetInputMask()->GetBufferedRegion().GetIndex(); this->GetInputMask()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInputMask()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInputMask()->GetSpacing()[1]; - geoTransform[1] = this->GetInputMask()->GetSpacing()[0]; - geoTransform[5] = this->GetInputMask()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInputMask()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInputMask()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetInputMask()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetInputMask()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters if (projSize == 0) { diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.txx b/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.txx index 7374c85c42ef49676dca2b65961350a02ec5d9e2..698b326eb9cb176344c74c07811e5e730976dc1d 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.txx @@ -167,10 +167,10 @@ LabelImageToVectorDataFilter<TInputImage, TPrecision> IndexType bufferIndexOrigin = this->GetInput()->GetBufferedRegion().GetIndex(); OriginType bufferOrigin; this->GetInput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInput()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInput()->GetSpacing()[1]; - geoTransform[1] = this->GetInput()->GetSpacing()[0]; - geoTransform[5] = this->GetInput()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInput()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInput()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetInput()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetInput()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters if (projSize == 0) { @@ -237,10 +237,10 @@ LabelImageToVectorDataFilter<TInputImage, TPrecision> // the spacing is unchanged, the origin is relative to the buffered region bufferIndexOrigin = this->GetInputMask()->GetBufferedRegion().GetIndex(); this->GetInputMask()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInputMask()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInputMask()->GetSpacing()[1]; - geoTransform[1] = this->GetInputMask()->GetSpacing()[0]; - geoTransform[5] = this->GetInputMask()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInputMask()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInputMask()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetInputMask()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetInputMask()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters if (projSize == 0) { diff --git a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h index d6dff7de76ffb0ca02e2ebb0b77545b729ba3a56..421075334f14fb41a2ebc4b9f4a826f4f44e8e82 100644 --- a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h +++ b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h @@ -109,7 +109,7 @@ public: itkGetConstReferenceMacro(OutputOrigin, OutputOriginType); /** Set the spacing (size of a pixel) of the output image. - * \sa GetSpacing() + * \sa GetSignedSpacing() */ virtual void SetOutputSpacing(const OutputSpacingType& spacing); virtual void SetOutputSpacing(const double spacing[2]); diff --git a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx index 6dbb4b8bb7f532f5ddd7bcda468217e113390e49..ef069d7611504b432fc256d298afbb3a2bd489dd 100644 --- a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx @@ -27,6 +27,7 @@ #include "otbImageMetadataInterfaceFactory.h" #include "itkMetaDataObject.h" #include "otbMetaDataKey.h" +#include "otbImage.h" #include "gdal_alg.h" #include "stdint.h" //needed for uintptr_t @@ -126,7 +127,7 @@ OGRDataSourceToLabelImageFilter<TOutputImage> ::SetOutputParametersFromImage(const ImageBaseType * image) { this->SetOutputOrigin ( image->GetOrigin() ); - this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputSpacing ( internal::GetSignedSpacing( image ) ); this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() ); ImageMetadataInterfaceBase::Pointer imi = ImageMetadataInterfaceFactory::CreateIMI(image->GetMetaDataDictionary()); @@ -153,7 +154,7 @@ OGRDataSourceToLabelImageFilter<TOutputImage> outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); // Set spacing and origin - outputPtr->SetSpacing(m_OutputSpacing); + outputPtr->SetSignedSpacing(m_OutputSpacing); outputPtr->SetOrigin(m_OutputOrigin); itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary(); @@ -229,10 +230,10 @@ OGRDataSourceToLabelImageFilter<TOutputImage>::GenerateData() OutputIndexType bufferIndexOrigin = bufferedRegion.GetIndex(); OutputOriginType bufferOrigin; this->GetOutput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSpacing()[1]; - geoTransform[1] = this->GetOutput()->GetSpacing()[0]; - geoTransform[5] = this->GetOutput()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetOutput()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetOutput()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters geoTransform[2] = 0.; diff --git a/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.txx b/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.txx index 69752f7a68e9fbf685307198a43dcd8fe1460aba..58f817ce10f036705dc664f3db19fa2f5eaf1122 100644 --- a/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.txx @@ -178,10 +178,10 @@ RasterizeVectorDataFilter<TVectorData, TInputImage, TOutputImage>::GenerateData( InputIndexType bufferIndexOrigin = bufferedRegion.GetIndex(); InputPointType bufferOrigin; this->GetOutput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSpacing()[1]; - geoTransform[1] = this->GetOutput()->GetSpacing()[0]; - geoTransform[5] = this->GetOutput()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetOutput()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetOutput()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters geoTransform[2] = 0.; diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h index e8b7b0d667454e77d197ee68b2f8b156d1fa8e5b..c7a0627250ab9516d93412d7e55fd81e0e5e1cb6 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h @@ -107,7 +107,7 @@ public: itkGetConstReferenceMacro(OutputOrigin, OutputOriginType); /** Set the spacing (size of a pixel) of the output image. - * \sa GetSpacing() + * \sa GetSignedSpacing() */ virtual void SetOutputSpacing(const OutputSpacingType& spacing); virtual void SetOutputSpacing(const double spacing[2]); diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.txx b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.txx index 20ce77a9d1206e14523654150721d3bb466c4352..f874cd69880ac0b689f3827dfaf8740fa126a471 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.txx @@ -29,6 +29,7 @@ #include "otbGdalDataTypeBridge.h" #include "otbImageMetadataInterfaceBase.h" #include "otbImageMetadataInterfaceFactory.h" +#include "otbImage.h" namespace otb { @@ -127,7 +128,7 @@ VectorDataToLabelImageFilter<TVectorData, TOutputImage> ::SetOutputParametersFromImage(const ImageBaseType * src) { this->SetOutputOrigin ( src->GetOrigin() ); - this->SetOutputSpacing ( src->GetSpacing() ); + this->SetOutputSpacing ( internal::GetSignedSpacing(src) ); this->SetOutputSize ( src->GetLargestPossibleRegion().GetSize() ); ImageMetadataInterfaceBase::Pointer imi = ImageMetadataInterfaceFactory::CreateIMI(src->GetMetaDataDictionary()); this->SetOutputProjectionRef(imi->GetProjectionRef()); @@ -152,7 +153,7 @@ VectorDataToLabelImageFilter<TVectorData, TOutputImage> outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); // Set spacing and origin - outputPtr->SetSpacing(m_OutputSpacing); + outputPtr->SetSignedSpacing(m_OutputSpacing); outputPtr->SetOrigin(m_OutputOrigin); itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary(); @@ -301,10 +302,10 @@ VectorDataToLabelImageFilter<TVectorData, TOutputImage>::GenerateData() OutputIndexType bufferIndexOrigin = bufferedRegion.GetIndex(); OutputOriginType bufferOrigin; this->GetOutput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSpacing()[0]; - geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSpacing()[1]; - geoTransform[1] = this->GetOutput()->GetSpacing()[0]; - geoTransform[5] = this->GetOutput()->GetSpacing()[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSignedSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSignedSpacing()[1]; + geoTransform[1] = this->GetOutput()->GetSignedSpacing()[0]; + geoTransform[5] = this->GetOutput()->GetSignedSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters geoTransform[2] = 0.; diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h index 8048c31bdaf5afcdddcd5b2e853ffb9bd8546460..924b6ff894961d86f2153036444bf8baf3f42fae 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h @@ -147,7 +147,7 @@ public: itkGetConstReferenceMacro(StartIndex, IndexType); itkSetMacro(StartIndex, IndexType); /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetSpacing(const SpacingType& spacing); virtual void SetSpacing(const double spacing[2]); virtual void SetSpacing(const float spacing[2]); diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h index 8bf4d55a508d55bc2dd9f60893241bd80647caa8..acedfcebebbc1093331c8be85a22ec28bab0b596 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h @@ -162,7 +162,7 @@ public: ; itkSetMacro(StartIndex, IndexType) ; /** Set the spacing (size of a pixel) of the vector data. - * \sa GetSpacing() */ + * \sa GetSignedSpacing() */ virtual void SetSpacing(const SpacingType& spacing); virtual void SetSpacing(const double spacing[2]); virtual void SetSpacing(const float spacing[2]); diff --git a/Modules/Segmentation/Conversion/test/otbLabelMapToVectorDataFilter.cxx b/Modules/Segmentation/Conversion/test/otbLabelMapToVectorDataFilter.cxx index df1429d3526eabc0a39804959af064a273b4a1d9..f32a91eb67af8d4ee91e8ea73f42bff54dc86d56 100644 --- a/Modules/Segmentation/Conversion/test/otbLabelMapToVectorDataFilter.cxx +++ b/Modules/Segmentation/Conversion/test/otbLabelMapToVectorDataFilter.cxx @@ -79,7 +79,7 @@ int otbLabelMapToVectorDataFilter(int argc, char * argv[]) VectorDataFilterType::Pointer vectorDataProjection = VectorDataFilterType::New(); vectorDataProjection->SetInputOrigin(lreader->GetOutput()->GetOrigin()); - vectorDataProjection->SetInputSpacing(lreader->GetOutput()->GetSpacing()); + vectorDataProjection->SetInputSpacing(lreader->GetOutput()->GetSignedSpacing()); vectorDataProjection->SetInput(MyFilter->GetOutput()); writer->SetFileName(outfname); diff --git a/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.txx b/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.txx index 7c8db05e0414b5a7cd63256c2c125ad95af76e42..5ecbfa89bd72e42bb82acdc40ec8b809bbaeef31 100644 --- a/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.txx +++ b/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.txx @@ -133,7 +133,7 @@ PersistentImageToOGRLayerSegmentationFilter<TImageType, TSegmentationFilter> OGRDataSourcePointerType tmpDS = const_cast<OGRDataSourceType *>(labelImageToOGRDataFilter->GetOutput()); OGRLayerType tmpLayer = tmpDS->GetLayer(0); - const typename InputImageType::SpacingType inSpacing = this->GetInput()->GetSpacing(); + const typename InputImageType::SpacingType inSpacing = this->GetInput()->GetSignedSpacing(); const double tol = m_SimplificationTolerance * std::max(vcl_abs(inSpacing[0]),vcl_abs(inSpacing[1])); typename OGRLayerType::iterator featIt = tmpLayer.begin(); @@ -160,7 +160,7 @@ PersistentImageToOGRLayerSegmentationFilter<TImageType, TSegmentationFilter> { double area = static_cast<const OGRPolygon *>((*featIt).GetGeometry())->get_Area(); //convert into pixel coordinates - typename InputImageType::SpacingType spacing = this->GetInput()->GetSpacing(); + typename InputImageType::SpacingType spacing = this->GetInput()->GetSignedSpacing(); double pixelsArea = area / (vcl_abs(spacing[0]*spacing[1])); otbMsgDebugMacro(<<"DN = "<<field.GetValue<int>()<<", area = "<<pixelsArea); if( pixelsArea < m_MinimumObjectSize ) diff --git a/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx b/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx index 212a0f883915ac7b78ef829aaf3a75cb8918eaba..c8db8c9d6fe02cc109b0b25b1c87eb117a9c2919 100644 --- a/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx +++ b/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx @@ -155,7 +155,7 @@ TransformToDisplacementFieldSource< TOutputImage, TTransformPrecisionType > } this->SetOutputOrigin( image->GetOrigin() ); - this->SetOutputSpacing( image->GetSpacing() ); + this->SetOutputSpacing( image->GetSignedSpacing() ); this->SetOutputDirection( image->GetDirection() ); this->SetOutputRegion( image->GetLargestPossibleRegion() ); } // end SetOutputParametersFromImage() @@ -352,7 +352,7 @@ TransformToDisplacementFieldSource< TOutputImage, TTransformPrecisionType > outputPtr->SetLargestPossibleRegion(m_OutputRegion); - outputPtr->SetSpacing(m_OutputSpacing); + outputPtr->SetSignedSpacing(m_OutputSpacing); outputPtr->SetOrigin(m_OutputOrigin); outputPtr->SetDirection(m_OutputDirection); } // end GenerateOutputInformation() diff --git a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx index c84c6d94aac1b29003f283b02161ada346a457eb..e5872ddce4bd35ab2e00cbf98b97fac77dc7a22c 100644 --- a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx +++ b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx @@ -133,7 +133,7 @@ UnaryFunctorImageFilter< TInputImage, TOutputImage, TFunction > } // set the spacing and origin - outputPtr->SetSpacing(outputSpacing); + outputPtr->SetSpacing( outputSpacing ); outputPtr->SetOrigin(outputOrigin); outputPtr->SetDirection(outputDirection); outputPtr->SetNumberOfComponentsPerPixel( // propagate vector length info diff --git a/Modules/Visualization/Ice/src/otbGlImageActor.cxx b/Modules/Visualization/Ice/src/otbGlImageActor.cxx index 5bb1f06881dd91c94a6b9a6ba6ea8ca578fd7ab4..dc14f9542b6c25e53ca7d55ceaa54c4c9256e0f3 100644 --- a/Modules/Visualization/Ice/src/otbGlImageActor.cxx +++ b/Modules/Visualization/Ice/src/otbGlImageActor.cxx @@ -154,7 +154,7 @@ void GlImageActor::Initialize(const std::string & filename) } m_Origin = m_FileReader->GetOutput()->GetOrigin(); - m_Spacing = m_FileReader->GetOutput()->GetSpacing(); + m_Spacing = m_FileReader->GetOutput()->GetSignedSpacing(); m_NumberOfComponents = m_FileReader->GetOutput()->GetNumberOfComponentsPerPixel(); unsigned int ovrCount = m_FileReader->GetOverviewsCount(); @@ -706,7 +706,7 @@ void GlImageActor::ImageRegionToViewportQuad(const RegionType & region, PointTyp m_FileReader->GetOutput()->TransformContinuousIndexToPhysicalPoint(clr,ilr); // Take into account that Origin refers to center of first pixel - SpacingType spacing = m_FileReader->GetOutput()->GetSpacing(); + SpacingType spacing = m_FileReader->GetOutput()->GetSignedSpacing(); iul[0]-=0.5*spacing[0]; iul[1]-=0.5*spacing[1]; iur[0]+=0.5*spacing[0]; diff --git a/Modules/Visualization/Ice/src/otbNonOptGlImageActor.cxx b/Modules/Visualization/Ice/src/otbNonOptGlImageActor.cxx index e9ac3174aad021a3386685d5bcdec698cedce8e1..b1ba5e1274fe6c7cf32730fb2e78c42702601d46 100644 --- a/Modules/Visualization/Ice/src/otbNonOptGlImageActor.cxx +++ b/Modules/Visualization/Ice/src/otbNonOptGlImageActor.cxx @@ -101,7 +101,7 @@ void NonOptGlImageActor::Initialize(const std::string & filename) } m_Origin = m_FileReader->GetOutput()->GetOrigin(); - m_Spacing = m_FileReader->GetOutput()->GetSpacing(); + m_Spacing = m_FileReader->GetOutput()->GetSignedSpacing(); m_NumberOfComponents = m_FileReader->GetOutput()->GetNumberOfComponentsPerPixel(); unsigned int ovrCount = m_FileReader->GetOverviewsCount(); diff --git a/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h b/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h index 9b9c2632aadf573a2db636b6da7dbc7c78674471..8eff3030ebf21d1ffe3400a46551b6ac09c513d4 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h @@ -49,7 +49,7 @@ #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility #include "otbImageMetadataInterfaceBase.h" #endif //tag=QT4-boost-compatibility - +#include "otbImage.h" // Needed to get otb::internal::Get/SetSignedSpacing() // // Monteverdi includes (sorted by alphabetic order) #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility @@ -263,7 +263,7 @@ public: /** */ - inline const SpacingType& GetSpacing() const; + inline const SpacingType GetSpacing() const; /** */ @@ -479,7 +479,8 @@ AbstractImageModel m_CurrentLod = lod; // if everything ok emit the new spacing of the current lod - emit SpacingChanged(ToImageBase()->GetSpacing()); + emit SpacingChanged( otb::internal::GetSignedSpacing( + static_cast< ImageBaseType * > ( ToImageBase() ) ) ); } /*****************************************************************************/ @@ -554,13 +555,14 @@ AbstractImageModel /*****************************************************************************/ inline -const SpacingType& +const SpacingType AbstractImageModel ::GetSpacing() const { assert( !ToImageBase().IsNull() ); - return ToImageBase()->GetSpacing(); + return otb::internal::GetSignedSpacing( + static_cast< ImageBaseType const * >( ToImageBase() ) ); } /*****************************************************************************/ diff --git a/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx b/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx index 378763d26e561bbc8bae2c0c51ac923dd80a3e58..558450de9c80b6d2f2ca2fafab6eaf32e3bcc9fc 100644 --- a/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx +++ b/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx @@ -112,7 +112,7 @@ VectorImageModel m_ImageFileReader->SetFileName( QFile::encodeName( GetFilename() ) ); m_ImageFileReader->GetOutput()->UpdateOutputInformation(); - + // Retrieve the list of Lod from file m_LodCount = m_ImageFileReader->GetOverviewsCount(); @@ -121,7 +121,7 @@ VectorImageModel m_ImageFileReader->GetOutput()->GetLargestPossibleRegion(); // Remember native spacing - m_NativeSpacing = m_ImageFileReader->GetOutput()->GetSpacing(); + m_NativeSpacing = m_ImageFileReader->GetOutput()->GetSignedSpacing(); // qDebug() // << filename @@ -130,7 +130,7 @@ VectorImageModel // << m_ImageFileReader->GetOutput()->GetOrigin()[ 1 ] // << "\nspacing:" << m_NativeSpacing[ 0 ] << m_NativeSpacing[ 1 ]; - + // Setup GenericRSTransform m_ToWgs84 = otb::GenericRSTransform<>::New(); m_ToWgs84->SetInputDictionary(m_ImageFileReader->GetOutput()->GetMetaDataDictionary()); @@ -140,11 +140,11 @@ VectorImageModel //Compute estimated spacing here //m_EstimatedGroundSpacing m_EstimatedGroundSpacing = m_NativeSpacing; - + typedef otb::GroundSpacingImageFunction<VectorImageType> GroundSpacingImageType; GroundSpacingImageType::Pointer GroundSpacing = GroundSpacingImageType::New(); GroundSpacing->SetInputImage(m_ImageFileReader->GetOutput()); - + if (m_ToWgs84->IsUpToDate()) { if (m_ToWgs84->GetTransformAccuracy() != otb::Projection::UNKNOWN) @@ -301,7 +301,7 @@ VectorImageModel static_cast< VectorImageSettings * const >( buildContext->m_Settings ); -// Fetch the no data flags if any + // Fetch the no data flags if any otb::ImageMetadataInterfaceBase::ConstPointer metaData( GetMetaDataInterface() ); @@ -316,7 +316,7 @@ VectorImageModel GetProperties()->SetNoDataEnabled(true); GetProperties()->SetNoData(values[0]); } - + // // Step #1: Perform pre-process of AbstractModel::BuildModel() // pattern. @@ -348,7 +348,7 @@ VectorImageModel // Remember image properties. if( buildContext->m_Properties!=NULL ) SetProperties( *buildContext->m_Properties ); - + // Apply settings to child QuicklookModel. ApplySettings(); } @@ -479,7 +479,7 @@ VectorImageModel::ComputeBestLod( double zoomFactor ) const } /*****************************************************************************/ -unsigned int +unsigned int VectorImageModel::Closest( double invZoomfactor, unsigned int lodCount ) { @@ -554,7 +554,7 @@ VectorImageModel // Update m_ImageFileReader m_ImageFileReader->SetFileName( QFile::encodeName( lodFilename ).constData() ); m_ImageFileReader->GetOutput()->UpdateOutputInformation(); - + // (Always) Update m_Image reference. m_Image = m_ImageFileReader->GetOutput(); } @@ -594,17 +594,17 @@ VectorImageModel IndexType centerIndex; centerIndex[0] = GetNativeLargestRegion().GetIndex()[0] + GetNativeLargestRegion().GetSize(0)/2; centerIndex[1] = GetNativeLargestRegion().GetIndex()[1] + GetNativeLargestRegion().GetSize(1)/2; - + // - // Compute the physical coordinates of the center pixel + // Compute the physical coordinates of the center pixel PointType centerPoint; centerPoint[0] = (centerIndex[0] * GetNativeSpacing()[0] ) + GetOrigin()[0]; centerPoint[1] = (centerIndex[1] * GetNativeSpacing()[1] ) + GetOrigin()[1]; - + // lat / long PointType wgs84; wgs84 = GetGenericRSTransform()->TransformPoint(centerPoint); - + // get placename otb::CoordinateToName::Pointer coordinateToName = otb::CoordinateToName::New(); coordinateToName->SetLonLat(wgs84); @@ -612,13 +612,13 @@ VectorImageModel // get the placename - Country (if any) std::ostringstream oss; - + std::string placeName = coordinateToName->GetPlaceName(); std::string countryName = coordinateToName->GetCountryName(); - + if (placeName != "") oss << placeName; - + if (countryName != "") oss << " - "<< countryName; @@ -792,7 +792,7 @@ VectorImageModel // show the current pixel description only if the mouse cursor is // under the image if( isInsideNativeLargestRegion || 1 ) - { + { // // get the physical coordinates if (!ToImage()->GetProjectionRef().empty()) @@ -813,13 +813,13 @@ VectorImageModel // index in current Lod image IndexType currentLodIndex; - currentLodIndex[0] = (point[ 0 ] - ToImage()->GetOrigin()[0]) / ToImage()->GetSpacing()[0]; - currentLodIndex[1] = (point[ 1 ] - ToImage()->GetOrigin()[1]) / ToImage()->GetSpacing()[1]; - + currentLodIndex[0] = (point[ 0 ] - ToImage()->GetOrigin()[0]) / ToImage()->GetSignedSpacing()[0]; + currentLodIndex[1] = (point[ 1 ] - ToImage()->GetOrigin()[1]) / ToImage()->GetSignedSpacing()[1]; + // // get the LatLong - - if (!ToImage()->GetProjectionRef().empty()) + + if (!ToImage()->GetProjectionRef().empty()) { geoVector.push_back(ToStdString(tr("Geographic(exact)"))); } @@ -835,23 +835,23 @@ VectorImageModel if( ToImage()->GetLargestPossibleRegion().IsInside(currentLodIndex) || 1 ) { // TODO : Is there a better method to detect no geoinfo available ? - if (!ToImage()->GetProjectionRef().empty() || ToImage()->GetImageKeywordlist().GetSize() != 0) + if (!ToImage()->GetProjectionRef().empty() || ToImage()->GetImageKeywordlist().GetSize() != 0) { assert( !m_ToWgs84.IsNull() ); PointType wgs84; wgs84 = m_ToWgs84->TransformPoint( point ); - + ossGeographicLong.precision(6); ossGeographicLat.precision(6); - + ossGeographicLong << std::fixed << wgs84[0]; ossGeographicLat << std::fixed << wgs84[1]; geoVector.push_back(ossGeographicLong.str()); geoVector.push_back(ossGeographicLat.str()); - + double elev = otb::DEMHandler::Instance()->GetHeightAboveEllipsoid(wgs84[0],wgs84[1]); if(elev > -32768) @@ -873,33 +873,33 @@ VectorImageModel /* else { - //handle here the case of QL information display. It + //handle here the case of QL information display. It //displays geographic info when the user is scrolling over the QL // // compute the current ql index - if (!ToImage()->GetProjectionRef().empty() || ToImage()->GetImageKeywordlist().GetSize() != 0) + if (!ToImage()->GetProjectionRef().empty() || ToImage()->GetImageKeywordlist().GetSize() != 0) { - currentLodIndex[0] = (Xpc - GetQuicklookModel()->ToImage()->GetOrigin()[0]) + currentLodIndex[0] = (Xpc - GetQuicklookModel()->ToImage()->GetOrigin()[0]) / GetQuicklookModel()->ToImage()->GetSpacing()[0]; - currentLodIndex[1] = (Ypc - GetQuicklookModel()->ToImage()->GetOrigin()[1]) + currentLodIndex[1] = (Ypc - GetQuicklookModel()->ToImage()->GetOrigin()[1]) / GetQuicklookModel()->ToImage()->GetSpacing()[1]; PointType wgs84; PointType currentLodPoint; GetQuicklookModel()->ToImage()->TransformIndexToPhysicalPoint(currentLodIndex, currentLodPoint); wgs84 = GetGenericRSTransform()->TransformPoint(currentLodPoint); - + ossGeographicLong.precision(6); ossGeographicLat.precision(6); - + ossGeographicLong << std::fixed << wgs84[0]; ossGeographicLat << std::fixed << wgs84[1]; //Update geovector with location over QL index geoVector.push_back(ossGeographicLong.str()); geoVector.push_back(ossGeographicLat.str()); - + double elev = otb::DEMHandler::Instance()->GetHeightAboveEllipsoid(wgs84[0],wgs84[1]); if(elev > -32768) @@ -950,16 +950,16 @@ VectorImageModel { // // compute the current ql index - currentLodIndex[0] = (Xpc - GetQuicklookModel()->ToImage()->GetOrigin()[0]) + currentLodIndex[0] = (Xpc - GetQuicklookModel()->ToImage()->GetOrigin()[0]) / GetQuicklookModel()->ToImage()->GetSpacing()[0]; - currentLodIndex[1] = (Ypc - GetQuicklookModel()->ToImage()->GetOrigin()[1]) + currentLodIndex[1] = (Ypc - GetQuicklookModel()->ToImage()->GetOrigin()[1]) / GetQuicklookModel()->ToImage()->GetSpacing()[1]; - + // // Get the radiometry form the Ql if ( GetQuicklookModel()->ToImage()->GetBufferedRegion().IsInside(currentLodIndex) ) { - currentPixel = + currentPixel = GetQuicklookModel()->ToImage()->GetPixel(currentLodIndex); ossRadio <<"Ql [ "; @@ -973,7 +973,7 @@ VectorImageModel */ } - // update band name for the current position + // update band name for the current position bandNames = GetBandNames( true ); // qDebug() << bandNames; diff --git a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h index 3a3fc21ddc09bfdb277e18b2aab6b2a1e2018ab4..97f096ad9f43ff41d8f2e26a77a0980dce7af9b8 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h @@ -157,15 +157,13 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#data */ - - QVariant + QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const ITK_OVERRIDE; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#dropMimeData */ - - bool + bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, @@ -188,11 +186,11 @@ public: QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const ITK_OVERRIDE; + /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#index */ - - QModelIndex + QModelIndex index( int row, int column, const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; @@ -200,8 +198,7 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#insertRows */ - - bool + bool insertRows( int row, int count, const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; @@ -224,8 +221,7 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#removeRows */ - - bool + bool removeRows( int row, int count, const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; @@ -238,8 +234,7 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#setData */ - - bool + bool setData( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) ITK_OVERRIDE; diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h index 61d425e75d7597f248933b7c80b066f1bda3aaf8..8ad2bfc76d0f4b08239b8c0524ec1c59cb6607a3 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h @@ -62,6 +62,7 @@ #include "otbWrapperQtWidgetComplexInputImageParameter.h" #include "otbWrapperQtWidgetComplexOutputImageParameter.h" #include "otbWrapperQtWidgetParameterFactory.h" +#include "otbWrapperQtWidgetListEditWidget.h" #endif //tag=QT4-boost-compatibility #include "OTBMonteverdiGUIExport.h" @@ -135,7 +136,6 @@ class FileSelectionInitializer : public std::unary_function< > { public: - inline FileSelectionInitializer(); inline result_type operator () ( argument_type widget ) const; }; @@ -152,7 +152,6 @@ class InputImageInitializer : public std::unary_function< > { public: - inline InputImageInitializer(); inline result_type operator () ( argument_type widget ) const; }; @@ -169,12 +168,7 @@ class InputImageListInitializer : public std::unary_function< > { public: - inline InputImageListInitializer( QWidget * view ); - inline result_type operator () ( argument_type widget ) const; - -private: - QWidget * m_View; }; /** @@ -190,7 +184,6 @@ class ComplexInputImageInitializer : public std::unary_function< > { public: - inline ComplexInputImageInitializer(); inline result_type operator () ( argument_type widget ) const; }; @@ -221,12 +214,7 @@ class InputVectorDataListInitializer : public std::unary_function< void > { public: - inline InputVectorDataListInitializer( QWidget * view ); - inline result_type operator () ( argument_type widget ) const; - -private: - QWidget * m_View; }; /** @@ -256,12 +244,7 @@ class InputFilenameListInitializer : public std::unary_function< void > { public: - inline InputFilenameListInitializer( QWidget * view ); - inline result_type operator () ( argument_type widget ) const; - -private: - QWidget * m_View; }; /** @@ -334,8 +317,6 @@ class OutputVectorDataInitializer : public std::unary_function< { public: inline result_type operator () ( argument_type widget ) const; - -private: }; /** @@ -352,8 +333,6 @@ class OutputFilenameInitializer : public std::unary_function< { public: inline result_type operator () ( argument_type widget ) const; - -private: }; /** @@ -370,8 +349,6 @@ class OutputProcessXMLInitializer : public std::unary_function< { public: inline result_type operator () ( argument_type widget ) const; - -private: }; /** @@ -387,6 +364,21 @@ public: inline result_type operator () ( argument_type widget ) const; }; +/** + * \class ParameterListInitializer + * + * \ingroup OTBMonteverdiGUI + * + * \brief WIP. + */ +class ParameterListInitializer : public std::unary_function< + otb::Wrapper::QtWidgetParameterList *, + void > +{ +public: + inline result_type operator () ( argument_type widget ) const; +}; + } // end namespace 'Wrapper'. } // end namespace 'mvd'. @@ -420,13 +412,6 @@ namespace mvd namespace Wrapper { -/*****************************************************************************/ -inline -FileSelectionInitializer -::FileSelectionInitializer() -{ -} - /*****************************************************************************/ inline FileSelectionInitializer::result_type @@ -438,13 +423,6 @@ FileSelectionInitializer SetupForFilenameDrop( widget, "You can drop filename here." ); } -/*****************************************************************************/ -inline -InputImageInitializer -::InputImageInitializer() -{ -} - /*****************************************************************************/ inline InputImageInitializer::result_type @@ -456,35 +434,15 @@ InputImageInitializer SetupForFilenameDrop( widget, "You can drop filename here." ); } -/*****************************************************************************/ -inline -InputImageListInitializer -::InputImageListInitializer( QWidget * view ) : - m_View( view ) -{ -} - /*****************************************************************************/ inline InputImageListInitializer::result_type InputImageListInitializer -::operator () ( argument_type widget ) const +::operator () ( argument_type /* widget */ ) const { - assert( widget!=NULL ); - - QObject::connect( - widget, SIGNAL( FileSelectionWidgetAdded( QWidget * ) ), - m_View, SLOT( OnFileSelectionWidgetAdded0( QWidget * ) ) - ); - - SetupWidget( widget, FileSelectionInitializer() ); -} + // assert( widget!=NULL ); -/*****************************************************************************/ -inline -ComplexInputImageInitializer -::ComplexInputImageInitializer() -{ + // Drop support is done by ParameterListInitializer } /*****************************************************************************/ @@ -509,28 +467,15 @@ InputFilenameInitializer SetupForFilenameDrop( widget, "You can drop filename here." ); } -/*****************************************************************************/ -inline -InputFilenameListInitializer -::InputFilenameListInitializer( QWidget * view ) : - m_View( view ) -{ -} - /*****************************************************************************/ inline InputFilenameListInitializer::result_type InputFilenameListInitializer -::operator () ( argument_type widget ) const +::operator () ( argument_type /* widget */) const { - assert( widget!=NULL ); + // assert( widget!=NULL ); - QObject::connect( - widget, SIGNAL( FileSelectionWidgetAdded( QWidget * ) ), - m_View, SLOT( OnFileSelectionWidgetAdded0( QWidget * ) ) - ); - - SetupWidget( widget, FileSelectionInitializer() ); + // Drop support is done by ParameterListInitializer } /*****************************************************************************/ @@ -544,28 +489,15 @@ InputVectorDataInitializer SetupForFilenameDrop( widget, "You can drop filename here." ); } -/*****************************************************************************/ -inline -InputVectorDataListInitializer -::InputVectorDataListInitializer( QWidget * view ) : - m_View( view ) -{ -} - /*****************************************************************************/ inline InputVectorDataListInitializer::result_type InputVectorDataListInitializer -::operator () ( argument_type widget ) const +::operator () ( argument_type /* widget */) const { - assert( widget!=NULL ); + // assert( widget!=NULL ); - QObject::connect( - widget, SIGNAL( FileSelectionWidgetAdded( QWidget * ) ), - m_View, SLOT( OnFileSelectionWidgetAdded0( QWidget * ) ) - ); - - SetupWidget( widget, FileSelectionInitializer() ); + // Drop support is done by ParameterListInitializer } /*****************************************************************************/ @@ -719,6 +651,34 @@ OutputProcessXMLInitializer // } } +/*****************************************************************************/ +inline +ParameterListInitializer::result_type +ParameterListInitializer +::operator () ( argument_type widget ) const +{ + assert( widget!=nullptr ); + + QWidget *listWidget = widget->layout()->itemAt(0)->widget(); + + assert( listWidget ); + + otb::Wrapper::ListEditWidget *castListEdit = + dynamic_cast<otb::Wrapper::ListEditWidget *>(listWidget); + + assert(castListEdit); + + QObject* eventFilter = new FilenameDragAndDropEventFilter( castListEdit ); + castListEdit->installEventFilter(eventFilter); + QObject::connect( + eventFilter, + SIGNAL( FilenameDropped( const QString& ) ), + // to: + castListEdit, + SLOT( OnFilenameDropped( const QString& ) ) + ); +} + /*****************************************************************************/ template< typename W > void diff --git a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx index ff6d14ecc26aa84d14d8f6418160b2d80adb9595..b11becb03201e8a5714c86285a706d1a364fdd0f 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx @@ -345,13 +345,14 @@ QtWidgetView assert( widget!=NULL ); SetupWidget( widget, InputFilenameInitializer() ); - SetupWidget( widget, InputFilenameListInitializer( this ) ); + //SetupWidget( widget, InputFilenameListInitializer() ); SetupWidget( widget, InputImageInitializer() ); - SetupWidget( widget, InputImageListInitializer( this ) ); + //SetupWidget( widget, InputImageListInitializer() ); SetupWidget( widget, ComplexInputImageInitializer() ); SetupWidget( widget, InputProcessXMLInitializer() ); SetupWidget( widget, InputVectorDataInitializer() ); - SetupWidget( widget, InputVectorDataListInitializer( this ) ); + //SetupWidget( widget, InputVectorDataListInitializer() ); + SetupWidget( widget, ParameterListInitializer() ); #if defined( OTB_DEBUG ) SetupWidget( widget, ToolTipInitializer() ); #endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAbstractParameterList.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAbstractParameterList.h new file mode 100644 index 0000000000000000000000000000000000000000..94a0c2896e008acf2bb62c807c06f4d959bd4f6f --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAbstractParameterList.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperAbstractParameterList_h +#define otbWrapperAbstractParameterList_h + + +#include "otbWrapperParameter.h" +#include "otbWrapperStringListInterface.h" + + +namespace otb +{ + +namespace Wrapper +{ + + +/** \class AbstractParameterList + * \brief This class is a base class for list-type parameters + * + * \ingroup OTBApplicationEngine + */ +class OTBApplicationEngine_EXPORT AbstractParameterList : + public Parameter, + public StringListInterface +{ +// +// Public types. +public: + /** Standard class typedef */ + typedef AbstractParameterList Self; + typedef Parameter Superclass; + +// +// Public methods. +public: + + /** RTTI support */ + itkTypeMacro( AbstractParameterList, Parameter ); + +// +// Protected methods. +protected: + /** Constructor */ + AbstractParameterList(); + + /** Destructor */ + ~AbstractParameterList() override; + +// +// Private methods. +private: + AbstractParameterList( const Parameter & ) = delete; // purposely not implemented + void operator = ( const Parameter & ) = delete; // purposely not implemented + +// +// Protected methods. +protected: + +// +// Private attributes. +private: + +}; // End class InputImage Parameter + +} // End namespace Wrapper + +} // End namespace otb + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index cbc0f7f2736f9ffecb4933b6616032067acdd8bb..cec459dc965019f1d42396b995b89837138213a8 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -375,7 +375,7 @@ public: /** * Enable single selection mode for list view if status in true * (default is false). - * + * * Can be called for types: * \li ParameterType_ListView */ @@ -455,10 +455,18 @@ public: * \li ParameterType_InputImageList * \li ParameterType_InputFilenameList */ - std::vector<std::string> GetParameterStringList(std::string parameter); + // TODO: Should be rewritten: + // + // std::size_t + // GetParameterStringList( const std::vector< String > & v, + // const std::string & parameter ) const; + // + // to avoid useless memory allocations. + std::vector< std::string > + GetParameterStringList( const std::string & parameter ); - /** + /** * Set the input image parameter as an ImageBase * instead * of filename. Useful to connect pipelines between different * application instances. @@ -480,7 +488,7 @@ public: */ OutputImageParameter::ImageBaseType * GetParameterOutputImage(std::string parameter); - /** + /** * Set the input complex image parameter as an ImageBase * instead * of filename. Useful to connect pipelines between different * application instances. @@ -510,7 +518,7 @@ public: * \in img The ImageBase * of the image to add * \throw itk::Exception if parameter is not found or not an * InputImageList parameter - */ + */ void AddImageToParameterInputImageList(std::string parameter, InputImageListParameter::ImageBaseType * img); /** @@ -522,7 +530,7 @@ public: * \in img The ImageBase * of the image to add * \throw itk::Exception if parameter is not found or not an * InputImageList parameter or if id is out of bounds - */ + */ void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img); /** @@ -530,12 +538,12 @@ public: * * Can be called for parameter types: * \li ParameterType_InputImageList - * + * * \in parameter The parameter key * \in str The string * \throw itk::Exception if parameter is not found or not an * InputImageList parameter - */ + */ void AddParameterStringList(std::string parameter, const std::string & str); /** @@ -543,15 +551,15 @@ public: * * Can be called for parameter types: * \li ParameterType_InputImageList - * + * * \in parameter The parameter key * \in id Position at which to set the ImageBase pointer * \in str The string * \throw itk::Exception if parameter is not found or not an * InputImageList parameter or if id is out of bounds - */ + */ void SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string& str); - + /** * Clear all images from an InputImageList parameter. @@ -559,7 +567,7 @@ public: * \in parameter The parameter key * \throw itk::Exception if parameter is not found or not an * InputImageList parameter - */ + */ void ClearParameterInputImageList(std::string parameter); /** @@ -568,10 +576,10 @@ public: * \return The number of images * \throw itk::Exception if parameter is not found or not an * InputImageList parameter - */ + */ unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter); - + /* Get an image value * * Can be called for types : diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx index 47320646f9948127877d1a084e7b951e630bc26b..774dfdbf789b8cdb48252f76e7aad13bba90399c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx @@ -49,21 +49,14 @@ ComplexInputImageParameter::GetImage() { //////////////////////// Filename case: // A new valid filename has been given : a reader is created - m_PreviousFileName = m_FileName; typedef otb::ImageFileReader<TOutputImage> ReaderType; typename ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(m_FileName); - try - { - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject &) - { - this->ClearValue(); - } + reader->UpdateOutputInformation(); m_Image = reader->GetOutput(); m_Reader = reader; + m_PreviousFileName = m_FileName; // Pay attention, don't return m_Image because it is a ImageBase... return reader->GetOutput(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index 37dc1434376dd6afe5806bb16367f9b59cecb644..371c4d416691d36e3e07ffe50ea69c1580c20284 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -85,6 +85,10 @@ public: /** Static method to convert pixel type into string */ static std::string ConvertPixelTypeToString(ComplexImagePixelType type); + /** Convert a string into a ComplexImagePixelType (returns false if the + * conversion fails) */ + static bool ConvertStringToPixelType(const std::string &value, ComplexImagePixelType &type); + /** Return true if a filename is set */ bool HasValue() const ITK_OVERRIDE; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h index b5ef343dcdf7880a7131501423b10d3311f413e5..61e1dd605d0acc9f23fabb270094b3a5c8d9e778 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h @@ -21,88 +21,85 @@ #ifndef otbWrapperInputFilenameListParameter_h #define otbWrapperInputFilenameListParameter_h -#include <string> + +#include "otbWrapperParameterList.h" #include "otbWrapperStringParameter.h" -#include "otbObjectList.h" namespace otb { + namespace Wrapper { + /** \class InputFilenameListParameter * \brief This class represents a list of InputFilename parameter * * \ingroup OTBApplicationEngine */ - -class OTBApplicationEngine_EXPORT InputFilenameListParameter : public Parameter +class OTBApplicationEngine_EXPORT InputFilenameListParameter : + public ParameterList< StringParameter > { +// +// Public types. public: /** Standard class typedef */ - typedef InputFilenameListParameter Self; - typedef Parameter Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef otb::ObjectList<StringParameter> StringParameterListType; - typedef StringParameterListType* StringParameterListPointerType; + typedef InputFilenameListParameter Self; + typedef ParameterList< StringParameter > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; +// +// Public methods. +public: /** Defining ::New() static method */ - itkNewMacro(Self); + itkNewMacro( Self ); /** RTTI support */ - itkTypeMacro(InputFilenameListParameter, Parameter); - - /** Set file form a list of filenames */ - bool SetListFromFileName(const std::vector<std::string> & filenames); + itkTypeMacro( InputFilenameListParameter, Superclass ); - /** Add null element to lists. */ - void AddNullElement(); + /** */ + Role GetDirection( std::size_t ) const override; - /** Add a filename from a filename */ - bool AddFromFileName(const std::string & filename); + /** */ + Role GetDirection() const override; - /** Set one specific stored filename. */ - bool SetNthFileName( const unsigned int id, const std::string & filename ); + /** */ + const std::string & GetFilenameFilter( std::size_t ) const override; - /** Get the stored filename list */ - std::vector<std::string> GetFileNameList() const; - - /** Get one specific stored filename. */ - std::string GetNthFileName( unsigned int i ) const; - - /** Get one list of the stored files. */ - StringParameterListPointerType GetFileList() const; - - bool HasValue() const ITK_OVERRIDE; - - - /** Erase one element of the list. */ - void Erase( unsigned int id ); - - /** Clear all the list. */ - void ClearValue() ITK_OVERRIDE; + /** */ + const std::string & GetFilenameFilter() const override; +// +// Protected methods. protected: /** Constructor */ InputFilenameListParameter(); /** Destructor */ - ~InputFilenameListParameter() ITK_OVERRIDE; + ~InputFilenameListParameter() override; + /** */ + const std::string & ToString( const ParameterType::Pointer & ) const override; - StringParameterListType::Pointer m_FilenameList; + /** */ + using Superclass::FromString; + const ParameterType::Pointer & + FromString( const ParameterType::Pointer &, + const std::string & ) const override; +// +// Private methods. private: - InputFilenameListParameter(const Parameter &); //purposely not implemented - void operator =(const Parameter&); //purposely not implemented + InputFilenameListParameter( const Parameter & ); //purposely not implemented + void operator = ( const Parameter & ); //purposely not implemented }; // End class InputFilenameList Parameter } // End namespace Wrapper + } // End namespace otb #endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h index 6b4bf70c7d66869098aa17dc42aa2a7f12fc5d4f..889e6d8df2bd02d831a1c26a571475407e6b6f86 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h @@ -21,104 +21,113 @@ #ifndef otbWrapperInputImageListParameter_h #define otbWrapperInputImageListParameter_h -#include "otbWrapperParameter.h" + #include "otbWrapperInputImageParameter.h" +#include "otbWrapperParameterList.h" + namespace otb { + + namespace Wrapper { + /** \class InputImageListParameter * \brief This class represents a list of InputImage parameter * * \ingroup OTBApplicationEngine */ - -class OTBApplicationEngine_EXPORT InputImageListParameter : public Parameter +class OTBApplicationEngine_EXPORT InputImageListParameter : + public ParameterList< InputImageParameter > { public: /** Standard class typedef */ - typedef InputImageListParameter Self; - typedef Parameter Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef InputImageListParameter Self; + typedef ParameterList< InputImageParameter > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - typedef std::vector<InputImageParameter::Pointer> InputImageParameterVectorType; + typedef itk::ImageBase< 2 > ImageBaseType; - typedef itk::ImageBase<2> ImageBaseType; - /** Defining ::New() static method */ - itkNewMacro(Self); + itkNewMacro( Self ); /** RTTI support */ - itkTypeMacro(InputImageListParameter, Parameter); - - /** Set image form a list of filename */ - bool SetListFromFileName(const std::vector<std::string> & filenames); - - /** Add null element to lists. */ - void AddNullElement(); - - /** Add an image from a filename */ - bool AddFromFileName(const std::string & filename); - - /** Set one specific stored image filename. */ - bool SetNthFileName( const unsigned int id, const std::string & filename ); - - /** Get the stored image filename list */ - std::vector<std::string> GetFileNameList() const; - - /** Get one specific stored image filename. */ - std::string GetNthFileName( unsigned int i ) const; + itkTypeMacro( InputImageListParameter, ParameterList ); /** Get one list of the stored image. WARNING : if the parameter list changes, * the returned image list may become obsolete. You should call * GetImageList() again to make sure your image list is up-to-date. */ - FloatVectorImageListType* GetImageList() const; + const FloatVectorImageListType * GetImageList() const; + FloatVectorImageListType * GetImageList(); /** Get one specific stored image. */ - FloatVectorImageType* GetNthImage(unsigned int i) const; + const FloatVectorImageType * GetNthImage( std::size_t ) const; + FloatVectorImageType * GetNthImage( std::size_t ); /** Set one specific image. */ - void SetNthImage(unsigned int i, ImageBaseType * img); - + void SetNthImage( std::size_t, ImageBaseType * ); + /** Set the list of image. */ - void SetImageList(FloatVectorImageListType* imList); + void SetImageList( FloatVectorImageListType * ); /** Add an image to the list. */ - void AddImage(ImageBaseType* image); - - bool HasValue() const ITK_OVERRIDE; + void AddImage( ImageBaseType * ); + /** Clear all the list. */ + void ClearValue() override; - /** Erase one element of the list. */ - void Erase( unsigned int id ); + /** */ + using StringListInterface::GetDirection; + Role GetDirection() const override; - /** Clear all the list. */ - void ClearValue() ITK_OVERRIDE; + /** */ + using StringListInterface::GetFilenameFilter; + const std::string & GetFilenameFilter() const override; - /** Retrieve number of elements */ - unsigned int Size() const; - protected: /** Constructor */ InputImageListParameter(); /** Destructor */ - ~InputImageListParameter() ITK_OVERRIDE; + ~InputImageListParameter() override; + +// +// Protected methods. +protected: + + /** */ + const std::string & ToString( const ParameterType::Pointer & ) const override; + /** */ + using Superclass::FromString; + const ParameterType::Pointer & + FromString( const ParameterType::Pointer &, + const std::string & ) const override; +// +// Private methods. private: - InputImageListParameter(const Parameter &); //purposely not implemented - void operator =(const Parameter&); //purposely not implemented + InputImageListParameter( const Parameter & ); //purposely not implemented + void operator = ( const Parameter & ); //purposely not implemented + + InputImageParameter::Pointer + FromImage( ImageBaseType * ); - InputImageParameterVectorType m_InputImageParameterVector; + InputImageParameter::Pointer & + FromImage( InputImageParameter::Pointer &, ImageBaseType * ); + +// +// Private attributes +private: FloatVectorImageListType::Pointer m_ImageList; - - + + }; // End class InputImage Parameter } // End namespace Wrapper + } // End namespace otb #endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 0cf771abccd2717c56ebeee8a8d7bc06b48e0a0e..6ff36eedeed7f32c1382aa06be580d2904741967 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -53,8 +53,8 @@ public: itkTypeMacro(InputImageParameter, Parameter); /** Set value from filename */ - bool SetFromFileName(const std::string& filename); - itkGetConstMacro(FileName, std::string); + bool SetFromFileName( const std::string & filename ); + itkGetConstReferenceMacro( FileName, std::string ); /** Get the input image as FloatVectorImageType. */ @@ -96,7 +96,7 @@ public: /** Generic cast method that will be specified for each image type. */ template <class TInputImage, class TOutputImage> TOutputImage* CastImage(); - + /** Cast an image to an image of the same type * Image to Image, VectorImage to VectorImage, RGBAImage to RGBAImage. */ template <class TInputImage, class TOutputImage> @@ -177,7 +177,7 @@ private: otbDeclareCastImageMacro(InputImageType, Float##prefix##ImageType) \ otbDeclareCastImageMacro(InputImageType, Double##prefix##ImageType) - + /********************************************************************* ********************** Image -> Image **********************************************************************/ diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 64a620f70610e941fc293f1ada0704d904fbc22b..9db0e6140868eb635b115f0b46627f956615d178 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -33,6 +33,8 @@ namespace Wrapper { +#define INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION 0 + template <class TImageType> TImageType* InputImageParameter::GetImage() @@ -45,27 +47,35 @@ InputImageParameter::GetImage() // Only one image type can be used // 2 cases : the user set a filename vs. the user set an image - if (m_UseFilename) + if( m_UseFilename ) { - if( m_PreviousFileName!=m_FileName && !m_FileName.empty() ) + if( m_PreviousFileName!=m_FileName && + !m_FileName.empty() ) { //////////////////////// Filename case: // A new valid filename has been given : a reader is created - m_PreviousFileName = m_FileName; typedef otb::ImageFileReader<TImageType> ReaderType; + typename ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(m_FileName); + + reader->SetFileName( m_FileName ); reader->UpdateOutputInformation(); m_Image = reader->GetOutput(); m_Reader = reader; + m_PreviousFileName = m_FileName; + // Pay attention, don't return m_Image because it is a ImageBase... return reader->GetOutput(); } else { +#if INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION + return dynamic_cast< TImageType* >( m_Image.GetPointer() ); + +#else // INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION // In this case, the reader and the image should already be there if (m_Image.IsNull()) { @@ -83,14 +93,20 @@ InputImageParameter::GetImage() itkExceptionMacro("Cannot ask a different image type"); } } +#endif // INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION } } + else { //////////////////////// Image case: if (m_Image.IsNull()) { +#if INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION itkExceptionMacro("No input image or filename detected..."); +#else + return nullptr; +#endif } else { @@ -160,7 +176,11 @@ InputImageParameter::GetImage() } else { +#if INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION itkExceptionMacro("Unknown image type"); +#else + return nullptr; +#endif } } } diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h index 423d2ca0f9953c601c2122b6f9a004dcfbb61173..52d4ac37ea4c5aa116e211a203f1b2bca3860bbd 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h @@ -21,78 +21,65 @@ #ifndef otbWrapperInputVectorDataListParameter_h #define otbWrapperInputVectorDataListParameter_h -#include "otbVectorDataFileReader.h" -#include "otbWrapperParameter.h" -#include "otbObjectList.h" +#include "otbWrapperInputVectorDataParameter.h" +#include "otbWrapperParameterList.h" + namespace otb { + + namespace Wrapper { + /** \class InputVectorDataListParameter * \brief This class represents a list of VectorData parameter * * \ingroup OTBApplicationEngine */ - -class OTBApplicationEngine_EXPORT InputVectorDataListParameter : public Parameter +class OTBApplicationEngine_EXPORT InputVectorDataListParameter : + public ParameterList< InputVectorDataParameter > { public: /** Standard class typedef */ - typedef InputVectorDataListParameter Self; - typedef Parameter Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType; - typedef otb::ObjectList<VectorDataFileReaderType> VectorDataFileReaderListType; + typedef InputVectorDataListParameter Self; + typedef ParameterList< InputVectorDataParameter > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; /** Defining ::New() static method */ - itkNewMacro(Self); + itkNewMacro( Self ); /** RTTI support */ - itkTypeMacro(InputVectorDataListParameter, Parameter); - - /** Set image form a list of filename */ - bool SetListFromFileName(const std::vector<std::string> & filenames); - - /** Add null element to lists. */ - void AddNullElement(); - - /** Add an image from a filename */ - bool AddFromFileName(const std::string & filename); - - /** Set one specific stored image filename. */ - bool SetNthFileName( const unsigned int id, const std::string & filename ); - - - /** Get the stored image filename list */ - std::vector<std::string> GetFileNameList() const; - - /** Get one specific stored image filename. */ - std::string GetNthFileName( unsigned int i ) const; + itkTypeMacro( InputVectorDataListParameter, ParameterList ); /** Get one list of the stored image. */ - VectorDataListType* GetVectorDataList() const; + const VectorDataListType * GetVectorDataList() const; + VectorDataListType * GetVectorDataList(); /** Get one specific stored image. */ - VectorDataType* GetNthVectorData(unsigned int i) const; + // + // FIXME: Definition is not const-correct because + // InputVectorDataParameter::GetVectorData() is not const-correct! + const VectorDataType * GetNthVectorData( std::size_t ); /** Set the list of image. */ - void SetVectorDataList(VectorDataListType* vdList); + void SetVectorDataList( VectorDataListType * ); /** Add an image to the list. */ - void AddVectorData(VectorDataType* image); - - bool HasValue() const ITK_OVERRIDE; + void AddVectorData( VectorDataType * ); + /** Clear all the list. */ + void ClearValue() override; - /** Erase one element of the list. */ - void Erase( unsigned int id ); + /** */ + using StringListInterface::GetDirection; + virtual Role GetDirection() const override; - /** Clear all the list. */ - void ClearValue() ITK_OVERRIDE; + /** */ + using StringListInterface::GetFilenameFilter; + const std::string & GetFilenameFilter() const override; protected: @@ -100,18 +87,39 @@ protected: InputVectorDataListParameter(); /** Destructor */ - ~InputVectorDataListParameter() ITK_OVERRIDE; + ~InputVectorDataListParameter() override; - VectorDataListType::Pointer m_VectorDataList; - VectorDataFileReaderListType::Pointer m_ReaderList; + /** */ + const std::string & ToString( const ParameterType::Pointer & ) const override; + + /** */ + using Superclass::FromString; + const ParameterType::Pointer & + FromString( const ParameterType::Pointer &, + const std::string & ) const override; + +private: + // Purposely not implemented + InputVectorDataListParameter( const Parameter & ); + + // Purposely not implemented + void operator = ( const Parameter & ); + + InputVectorDataParameter::Pointer + FromVectorData( VectorDataType * ); + InputVectorDataParameter::Pointer & + FromVectorData( InputVectorDataParameter::Pointer &, VectorDataType * ); + +// +// Private attributes private: - InputVectorDataListParameter(const Parameter &); //purposely not implemented - void operator =(const Parameter&); //purposely not implemented + VectorDataListType::Pointer m_VectorDataList; }; // End class InputVectorDataList Parameter } // End namespace Wrapper + } // End namespace otb #endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h index dded12d42bc14e4d751c511ee7eb534aaf71e85a..f84a3834ebb28767374455d8d48035ffac275dbf 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h @@ -55,9 +55,10 @@ public: /** Set value from filename */ bool SetFromFileName(const std::string& filename); - itkGetConstMacro(FileName, std::string); + itkGetConstReferenceMacro( FileName, std::string ); - VectorDataType* GetVectorData(); + const VectorDataType * GetVectorData() const; + VectorDataType * GetVectorData(); void SetVectorData(VectorDataType* vectorData); @@ -78,6 +79,8 @@ protected: std::string m_FileName; + std::string m_PreviousFileName; + private: InputVectorDataParameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index adbf9d12ee1628d5d1dd5e5f02e1b8a7ac8569c1..b420299ff6b707f8ccbed39577b488684e527fae 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -86,6 +86,10 @@ public: /** Static method to convert pixel type into string */ static std::string ConvertPixelTypeToString(ImagePixelType type); + /** Converts a string into a pixel type (returns false if the conversion + * fails) */ + static bool ConvertStringToPixelType(const std::string &value, ImagePixelType &type); + /** Return true if a filename is set */ bool HasValue() const ITK_OVERRIDE; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 772ee60902a878ef883b8fc568e138b47ea44c1c..236411f8f21e8b185bed7aa514770bb19ca00b14 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -70,9 +70,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - /** Defining ::New() static method */ - itkNewMacro(Self); - /** RTTI support */ itkTypeMacro(Parameter, itk::Object); @@ -86,7 +83,7 @@ public: itkSetStringMacro(Description); /** Get the parameter description */ - itkGetStringMacro(Description); + itkGetConstReferenceMacro( Description, std::string ); /** Set the parameter key */ itkSetStringMacro(Key); @@ -151,14 +148,11 @@ public: { } - virtual bool HasValue() const - { - itkExceptionMacro(<<"HasValue() method must be re-implemented by sub-classes."); - } + virtual bool HasValue() const = 0; virtual bool HasUserValue() const { - return HasValue() && m_UserValue; + return this->HasValue() && m_UserValue; } virtual void SetUserValue(bool isUserValue) @@ -168,7 +162,8 @@ public: virtual void ClearValue() { - itkExceptionMacro(<<"ClearValue() method must be re-implemented by sub-classes."); + SetActive( false ); + Modified(); } /** Set/Get the root of the current parameter (direct parent) */ @@ -207,7 +202,7 @@ public: /** Store the state of the check box relative to this parameter (TO * BE MOVED to QtWrapper Model ) */ - virtual bool IsChecked() + virtual bool IsChecked() const { return m_IsChecked; } @@ -220,23 +215,23 @@ public: protected: /** Constructor */ - Parameter() : m_Name(""), - m_Description(""), - m_Key(""), - m_Mandatory(true), - m_Active(false), - m_UserValue(false), - m_AutomaticValue(false), - m_DefaultValueMode(DefaultValueMode_UNKNOWN), - m_UserLevel(UserLevel_Basic), - m_Role(Role_Input), - m_Root(this), - m_IsChecked(false) + Parameter() : + m_Name( "" ), + m_Description( "" ), + m_Key( "" ), + m_Mandatory( true ), + m_Active( false ), + m_UserValue( false ), + m_AutomaticValue( false ), + m_DefaultValueMode( DefaultValueMode_UNKNOWN ), + m_UserLevel( UserLevel_Basic ), + m_Role( Role_Input ), + m_Root( this ), + m_IsChecked( false ) {} /** Destructor */ - ~Parameter() ITK_OVERRIDE - {} + ~Parameter() ITK_OVERRIDE {} /** Name of the parameter */ std::string m_Name; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h new file mode 100644 index 0000000000000000000000000000000000000000..2c9c699fbe3c540a62d9cc4b39c39bfa052508b6 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperParameterList_h +#define otbWrapperParameterList_h + + +#include "otbWrapperAbstractParameterList.h" +#include "otbWrapperStringListInterface.h" + + +namespace otb +{ + +namespace Wrapper +{ + + +/** \class ParameterList + * \brief This class represents a InputImage parameter + * + * \ingroup OTBApplicationEngine + */ +template< typename T > +class ParameterList : + public AbstractParameterList +{ +// +// Public types. +public: + /** Standard class typedef */ + typedef ParameterList Self; + typedef AbstractParameterList Superclass; + + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + /** Custom types */ + typedef T ParameterType; + typedef std::vector< typename T::Pointer > ParameterVector; + +// +// Public methods. +public: + + /** RTTI support */ + itkTypeMacro( ParameterList, AbstractParameterList ); + + /** */ + typename ParameterVector::const_iterator begin() const; + + /** */ + typename ParameterVector::const_iterator end() const; + + /** */ + void ClearValue() override; + + /** */ + bool HasValue() const override; + + /** Set file form a list of filenames */ + void SetListFromFileName( const StringVector & ) override; + + /** */ + void InsertNullElement( std::size_t = -1 ) override; + + /** Add a filename from a filename */ + void AddFromFileName( const std::string & ) override; + + /** */ + void Insert( const std::string &, std::size_t = -1 ) override; + + /** Set one specific stored filename. */ + void SetNthFileName( std::size_t, const std::string & ) override; + + /** */ + std::size_t SetStrings( const StringVector & ); + + /** */ + std::size_t GetStrings( StringVector & ) const override; + + /** Get the stored image filename list */ + StringVector GetFileNameList() const override; + + /** Get one specific stored image filename. */ + const std::string & GetNthFileName( std::size_t ) const override; + + /** */ + const std::string & GetToolTip( std::size_t ) const override; + + /** */ + using StringListInterface::Erase; + void Erase( std::size_t start, std::size_t count ) override; + + /** Retrieve number of elements */ + std::size_t Size() const override; + + /** */ + bool IsActive( size_t ) const override; + + /** */ + void Swap( std::size_t, std::size_t ) override; + +// +// Protected methods. +protected: + /** Constructor */ + ParameterList(); + + /** Destructor */ + ~ParameterList() override; + +// +// Private methods. +private: + // ParameterList( const Parameter & ); // purposely not implemented + // void operator = ( const Parameter & ); // purposely not implemented + +// +// Protected methods. +protected: + /** Utility method to factorize some code */ + template< typename L, typename From, typename Get > + void + SetObjectList( L &, const L &, From, Get ); + + /** Utility method to factorize some code */ + template< typename L, typename Get > + typename L::ObjectType * + GetObjectList( L &, Get ); + + /** */ + template< typename L, typename Get > + const typename L::ObjectType * + GetObjectList( L &, Get ) const; + + /** */ + template< typename D, typename From > + void AddData( D *, From ); + + /** */ + template< typename D, typename Set > + typename T::Pointer + FromData( D *, + Set, + const std::string & description = std::string() ); + + /** */ + template< typename D, typename Set > + typename T::Pointer & + FromData( typename T::Pointer &, + D *, + Set, + const std::string & description = std::string() ); + + /** ParameterType::ValueType -> std::string protocol */ + virtual + const std::string & + ToString( const typename ParameterType::Pointer & ) const = 0; + + /** std::string -> ParameterType::ValueType protocol */ + virtual + const typename ParameterType::Pointer & + FromString( const typename ParameterType::Pointer &, + const std::string & ) const = 0; + + /** Utility method to use std::string -> conversion in lambdas. */ + virtual + typename ParameterType::Pointer + FromString( const std::string & ) const; + +// +// Protected attributes. +protected: + /** */ + ParameterVector m_Parameters; + +}; // End class InputImage Parameter + +} // End namespace Wrapper + +} // End namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +# include "otbWrapperParameterList.txx" +#endif + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.txx new file mode 100644 index 0000000000000000000000000000000000000000..da857bcbf8bff3e78b988e2044f8f14cb4c144b6 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.txx @@ -0,0 +1,487 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperParameterList_txx +#define otbWrapperParameterList_txx + + +#include <algorithm> +#include <iterator> + +#include "otbCast.h" +#include "otbWrapperParameterList.h" + + +namespace otb +{ + +namespace Wrapper +{ + + +/*****************************************************************************/ +template< typename T > +ParameterList< T > +::ParameterList() : + AbstractParameterList(), + m_Parameters() +{ +} + +/*****************************************************************************/ +template< typename T > +ParameterList< T > +::~ParameterList() +{ +} + +/*****************************************************************************/ +template< typename T > +typename ParameterList< T >::ParameterVector::const_iterator +ParameterList< T > +::begin() const +{ + return m_Parameters.begin(); +} + +/*****************************************************************************/ +template< typename T > +typename ParameterList< T >::ParameterVector::const_iterator +ParameterList< T > +::end() const +{ + return m_Parameters.end(); +} + +/*****************************************************************************/ +template< typename T > +bool +ParameterList< T > +::HasValue() const +{ + return + Size()>0 + && + std::all_of( + begin(), + end(), + []( auto p ) -> bool + { + assert( p!=nullptr ); + return p && p->HasValue(); + } + ); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::ClearValue() +{ + m_Parameters.clear(); + + Superclass::ClearValue(); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::SetListFromFileName( const StringVector & strings ) +{ + this->SetStrings(strings); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::InsertNullElement( std::size_t index ) +{ + m_Parameters.insert( + index>=m_Parameters.size() + ? m_Parameters.end() + : m_Parameters.begin() + index, + typename T::Pointer() + ); + + SetActive( false ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::AddFromFileName( const std::string & filename ) +{ + assert( !filename.empty() ); + + typename T::Pointer p( T::New() ); + + FromString( p, filename ); + + m_Parameters.push_back( p ); + + assert( !m_Parameters.back().IsNull() ); + + SetActive( true ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::Insert( const std::string & filename, std::size_t index ) +{ + typename T::Pointer p( T::New() ); + + FromString( p, filename ); + + m_Parameters.insert( m_Parameters.begin() + index, p ); + + assert( !m_Parameters.back().IsNull() ); + + SetActive( true ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::SetNthFileName( std::size_t i, + const std::string & filename ) +{ + assert( i<m_Parameters.size() ); + assert( !m_Parameters[ i ].IsNull() ); + + // Should throw exception when failed. + FromString( m_Parameters[ i ], filename ); + + SetActive( true ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +std::size_t +ParameterList< T > +::SetStrings( const StringVector & strings ) +{ + // First clear previous file chosen + ClearValue(); + + if ( !strings.empty() ) + { + std::transform( + strings.begin(), + strings.end(), + std::back_inserter( m_Parameters ), + [ this ]( auto s ) -> auto + { + return this->FromString( s ); + } + ); + + SetActive( true ); + Modified(); + } + return strings.size(); +} + +/*****************************************************************************/ +template< typename T > +std::size_t +ParameterList< T > +::GetStrings( StringVector & strings ) const +{ + std::transform( + begin(), + end(), + std::back_inserter( strings ), + [ this ]( auto p ) -> auto + { + return this->ToString( p ); + } + ); + + return m_Parameters.size(); +} + +/*****************************************************************************/ +template< typename T > +StringListInterface::StringVector +ParameterList< T > +::GetFileNameList() const +{ + StringVector filenames; + + GetStrings( filenames ); + + return filenames; +} + +/*****************************************************************************/ +template< typename T > +const std::string & +ParameterList< T > +::GetNthFileName( std::size_t i ) const +{ + assert( i<m_Parameters.size() ); + + return ToString( m_Parameters[ i ] ); +} + +/*****************************************************************************/ +template< typename T > +const std::string & +ParameterList< T > +::GetToolTip( std::size_t i ) const +{ + assert( i<m_Parameters.size() ); + assert( !m_Parameters[ i ].IsNull() ); + + return m_Parameters[ i ]->GetDescription(); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::Erase( std::size_t start, std::size_t count ) +{ + assert( start<m_Parameters.size() ); + assert( start+count<=m_Parameters.size() ); + + m_Parameters.erase( + m_Parameters.begin() + start, + m_Parameters.begin() + start + count + ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +std::size_t +ParameterList< T > +::Size() const +{ + return m_Parameters.size(); +} + +/*****************************************************************************/ +template< typename T > +bool +ParameterList< T > +::IsActive( std::size_t i ) const +{ + assert( i<m_Parameters.size() ); + assert( !m_Parameters[ i ].IsNull() ); + + return m_Parameters[ i ]->GetActive(); +} + +/*****************************************************************************/ +template< typename T > +void +ParameterList< T > +::Swap( std::size_t i1, std::size_t i2 ) +{ + assert( !m_Parameters.empty() ); + + auto clamp = [ this ]( std::size_t i ) -> std::size_t + { + return + i>=m_Parameters.size() + ? m_Parameters.size() - 1 + : i; + }; + + std::swap( + m_Parameters[ clamp( i1 ) ], + m_Parameters[ clamp( i2 ) ] + ); +} + +/*****************************************************************************/ +template< typename T > +template< typename L, typename From, typename Get > +void +ParameterList< T > +::SetObjectList( L & this_list, + const L & list, + From from, + Get get ) +{ + // Force update of input-list elements. + for( std::size_t i=0; i<list.Size(); i++ ) + { + assert( list.GetNthElement( i )!=nullptr ); + + list.GetNthElement( i )->UpdateOutputInformation(); + } + + // Clear previous target list. + ClearValue(); + + for( std::size_t i=0; i<list.Size(); i++ ) + { + assert( list.GetNthElement( i )!=nullptr ); + + typename T::Pointer parameter; + + from( parameter, list.GetNthElement( i ) ); + + m_Parameters.push_back( parameter ); + + assert( get( parameter )!=nullptr ); + + this_list.PushBack( get( parameter ) ); + } + + SetActive( true ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +template< typename L, typename Get > +typename L::ObjectType * +ParameterList< T > +::GetObjectList( L & this_list, Get get ) +{ + assert( this_list ); + + this_list->Clear(); + + std::for_each( + begin(), + end(), + [ this_list, get ]( auto parameter ) -> void + { + assert( parameter ); + assert( parameter==otb::DynamicCast< T >( parameter ) ); + + assert( get( DynamicCast< T >( parameter ) ) ); + + this_list->PushBack( + get( + DynamicCast< T >( parameter ) + ) + ); + } + ); + + return this_list; +} + +/*****************************************************************************/ +template< typename T > +template< typename L, typename Get > +const typename L::ObjectType * +ParameterList< T > +::GetObjectList( L & this_list, Get get ) const +{ + return + const_cast< ParameterList< T > * >( this ) + ->GetObjectList( this_list, get ); +} + +/*****************************************************************************/ +template< typename T > +template< typename D, typename From > +void +ParameterList< T > +::AddData( D * data, From from ) +{ + assert( data!=nullptr ); + + // Check input availability + data->UpdateOutputInformation(); + + // Build & add parameter. + m_Parameters.push_back( from( data ) ); + + Modified(); +} + +/*****************************************************************************/ +template< typename T > +template< typename D, typename Set > +typename T::Pointer +ParameterList< T > +::FromData( D * data, + Set set, + const std::string & description ) +{ + assert( data!=nullptr ); + + typename T::Pointer p; + + return From( p, data, set, description ); +} + +/*****************************************************************************/ +template< typename T > +template< typename D, typename Set > +typename T::Pointer & +ParameterList< T > +::FromData( typename T::Pointer & parameter, + D * data, + Set set, + const std::string & description ) +{ + assert( data!=nullptr ); + + parameter = T::New(); + + set( parameter, data ); + parameter->SetDescription( description ); + + return parameter; +} + +/*****************************************************************************/ +template< typename T > +typename T::Pointer +ParameterList< T > +::FromString( const std::string & s ) const +{ + typename T::Pointer parameter( T::New() ); + + return FromString( parameter, s ); +} + +} // End namespace Wrapper + + +} // End namespace otb + + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h index 1a93c2445479aaadc84e3303f01722181bdb4505..c7594f8c5dd625f96f144105513944e4c7fd39b1 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h @@ -70,6 +70,11 @@ public: return m_Target; } + bool HasValue() const override + { + return m_Target.first.IsNotNull(); + } + protected: ProxyParameter() {} ~ProxyParameter() ITK_OVERRIDE {} diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..dd84632d2312d9ed3ecc7d60bedbb806232f9f3e --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperStringListInterface_h +#define otbWrapperStringListInterface_h + + +#include <string> +#include <vector> + +#include "OTBApplicationEngineExport.h" + +#include "otbWrapperTypes.h" + + +namespace otb +{ + +namespace Wrapper +{ + +/** \class StringListInterface + * \brief This class represents a list of InputFilename parameter + * + * \ingroup OTBApplicationEngine + */ +class OTBApplicationEngine_EXPORT StringListInterface +{ +public: + /** */ + typedef std::vector< std::string > StringVector; + + /** Set file form a list of filenames */ + virtual void SetListFromFileName( const StringVector & ) = 0; + + /** Add null element to lists. */ + virtual void AddNullElement(); + + /** */ + virtual void InsertNullElement( std::size_t = -1 ) = 0; + + /** Add a filename from a filename */ + virtual void AddFromFileName( const std::string & ) = 0; + + /** */ + virtual void Insert( const std::string & filename, std::size_t = -1 ) = 0; + + /** Set one specific stored filename. */ + virtual void SetNthFileName( std::size_t, const std::string & ) = 0; + + /** */ + virtual std::size_t SetStrings( const StringVector & ); + + /** */ + virtual std::size_t GetStrings( StringVector & ) const; + + /** Get the stored filename list */ + virtual StringVector GetFileNameList() const = 0; + + /** Get one specific stored filename. */ + virtual const std::string & GetNthFileName( std::size_t i ) const = 0; + + /** Erase one element of the list. */ + virtual void Erase( std::size_t id ); + + /** */ + virtual void Erase( std::size_t start, std::size_t count ) = 0; + + /** Retrieve number of elements */ + virtual std::size_t Size() const = 0; + + /** */ + virtual bool IsActive( std::size_t ) const = 0; + + /** */ + virtual const std::string & GetToolTip( std::size_t ) const = 0; + + /** */ + virtual void Swap( std::size_t, std::size_t ) = 0; + + /** */ + virtual Role GetDirection( std::size_t ) const; + + /** */ + virtual Role GetDirection() const = 0; + + /** */ + virtual const std::string & GetFilenameFilter( std::size_t ) const; + + /** */ + virtual const std::string & GetFilenameFilter() const; + + /** */ + virtual bool IsFilename() const; + +protected: + /** Constructor */ + StringListInterface() {}; + +private: + +}; + +} // End namespace Wrapper + +} // End namespace otb + + +#endif // otbWrapperStringListInterface_h diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h index c0368288448ff268bde9308a64b227bf3665b7c1..a01a11db2f44e056e9fd9cfa691548bf3eefad2a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h @@ -21,11 +21,15 @@ #ifndef otbWrapperStringListParameter_h #define otbWrapperStringListParameter_h -#include <string> -#include "otbWrapperParameter.h" + +#include "otbWrapperParameterList.h" +#include "otbWrapperStringParameter.h" + namespace otb { + + namespace Wrapper { @@ -34,114 +38,79 @@ namespace Wrapper * * \ingroup OTBApplicationEngine */ -class OTBApplicationEngine_EXPORT StringListParameter - : public Parameter +class OTBApplicationEngine_EXPORT StringListParameter : + public ParameterList< StringParameter > { +// +// Public methods. public: /** Standard class typedef */ typedef StringListParameter Self; - typedef Parameter Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef ParameterList< StringParameter > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - typedef std::vector<std::string> StringListType; + typedef StringListInterface::StringVector StringListType; /** Defining ::New() static method */ - itkNewMacro(Self) -; + itkNewMacro( Self ); /** RTTI support */ - itkTypeMacro(StringListParameter, Parameter) -; + itkTypeMacro( StringListParameter, ParameterList ); /** Set the value */ - void SetValue(StringListType sList) - { - m_Value.clear(); - for(unsigned int i=0; i<sList.size(); i++) - { - this->AddString(sList[i]); - } - } - - void AddString(std::string value) - { - if(!value.empty()) - { - m_Value.push_back(value); - if(!this->GetActive()) - { - this->SetActive(true); - } - } - } + void SetValue( const StringListInterface::StringVector & ); - /** Get the value */ - StringListType GetValue() const - { - return m_Value; - } + /** */ + void AddString( const std::string & value ); /** Get the value */ - std::string GetNthElement(unsigned int i) const - { - if (m_Value.size() < i) - { - itkExceptionMacro( "Invalid index "<<i<<" the string list has only "<<m_Value.size()<<" elements...") - } + StringListInterface::StringVector GetValue() const; - return m_Value[i]; - } + /** Get the value */ + const std::string & GetNthElement( std::size_t ) const; /** Get the value */ - void SetNthElement(unsigned int i, std::string value) - { - if (m_Value.size() < i) - { - itkExceptionMacro( "Invalid index "<<i<<" the string list has only "<<m_Value.size()<<" elements...") - } - m_Value[i] = value; - } - - bool HasValue() const ITK_OVERRIDE - { - return !m_Value.empty(); - } - - void ClearValue() ITK_OVERRIDE - { - m_Value.clear(); - } - - void AddNullElement() - { - m_Value.push_back(""); - SetActive(false); - this->Modified(); - } + void SetNthElement( std::size_t, const std::string & ); + /** */ + using StringListInterface::GetDirection; + Role GetDirection() const override; + + /** */ + bool IsFilename() const override; + +// +// Protected methods. protected: /** Constructor */ - StringListParameter() - { - this->SetName("String List"); - this->SetKey("strList"); - } + StringListParameter(); /** Destructor */ - ~StringListParameter() ITK_OVERRIDE - { - } + ~StringListParameter() override; + + /** */ + const std::string & ToString( const ParameterType::Pointer & ) const override; - StringListType m_Value; + /** */ + using Superclass::FromString; + const ParameterType::Pointer & + FromString( const ParameterType::Pointer &, + const std::string & ) const override; +// +// Private methods. private: - StringListParameter(const StringListParameter &); //purposely not implemented - void operator =(const StringListParameter&); //purposely not implemented + // Purposely not implemented + StringListParameter ( const StringListParameter & ); + + // Purposely not implemented + void operator = ( const StringListParameter & ); }; // End class Parameter } // End namespace Wrapper + } // End namespace otb #endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h index a8f7943dbc2bd565e660ba7ed9cbaae653063e5c..9c8b1e88a976707a3da0d29842775f138777cd2b 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h @@ -51,14 +51,14 @@ public: itkTypeMacro(StringParameter, Parameter); /** Set the value */ - void SetValue( std::string value) + void SetValue( const std::string & value ) { m_Value = value; - SetActive(true); + SetActive( true ); } /** Get the value */ - std::string GetValue() const + const std::string & GetValue() const { return m_Value; } diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index f00cb08571c9834067dadb996004bac9efa2f39e..63dafb639b432a1e3508084cdcc860b7c9efc7ae 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -87,7 +87,7 @@ typedef enum typedef enum { - Role_Input, + Role_Input = 0, Role_Output } Role; diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 3251a05d8e7f250abf1aae901438544cd7ae13eb..343f9db8354ca588189b10f7fcf625413225f1e4 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -18,7 +18,7 @@ # limitations under the License. # -set(OTBApplicationEngine_SRC +set( OTBApplicationEngine_SRC otbWrapperApplicationHtmlDocGenerator.cxx otbWrapperComplexOutputImageParameter.cxx otbWrapperInputVectorDataListParameter.cxx @@ -48,11 +48,15 @@ set(OTBApplicationEngine_SRC otbWrapperApplicationRegistry.cxx otbWrapperApplicationFactoryBase.cxx otbWrapperCompositeApplication.cxx + otbWrapperStringListInterface.cxx + otbWrapperStringListParameter.cxx + otbWrapperAbstractParameterList.cxx + otbWrapperParameterList.cxx otbLogger.cxx ) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) -target_link_libraries(OTBApplicationEngine +target_link_libraries(OTBApplicationEngine ${OTBVectorDataBase_LIBRARIES} ${OTBImageManipulation_LIBRARIES} ${OTBImageIO_LIBRARIES} diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperParameterTest.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperAbstractParameterList.cxx similarity index 50% rename from Modules/Wrappers/ApplicationEngine/test/otbWrapperParameterTest.cxx rename to Modules/Wrappers/ApplicationEngine/src/otbWrapperAbstractParameterList.cxx index e4104cdc6560c6b391b094b372b841b0fb376799..06b3cef29cbb21c783f3ed4c99b8b7df89662496 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperParameterTest.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperAbstractParameterList.cxx @@ -18,37 +18,31 @@ * limitations under the License. */ -#if defined(_MSC_VER) -#pragma warning ( disable : 4786 ) -#endif +#include "otbWrapperAbstractParameterList.h" -#include "otbWrapperParameter.h" -int otbWrapperParameterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[]) +namespace otb { - typedef otb::Wrapper::Parameter ParameterBaseType; - ParameterBaseType::Pointer parameter = ParameterBaseType::New(); - //std::cout << parameter << std::endl; - return EXIT_SUCCESS; +namespace Wrapper +{ + + +/*****************************************************************************/ +AbstractParameterList +::AbstractParameterList() +{ } -int otbWrapperParameterTest1(int itkNotUsed(argc), char* argv[]) +/*****************************************************************************/ +AbstractParameterList +::~AbstractParameterList() { - typedef otb::Wrapper::Parameter ParameterBaseType; - ParameterBaseType::Pointer parameter = ParameterBaseType::New(); +} - const std::string name = argv[1]; - parameter->SetName(name); +} // End of namespace 'Wrapper' - if (name == parameter->GetName()) - { - return EXIT_SUCCESS; - } - else - { - return EXIT_FAILURE; - } -} + +} // End of namespace 'otb' diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 47c4e85d5fef4371e1454c0c65f35166ffea32a9..776b09fa45e894afe8efe0feb2980410de48b3bd 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -265,20 +265,17 @@ void Application::SetParameterStringList(std::string parameter, std::vector<std: if (dynamic_cast<InputImageListParameter*>(param)) { InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); - if( !paramDown->SetListFromFileName(values) ) - otbAppLogCRITICAL( <<"At least one image filename is invalid."); + paramDown->SetListFromFileName( values ); } else if (dynamic_cast<InputVectorDataListParameter*>(param)) { InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*>(param); - if( !paramDown->SetListFromFileName(values) ) - otbAppLogCRITICAL( <<"At least one vector data filename is invalid.."); + paramDown->SetListFromFileName( values ); } else if (dynamic_cast<InputFilenameListParameter*>(param)) { InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*>(param); - if( !paramDown->SetListFromFileName(values) ) - otbAppLogCRITICAL( <<"At least one filename is invalid.."); + paramDown->SetListFromFileName( values ); } else if (dynamic_cast<StringListParameter*>(param)) { @@ -476,7 +473,7 @@ int Application::ExecuteAndWriteOutput() { Parameter* param = GetParameterByKey(key); ComplexOutputImageParameter* outputParam = dynamic_cast<ComplexOutputImageParameter*>(param); - + if(outputParam!=ITK_NULLPTR) { outputParam->InitializeWriters(); @@ -884,7 +881,7 @@ void Application::SetListViewSingleSelectionMode(std::string parameter, bool sta } else itkExceptionMacro(<<parameter << "parameter can't be casted to ListView"); - + } @@ -1124,14 +1121,16 @@ std::string Application::GetParameterString(std::string parameter) return ret; } -std::vector<std::string> Application::GetParameterStringList(std::string parameter) +std::vector< std::string > +Application +::GetParameterStringList( const std::string & parameter ) { std::vector<std::string> ret; - Parameter* param = GetParameterByKey(parameter); + Parameter * param = GetParameterByKey(parameter); if (dynamic_cast<InputImageListParameter*> (param)) { - InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*> (param); + InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter*> (param); ret = paramDown->GetFileNameList(); } else @@ -1143,13 +1142,13 @@ std::vector<std::string> Application::GetParameterStringList(std::string paramet else if (dynamic_cast<InputFilenameListParameter*> (param)) { - InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*> (param); + InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*> (param); ret = paramDown->GetFileNameList(); } else if (dynamic_cast<StringListParameter*> (param)) { - StringListParameter* paramDown = dynamic_cast<StringListParameter*> (param); + StringListParameter* paramDown = dynamic_cast<StringListParameter*> (param); ret = paramDown->GetValue(); } else @@ -1171,7 +1170,7 @@ void Application::SetParameterInputImage(std::string parameter, InputImageParame Parameter* param = GetParameterByKey(parameter); InputImageParameter* paramDown = dynamic_cast<InputImageParameter*> (param); - + if (paramDown) { paramDown->SetImage(inputImage); @@ -1185,11 +1184,11 @@ void Application::SetParameterInputImage(std::string parameter, InputImageParame OutputImageParameter::ImageBaseType * Application::GetParameterOutputImage(std::string parameter) { Parameter* param = GetParameterByKey(parameter); - + OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*> (param); - + if (paramDown) - { + { return paramDown->GetValue(); } else @@ -1204,7 +1203,7 @@ void Application::SetParameterComplexInputImage(std::string parameter, ComplexIn Parameter* param = GetParameterByKey(parameter); ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*> (param); - + if (paramDown) { paramDown->SetImage(inputImage); @@ -1218,11 +1217,11 @@ void Application::SetParameterComplexInputImage(std::string parameter, ComplexIn ComplexOutputImageParameter::ImageBaseType * Application::GetParameterComplexOutputImage(std::string parameter) { Parameter* param = GetParameterByKey(parameter); - + ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*> (param); - + if (paramDown) - { + { return paramDown->GetValue(); } else @@ -1234,9 +1233,9 @@ ComplexOutputImageParameter::ImageBaseType * Application::GetParameterComplexOut void Application::AddImageToParameterInputImageList(std::string parameter, InputImageListParameter::ImageBaseType * img) { Parameter* param = GetParameterByKey(parameter); - + InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - + if(paramDown) { paramDown->AddImage(img); @@ -1245,7 +1244,7 @@ void Application::AddImageToParameterInputImageList(std::string parameter, Input { itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); } - + } void Application::SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img) @@ -1268,9 +1267,9 @@ void Application::SetNthParameterInputImageList(std::string parameter, const uns void Application::AddParameterStringList(std::string parameter, const std::string & str) { Parameter* param = GetParameterByKey(parameter); - + InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - + if(paramDown) { paramDown->AddFromFileName(str); @@ -1279,7 +1278,7 @@ void Application::AddParameterStringList(std::string parameter, const std::strin { itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); } - + } void Application::SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string & str) @@ -1454,7 +1453,10 @@ std::string Application::GetParameterAsString(std::string paramKey) oss << this->GetParameterFloat( paramKey ); ret = oss.str(); } - else if( type == ParameterType_StringList ) + else if( type == ParameterType_StringList || + type == ParameterType_InputImageList || + type == ParameterType_InputVectorDataList || + type == ParameterType_InputFilenameList) { std::ostringstream oss; oss << std::setprecision(10); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx index df0ed51e820e95e9dc3cf19f87b6528d5dc2a1ff..6c59ad4c83753feeacf012655642eba680586279 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx @@ -52,27 +52,10 @@ ComplexInputImageParameter::SetFromFileName(const std::string& filename) // - Done in the reader // - allow appending additional information to the filename // myfile.tif:2 for example, or myfile.tif:nocarto - if (!filename.empty()) - { - ComplexFloatVectorReaderType::Pointer reader = ComplexFloatVectorReaderType::New(); - - try - { - reader->SetFileName(filename); - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject & /*err*/) - { - return false; - } - - // the specified filename is valid => store the value - m_FileName = filename; - m_UseFilename = true; - SetActive(true); - return true; - } - return false; + m_FileName = filename; + m_UseFilename = true; + SetActive(true); + return true; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index ce11263ccd7cab428275ce32d374264afc12f85c..64ef3657181d767341ce804d642374d6ed7b6a27 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -73,6 +73,18 @@ ComplexOutputImageParameter::ConvertPixelTypeToString(ComplexImagePixelType type return ret; } +bool +ComplexOutputImageParameter::ConvertStringToPixelType(const std::string &value, ComplexImagePixelType &type) +{ + if (value == "cfloat") + type = ComplexImagePixelType_float; + else if (value == "cdouble") + type = ComplexImagePixelType_double; + else + return false; + return true; +} + void ComplexOutputImageParameter::InitializeWriters() { m_ComplexFloatWriter = ComplexFloatWriterType::New(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx index e65e22078177f51cf6d8f85a188d68f4ac9f1416..72b5aa13caf22c3827c30c52722f46d7bffd733d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx @@ -19,189 +19,110 @@ */ #include "otbWrapperInputFilenameListParameter.h" -#include "itksys/SystemTools.hxx" + namespace otb { + + namespace Wrapper { -InputFilenameListParameter::InputFilenameListParameter() -{ - this->SetName("Input Filename List"); - this->SetKey("inList"); - m_FilenameList = StringParameterListType::New(); -} -InputFilenameListParameter::~InputFilenameListParameter() -{ -} +const std::string FILENAME_FILTER( + "All files (*);;" + "CSV files (.csv);;" + "Text files (.txt);;" + "XML files (.xml)" +); + -bool -InputFilenameListParameter::SetListFromFileName(const std::vector<std::string> & filenames) +/*****************************************************************************/ +InputFilenameListParameter +::InputFilenameListParameter() { - // First clear previous file chosen - this->ClearValue(); - - for(unsigned int i=0; i<filenames.size(); i++) - { - std::string filename = filenames[i]; - // File existence checked by the reader - if (!filename.empty()) - { - StringParameter::Pointer strParameter = StringParameter::New(); - strParameter->SetValue(filename); - strParameter->HasValue(); - - // everything went fine, store the object reference - m_FilenameList->PushBack(strParameter); - } - } - - SetActive(true); - this->Modified(); - return true; + SetName( "Input Filename List" ); + SetKey( "inList" ); } -void -InputFilenameListParameter::AddNullElement() +/*****************************************************************************/ +InputFilenameListParameter +::~InputFilenameListParameter() { - m_FilenameList->PushBack(ITK_NULLPTR); - SetActive(false); - this->Modified(); } -bool -InputFilenameListParameter::AddFromFileName(const std::string & filename) -{ - // File existence checked by the reader - if (!filename.empty()) - { - StringParameter::Pointer strParameter = StringParameter::New(); - strParameter->SetValue(filename); - strParameter->HasValue(); - - // everything went fine, store the object references - m_FilenameList->PushBack(strParameter); - SetActive(true); - this->Modified(); - return true; - } - - return false; -} -bool -InputFilenameListParameter::SetNthFileName( const unsigned int id, const std::string & filename ) +/*****************************************************************************/ +Role +InputFilenameListParameter +::GetDirection( std::size_t ) const { - if( m_FilenameList->Size()<id ) - { - itkExceptionMacro(<< "No file "<<id<<". Only "<<m_FilenameList->Size()<<" filenames available."); - } - - // File existence checked by the reader - if (!filename.empty()) - { - StringParameter::Pointer strParameter = StringParameter::New(); - strParameter->SetValue(filename); - strParameter->HasValue(); - - m_FilenameList->SetNthElement(id, strParameter); - SetActive(true); - this->Modified(); - return true; - } - - return false; -} +#if 0 + assert( i<m_FilenameList->Size() ); + assert( !m_FilenameList->GetNthElement( i ).IsNull() ); + return m_FilenameList->GetNthElement( i )->GetRole(); -std::vector<std::string> -InputFilenameListParameter::GetFileNameList() const -{ - if (m_FilenameList) - { - std::vector<std::string> filenames; - for(unsigned int i=0; i<m_FilenameList->Size(); i++) - { - if( m_FilenameList->GetNthElement(i) ) - filenames.push_back( m_FilenameList->GetNthElement(i)->GetValue() ); - } - - return filenames; - } - - itkExceptionMacro(<< "No filename value"); +#else + // otb::Parameter::GetRole() does not necessarily stand for + // direction of parameter. + return GetDirection(); + +#endif } -std::string -InputFilenameListParameter::GetNthFileName( unsigned int i ) const +/*****************************************************************************/ +Role +InputFilenameListParameter +::GetDirection() const { - if (m_FilenameList) - { - if(m_FilenameList->Size()<i) - { - itkExceptionMacro(<< "No file "<<i<<". Only "<<m_FilenameList->Size()<<" filenames available."); - } - - return m_FilenameList->GetNthElement(i)->GetValue(); - } - - itkExceptionMacro(<< "No filename value"); + return Role_Input; } -InputFilenameListParameter::StringParameterListPointerType -InputFilenameListParameter::GetFileList() const +/*****************************************************************************/ +const std::string & +InputFilenameListParameter +::GetFilenameFilter( std::size_t ) const { - return m_FilenameList; + return GetFilenameFilter(); } -bool -InputFilenameListParameter::HasValue() const + +/*****************************************************************************/ +const std::string & +InputFilenameListParameter +::GetFilenameFilter() const { - if(m_FilenameList->Size() == 0) - { - return false; - } - - bool res(true); - unsigned int i(0); - while(i < m_FilenameList->Size() && res == true) - { - res = m_FilenameList->GetNthElement(i).IsNotNull(); - i++; - } - - return res; + return FILENAME_FILTER; } -void -InputFilenameListParameter::Erase( unsigned int id ) +/*****************************************************************************/ +const std::string & +InputFilenameListParameter +::ToString( const ParameterType::Pointer & p ) const { - if(m_FilenameList->Size()<id) - { - itkExceptionMacro(<< "No file "<<id<<". Only "<<m_FilenameList->Size()<<" filenames available."); - } + assert( !p.IsNull() ); - m_FilenameList->Erase( id ); - - this->Modified(); + return p->GetValue(); } -void -InputFilenameListParameter::ClearValue() +/*****************************************************************************/ +const InputFilenameListParameter::ParameterType::Pointer & +InputFilenameListParameter +::FromString( const ParameterType::Pointer & p, + const std::string & s ) const { - m_FilenameList->Clear(); - - SetActive(false); - this->Modified(); -} + assert( !p.IsNull() ); + p->SetValue( s ); + return p; } + } +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx index 01c31e196abfc40267f0291f703fe4db20ed0c52..4bb5f6159a6af26f09040a54d0ecfe0d604fa7c0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx @@ -19,280 +19,235 @@ */ #include "otbWrapperInputImageListParameter.h" -#include "itksys/SystemTools.hxx" + + +#include "otbCast.h" + namespace otb { + namespace Wrapper { -InputImageListParameter::InputImageListParameter() - : m_InputImageParameterVector(), - m_ImageList(FloatVectorImageListType::New()) -{ - this->SetName("Input Image List"); - this->SetKey("inList"); -} -InputImageListParameter::~InputImageListParameter() -{ -} +const std::string +IMAGES_FILTER( + "All files (*);;" + "TIFF file (*tif);;" + "PNG File (*.png);;" + "JPEG File (*.jpg)" +); + -bool -InputImageListParameter::SetListFromFileName(const std::vector<std::string> & filenames) +/*****************************************************************************/ +InputImageParameter::Pointer +InputImageListParameter +::FromImage( ImageBaseType * image ) { - // First clear previous file chosen - this->ClearValue(); + assert( image!=nullptr ); - for(unsigned int i=0; i<filenames.size(); i++) - { - const std::string filename = filenames[i]; + InputImageParameter::Pointer p; - // File existence checked by the reader - if (!filename.empty()) - { - // Try to build a new ParameterInputImage - InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetFromFileName(filename); + return FromImage( p, image ); +} - m_InputImageParameterVector.push_back(tmpInputImageParameter); - } - } +/*****************************************************************************/ +InputImageParameter::Pointer & +InputImageListParameter +::FromImage( InputImageParameter::Pointer & parameter, + ImageBaseType * image ) +{ + return + FromData( + parameter, + image, + []( auto p, auto i ) -> void + { + assert( p ); - this->Modified(); - SetActive(true); - return true; + p->SetImage( i ); + }, + "Image filename" + ); } -void -InputImageListParameter::AddNullElement() +/*****************************************************************************/ +InputImageListParameter +::InputImageListParameter() : + m_ImageList( FloatVectorImageListType::New() ) { - m_InputImageParameterVector.push_back(ITK_NULLPTR); - SetActive(false); - this->Modified(); + SetName( "Input Image List" ); + SetKey( "inList" ); } -bool -InputImageListParameter::AddFromFileName(const std::string & filename) -{ - // File existence checked by the reader - if (!filename.empty()) - { - InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetFromFileName(filename); - - m_InputImageParameterVector.push_back(tmpInputImageParameter); - - this->Modified(); - SetActive(true); - return true; - } - return false; +/*****************************************************************************/ +InputImageListParameter +::~InputImageListParameter() +{ } -bool -InputImageListParameter::SetNthFileName( const unsigned int id, const std::string & filename ) +/*****************************************************************************/ +const FloatVectorImageListType * +InputImageListParameter +::GetImageList() const { - if( m_InputImageParameterVector.size()<id ) - { - itkExceptionMacro(<< "No image "<<id<<". Only "<<m_InputImageParameterVector.size()<<" images available."); - } - - // File existence checked by the reader - if (!filename.empty()) - { - InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetFromFileName(filename); - - m_InputImageParameterVector[id] = tmpInputImageParameter; - - this->Modified(); - SetActive(true); - return true; - } - - return false; + return const_cast< InputImageListParameter * >( this )->GetImageList(); } -std::vector<std::string> -InputImageListParameter::GetFileNameList() const +/*****************************************************************************/ +FloatVectorImageListType * +InputImageListParameter +::GetImageList() { - std::vector<std::string> filenames; - - for(InputImageParameterVectorType::const_iterator it = m_InputImageParameterVector.begin(); - it!=m_InputImageParameterVector.end();++it) - { - if(it->IsNull()) + return + GetObjectList( + m_ImageList, + []( auto param ) -> auto { - itkExceptionMacro(<< "Empty image in InputImageListParameter."); - } - filenames.push_back( (*it)->GetFileName() ); - } + assert( param ); - return filenames; + return param->GetFloatVectorImage(); + } + ); } -std::string -InputImageListParameter::GetNthFileName( unsigned int i ) const +/*****************************************************************************/ +const FloatVectorImageType * +InputImageListParameter +::GetNthImage( std::size_t i ) const { - if(m_InputImageParameterVector.size()<i) - { - itkExceptionMacro(<< "No image "<<i<<". Only "<<m_InputImageParameterVector.size()<<" images available."); - } - if(m_InputImageParameterVector[i].IsNull()) - { - itkExceptionMacro(<< "Requested image "<<i<<" has no filename"); - } - return m_InputImageParameterVector[i]->GetFileName(); + return const_cast< InputImageListParameter * >( this )->GetNthImage( i ); } -FloatVectorImageListType* -InputImageListParameter::GetImageList() const -{ - m_ImageList->Clear(); - for (unsigned int i=0 ; i < this->Size() ; ++i) - { - if(m_InputImageParameterVector[i].IsNull()) - { - itkExceptionMacro(<< "Image "<<i<<" is empty."); - } - m_ImageList->PushBack(m_InputImageParameterVector[i]->GetFloatVectorImage()); - } - return m_ImageList; -} -FloatVectorImageType* -InputImageListParameter::GetNthImage(unsigned int i) const +/*****************************************************************************/ +FloatVectorImageType * +InputImageListParameter::GetNthImage( std::size_t i ) { - if(this->Size()<=i) - { - itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); - } - if(m_InputImageParameterVector[i].IsNull()) - { - itkExceptionMacro(<< "Image "<<i<<" is empty."); - } - return m_InputImageParameterVector[i]->GetFloatVectorImage(); + assert( i<Size() ); + assert( !m_Parameters[ i ].IsNull() ); + assert( m_Parameters[ i ]->GetFloatVectorImage()!=nullptr ); + + return m_Parameters[ i ]->GetFloatVectorImage(); } +/*****************************************************************************/ void -InputImageListParameter::SetImageList(FloatVectorImageListType* imList) +InputImageListParameter +::SetImageList( FloatVectorImageListType * imList ) { - // Check input availability - for(unsigned int i = 0; i < imList->Size(); i++) - { - imList->GetNthElement(i)->UpdateOutputInformation(); - } + assert( imList!=nullptr ); + assert( !m_ImageList.IsNull() ); - // Clear previous values - this->ClearValue(); - - for(unsigned int i = 0; i<imList->Size(); i++) + SetObjectList( + *m_ImageList, + *imList, + [ this ]( auto p, auto image ) -> auto { - // Try to build a new ParameterInputImage - InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - - tmpInputImageParameter->SetImage(imList->GetNthElement(i)); + this->FromImage( p, image ); + }, + // + []( auto p ) -> auto + { + assert( p ); - m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); + return p->GetFloatVectorImage(); } - - SetActive(true); - this->Modified(); + ); } -void InputImageListParameter::SetNthImage(unsigned int i, ImageBaseType * img) + +/*****************************************************************************/ +void +InputImageListParameter +::SetNthImage( std::size_t i, ImageBaseType * image ) { - if(this->Size()<i) - { - itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); - } + assert( i<Size() ); + assert( image!=nullptr ); // Check input availability - img->UpdateOutputInformation(); - - // Try to build a new ParameterInputImage - InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - - tmpInputImageParameter->SetImage(img); + image->UpdateOutputInformation(); - m_InputImageParameterVector[i] = tmpInputImageParameter; + // Build parameter. + FromImage( m_Parameters[ i ], image ); } +/*****************************************************************************/ void -InputImageListParameter::AddImage(ImageBaseType* image) +InputImageListParameter +::AddImage( ImageBaseType * image ) { - // Check input availability - image->UpdateOutputInformation(); + AddData( + image, + [ this ]( auto i ) -> auto + { + return this->FromImage( i ); + } + ); +} - InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetImage(image); +/*****************************************************************************/ +void +InputImageListParameter +::ClearValue() +{ + Superclass::ClearValue(); - m_InputImageParameterVector.push_back(tmpInputImageParameter); + assert( m_ImageList ); - this->Modified(); + m_ImageList->Clear(); } -bool -InputImageListParameter::HasValue() const + +/*****************************************************************************/ +Role +InputImageListParameter +::GetDirection() const { - if(this->Size() == 0) - { - return false; - } + return Role_Input; +} - bool res(true); - unsigned int i(0); - while(i < this->Size() && res == true) - { - res = (m_InputImageParameterVector[i] ? - m_InputImageParameterVector[i]->HasValue() : - false); - i++; - } - return res; +/*****************************************************************************/ +const std::string & +InputImageListParameter +::GetFilenameFilter() const +{ + return IMAGES_FILTER; } -void -InputImageListParameter::Erase( unsigned int id ) +/*****************************************************************************/ +const std::string & +InputImageListParameter +::ToString( const ParameterType::Pointer & p ) const { - if(this->Size()<id) - { - itkExceptionMacro(<< "No image "<<id<<". Only "<<this->Size()<<" images available."); - } + assert( !p.IsNull() ); - m_InputImageParameterVector.erase(m_InputImageParameterVector.begin()+id); - - this->Modified(); + return p->GetFileName(); } -unsigned int -InputImageListParameter::Size() const +/*****************************************************************************/ +const InputImageListParameter::ParameterType::Pointer & +InputImageListParameter +::FromString( const ParameterType::Pointer & p, + const std::string & s ) const { - return m_InputImageParameterVector.size(); -} + assert( !p.IsNull() ); + p->SetFromFileName( s ); -void -InputImageListParameter::ClearValue() -{ - m_ImageList->Clear(); - m_InputImageParameterVector.clear(); - - SetActive(false); - this->Modified(); + return p; } } -} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index 08c0e1c36249954b7a18c58fd253f7df9d0d1b67..166ab2956ad5fc46a6bd1df6a1298e3066b4f23f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -26,6 +26,7 @@ namespace otb { + namespace Wrapper { @@ -55,7 +56,8 @@ InputImageParameter::SetFromFileName(const std::string& filename) // myfile.tif:2 for example, or myfile.tif:nocarto m_FileName = filename; m_UseFilename = true; - SetActive(true); + SetActive( true ); + return true; } @@ -88,14 +90,15 @@ InputImageParameter::HasValue() const } void -InputImageParameter::ClearValue() +InputImageParameter +::ClearValue() { - m_Image = ITK_NULLPTR; - m_Reader = ITK_NULLPTR; - m_Caster = ITK_NULLPTR; - m_FileName = ""; - m_PreviousFileName=""; - m_UseFilename = true; + m_Image = ITK_NULLPTR; + m_Reader = ITK_NULLPTR; + m_Caster = ITK_NULLPTR; + m_FileName = ""; + m_PreviousFileName=""; + m_UseFilename = true; } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx index 8bfd04bbf50c86e349b732c8ec624774a1e79551..938936ebf64784d0287e9d5e4be25701e2c2c738 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx @@ -384,7 +384,6 @@ InputProcessXMLParameter::Read(Application::Pointer this_) if(itksys::SystemTools::FileExists(value.c_str())) { InputVectorDataParameter* paramDown = dynamic_cast<InputVectorDataParameter*>(param); - paramDown->SetFromFileName(value); if ( !paramDown->SetFromFileName(value) ) { ret = -1; @@ -395,28 +394,16 @@ InputProcessXMLParameter::Read(Application::Pointer this_) { InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); paramDown->SetListFromFileName(values); - if ( !paramDown->SetListFromFileName(values) ) - { - ret = -1; - } } else if (dynamic_cast<InputVectorDataListParameter*>(param)) { InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*>(param); - paramDown->SetListFromFileName(values); - if ( !paramDown->SetListFromFileName(values) ) - { - ret = -1; - } + paramDown->SetListFromFileName( values ); } else if (dynamic_cast<InputFilenameListParameter*>(param)) { InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*>(param); - paramDown->SetListFromFileName(values); - if ( !paramDown->SetListFromFileName(values) ) - { - ret= -1; - } + paramDown->SetListFromFileName( values ); } else if (type == ParameterType_Radius || type == ParameterType_Int || typeAsString == "rand" ) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx index 8b40c1e13ae77c4974542986b65f51bb2bac2fe6..3b21c919327b2b75ae04c2d9073fab0b0c595125 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx @@ -19,291 +19,201 @@ */ #include "otbWrapperInputVectorDataListParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperMacros.h" namespace otb { -namespace Wrapper -{ -InputVectorDataListParameter::InputVectorDataListParameter() -{ - this->SetName("Input VectorData List"); - this->SetKey("vdList"); - m_VectorDataList = VectorDataListType::New(); - m_ReaderList = VectorDataFileReaderListType::New(); -} -InputVectorDataListParameter::~InputVectorDataListParameter() +namespace Wrapper { -} -bool -InputVectorDataListParameter::SetListFromFileName(const std::vector<std::string> & filenames) -{ - // First clear previous file chosen - this->ClearValue(); - bool isOk = true; - for(unsigned int i=0; i<filenames.size(); i++) - { - const std::string filename = filenames[i]; - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - if (!filename.empty()) - { - VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); - try - { - reader->SetFileName(filename); - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject & /*err*/) - { - this->ClearValue(); - isOk = false; - break; - } - - // everything went fine, store the object references - m_ReaderList->PushBack(reader); - m_VectorDataList->PushBack(reader->GetOutput()); - } - } +const std::string +VECTOR_DATA_FILTER( + "All files (*);;" + "Shape file (*shp)" +); - if( !isOk ) - { - return false; - } - SetActive(true); - this->Modified(); - return true; -} +/*****************************************************************************/ +InputVectorDataParameter::Pointer +InputVectorDataListParameter +::FromVectorData( VectorDataType * data ) +{ + assert( data!=nullptr ); + InputVectorDataParameter::Pointer p; -void -InputVectorDataListParameter::AddNullElement() -{ - m_ReaderList->PushBack(ITK_NULLPTR); - m_VectorDataList->PushBack(ITK_NULLPTR); - SetActive(false); - this->Modified(); + return FromVectorData( p, data ); } -bool -InputVectorDataListParameter::AddFromFileName(const std::string & filename) +/*****************************************************************************/ +InputVectorDataParameter::Pointer & +InputVectorDataListParameter +::FromVectorData( InputVectorDataParameter::Pointer & parameter, + VectorDataType * data ) { - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - if (!filename.empty()) - { - VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); - reader->SetFileName(filename); - try + return + FromData( + parameter, + data, + []( auto p, auto d ) -> void { - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject & /*err*/) - { - this->ClearValue(); - return false; - } + assert( p ); - // everything went fine, store the object references - m_ReaderList->PushBack(reader); - m_VectorDataList->PushBack(reader->GetOutput()); - SetActive(true); - this->Modified(); - return true; - } - - return false; + p->SetVectorData( d ); + }, + "Vector-data filename" + ); } -bool -InputVectorDataListParameter::SetNthFileName( const unsigned int id, const std::string & filename ) +/*****************************************************************************/ +InputVectorDataListParameter +::InputVectorDataListParameter() : + m_VectorDataList( VectorDataListType::New() ) { - if( m_ReaderList->Size()<id ) - { - itkExceptionMacro(<< "No vectordata "<<id<<". Only "<<m_ReaderList->Size()<<" vector data available."); - } - - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - if (!filename.empty()) - { - VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); - reader->SetFileName(filename); - try - { - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject &) - { - this->ClearValue(); - return false; - } - - m_ReaderList->SetNthElement(id, reader); - m_VectorDataList->SetNthElement(id, reader->GetOutput()); - - this->Modified(); - return true; - } - - return false; + SetName( "Input VectorData List" ); + SetKey( "vdList" ); } - -std::vector<std::string> -InputVectorDataListParameter::GetFileNameList() const +/*****************************************************************************/ +InputVectorDataListParameter +::~InputVectorDataListParameter() { - if (m_ReaderList) - { - std::vector<std::string> filenames; - for(unsigned int i=0; i<m_ReaderList->Size(); i++) - { - if( m_ReaderList->GetNthElement(i) ) - filenames.push_back( m_ReaderList->GetNthElement(i)->GetFileName() ); - } - - return filenames; - } - - itkExceptionMacro(<< "No filename value"); } +/*****************************************************************************/ +const VectorDataListType * +InputVectorDataListParameter +::GetVectorDataList() const +{ + return + const_cast< InputVectorDataListParameter * >( this ) + ->GetVectorDataList(); +} -std::string -InputVectorDataListParameter::GetNthFileName( unsigned int i ) const +/*****************************************************************************/ +VectorDataListType * +InputVectorDataListParameter +::GetVectorDataList() { - if (m_ReaderList) - { - if(m_ReaderList->Size()<i) + return + GetObjectList( + m_VectorDataList, + []( auto param ) -> auto { - itkExceptionMacro(<< "No vector data "<<i<<". Only "<<m_ReaderList->Size()<<" vector data available."); - } + assert( param ); - return m_ReaderList->GetNthElement(i)->GetFileName(); - } - - itkExceptionMacro(<< "No filename value"); + return param->GetVectorData(); + } + ); } -VectorDataListType* -InputVectorDataListParameter::GetVectorDataList() const +/*****************************************************************************/ +const VectorDataType * +InputVectorDataListParameter +::GetNthVectorData( std::size_t i ) { - return m_VectorDataList; -} + assert( i<m_Parameters.size() ); + assert( !m_Parameters[ i ].IsNull() ); + assert( m_Parameters[ i ]->GetVectorData()!=nullptr ); -VectorDataType* -InputVectorDataListParameter::GetNthVectorData(unsigned int i) const -{ - if(m_VectorDataList->Size()<i) - { - itkExceptionMacro(<< "No vector data "<<i<<". Only "<<m_VectorDataList->Size()<<" vector data available."); - } - return m_VectorDataList->GetNthElement(i); + return m_Parameters[ i ]->GetVectorData(); } +/*****************************************************************************/ void -InputVectorDataListParameter::SetVectorDataList(VectorDataListType* vdList) +InputVectorDataListParameter +::SetVectorDataList( VectorDataListType * vdList ) { - // Check input availability - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - try + assert( vdList!=nullptr ); + assert( !m_VectorDataList.IsNull() ); + + SetObjectList( + *m_VectorDataList, + *vdList, + // + [ this ]( auto p, auto vd ) -> auto { - for(unsigned int i=0; i<vdList->Size(); i++) - { - vdList->GetNthElement( i )->UpdateOutputInformation(); - } - } - catch(itk::ExceptionObject &) + this->FromVectorData( p, vd ); + }, + // + []( auto p ) -> auto { - return; - } + assert( p ); - m_VectorDataList = vdList; - m_ReaderList = VectorDataFileReaderListType::Pointer(); - for(unsigned int i=0; i<m_VectorDataList->Size(); i++) - { - m_ReaderList->PushBack( VectorDataFileReaderType::Pointer() ); + return p->GetVectorData(); } - - SetActive(true); - this->Modified(); + ); } +/*****************************************************************************/ void -InputVectorDataListParameter::AddVectorData(VectorDataType* vectorData) +InputVectorDataListParameter +::AddVectorData( VectorDataType * vectorData ) { - // Check input availability - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - try - { - vectorData->UpdateOutputInformation(); - } - catch(itk::ExceptionObject &) + AddData( + vectorData, + [ this ]( auto d ) -> auto { - return; + return this->FromVectorData( d ); } - - m_VectorDataList->PushBack( vectorData ); - m_ReaderList->PushBack( VectorDataFileReaderType::Pointer() ); - - this->Modified(); + ); } -bool -InputVectorDataListParameter::HasValue() const +/*****************************************************************************/ +void +InputVectorDataListParameter +::ClearValue() { - if (m_VectorDataList->Size() == 0) - { - return false; - } + Superclass::ClearValue(); - bool res(true); - unsigned int i(0); - while (i < m_VectorDataList->Size() && res == true) - { - res = m_VectorDataList->GetNthElement(i).IsNotNull(); - i++; - } + assert( m_VectorDataList ); - return res; + m_VectorDataList->Clear(); } +/*****************************************************************************/ +Role +InputVectorDataListParameter +::GetDirection() const +{ + return Role_Input; +} -void -InputVectorDataListParameter::Erase( unsigned int id ) +/*****************************************************************************/ +const std::string & +InputVectorDataListParameter +::GetFilenameFilter() const { - if(m_VectorDataList->Size()<id) - { - itkExceptionMacro(<< "No vector data "<<id<<". Only "<<m_VectorDataList->Size()<<" vector data available."); - } + return VECTOR_DATA_FILTER; +} - m_VectorDataList->Erase( id ); - m_ReaderList->Erase( id ); +/*****************************************************************************/ +const std::string & +InputVectorDataListParameter +::ToString( const ParameterType::Pointer & p ) const +{ + assert( !p.IsNull() ); - this->Modified(); + return p->GetFileName(); } -void -InputVectorDataListParameter::ClearValue() +/*****************************************************************************/ +const InputVectorDataListParameter::ParameterType::Pointer & +InputVectorDataListParameter +::FromString( const ParameterType::Pointer & p, + const std::string & s ) const { - m_VectorDataList->Clear(); - m_ReaderList->Clear(); + assert( !p.IsNull() ); + + p->SetFromFileName( s ); - SetActive(false); - this->Modified(); + return p; } } -} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx index ee3b2559136860c5a35acd8ce28d2e370b9b49a5..f60cf29078bf0c487c35b90ed0c94f9fcee1800d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx @@ -43,53 +43,37 @@ InputVectorDataParameter::SetFromFileName(const std::string& filename) // First clear previous file chosen this->ClearValue(); - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - if (!filename.empty() - && itksys::SystemTools::FileExists(filename.c_str())) - { - VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); - try - { - reader->SetFileName(filename); - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject & /*err*/) - { - return false; - } + // No file existence is done here : + m_FileName = filename; + SetActive( true ); - // the specified filename is valid => store the value - m_FileName = filename; - SetActive(true); - return true; - } - return false; + return true; } -VectorDataType* +const VectorDataType * +InputVectorDataParameter +::GetVectorData() const +{ + return const_cast< InputVectorDataParameter * >( this )->GetVectorData(); +} + +VectorDataType * InputVectorDataParameter::GetVectorData() { // 2 cases : the user sets a filename vs. the user sets a vector data //////////////////////// Filename case: - if (!m_FileName.empty()) + if (!m_FileName.empty() && m_PreviousFileName!=m_FileName) { - //typedef otb::ImageFileReader<TOutputImage> ReaderType; - //typename ReaderType::Pointer reader = ReaderType::New(); - m_Reader = VectorDataFileReaderType::New(); - m_Reader->SetFileName(m_FileName); - try - { - // Update the viewer here to load the file => no streaming for VectorData - m_Reader->Update(); - } - catch (itk::ExceptionObject &) - { - this->ClearValue(); - } + VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); + reader->SetFileName(m_FileName); + // Update the viewer here to load the file => no streaming for VectorData + reader->Update(); + + m_VectorData = reader->GetOutput(); + m_Reader = reader; - m_VectorData = m_Reader->GetOutput(); + m_PreviousFileName = m_FileName; } //////////////////////// VectorData case: else @@ -97,7 +81,7 @@ InputVectorDataParameter::GetVectorData() if (m_VectorData.IsNull()) { // Else : error - itkExceptionMacro("No input vector data or filename detected..."); + itkExceptionMacro("No input vector data detected..."); } } @@ -131,5 +115,3 @@ InputVectorDataParameter::ClearValue() } } - - diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx index 364fb600359f0964f7d4b35a99e5a8bb0e63c0ec..493191677c554686770604ca734effe4017c3784 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx @@ -33,8 +33,8 @@ namespace Wrapper void MapProjectionParametersHandler::AddMapProjectionParameters( Application::Pointer app, const std::string & key) { - app->AddParameter(ParameterType_Choice, key, "Output Cartographic Map Projection"); - app->SetParameterDescription(key,"Parameters of the output map projection to be used."); + app->AddParameter(ParameterType_Choice, key, "Map Projection"); + app->SetParameterDescription(key,"Defines the map projection to be used."); // utm std::ostringstream oss; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index b2f2d8d5523d00adb29e556c0ca4d811b5902d43..2790bdce255aa5d0e8a3f92ab625e274ce48bf10 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -98,6 +98,28 @@ std::string OutputImageParameter::ConvertPixelTypeToString(ImagePixelType type) return ret; } +bool +OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePixelType &type) +{ + if (value == "uint8") + type = ImagePixelType_uint8; + else if (value == "int16") + type = ImagePixelType_int16; + else if (value == "uint16") + type = ImagePixelType_uint16; + else if (value == "int32") + type = ImagePixelType_int32; + else if (value == "uint32") + type = ImagePixelType_uint32; + else if (value == "float") + type = ImagePixelType_float; + else if (value == "double") + type = ImagePixelType_double; + else + return false; + return true; +} + void OutputImageParameter::InitializeWriters() { m_UInt8Writer = UInt8WriterType::New(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterList.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterList.cxx new file mode 100644 index 0000000000000000000000000000000000000000..272f1faed2932f63b79ed56628ecba0b9ceb3552 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterList.cxx @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperParameterList.h" + + +namespace otb +{ + + +namespace Wrapper +{ + + +} // End of namespace 'Wrapper' + + +} // End of namespace 'otb' diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListInterface.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListInterface.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3f8175ef55aa7aec9aa5a3fb521a1495df337748 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListInterface.cxx @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "otbWrapperStringListInterface.h" + + +namespace otb +{ + + +namespace Wrapper +{ + +const std::string +NULL_STRING; + + +/*****************************************************************************/ +void +StringListInterface +::AddNullElement() +{ + InsertNullElement(); +} + + +/*****************************************************************************/ +Role +StringListInterface +::GetDirection( std::size_t ) const +{ + return GetDirection(); +} + + +/*****************************************************************************/ +const std::string & +StringListInterface +::GetFilenameFilter( std::size_t ) const +{ + return GetFilenameFilter(); +} + + +/*****************************************************************************/ +const std::string & +StringListInterface +::GetFilenameFilter() const +{ + return NULL_STRING; +} + +/*****************************************************************************/ +bool +StringListInterface +::IsFilename() const +{ + return true; +} + +/*****************************************************************************/ +void +StringListInterface +::Erase( std::size_t id ) +{ + Erase( id, 1 ); +} + +/*****************************************************************************/ +std::size_t +StringListInterface +::SetStrings( const StringVector & ) +{ + return 0; +} + +/*****************************************************************************/ +std::size_t +StringListInterface +::GetStrings( StringVector & ) const +{ + return 0; +} + +} // End of Namespace 'Wrapper' + +} // End of Namespace 'otb' diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c880f2fa3ec094f7d9e1317a6d8fc26727162a15 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperStringListParameter.h" + + +#include "otbCast.h" + + +namespace otb +{ + +namespace Wrapper +{ + + +/*****************************************************************************/ +StringListParameter +::StringListParameter() +{ + SetName( "String List" ); + SetKey( "strList" ); +} + + +/*****************************************************************************/ +StringListParameter +::~StringListParameter() +{ +} + + +/*****************************************************************************/ +void +StringListParameter +::SetValue( const StringListInterface::StringVector & strings ) +{ + SetStrings( strings ); +} + +/*****************************************************************************/ +StringListInterface::StringVector +StringListParameter +::GetValue() const +{ + // Should get benefit of C++11 move constructor. + return GetFileNameList(); +} + +/*****************************************************************************/ +void +StringListParameter +::AddString( const std::string & s ) +{ + AddFromFileName( s ); +} + +/*****************************************************************************/ +const std::string & +StringListParameter +::GetNthElement( std::size_t i ) const +{ + return GetNthFileName( i ); +} + +/*****************************************************************************/ +void +StringListParameter +::SetNthElement( std::size_t i, const std::string & string ) +{ + SetNthFileName( i, string ); +} + +/*****************************************************************************/ +Role +StringListParameter +::GetDirection() const +{ + return GetRole(); +} + +/*****************************************************************************/ +bool +StringListParameter +::IsFilename() const +{ + return false; +} + +/*****************************************************************************/ +const std::string & +StringListParameter +::ToString( const ParameterType::Pointer & p ) const +{ + assert( !p.IsNull() ); + + return p->GetValue(); +} + +/*****************************************************************************/ +const StringListParameter::ParameterType::Pointer & +StringListParameter +::FromString( const ParameterType::Pointer & p, + const std::string & s ) const +{ + assert( !p.IsNull() ); + + p->SetValue( s ); + + return p; +} + + +} + +} diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index 0a5bd88dca87fd13c7adcc9c79c64d45b389eae0..860c8673636aff84ee7d5ae5f26c9c5ab0bc733d 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -23,7 +23,6 @@ otb_module_test() set(OTBApplicationEngineTests otbApplicationEngineTestDriver.cxx otbWrapperApplicationTest.cxx -otbWrapperParameterTest.cxx otbWrapperInputImageParameterTest.cxx otbWrapperNumericalParameterTest.cxx otbWrapperStringParameterTest.cxx @@ -54,15 +53,6 @@ otb_add_test(NAME owTuApplication COMMAND otbApplicationEngineTestDriver otbWrapperApplicationNew ) -otb_add_test(NAME owTvParameter COMMAND otbApplicationEngineTestDriver - otbWrapperParameterTest1 - "param1" - ) - -otb_add_test(NAME owTuParameterNew COMMAND otbApplicationEngineTestDriver - otbWrapperParameterNew - ) - otb_add_test(NAME owTvInputImageParameter COMMAND otbApplicationEngineTestDriver otbWrapperInputImageParameterTest1 ${INPUTDATA}/poupees.tif diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx index f5db2967c0e9df41d8c910d8ff553962a07f7131..f5b3aabf3d5b4642044293927422883c491198f1 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx @@ -23,8 +23,6 @@ void RegisterTests() { REGISTER_TEST(otbWrapperApplicationNew); - REGISTER_TEST(otbWrapperParameterNew); - REGISTER_TEST(otbWrapperParameterTest1); REGISTER_TEST(otbWrapperInputImageParameterNew); REGISTER_TEST(otbWrapperInputImageParameterTest1); REGISTER_TEST(otbWrapperNumericalParameterNew); diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index 5d57a8337e73ee2298f313f08c13dc9f2ec5258f..cf70dc07b7bd8e50922a313f4bc6ff21ecaa973c 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -390,7 +390,6 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() const std::string paramKey(appKeyList[i]); std::vector<std::string> values; - Parameter::Pointer param = m_Application->GetParameterByKey(paramKey); ParameterType type = m_Application->GetParameterType(paramKey); const bool paramExists(m_Parser->IsAttributExists(std::string("-").append(paramKey), m_VExpression)); @@ -412,166 +411,99 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() return INVALIDNUMBEROFVALUE; } - // Ensure that the parameter is enabled - m_Application->EnableParameter(paramKey); - - if (type == ParameterType_InputVectorDataList) + if (type == ParameterType_InputVectorDataList || + type == ParameterType_InputImageList || + type == ParameterType_InputFilenameList || + type == ParameterType_StringList || + type == ParameterType_ListView) { - dynamic_cast<InputVectorDataListParameter *> (param.GetPointer())->SetListFromFileName(values); + // Multiple values parameters + m_Application->SetParameterStringList(paramKey, values); } - else - if (type == ParameterType_InputImageList) - { - dynamic_cast<InputImageListParameter *> (param.GetPointer())->SetListFromFileName(values); - } - else - if (type == ParameterType_InputFilenameList) - { - dynamic_cast<InputFilenameListParameter *> (param.GetPointer())->SetListFromFileName(values); - } - else - if (type == ParameterType_StringList) - { - dynamic_cast<StringListParameter *> (param.GetPointer())->SetValue(values); - } - else - if (type == ParameterType_String) - { - dynamic_cast<StringParameter *> (param.GetPointer())->SetValue( - m_Parser->GetAttributAsString(std::string("-").append(paramKey), m_VExpression) ); - } - else - if (type == ParameterType_OutputImage) - { - m_Application->SetParameterString(paramKey, values[0]); - // Check if pixel type is given - if (values.size() == 2) - { - ImagePixelType outPixType = ImagePixelType_float; - if (values[1] == "uint8") - outPixType = ImagePixelType_uint8; - else if (values[1] == "int16") - outPixType = ImagePixelType_int16; - else if (values[1] == "uint16") - outPixType = ImagePixelType_uint16; - else if (values[1] == "int32") - outPixType = ImagePixelType_int32; - else if (values[1] == "uint32") - outPixType = ImagePixelType_uint32; - else if (values[1] == "float") - outPixType = ImagePixelType_float; - else if (values[1] == "double") - outPixType = ImagePixelType_double; - else - { - std::cerr << "ERROR: Invalid output type for parameter -" << paramKey << ": " << values[1] << "." << std::endl; - return WRONGPARAMETERVALUE; - } - dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType); - } - else - if (values.size() > 2) - { - std::cerr << "ERROR: Too many values for parameter -" << paramKey << " (expected 2 or less, got " << values.size() << ")." << std::endl; - return INVALIDNUMBEROFVALUE; - } - } - else if (type == ParameterType_ComplexOutputImage) - { - m_Application->SetParameterString(paramKey, values[0]); - // Check if pixel type is given - if (values.size() == 2) - { - ComplexImagePixelType outPixType = ComplexImagePixelType_float; - if (values[1] == "cfloat") - outPixType = ComplexImagePixelType_float; - else if (values[1] == "cdouble") - outPixType = ComplexImagePixelType_double; - else - { - std::cerr << "ERROR: Invalid output type for parameter -" << paramKey << ": " << values[1] << "." << std::endl; - return WRONGPARAMETERVALUE; - } - dynamic_cast<ComplexOutputImageParameter *> (param.GetPointer())->SetComplexPixelType(outPixType); - } - else - if (values.size() != 1 && values.size() != 2) - { - std::cerr << "ERROR: Invalid number of value for: \"" << paramKey - << "\", invalid number of values " << values.size() << std::endl; - return INVALIDNUMBEROFVALUE; - } - } - else - if (type == ParameterType_ListView) - { - - ListViewParameter * tmpLV = dynamic_cast<ListViewParameter *>(param.GetPointer()); - - if(tmpLV->GetSingleSelection() && values.size() > 1) - { - std::cerr << "ERROR: Invalid number of value for: \"" << paramKey - << "\", invalid number of values " << values.size() << std::endl; - return INVALIDNUMBEROFVALUE; - } - - tmpLV->SetSelectedNames(values); - } - else - if(values.size() != 1) - { - // Handle space in filename. Only for input - // files or directories - if (type == ParameterType_Directory || type == ParameterType_InputFilename || - type == ParameterType_ComplexInputImage || - type == ParameterType_InputImage || - type == ParameterType_InputVectorData || type == ParameterType_OutputVectorData ) - { - for(unsigned int j=1; j<values.size(); j++) - { - values[0].append(" "); - values[0].append(values[j]); - } - } - else if (!param->GetAutomaticValue()) - { - std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", must have 1 value, not " - << values.size() << std::endl; - return INVALIDNUMBEROFVALUE; - } - } - // Single value parameter - if (type == ParameterType_Choice || type == ParameterType_Float || type == ParameterType_Int || - type == ParameterType_Radius || type == ParameterType_Directory || type == ParameterType_InputFilename || + else if (type == ParameterType_Choice || + type == ParameterType_Float || + type == ParameterType_Int || + type == ParameterType_Radius || + type == ParameterType_Directory || + type == ParameterType_String || + type == ParameterType_InputFilename || type == ParameterType_OutputFilename || - type == ParameterType_ComplexInputImage || type == ParameterType_InputImage || + type == ParameterType_ComplexInputImage || + type == ParameterType_InputImage || + type == ParameterType_OutputImage || type == ParameterType_ComplexOutputImage || type == ParameterType_InputVectorData || - type == ParameterType_OutputVectorData || type == ParameterType_RAM || + type == ParameterType_OutputVectorData || + type == ParameterType_RAM || type == ParameterType_OutputProcessXML) // || type == ParameterType_InputProcessXML) { + // Single value parameter m_Application->SetParameterString(paramKey, values[0]); - } - else - if (type == ParameterType_Empty) + + if (type == ParameterType_OutputImage) { - if (values[0] == "1" || values[0] == "true") + // Check if pixel type is given + if (values.size() == 2) { - dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(true); + ImagePixelType pixType = ImagePixelType_float; + if ( !OutputImageParameter::ConvertStringToPixelType(values[1],pixType) ) + { + std::cerr << "ERROR: Invalid output type for parameter -" << + paramKey << ": " << values[1] << "." << std::endl; + return WRONGPARAMETERVALUE; + } + m_Application->SetParameterOutputImagePixelType(paramKey, pixType); } - else - if (values[0] == "0" || values[0] == "false") + else if (values.size() > 2) + { + std::cerr << "ERROR: Too many values for parameter -" << + paramKey << " (expected 2 or 1, got " << values.size() << ")." + << std::endl; + return INVALIDNUMBEROFVALUE; + } + } + else if (type == ParameterType_ComplexOutputImage) + { + // Check if pixel type is given + if (values.size() == 2) + { + ComplexImagePixelType cpixType = ComplexImagePixelType_float; + if ( !ComplexOutputImageParameter::ConvertStringToPixelType(values[1],cpixType) ) { - dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(false); + std::cerr << "ERROR: Invalid output type for parameter -" << + paramKey << ": " << values[1] << "." << std::endl; + return WRONGPARAMETERVALUE; } - else + m_Application->SetParameterComplexOutputImagePixelType(paramKey, cpixType); + } + else if (values.size() > 2) { - std::cerr << "ERROR: Wrong value for parameter -" << paramKey << "." << std::endl; - return WRONGPARAMETERVALUE; + std::cerr << "ERROR: Too many values for parameter: -" << paramKey + << " (expected 2 or 1, got " << values.size() << ")." <<std::endl; + return INVALIDNUMBEROFVALUE; } } - // Update the flag UserValue - param->SetUserValue(true); + } + else if (type == ParameterType_Empty) + { + // Set UserValue flag specific for EmptyParameter, beware that it + // should be done before Enable/Disable because SetParameterUserValue() + // may enable it by default + m_Application->SetParameterUserValue(paramKey,true); + if (values[0] == "1" || values[0] == "true") + { + m_Application->EnableParameter(paramKey); + } + else if (values[0] == "0" || values[0] == "false") + { + m_Application->DisableParameter(paramKey); + } + else + { + std::cerr << "ERROR: Wrong value for parameter -" << paramKey << "." << std::endl; + return WRONGPARAMETERVALUE; + } + } // Call the DoUpdateParameter to update dependent params m_Application->UpdateParameters(); } @@ -668,12 +600,6 @@ void CommandLineLauncher::DisplayHelp(bool longHelp) for(unsigned int i=0; i<maxKeySize-std::string("progress").size(); i++) bigKey.append(" "); - std::cerr << " -"<<bigKey<<" <boolean> Report progress " << std::endl; - bigKey = "help"; - for(unsigned int i=0; i<maxKeySize-std::string("help").size(); i++) - bigKey.append(" "); - std::cerr << " -"<<bigKey<<" <string list> Display long help (empty list), or help for given parameters keys" << std::endl; - for (unsigned int i = 0; i < nbOfParam; i++) { Parameter::Pointer param = m_Application->GetParameterByKey(appKeyList[i]); @@ -683,6 +609,12 @@ void CommandLineLauncher::DisplayHelp(bool longHelp) } } + std::cerr << " -"<<bigKey<<" <boolean> Report progress " << std::endl; + bigKey = "help"; + for(unsigned int i=0; i<maxKeySize-std::string("help").size(); i++) + bigKey.append(" "); + std::cerr << " -"<<bigKey<<" <string list> Display long help (empty list), or help for given parameters keys" << std::endl; + std::cerr<<std::endl; //std::string cl(m_Application->GetCLExample()); @@ -721,11 +653,9 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & // Display the type the type ParameterType type = m_Application->GetParameterType(paramKey); - // Discard Group parameters (they don't need a value) - if (type == ParameterType_Group) - { - return ""; - } + std::string bigKey = paramKey; + + unsigned int maxKeySize = GetMaxKeySize(); bool singleSelectionForListView = false; @@ -745,10 +675,6 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & { oss << " "; } - - std::string bigKey = paramKey; - - unsigned int maxKeySize = GetMaxKeySize(); for(unsigned int i=0; i<maxKeySize-paramKey.size(); i++) bigKey.append(" "); @@ -784,6 +710,10 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & { oss << "<string list> "; } + else if(type == ParameterType_Group) + { + oss<< "<group> "; + } else itkExceptionMacro("Not handled parameter type."); @@ -835,30 +765,33 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & } } - if(m_Application->IsMandatory(paramKey)) + if(type != ParameterType_Group) { - oss<<" (mandatory"; - } - else - { - oss<<" (optional"; - if(m_Application->IsParameterEnabled(paramKey)) + if(m_Application->IsMandatory(paramKey)) { - oss<<", on by default"; + oss<<" (mandatory"; } else { - oss<<", off by default"; - } - } + oss<<" (optional"; - if(m_Application->HasValue(paramKey)) - { - oss<<", default value is "<<m_Application->GetParameterAsString(paramKey); + if(m_Application->IsParameterEnabled(paramKey)) + { + oss<<", on by default"; + } + else + { + oss<<", off by default"; + } + } + + if(m_Application->HasValue(paramKey)) + { + oss<<", default value is "<<m_Application->GetParameterAsString(paramKey); + } + oss<<")"; } - oss<<")"; - oss << std::endl; if(longHelp) @@ -869,8 +802,25 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & oss<<" "; oss<<m_Application->GetParameterDescription(paramKey)<<std::endl; + + if (type == ParameterType_Choice) + { + std::vector<std::string> keys = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceKeys(); + std::vector<std::string> names = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceNames(); + + auto keyIt = keys.begin(); + auto nameIt = names.begin(); + + for( ; keyIt!=keys.end()&&nameIt!=names.end();++keyIt,++nameIt) + { + oss << " "; + for(unsigned int i=0; i<maxKeySize;++i) + oss<<" "; + oss<<" "; + oss<<"- "<<*nameIt<<" ("<<*keyIt<<"): "<<m_Application->GetParameterDescription(paramKey+"."+(*keyIt))<<std::endl; + } + } } - return oss.str(); } diff --git a/Modules/Wrappers/QtWidget/CMakeLists.txt b/Modules/Wrappers/QtWidget/CMakeLists.txt index 4162b8dd0192cd7dc25b157eee7d7773f2fd6941..7776d931eb8c30643bcf4f9066e7f66facdbb988 100644 --- a/Modules/Wrappers/QtWidget/CMakeLists.txt +++ b/Modules/Wrappers/QtWidget/CMakeLists.txt @@ -21,4 +21,10 @@ project(OTBQtWidget) set(OTBQtWidget_LIBRARIES OTBQtWidget) + +# folder where ui headers are generated +set( OTBQtWidget_INCLUDE_DIRS + ${OTBQtWidget_BINARY_DIR}/src + ) + otb_module_impl() diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameListParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameListParameter.h index 0fd039933b71be32f1938331575b6d407605ebaf..9a64d46a516b26cde431b9c078fea5a9c01e5ca9 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameListParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameListParameter.h @@ -22,59 +22,43 @@ #define otbWrapperQtWidgetInputFilenameListParameter_h #include <QtGui> + #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility -#include "otbQtFileSelectionWidget.h" +# include "otbWrapperQtWidgetParameterList.h" #endif //tag=QT4-boost-compatibility namespace otb { + namespace Wrapper { +class InputFilenameListParameter; + /** \class QtWidgetInputFilenameListParameter * \brief * * \ingroup OTBQtWidget */ -class OTBQtWidget_EXPORT QtWidgetInputFilenameListParameter : public QtWidgetParameterBase +class OTBQtWidget_EXPORT QtWidgetInputFilenameListParameter : + public QtWidgetParameterList { Q_OBJECT -public: - QtWidgetInputFilenameListParameter(InputFilenameListParameter*, QtWidgetModel*); - ~QtWidgetInputFilenameListParameter() ITK_OVERRIDE; - - -signals: - void Change(); - void FileSelectionWidgetAdded( QWidget * ); -protected slots: - //void SetFileName( const QString& value ); - //virtual void SelectFile(); - virtual void UpFile(); - virtual void DownFile(); - virtual void AddFile(); - virtual void SuppressFile(); - virtual void EraseFile(); - virtual void UpdateFilenameList(); +// +// Public methods. +public: + QtWidgetInputFilenameListParameter( InputFilenameListParameter *, QtWidgetModel * ); + ~QtWidgetInputFilenameListParameter() override; +// +// Private methods. private: - QtWidgetInputFilenameListParameter(const QtWidgetInputFilenameListParameter&); //purposely not implemented - void operator=(const QtWidgetInputFilenameListParameter&); //purposely not implemented - - void DoCreateWidget() ITK_OVERRIDE; - - void DoUpdateGUI() ITK_OVERRIDE; - - void RecreateFilenameList(); - void UpdateFileList( std::map<unsigned int, unsigned int> idMap ); - - InputFilenameListParameter::Pointer m_InputFilenameListParam; + // purposely not implemented + QtWidgetInputFilenameListParameter( const QtWidgetInputFilenameListParameter & ); - QHBoxLayout * m_HLayout; - QVBoxLayout * m_FileLayout; - QScrollArea * m_Scroll; - std::vector<QtFileSelectionWidget *> m_FileSelectionList; + // purposely not implemented + void operator = ( const QtWidgetInputFilenameListParameter & ); }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageListParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageListParameter.h index e4e5b0c3c134e42a9e3abb3361ef2f1e254ceeda..a975dedc454e3a329c040f53168fa14cdb16fef9 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageListParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageListParameter.h @@ -21,60 +21,49 @@ #ifndef otbWrapperQtWidgetInputImageListParameter_h #define otbWrapperQtWidgetInputImageListParameter_h + #include <QtGui> -#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility -#include "otbQtFileSelectionWidget.h" -#endif //tag=QT4-boost-compatibility + + +#include "OTBQtWidgetExport.h" +#include "otbWrapperQtWidgetParameterList.h" + namespace otb { + + namespace Wrapper { + +class InputImageListParameter; + + /** \class QtWidgetInputImageListParameter * \brief * * \ingroup OTBQtWidget */ -class OTBQtWidget_EXPORT QtWidgetInputImageListParameter : public QtWidgetParameterBase +class OTBQtWidget_EXPORT QtWidgetInputImageListParameter : + public QtWidgetParameterList { - Q_OBJECT -public: - QtWidgetInputImageListParameter(InputImageListParameter*, QtWidgetModel*); - ~QtWidgetInputImageListParameter() ITK_OVERRIDE; - + Q_OBJECT; -signals: - void Change(); - void FileSelectionWidgetAdded( QWidget * ); - -protected slots: - //void SetFileName( const QString& value ); - //virtual void SelectFile(); - virtual void UpFile(); - virtual void DownFile(); - virtual void AddFile(); - virtual void SuppressFile(); - virtual void EraseFile(); - virtual void UpdateImageList(); +// +// Public methods. +public: + QtWidgetInputImageListParameter( InputImageListParameter *, QtWidgetModel * ); + ~QtWidgetInputImageListParameter() override; +// +// Private methods. private: - QtWidgetInputImageListParameter(const QtWidgetInputImageListParameter&); //purposely not implemented - void operator=(const QtWidgetInputImageListParameter&); //purposely not implemented - - void DoCreateWidget() ITK_OVERRIDE; - - void DoUpdateGUI() ITK_OVERRIDE; - - void RecreateImageList(); - void UpdateFileList( std::map<unsigned int, unsigned int> idMap ); - - InputImageListParameter::Pointer m_InputImageListParam; + // Purposely not implemented + QtWidgetInputImageListParameter( const QtWidgetInputImageListParameter & ); - QHBoxLayout * m_HLayout; - QVBoxLayout * m_FileLayout; - QScrollArea * m_Scroll; - std::vector<QtFileSelectionWidget *> m_FileSelectionList; + // Purposely not implemented + void operator = ( const QtWidgetInputImageListParameter & ); }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataListParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataListParameter.h index 4a43f7a00ebc1afa81d131a2eddc4c0dcd2a1770..7101cee908f87593f092471aa75d6b451be4e5f0 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataListParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataListParameter.h @@ -21,61 +21,52 @@ #ifndef otbWrapperQtWidgetInputVectorDataListParameter_h #define otbWrapperQtWidgetInputVectorDataListParameter_h + #include <QtGui> + + #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility -#include "otbWrapperInputVectorDataListParameter.h" -#include "otbQtFileSelectionWidget.h" +# include "otbWrapperQtWidgetParameterList.h" #endif //tag=QT4-boost-compatibility namespace otb { + + namespace Wrapper { + +class InputVectorDataListParameter; + + /** \class QtWidgetInputVectorDataListParameter * \brief * * \ingroup OTBQtWidget */ -class OTBQtWidget_EXPORT QtWidgetInputVectorDataListParameter : public QtWidgetParameterBase +class OTBQtWidget_EXPORT QtWidgetInputVectorDataListParameter + : public QtWidgetParameterList { - Q_OBJECT -public: - QtWidgetInputVectorDataListParameter(InputVectorDataListParameter*, QtWidgetModel*); - ~QtWidgetInputVectorDataListParameter() ITK_OVERRIDE; + Q_OBJECT; +// +// Public methods. +public: + QtWidgetInputVectorDataListParameter( InputVectorDataListParameter *, + QtWidgetModel * ); -signals: - void Change(); - void FileSelectionWidgetAdded( QWidget * ); + ~QtWidgetInputVectorDataListParameter() override; -protected slots: - //void SetFileName( const QString& value ); - //virtual void SelectFile(); - virtual void UpFile(); - virtual void DownFile(); - virtual void AddFile(); - virtual void SuppressFile(); - virtual void EraseFile(); - virtual void UpdateVectorDataList(); +// +// Private methods. private: - QtWidgetInputVectorDataListParameter(const QtWidgetInputVectorDataListParameter&); //purposely not implemented - void operator=(const QtWidgetInputVectorDataListParameter&); //purposely not implemented - - void DoCreateWidget() ITK_OVERRIDE; - - void DoUpdateGUI() ITK_OVERRIDE; - - void RecreateVectorDataList(); - void UpdateFileList( std::map<unsigned int, unsigned int> idMap ); - - InputVectorDataListParameter::Pointer m_InputVectorDataListParam; + // Purposely not implemented + QtWidgetInputVectorDataListParameter( const QtWidgetInputVectorDataListParameter & ); - QHBoxLayout * m_HLayout; - QVBoxLayout * m_FileLayout; - QScrollArea * m_Scroll; - std::vector<QtFileSelectionWidget *> m_FileSelectionList; + // Purposely not implemented + void operator = ( const QtWidgetInputVectorDataListParameter & ); }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h new file mode 100644 index 0000000000000000000000000000000000000000..34000ebc980150843eabbbebc0b58302b0de3027 --- /dev/null +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h @@ -0,0 +1,288 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbListEditItemModel_h +#define otbListEditItemModel_h + +// +// Configuration include. +//// Included at first position before any other ones. +#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility +#include "otbMacro.h" +#endif //tag=QT4-boost-compatibility + +#include "OTBQtWidgetExport.h" + +/*****************************************************************************/ +/* INCLUDE SECTION */ + +// +// Qt includes (sorted by alphabetic order) +//// Must be included before system/custom includes. +#include <QtCore> + +// +// System includes (sorted by alphabetic order) + +// +// ITK includes (sorted by alphabetic order) + +// +// OTB includes (sorted by alphabetic order) + +// +// Monteverdi includes (sorted by alphabetic order) + + +/*****************************************************************************/ +/* PRE-DECLARATION SECTION */ + +// +// External classes pre-declaration. +namespace +{ + +} + +namespace otb +{ + +namespace Wrapper +{ + +// +// Internal classes pre-declaration. +class StringListInterface; + + +/*****************************************************************************/ +/* CLASS DEFINITION SECTION */ + +/** + * \class ListEditItemModel + * + * \ingroup OTBQtWidget + * + * \brief WIP. + */ +class OTBQtWidget_EXPORT ListEditItemModel : + public QAbstractItemModel +{ + + /*-[ QOBJECT SECTION ]-----------------------------------------------------*/ + + Q_OBJECT; + + /*-[ PUBLIC SECTION ]------------------------------------------------------*/ + +// +// Public types. +public: + + enum Columns + { + COLUMN_NONE = -1, + // + COLUMN_NAME = 0, + // COLUMN_BROWSE = 1, + // + COLUMN_COUNT, + }; + + enum UserRole + { + USER_ROLE_NONE = Qt::UserRole, + USER_ROLE_DIRECTION, + USER_ROLE_FILTER, + }; + +// +// Public methods. +public: + + /** \brief Constructor. */ + ListEditItemModel( StringListInterface *, + QObject * p = nullptr ); + + /** \brief Destructor. */ + ~ListEditItemModel() ITK_OVERRIDE; + + // + // QAbstractItemModel overloads. + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#columnCount + */ + int columnCount( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#data + */ + QVariant + data( const QModelIndex & index, + int role = Qt::DisplayRole ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#flags + */ + Qt::ItemFlags flags( const QModelIndex & index ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#hasChildren + */ + bool hasChildren( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#headerData + */ + QVariant headerData( int section, + Qt::Orientation orientation, + int role = Qt::DisplayRole ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#index + */ + QModelIndex + index( int row, + int column, + const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + + /** + * \see http://doc.qt.io/qt-4.8/qabstractitemmodel.html#insertRow + */ + bool + insertRow( int row, const QModelIndex & parent = QModelIndex() ); + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#insertRows + */ + bool + insertRows( int row, + int count, + const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#parent + */ + QModelIndex parent( const QModelIndex & index ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#removeRows + */ + bool + removeRows( int row, + int count, + const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#rowCount + */ + int rowCount( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + + /** + * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#setData + */ + bool + setData( const QModelIndex & index, + const QVariant & value, + int role = Qt::EditRole ) ITK_OVERRIDE; + + /** */ + virtual bool Swap( int, int ); + + /** */ + virtual bool IsInput() const; + + /** */ + virtual QString GetFilter() const; + + /** */ + virtual bool IsBrowsable() const; + + /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ + +// +// Public SLOTS. +public slots: + + /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ + +// +// Signals. +signals: + + /*-[ PROTECTED SECTION ]---------------------------------------------------*/ + +// +// Protected methods. +protected: + +// +// Protected attributes. +protected: + + /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ + +// +// Private methods. +private: + + +// +// Private attributes. +private: + /** */ + StringListInterface * m_StringList; + + /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/ + +// +// Slots. +private slots: +}; + +} // end namespace 'Wrapper'. + +} // end namespace 'otb'. + +/*****************************************************************************/ +/* INLINE SECTION */ + +// +// Qt includes (sorted by alphabetic order) +//// Must be included before system/custom includes. + +// +// System includes (sorted by alphabetic order) + +// +// ITK includes (sorted by alphabetic order) + +// +// OTB includes (sorted by alphabetic order) + +// +// Monteverdi includes (sorted by alphabetic order) + +namespace otb +{ +} // end namespace 'otb' + +#endif // otbListEditItemModel_h diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditWidget.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..a804dbe7bc8e5df5964abe581f528ce5ee6e2401 --- /dev/null +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditWidget.h @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperQtWidgetListEditWidget_h +#define otbWrapperQtWidgetListEditWidget_h + +// +// Configuration include. +//// Included at first position before any other ones. +#include "otbConfigure.h" + + +/*****************************************************************************/ +/* INCLUDE SECTION */ + +// +// Qt includes (sorted by alphabetic order) +//// Must be included before system/custom includes. +#include <QtGui> + +// +// System includes (sorted by alphabetic order) + +// +// ITK includes (sorted by alphabetic order) + +// +// OTB includes (sorted by alphabetic order) +#include "OTBQtWidgetExport.h" + + +/*****************************************************************************/ +/* PRE-DECLARATION SECTION */ + +// +// External classes pre-declaration. +namespace +{ +} + +namespace otb +{ + +namespace Wrapper +{ + +// +// Internal classes pre-declaration. +class ListEditItemModel; +class StringListInterface; + +namespace Ui +{ +class ListEditWidget; +}; + + +/*****************************************************************************/ +/* CLASS DEFINITION SECTION */ + +/** + * \class ListEditWidget + * + * \ingroup OTBQtWidget + * + * \brief + */ +class OTBQtWidget_EXPORT ListEditWidget : + public QWidget +{ + + /*-[ QOBJECT SECTION ]-----------------------------------------------------*/ + + Q_OBJECT; + + /*-[ PUBLIC SECTION ]------------------------------------------------------*/ + +// +// Public methods. +public: + + /** \brief Constructor. */ + ListEditWidget( StringListInterface *, + QWidget * p =NULL, + Qt::WindowFlags flags =0 ); + + /** \brief Destructor. */ + virtual ~ListEditWidget(); + + /** + */ + const ListEditItemModel * GetItemModel() const; + + /** + */ + ListEditItemModel * GetItemModel(); + +#if 0 + + /** */ + void SetBrowseEnabled( bool ); + + /** */ + bool IsBrowseEnabled() const; +#endif + + /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ + +// +// Public SLOTS. +public slots: + void OnFilenameDropped(const QString &); + /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ + +// +// Signals. +signals: + /** */ + void Updated(); + + /*-[ PROTECTED SECTION ]---------------------------------------------------*/ + +// +// Protected methods. +protected: + + /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ + +// +// Protected attributes. +protected: + +// +// Private types. +private: + enum SwapSelection + { + LEFT = -1, + NONE = 0, + RIGHT = +1, + }; + +// +// Private methods. +private: + void Swap( int, int, SwapSelection = NONE ); + + QStringList browseFilenames( bool multi = false, const QString & filename = QString()); + + QString browseFilename( const QModelIndex & ); + +// +// Private attributes. +private: + /** + * \brief uic generated. + */ + Ui::ListEditWidget * m_UI; + + /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/ + +// +// Slots. +private slots: + void on_addButton_clicked(); + void on_browseButton_clicked(); + void on_downButton_clicked(); + void on_removeButton_clicked(); + void on_removeAllButton_clicked(); + void on_upButton_clicked(); + + void OnDataChanged( const QModelIndex &, const QModelIndex & ); + void OnModelReset(); + void OnRowsInserted( const QModelIndex &, int, int ); + void OnRowsRemoved( const QModelIndex &, int, int ); + void OnSelectionChanged( const QItemSelection &, const QItemSelection & ); +}; + +} // end namespace 'Wrapper' + +} // end namespace 'otb' + +/*****************************************************************************/ +/* INLINE SECTION */ + +namespace Wrapper +{ +} // end namespace 'Wrapper' + +#endif // otbWrappersQtWidgetListEditWidget_h diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h index 6edb46ea956dfd32b11bfb2426478fc5bb3319ff..db88ca9ace0243f4a10165b560e26dc2967b4869 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h @@ -42,7 +42,7 @@ class OTBQtWidget_EXPORT QtWidgetParameterBase : public QWidget { Q_OBJECT public: - QtWidgetParameterBase(Parameter *, QtWidgetModel*); + QtWidgetParameterBase( Parameter *, QtWidgetModel * ); ~QtWidgetParameterBase() ITK_OVERRIDE; void CreateWidget(); @@ -61,6 +61,9 @@ signals: protected: QtWidgetModel* GetModel(); + const Parameter * GetParam() const; + + Parameter * GetParam(); private: QtWidgetParameterBase(const QtWidgetParameterBase&); //purposely not implemented @@ -70,9 +73,10 @@ private: virtual void DoCreateWidget() = 0; - QtWidgetModel* m_Model; +private: + QtWidgetModel * m_Model; - Parameter* m_Param; + Parameter * m_Param; }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterList.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterList.h new file mode 100644 index 0000000000000000000000000000000000000000..61768297a1677ba29bd4ad8396890551a299d2e0 --- /dev/null +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterList.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperQtWidgetParameterList_h +#define otbWrapperQtWidgetParameterList_h + +#include <QtGui> +#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility +# include "otbWrapperQtWidgetParameterBase.h" +#endif //tag=QT4-boost-compatibility + + +namespace otb +{ + + +namespace Wrapper +{ + +class AbstractParameterList; + +/** \class QtWidgetParameterList + * \brief + * + * \ingroup OTBQtWidget + */ +class OTBQtWidget_EXPORT QtWidgetParameterList : public QtWidgetParameterBase +{ + Q_OBJECT + +// +// Public methods. +public: + QtWidgetParameterList( AbstractParameterList *, QtWidgetModel * ); + ~QtWidgetParameterList() override; + +// +// Signals. +signals: + void NotifyUpdate(); + +// +// Private methods. +private: + QtWidgetParameterList( const QtWidgetParameterList & ); // purposely not implemented + void operator = (const QtWidgetParameterList & ); // purposely not implemented + + void DoCreateWidget() override; + + void DoUpdateGUI() override; + +// +// Private attributes. +private: + +// +// Private slots. +private slots: +}; + +} // Wrapper + +} // otb + +#endif diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringListParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringListParameter.h index 8ae05e7551e57ec1e8ab239c1214c96468877d01..062e38ea6735f94c4dd2e841a33ae8135668df41 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringListParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringListParameter.h @@ -21,52 +21,47 @@ #ifndef otbWrapperQtWidgetStringListParameter_h #define otbWrapperQtWidgetStringListParameter_h -#include <QtGui> -#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility -#include "otbQtStringSelectionWidget.h" -#endif //tag=QT4-boost-compatibility + +#include "otbWrapperQtWidgetParameterList.h" + namespace otb { + + namespace Wrapper { + +class StringListParameter; + + /** \class QtWidgetStringListParameter * \brief * * \ingroup OTBQtWidget */ -class OTBQtWidget_EXPORT QtWidgetStringListParameter : public QtWidgetParameterBase +class OTBQtWidget_EXPORT QtWidgetStringListParameter : + public QtWidgetParameterList { - Q_OBJECT -public: - QtWidgetStringListParameter(StringListParameter*, QtWidgetModel*); - ~QtWidgetStringListParameter() ITK_OVERRIDE; - -signals: - void Change(); + Q_OBJECT; -protected slots: - void SetString( const QString& value ); - virtual void AddString(); - virtual void SuppressString(); - virtual void UpdateStringList(); - -private: - QtWidgetStringListParameter(const QtWidgetStringListParameter&); //purposely not implemented - void operator=(const QtWidgetStringListParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; - - void DoUpdateGUI() ITK_OVERRIDE; +// +// Public methods. +public: + QtWidgetStringListParameter( StringListParameter *, QtWidgetModel * ); + ~QtWidgetStringListParameter() override; - StringListParameter::Pointer m_StringListParam; - QHBoxLayout * m_HLayout; - QVBoxLayout * m_StringLayout; - QScrollArea * m_Scroll; +// +// Private methods. +private: + // Purposely not implemented. + QtWidgetStringListParameter( const QtWidgetStringListParameter & ); - std::vector<QtStringSelectionWidget *> m_LineEditList; + // Purposely not implemented + void operator = ( const QtWidgetStringListParameter & ); }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h index 761973da1dba385c8dc0bc64e863668818386da5..08857a242016ffb592d3005b209d6b2ffbb874fb 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h @@ -55,6 +55,7 @@ public: public slots: void CloseSlot(); void UnhandledException(QString message); + void OnExceptionRaised(QString message); private slots: void UpdateMessageAfterExecuteClicked(); diff --git a/Modules/Wrappers/QtWidget/src/CMakeLists.txt b/Modules/Wrappers/QtWidget/src/CMakeLists.txt index e567d8d7cadba6c047bc655a7de55d0e02bf8abb..28cb58c37691087555171daca7ab833814eed571 100644 --- a/Modules/Wrappers/QtWidget/src/CMakeLists.txt +++ b/Modules/Wrappers/QtWidget/src/CMakeLists.txt @@ -54,6 +54,9 @@ set(OTBQtWidget_SRC otbWrapperQtWidgetOutputVectorDataParameter.cxx otbWrapperQtWidgetInputFilenameParameter.cxx otbWrapperQtWidgetInputImageListParameter.cxx + otbWrapperQtWidgetListEditWidget.cxx + otbWrapperQtWidgetListEditItemModel.cxx + otbWrapperQtWidgetParameterList.cxx ) set(OTBQtWidget_MOC_HDR @@ -91,11 +94,23 @@ set(OTBQtWidget_MOC_HDR ../include/otbWrapperQtWidgetDirectoryParameter.h ../include/otbWrapperQtWidgetSimpleProgressReport.h ../include/otbWrapperQtWidgetRAMParameter.h + ../include/otbWrapperQtWidgetListEditWidget.h + ../include/otbWrapperQtWidgetListEditItemModel.h + ../include/otbWrapperQtWidgetParameterList.h ) -QT4_WRAP_CPP(OTBQtWidget_MOC_SRC ${OTBQtWidget_MOC_HDR}) +set( OTBQtWidget_FORMS + otbWrapperQtWidgetListEditWidget.ui + ) + +qt4_wrap_cpp( OTBQtWidget_MOC_SRC ${OTBQtWidget_MOC_HDR} ) +qt4_wrap_ui( OTBQtWidget_FORMS_HEADERS ${OTBQtWidget_FORMS} ) -add_library(OTBQtWidget ${OTBQtWidget_SRC} ${OTBQtWidget_MOC_SRC}) +add_library( OTBQtWidget + ${OTBQtWidget_SRC} + ${OTBQtWidget_FORMS_HEADERS} + ${OTBQtWidget_MOC_SRC} + ) target_link_libraries( OTBQtWidget ${OTBApplicationEngine_LIBRARIES} diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetChoiceParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetChoiceParameter.cxx index e3321703b0793b6fe15b72897832035802165ad1..078064cba3623f721315bb0629babb77de0c89d5 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetChoiceParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetChoiceParameter.cxx @@ -61,7 +61,9 @@ void QtWidgetChoiceParameter::DoUpdateGUI() void QtWidgetChoiceParameter::DoCreateWidget() { m_ComboBox = new QComboBox; - m_ComboBox->setToolTip(m_ChoiceParam->GetDescription()); + m_ComboBox->setToolTip( + QString::fromStdString( m_ChoiceParam->GetDescription() ) + ); m_StackWidget = new QStackedWidget; diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexInputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexInputImageParameter.cxx index 5334147cfa86ed0b117def49699468bebae9bb85..198b4a4929706fff9a83aeb9451bb644edcc5b96 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexInputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexInputImageParameter.cxx @@ -60,7 +60,9 @@ void QtWidgetComplexInputImageParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_ComplexInputImageParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_ComplexInputImageParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx index 7432d261b9bcf07251c42df8b316b2cbe972d637..0cd5800dfa462ba05af6123a247ca48c15d29d78 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx @@ -57,7 +57,9 @@ void QtWidgetComplexOutputImageParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_OutputImageParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_OutputImageParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); m_HLayout->addWidget(m_Input); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetDirectoryParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetDirectoryParameter.cxx index 0c5aee0d58d9e986a5255e4370d4f07c0927dd05..6eb0189d11729838618eea498be3495b15c597e8 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetDirectoryParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetDirectoryParameter.cxx @@ -56,7 +56,9 @@ void QtWidgetDirectoryParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_DirectoryParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_DirectoryParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetFloatParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetFloatParameter.cxx index 2c7a2a99f109bb71b05a7bfacacadddcf97ad367..6c30dd23e88aad1c10252aa25c307b429601e97d 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetFloatParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetFloatParameter.cxx @@ -72,7 +72,11 @@ void QtWidgetFloatParameter::DoCreateWidget() m_QDoubleSpinBox->setDecimals(5); m_QDoubleSpinBox->setSingleStep(0.1); m_QDoubleSpinBox->setRange(m_FloatParam->GetMinimumValue(), m_FloatParam->GetMaximumValue()); - m_QDoubleSpinBox->setToolTip(m_FloatParam->GetDescription()); + m_QDoubleSpinBox->setToolTip( + QString::fromStdString( + m_FloatParam->GetDescription() + ) + ); connect( m_QDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(SetValue(double)) ); connect( m_QDoubleSpinBox, SIGNAL(valueChanged(double)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx index da366b6308179702193e847846d918fc814ab1e8..8aeae849f6cf742c2ff857b4aa9e4bc5f060e04d 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx @@ -18,382 +18,31 @@ * limitations under the License. */ +#include "otbWrapperInputFilenameListParameter.h" #include "otbWrapperQtWidgetInputFilenameListParameter.h" -namespace otb -{ -namespace Wrapper -{ - -QtWidgetInputFilenameListParameter::QtWidgetInputFilenameListParameter(InputFilenameListParameter* param, QtWidgetModel* m) -: QtWidgetParameterBase(param, m), - m_InputFilenameListParam(param) -{ - connect(this, SIGNAL(Change()), GetModel(), SLOT(NotifyUpdate())); -} - -QtWidgetInputFilenameListParameter::~QtWidgetInputFilenameListParameter() -{ -} - -void QtWidgetInputFilenameListParameter::DoUpdateGUI() -{ - if(!m_InputFilenameListParam) - return; - - std::vector<std::string> fileList = m_InputFilenameListParam->GetFileNameList(); - for( unsigned int i = m_FileSelectionList.size(); i < fileList.size(); i++ ) - { - this->AddFile(); - } - int i = 0; - std::vector<std::string>::iterator it; - for (it = fileList.begin(); it != fileList.end(); ++it) - { - m_FileSelectionList[i++]->GetInput()->setText( - QFile::decodeName( - it->c_str() - ) - ); - } -} - -void QtWidgetInputFilenameListParameter::DoCreateWidget() -{ - m_FileSelectionList.clear(); - const unsigned int sp(2); - const unsigned int buttonSize(30); - - // Global layout - QHBoxLayout * hLayout = new QHBoxLayout; - hLayout->setSpacing(sp); - hLayout->setContentsMargins(sp, sp, sp, sp); - - // Button layout - QVBoxLayout * buttonLayout = new QVBoxLayout; - buttonLayout->setSpacing(sp); - buttonLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * addSupLayout = new QHBoxLayout; - addSupLayout->setSpacing(sp); - addSupLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * upDownLayout = new QHBoxLayout; - upDownLayout->setSpacing(sp); - upDownLayout->setContentsMargins(sp, sp, sp, sp); - - // Add file button - QPushButton * addButton = new QPushButton; - addButton->setText("+"); - addButton->setFixedWidth(buttonSize); - addButton->setToolTip("Add a file selector..."); - connect(addButton, SIGNAL(clicked()), this, SLOT(AddFile())); - addSupLayout->addWidget(addButton); - - // Suppress file button - QPushButton * supButton = new QPushButton; - supButton->setText("-"); - supButton->setFixedWidth(buttonSize); - supButton->setToolTip("Suppress the selected file..."); - connect(supButton, SIGNAL(clicked()), this, SLOT(SuppressFile())); - addSupLayout->addWidget(supButton); - buttonLayout->addLayout(addSupLayout); - - // Up file edit - QPushButton * upButton = new QPushButton; - upButton->setText("Up"); - upButton->setFixedWidth(buttonSize); - upButton->setToolTip("Up the selected file in the list..."); - connect(upButton, SIGNAL(clicked()), this, SLOT(UpFile())); - upDownLayout->addWidget(upButton); - - // Down file edit - QPushButton * downButton = new QPushButton; - downButton->setText("Down"); - downButton->setFixedWidth(buttonSize); - downButton->setToolTip("Down the selected file in the list..."); - connect(downButton, SIGNAL(clicked()), this, SLOT(DownFile())); - upDownLayout->addWidget(downButton); - buttonLayout->addLayout(upDownLayout); - - // Erase file edit - QPushButton * eraseButton = new QPushButton; - eraseButton->setText("Erase"); - eraseButton->setFixedWidth(2*(buttonSize+sp)); - eraseButton->setToolTip("Erase the selected file of the list..."); - connect(eraseButton, SIGNAL(clicked()), this, SLOT(EraseFile())); - buttonLayout->addWidget(eraseButton); - - QVBoxLayout * fileLayout = new QVBoxLayout(); - fileLayout->setSpacing(0); - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - fileLayout->addWidget(fileSelection); - m_InputFilenameListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateFilenameList())); - - m_FileSelectionList.push_back(fileSelection); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(fileLayout); - QScrollArea * s = new QScrollArea(); - s->setWidget(mainGroup); - s->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - s->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - s->setWidgetResizable(true); - - hLayout->addWidget(s); - hLayout->addLayout(buttonLayout); - - this->setLayout(hLayout); - - m_FileLayout = fileLayout; - m_HLayout = hLayout; - m_Scroll = s; -} - -void -QtWidgetInputFilenameListParameter::UpdateFilenameList() -{ - for(unsigned int j = 0; j < m_InputFilenameListParam->GetFileList()->Size(); j++) - { - if(m_InputFilenameListParam->SetNthFileName(j, m_FileSelectionList[j]->GetFilename()) == false) - { - std::ostringstream oss; - oss << "The given file " << m_FileSelectionList[j]->GetFilename() << " is not valid."; - this->GetModel()->SendLogWARNING(oss.str()); - m_FileSelectionList[j]->ClearFilename(); - } - } - - emit Change(); - - // notify of value change - QString key(m_InputFilenameListParam->GetKey()); - emit ParameterChanged(key); -} - - -void -QtWidgetInputFilenameListParameter::UpFile() -{ - if(m_FileSelectionList.size() < 2) - return; - - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(2); - - // Map link between old and new index in the list - std::map<unsigned int, unsigned int> idMap; - - // Init map - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - idMap[i] = i; - } - // If the first item is checked, uncheck it... - // It won't be moved - if(m_FileSelectionList[0]->IsChecked()) - { - m_FileSelectionList[0]->SetChecked(false); - } - - - // If other item are checked, up the index - // Starts at 1 because the first item mustn't move - for(unsigned int i = 1; i < m_FileSelectionList.size(); i++) - { - if(m_FileSelectionList[i]->IsChecked()) - { - unsigned int tmp = idMap[i]; - idMap[i] = i-1; - idMap[idMap[i-1]] = tmp; - } - } - - this->UpdateFileList(idMap); - - this->RecreateFilenameList(); -} - -void -QtWidgetInputFilenameListParameter::DownFile() -{ - if(m_FileSelectionList.size() < 2) return; - - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - - // Map link between old and new index in the list - std::map<unsigned int, unsigned int> idMap; - - // Init map - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - idMap[i] = i; - } - - // If the last item is checked, uncheck it... - // It won't be moved - if(m_FileSelectionList[m_FileSelectionList.size() - 1]->IsChecked()) - { - m_FileSelectionList[m_FileSelectionList.size() - 1]->SetChecked(false); - } - - // If other item are checked, up the index - // Stops at size-1 because the last item mustn't move - for(int i = m_FileSelectionList.size() - 2; i >= 0; i--) - { - if(m_FileSelectionList[i]->IsChecked()) - { - unsigned int tmp = idMap[i]; - idMap[i] = i + 1; - idMap[idMap[i + 1]] = tmp; - } - } - - this->UpdateFileList(idMap); - - this->RecreateFilenameList(); -} - - -void -QtWidgetInputFilenameListParameter::UpdateFileList(std::map<unsigned int, unsigned int> idMap) +namespace otb { - std::vector<QtFileSelectionWidget *> tmpList; - // Keys become values and inverse - std::map<unsigned int, unsigned int> idMapBis; - for(unsigned int i = 0; i < idMap.size(); i++) - { - idMapBis[idMap[i]] = i; - } - - // Create the new item list - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - m_FileLayout->addWidget(m_FileSelectionList[idMapBis[i]]); - tmpList.push_back(m_FileSelectionList[idMapBis[i]]); - } - - m_FileSelectionList = tmpList; - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - - // notify of value change - QString key(m_InputFilenameListParam->GetKey()); - emit ParameterChanged(key); -} - -void -QtWidgetInputFilenameListParameter::AddFile() +namespace Wrapper { - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - m_FileLayout->addWidget(m_FileSelectionList[i]); - } - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - m_FileLayout->addWidget(fileSelection); - m_FileSelectionList.push_back(fileSelection); - m_InputFilenameListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateFilenameList())); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - this->update(); - - emit FileSelectionWidgetAdded( fileSelection ); -} - -void -QtWidgetInputFilenameListParameter::SuppressFile() +/*****************************************************************************/ +QtWidgetInputFilenameListParameter +::QtWidgetInputFilenameListParameter( InputFilenameListParameter * param, + QtWidgetModel * m ) : + QtWidgetParameterList( param, m ) { - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - std::vector<QtFileSelectionWidget *> tmpList; - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - if(!m_FileSelectionList[i]->IsChecked()) - { - m_FileLayout->addWidget(m_FileSelectionList[i]); - tmpList.push_back(m_FileSelectionList[i]); - } - } - - m_FileSelectionList = tmpList; - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - this->RecreateFilenameList(); } -void -QtWidgetInputFilenameListParameter::EraseFile() +/*****************************************************************************/ +QtWidgetInputFilenameListParameter +::~QtWidgetInputFilenameListParameter() { - m_FileSelectionList.clear(); - - m_FileLayout = new QVBoxLayout(); - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - m_FileLayout->addWidget(fileSelection); - m_FileSelectionList.push_back(fileSelection); - m_InputFilenameListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateFilenameList())); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - this->RecreateFilenameList(); } - -void QtWidgetInputFilenameListParameter::RecreateFilenameList() -{ - // save value - m_InputFilenameListParam->ClearValue(); - - if(m_FileSelectionList.size() == 0) - { - this->AddFile(); - } - else - { - for(unsigned int j = 0; j < m_FileSelectionList.size(); j++) - { - m_InputFilenameListParam->AddFromFileName(m_FileSelectionList[j]->GetFilename()); - connect(m_FileSelectionList[j]->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateFilenameList())); - } - - emit Change(); - // notify of value change - QString key(m_InputFilenameListParam->GetKey()); - emit ParameterChanged(key); - } } - -} } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameParameter.cxx index 6db8cb82bbc1182e84dc99c6642a5e5ed3c91366..93011f37eb41736daf76cd063b5bdac4ff44fca5 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameParameter.cxx @@ -61,7 +61,9 @@ void QtWidgetInputFilenameParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_FilenameParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_FilenameParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx index 8224946af0c073f5707a8ee268c2e4dfde1ebefa..218e6389d59ea9b0559dd9bc7950e73e839887a1 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx @@ -20,393 +20,28 @@ #include "otbWrapperQtWidgetInputImageListParameter.h" -namespace otb -{ -namespace Wrapper -{ - -QtWidgetInputImageListParameter::QtWidgetInputImageListParameter(InputImageListParameter* param, QtWidgetModel* m) -: QtWidgetParameterBase(param, m), - m_InputImageListParam(param) -{ - connect(this, SIGNAL(Change()), GetModel(), SLOT(NotifyUpdate())); -} - -QtWidgetInputImageListParameter::~QtWidgetInputImageListParameter() -{ -} - -void QtWidgetInputImageListParameter::DoUpdateGUI() -{ - if(!m_InputImageListParam) - return; - - //update fileSelectionList only if HasUserValue flag is set(from xml) - if(m_InputImageListParam->HasUserValue()) - { - std::vector<std::string> fileList = m_InputImageListParam->GetFileNameList(); - - for( unsigned int i = m_FileSelectionList.size(); i < fileList.size(); i++ ) - { - this->AddFile(); - } - unsigned int i = 0; - std::vector<std::string>::iterator it; - for (it = fileList.begin(); it != fileList.end(); ++it) - { - m_FileSelectionList[i++]->GetInput()->setText( - QFile::decodeName( it->c_str() ) - ); - } - } -} -void QtWidgetInputImageListParameter::DoCreateWidget() -{ - m_FileSelectionList.clear(); - const unsigned int sp(2); - const unsigned int buttonSize(30); - - // Global layout - QHBoxLayout * hLayout = new QHBoxLayout; - hLayout->setSpacing(sp); - hLayout->setContentsMargins(sp, sp, sp, sp); - - // Button layout - QVBoxLayout * buttonLayout = new QVBoxLayout; - buttonLayout->setSpacing(sp); - buttonLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * addSupLayout = new QHBoxLayout; - addSupLayout->setSpacing(sp); - addSupLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * upDownLayout = new QHBoxLayout; - upDownLayout->setSpacing(sp); - upDownLayout->setContentsMargins(sp, sp, sp, sp); - - // Add file button - QPushButton * addButton = new QPushButton; - addButton->setText("+"); - addButton->setFixedWidth(buttonSize); - addButton->setToolTip("Add a file selector..."); - connect(addButton, SIGNAL(clicked()), this, SLOT(AddFile())); - addSupLayout->addWidget(addButton); - - // Suppress file button - QPushButton * supButton = new QPushButton; - supButton->setText("-"); - supButton->setFixedWidth(buttonSize); - supButton->setToolTip("Suppress the selected file..."); - connect(supButton, SIGNAL(clicked()), this, SLOT(SuppressFile())); - addSupLayout->addWidget(supButton); - buttonLayout->addLayout(addSupLayout); - - // Up file edit - QPushButton * upButton = new QPushButton; - upButton->setText("Up"); - upButton->setFixedWidth(buttonSize); - upButton->setToolTip("Up the selected file in the list..."); - connect(upButton, SIGNAL(clicked()), this, SLOT(UpFile())); - upDownLayout->addWidget(upButton); - - // Down file edit - QPushButton * downButton = new QPushButton; - downButton->setText("Down"); - downButton->setFixedWidth(buttonSize); - downButton->setToolTip("Down the selected file in the list..."); - connect(downButton, SIGNAL(clicked()), this, SLOT(DownFile())); - upDownLayout->addWidget(downButton); - buttonLayout->addLayout(upDownLayout); - - // Erase file edit - QPushButton * eraseButton = new QPushButton; - eraseButton->setText("Erase"); - eraseButton->setFixedWidth(2*(buttonSize+sp)); - eraseButton->setToolTip("Erase the selected file of the list..."); - connect(eraseButton, SIGNAL(clicked()), this, SLOT(EraseFile())); - buttonLayout->addWidget(eraseButton); - - QVBoxLayout * fileLayout = new QVBoxLayout(); - fileLayout->setSpacing(0); - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - fileLayout->addWidget(fileSelection); - m_InputImageListParam->AddNullElement(); - connect(fileSelection, SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList())); - - m_FileSelectionList.push_back(fileSelection); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(fileLayout); - QScrollArea * s = new QScrollArea(); - s->setWidget(mainGroup); - s->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - s->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - s->setWidgetResizable(true); - - hLayout->addWidget(s); - hLayout->addLayout(buttonLayout); - - this->setLayout(hLayout); - - m_FileLayout = fileLayout; - m_HLayout = hLayout; - m_Scroll = s; - -} - -void -QtWidgetInputImageListParameter::UpdateImageList() -{ - // Adding a NullElement so to make the m_FileSelectionList and - // m_InputImageList's ImageList are of same size. - for(unsigned int i = m_InputImageListParam->Size(); i < m_FileSelectionList.size(); i++) - { - m_InputImageListParam->AddNullElement(); - } - - for(unsigned int j = 0; j < m_InputImageListParam->Size(); j++) - { - if(m_InputImageListParam->SetNthFileName(j, m_FileSelectionList[j]->GetFilename()) == false) - { - std::ostringstream oss; - oss << "The given file " << m_FileSelectionList[j]->GetFilename() << " is not valid."; - this->GetModel()->SendLogWARNING(oss.str()); - } - } - - emit Change(); - - // notify of value change - QString key(m_InputImageListParam->GetKey()); - emit ParameterChanged(key); -} - -void -QtWidgetInputImageListParameter::UpFile() -{ - if(m_FileSelectionList.size() < 2) - return; - - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(2); - - // Map link between old and new index in the list - std::map<unsigned int, unsigned int> idMap; - // Init map - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - idMap[i] = i; - } - - // If the first item is checked, uncheck it... - // It won't be moved - if(m_FileSelectionList[0]->IsChecked()) - { - m_FileSelectionList[0]->SetChecked(false); - } - - - // If other item are checked, up the index - // Starts at 1 because the first item mustn't move - for(unsigned int i = 1; i < m_FileSelectionList.size(); i++) - { - if(m_FileSelectionList[i]->IsChecked()) - { - unsigned int tmp = idMap[i]; - idMap[i] = i-1; - idMap[idMap[i-1]] = tmp; - } - } - - this->UpdateFileList(idMap); - - this->RecreateImageList(); -} - -void -QtWidgetInputImageListParameter::DownFile() -{ - if(m_FileSelectionList.size() < 2) return; - - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - - // Map link between old and new index in the list - std::map<unsigned int, unsigned int> idMap; - - // Init map - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - idMap[i] = i; - } - - // If the last item is checked, uncheck it... - // It won't be moved - if(m_FileSelectionList[m_FileSelectionList.size() - 1]->IsChecked()) - { - m_FileSelectionList[m_FileSelectionList.size() - 1]->SetChecked(false); - } - - // If other item are checked, up the index - // Stops at size-1 because the last item mustn't move - for(int i = m_FileSelectionList.size() - 2; i >= 0; i--) - { - if(m_FileSelectionList[i]->IsChecked()) - { - unsigned int tmp = idMap[i]; - idMap[i] = i + 1; - idMap[idMap[i + 1]] = tmp; - } - } - - this->UpdateFileList(idMap); - - this->RecreateImageList(); -} - - -void -QtWidgetInputImageListParameter::UpdateFileList(std::map<unsigned int, unsigned int> idMap) +namespace otb { - std::vector<QtFileSelectionWidget *> tmpList; - // Keys become values and inverse - std::map<unsigned int, unsigned int> idMapBis; - for(unsigned int i = 0; i < idMap.size(); i++) - { - idMapBis[idMap[i]] = i; - } - - // Create the new item list - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - m_FileLayout->addWidget(m_FileSelectionList[idMapBis[i]]); - tmpList.push_back(m_FileSelectionList[idMapBis[i]]); - } - - m_FileSelectionList = tmpList; - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - // notify of value change - QString key(m_InputImageListParam->GetKey()); - emit ParameterChanged(key); -} - - -void -QtWidgetInputImageListParameter::AddFile() +namespace Wrapper { - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - m_FileLayout->addWidget(m_FileSelectionList[i]); - } - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - m_FileLayout->addWidget(fileSelection); - m_FileSelectionList.push_back(fileSelection); - /* No need of AddNullElement() here. Moved adding NullElement when updating the list */ - //m_InputImageListParam->AddNullElement(); - connect( - fileSelection, - SIGNAL( FilenameChanged() ), - this, - SLOT( UpdateImageList() ) - ); - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - - emit FileSelectionWidgetAdded( fileSelection ); -} - -void -QtWidgetInputImageListParameter::SuppressFile() +/*****************************************************************************/ +QtWidgetInputImageListParameter +::QtWidgetInputImageListParameter( InputImageListParameter * param, + QtWidgetModel * m ) : + QtWidgetParameterList( param, m ) { - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - std::vector<QtFileSelectionWidget *> tmpList; - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - if(!m_FileSelectionList[i]->IsChecked()) - { - m_FileLayout->addWidget(m_FileSelectionList[i]); - tmpList.push_back(m_FileSelectionList[i]); - } - } - - m_FileSelectionList = tmpList; - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - this->RecreateImageList(); } -void -QtWidgetInputImageListParameter::EraseFile() +/*****************************************************************************/ +QtWidgetInputImageListParameter +::~QtWidgetInputImageListParameter() { - m_FileSelectionList.clear(); - - m_FileLayout = new QVBoxLayout(); - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - m_FileLayout->addWidget(fileSelection); - m_FileSelectionList.push_back(fileSelection); - m_InputImageListParam->AddNullElement(); - connect(fileSelection, SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList())); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - this->RecreateImageList(); } -void QtWidgetInputImageListParameter::RecreateImageList() -{ - // save value - m_InputImageListParam->ClearValue(); - - if(m_FileSelectionList.size() == 0) - { - this->AddFile(); - } - else - { - for(unsigned int j = 0; j < m_FileSelectionList.size(); j++) - { - m_InputImageListParam->AddFromFileName(m_FileSelectionList[j]->GetFilename()); - connect(m_FileSelectionList[j], SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList())); - } - - emit Change(); - // notify of value change - QString key(m_InputImageListParam->GetKey()); - emit ParameterChanged(key); - } } - -} } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx index e41c35dc01c1ede50efab19452972e0970abd9ce..8f9873bbbd81fcc3023d54899d0ec5e92cf32229 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx @@ -68,7 +68,11 @@ void QtWidgetInputImageParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_InputImageParam->GetDescription() ); + + m_Input->setToolTip( + QString::fromStdString( m_InputImageParam->GetDescription() ) + ); + connect( m_Input, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()) ); connect( this, SIGNAL(FileNameIsSet()), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx index bd72303cccda39728fe3843acfc64a7c68a1e431..9229d584f77997a4764941f5a4cccbcc54d6810a 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx @@ -60,7 +60,9 @@ void QtWidgetInputProcessXMLParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_XMLParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_XMLParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx index fd8cdad935c4ceaea5cac3572e01ae82210deddb..e4184c55351b546ef977bc453176679d5bc0fc97 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx @@ -20,380 +20,32 @@ #include "otbWrapperQtWidgetInputVectorDataListParameter.h" -namespace otb -{ -namespace Wrapper -{ - -QtWidgetInputVectorDataListParameter::QtWidgetInputVectorDataListParameter(InputVectorDataListParameter* param, - QtWidgetModel* m) -: QtWidgetParameterBase(param, m), - m_InputVectorDataListParam(param) -{ - connect(this, SIGNAL(Change()), GetModel(), SLOT(NotifyUpdate())); -} - -QtWidgetInputVectorDataListParameter::~QtWidgetInputVectorDataListParameter() -{ -} - -void QtWidgetInputVectorDataListParameter::DoUpdateGUI() -{ - if(!m_InputVectorDataListParam) - return; - - std::vector<std::string> fileList = m_InputVectorDataListParam->GetFileNameList(); - for( unsigned int i = m_FileSelectionList.size(); i < fileList.size(); i++ ) - { - this->AddFile(); - } - int i = 0; - std::vector<std::string>::iterator it; - for (it = fileList.begin(); it != fileList.end(); ++it) - { - m_FileSelectionList[i++]->GetInput()->setText( - QFile::decodeName( it->c_str() ) - ); - } -} - -void QtWidgetInputVectorDataListParameter::DoCreateWidget() -{ - m_FileSelectionList.clear(); - const unsigned int sp(2); - const unsigned int buttonSize(30); - - // Global layout - QHBoxLayout * hLayout = new QHBoxLayout; - hLayout->setSpacing(sp); - hLayout->setContentsMargins(sp, sp, sp, sp); - - // Button layout - QVBoxLayout * buttonLayout = new QVBoxLayout; - buttonLayout->setSpacing(sp); - buttonLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * addSupLayout = new QHBoxLayout; - addSupLayout->setSpacing(sp); - addSupLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * upDownLayout = new QHBoxLayout; - upDownLayout->setSpacing(sp); - upDownLayout->setContentsMargins(sp, sp, sp, sp); - - // Add file button - QPushButton * addButton = new QPushButton; - addButton->setText("+"); - addButton->setFixedWidth(buttonSize); - addButton->setToolTip("Add a file selector..."); - connect(addButton, SIGNAL(clicked()), this, SLOT(AddFile())); - addSupLayout->addWidget(addButton); - - // Suppress file button - QPushButton * supButton = new QPushButton; - supButton->setText("-"); - supButton->setFixedWidth(buttonSize); - supButton->setToolTip("Suppress the selected file..."); - connect(supButton, SIGNAL(clicked()), this, SLOT(SuppressFile())); - addSupLayout->addWidget(supButton); - buttonLayout->addLayout(addSupLayout); - - // Up file edit - QPushButton * upButton = new QPushButton; - upButton->setText("Up"); - upButton->setFixedWidth(buttonSize); - upButton->setToolTip("Up the selected file in the list..."); - connect(upButton, SIGNAL(clicked()), this, SLOT(UpFile())); - upDownLayout->addWidget(upButton); - - // Down file edit - QPushButton * downButton = new QPushButton; - downButton->setText("Down"); - downButton->setFixedWidth(buttonSize); - downButton->setToolTip("Down the selected file in the list..."); - connect(downButton, SIGNAL(clicked()), this, SLOT(DownFile())); - upDownLayout->addWidget(downButton); - buttonLayout->addLayout(upDownLayout); - - // Erase file edit - QPushButton * eraseButton = new QPushButton; - eraseButton->setText("Erase"); - eraseButton->setFixedWidth(2*(buttonSize+sp)); - eraseButton->setToolTip("Erase the selected file of the list..."); - connect(eraseButton, SIGNAL(clicked()), this, SLOT(EraseFile())); - buttonLayout->addWidget(eraseButton); - - QVBoxLayout * fileLayout = new QVBoxLayout(); - fileLayout->setSpacing(0); - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - fileLayout->addWidget(fileSelection); - m_InputVectorDataListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateVectorDataList())); - - m_FileSelectionList.push_back(fileSelection); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(fileLayout); - QScrollArea * scroll2 = new QScrollArea(); - scroll2->setWidget(mainGroup); - scroll2->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scroll2->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - scroll2->setWidgetResizable(true); - - hLayout->addWidget(scroll2); - hLayout->addLayout(buttonLayout); - - this->setLayout(hLayout); - - m_FileLayout = fileLayout; - m_HLayout = hLayout; - m_Scroll = scroll2; - -} - -void -QtWidgetInputVectorDataListParameter::UpdateVectorDataList() -{ - for(unsigned int j = 0; j < m_InputVectorDataListParam->GetVectorDataList()->Size(); j++) - { - if(m_InputVectorDataListParam->SetNthFileName(j, m_FileSelectionList[j]->GetFilename()) == false) - { - std::ostringstream oss; - oss << "The given file " << m_FileSelectionList[j]->GetFilename() << " is not valid."; - this->GetModel()->SendLogWARNING(oss.str()); - } - } - - emit Change(); - - // notify of value change - QString key(m_InputVectorDataListParam->GetKey()); - emit ParameterChanged(key); -} - - -void -QtWidgetInputVectorDataListParameter::UpFile() -{ - if(m_FileSelectionList.size() < 2) - return; - - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(2); - // Map link between old and new index in the list - std::map<unsigned int, unsigned int> idMap; +#include "otbWrapperInputVectorDataListParameter.h" - // Init map - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - idMap[i] = i; - } - - // If the first item is checked, uncheck it... - // It won't be moved - if(m_FileSelectionList[0]->IsChecked()) - { - m_FileSelectionList[0]->SetChecked(false); - } - - - // If other item are checked, up the index - // Starts at 1 because the first item mustn't move - for(unsigned int i = 1; i < m_FileSelectionList.size(); i++) - { - if(m_FileSelectionList[i]->IsChecked()) - { - unsigned int tmp = idMap[i]; - idMap[i] = i-1; - idMap[idMap[i-1]] = tmp; - } - } - - this->UpdateFileList(idMap); - - this->RecreateVectorDataList(); -} - -void -QtWidgetInputVectorDataListParameter::DownFile() -{ - if(m_FileSelectionList.size() < 2) return; - - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - - // Map link between old and new index in the list - std::map<unsigned int, unsigned int> idMap; - - // Init map - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - idMap[i] = i; - } - - // If the last item is checked, uncheck it... - // It won't be moved - if(m_FileSelectionList[m_FileSelectionList.size() - 1]->IsChecked()) - { - m_FileSelectionList[m_FileSelectionList.size() - 1]->SetChecked(false); - } - - // If other item are checked, up the index - // Stops at size-1 because the last item mustn't move - for(int i = m_FileSelectionList.size() - 2; i >= 0; i--) - { - if(m_FileSelectionList[i]->IsChecked()) - { - unsigned int tmp = idMap[i]; - idMap[i] = i + 1; - idMap[idMap[i + 1]] = tmp; - } - } - - this->UpdateFileList(idMap); - - this->RecreateVectorDataList(); -} - - -void -QtWidgetInputVectorDataListParameter::UpdateFileList(std::map<unsigned int, unsigned int> idMap) +namespace otb { - std::vector<QtFileSelectionWidget *> tmpList; - // Keys become values and inverse - std::map<unsigned int, unsigned int> idMapBis; - for(unsigned int i = 0; i < idMap.size(); i++) - { - idMapBis[idMap[i]] = i; - } - - // Create the new item list - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - m_FileLayout->addWidget(m_FileSelectionList[idMapBis[i]]); - tmpList.push_back(m_FileSelectionList[idMapBis[i]]); - } - m_FileSelectionList = tmpList; - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - this->update(); - - // notify of value change - QString key(m_InputVectorDataListParam->GetKey()); - emit ParameterChanged(key); -} - - -void -QtWidgetInputVectorDataListParameter::AddFile() +namespace Wrapper { - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - m_FileLayout->addWidget(m_FileSelectionList[i]); - } - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - m_FileLayout->addWidget(fileSelection); - m_FileSelectionList.push_back(fileSelection); - m_InputVectorDataListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateVectorDataList())); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - this->update(); - emit FileSelectionWidgetAdded( fileSelection ); -} - -void -QtWidgetInputVectorDataListParameter::SuppressFile() +/*****************************************************************************/ +QtWidgetInputVectorDataListParameter +::QtWidgetInputVectorDataListParameter( InputVectorDataListParameter * param, + QtWidgetModel* m ) : + QtWidgetParameterList( param, m ) { - m_FileLayout = new QVBoxLayout(); - m_FileLayout->setSpacing(0); - std::vector<QtFileSelectionWidget *> tmpList; - for(unsigned int i = 0; i < m_FileSelectionList.size(); i++) - { - if(!m_FileSelectionList[i]->IsChecked()) - { - m_FileLayout->addWidget(m_FileSelectionList[i]); - tmpList.push_back(m_FileSelectionList[i]); - } - } - - m_FileSelectionList = tmpList; - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - this->RecreateVectorDataList(); } - -void -QtWidgetInputVectorDataListParameter::EraseFile() +/*****************************************************************************/ +QtWidgetInputVectorDataListParameter +::~QtWidgetInputVectorDataListParameter() { - m_FileSelectionList.clear(); - - m_FileLayout = new QVBoxLayout(); - - QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget(); - fileSelection->SetIOMode( QtFileSelectionWidget::IO_MODE_INPUT ); - fileSelection->setFixedHeight(30); - m_FileLayout->addWidget(fileSelection); - m_FileSelectionList.push_back(fileSelection); - m_InputVectorDataListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateVectorDataList())); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(m_FileLayout); - m_Scroll->setWidget(mainGroup); - - this->update(); - this->RecreateVectorDataList(); } -void QtWidgetInputVectorDataListParameter::RecreateVectorDataList() -{ - // save value - m_InputVectorDataListParam->ClearValue(); - - if(m_FileSelectionList.size() == 0) - { - this->AddFile(); - } - else - { - for(unsigned int j = 0; j < m_FileSelectionList.size(); j++) - { - m_InputVectorDataListParam->AddFromFileName(m_FileSelectionList[j]->GetFilename()); - connect(m_FileSelectionList[j]->GetInput(), SIGNAL(textChanged(const QString&)), - this, SLOT(UpdateVectorDataList())); - } - - emit Change(); - // notify of value change - QString key(m_InputVectorDataListParam->GetKey()); - emit ParameterChanged(key); - } } - -} } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataParameter.cxx index 3fd1a551120fc3c38d4a1f23b019bccac9b762cd..26c6e54af87acfacc9f65b531cd6b10b703de3f9 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataParameter.cxx @@ -61,7 +61,9 @@ void QtWidgetInputVectorDataParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_InputVectorDataParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_InputVectorDataParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetIntParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetIntParameter.cxx index 2d4e7b1e02a0eee668934f83ab65e8c2ff50ed68..052c919a63ea9e33b37eaf2ce9627ccdf68ed80e 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetIntParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetIntParameter.cxx @@ -44,7 +44,9 @@ void QtWidgetIntParameter::DoCreateWidget() m_QSpinBox = new QSpinBox; m_QSpinBox->setRange(m_IntParam->GetMinimumValue(), m_IntParam->GetMaximumValue()); - m_QSpinBox->setToolTip(m_IntParam->GetDescription()); + m_QSpinBox->setToolTip( + QString::fromStdString( m_IntParam->GetDescription() ) + ); connect( m_QSpinBox, SIGNAL(valueChanged(int)), this, SLOT(SetValue(int)) ); connect( m_QSpinBox, SIGNAL(valueChanged(int)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditItemModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditItemModel.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b0ec1d5a917f34631be67042048eae6edd1b4cee --- /dev/null +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditItemModel.cxx @@ -0,0 +1,483 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperQtWidgetListEditItemModel.h" + + +/*****************************************************************************/ +/* INCLUDE SECTION */ + +// +// Qt includes (sorted by alphabetic order) +//// Must be included before system/custom includes. + +// +// System includes (sorted by alphabetic order) + +// +// ITK includes (sorted by alphabetic order) + +// +// OTB includes (sorted by alphabetic order) + +#include "otbWrapperStringListInterface.h" + + +namespace otb +{ + +namespace Wrapper +{ + +/* + TRANSLATOR otb::Wapper::ListEditItemModel + + Necessary for lupdate to be aware of C++ namespaces. + + Context comment for translator. +*/ + + +/*****************************************************************************/ +/* CONSTANTS */ + +namespace +{ + +const char * const +HEADERS[ ListEditItemModel::COLUMN_COUNT ] = +{ + QT_TRANSLATE_NOOP( "otb::Wrapper::ListEditItemModel", "Name" ), + // QT_TRANSLATE_NOOP( "otb::Wrapper::ListEditItemModel", "Browse" ), +}; + +} // end of anonymous namespace. + + +/*****************************************************************************/ +/* STATIC IMPLEMENTATION SECTION */ + + +/*****************************************************************************/ +/* CLASS IMPLEMENTATION SECTION */ + +/*******************************************************************************/ +ListEditItemModel +::ListEditItemModel( StringListInterface * sli, + QObject * p ) : + QAbstractItemModel( p ), + m_StringList( sli ) +{ + assert( sli!=nullptr ); +} + +/*******************************************************************************/ +ListEditItemModel +::~ListEditItemModel() +{ +} + +/*****************************************************************************/ +/* QAbstractItemModel overloads */ +/*****************************************************************************/ +int +ListEditItemModel +::columnCount( const QModelIndex & ) const +{ + // qDebug() << this << "::columnCount(" << parent << ")"; + + return COLUMN_COUNT; +} + +/*****************************************************************************/ +QVariant +ListEditItemModel +::data( const QModelIndex & idx, int role ) const +{ + // qDebug() << this << "::data(" << idx << "," << role << ")"; + + // Get layer. + assert( m_StringList!=NULL ); + + assert( idx.isValid() ); + assert( !idx.parent().isValid() ); + assert( idx.internalPointer()!=NULL ); + + const StringListInterface * stringList = + static_cast< const StringListInterface * >( idx.internalPointer() ); + + assert( stringList!=nullptr ); + + // Return data given role. + switch( role ) + { + case Qt::CheckStateRole: +#if 0 + if( idx.column()!=COLUMN_NAME ) + return QVariant(); + else + { + assert( idx.row() >= 0 ); + return stringList->IsActive( idx.row() ); + } +#endif + break; + + case Qt::EditRole: + case Qt::DisplayRole: + switch( idx.column() ) + { + case COLUMN_NAME: + { + assert( idx.row() >= 0 ); + + std::string filename( + stringList->GetNthFileName( idx.row() ) + ); + + // qDebug() << "Filename:" << QString( "%1" ).arg( filename.c_str() ); + + return + filename.empty() + ? ( role==Qt::EditRole ? QString() : "EMPTY" ) + : QFile::decodeName( filename.c_str() + ); + } + break; + + default: + break; + } + break; + + case Qt::FontRole: + break; + + case Qt::ToolTipRole: + switch( idx.column() ) + { + case COLUMN_NAME: + assert( idx.row() >= 0 ); + return QString::fromStdString( stringList->GetToolTip( idx.row() ) ); + break; + } + break; + + case USER_ROLE_DIRECTION: + assert( idx.row()>=0 ); + return stringList->GetDirection( idx.row() ); + break; + + case USER_ROLE_FILTER: + assert( idx.row()>=0 ); + return QString::fromStdString( stringList->GetFilenameFilter( idx.row() ) ); + break; + + default: + break; + } + + return QVariant(); +} + +/*****************************************************************************/ +Qt::ItemFlags +ListEditItemModel +::flags( const QModelIndex & idx ) const +{ + if( !idx.isValid() ) + return QAbstractItemModel::flags( idx ); + + Qt::ItemFlags iflags = + QAbstractItemModel::flags( idx ) + // | Qt::ItemIsDragEnabled + // | Qt::ItemIsDropEnabled + ; + + if( idx.column()==COLUMN_NAME ) + iflags |= + Qt::ItemIsEditable + // | Qt::ItemIsUserCheckable + // | Qt::ItemIsDragEnabled + ; + + return iflags; +} + +/*****************************************************************************/ +bool +ListEditItemModel +::hasChildren( const QModelIndex & idx ) const +{ + return !idx.isValid(); +} + +/*****************************************************************************/ +QVariant +ListEditItemModel +::headerData( int section, + Qt::Orientation /**orientation*/, + int role ) const +{ + // qDebug() + // << this << "::headerData(" + // << section << "," << orientation << "," << role + // << ")"; + + // assert( orientation==Qt::Horizontal ); + + switch( role ) + { + case Qt::DisplayRole: + assert( section>=0 && section<COLUMN_COUNT ); + return tr( HEADERS[ section ] ); + break; + + default: + break; + } + + return QVariant(); +} + +/*****************************************************************************/ +QModelIndex +ListEditItemModel +::index( int row, + int column, + const QModelIndex & p ) const +{ + // qDebug() + // << this << "::index(" << row << "," << column << "," << parent << ")"; + + if( m_StringList == nullptr ) + return QModelIndex(); + + // qDebug() + // << "index:" << row << "," << column << "," << m_StringList->At( row ); + + assert( row>=0 && column>=0 ); + +#if 0 + AbstractLayerModel * layer = m_StringList->At( row ); + + if( layer==NULL || p.isValid() ) + return QModelIndex(); +#endif + + return + createIndex( + row, + column, + p.isValid() + ? NULL + : m_StringList + ); +} + +/*****************************************************************************/ +bool +ListEditItemModel +::insertRow( int row, const QModelIndex & idxParent ) +{ + return insertRows( row, 1, idxParent ); +} + +/*****************************************************************************/ +bool +ListEditItemModel +::insertRows( int row, int count, const QModelIndex & idxParent ) +{ + // qDebug() << this << "::insertRows(" << row << "," << count << "," << idxParent << ")"; + + assert( m_StringList!=nullptr ); + + beginInsertRows( idxParent, row, count ); + { + for( int r=row; r<row+count; ++r ) + m_StringList->Insert( "", r ); + } + endInsertRows(); + + return true; +} + +/*****************************************************************************/ +QModelIndex +ListEditItemModel +::parent( const QModelIndex & ) const +{ + // qDebug() << this << "::parent(" << index << ")"; + + return QModelIndex(); +} + +/*****************************************************************************/ +bool +ListEditItemModel +::removeRows( int row, int count, const QModelIndex & p ) +{ + assert( !p.isValid() ); + assert( count>=1 ); + + if( p.isValid() || count<1 ) + return false; + + assert( m_StringList!=nullptr ); + + beginRemoveRows( p, row, row + count - 1 ); + { + m_StringList->Erase( row, count ); + } + endRemoveRows(); + + return true; +} + +/*****************************************************************************/ +int +ListEditItemModel +::rowCount( const QModelIndex & p ) const +{ + // qDebug() << this << "::rowCount(" << p << ")"; + + // qDebug() << "row-count:" << + // ( ( m_StringList==NULL || p.isValid() ) + // ? 0 + // : m_StringList->GetCount() + // ); + + return + ( m_StringList==nullptr || p.isValid() ) + ? 0 + : m_StringList->Size(); +} + +/*****************************************************************************/ +bool +ListEditItemModel +::setData( const QModelIndex & idx, + const QVariant & value, + int role ) +{ + // qDebug() + // << this << "::setData(" << idx << "," << value << "," << role + // << ");"; + + assert( !idx.parent().isValid() ); + assert( idx.row()>=0 ); + assert( idx.internalPointer()!=nullptr ); + + StringListInterface * stringList = + static_cast< StringListInterface * >( idx.internalPointer() ); + + switch( idx.column() ) + { + case COLUMN_NAME: + switch( role ) + { + case Qt::EditRole: + stringList->SetNthFileName( + idx.row(), + QFile::encodeName( value.toString() ).data() + ); + emit dataChanged( idx, idx ); + return true; + break; + + case Qt::CheckStateRole: + break; + + case USER_ROLE_DIRECTION: + break; + + default: + break; + } + break; + + default: + break; + } + + return false; +} + +/*******************************************************************************/ +bool +ListEditItemModel +::Swap( int row1, int row2 ) +{ + assert( m_StringList!=nullptr ); + + assert( row1>=0 ); + assert( static_cast< unsigned int >( row1 )<m_StringList->Size() ); + + assert( row2>=0 ); + assert( static_cast< unsigned int >( row2 )<m_StringList->Size() ); + + assert( row1!=row2 ); + + emit layoutAboutToBeChanged(); + + m_StringList->Swap( row1, row2 ); + + emit layoutChanged(); + + return true; +} + +/*******************************************************************************/ +bool +ListEditItemModel +::IsInput() const +{ + assert( m_StringList!=nullptr ); + + return m_StringList->GetDirection()==Role_Input; +} + +/*******************************************************************************/ +bool +ListEditItemModel +::IsBrowsable() const +{ + assert( m_StringList!=nullptr ); + + return m_StringList->IsFilename(); +} + +/*******************************************************************************/ +QString +ListEditItemModel +::GetFilter() const +{ + assert( m_StringList!=nullptr ); + + return QString::fromStdString( m_StringList->GetFilenameFilter() ); +} + +/*******************************************************************************/ +/* SLOTS */ +/*******************************************************************************/ + +} // end namespace 'Wrapper'. + +} // end namespace 'otb' diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f2b1524dc9a3f080e8dfd18a02ada040db381ea7 --- /dev/null +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.cxx @@ -0,0 +1,657 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperQtWidgetListEditWidget.h" +#include "ui_otbWrapperQtWidgetListEditWidget.h" + + +/*****************************************************************************/ +/* INCLUDE SECTION */ + +// +// Qt includes (sorted by alphabetic order) +//// Must be included before system/custom includes. + +// +// System includes (sorted by alphabetic order) + +// +// ITK includes (sorted by alphabetic order) + +// +// OTB includes (sorted by alphabetic order) +#include "otbQtAdapters.h" +#include "otbWrapperQtWidgetListEditItemModel.h" +#include "otbWrapperTypes.h" + +namespace otb +{ + +namespace Wrapper +{ + +/* + TRANSLATOR otn::Wrappers + + Necessary for lupdate to be aware of C++ namespaces. + + Context comment for translator. +*/ + + +/*****************************************************************************/ +/* CONSTANTS */ + + +/*****************************************************************************/ +/* STATIC IMPLEMENTATION SECTION */ + + +/*****************************************************************************/ +/* CLASS IMPLEMENTATION SECTION */ +/*****************************************************************************/ +ListEditWidget +::ListEditWidget( StringListInterface * sli, + QWidget * p, + Qt::WindowFlags flags ) : + QWidget( p, flags ), + m_UI( new otb::Wrapper::Ui::ListEditWidget() ) +{ + m_UI->setupUi( this ); + + setAcceptDrops(true); + + assert( m_UI->treeView->selectionModel()==nullptr ); + + // + // Item-model. + ListEditItemModel * model = new ListEditItemModel( sli, m_UI->treeView ); + + m_UI->treeView->setModel( model ); + + QObject::connect( + model, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), + this, SLOT( OnDataChanged( const QModelIndex &, const QModelIndex & ) ) + ); + + QObject::connect( + model, SIGNAL( modelReset() ), + this, SLOT( OnModelReset() ) + ); + + QObject::connect( + model, SIGNAL( rowsInserted( const QModelIndex &, int, int ) ), + this, SLOT( OnRowsInserted( const QModelIndex &, int, int ) ) + ); + + QObject::connect( + model, SIGNAL( rowsRemoved( const QModelIndex &, int, int ) ), + this, SLOT( OnRowsRemoved( const QModelIndex &, int, int ) ) + ); + + // + // Selection-model. + assert( m_UI->treeView->selectionModel()!=nullptr ); + + QObject::connect( + m_UI->treeView->selectionModel(), + SIGNAL( + selectionChanged( const QItemSelection & , const QItemSelection & ) + ), + // to: + this, + SLOT( + OnSelectionChanged( const QItemSelection & , const QItemSelection & ) + ) + ); + + // + // Browse-button. + assert( m_UI->browseButton!=nullptr ); + + m_UI->browseButton->setEnabled( model->IsBrowsable() ); +} + +/*******************************************************************************/ +ListEditWidget +::~ListEditWidget() +{ + delete m_UI; + m_UI = nullptr; +} + +#if 0 + +/*****************************************************************************/ +void +ListEditWidget +::SetBrowseEnabled( bool enabled ) +{ + assert( m_UI!=nullptr ); + assert( m_UI->browseButton ); + + m_UI->browseButton->setEnabled( enabled ); +} + +/*******************************************************************************/ +bool +ListEditWidget +::IsBrowseEnabled() const +{ + assert( m_UI!=nullptr ); + assert( m_UI->browseButton ); + + return m_UI->browseButton->isEnabled(); +} + +#endif + +/*******************************************************************************/ +const ListEditItemModel * +ListEditWidget +::GetItemModel() const +{ + return const_cast< ListEditWidget * >( this )->GetItemModel(); +} + +/*******************************************************************************/ +ListEditItemModel * +ListEditWidget +::GetItemModel() +{ + assert( + m_UI->treeView->model()== + qobject_cast< ListEditItemModel * >( m_UI->treeView->model() ) + ); + + return qobject_cast< ListEditItemModel * >( m_UI->treeView->model() ); +} + +/*******************************************************************************/ +void +ListEditWidget +::Swap( int row1, int row2, SwapSelection s ) +{ + assert( GetItemModel()!=nullptr ); + + assert( row1>=0 ); + assert( row1<GetItemModel()->rowCount() ); + + assert( row2>=0 ); + assert( row2<GetItemModel()->rowCount() ); + + + ListEditItemModel * itemModel = GetItemModel(); + + assert( itemModel!=nullptr ); + + + itemModel->Swap( row1, row2 ); + + + { + int row = + s==LEFT + ? row1 + : ( s==RIGHT + ? row2 + : -1 ); + + if( row<0 ) + return; + + assert( m_UI!=nullptr ); + assert( m_UI->treeView!=nullptr ); + assert( m_UI->treeView->selectionModel()!=nullptr ); + + QItemSelectionModel * ism = m_UI->treeView->selectionModel(); + + assert( ism!=nullptr ); + + ism->clear(); + + ism->setCurrentIndex( + itemModel->index( row, ListEditItemModel::COLUMN_NAME ), + QItemSelectionModel::Clear | + QItemSelectionModel::Select | + QItemSelectionModel::Current | + QItemSelectionModel::Rows + ); + } +} + +/*******************************************************************************/ +QStringList +ListEditWidget +::browseFilenames( bool multi , const QString & filename ) +{ + const ListEditItemModel * itemModel = GetItemModel(); + assert( itemModel!=nullptr ); + + QString filePath( + QDir::current().filePath( + filename + ) + ); + + QString selectedFilter; + QStringList output; + if(itemModel->IsInput()) + { + if (multi) + { + output = GetOpenFileNames( + this, + tr( "Select input filename..." ), + filePath, + itemModel->GetFilter(), + &selectedFilter + ); + } + else + { + output.push_back( + GetOpenFileName( + this, + tr( "Select input filename..." ), + filePath, + itemModel->GetFilter(), + &selectedFilter + ) + ); + } + } + else + { + output.push_back( + GetSaveFileName( + this, + tr( "Select output filename..." ), + filePath, + itemModel->GetFilter(), + &selectedFilter + ) + ); + } + return output; +} + +/*******************************************************************************/ +QString +ListEditWidget +::browseFilename( const QModelIndex & index ) +{ + assert( index.isValid() ); + assert( index.row()>=0 ); + assert( index.column()>=0 ); + + // + // Get item-model. + const ListEditItemModel * itemModel = GetItemModel(); + assert( itemModel!=nullptr ); + + // + // Pick-up filename. + assert( + itemModel->data( index, ListEditItemModel::USER_ROLE_DIRECTION ).isValid() + ); + + assert( + itemModel->data( index, ListEditItemModel::USER_ROLE_DIRECTION )==Role_Input + || + itemModel->data( index, ListEditItemModel::USER_ROLE_DIRECTION )==Role_Output + ); + + return + (browseFilenames( false, itemModel->data( index ).toString() )).front(); +} + + +/*******************************************************************************/ +/* SLOTS */ +/*******************************************************************************/ +void +ListEditWidget +::OnFilenameDropped(const QString & filename) +{ + ListEditItemModel * itemModel = GetItemModel(); + assert( itemModel!=nullptr ); + + if( filename.isEmpty() ) + return; + + int row = itemModel->rowCount(); + assert( row>=0 ); + + if( !itemModel->insertRow( row ) ) + return; + + itemModel->setData( + itemModel->index( row, ListEditItemModel::COLUMN_NAME ), + filename + ); +} + + +void +ListEditWidget +::on_addButton_clicked() +{ + // qDebug() << this << "::on_addButton_clicked()"; + + ListEditItemModel * itemModel = GetItemModel(); + assert( itemModel!=nullptr ); + + // + // When not browsable + if( !itemModel->IsBrowsable() ) + { + itemModel->insertRow( itemModel->rowCount() ); + + return; + } + + // + // When browsable. + QStringList filenames( browseFilenames(true) ); + + if( filenames.isEmpty() ) + return; + + int row = itemModel->rowCount(); + assert( row>=0 ); + + for (int i=0 ; i<filenames.size() ; i++) + { + if( !itemModel->insertRow( row ) ) + return; + + itemModel->setData( + itemModel->index( row, ListEditItemModel::COLUMN_NAME ), + filenames[i] + ); + row++; + } +} + +/*******************************************************************************/ +void +ListEditWidget +::on_removeButton_clicked() +{ + // qDebug() << this << "::on_removeButton_clicked()"; + + assert( m_UI->treeView->selectionModel()!=nullptr ); + + + QModelIndexList indexes( + m_UI->treeView->selectionModel()->selectedRows() + ); + + if( indexes.empty() ) + return; + + + ListEditItemModel * itemModel = GetItemModel(); + + assert( itemModel!=nullptr ); + + + for( const QModelIndex & i : indexes ) + { + assert( i.isValid() ); + + itemModel->removeRow( i.row() ); + } +} + +/*******************************************************************************/ +void +ListEditWidget +::on_removeAllButton_clicked() +{ + // qDebug() << this << "::on_removeAllButton_clicked()"; + + ListEditItemModel * model = GetItemModel(); + assert( model ); + + if( model->rowCount()<1 ) + return; + + assert( qApp ); + assert( !qApp->applicationName().isEmpty() ); + + if( QMessageBox::question( + this, + qApp->applicationName(), + tr("Are you sure you want to delete all (%1) item(s)?") + .arg( model->rowCount() ), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No + ) + ==QMessageBox::No ) + return; + + model->removeRows( 0, model->rowCount() ); +} + +/*******************************************************************************/ +void +ListEditWidget +::on_upButton_clicked() +{ + // qDebug() << this << "::on_upButton_clicked()"; + + assert( m_UI!=nullptr ); + assert( m_UI->treeView!=nullptr ); + assert( m_UI->treeView->selectionModel()!=nullptr ); + + + QModelIndexList indexes( + m_UI->treeView->selectionModel()->selectedRows() + ); + + if( indexes.empty() ) + return; + + assert( indexes.size()==1 ); + + + const QModelIndex & front = indexes.front(); + + if( front.row()<1 ) + return; + + + Swap( + front.row(), + front.row() - 1, + RIGHT + ); +} + +/*******************************************************************************/ +void +ListEditWidget +::on_downButton_clicked() +{ + // qDebug() << this << "::on_downButton_clicked()"; + + assert( m_UI!=nullptr ); + assert( m_UI->treeView!=nullptr ); + assert( m_UI->treeView->selectionModel()!=nullptr ); + + + QModelIndexList indexes( + m_UI->treeView->selectionModel()->selectedRows() + ); + + if( indexes.empty() ) + return; + + assert( indexes.size()==1 ); + + + const QModelIndex & front = indexes.front(); + + if( front.row() >= GetItemModel()->rowCount() - 1 ) + return; + + + Swap( + front.row(), + front.row() + 1, + RIGHT + ); +} + +/*******************************************************************************/ +void +ListEditWidget +::on_browseButton_clicked() +{ + // qDebug() << this << "::on_browseButton_clicked()"; + + assert( m_UI!=nullptr ); + assert( m_UI->treeView!=nullptr ); + assert( m_UI->treeView->selectionModel()!=nullptr ); + + + // + // Pick-up first item of selection. + QModelIndexList indexes( + m_UI->treeView->selectionModel()->selectedRows() + ); + + if( indexes.isEmpty() ) + return; + + assert( indexes.size()==1 ); + + const QModelIndex & front = indexes.front(); + + // + // Get item-model. + ListEditItemModel * itemModel = GetItemModel(); + assert( itemModel!=nullptr ); + + // + // Pick-up filename. + QString selectedFilter; + + QString filename( browseFilename( front ) ); + + if( filename.isEmpty() ) + return; + + // + // Foo. + itemModel->setData( front, filename ); +} + +/*******************************************************************************/ +void +ListEditWidget +::OnSelectionChanged( const QItemSelection & /* selected */, + const QItemSelection & /* deselected */ ) +{ + // qDebug() + // << this + // << "::onSelectionChanged(" << selected << "," << deselected << ")"; + + // Experimental code. + // assert( selected.indexes().size()>=0 && selected.indexes().size()<=1 ); + + // assert( m_UI->upButton ); + // assert( m_UI->downButton ); + // assert( m_UI->browseButton ); + // assert( m_UI->removeButton ); + + // if( selected.empty() ) + // { + // m_UI->browseButton->setEnabled( false ); + // m_UI->removeButton->setEnabled( false ); + + // m_UI->upButton->setEnabled( false ); + // m_UI->downButton->setEnabled( false ); + + // return; + // } + + // assert( GetItemModel() ); + + // m_UI->browseButton->setEnabled( GetItemModel()->IsBrowsable() ); + // m_UI->removeButton->setEnabled( true ); + + // const QModelIndex & index = selected.indexes().front(); + + // m_UI->upButton->setEnabled( index.isValid() && index.row()>0 ); + + // m_UI->downButton->setEnabled( + // index.isValid() && + // index.sibling( index.row() + 1, index.column() ).isValid() + // ); +} + +/*****************************************************************************/ +void +ListEditWidget +::OnDataChanged( const QModelIndex &, const QModelIndex & ) +{ + // qDebug() << this << "::OnDataChanged()"; + + assert( GetItemModel()!=nullptr ); + + emit Updated(); +} + +/*****************************************************************************/ +void +ListEditWidget +::OnModelReset() +{ + // qDebug() << this << "::OnModelReset()"; + + emit Updated(); +} + +/*****************************************************************************/ +void +ListEditWidget +::OnRowsInserted( const QModelIndex &, int, int ) +{ + // qDebug() << this << "::OnRowsInserted()"; + + emit Updated(); +} + +/*****************************************************************************/ +void +ListEditWidget +::OnRowsRemoved( const QModelIndex &, int, int ) +{ + // qDebug() << this << "::OnRowsRemoved()"; + + emit Updated(); +} + +} // end namespace 'Wrapper' + +} // end namespace 'otb' diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.ui b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..58a773eeafb8924a9e7dbc5a2c40343445952998 --- /dev/null +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.ui @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>otb::Wrapper::ListEditWidget</class> + <widget class="QWidget" name="otb::Wrapper::ListEditWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>122</width> + <height>178</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <property name="locale"> + <locale language="C" country="AnyCountry"/> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>3</number> + </property> + <property name="spacing"> + <number>3</number> + </property> + <item row="0" column="0"> + <widget class="QTreeView" name="treeView"/> + </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>1</number> + </property> + <item> + <widget class="QToolButton" name="upButton"> + <property name="toolTip"> + <string>Move up</string> + </property> + <property name="text"> + <string>Up</string> + </property> + <property name="arrowType"> + <enum>Qt::UpArrow</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="addButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Add</string> + </property> + <property name="text"> + <string>+</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="browseButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Browse filename</string> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="removeAllButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Remove all items</string> + </property> + <property name="text"> + <string>✕</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="removeButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Remove</string> + </property> + <property name="text"> + <string>-</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="downButton"> + <property name="toolTip"> + <string>Move down</string> + </property> + <property name="text"> + <string>Down</string> + </property> + <property name="arrowType"> + <enum>Qt::DownArrow</enum> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx index 7f7b3ab995b85f92afeee24954d29ee971c1c2ba..f4f31d45d7b2f41ee2cc9999dfbb46b992c04298 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx @@ -102,7 +102,9 @@ void QtWidgetListViewParameter::DoUpdateGUI() void QtWidgetListViewParameter::DoCreateWidget() { m_ListView = new QListWidget(); - m_ListView->setToolTip(m_ListViewParam->GetDescription()); + m_ListView->setToolTip( + QString::fromStdString( m_ListViewParam->GetDescription() ) + ); if(m_ListViewParam->GetSingleSelection()) { diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index 1fa1e283efa1d6710096ba5c8dcb6512bf433da8..a0d61138d72e424fd282b89c1daeb9da67bb9fe6 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -70,7 +70,42 @@ QtWidgetModel ::NotifyUpdate() { // Update the parameters - m_Application->UpdateParameters(); + try + { + m_Application->UpdateParameters(); + } + catch(otb::ApplicationException& err) + { + m_Application->GetLogger()->Debug("Caught otb::ApplicationException during application update:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + emit ExceptionRaised( err.what() ); + } + catch(otb::ImageFileReaderException& err) + { + m_Application->GetLogger()->Debug("Caught otb::ImageFileReaderException during application update:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + string message( string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() ); + m_Application->GetLogger()->Fatal( message + string("\n")); + emit ExceptionRaised( message.c_str() ); + } + catch(itk::ExceptionObject& err) + { + m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application update:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + m_Application->GetLogger()->Fatal(string(err.GetDescription()) + "\n"); + emit ExceptionRaised( err.GetDescription() ); + } + catch(std::exception& err) + { + m_Application->GetLogger()->Fatal(string("Caught std::exception during application update: ") + err.what() + "\n"); + emit ExceptionRaised( err.what() ); + } + catch(...) + { + m_Application->GetLogger()->Fatal("Caught unknown exception during application update.\n"); + emit ExceptionRaised("Unknown exception"); + } + emit UpdateGui(); // Notify all diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputFilenameParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputFilenameParameter.cxx index 78ea7f7c7c220fd810671c0c7d916fc2ec3302b7..4f395262c43dd1ab3dc85c1bcf5f4ccdd315b298 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputFilenameParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputFilenameParameter.cxx @@ -57,7 +57,9 @@ void QtWidgetOutputFilenameParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_FilenameParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_FilenameParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx index bd47efd4203cb2c59b027c0db5363771961e0730..140ff6534f8487f97bbda7d0a99fc49128401843 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx @@ -58,7 +58,9 @@ void QtWidgetOutputImageParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit(); - m_Input->setToolTip( m_OutputImageParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_OutputImageParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); m_HLayout->addWidget(m_Input); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputProcessXMLParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputProcessXMLParameter.cxx index 3e67ad01c0f8827c51bb6cbd33ac046ab404db71..324fa4e10a57d6c9432ac4cf1a2e62d99e07f107 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputProcessXMLParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputProcessXMLParameter.cxx @@ -55,7 +55,9 @@ void QtWidgetOutputProcessXMLParameter::DoCreateWidget() m_HLayout->setSpacing(0); m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_XMLParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_XMLParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputVectorDataParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputVectorDataParameter.cxx index b605c9be4df59714cccb6836530621e63c62af75..62c06044a1decaa9f28b12a3af67b4a63f3b16b0 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputVectorDataParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputVectorDataParameter.cxx @@ -53,7 +53,9 @@ void QtWidgetOutputVectorDataParameter::DoCreateWidget() m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip( m_OutputVectorDataParam->GetDescription() ); + m_Input->setToolTip( + QString::fromStdString( m_OutputVectorDataParam->GetDescription() ) + ); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); m_HLayout->addWidget(m_Input); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx index 2efb31574dfc5e701a7e29ab6c996fa343618bb0..eb44e1a4ee8eca304b95e7e52f11a185c2560c0a 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx @@ -103,6 +103,21 @@ void QtWidgetParameterBase::Reset( ) this->UpdateGUI(); } +const Parameter * +QtWidgetParameterBase +::GetParam() const +{ + return m_Param; +} + +Parameter * +QtWidgetParameterBase +::GetParam() +{ + return m_Param; +} + + } } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx index 5f57b483daaae46469844d900a53f23d16afa5a7..89763c423741832b3c1e21f21ef144ff85690a22 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx @@ -21,39 +21,45 @@ #include "otbWrapperQtWidgetParameterFactory.h" #include "otbWrapperParameter.h" -#include "otbWrapperQtWidgetModel.h" - -#include "otbWrapperQtWidgetParameterBase.h" +#include "otbWrapperInputFilenameListParameter.h" +#include "otbWrapperInputVectorDataListParameter.h" +#include "otbWrapperStringListParameter.h" -#include "otbWrapperQtWidgetEmptyParameter.h" -#include "otbWrapperQtWidgetIntParameter.h" -#include "otbWrapperQtWidgetFloatParameter.h" -#include "otbWrapperQtWidgetStringParameter.h" -#include "otbWrapperQtWidgetStringListParameter.h" #include "otbWrapperQtWidgetChoiceParameter.h" -#include "otbWrapperQtWidgetListViewParameter.h" -#include "otbWrapperQtWidgetInputImageParameter.h" #include "otbWrapperQtWidgetComplexInputImageParameter.h" #include "otbWrapperQtWidgetComplexOutputImageParameter.h" -#include "otbWrapperQtWidgetInputImageListParameter.h" -#include "otbWrapperQtWidgetOutputImageParameter.h" -#include "otbWrapperQtWidgetOutputVectorDataParameter.h" +#include "otbWrapperQtWidgetDirectoryParameter.h" +#include "otbWrapperQtWidgetEmptyParameter.h" +#include "otbWrapperQtWidgetFloatParameter.h" +#include "otbWrapperQtWidgetIntParameter.h" #include "otbWrapperQtWidgetInputFilenameParameter.h" #include "otbWrapperQtWidgetInputFilenameListParameter.h" -#include "otbWrapperQtWidgetOutputFilenameParameter.h" -#include "otbWrapperQtWidgetDirectoryParameter.h" -#include "otbWrapperQtWidgetParameterGroup.h" +#include "otbWrapperQtWidgetInputImageParameter.h" +#include "otbWrapperQtWidgetInputImageListParameter.h" +#include "otbWrapperQtWidgetInputProcessXMLParameter.h" #include "otbWrapperQtWidgetInputVectorDataListParameter.h" #include "otbWrapperQtWidgetInputVectorDataParameter.h" -#include "otbWrapperQtWidgetRAMParameter.h" +#include "otbWrapperQtWidgetListViewParameter.h" +#include "otbWrapperQtWidgetModel.h" +#include "otbWrapperQtWidgetOutputFilenameParameter.h" +#include "otbWrapperQtWidgetOutputImageParameter.h" #include "otbWrapperQtWidgetOutputProcessXMLParameter.h" -#include "otbWrapperQtWidgetInputProcessXMLParameter.h" +#include "otbWrapperQtWidgetOutputVectorDataParameter.h" +#include "otbWrapperQtWidgetParameterBase.h" +#include "otbWrapperQtWidgetParameterGroup.h" +#include "otbWrapperQtWidgetRAMParameter.h" +#include "otbWrapperQtWidgetStringParameter.h" +#include "otbWrapperQtWidgetStringListParameter.h" + namespace otb { + + namespace Wrapper { + template <class TParameterType, class TQtWidget> class QtWidgetParameterGenericFactory { @@ -66,13 +72,14 @@ public: static QtWidgetParameterBase* Create( Parameter* param, QtWidgetModel* model ) { - QtWidgetParameterBase* widget = ITK_NULLPTR; - TParameterType* specificParam = dynamic_cast<TParameterType *>(param); + QtWidgetParameterBase * widget = ITK_NULLPTR; + TParameterType * specificParam = dynamic_cast< TParameterType * >( param ); + + // Code should break if param is not a TParameterType and not be silent! + assert( specificParam!=nullptr ); + + widget = new TQtWidget( specificParam, model ); - if (specificParam) - { - widget = new TQtWidget(specificParam, model); - } return widget; } }; diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterList.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterList.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5770106eeeab68b8ed66602717e520fc4e787c7b --- /dev/null +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterList.cxx @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperParameterList.h" +#include "otbWrapperQtWidgetListEditItemModel.h" +#include "otbWrapperQtWidgetListEditWidget.h" +#include "otbWrapperQtWidgetParameterList.h" + + +namespace otb +{ + +namespace Wrapper +{ + + +/*****************************************************************************/ +QtWidgetParameterList +::QtWidgetParameterList( AbstractParameterList * param, QtWidgetModel * m ) : + QtWidgetParameterBase( param, m ) +{ + assert( m!=nullptr ); + + QObject::connect( + this, SIGNAL( NotifyUpdate() ), + m, SLOT( NotifyUpdate() ) + ); +} + +/*****************************************************************************/ +QtWidgetParameterList +::~QtWidgetParameterList() +{ +} + +/*****************************************************************************/ +void +QtWidgetParameterList +::DoUpdateGUI() +{ +} + +/*****************************************************************************/ +void +QtWidgetParameterList +::DoCreateWidget() +{ + // + // List-edit widget. + assert( dynamic_cast< StringListInterface * >( GetParam() )!=nullptr ); + + ListEditWidget * widget = new ListEditWidget( + dynamic_cast< StringListInterface * >( GetParam() ) + ); + + // + // Global Layout + QGridLayout * gLayout = new QGridLayout(); + + gLayout->setSpacing( 1 ); + gLayout->setContentsMargins( 2, 2, 2, 2 ); + + gLayout->addWidget( widget ); + + setLayout( gLayout ); + + // + // Connections. + QObject::connect( + widget, SIGNAL( Updated() ), + this, SIGNAL( NotifyUpdate() ) + ); +} + +} + +} diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetRAMParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetRAMParameter.cxx index ffe5336b35f7c33fe56c2b56e56482ae24b87cfb..be73e12d1ca020529528eaf8fb59b473ed874fa0 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetRAMParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetRAMParameter.cxx @@ -43,7 +43,9 @@ void QtWidgetRAMParameter::DoCreateWidget() m_QHBoxLayout->setContentsMargins(0, 0, 0, 0); m_QSpinBox = new QSpinBox; - m_QSpinBox->setToolTip(m_RAMParam->GetDescription()); + m_QSpinBox->setToolTip( + QString::fromStdString( m_RAMParam->GetDescription() ) + ); connect( m_QSpinBox, SIGNAL(valueChanged(int)), this, SLOT(SetValue(int)) ); connect( m_QSpinBox, SIGNAL(valueChanged(int)), GetModel(), SLOT(NotifyUpdate()) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx index 04667ea5242400c04ba442c980d00f04a834b4e3..60a9073ae2d41215e8d3a387edb616c7994359cc 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx @@ -20,110 +20,35 @@ #include "otbWrapperQtWidgetStringListParameter.h" -namespace otb -{ -namespace Wrapper -{ -QtWidgetStringListParameter::QtWidgetStringListParameter(StringListParameter* param, QtWidgetModel* m) -: QtWidgetParameterBase(param, m), - m_StringListParam(param) -{ - connect( this, - SIGNAL(Change()), - GetModel(), - SLOT(NotifyUpdate()) ); -} +#include "otbWrapperStringListParameter.h" -QtWidgetStringListParameter::~QtWidgetStringListParameter() -{ -} -void QtWidgetStringListParameter::DoUpdateGUI() +namespace otb { - if(!m_StringListParam) - return; - std::vector<std::string> strList = m_StringListParam->GetValue(); - for( unsigned int i = m_LineEditList.size(); i < strList.size(); i++ ) - { - this->AddString(); - } - int i = 0; - std::vector<std::string>::iterator it; - for (it = strList.begin(); it != strList.end(); ++it) - { - m_LineEditList[i++]->SetText(QString( (*it).c_str() )); - } -} -void QtWidgetStringListParameter::DoCreateWidget() +namespace Wrapper { - m_LineEditList.clear(); - const unsigned int sp(2); - const unsigned int buttonSize(30); - // Global layout - QHBoxLayout * hLayout = new QHBoxLayout; - hLayout->setSpacing(sp); - hLayout->setContentsMargins(sp, sp, sp, sp); - if( m_StringListParam->GetRole() != Role_Output ) - { - // Button layout - QVBoxLayout * buttonLayout = new QVBoxLayout; - buttonLayout->setSpacing(sp); - buttonLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * addSupLayout = new QHBoxLayout; - addSupLayout->setSpacing(sp); - addSupLayout->setContentsMargins(sp, sp, sp, sp); - - QHBoxLayout * upDownLayout = new QHBoxLayout; - upDownLayout->setSpacing(sp); - upDownLayout->setContentsMargins(sp, sp, sp, sp); - - // Add file button - QPushButton * addButton = new QPushButton; - addButton->setText("+"); - addButton->setFixedWidth(buttonSize); - addButton->setToolTip("Add a string selector..."); - connect( addButton, SIGNAL(clicked()), this, SLOT(AddString()) ); - addSupLayout->addWidget(addButton); - - // Suppress file button - QPushButton * supButton = new QPushButton; - supButton->setText("-"); - supButton->setFixedWidth(buttonSize); - supButton->setToolTip("Suppress the selected string..."); - connect( supButton, SIGNAL(clicked()), this, SLOT(SuppressString()) ); - addSupLayout->addWidget(supButton); - buttonLayout->addLayout(addSupLayout); - - hLayout->addLayout(buttonLayout); - } - - QVBoxLayout * fileLayout = new QVBoxLayout(); - fileLayout->setSpacing(0); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(fileLayout); - QScrollArea * s = new QScrollArea(); - s->setWidget(mainGroup); - s->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - s->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - s->setWidgetResizable(true); - - hLayout->addWidget(s); - - - this->setLayout(hLayout); +/*****************************************************************************/ +QtWidgetStringListParameter +::QtWidgetStringListParameter( StringListParameter * param, + QtWidgetModel * m ) : + QtWidgetParameterList( param, m ) +{ +} - m_HLayout = hLayout; - m_Scroll = s; +/*****************************************************************************/ +QtWidgetStringListParameter +::~QtWidgetStringListParameter() +{ } +#if 0 + void QtWidgetStringListParameter::UpdateStringList() { @@ -206,5 +131,8 @@ QtWidgetStringListParameter::SuppressString() this->update(); } +#endif + } + } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringParameter.cxx index b48616d65f62868bdd9f088b6e226b552ce412ec..54ffc7f82f1b0c2281bc77008d5e10684ae20b46 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringParameter.cxx @@ -37,7 +37,9 @@ QtWidgetStringParameter::~QtWidgetStringParameter() void QtWidgetStringParameter::DoUpdateGUI() { - m_Input->setToolTip(m_StringParam->GetDescription()); + m_Input->setToolTip( + QString::fromStdString( m_StringParam->GetDescription() ) + ); // Update the lineEdit only if there is a change and that's not empty or whitespaces QString text( m_StringParam->GetValue().c_str() ); @@ -55,7 +57,9 @@ void QtWidgetStringParameter::DoCreateWidget() m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; - m_Input->setToolTip(m_StringParam->GetDescription()); + m_Input->setToolTip( + QString::fromStdString( m_StringParam->GetDescription() ) + ); m_HLayout->addWidget(m_Input); connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetValue(const QString&)) ); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx index ae64ff49e556c3f0a2431472dad49290eb9a480c..9cc7c4af44e33e7520c0034551b48b1805dd0762 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx @@ -82,6 +82,8 @@ void QtWidgetView::CreateGui() QVBoxLayout *finalLayout = new QVBoxLayout(); finalLayout->addWidget(mainGroup); + connect( m_Model, SIGNAL(ExceptionRaised(QString)), this, SLOT(OnExceptionRaised(QString)) ); + // Make the final layout to the widget this->setLayout(finalLayout); } @@ -188,9 +190,14 @@ void QtWidgetView::CloseSlot() void QtWidgetView::UnhandledException(QString message) { - m_TabWidget->setCurrentIndex(1); + this->OnExceptionRaised(message); m_LogText->append(message); } +void QtWidgetView::OnExceptionRaised(QString /*message*/) +{ + m_TabWidget->setCurrentIndex(1); +} + } } diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 72adde8bd4d3181aee5c712ea41f0822ece49f39..3489e589aa3e3c3a18e305e4448076aa99612404 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -128,7 +128,7 @@ namespace Wrapper typedef enum { - Role_Input, + Role_Input = 0, Role_Output } Role; @@ -198,7 +198,7 @@ public: std::string GetParameterString(std::string parameter); std::vector<std::string> GetParameterStringList(std::string parameter); std::string GetParameterAsString(std::string paramKey); - + InputImageParameter::ImageBaseType * GetParameterOutputImage(std::string parameter); void SetParameterInputImage(std::string parameter, InputImageParameter::ImageBaseType * inputImage); ComplexInputImageParameter::ImageBaseType * GetParameterComplexOutputImage(std::string parameter); @@ -211,7 +211,7 @@ public: unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter); - + itkProcessObject* GetProgressSource() const; std::string GetProgressDescription() const; @@ -279,7 +279,7 @@ public: spacing.Fill( 1.0 ); \ direction.SetIdentity(); \ output->SetOrigin( origin ); \ - output->SetSpacing( spacing ); \ + output->SetSignedSpacing( spacing ); \ output->SetDirection(direction); \ output->SetLargestPossibleRegion(region); \ output->SetRequestedRegion(output->GetLargestPossibleRegion()); \ @@ -562,38 +562,53 @@ class ApplicationProxy(object): print ("Unsupported parameter type '%s' with key '%s'" %(self.GetParameterTypeAsString(paramType) ,paramKey)) return None - def __getattr__(self,attr): - """ - __get_attribute__ is called whenever an instance request an attribute. - eg: App.SetParameterString(), App.GetName() .. - __getattr__ is only called if the attribute is not found by __get_attribute__ call - So we keep hide the GetParameter** calls within this method so that it seems like - an obivous call for users. App.IN , App.OUT , where 'in' and 'out' are - parameters in the 'otb application' with instance App - """ - if attr is not None: - key_list = [k.upper() for k in self.GetParametersKeys(True)] - if attr in key_list: - return self.GetParameterValue(attr.lower()) - else: - raise AttributeError("Parameter {} does not exist in the application.".format(attr.lower())) - - def __setattr__(self, attr, value): - """ - __setattr__ is called if the attribute requested is not found in the attribute list. - So these attributes are supposed to be 'key' of parameters used. Here we - keep hide the SetParameter** calls within this method so that it seems like - an obivous call for users. App.IN='my-input-file-name' , App.OUT='my-output-file-name'w - here 'in' and 'out' are parameters in the 'otb application' with instance App - Ofcourse, we don't blindly accept any attributes as python, we check them against - list of existing parameters for application with 'self.GetParametersKeys(True)' - """ - if attr is not None: - key_list = [k.upper() for k in self.GetParametersKeys(True)] - if attr in key_list: - self.SetParameterValue(attr.lower(), value) - else: - raise AttributeError("Parameter {} does not exist in the application.".format(attr.lower())) + def __getattr__(self,name): + """ + __get_attribute__ is called whenever an instance request an attribute. + eg: App.SetParameterString(), App.GetName() .. + __getattr__ is only called if the attribute is not found by __get_attribute__ call + So we keep hide the GetParameter** calls within this method so that it seems like + an obivous call for users. App.IN , App.OUT , where 'in' and 'out' are + parameters in the 'otb application' with instance App + Since SWIG also uses this function, we have to copy their code before + using custom OTB behaviour + """ + if (name == "thisown"): + return self.this.own() + method = Application.__swig_getmethods__.get(name, None) + if method: + return method(self) + key_list = [k.upper() for k in self.GetParametersKeys(True)] + if name in key_list: + return self.GetParameterValue(name.lower()) + raise AttributeError("'%s' object has no attribute '%s'" % (Application.__name__, name)) + + def __setattr__(self, name, value): + """ + __setattr__ is called if the attribute requested is not found in the attribute list. + So these attributes are supposed to be 'key' of parameters used. Here we + keep hide the SetParameter** calls within this method so that it seems like + an obivous call for users. App.IN='my-input-file-name' , App.OUT='my-output-file-name'w + here 'in' and 'out' are parameters in the 'otb application' with instance App + Ofcourse, we don't blindly accept any attributes as python, we check them against + list of existing parameters for application with 'self.GetParametersKeys(True)' + Since SWIG also uses this function, we have to copy their code before + using custom OTB behaviour + """ + if (name == "thisown"): + return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = Application.__swig_setmethods__.get(name, None) + if method: + return method(self, value) + key_list = [k.upper() for k in self.GetParametersKeys(True)] + if name in key_list: + self.SetParameterValue(name.lower(), value) + else: + raise AttributeError("You cannot add attributes to %s" % self) } } diff --git a/Modules/Wrappers/SWIG/test/python/Bug823.py b/Modules/Wrappers/SWIG/test/python/Bug823.py index 96c9ed5894f37a4d3cee47fdd46f6887bc907917..35604ec1acecdad4f584f8daa4cd9a67f02b92e0 100644 --- a/Modules/Wrappers/SWIG/test/python/Bug823.py +++ b/Modules/Wrappers/SWIG/test/python/Bug823.py @@ -24,7 +24,7 @@ def test(otb, argv): app = otb.Registry.CreateApplication('Rasterization') try: app.GetParameterInt('szx') - except RuntimeError, e: + except RuntimeError as e: print( "Exception message : " + e.args[0] ) if e.args[0].startswith("boost::bad_any_cast"): exit(1) diff --git a/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py b/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py index 0e14f65f0c468ae350d1ee28d77e34818f2b9eb7..34e48dbb646767a82c3e12d816954d2fafbb5d8c 100644 --- a/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py +++ b/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py @@ -42,7 +42,7 @@ def test(otb, argv): app4.AddImageToParameterInputImageList("il",app2.GetParameterOutputImage("out")); app4.AddImageToParameterInputImageList("il",app3.GetParameterOutputImage("out")); - app4.AddParameterStringList("il",argv[1]) + app4.AddParameterStringList("il",argv[1]) app4.OUT = argv[2] app4.ExecuteAndWriteOutput() diff --git a/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py b/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py index d8aab348b0ec805bddd99ddd89b05e568df419a8..4cb17b6fe546d0c2ad2a97222d40e5eca83eae4b 100644 --- a/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py +++ b/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py @@ -22,7 +22,7 @@ # Example on the use of otb "pythonization" # def cm_assert(a,b): - print "debug print before assert check: '%s'== '%s'" %(a, b) + print("debug print before assert check: '%s'== '%s'" %(a, b)) assert a == b def test(otb, argv):