Commit ced912bd authored by Rashad Kanavath's avatar Rashad Kanavath

Merge branch 'wrapper_qgis_fixes' into 'release-6.6'

Review: "add Wrapper/QGIS to generate qgis descriptors for processing plugin"

See merge request !74
parents 16bff817 d9278815
......@@ -174,6 +174,10 @@ if(NOT OTB_INSTALL_PACKAGE_DIR)
set(OTB_INSTALL_PACKAGE_DIR "${OTB_INSTALL_LIBRARY_DIR}/cmake/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
endif()
if(NOT OTB_INSTALL_DESCR_DIR)
set (OTB_INSTALL_DESCR_DIR "share/otb/description")
endif()
#convert path to native for reconfiguring otbcli.bat.in
file(TO_NATIVE_PATH "${OTB_INSTALL_APP_DIR}" OTB_INSTALL_APP_DIR_NATIVE)
......
......@@ -18,7 +18,7 @@
# limitations under the License.
#
set(DOCUMENTATION "Required to generate descriptor files for QGIS processing plugin.")
set(DOCUMENTATION "This module allows to generate application descriptor files for QGIS processing plugin.")
otb_module(OTBQgis
DEPENDS
......
......@@ -22,35 +22,40 @@ target_link_libraries(otbQgisDescriptor ${OTBQgis_LIBRARIES})
otb_module_target(otbQgisDescriptor)
set(dfiles)
set(app_list ${OTB_APPLICATIONS_NAME_LIST})
list(REMOVE_ITEM app_list "TestApplication")
list(REMOVE_ITEM app_list "ApplicationExample")
list(REMOVE_DUPLICATES app_list)
foreach(otb_app ${app_list})
set(dfile "${OTB_BINARY_DIR}/descriptors/${otb_app}.txt")
set(app_names ${OTB_APPLICATIONS_NAME_LIST})
list(REMOVE_ITEM app_names "TestApplication")
list(REMOVE_ITEM app_names "ApplicationExample")
list(REMOVE_DUPLICATES app_names)
foreach(app_name ${app_names})
set(dfile "${OTB_BINARY_DIR}/descriptors/${app_name}.txt")
add_custom_command(OUTPUT "${dfile}"
COMMAND "$<TARGET_FILE:otbQgisDescriptor>"
"${otb_app}" "${OTB_BINARY_DIR}/lib/otb/applications" "${OTB_BINARY_DIR}/descriptors/"
DEPENDS otbQgisDescriptor
WORKING_DIRECTORY ${OTB_BINARY_DIR}
COMMENT "./bin/otbQgisDescriptor ${otb_app} ./lib/otb/applications ./descriptors/"
VERBATIM)
list(APPEND dfiles "${dfile}")
COMMAND "$<TARGET_FILE:otbQgisDescriptor>"
"${app_name}" "${OTB_BINARY_DIR}/${OTB_INSTALL_APP_DIR}" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
DEPENDS otbQgisDescriptor
WORKING_DIRECTORY ${OTB_BINARY_DIR}
COMMENT "./bin/otbQgisDescriptor ${app_name} ./${OTB_INSTALL_APP_DIR} ./${OTB_INSTALL_DESCR_DIR}/"
VERBATIM)
list(APPEND dfiles "${dfile}")
endforeach()
add_custom_target(clean_algs_txt
COMMAND "${CMAKE_COMMAND}" "-E" "remove_directory" "${OTB_BINARY_DIR}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "remove_directory" "${CMAKE_INSTALL_PREFIX}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${OTB_BINARY_DIR}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Generating descriptor files for QGIS"
add_custom_target(clean_descr.dirs
COMMAND "${CMAKE_COMMAND}" "-E" "remove_directory" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
DEPENDS otbQgisDescriptor
)
add_custom_target(generate_qgis_descriptor
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Installing: ${CMAKE_INSTALL_PREFIX}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${OTB_BINARY_DIR}/descriptors" "${CMAKE_INSTALL_PREFIX}/descriptors"
DEPENDS clean_algs_txt ${dfiles}
add_custom_target(generate_descriptors
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Generated descriptor files for QGIS"
DEPENDS clean_descr.dirs ${dfiles}
)
#otb_module_target_label(generate_qgis_descriptor)
install(CODE "
message(STATUS \"Generating descriptor files for QGIS in ${OTB_INSTALL_DESCR_DIR}\")
execute_process(
COMMAND ${CMAKE_COMMAND} --build \"${OTB_BINARY_DIR}\" --target generate_descriptors
COMMAND ${CMAKE_COMMAND} -E echo \"Installing: ${CMAKE_INSTALL_PREFIX}/${OTB_INSTALL_DESCR_DIR}/\"
COMMAND ${CMAKE_COMMAND} -E copy_directory \"${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}\" \"${CMAKE_INSTALL_PREFIX}/${OTB_INSTALL_DESCR_DIR}\"
WORKING_DIRECTORY \"${OTB_BINARY_DIR}\"
)
")
......@@ -50,6 +50,9 @@ int main(int argc, char* argv[])
assert(!appli.IsNull());
const std::string group = appli->GetDocTags().size() > 0 ? appli->GetDocTags()[0] : "";
assert(!group.empty());
std::map<ParameterType, std::string> parameterTypeToString;
parameterTypeToString[ParameterType_Empty] = "QgsProcessingParameterBoolean";
parameterTypeToString[ParameterType_Bool] = "QgsProcessingParameterBoolean";
......@@ -96,7 +99,6 @@ int main(int argc, char* argv[])
}
std::ofstream dFile;
dFile.open (output_file, std::ios::out);
std::cerr << "Writing " << output_file << std::endl;
std::string output_parameter_name;
bool hasRasterOutput = false;
......@@ -106,12 +108,11 @@ int main(int argc, char* argv[])
Parameter::Pointer param = appli->GetParameterByKey(appKeyList[i]);
if (param->GetMandatory())
{
ParameterType type = appli->GetParameterType(appKeyList[i]);
if (type == ParameterType_OutputImage )
{
output_parameter_name = appKeyList[i];
hasRasterOutput = true;
}
if (appli->GetParameterType(appKeyList[i]) == ParameterType_OutputImage)
{
output_parameter_name = appKeyList[i];
hasRasterOutput = true;
}
}
}
}
......@@ -122,15 +123,13 @@ int main(int argc, char* argv[])
dFile << module << "|" << output_parameter_name << std::endl;
dFile << appli->GetDescription() << std::endl;
const std::string group = appli->GetDocTags().size() > 0 ? appli->GetDocTags()[0] : "UNCLASSIFIED";
dFile << group << std::endl;
for (unsigned int i = 0; i < nbOfParam; i++)
{
const std::string name = appKeyList[i];
Parameter::Pointer param = appli->GetParameterByKey(name);
ParameterType type = appli->GetParameterType(name);
const Parameter::Pointer param = appli->GetParameterByKey(name);
const ParameterType type = appli->GetParameterType(name);
const std::string description = param->GetName();
if ( type == ParameterType_Group ||
type == ParameterType_OutputProcessXML ||
......@@ -239,7 +238,7 @@ int main(int argc, char* argv[])
{
dFile << "|4"; //QgsProcessing.TypeFile"
}
else if(type ==ParameterType_String)
else if(type == ParameterType_String)
{
// Below line is interpreted in qgis processing as
// 1. default_value = None
......@@ -248,7 +247,7 @@ int main(int argc, char* argv[])
// please refer to documetation of QgsProcessingParameterString.
default_value = "None|False";
}
else if(type ==ParameterType_StringList)
else if(type == ParameterType_StringList)
{
// Below line is interpreted in qgis processing as
// 1. default_value = None
......@@ -262,13 +261,13 @@ int main(int argc, char* argv[])
{
// default is None and nothing to add to dFile
}
else if(type ==ParameterType_ListView)
else if(type == ParameterType_ListView)
{
// default is None and nothing to add to dFile
}
else if(type == ParameterType_Bool)
{
default_value = appli->GetParameterAsString(name);
default_value = appli->GetParameterAsString(name);
}
else if(type == ParameterType_Choice)
{
......@@ -328,9 +327,10 @@ int main(int argc, char* argv[])
if(hasRasterOutput)
{
dFile << "*QgsProcessingParameterEnum|outputpixeltype|Output pixel type|unit8;int;float;double|False|2|True" << std::endl;
dFile << "*QgsProcessingParameterEnum|outputpixeltype|Output pixel type|uint8;int;float;double|False|2|True" << std::endl;
}
std::cerr << "Writing " << output_file << std::endl;
dFile.close();
std::ofstream indexFile;
......
......@@ -194,7 +194,7 @@ if(EXISTS "${SUPERBUILD_INSTALL_DIR}/lib/otb/java/org.otb.application.jar")
endif()
set(HAVE_QGIS FALSE CACHE INTERNAL "QGIS wrappings")
if(IS_DIRECTORY "${SUPERBUILD_INSTALL_DIR}/descriptors")
if(IS_DIRECTORY "${SUPERBUILD_INSTALL_DIR}/share/otb/description")
set(HAVE_QGIS TRUE)
endif()
......
......@@ -20,7 +20,7 @@
function(install_qgis_bindings)
if(HAVE_QGIS)
install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/descriptors
install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/share/otb/description
DESTINATION ${PKG_STAGE_DIR})
endif()
endfunction()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment