Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
cae2e704
Commit
cae2e704
authored
Nov 23, 2020
by
Julien Cabieces
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't generate Enum parameter is there is no choice values available
parent
d9cd1e6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
29 deletions
+43
-29
Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
+43
-29
No files found.
Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
View file @
cae2e704
...
...
@@ -132,8 +132,36 @@ int main(int argc, char* argv[])
{
const
std
::
string
name
=
appKeyList
[
i
];
const
Parameter
::
Pointer
param
=
appli
->
GetParameterByKey
(
name
);
const
ParameterType
type
=
appli
->
GetParameterType
(
name
);
ParameterType
type
=
appli
->
GetParameterType
(
name
);
const
std
::
string
description
=
appli
->
GetParameterName
(
name
);
// if there is no choice value for a list view parameter
// we switch to parameter stringlist to avoid aving empty combobox in QGIS
if
(
type
==
ParameterType_ListView
)
{
ListViewParameter
*
lv_param
=
dynamic_cast
<
ListViewParameter
*>
(
param
.
GetPointer
());
if
(
appli
->
GetChoiceNames
(
name
).
empty
()
)
{
type
=
ParameterType_StringList
;
}
}
std
::
string
optional
;
if
(
param
->
GetMandatory
())
{
// TODO: avoid workaround for stringlist types (fix appengine)
// type == ParameterType_StringList check is needed because:
// If parameter is mandatory it can have no value
// It is accepted in OTB that, string list could be generated dynamically
// qgis has no such option to handle dynamic values yet..
// So mandatory parameters whose type is StringList is considered optional
optional
=
param
->
HasValue
()
||
type
==
ParameterType_StringList
?
"True"
:
"False"
;
}
else
{
optional
=
"True"
;
}
if
(
type
==
ParameterType_Group
||
type
==
ParameterType_RAM
||
param
->
GetRole
()
==
Role_Output
)
{
// group parameter cannot have any value.
...
...
@@ -141,6 +169,7 @@ int main(int argc, char* argv[])
// parameter role cannot be of type Role_Output
continue
;
}
auto
it
=
parameterTypeToString
.
find
(
type
);
assert
(
it
!=
parameterTypeToString
.
end
());
if
(
it
==
parameterTypeToString
.
end
())
...
...
@@ -286,18 +315,22 @@ int main(int argc, char* argv[])
filterType
|=
NUMERIC
;
}
dFile
<<
"|None|"
<<
f_param
->
GetVectorData
()
<<
"|"
<<
(
filterType
==
STRING
?
"QgsProcessingParameterField.String"
:
filterType
==
NUMERIC
?
"QgsProcessingParameterField.Numeric"
:
"QgsProcessingParameterField.Any"
)
<<
"|"
<<
(
f_param
->
GetSingleSelection
()
?
"False"
:
"True"
);
dFile
<<
"|None|"
<<
f_param
->
GetVectorData
()
<<
"|"
<<
(
filterType
==
STRING
?
"QgsProcessingParameterField.String"
:
filterType
==
NUMERIC
?
"QgsProcessingParameterField.Numeric"
:
"QgsProcessingParameterField.Any"
)
<<
"|"
<<
(
f_param
->
GetSingleSelection
()
?
"False"
:
"True"
)
<<
"|"
<<
optional
;
}
else
if
(
type
==
ParameterType_Band
)
{
BandParameter
*
f_param
=
dynamic_cast
<
BandParameter
*>
(
param
.
GetPointer
());
dFile
<<
"|None|"
<<
f_param
->
GetRasterData
();
dFile
<<
"|None|"
<<
f_param
->
GetRasterData
()
<<
optional
<<
"|"
<<
(
f_param
->
GetSingleSelection
()
?
"False"
:
"True"
);
}
else
{
...
...
@@ -305,21 +338,6 @@ int main(int argc, char* argv[])
return
EXIT_FAILURE
;
}
std
::
string
optional
;
if
(
param
->
GetMandatory
())
{
// TODO: avoid workaround for stringlist types (fix appengine)
// type == ParameterType_StringList check is needed because:
// If parameter is mandatory it can have no value
// It is accepted in OTB that, string list could be generated dynamically
// qgis has no such option to handle dynamic values yet..
// So mandatory parameters whose type is StringList is considered optional
optional
=
param
->
HasValue
()
||
type
==
ParameterType_StringList
?
"True"
:
"False"
;
}
else
{
optional
=
"True"
;
}
#if 0
std::cerr << name;
std::cerr << " mandatory=" << param->GetMandatory();
...
...
@@ -328,13 +346,9 @@ int main(int argc, char* argv[])
std::cerr << " optional=" << optional << std::endl;
#endif
// option
n
al and default value are not in the same order than
// optional and default value are not in the same order than
// other QGis processing parameters for field and band
if
(
type
==
ParameterType_Field
||
type
==
ParameterType_Band
)
{
dFile
<<
"|"
<<
optional
<<
"|False"
;
}
else
if
(
type
!=
ParameterType_Field
&&
type
!=
ParameterType_Band
)
{
dFile
<<
"|"
<<
default_value
<<
"|"
<<
optional
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment