Request for changes-104: Refactor OTB-applications input/output string/filename lists
Contents
Request for Changes-104: Refactor OTB-applications input/output string/filename lists
Status
- Author: Stéphane ALBERT
- Additional Contributors: Guillaume Pasero
- Submitted on September 25th, 2017
- Proposed target release : 6.4
- Adopted: +2 from Julien, Guillaume
- Merge: 38bb01822ef7cf5c7fea8abfcf80cab3dfc62720
Summary
Improve input filename/image/vector-data/string list editors, refactor and factorize common code in base classes for those parameters and Qt widgets.
Rationale
Manipulation of input list parameters (strings, filenames, images and vector-data) via the OTB-applications UI could be improved in order to:
- ease editing (add/remove/move); and
- replace the check-box by a more intuitive selection widget; and
- provide a better looking & more modern widget editor.
These improvements could also allow to factorize a lot of common code from the related QtWidget wrappers into a generic and reusable base class communicating with the application engine via an abstract string-item list interface.
Also, the related OTB-applications parameters have a lot of duplicated code which could be factorized into a template base class implementing the string-list interface.
Implementation details
Application Engine
The StringListInterface
abstract class is added to the application engine core. It defines a common container-model interface to get/set string parameter as strings and edit items of the container. This class will be used as the communication interface with its Qt widget counterpart. Each parameter which implements this interface could then be mapped to the related Qt widget.
All of the StringListParameter
, FilenameListParameter
, InputImageListParameter
and InputVectorDataParameter
should implement the WrapperStringListInterface
in order to be linked to the GUI component. Algorithmically, all those parameters are a specialization of a sequence of their respective atomic parameter namely, StringParameter
, FilenameParameter
, InputImaegParameter
and VectorDataParameter
.
Instead of rewriting all those implementation, a template ParameterList<>
base class could be implemented in order to avoid code duplication and provide template implementations and of the StringListInterface
for all the aforementioned atomic parameter types. Then, each parameter list can derive from an instantiation of the ParameterList<>
class and override only its very specific StringListInterface
behaviors. Some second level internal method template could be defined in order to avoid code duplication for similar tasks of the list parameters, thanks to C++ 14 features.
The ParameterList<>
class would also be reusable for future list parameter types drastically limiting code duplication.
QtWidget
The Graphical User Interface components of the input list parameters will be replaced by a generic QtWidgetListEditWidget
containing a QTreeView
[1] widget and some control buttons (add, remove, move up, move dow, optional browse file and remove-all) to edit its content.
The QTreeView
uses a Model-View-Controller architecture. An QtWidgetListEditItemModel
class, interfaced to the StringListInterface
, will be derived from the Qt abstract item-model to communicate with the QTreeView
. Thus, the QtWidgetListEditWidget
is made generic for all StringListInterface
parameters.
Finally, an QtWidgetParameterList
base class is added to the QtWidget module as the counterpart of of the ParameterList<>
instantiations, thus factorizing all the QtWdigetListEditWidget
code.
Classes and files
Core modifications
A Modules/Wrappers/ApplicationEngine/include/otbWrapperAbstractParameterList.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx M Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx M Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h A Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h A Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h M Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h M Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt A Modules/Wrappers/ApplicationEngine/src/otbWrapperAbstractParameterList.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx M Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx A Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterList.cxx A Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListInterface.cxx A Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx
In the module ApplicationEngine:
- addition of classes AbstractParameterList, StringListInterface, ParameterList
- parameters of types InputImageList, InputFilenameList, InputVectorDataList, StringList now derive from ParameterList
- parameters ComplexInputImage and InputVectorData behave like InputImage : no validity check when setting the filename, the check is done when we get the actual data.
- addition of 2 helper functions to convert a string into ImagePixelType and ComplexImagePixelType.
- In several places, the functions now use string references.
M Modules/Wrappers/QtWidget/CMakeLists.txt M Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameListParameter.h M Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageListParameter.h M Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataListParameter.h A Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h A Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditWidget.h A Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterList.h M Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringListParameter.h M Modules/Wrappers/QtWidget/src/CMakeLists.txt M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx A Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditItemModel.cxx A Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.cxx A Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListEditWidget.ui M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx A Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterList.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx
The QtWidgets for "list" parameters have been revamped using a new component : ListEditWidget.
Other minor modifications:
M Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h
The base parameter otb::Wrapper::Parameter can't be instanciated anymore (HasValue() is pure virtual). ClearValue() has a default implementation, and GetDescription() now returns a const reference.
M Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
The loading of parameters has been simplified to avoid duplicated code.
M Modules/Core/ObjectList/include/otbObjectList.h
Addition of two operators '+=' and '-=' for the Iterator.
M Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx
Addition of two getters on the internal parameter.
M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetChoiceParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexInputImageParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetDirectoryParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetFloatParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetIntParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputFilenameParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputProcessXMLParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputVectorDataParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetRAMParameter.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringParameter.cxx
The tooltip is set using an explicit conversion QString::fromStdString().
M Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx M Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx
The call to Application::UpdateParameter() has to be protected with a try/catch (like the call to Application::ExectuteAndWriteOutput() ). The exception generated in the QtWidgetModel is connected to a dedicated slot in the QtWidgetView.
M Modules/Applications/AppTest/app/otbTestApplication.cxx
The TestApplication has been enhanced with the revamped parameters.
M Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h M Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx
Drag & drop support is handled once in ParameterListInitializer, which make a lot of code obsolete (has been removed).
M Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx M Modules/Wrappers/SWIG/src/otbApplication.i M Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx M Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h
Only style modifications and minor modifications in theses files.
Applications
Impacts all OTB-applications using input parameter lists.
Tests
M Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt M Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx D Modules/Wrappers/ApplicationEngine/test/otbWrapperParameterTest.cxx
Since base parameter otb::Wrapper::Parameter can't be instanciated, 2 tests become useless.
Documentation
N/A
Additional notes
N/A