diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index 70d55ce7c9490d4998b7db595130d0f917bf5576..7f0606992f8e5c461a1b53d6f1e4460f88141125 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -95,7 +95,8 @@ def GenerateChoice(app,param,paramlist, count = 0): return output def GenerateParameterType(app,param): - if app.GetParameterType(param) == otbApplication.ParameterType_Empty: + if app.GetParameterType(param) == otbApplication.ParameterType_Empty \ + or app.GetParameterType(param) == otbApplication.ParameterType_Bool: return "Boolean" if app.GetParameterType(param) == otbApplication.ParameterType_Int \ or app.GetParameterType(param) == otbApplication.ParameterType_Radius \ @@ -346,6 +347,8 @@ def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outp if paramtype == otbApplication.ParameterType_Empty: app.EnableParameter(param) output+= "\t" + appname + ".EnableParameter("+EncloseString(param)+")" + linesep + if paramtype == otbApplication.ParameterType_Bool: + output+= "\t" + appname + ".SetParameterString("+EncloseString(param)+","+EncloseString(value)+")" + linesep if paramtype == otbApplication.ParameterType_Int \ or paramtype == otbApplication.ParameterType_Radius \ or paramtype == otbApplication.ParameterType_RAM: diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index 4f5089cb95d837fd5d8451c13f64d3b6d560282f..f0b2e95f251d5e642a6eb6a1e6ad4c82328e703d 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -239,12 +239,16 @@ doing geometry, projections, and also calibration. Future developments will probably offer a more adapted structure to import and export images between OTB and the Python world. -Setting of boolean parameters -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Setting of EmptyParameter +^^^^^^^^^^^^^^^^^^^^^^^^^ -Most of the parameters are set using functions ``SetParameterXXX()``. The boolean -parameters are handled differently (also called Empty parameter). Let's take an example with the application -``ReadImageInfo``: +Most of the parameters are set using functions ``SetParameterXXX()``, except for +one type of parameter: the ``EmptyParameter``. This class was the first +implementation of a boolean. It is now **deprecated**, you should use ``BoolParameter`` +instead. + +Let's take an example with the application ``ReadImageInfo`` when it was still +using an ``EmptyParameter`` for parameter ``keywordlist``: .. code-block:: python diff --git a/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx b/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx index c5b0262be43c83ff560ec97ea3a418411ef5d17f..269a6f5bf5b7f9525380233d3a5414f6c9a82948 100644 --- a/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx +++ b/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx @@ -92,7 +92,7 @@ private: SetParameterDescription("ip.radius", "The radius of the ball shaped structuring element (expressed in pixels). By default, 'ip.radius = 1 pixel'."); SetDefaultParameterInt("ip.radius", 1.0); - AddParameter(ParameterType_Empty, "ip.suvbool", "Multiple majority: Undecided(X)/Original"); + AddParameter(ParameterType_Bool, "ip.suvbool", "Multiple majority: Undecided(X)/Original"); SetParameterDescription("ip.suvbool", "Pixels with more than 1 majority class are marked as Undecided if this parameter is checked (true), or keep their Original labels otherwise (false). Please note that the Undecided value must be different from existing labels in the input labeled image. By default, 'ip.suvbool = false'."); AddParameter(ParameterType_Int, "ip.nodatalabel", "Label for the NoData class"); @@ -103,7 +103,7 @@ private: SetParameterDescription("ip.undecidedlabel", "Label for the Undecided class. By default, 'ip.undecidedlabel = 0'."); SetDefaultParameterInt("ip.undecidedlabel", 0.0); - AddParameter(ParameterType_Empty, "ip.onlyisolatedpixels", "Process isolated pixels only"); + AddParameter(ParameterType_Bool, "ip.onlyisolatedpixels", "Process isolated pixels only"); SetParameterDescription("ip.onlyisolatedpixels", "Only pixels whose label is unique in the neighbordhood will be processed. By default, 'ip.onlyisolatedpixels = false'."); AddParameter(ParameterType_Int, "ip.isolatedthreshold", "Threshold for isolated pixels"); @@ -153,7 +153,7 @@ private: m_NeighMajVotingFilter->SetLabelForUndecidedPixels(GetParameterInt("ip.undecidedlabel")); // Set to Undecided label if NOT unique Majority Voting - if (IsParameterEnabled("ip.suvbool")) + if (GetParameterInt("ip.suvbool")) { m_NeighMajVotingFilter->SetKeepOriginalLabelBool(false); } @@ -164,7 +164,7 @@ private: } // Process isolated pixels only - if (IsParameterEnabled("ip.onlyisolatedpixels")) + if (GetParameterInt("ip.onlyisolatedpixels")) { m_NeighMajVotingFilter->SetOnlyIsolatedPixels(true); m_NeighMajVotingFilter->SetIsolatedThreshold(GetParameterInt("ip.isolatedthreshold")); diff --git a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx index e6343bf4b9654a41b82317f7c8d6412b87e2e940..336c447c2a2a3214f185a765b0344b5f0d0fb021 100644 --- a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx +++ b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx @@ -143,12 +143,12 @@ private: AddParameter(ParameterType_String, "cri", "Criterion"); SetParameterDescription("cri", "Dempster Shafer criterion (by default (belief+plausibility)/2)"); MandatoryOff("cri"); - SetParameterString("cri","((Belief + Plausibility)/2.)", false); + SetParameterString("cri","((Belief + Plausibility)/2.)"); AddParameter(ParameterType_Float,"wgt","Weighting"); SetParameterDescription("wgt","Coefficient between 0 and 1 to promote undetection or false detections (default 0.5)"); MandatoryOff("wgt"); - SetParameterFloat("wgt",0.5, false); + SetParameterFloat("wgt",0.5); AddParameter(ParameterType_InputFilename,"initmod","initialization model"); SetParameterDescription("initmod","Initialization model (xml file) to be used. If the xml initialization model is set, the descriptor list is not used (specified using the option -desclist)"); @@ -157,16 +157,15 @@ private: AddParameter(ParameterType_StringList, "desclist","Descriptor list"); SetParameterDescription("desclist","List of the descriptors to be used in the model (must be specified to perform an automatic initialization)"); MandatoryOff("desclist"); - SetParameterString("desclist","", false); + SetParameterString("desclist",""); AddParameter(ParameterType_Int,"maxnbit","Maximum number of iterations"); MandatoryOff("maxnbit"); SetParameterDescription("maxnbit","Maximum number of optimizer iteration (default 200)"); - SetParameterInt("maxnbit",200, false); + SetParameterInt("maxnbit",200); - AddParameter(ParameterType_Empty,"optobs","Optimizer Observer"); + AddParameter(ParameterType_Bool,"optobs","Optimizer Observer"); SetParameterDescription("optobs","Activate the optimizer observer"); - MandatoryOff("optobs"); AddParameter(ParameterType_OutputFilename,"out","Output filename"); SetParameterDescription("out","Output model file name (xml file) contains the optimal model to perform information fusion."); @@ -405,7 +404,7 @@ private: // Create the Command observer and register it with the optimizer. CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); - if (IsParameterEnabled("optobs")) + if (GetParameterInt("optobs")) { m_Optimizer->AddObserver(itk::IterationEvent(), observer); } diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx index a5067bf9cdb782b5dd2d70e25a43c23f7d41baa8..a5a44e6b4e1ad0f62248d0f879096657c3a6199c 100644 --- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx @@ -59,11 +59,10 @@ protected: InitKMClassification(); // init at the end cleanup - AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); - EnableParameter( "cleanup" ); + AddParameter( ParameterType_Bool, "cleanup", "Temporary files cleaning" ); SetParameterDescription( "cleanup", "If activated, the application will try to clean all temporary files it created" ); - MandatoryOff( "cleanup" ); + SetParameterInt("cleanup", 1); } void InitKMSampling() @@ -148,7 +147,7 @@ protected: void ComputeImageEnvelope(const std::string &vectorFileName) { - GetInternalApplication("imgenvelop")->SetParameterString("out", vectorFileName, false); + GetInternalApplication("imgenvelop")->SetParameterString("out", vectorFileName); GetInternalApplication("imgenvelop")->ExecuteAndWriteOutput(); } @@ -187,8 +186,8 @@ protected: { std::vector<std::string> fieldList = {fieldName}; - GetInternalApplication("polystats")->SetParameterStringList("field", fieldList, false); - GetInternalApplication("polystats")->SetParameterString("out", statisticsFileName, false); + GetInternalApplication("polystats")->SetParameterStringList("field", fieldList); + GetInternalApplication("polystats")->SetParameterString("out", statisticsFileName); ExecuteInternal("polystats"); } @@ -199,17 +198,17 @@ protected: int NBSamples) { /* SampleSelection */ - GetInternalApplication("select")->SetParameterString("out", sampleFileName, false); + GetInternalApplication("select")->SetParameterString("out", sampleFileName); UpdateInternalParameters("select"); - GetInternalApplication("select")->SetParameterString("instats", statisticsFileName, false); - GetInternalApplication("select")->SetParameterString("field", fieldName, false); + GetInternalApplication("select")->SetParameterString("instats", statisticsFileName); + GetInternalApplication("select")->SetParameterString("field", fieldName); - GetInternalApplication("select")->SetParameterString("strategy", "constant", false); - GetInternalApplication("select")->SetParameterInt("strategy.constant.nb", NBSamples, false); + GetInternalApplication("select")->SetParameterString("strategy", "constant"); + GetInternalApplication("select")->SetParameterInt("strategy.constant.nb", NBSamples); if( IsParameterEnabled("rand")) - GetInternalApplication("select")->SetParameterInt("rand", GetParameterInt("rand"), false); + GetInternalApplication("select")->SetParameterInt("rand", GetParameterInt("rand")); // select sample positions ExecuteInternal("select"); @@ -217,8 +216,8 @@ protected: /* SampleExtraction */ UpdateInternalParameters("extraction"); - GetInternalApplication("extraction")->SetParameterString("outfield", "prefix", false); - GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name", "value_", false); + GetInternalApplication("extraction")->SetParameterString("outfield", "prefix"); + GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name", "value_"); // extract sample descriptors GetInternalApplication("extraction")->ExecuteAndWriteOutput(); @@ -229,7 +228,7 @@ protected: const std::string &modelFileName) { std::vector<std::string> extractOutputList = {sampleTrainFileName}; - GetInternalApplication("training")->SetParameterStringList("io.vd", extractOutputList, false); + GetInternalApplication("training")->SetParameterStringList("io.vd", extractOutputList); UpdateInternalParameters("training"); // set field names @@ -242,19 +241,19 @@ protected: oss << i; selectedNames.push_back( selectPrefix + oss.str() ); } - GetInternalApplication("training")->SetParameterStringList("feat", selectedNames, false); + GetInternalApplication("training")->SetParameterStringList("feat", selectedNames); - GetInternalApplication("training")->SetParameterString("classifier", "sharkkm", false); + GetInternalApplication("training")->SetParameterString("classifier", "sharkkm"); GetInternalApplication("training")->SetParameterInt("classifier.sharkkm.maxiter", - GetParameterInt("maxit"), false); + GetParameterInt("maxit")); GetInternalApplication("training")->SetParameterInt("classifier.sharkkm.k", - GetParameterInt("nc"), false); + GetParameterInt("nc")); if( IsParameterEnabled("rand")) - GetInternalApplication("training")->SetParameterInt("rand", GetParameterInt("rand"), false); + GetInternalApplication("training")->SetParameterInt("rand", GetParameterInt("rand")); GetInternalApplication("training")->GetParameterByKey("v")->SetActive(false); - GetInternalApplication("training")->SetParameterString("io.out", modelFileName, false); + GetInternalApplication("training")->SetParameterString("io.out", modelFileName); ExecuteInternal( "training" ); otbAppLogINFO("output model : " << GetInternalApplication("training")->GetParameterString("io.out")); @@ -264,8 +263,8 @@ protected: const std::string &imagesStatsFileName) { std::vector<std::string> imageFileNameList = {imageFileName}; - GetInternalApplication("imgstats")->SetParameterStringList("il", imageFileNameList, false); - GetInternalApplication("imgstats")->SetParameterString("out", imagesStatsFileName, false); + GetInternalApplication("imgstats")->SetParameterStringList("il", imageFileNameList); + GetInternalApplication("imgstats")->SetParameterString("out", imagesStatsFileName); ExecuteInternal( "imgstats" ); otbAppLogINFO("image statistics file : " << GetInternalApplication("imgstats")->GetParameterString("out")); @@ -497,7 +496,7 @@ private: Superclass::CreateOutMeansFile(GetParameterImage("in"), fileNames.modelFile, GetParameterInt("nc")); // Remove all tempory files - if( IsParameterEnabled( "cleanup" ) ) + if( GetParameterInt( "cleanup" ) ) { otbAppLogINFO( <<"Final clean-up ..." ); fileNames.clear(); @@ -506,7 +505,7 @@ private: void UpdateKMPolygonClassStatisticsParameters(const std::string &vectorFileName) { - GetInternalApplication( "polystats" )->SetParameterString( "vec", vectorFileName, false ); + GetInternalApplication( "polystats" )->SetParameterString( "vec", vectorFileName); UpdateInternalParameters( "polystats" ); } diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx index 889e909cc54301fb53eeb952783e9d1f4325fa20..85bed4e53ba73895d2619c590ed6b474718acac6 100644 --- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx +++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx @@ -164,7 +164,7 @@ private: SetParameterDescription("strategy.all","Take all samples"); // Default strategy : smallest - SetParameterString("strategy","smallest", false); + SetParameterString("strategy","smallest"); AddParameter(ParameterType_Choice, "mim", "Multi-Image Mode"); diff --git a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx index eb58a7e0ac4371d6c0fa4830f457bf36c11d426f..a29b0bc527a1d280f596177323e66bbfcfcd2140 100644 --- a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx @@ -82,7 +82,7 @@ private: AddParameter(ParameterType_String,"cfield","Field containing the predicted class."); SetParameterDescription("cfield","Field containing the predicted class"); - SetParameterString("cfield","predicted", false); + SetParameterString("cfield","predicted"); // Doc example parameter settings SetDocExampleParameterValue("inshp", "vectorData.shp"); diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index a9c2b07fbde06f288706a67fb9b7b999cb7de076..4c3d40b56077b7ad605758e92c59a76c9919ff74 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -89,7 +89,7 @@ private: AddParameter(ParameterType_String, "outfield.prefix.name", "Output field prefix"); SetParameterDescription("outfield.prefix.name","Prefix used to form the field names that" "will contain the extracted values."); - SetParameterString("outfield.prefix.name", "value_", false); + SetParameterString("outfield.prefix.name", "value_"); AddChoice("outfield.list","Use the given name list"); SetParameterDescription("outfield.list","Use the given name list"); diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index b41f20470f2ac4fe5d2321011cc6c806a66ebb03..cd3542db8e2db78a0c8e0f4cf624e88ab62575ed 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -200,7 +200,7 @@ private: SetParameterDescription("strategy.all","Take all samples"); // Default strategy : smallest - SetParameterString("strategy","smallest", false); + SetParameterString("strategy","smallest"); AddParameter(ParameterType_ListView, "field", "Field Name"); SetParameterDescription("field","Name of the field carrying the class name in the input vectors."); diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx index a76f81dce73870d4d6820f4931999d5253e9fed5..7bdb39044373e59b0dadb11c84b64853181c438d 100644 --- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx @@ -205,7 +205,7 @@ public: TrainModel( imageList, fileNames.sampleTrainOutputs, fileNames.sampleValidOutputs ); // cleanup - if( IsParameterEnabled( "cleanup" ) ) + if( GetParameterInt( "cleanup" ) ) { otbAppLogINFO( <<"Final clean-up ..." ); fileNames.clear(); @@ -217,7 +217,7 @@ private : void UpdatePolygonClassStatisticsParameters() { std::vector<std::string> vectorFileList = GetParameterStringList( "io.vd" ); - GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileList[0], false ); + GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileList[0]); UpdateInternalParameters( "polystat" ); } diff --git a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx index 690d03da1de8ad2a9388f36f11e1775d5ce9ce8f..9d22eb9d1afd45fe82224e62e57d6e7267f06e35 100644 --- a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx @@ -183,7 +183,7 @@ void DoInit() ITK_OVERRIDE 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 ); + SetParameterFloat( "sample.vtr" , 0.5); Superclass::DoInit(); diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx index f37eb3020f4934146d3ad4cfa9d402c19d058026..c1f6a9456ddf2ad5c419464d3fb557a6c75ca470 100644 --- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx @@ -112,7 +112,7 @@ protected: contingencyTableCalculator->Compute(performanceLabeledListSample->Begin(), performanceLabeledListSample->End(),predictedListSample->Begin(), predictedListSample->End()); - if(IsParameterEnabled("v")) + if(GetParameterInt("v")) { otbAppLogINFO( "Training performances:" ); otbAppLogINFO(<<"Contingency table: reference labels (rows) vs. produced labels (cols)\n" diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index b8ecd88713eb985b25f935741268a17f8f955edf..df1aef66be62d2c57c3178fa9141122d21f55c5f 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -124,13 +124,13 @@ private: "Only geometries with this field available will be taken into account.\n" "The field is added either in the input file (if 'out' off) or in the output file.\n" "Caution, the 'cfield' must not exist in the input file if you are updating the file."); - SetParameterString("cfield","predicted", false); + SetParameterString("cfield","predicted"); AddParameter(ParameterType_ListView, "feat", "Field names to be calculated."); SetParameterDescription("feat","List of field names in the input vector data used as features for training. " "Put the same field names as the TrainVectorClassifier application."); - AddParameter(ParameterType_Empty, "confmap", "Confidence map"); + AddParameter(ParameterType_Bool, "confmap", "Confidence map"); SetParameterDescription( "confmap", "Confidence map of the produced classification. " "The confidence index depends on the model : \n" " - LibSVM : difference between the two highest probabilities " @@ -145,7 +145,6 @@ private: " * RandomForest : Confidence (proportion of votes for the majority class). " "Margin (normalized difference of the votes of the 2 majority classes) is not available for now.\n" " * SVM : distance to margin (only works for 2-class models).\n"); - MandatoryOff("confmap"); AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing class labels"); SetParameterDescription("out","Output vector data file storing sample values (OGR format)." @@ -271,10 +270,10 @@ private: ConfidenceListSampleType::Pointer quality; - bool computeConfidenceMap(IsParameterEnabled("confmap") && m_Model->HasConfidenceIndex() + bool computeConfidenceMap(GetParameterInt("confmap") && m_Model->HasConfidenceIndex() && !m_Model->GetRegressionMode()); - if (!m_Model->HasConfidenceIndex() && IsParameterEnabled("confmap")) + if (!m_Model->HasConfidenceIndex() && GetParameterInt("confmap")) { otbAppLogWARNING("Confidence map requested but the classifier doesn't support it!"); } diff --git a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx index 11e75421ae78dee6bd5e17de99aefa91fe660ee4..05ddb93a0582162c20dbfe1ff3d4d2e009287798 100644 --- a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx @@ -87,12 +87,12 @@ private: AddParameter(ParameterType_String, "cri", "Criterion"); SetParameterDescription("cri", "Dempster Shafer criterion (by default (belief+plausibility)/2)"); MandatoryOff("cri"); - SetParameterString("cri", "((Belief + Plausibility)/2.)", false); + SetParameterString("cri", "((Belief + Plausibility)/2.)"); AddParameter(ParameterType_Float, "thd", "Criterion threshold"); SetParameterDescription("thd", "Criterion threshold (default 0.5)"); MandatoryOff("thd"); - SetParameterFloat("thd",0.5, false); + SetParameterFloat("thd",0.5); AddParameter(ParameterType_OutputVectorData, "out", "Output Vector Data"); SetParameterDescription("out", "Output VectorData containing only the validated samples"); diff --git a/Modules/Applications/AppClassification/include/otbTrainBoost.txx b/Modules/Applications/AppClassification/include/otbTrainBoost.txx index 46cbbbd12560b459c95a3264116ac189b75398fc..f971a2a6294bf42561db2bd799c895877482f254 100644 --- a/Modules/Applications/AppClassification/include/otbTrainBoost.txx +++ b/Modules/Applications/AppClassification/include/otbTrainBoost.txx @@ -61,16 +61,16 @@ namespace Wrapper SetParameterDescription("classifier.boost.t.gentle", "A modified version of the Real Adaboost algorithm, using Newton stepping " "rather than exact optimization at each step."); - SetParameterString("classifier.boost.t", "real", false); + SetParameterString("classifier.boost.t", "real"); SetParameterDescription("classifier.boost.t", "Type of Boosting algorithm."); //Do not expose SplitCriteria //WeakCount AddParameter(ParameterType_Int, "classifier.boost.w", "Weak count"); - SetParameterInt("classifier.boost.w",100, false); + SetParameterInt("classifier.boost.w",100); SetParameterDescription("classifier.boost.w","The number of weak classifiers."); //WeightTrimRate AddParameter(ParameterType_Float, "classifier.boost.r", "Weight Trim Rate"); - SetParameterFloat("classifier.boost.r",0.95, false); + SetParameterFloat("classifier.boost.r",0.95); SetParameterDescription("classifier.boost.r", "A threshold between 0 and 1 used to save computational time. " "Samples with summary weight <= (1 - weight_trim_rate) do not participate in" @@ -78,7 +78,7 @@ namespace Wrapper "functionality."); //MaxDepth : Not sure that this parameter has to be exposed. AddParameter(ParameterType_Int, "classifier.boost.m", "Maximum depth of the tree"); - SetParameterInt("classifier.boost.m",1, false); + SetParameterInt("classifier.boost.m",1); SetParameterDescription("classifier.boost.m","Maximum depth of the tree."); } diff --git a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx index 9803a91a7a8a03f46f9b5bd8443d3d12a112926a..01284b5826247a8f07aaabe429d3bd06034e95ed 100644 --- a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx @@ -40,9 +40,9 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxDepth AddParameter(ParameterType_Int, "classifier.dt.max", "Maximum depth of the tree"); #ifdef OTB_OPENCV_3 - SetParameterInt("classifier.dt.max",10, false); + SetParameterInt("classifier.dt.max",10); #else - SetParameterInt("classifier.dt.max",65535, false); + SetParameterInt("classifier.dt.max",65535); #endif SetParameterDescription("classifier.dt.max", "The training algorithm attempts to split each node while its depth is smaller " @@ -51,14 +51,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //MinSampleCount AddParameter(ParameterType_Int, "classifier.dt.min", "Minimum number of samples in each node"); - SetParameterInt("classifier.dt.min",10, false); + SetParameterInt("classifier.dt.min",10); SetParameterDescription("classifier.dt.min", "If the number of samples in a node is smaller " "than this parameter, then this node will not be split."); //RegressionAccuracy AddParameter(ParameterType_Float, "classifier.dt.ra", "Termination criteria for regression tree"); - SetParameterFloat("classifier.dt.ra",0.01, false); + SetParameterFloat("classifier.dt.ra",0.01); SetParameterDescription("classifier.dt.ra", "If all absolute differences between an estimated value in a node " "and the values of the train samples in this node are smaller than this " @@ -72,7 +72,7 @@ LearningApplicationBase<TInputValue,TOutputValue> AddParameter(ParameterType_Int, "classifier.dt.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a " "suboptimal split"); - SetParameterInt("classifier.dt.cat",10, false); + SetParameterInt("classifier.dt.cat",10); SetParameterDescription("classifier.dt.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a " "suboptimal split."); @@ -81,22 +81,22 @@ LearningApplicationBase<TInputValue,TOutputValue> AddParameter(ParameterType_Int, "classifier.dt.f", "K-fold cross-validations"); #ifdef OTB_OPENCV_3 // disable cross validation by default (crash in opencv 3.2) - SetParameterInt("classifier.dt.f",0, false); + SetParameterInt("classifier.dt.f",0); #else - SetParameterInt("classifier.dt.f",10, false); + SetParameterInt("classifier.dt.f",10); #endif SetParameterDescription("classifier.dt.f", "If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K " "is equal to cv_folds."); //Use1seRule - AddParameter(ParameterType_Empty, "classifier.dt.r", "Set Use1seRule flag to false"); + AddParameter(ParameterType_Bool, "classifier.dt.r", "Set Use1seRule flag to false"); SetParameterDescription("classifier.dt.r", "If true, then a pruning will be harsher. This will make a tree more compact and more " "resistant to the training data noise but a bit less accurate."); //TruncatePrunedTree - AddParameter(ParameterType_Empty, "classifier.dt.t", "Set TruncatePrunedTree flag to false"); + AddParameter(ParameterType_Bool, "classifier.dt.t", "Set TruncatePrunedTree flag to false"); SetParameterDescription("classifier.dt.t", "If true, then pruned branches are physically removed from the tree."); @@ -121,11 +121,11 @@ LearningApplicationBase<TInputValue,TOutputValue> classifier->SetRegressionAccuracy(GetParameterFloat("classifier.dt.ra")); classifier->SetMaxCategories(GetParameterInt("classifier.dt.cat")); classifier->SetCVFolds(GetParameterInt("classifier.dt.f")); - if (IsParameterEnabled("classifier.dt.r")) + if (GetParameterInt("classifier.dt.r")) { classifier->SetUse1seRule(false); } - if (IsParameterEnabled("classifier.dt.t")) + if (GetParameterInt("classifier.dt.t")) { classifier->SetTruncatePrunedTree(false); } diff --git a/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx b/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx index 7f69ac9338011c00f3c11164f3a4a1a362a65c65..30a3fde157d6bc04ca60524373333d088254b549 100644 --- a/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx @@ -52,7 +52,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //WeakCount AddParameter(ParameterType_Int, "classifier.gbt.w", "Number of boosting algorithm iterations"); - SetParameterInt("classifier.gbt.w",200, false); + SetParameterInt("classifier.gbt.w",200); SetParameterDescription( "classifier.gbt.w", "Number \"w\" of boosting algorithm iterations, with w*K being the total number of trees in " @@ -60,20 +60,20 @@ LearningApplicationBase<TInputValue,TOutputValue> //Shrinkage AddParameter(ParameterType_Float, "classifier.gbt.s", "Regularization parameter"); - SetParameterFloat("classifier.gbt.s",0.01, false); + SetParameterFloat("classifier.gbt.s",0.01); SetParameterDescription("classifier.gbt.s", "Regularization parameter."); //SubSamplePortion AddParameter(ParameterType_Float, "classifier.gbt.p", "Portion of the whole training set used for each algorithm iteration"); - SetParameterFloat("classifier.gbt.p",0.8, false); + SetParameterFloat("classifier.gbt.p",0.8); SetParameterDescription( "classifier.gbt.p", "Portion of the whole training set used for each algorithm iteration. The subset is generated randomly."); //MaxDepth AddParameter(ParameterType_Int, "classifier.gbt.max", "Maximum depth of the tree"); - SetParameterInt("classifier.gbt.max",3, false); + SetParameterInt("classifier.gbt.max",3); SetParameterDescription( "classifier.gbt.max", "The training algorithm attempts to split each node while its depth is smaller than the maximum " "possible depth of the tree. The actual depth may be smaller if the other termination criteria are met, and/or " diff --git a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx index a646cea9539fc3c8b6dcc5f013a6996ed7bf2a9d..15d599176a00bace3665bf780ec4ea55ad197b4d 100644 --- a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx @@ -39,11 +39,10 @@ void TrainImagesBase::InitIO() SetParameterDescription( "io.vd", "A list of vector data to select the training samples." ); MandatoryOn( "io.vd" ); - AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); - EnableParameter( "cleanup" ); + AddParameter( ParameterType_Bool, "cleanup", "Temporary files cleaning" ); SetParameterDescription( "cleanup", "If activated, the application will try to clean all temporary files it created" ); - MandatoryOff( "cleanup" ); + SetParameterInt( "cleanup", 1); } void TrainImagesBase::InitSampling() @@ -79,7 +78,7 @@ void TrainImagesBase::InitSampling() 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 ); + SetParameterFloat( "sample.vtr", 0.5); SetMaximumParameterFloatValue( "sample.vtr", 1.0 ); SetMinimumParameterFloatValue( "sample.vtr", 0.0 ); @@ -160,8 +159,8 @@ void TrainImagesBase::ComputePolygonStatistics(FloatVectorImageListType *imageLi for( unsigned int i = 0; i < nbImages; i++ ) { GetInternalApplication( "polystat" )->SetParameterInputImage( "in", imageList->GetNthElement( i ) ); - GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileNames[i], false ); - GetInternalApplication( "polystat" )->SetParameterString( "out", statisticsFileNames[i], false ); + GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileNames[i]); + GetInternalApplication( "polystat" )->SetParameterString( "out", statisticsFileNames[i]); ExecuteInternal( "polystat" ); } } @@ -170,7 +169,7 @@ void TrainImagesBase::ComputePolygonStatistics(FloatVectorImageListType *imageLi TrainImagesBase::SamplingRates TrainImagesBase::ComputeFinalMaximumSamplingRates(bool dedicatedValidation) { SamplingRates rates; - GetInternalApplication( "rates" )->SetParameterString( "mim", "proportional", false ); + GetInternalApplication( "rates" )->SetParameterString( "mim", "proportional"); double vtr = GetParameterFloat( "sample.vtr" ); long mt = GetParameterInt( "sample.mt" ); long mv = GetParameterInt( "sample.mv" ); @@ -224,11 +223,11 @@ void TrainImagesBase::ComputeSamplingRate(const std::vector<std::string> &statis const std::string &ratesFileName, long maximum) { // Sampling rates - GetInternalApplication( "rates" )->SetParameterStringList( "il", statisticsFileNames, false ); - GetInternalApplication( "rates" )->SetParameterString( "out", ratesFileName, false ); + GetInternalApplication( "rates" )->SetParameterStringList( "il", statisticsFileNames); + GetInternalApplication( "rates" )->SetParameterString( "out", ratesFileName); if( GetParameterInt( "sample.bm" ) != 0 ) { - GetInternalApplication( "rates" )->SetParameterString( "strategy", "smallest", false ); + GetInternalApplication( "rates" )->SetParameterString( "strategy", "smallest"); } else { @@ -236,12 +235,12 @@ void TrainImagesBase::ComputeSamplingRate(const std::vector<std::string> &statis { std::ostringstream oss; oss << maximum; - GetInternalApplication( "rates" )->SetParameterString( "strategy", "constant", false ); - GetInternalApplication( "rates" )->SetParameterString( "strategy.constant.nb", oss.str(), false ); + GetInternalApplication( "rates" )->SetParameterString( "strategy", "constant"); + GetInternalApplication( "rates" )->SetParameterString( "strategy.constant.nb", oss.str()); } else { - GetInternalApplication( "rates" )->SetParameterString( "strategy", "all", false ); + GetInternalApplication( "rates" )->SetParameterString( "strategy", "all"); } } ExecuteInternal( "rates" ); @@ -251,9 +250,9 @@ void TrainImagesBase::TrainModel(FloatVectorImageListType *imageList, const std::vector<std::string> &sampleTrainFileNames, const std::vector<std::string> &sampleValidationFileNames) { - GetInternalApplication( "training" )->SetParameterStringList( "io.vd", sampleTrainFileNames, false ); + GetInternalApplication( "training" )->SetParameterStringList( "io.vd", sampleTrainFileNames); if( !sampleValidationFileNames.empty() ) - GetInternalApplication( "training" )->SetParameterStringList( "valid.vd", sampleValidationFileNames, false ); + GetInternalApplication( "training" )->SetParameterStringList( "valid.vd", sampleValidationFileNames); UpdateInternalParameters( "training" ); // set field names @@ -266,7 +265,7 @@ TrainImagesBase::TrainModel(FloatVectorImageListType *imageList, const std::vect oss << i; selectedNames.push_back( "value_" + oss.str() ); } - GetInternalApplication( "training" )->SetParameterStringList( "feat", selectedNames, false ); + GetInternalApplication( "training" )->SetParameterStringList( "feat", selectedNames); ExecuteInternal( "training" ); } @@ -276,38 +275,38 @@ void TrainImagesBase::SelectAndExtractSamples(FloatVectorImageType *image, std:: std::string selectedField) { GetInternalApplication( "select" )->SetParameterInputImage( "in", image ); - GetInternalApplication( "select" )->SetParameterString( "out", sampleFileName, false ); + GetInternalApplication( "select" )->SetParameterString( "out", sampleFileName); // Change the selection strategy based on selected sampling strategy switch( strategy ) { // case GEOMETRIC: -// GetInternalApplication( "select" )->SetParameterString( "sampler", "random", false ); -// GetInternalApplication( "select" )->SetParameterString( "strategy", "percent", false ); +// GetInternalApplication( "select" )->SetParameterString( "sampler", "random"); +// GetInternalApplication( "select" )->SetParameterString( "strategy", "percent"); // GetInternalApplication( "select" )->SetParameterFloat( "strategy.percent.p", -// GetParameterFloat( "sample.percent" ), false ); +// GetParameterFloat( "sample.percent" )); // break; case CLASS: default: - GetInternalApplication( "select" )->SetParameterString( "vec", vectorFileName, false ); - GetInternalApplication( "select" )->SetParameterString( "instats", statisticsFileName, false ); - GetInternalApplication( "select" )->SetParameterString( "sampler", "periodic", false ); + GetInternalApplication( "select" )->SetParameterString( "vec", vectorFileName); + GetInternalApplication( "select" )->SetParameterString( "instats", statisticsFileName); + GetInternalApplication( "select" )->SetParameterString( "sampler", "periodic"); GetInternalApplication( "select" )->SetParameterInt( "sampler.periodic.jitter", 50 ); - GetInternalApplication( "select" )->SetParameterString( "strategy", "byclass", false ); - GetInternalApplication( "select" )->SetParameterString( "strategy.byclass.in", ratesFileName, false ); + GetInternalApplication( "select" )->SetParameterString( "strategy", "byclass"); + GetInternalApplication( "select" )->SetParameterString( "strategy.byclass.in", ratesFileName); break; } // select sample positions ExecuteInternal( "select" ); - GetInternalApplication( "extraction" )->SetParameterString( "vec", sampleFileName, false ); + GetInternalApplication( "extraction" )->SetParameterString( "vec", sampleFileName); UpdateInternalParameters( "extraction" ); if( !selectedField.empty() ) - GetInternalApplication( "extraction" )->SetParameterString( "field", selectedField, false ); + GetInternalApplication( "extraction" )->SetParameterString( "field", selectedField); - GetInternalApplication( "extraction" )->SetParameterString( "outfield", "prefix", false ); - GetInternalApplication( "extraction" )->SetParameterString( "outfield.prefix.name", "value_", false ); + GetInternalApplication( "extraction" )->SetParameterString( "outfield", "prefix"); + GetInternalApplication( "extraction" )->SetParameterString( "outfield.prefix.name", "value_"); // extract sample descriptors ExecuteInternal( "extraction" ); diff --git a/Modules/Applications/AppClassification/include/otbTrainKNN.txx b/Modules/Applications/AppClassification/include/otbTrainKNN.txx index 2ff93632bcd9b399e6d399f16cfe1fa33ed2cc6d..71e02215dbbf94e4b6d014ae89e92f11ac1389fb 100644 --- a/Modules/Applications/AppClassification/include/otbTrainKNN.txx +++ b/Modules/Applications/AppClassification/include/otbTrainKNN.txx @@ -39,7 +39,7 @@ namespace Wrapper //K parameter AddParameter(ParameterType_Int, "classifier.knn.k", "Number of Neighbors"); - SetParameterInt("classifier.knn.k",32, false); + SetParameterInt("classifier.knn.k",32); SetParameterDescription("classifier.knn.k","The number of neighbors to use."); if (this->m_RegressionFlag) diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx index 18b9f4d39a8926abf645647bec30273d2b98e3b5..0e34ad78c40f9e7465f1de7a88e5bef08bfa1fa0 100644 --- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx @@ -54,7 +54,7 @@ namespace Wrapper SetParameterDescription("classifier.libsvm.k.sigmoid", "The kernel is a hyperbolic tangente function of the vectors."); - SetParameterString("classifier.libsvm.k", "linear", false); + SetParameterString("classifier.libsvm.k", "linear"); SetParameterDescription("classifier.libsvm.k", "SVM Kernel Type."); AddParameter(ParameterType_Choice, "classifier.libsvm.m", "SVM Model Type"); SetParameterDescription("classifier.libsvm.m", "Type of SVM formulation."); @@ -67,7 +67,7 @@ namespace Wrapper "multiplier C is used "); AddChoice("classifier.libsvm.m.nusvr", "Nu Support Vector Regression"); - SetParameterString("classifier.libsvm.m", "epssvr", false); + SetParameterString("classifier.libsvm.m", "epssvr"); SetParameterDescription("classifier.libsvm.m.nusvr", "Same as the epsilon regression except that this time the bounded " "parameter nu is used instead of epsilon"); @@ -89,33 +89,32 @@ namespace Wrapper SetParameterDescription("classifier.libsvm.m.oneclass", "All the training data are from the same class, SVM builds a boundary " "that separates the class from the rest of the feature space."); - SetParameterString("classifier.libsvm.m", "csvc", false); + SetParameterString("classifier.libsvm.m", "csvc"); } AddParameter(ParameterType_Float, "classifier.libsvm.c", "Cost parameter C"); - SetParameterFloat("classifier.libsvm.c",1.0, false); + SetParameterFloat("classifier.libsvm.c",1.0); SetParameterDescription("classifier.libsvm.c", "SVM models have a cost parameter C (1 by default) to control the " "trade-off between training errors and forcing rigid margins."); AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Cost parameter Nu"); - SetParameterFloat("classifier.libsvm.nu",0.5, false); + SetParameterFloat("classifier.libsvm.nu",0.5); SetParameterDescription("classifier.libsvm.nu", "Cost parameter Nu, in the range 0..1, the larger the value, " "the smoother the decision."); // It seems that it miss a nu parameter for the nu-SVM use. - AddParameter(ParameterType_Empty, "classifier.libsvm.opt", "Parameters optimization"); - MandatoryOff("classifier.libsvm.opt"); + AddParameter(ParameterType_Bool, "classifier.libsvm.opt", "Parameters optimization"); SetParameterDescription("classifier.libsvm.opt", "SVM parameters optimization flag."); - AddParameter(ParameterType_Empty, "classifier.libsvm.prob", "Probability estimation"); - MandatoryOff("classifier.libsvm.prob"); + + AddParameter(ParameterType_Bool, "classifier.libsvm.prob", "Probability estimation"); SetParameterDescription("classifier.libsvm.prob", "Probability estimation flag."); if (this->m_RegressionFlag) { AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon"); - SetParameterFloat("classifier.libsvm.eps",1e-3, false); + SetParameterFloat("classifier.libsvm.eps",1e-3); SetParameterDescription("classifier.libsvm.eps", "The distance between feature vectors from the training set and " "the fitting hyper-plane must be less than Epsilon. For outliers" @@ -137,14 +136,8 @@ namespace Wrapper libSVMClassifier->SetTargetListSample(trainingLabeledListSample); //SVM Option //TODO : Add other options ? - if (IsParameterEnabled("classifier.libsvm.opt")) - { - libSVMClassifier->SetParameterOptimization(true); - } - if (IsParameterEnabled("classifier.libsvm.prob")) - { - libSVMClassifier->SetDoProbabilityEstimates(true); - } + libSVMClassifier->SetParameterOptimization(GetParameterInt("classifier.libsvm.opt")); + libSVMClassifier->SetDoProbabilityEstimates(GetParameterInt("classifier.libsvm.prob")); libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu")); libSVMClassifier->SetC(GetParameterFloat("classifier.libsvm.c")); diff --git a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx index 4081034a5f0fead34f03f3f0325f0ad6294b5582..33a4930ac4f2458b0aa0153d7f762529b7fa280a 100644 --- a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx +++ b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx @@ -52,7 +52,7 @@ LearningApplicationBase<TInputValue,TOutputValue> "take into account the magnitude of the partial derivative (coordinate " "of the gradient) but only its sign."); - SetParameterString("classifier.ann.t", "reg", false); + SetParameterString("classifier.ann.t", "reg"); SetParameterDescription("classifier.ann.t", "Type of training method for the multilayer perceptron (MLP) neural network."); @@ -73,7 +73,7 @@ LearningApplicationBase<TInputValue,TOutputValue> AddChoice("classifier.ann.f.ident", "Identity function"); AddChoice("classifier.ann.f.sig", "Symmetrical Sigmoid function"); AddChoice("classifier.ann.f.gau", "Gaussian function (Not completely supported)"); - SetParameterString("classifier.ann.f", "sig", false); + SetParameterString("classifier.ann.f", "sig"); SetParameterDescription("classifier.ann.f", "This function determine whether the output of the node is positive or not " "depending on the output of the transfert function."); @@ -81,21 +81,21 @@ LearningApplicationBase<TInputValue,TOutputValue> //Alpha AddParameter(ParameterType_Float, "classifier.ann.a", "Alpha parameter of the activation function"); - SetParameterFloat("classifier.ann.a",1., false); + SetParameterFloat("classifier.ann.a",1.); SetParameterDescription("classifier.ann.a", "Alpha parameter of the activation function (used only with sigmoid and gaussian functions)."); //Beta AddParameter(ParameterType_Float, "classifier.ann.b", "Beta parameter of the activation function"); - SetParameterFloat("classifier.ann.b",1., false); + SetParameterFloat("classifier.ann.b",1.); SetParameterDescription("classifier.ann.b", "Beta parameter of the activation function (used only with sigmoid and gaussian functions)."); //BackPropDWScale AddParameter(ParameterType_Float, "classifier.ann.bpdw", "Strength of the weight gradient term in the BACKPROP method"); - SetParameterFloat("classifier.ann.bpdw",0.1, false); + SetParameterFloat("classifier.ann.bpdw",0.1); SetParameterDescription("classifier.ann.bpdw", "Strength of the weight gradient term in the BACKPROP method. The " "recommended value is about 0.1."); @@ -103,7 +103,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //BackPropMomentScale AddParameter(ParameterType_Float, "classifier.ann.bpms", "Strength of the momentum term (the difference between weights on the 2 previous iterations)"); - SetParameterFloat("classifier.ann.bpms",0.1, false); + SetParameterFloat("classifier.ann.bpms",0.1); SetParameterDescription("classifier.ann.bpms", "Strength of the momentum term (the difference between weights on the 2 previous " "iterations). This parameter provides some inertia to smooth the random " @@ -113,14 +113,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //RegPropDW0 AddParameter(ParameterType_Float, "classifier.ann.rdw", "Initial value Delta_0 of update-values Delta_{ij} in RPROP method"); - SetParameterFloat("classifier.ann.rdw",0.1, false); + SetParameterFloat("classifier.ann.rdw",0.1); SetParameterDescription("classifier.ann.rdw", "Initial value Delta_0 of update-values Delta_{ij} in RPROP method (default = 0.1)."); //RegPropDWMin AddParameter(ParameterType_Float, "classifier.ann.rdwm", "Update-values lower limit Delta_{min} in RPROP method"); - SetParameterFloat("classifier.ann.rdwm",1e-7, false); + SetParameterFloat("classifier.ann.rdwm",1e-7); SetParameterDescription("classifier.ann.rdwm", "Update-values lower limit Delta_{min} in RPROP method. It must be positive " "(default = 1e-7)."); @@ -139,20 +139,20 @@ LearningApplicationBase<TInputValue,TOutputValue> AddChoice("classifier.ann.term.all", "Max. iterations + Epsilon"); SetParameterDescription("classifier.ann.term.all", "Both termination criteria are used. Training stop at the first reached"); - SetParameterString("classifier.ann.term", "all", false); + SetParameterString("classifier.ann.term", "all"); SetParameterDescription("classifier.ann.term", "Termination criteria."); //Epsilon AddParameter(ParameterType_Float, "classifier.ann.eps", "Epsilon value used in the Termination criteria"); - SetParameterFloat("classifier.ann.eps",0.01, false); + SetParameterFloat("classifier.ann.eps",0.01); SetParameterDescription("classifier.ann.eps", "Epsilon value used in the Termination criteria."); //MaxIter AddParameter(ParameterType_Int, "classifier.ann.iter", "Maximum number of iterations used in the Termination criteria"); - SetParameterInt("classifier.ann.iter",1000, false); + SetParameterInt("classifier.ann.iter",1000); SetParameterDescription("classifier.ann.iter", "Maximum number of iterations used in the Termination criteria."); diff --git a/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx b/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx index f557731207aa92509c7f156fcfbdf794ebaf9d03..e19777a6861c793150c652cdb9d695cde874a618 100644 --- a/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx +++ b/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx @@ -39,7 +39,7 @@ LearningApplicationBase<TInputValue,TOutputValue> "See complete documentation here \\url{http://docs.opencv.org/modules/ml/doc/random_trees.html}."); //MaxDepth AddParameter(ParameterType_Int, "classifier.rf.max", "Maximum depth of the tree"); - SetParameterInt("classifier.rf.max",5, false); + SetParameterInt("classifier.rf.max",5); SetParameterDescription( "classifier.rf.max", "The depth of the tree. A low value will likely underfit and conversely a high value will likely overfit. " @@ -47,14 +47,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //MinSampleCount AddParameter(ParameterType_Int, "classifier.rf.min", "Minimum number of samples in each node"); - SetParameterInt("classifier.rf.min",10, false); + SetParameterInt("classifier.rf.min",10); SetParameterDescription( "classifier.rf.min", "If the number of samples in a node is smaller than this parameter, " "then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent."); //RegressionAccuracy AddParameter(ParameterType_Float, "classifier.rf.ra", "Termination Criteria for regression tree"); - SetParameterFloat("classifier.rf.ra",0., false); + SetParameterFloat("classifier.rf.ra",0.); SetParameterDescription("classifier.rf.ra", "If all absolute differences between an estimated value in a node " "and the values of the train samples in this node are smaller than this regression accuracy parameter, " "then the node will not be split."); @@ -66,7 +66,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfCategories AddParameter(ParameterType_Int, "classifier.rf.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split"); - SetParameterInt("classifier.rf.cat",10, false); + SetParameterInt("classifier.rf.cat",10); SetParameterDescription( "classifier.rf.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split."); @@ -78,7 +78,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfVariables AddParameter(ParameterType_Int, "classifier.rf.var", "Size of the randomly selected subset of features at each tree node"); - SetParameterInt("classifier.rf.var",0, false); + SetParameterInt("classifier.rf.var",0); SetParameterDescription( "classifier.rf.var", "The size of the subset of features, randomly selected at each tree node, that are used to find the best split(s). " @@ -87,7 +87,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfTrees AddParameter(ParameterType_Int, "classifier.rf.nbtrees", "Maximum number of trees in the forest"); - SetParameterInt("classifier.rf.nbtrees",100, false); + SetParameterInt("classifier.rf.nbtrees",100); SetParameterDescription( "classifier.rf.nbtrees", "The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. " @@ -97,7 +97,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //ForestAccuracy AddParameter(ParameterType_Float, "classifier.rf.acc", "Sufficient accuracy (OOB error)"); - SetParameterFloat("classifier.rf.acc",0.01, false); + SetParameterFloat("classifier.rf.acc",0.01); SetParameterDescription("classifier.rf.acc","Sufficient accuracy (OOB error)."); diff --git a/Modules/Applications/AppClassification/include/otbTrainSVM.txx b/Modules/Applications/AppClassification/include/otbTrainSVM.txx index ac9524faa26de64a04e4a98b008b101f225cc8ca..ab5138ba33027df907b4d908622250404e2dd1a0 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSVM.txx @@ -42,14 +42,14 @@ namespace Wrapper { AddChoice("classifier.svm.m.epssvr", "Epsilon Support Vector Regression"); AddChoice("classifier.svm.m.nusvr", "Nu Support Vector Regression"); - SetParameterString("classifier.svm.m", "epssvr", false); + SetParameterString("classifier.svm.m", "epssvr"); } else { AddChoice("classifier.svm.m.csvc", "C support vector classification"); AddChoice("classifier.svm.m.nusvc", "Nu support vector classification"); AddChoice("classifier.svm.m.oneclass", "Distribution estimation (One Class SVM)"); - SetParameterString("classifier.svm.m", "csvc", false); + SetParameterString("classifier.svm.m", "csvc"); } AddParameter(ParameterType_Choice, "classifier.svm.k", "SVM Kernel Type"); AddChoice("classifier.svm.k.linear", "Linear"); @@ -57,22 +57,22 @@ namespace Wrapper AddChoice("classifier.svm.k.rbf", "Gaussian radial basis function"); AddChoice("classifier.svm.k.poly", "Polynomial"); AddChoice("classifier.svm.k.sigmoid", "Sigmoid"); - SetParameterString("classifier.svm.k", "linear", false); + SetParameterString("classifier.svm.k", "linear"); SetParameterDescription("classifier.svm.k", "SVM Kernel Type."); AddParameter(ParameterType_Float, "classifier.svm.c", "Cost parameter C"); - SetParameterFloat("classifier.svm.c",1.0, false); + SetParameterFloat("classifier.svm.c",1.0); SetParameterDescription("classifier.svm.c", "SVM models have a cost parameter C (1 by default) to control the trade-off" " between training errors and forcing rigid margins."); AddParameter(ParameterType_Float, "classifier.svm.nu", "Parameter nu of a SVM optimization problem (NU_SVC / ONE_CLASS)"); - SetParameterFloat("classifier.svm.nu",0.0, false); + SetParameterFloat("classifier.svm.nu",0.0); SetParameterDescription("classifier.svm.nu", "Parameter nu of a SVM optimization problem."); if (this->m_RegressionFlag) { AddParameter(ParameterType_Float, "classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR)"); - SetParameterFloat("classifier.svm.p",1.0, false); + SetParameterFloat("classifier.svm.p",1.0); SetParameterDescription("classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR)."); AddParameter(ParameterType_Choice, @@ -87,34 +87,33 @@ namespace Wrapper "Stops when either iteration or epsilon criteria is true"); AddParameter(ParameterType_Float, "classifier.svm.iter", "Maximum iteration"); - SetParameterFloat("classifier.svm.iter",1000, false); + SetParameterFloat("classifier.svm.iter",1000); SetParameterDescription("classifier.svm.iter", "Maximum number of iterations (corresponds to the termination criteria 'iter')."); AddParameter(ParameterType_Float, "classifier.svm.eps", "Epsilon accuracy threshold"); - SetParameterFloat("classifier.svm.eps",FLT_EPSILON, false); + SetParameterFloat("classifier.svm.eps",FLT_EPSILON); SetParameterDescription("classifier.svm.eps", "Epsilon accuracy (corresponds to the termination criteria 'eps')."); } AddParameter(ParameterType_Float, "classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID)"); - SetParameterFloat("classifier.svm.coef0",0.0, false); + SetParameterFloat("classifier.svm.coef0",0.0); SetParameterDescription("classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID)."); AddParameter(ParameterType_Float, "classifier.svm.gamma", "Parameter gamma of a kernel function (POLY / RBF / SIGMOID)"); - SetParameterFloat("classifier.svm.gamma",1.0, false); + SetParameterFloat("classifier.svm.gamma",1.0); SetParameterDescription("classifier.svm.gamma", "Parameter gamma of a kernel function (POLY / RBF / SIGMOID)."); AddParameter(ParameterType_Float, "classifier.svm.degree", "Parameter degree of a kernel function (POLY)"); - SetParameterFloat("classifier.svm.degree",1.0, false); + SetParameterFloat("classifier.svm.degree",1.0); SetParameterDescription("classifier.svm.degree", "Parameter degree of a kernel function (POLY)."); - AddParameter(ParameterType_Empty, "classifier.svm.opt", + AddParameter(ParameterType_Bool, "classifier.svm.opt", "Parameters optimization"); - MandatoryOff("classifier.svm.opt"); SetParameterDescription("classifier.svm.opt", "SVM parameters optimization flag.\n" "-If set to True, then the optimal SVM parameters will be estimated. " "Parameters are considered optimal by OpenCV when the cross-validation estimate of " @@ -229,23 +228,20 @@ namespace Wrapper SVMClassifier->SetCoef0(GetParameterFloat("classifier.svm.coef0")); SVMClassifier->SetGamma(GetParameterFloat("classifier.svm.gamma")); SVMClassifier->SetDegree(GetParameterFloat("classifier.svm.degree")); - if (IsParameterEnabled("classifier.svm.opt")) - { - SVMClassifier->SetParameterOptimization(true); - } + SVMClassifier->SetParameterOptimization(GetParameterInt("classifier.svm.opt")); SVMClassifier->Train(); SVMClassifier->Save(modelPath); // Update the displayed parameters in the GUI after the training process, for further use of them - SetParameterFloat("classifier.svm.c",static_cast<float> (SVMClassifier->GetOutputC()), false); - SetParameterFloat("classifier.svm.nu",static_cast<float> (SVMClassifier->GetOutputNu()), false); + SetParameterFloat("classifier.svm.c",static_cast<float> (SVMClassifier->GetOutputC())); + SetParameterFloat("classifier.svm.nu",static_cast<float> (SVMClassifier->GetOutputNu())); if (this->m_RegressionFlag) { - SetParameterFloat("classifier.svm.p",static_cast<float> (SVMClassifier->GetOutputP()), false); + SetParameterFloat("classifier.svm.p",static_cast<float> (SVMClassifier->GetOutputP())); } - SetParameterFloat("classifier.svm.coef0",static_cast<float> (SVMClassifier->GetOutputCoef0()), false); - SetParameterFloat("classifier.svm.gamma",static_cast<float> (SVMClassifier->GetOutputGamma()), false); - SetParameterFloat("classifier.svm.degree",static_cast<float> (SVMClassifier->GetOutputDegree()), false); + SetParameterFloat("classifier.svm.coef0",static_cast<float> (SVMClassifier->GetOutputCoef0())); + SetParameterFloat("classifier.svm.gamma",static_cast<float> (SVMClassifier->GetOutputGamma())); + SetParameterFloat("classifier.svm.degree",static_cast<float> (SVMClassifier->GetOutputDegree())); } } //end namespace wrapper diff --git a/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx b/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx index f2c2f97dc24bc77d798e533eadb09ef9354298d0..fa7ef6646ac634a1dca47dbc5741743ad201ccee 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx @@ -43,7 +43,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfTrees AddParameter(ParameterType_Int, "classifier.sharkrf.nbtrees", "Maximum number of trees in the forest"); - SetParameterInt("classifier.sharkrf.nbtrees",100, false); + SetParameterInt("classifier.sharkrf.nbtrees",100); SetParameterDescription( "classifier.sharkrf.nbtrees", "The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. " @@ -53,7 +53,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //NodeSize AddParameter(ParameterType_Int, "classifier.sharkrf.nodesize", "Min size of the node for a split"); - SetParameterInt("classifier.sharkrf.nodesize",25, false); + SetParameterInt("classifier.sharkrf.nodesize",25); SetParameterDescription( "classifier.sharkrf.nodesize", "If the number of samples in a node is smaller than this parameter, " @@ -61,7 +61,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MTry AddParameter(ParameterType_Int, "classifier.sharkrf.mtry", "Number of features tested at each node"); - SetParameterInt("classifier.sharkrf.mtry",0, false); + SetParameterInt("classifier.sharkrf.mtry",0); SetParameterDescription( "classifier.sharkrf.mtry", "The number of features (variables) which will be tested at each node in " @@ -71,7 +71,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //OOB Ratio AddParameter(ParameterType_Float, "classifier.sharkrf.oobr", "Out of bound ratio"); - SetParameterFloat("classifier.sharkrf.oobr",0.66, false); + SetParameterFloat("classifier.sharkrf.oobr",0.66); SetParameterDescription("classifier.sharkrf.oobr", "Set the fraction of the original training dataset to use as the out of bag sample." "A good default value is 0.66. "); diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx index 2c3575c2ead20381438f9f66d5cd9c65c1723132..453db3f3f02c29a23533ef26db67fb71d8cb6411 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx @@ -91,10 +91,9 @@ void TrainVectorBase::DoInit() "The contingency table is output when we unsupervised algorithms is used otherwise the confusion matrix is output." ); MandatoryOff( "io.confmatout" ); - AddParameter(ParameterType_Empty, "v", "Verbose mode"); - EnableParameter("v"); + AddParameter(ParameterType_Bool, "v", "Verbose mode"); SetParameterDescription("v", "Verbose mode, display the contingency table result."); - MandatoryOff("v"); + SetParameterInt("v", 1); // Doc example parameter settings SetDocExampleParameterValue( "io.vd", "vectorData.shp" ); diff --git a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx index 073e53727f6b194b27e49887c4cf8c70469c537f..04cf50df4d626be84da6288cdd740e9b2f10db55 100644 --- a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx +++ b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx @@ -135,10 +135,8 @@ private: SetMinimumParameterFloatValue("threshold",0.0); SetDefaultParameterFloat("threshold",0.6); - AddParameter(ParameterType_Empty,"backmatching","Use back-matching to filter matches."); + AddParameter(ParameterType_Bool,"backmatching","Use back-matching to filter matches."); SetParameterDescription("backmatching","If set to true, matches should be consistent in both ways."); - MandatoryOff("backmatching"); - DisableParameter("backmatching"); AddParameter(ParameterType_Choice,"mode","Keypoints search mode"); @@ -177,10 +175,10 @@ private: SetParameterDescription("precision","Estimated precision of the colocalisation function in pixels"); SetDefaultParameterFloat("precision",0.); - AddParameter(ParameterType_Empty,"mfilter","Filter points according to geographical or sensor based colocalisation"); + AddParameter(ParameterType_Bool,"mfilter","Filter points according to geographical or sensor based colocalisation"); SetParameterDescription("mfilter","If enabled, this option allows one to filter matches according to colocalisation from sensor or geographical information, using the given tolerancy expressed in pixels"); - AddParameter(ParameterType_Empty,"2wgs84","If enabled, points from second image will be exported in WGS84"); + AddParameter(ParameterType_Bool,"2wgs84","If enabled, points from second image will be exported in WGS84"); // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); @@ -251,7 +249,7 @@ private: matchingFilter->SetInput1(surf1->GetOutput()); matchingFilter->SetInput2(surf2->GetOutput()); matchingFilter->SetDistanceThreshold(GetParameterFloat("threshold")); - matchingFilter->SetUseBackMatching(IsParameterEnabled("backmatching")); + matchingFilter->SetUseBackMatching(GetParameterInt("backmatching")); } try @@ -276,7 +274,7 @@ private: bool filtered = false; - if(IsParameterEnabled("mfilter")) + if(GetParameterInt("mfilter")) { pprime1 = rsTransform->TransformPoint(point1); error = vcl_sqrt((point2[0]-pprime1[0])*(point2[0]-pprime1[0])+(point2[1]-pprime1[1])*(point2[1]-pprime1[1])); @@ -289,7 +287,7 @@ private: if(!filtered) { - if(IsParameterEnabled("2wgs84")) + if(GetParameterInt("2wgs84")) { pprime2 = rsTransform2ToWGS84->TransformPoint(point2); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx index 686b78bb4cad81a332c249358998b59523fabdc6..d783a3df7535f9f2848ab50fe55867c30a4610ea 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx @@ -164,9 +164,8 @@ private: MandatoryOff("nbcomp"); SetMinimumParameterIntValue("nbcomp", 0); - AddParameter(ParameterType_Empty, "normalize", "Normalize."); + AddParameter(ParameterType_Bool, "normalize", "Normalize."); SetParameterDescription("normalize", "center AND reduce data before Dimensionality reduction."); - MandatoryOff("normalize"); AddParameter(ParameterType_OutputFilename, "outmatrix", "Transformation matrix output (text format)"); SetParameterDescription("outmatrix", "Filename to store the transformation matrix (csv format)"); @@ -196,7 +195,7 @@ private: unsigned int nbComp = static_cast<unsigned int> (GetParameterInt("nbcomp")); if (nbComp > nbComponents) { - SetParameterInt("nbcomp",nbComponents, false); + SetParameterInt("nbcomp",nbComponents); otbAppLogINFO( << "number of selected components can't exceed image dimension : "<<nbComponents ); } @@ -206,14 +205,14 @@ private: if (this->GetParameterString("outinv").size()!= 0) { otbAppLogWARNING(<<"This application only provides the forward transform for the MAF method."); - this->SetParameterString("outinv", "", false); + this->SetParameterString("outinv", ""); } this->DisableParameter("outinv"); if (this->GetParameterString("outmatrix").size()!= 0) { otbAppLogWARNING(<<"No transformation matrix available for MAF method."); - this->SetParameterString("outmatrix", "", false); + this->SetParameterString("outmatrix", ""); } this->DisableParameter("outmatrix"); @@ -225,7 +224,7 @@ private: unsigned int nbComp = static_cast<unsigned int> (GetParameterInt("nbcomp")); if ((nbComp != 0) && (nbComp != nbComponents)) { - SetParameterInt("nbcomp",nbComponents, false); + SetParameterInt("nbcomp",nbComponents); otbAppLogINFO( << "all components are kept when using MAF filter method."); } @@ -237,7 +236,7 @@ private: // Get Parameters int nbComp = GetParameterInt("nbcomp"); - bool normalize = IsParameterEnabled("normalize"); + bool normalize = GetParameterInt("normalize"); bool rescale = IsParameterEnabled("rescale"); bool invTransform = HasValue("outinv") && IsParameterEnabled("outinv"); diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index c853f4863b75e799d10a1199098cffae48640792..e66c5a35fc92a4c7a129b0ddc5c565208e5ab6af 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -134,7 +134,7 @@ private: AddChoice("mode.fft", "FFT transform"); SetParameterDescription("mode.fft", "FFT transform"); - AddParameter(ParameterType_Empty, "mode.fft.shift", "Shift fft transform"); + AddParameter(ParameterType_Bool, "mode.fft.shift", "Shift fft transform"); SetParameterDescription("mode.fft.shift", "Shift transform of fft filter"); AddChoice("mode.wavelet", "Wavelet"); @@ -152,8 +152,8 @@ private: AddChoice("mode.wavelet.form.sym8", "SYMLET8"); // Default values for mode - SetParameterString("mode", "wavelet", false); - SetParameterString("mode.wavelet.form", "haar", false); + SetParameterString("mode", "wavelet"); + SetParameterString("mode.wavelet.form", "haar"); AddParameter(ParameterType_Choice,"direction", "Direction"); AddChoice("direction.forward", "Forward"); @@ -263,7 +263,7 @@ private: else { // fft ttransform - bool shift = IsParameterEnabled( "mode.fft.shift"); + bool shift = GetParameterInt( "mode.fft.shift"); typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType; if (dir == 0 ) diff --git a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx index 45bc66c51d3562a5850bf83c269f8102e87828e0..588e8e1ff6af8a3497495c6962fd316147fb1888 100644 --- a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx +++ b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx @@ -85,11 +85,10 @@ private: // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); - AddParameter(ParameterType_Empty, "norescale", "No rescaling in [0, 255]"); + AddParameter(ParameterType_Bool, "norescale", "No rescaling in [0, 255]"); SetParameterDescription("norescale", "By default, the input image amplitude is rescaled between [0,255]." " Turn on this parameter to skip rescaling"); - MandatoryOff("norescale"); AddRAMParameter(); @@ -132,7 +131,7 @@ private: = ShiftScaleImageFilterType::New(); // Default behavior is to do the rescaling - if ( !IsParameterEnabled("norescale") ) + if ( !GetParameterInt("norescale") ) { stats->SetInput(amplitudeConverter->GetOutput()); stats->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index 3c55bf6efaa3da250f6c0286c1dc1f7cb6e69045..0ec0c5628635b56bc7cdf7555db14ede8839c2fc 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -229,7 +229,7 @@ private: SetParameterDescription("minmax.auto" , "Minimum and maximum value will " "be computed on the image (nodata value won't be taken " "into account) . Each band will have a minimum and a maximum."); - AddParameter(ParameterType_Empty, "minmax.auto.global", "Global"); + AddParameter(ParameterType_Bool, "minmax.auto.global", "Global"); SetParameterDescription("minmax.auto.global" , "Automatic" "Min/max computation will result in the same minimum and maximum for " "all the bands."); @@ -488,7 +488,7 @@ private: if ( m_MinMaxMode == "auto" ) { oss << "automatic"; - if ( IsParameterEnabled( "minmax.auto.global" ) ) + if ( GetParameterInt( "minmax.auto.global" ) ) { oss << " and global"; } @@ -584,7 +584,7 @@ private: statFilter->Update(); min = statFilter->GetMinimum(); max = statFilter->GetMaximum(); - if ( IsParameterEnabled("minmax.auto.global") ) + if ( GetParameterInt("minmax.auto.global") ) { float temp(min[0]); for ( unsigned int i = 1 ; i < min.GetSize() ; i++ ) @@ -602,7 +602,7 @@ private: } std::ostringstream oss; oss<<"Minimum and maximum are for each channel : "; - if ( IsParameterEnabled("minmax.auto.global") || + if ( GetParameterInt("minmax.auto.global") || m_MinMaxMode == "manuel" ) { oss<<std::endl<<min[0]<<" and "<<max[0]; diff --git a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx index a31dc933881f65e3e50618d151f880fc87c90e9c..5f93a6b87183e62b5d40581f00d1a918b7794b0d 100644 --- a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx +++ b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx @@ -116,7 +116,7 @@ private: SetDefaultParameterInt( "type.anidif.nbiter" , 10 ); SetDefaultParameterInt( "type.anidif.conductance" , 1. ); - SetParameterString( "type" , "anidif" , false ); + SetParameterString( "type" , "anidif"); // Doc example parameter settings SetExampleComment( "Image smoothing using a mean filter." , 0 ); diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx index 8d510460a6892d3a64124625e3288b8d107a476e..3a5032af1f3a37fbda3d8a534a832dff8b31e63a 100644 --- a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx @@ -144,7 +144,7 @@ private: AddChoice("ua.mdmdnmf", "MDMDNMF"); SetParameterDescription("ua.mdmdnmf", "Minimum Dispersion Constrained Non Negative Matrix Factorization"); - SetParameterString("ua", "ucls", false); + SetParameterString("ua", "ucls"); // Doc example parameter settings SetDocExampleParameterValue("in", "cupriteSubHsi.tif"); SetDocExampleParameterValue("ie", "cupriteEndmembers.tif"); diff --git a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx index c3b04df6a957230444db0dfb6a5c1eb8f3961587..1dc286bb9cf35ea88dfc8f8da5402a0780aaad36 100644 --- a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx @@ -80,7 +80,7 @@ private: AddParameter(ParameterType_Int, "ne", "Number of endmembers"); SetParameterDescription("ne","The number of endmembers to extract from the hyperspectral image."); - SetParameterInt("ne",1, false); + SetParameterInt("ne",1); MandatoryOn("ne"); AddParameter(ParameterType_OutputImage, "outendm", "Output Endmembers"); diff --git a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx index ad8c68b614ed9b23f12182729964cabaae40f104..d68776716981ea94e1b691020bdbcd3d243595c2 100644 --- a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx +++ b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx @@ -346,11 +346,11 @@ private: AddParameter(ParameterType_Float,"method.continuous.min","Mapping range lower value"); SetParameterDescription("method.continuous.min","Set the lower input value of the mapping range."); - SetParameterFloat("method.continuous.min",0., false); + SetParameterFloat("method.continuous.min",0.); AddParameter(ParameterType_Float,"method.continuous.max","Mapping range higher value"); SetParameterDescription("method.continuous.max","Set the higher input value of the mapping range."); - SetParameterFloat("method.continuous.max",255., false); + SetParameterFloat("method.continuous.max",255.); // Optimal LUT AddChoice("method.optimal","Compute an optimized look-up table"); @@ -359,7 +359,7 @@ private: "[color to label] Searching all the colors present in the image to compute a continuous label list"); AddParameter(ParameterType_Int,"method.optimal.background", "Background label"); SetParameterDescription("method.optimal.background","Value of the background label"); - SetParameterInt("method.optimal.background",0, false); + SetParameterInt("method.optimal.background",0); SetMinimumParameterIntValue("method.optimal.background", 0); SetMaximumParameterIntValue("method.optimal.background", 255); @@ -371,18 +371,18 @@ private: AddParameter(ParameterType_Float, "method.image.nodatavalue", "NoData value"); SetParameterDescription("method.image.nodatavalue","NoData value for each channel of the support image, which will not be handled in the LUT estimation. If NOT checked, ALL the pixel values of the support image will be handled in the LUT estimation."); MandatoryOff("method.image.nodatavalue"); - SetParameterFloat("method.image.nodatavalue",0, false); + SetParameterFloat("method.image.nodatavalue",0); DisableParameter("method.image.nodatavalue"); AddParameter(ParameterType_Int, "method.image.low", "lower quantile"); SetParameterDescription("method.image.low","lower quantile for image normalization"); MandatoryOff("method.image.low"); - SetParameterInt("method.image.low",2, false); + SetParameterInt("method.image.low",2); SetMinimumParameterIntValue("method.image.low", 0); SetMaximumParameterIntValue("method.image.low", 100); AddParameter(ParameterType_Int, "method.image.up", "upper quantile"); SetParameterDescription("method.image.up","upper quantile for image normalization"); MandatoryOff("method.image.up"); - SetParameterInt("method.image.up",2, false); + SetParameterInt("method.image.up",2); SetMinimumParameterIntValue("method.image.up", 0); SetMaximumParameterIntValue("method.image.up", 100); @@ -406,7 +406,7 @@ private: if (GetParameterInt("method")==1 || GetParameterInt("method")==3) { otbAppLogWARNING("Override method : use optimal"); - SetParameterInt("method",2, false); + SetParameterInt("method",2); } } } diff --git a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx index 2d0d54c83c8e1297ebcbfba5206cf88a231f2bc0..d376e56b5c0172dd5039fe2b35296025c5bfc6ae 100644 --- a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx @@ -225,10 +225,10 @@ private: otbAppLogINFO( << "PSNR: " << m_CompareFilter->GetPSNR() ); otbAppLogINFO( << "Number of Pixel different: " << m_CompareFilter->GetDiffCount() ); - SetParameterFloat( "mse",m_CompareFilter->GetMSE() , false); - SetParameterFloat( "mae",m_CompareFilter->GetMAE() , false); - SetParameterFloat( "psnr",m_CompareFilter->GetPSNR() , false); - SetParameterFloat( "count",m_CompareFilter->GetDiffCount() , false); + SetParameterFloat( "mse",m_CompareFilter->GetMSE()); + SetParameterFloat( "mae",m_CompareFilter->GetMAE()); + SetParameterFloat( "psnr",m_CompareFilter->GetPSNR()); + SetParameterFloat( "count",m_CompareFilter->GetDiffCount()); } diff --git a/Modules/Applications/AppImageUtils/app/otbConvert.cxx b/Modules/Applications/AppImageUtils/app/otbConvert.cxx index 621d48adb330f544d8b7afb1ec7bd09aee43001b..2a553a76803cb3b682adfdd8247e8fe05afe2e21 100644 --- a/Modules/Applications/AppImageUtils/app/otbConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConvert.cxx @@ -120,7 +120,7 @@ private: AddChoice("type.none", "None"); AddChoice("type.linear", "Linear"); AddChoice("type.log2", "Log2"); - SetParameterString("type", "none", false); + SetParameterString("type", "none"); AddParameter(ParameterType_Float,"type.linear.gamma","Gamma correction factor"); SetParameterDescription("type.linear.gamma","Gamma correction factor"); diff --git a/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx b/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx index fa8b76c501ec66ee5672ce6a19efd8128ac8f5c7..28d51f406ee07f1cce78c5616864bd8e6bab4b8d 100644 --- a/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx @@ -124,7 +124,7 @@ private: SetParameterDescription("type", "Transfer function for the rescaling"); AddChoice("type.linear", "Linear"); AddChoice("type.log2", "Log2"); - SetParameterString("type", "linear", false); + SetParameterString("type", "linear"); AddParameter(ParameterType_Float,"type.linear.gamma", "Gamma correction factor"); diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index bd6a8d1583cf4b54dd0ebc441108000735a943ec..6bbd121c894926d7c97a5b469f32638e58dff5d6 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -267,8 +267,8 @@ private: // Update the sizes only if the user has not defined a size if (!HasUserValue("sizex") && !HasUserValue("sizey") ) { - SetParameterInt("sizex",largestRegion.GetSize()[0], false); - SetParameterInt("sizey",largestRegion.GetSize()[1], false); + SetParameterInt("sizex",largestRegion.GetSize()[0]); + SetParameterInt("sizey",largestRegion.GetSize()[1]); // Compute extent parameter with default sizex and sizey if ( GetParameterString( "mode" ) == "extent" && userExtent ) @@ -316,8 +316,8 @@ private: if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again - SetParameterInt("startx",0, false); - SetParameterInt("starty",0, false); + SetParameterInt("startx",0); + SetParameterInt("starty",0); this->CropRegionOfInterest(); } @@ -390,10 +390,10 @@ private: inImage->UpdateOutputInformation(); if (region.Crop(inImage->GetLargestPossibleRegion())) { - SetParameterInt("sizex",region.GetSize(0), HasUserValue("sizex")); - SetParameterInt("sizey",region.GetSize(1), HasUserValue("sizey")); - SetParameterInt("startx",region.GetIndex(0), HasUserValue("startx")); - SetParameterInt("starty",region.GetIndex(1), HasUserValue("starty")); + SetParameterInt("sizex",region.GetSize(0)); + SetParameterInt("sizey",region.GetSize(1)); + SetParameterInt("startx",region.GetIndex(0)); + SetParameterInt("starty",region.GetIndex(1)); return true; } } @@ -409,15 +409,15 @@ private: if (GetParameterString( "mode.extent.unit" ) == "pxl" ) { pixelValue = std::round( GetParameterFloat( "mode.extent.ulx" ) ); - SetParameterInt( "startx", pixelValue , true ); + SetParameterInt( "startx", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.lrx" ) \ - pixelValue ) + 1 ; - SetParameterInt( "sizex", pixelValue , true ); + SetParameterInt( "sizex", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.uly" ) ); - SetParameterInt( "starty", pixelValue , true ); + SetParameterInt( "starty", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.lry" ) \ - pixelValue ) + 1 ; - SetParameterInt( "sizey", pixelValue , true ); + SetParameterInt( "sizey", pixelValue); } else if( GetParameterString( "mode.extent.unit" ) == "phy" ) { @@ -432,11 +432,11 @@ private: inImage->TransformPhysicalPointToIndex(ulp,uli); inImage->TransformPhysicalPointToIndex(lrp,lri); - SetParameterInt( "startx", uli[0] , true ); - SetParameterInt( "starty", uli[1] , true ); + SetParameterInt( "startx", uli[0]); + SetParameterInt( "starty", uli[1]); - SetParameterInt( "sizex", lri[0] - uli[0] + 1, true ); - SetParameterInt( "sizey", lri[1] - uli[1] + 1, true ); + SetParameterInt( "sizex", lri[0] - uli[0] + 1); + SetParameterInt( "sizey", lri[1] - uli[1] + 1); } else if( GetParameterString( "mode.extent.unit" ) == "lonlat" ) @@ -458,11 +458,11 @@ private: inImage->TransformPhysicalPointToIndex(ulp_out,uli_out); inImage->TransformPhysicalPointToIndex(lrp_out,lri_out); - SetParameterInt( "startx", uli_out[0] , true ); - SetParameterInt( "starty", uli_out[1] , true ); + SetParameterInt( "startx", uli_out[0]); + SetParameterInt( "starty", uli_out[1]); - SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1, true ); - SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1, true ); + SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1); + SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1); } this->CropRegionOfInterest(); } @@ -477,22 +477,22 @@ private: lri[ 1 ] = largestRegion.GetSize()[1]; if ( GetParameterString( "mode.extent.unit" ) == "pxl" ) { - SetParameterFloat("mode.extent.ulx", uli[0] , false); - SetParameterFloat("mode.extent.uly", uli[1] , false); - SetParameterFloat("mode.extent.lrx", lri[0] , false); - SetParameterFloat("mode.extent.lry", lri[1] , false); + SetParameterFloat("mode.extent.ulx", uli[0]); + SetParameterFloat("mode.extent.uly", uli[1]); + SetParameterFloat("mode.extent.lrx", lri[0]); + SetParameterFloat("mode.extent.lry", lri[1]); } else if ( GetParameterString( "mode.extent.unit" ) == "phy" ) { itk::Point<float, 2> ulp, lrp; input->TransformIndexToPhysicalPoint(uli,ulp); - SetParameterFloat("mode.extent.ulx",ulp[0], false); - SetParameterFloat("mode.extent.uly",ulp[1], false); + SetParameterFloat("mode.extent.ulx",ulp[0]); + SetParameterFloat("mode.extent.uly",ulp[1]); input->TransformIndexToPhysicalPoint(lri,lrp); - SetParameterFloat("mode.extent.lrx",lrp[0], false); - SetParameterFloat("mode.extent.lry",lrp[1], false); + SetParameterFloat("mode.extent.lrx",lrp[0]); + SetParameterFloat("mode.extent.lry",lrp[1]); } else if ( GetParameterString( "mode.extent.unit" ) == "lonlat" ) { @@ -503,13 +503,13 @@ private: itk::Point<float, 2> ulp_in, lrp_in , ulp_out , lrp_out; input->TransformIndexToPhysicalPoint(uli,ulp_in); ulp_out = rsTransform->TransformPoint( ulp_in ); - SetParameterFloat( "mode.extent.ulx" , ulp_out[ 0 ] , false ); - SetParameterFloat( "mode.extent.uly" , ulp_out[ 1 ] , false ); + SetParameterFloat( "mode.extent.ulx" , ulp_out[ 0 ]); + SetParameterFloat( "mode.extent.uly" , ulp_out[ 1 ]); input->TransformIndexToPhysicalPoint( lri , lrp_in ); lrp_out = rsTransform->TransformPoint( lrp_in ); - SetParameterFloat( "mode.extent.lrx" , lrp_out[ 0 ] , false ); - SetParameterFloat( "mode.extent.lry" , lrp_out[ 1 ] , false ); + SetParameterFloat( "mode.extent.lrx" , lrp_out[ 0 ]); + SetParameterFloat( "mode.extent.lry" , lrp_out[ 1 ]); } } @@ -524,8 +524,8 @@ private: if ( GetParameterString( "mode.radius.unitr" ) == "pxl" ) { pixelValue = std::floor( 2 * GetParameterFloat( "mode.radius.r" ) ) + 1; - SetParameterInt( "sizey", pixelValue , true ); - SetParameterInt( "sizex", pixelValue , true ); + SetParameterInt( "sizey", pixelValue); + SetParameterInt( "sizex", pixelValue); } if ( GetParameterString( "mode.radius.unitr" ) == "phy" ) { @@ -564,8 +564,8 @@ private: { pixelValue = maxR; } - SetParameterInt( "sizey", 2 * pixelValue + 1 , true ); - SetParameterInt( "sizex", 2 * pixelValue + 1 , true ); + SetParameterInt( "sizey", 2 * pixelValue + 1); + SetParameterInt( "sizex", 2 * pixelValue + 1); } } @@ -579,9 +579,9 @@ private: if ( GetParameterString( "mode.radius.unitc" ) == "pxl" && size ) { pixelValue = std::round(GetParameterFloat( "mode.radius.cx" )); - SetParameterInt( "startx", pixelValue - radiusxi , true ); + SetParameterInt( "startx", pixelValue - radiusxi); pixelValue = std::round(GetParameterFloat( "mode.radius.cy" )); - SetParameterInt( "starty", pixelValue - radiusyi , true ); + SetParameterInt( "starty", pixelValue - radiusyi); } if ( GetParameterString( "mode.radius.unitc" ) == "phy" && size ) { @@ -593,8 +593,8 @@ private: bool isIn = inImage->TransformPhysicalPointToIndex( centerp , centeri ); if ( isIn ) { - SetParameterInt( "startx", centeri[0] - radiusxi , true ); - SetParameterInt( "starty", centeri[1] - radiusyi , true ); + SetParameterInt( "startx", centeri[0] - radiusxi); + SetParameterInt( "starty", centeri[1] - radiusyi); } } if ( GetParameterString( "mode.radius.unitc" ) == "lonlat" && size ) @@ -613,8 +613,8 @@ private: centeri_out ); if ( isIn ) { - SetParameterInt( "startx", centeri_out[0] - radiusxi , true ); - SetParameterInt( "starty", centeri_out[1] - radiusyi , true ); + SetParameterInt( "startx", centeri_out[0] - radiusxi); + SetParameterInt( "starty", centeri_out[1] - radiusyi); } } } @@ -636,7 +636,7 @@ private: if ( GetParameterString("mode.radius.unitr") == "pxl" ) { int rad = std::min( centeri[ 0 ], centeri[ 1 ] ); - SetParameterFloat( "mode.radius.r" , rad , false ); + SetParameterFloat( "mode.radius.r" , rad); } if ( GetParameterString("mode.radius.unitr") == "phy" ) { @@ -645,19 +645,19 @@ private: input->TransformIndexToPhysicalPoint(helpRxi,helpRxp); input->TransformIndexToPhysicalPoint(helpRyi,helpRyp); float rad = std::min( helpRxp[0] - helpRyp[0] , helpRyp[1] - helpRxp[1] ); - SetParameterFloat( "mode.radius.r" , rad , false ); + SetParameterFloat( "mode.radius.r" , rad); } if ( GetParameterString("mode.radius.unitc") == "pxl" ) { - SetParameterFloat( "mode.radius.cx" , centeri[0] , false ); - SetParameterFloat( "mode.radius.cy" , centeri[1] , false) ; + SetParameterFloat( "mode.radius.cx" , centeri[0]); + SetParameterFloat( "mode.radius.cy" , centeri[1]) ; } if ( GetParameterString("mode.radius.unitc") == "phy" ) { itk::Point<float, 2> centerp , helpRp; input->TransformIndexToPhysicalPoint(centeri,centerp); - SetParameterFloat( "mode.radius.cx" , centerp[0] , false ); - SetParameterFloat( "mode.radius.cy" , centerp[1] , false) ; + SetParameterFloat( "mode.radius.cx" , centerp[0]); + SetParameterFloat( "mode.radius.cy" , centerp[1]) ; } if ( GetParameterString("mode.radius.unitc") == "lonlat" ) { @@ -668,8 +668,8 @@ private: itk::Point<float, 2> centerp_in, centerp_out; input->TransformIndexToPhysicalPoint(centeri,centerp_in); centerp_out = rsTransform->TransformPoint( centerp_in ); - SetParameterFloat( "mode.radius.cx" , centerp_out[ 0 ] , false ); - SetParameterFloat( "mode.radius.cy" , centerp_out[ 1 ] , false ); + SetParameterFloat( "mode.radius.cx" , centerp_out[ 0 ]); + SetParameterFloat( "mode.radius.cy" , centerp_out[ 1 ]); } } @@ -755,10 +755,10 @@ private: lri[1] = std::max( std::max( uli_out[1] , uri_out[1] ) , std::max( lli_out[1] , lri_out[1] ) ); - SetParameterInt( "startx", uli[0] , false ); - SetParameterInt( "starty", uli[1] , false ); - SetParameterInt( "sizex", lri[0] - uli[0] , false ); - SetParameterInt( "sizey", lri[1] - uli[1] , false ); + SetParameterInt( "startx", uli[0]); + SetParameterInt( "starty", uli[1]); + SetParameterInt( "sizex", lri[0] - uli[0]); + SetParameterInt( "sizey", lri[1] - uli[1]); } } else if( HasValue( "mode.fit.im" ) && GetParameterString( "mode" ) == "fit" ) diff --git a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx index 439ba055904d6e1a3c8c5e72e367d2a27cc73771..8f0b43cfece666f796756d4b38fbf934783dc0d9 100644 --- a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx +++ b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx @@ -79,10 +79,8 @@ private: AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image"); - AddParameter(ParameterType_Empty,"usenan", "Consider NaN as no-data"); + AddParameter(ParameterType_Bool,"usenan", "Consider NaN as no-data"); SetParameterDescription("usenan","If active, the application will consider NaN as no-data values as well"); - MandatoryOff("usenan"); - DisableParameter("usenan"); AddParameter(ParameterType_Choice,"mode","No-data handling mode"); SetParameterDescription("mode","Allows choosing between different no-data handling options"); @@ -112,7 +110,7 @@ private: SetParameterDescription("mode.apply.ndval","No Data value used according to the mask image"); SetDefaultParameterFloat("mode.apply.ndval", 0.0); - SetParameterString("mode","buildmask", false); + SetParameterString("mode","buildmask"); AddRAMParameter(); @@ -138,12 +136,12 @@ private: m_Filter = FilterType::New(); m_Filter->SetInsideValue(this->GetParameterFloat("mode.buildmask.inv")); m_Filter->SetOutsideValue(this->GetParameterFloat("mode.buildmask.outv")); - m_Filter->SetNaNIsNoData(IsParameterEnabled("usenan")); + m_Filter->SetNaNIsNoData(GetParameterInt("usenan")); m_Filter->SetInput(inputPtr); m_ChangeNoDataFilter = ChangeNoDataFilterType::New(); m_ChangeNoDataFilter->SetInput(inputPtr); - m_ChangeNoDataFilter->SetNaNIsNoData(IsParameterEnabled("usenan")); + m_ChangeNoDataFilter->SetNaNIsNoData(GetParameterInt("usenan")); std::vector<double> newNoData(inputPtr->GetNumberOfComponentsPerPixel(),GetParameterFloat("mode.changevalue.newv")); diff --git a/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx b/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx index d94f67b260a694de203b6814f20b67ce207b6c03..8117e4c165fd95ced9c8d2cec4485508b647d947 100644 --- a/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx +++ b/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx @@ -96,12 +96,11 @@ private: SetParameterDescription( "vfactor", "Variance factor use in smoothing. It is multiplied by the subsampling factor of each level in the pyramid (default is 0.6)."); // Boolean Fast scheme - AddParameter(ParameterType_Empty, "fast", "Use Fast Scheme"); + AddParameter(ParameterType_Bool, "fast", "Use Fast Scheme"); std::ostringstream desc; desc<<"If used, this option allows one to speed-up computation by iteratively" <<" subsampling previous level of pyramid instead of processing the full input."; SetParameterDescription("fast", desc.str()); - MandatoryOff("fast"); // Doc example parameter settings SetDocExampleParameterValue("in", "QB_Toulouse_Ortho_XS.tif"); @@ -132,7 +131,7 @@ private: unsigned int shrinkFactor = GetParameterInt("sfactor"); double varianceFactor = GetParameterFloat("vfactor"); - bool fastScheme = IsParameterEnabled("fast"); + bool fastScheme = GetParameterInt("fast"); // Get the input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx index 1bca9241ea384ab9210913f1ca7949e68178142c..03f1351b8dd5d3a11bafa9b1aa4caa2fa18e57c5 100644 --- a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx +++ b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx @@ -292,7 +292,7 @@ private: id.Fill(0); std::ostringstream oss; oss << extractor->GetOutput()->GetPixel(id); - SetParameterString("value", oss.str(), false); + SetParameterString("value", oss.str()); //Display image information in the dedicated logger otbAppLogINFO( << oss.str() ); } diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index dd7134c62009cdfadc14b11f98f9f39734b09c50..f7f9db4a94e1364db0426c874fa7a65608e9fb89 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -146,8 +146,8 @@ private: if (!HasUserValue("rsx") && !HasUserValue("rsy") ) { - SetParameterInt("rsx",largestRegion.GetSize()[0], false); - SetParameterInt("rsy",largestRegion.GetSize()[1], false); + SetParameterInt("rsx",largestRegion.GetSize()[0]); + SetParameterInt("rsy",largestRegion.GetSize()[1]); } // Put the limit of the index and the size relative the image @@ -168,8 +168,8 @@ private: if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again - SetParameterInt("rox",0, false); - SetParameterInt("roy",0, false); + SetParameterInt("rox",0); + SetParameterInt("roy",0); this->CropRegionOfInterest(); } } @@ -183,15 +183,20 @@ bool CropRegionOfInterest() region.SetSize(1, GetParameterInt("rsy")); region.SetIndex(0, GetParameterInt("rox")); region.SetIndex(1, GetParameterInt("roy")); + FloatVectorImageType::RegionType region0 = region; if ( HasValue("in") ) { if (region.Crop(GetParameterImage("in")->GetLargestPossibleRegion())) { - SetParameterInt( "rsx", region.GetSize(0), HasUserValue("rsx") ); - SetParameterInt( "rsy", region.GetSize(1), HasUserValue("rsy") ); - SetParameterInt( "rox", region.GetIndex(0), HasUserValue("rox") ); - SetParameterInt( "roy", region.GetIndex(1), HasUserValue("roy") ); + if (region0.GetSize(0) != region.GetSize(0)) + SetParameterInt( "rsx", region.GetSize(0)); + if (region0.GetSize(1) != region.GetSize(1)) + SetParameterInt( "rsy", region.GetSize(1)); + if (region0.GetIndex(0) != region.GetIndex(0)) + SetParameterInt( "rox", region.GetIndex(0)); + if (region0.GetIndex(1) != region.GetIndex(1)) + SetParameterInt( "roy", region.GetIndex(1)); return true; } } diff --git a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx index 74bb9c42dadb51c605f164d14c228f5a6e5602c3..1aabf57ca8acf3b6c1be4e951ba03e56b87ae82a 100644 --- a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx +++ b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx @@ -67,10 +67,8 @@ private: AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription("in", "Input image to analyse"); - AddParameter(ParameterType_Empty, "keywordlist", "Display the OSSIM keywordlist"); + AddParameter(ParameterType_Bool, "keywordlist", "Display the OSSIM keywordlist"); SetParameterDescription("keywordlist", "Output the OSSIM keyword list. It contains metadata information (sensor model, geometry ). Information is stored in keyword list (pairs of key/value)"); - DisableParameter("keywordlist"); - MandatoryOff("keywordlist"); AddParameter(ParameterType_OutputFilename, "outkwl", "Write the OSSIM keywordlist to a geom file"); SetParameterDescription("outkwl", "This option allows extracting the OSSIM keywordlist of the image into a geom file."); @@ -267,7 +265,7 @@ private: ImageMetadataInterfaceType::Pointer metadataInterface = ImageMetadataInterfaceFactory::CreateIMI(inImage->GetMetaDataDictionary()); //Get number of bands - SetParameterInt("numberbands",inImage->GetNumberOfComponentsPerPixel(), false); + SetParameterInt("numberbands",inImage->GetNumberOfComponentsPerPixel()); ossOutput << "\tNumber of bands : " << GetParameterInt("numberbands") << std::endl; std::vector<bool> noDataValueAvailable; bool ret = itk::ExposeMetaData<std::vector<bool> >(inImage->GetMetaDataDictionary(),MetaDataKey::NoDataValueAvailable,noDataValueAvailable); @@ -298,26 +296,26 @@ private: ossOutput<<std::endl; //Get image size - SetParameterInt("indexx",inImage->GetLargestPossibleRegion().GetIndex()[0], false); - SetParameterInt("indexy",inImage->GetLargestPossibleRegion().GetIndex()[1], false); + SetParameterInt("indexx",inImage->GetLargestPossibleRegion().GetIndex()[0]); + SetParameterInt("indexy",inImage->GetLargestPossibleRegion().GetIndex()[1]); ossOutput << "\tStart index : [" << GetParameterInt("indexx") << "," << GetParameterInt("indexy") << "]" << std::endl; //Get image size - SetParameterInt("sizex",inImage->GetLargestPossibleRegion().GetSize()[0], false); - SetParameterInt("sizey",inImage->GetLargestPossibleRegion().GetSize()[1], false); + SetParameterInt("sizex",inImage->GetLargestPossibleRegion().GetSize()[0]); + SetParameterInt("sizey",inImage->GetLargestPossibleRegion().GetSize()[1]); ossOutput << "\tSize : [" << GetParameterInt("sizex") << "," << GetParameterInt("sizey") << "]" << std::endl; //Get image origin - SetParameterFloat("originx",inImage->GetOrigin()[0], false); - SetParameterFloat("originy",inImage->GetOrigin()[1], false); + SetParameterFloat("originx",inImage->GetOrigin()[0]); + SetParameterFloat("originy",inImage->GetOrigin()[1]); ossOutput << "\tOrigin : [" << GetParameterFloat("originx") << "," << GetParameterFloat("originy") << "]" << std::endl; //Get image spacing - SetParameterFloat("spacingx",inImage->GetSignedSpacing()[0], false); - SetParameterFloat("spacingy",inImage->GetSignedSpacing()[1], false); + SetParameterFloat("spacingx",inImage->GetSignedSpacing()[0]); + SetParameterFloat("spacingy",inImage->GetSignedSpacing()[1]); ossOutput << "\tSpacing : [" << GetParameterFloat("spacingx") << "," << GetParameterFloat("spacingy") << "]" << std::endl; //Estimate ground spacing @@ -336,14 +334,14 @@ private: approxGroundSpacing = groundSpacing->EvaluateAtIndex(index); //Get image estimated ground spacing (in m) - SetParameterFloat("estimatedgroundspacingx",approxGroundSpacing[0], false); - SetParameterFloat("estimatedgroundspacingy",approxGroundSpacing[1], false); + SetParameterFloat("estimatedgroundspacingx",approxGroundSpacing[0]); + SetParameterFloat("estimatedgroundspacingy",approxGroundSpacing[1]); ossOutput << "\tEstimated ground spacing (in meters): [" << GetParameterFloat("estimatedgroundspacingx") << "," << GetParameterFloat("estimatedgroundspacingy") << "]" << std::endl; ossOutput << std::endl << "Image acquisition information:" << std::endl; - SetParameterString("sensor", metadataInterface->GetSensorID(), false); + SetParameterString("sensor", metadataInterface->GetSensorID()); ossOutput << "\tSensor : "; if (!GetParameterString("sensor").empty()) ossOutput << GetParameterString("sensor"); @@ -353,11 +351,11 @@ private: ossOutput << "\tImage identification number: "; if (metadataInterface->GetImageKeywordlist().HasKey("image_id")) { - SetParameterString("id", metadataInterface->GetImageKeywordlist().GetMetadataByKey("image_id"), false); + SetParameterString("id", metadataInterface->GetImageKeywordlist().GetMetadataByKey("image_id")); ossOutput << GetParameterString("id"); } ossOutput << std::endl; - SetParameterString("projectionref", metadataInterface->GetProjectionRef(), false); + SetParameterString("projectionref", metadataInterface->GetProjectionRef()); if (!GetParameterString("projectionref").empty()) ossOutput << "\tImage projection : " << GetParameterString("projectionref") << std::endl; @@ -381,7 +379,7 @@ private: osstime<<"0"; osstime<<metadataInterface->GetMinute(); osstime<<":00"; - SetParameterString("time", osstime.str(), false); + SetParameterString("time", osstime.str()); ossOutput << "\tAcquisition time : " << GetParameterString("time") << std::endl; } @@ -410,29 +408,29 @@ private: if( !coord2name->GetCountryName().empty() ) { - SetParameterString("country", coord2name->GetCountryName(), false); + SetParameterString("country", coord2name->GetCountryName()); ossOutput << "\tCountry : " << GetParameterString("country") << std::endl; } else - SetParameterString("country", "Not available", false); + SetParameterString("country", "Not available"); if( !coord2name->GetPlaceName().empty() ) { - SetParameterString("town", coord2name->GetPlaceName(), false); + SetParameterString("town", coord2name->GetPlaceName()); ossOutput << "\tTown : " << GetParameterString("town") << std::endl; } else - SetParameterString("town", "Not available", false); + SetParameterString("town", "Not available"); // Retrieve footprint - SetParameterFloat("ullat",ullat, false); - SetParameterFloat("ullon",ullon, false); - SetParameterFloat("urlat",urlat, false); - SetParameterFloat("urlon",urlon, false); - SetParameterFloat("lrlat",lrlat, false); - SetParameterFloat("lrlon",lrlon, false); - SetParameterFloat("lllat",lllat, false); - SetParameterFloat("lllon",lllon, false); + SetParameterFloat("ullat",ullat); + SetParameterFloat("ullon",ullon); + SetParameterFloat("urlat",urlat); + SetParameterFloat("urlon",urlon); + SetParameterFloat("lrlat",lrlat); + SetParameterFloat("lrlon",lrlon); + SetParameterFloat("lllat",lllat); + SetParameterFloat("lllon",lllon); ossOutput << std::endl << "Image footprint coordinates:" << std::endl; ossOutput << "\tUpper left corner (latitude, longitude) = [" << GetParameterFloat("ullat") << "," << GetParameterFloat("ullon") << "]" << std::endl; @@ -444,15 +442,15 @@ private: { } - SetParameterInt("rgb.r",metadataInterface->GetDefaultDisplay()[0], false); - SetParameterInt("rgb.g",metadataInterface->GetDefaultDisplay()[1], false); - SetParameterInt("rgb.b",metadataInterface->GetDefaultDisplay()[2], false); + SetParameterInt("rgb.r",metadataInterface->GetDefaultDisplay()[0]); + SetParameterInt("rgb.g",metadataInterface->GetDefaultDisplay()[1]); + SetParameterInt("rgb.b",metadataInterface->GetDefaultDisplay()[2]); ossOutput << std::endl << "Image default RGB composition:" << std::endl; ossOutput << "\t[R, G, B] = [" << GetParameterInt("rgb.r") << "," << GetParameterInt("rgb.g") << "," << GetParameterInt("rgb.b") << "]" << std::endl; - SetParameterInt("gcp.count",metadataInterface->GetGCPCount(), false); - SetParameterString("gcp.proj", metadataInterface->GetGCPProjection(), false); + SetParameterInt("gcp.count",metadataInterface->GetGCPCount()); + SetParameterString("gcp.proj", metadataInterface->GetGCPProjection()); ossOutput << std::endl << "Ground control points information:" << std::endl; ossOutput << "\tNumber of GCPs = " << GetParameterInt("gcp.count") << std::endl; @@ -481,16 +479,16 @@ private: ossOutput << "\t\tGround coordinates =" << gcp_geocoord.back() << std::endl; } - SetParameterStringList("gcp.ids", gcp_ids, false); - SetParameterStringList("gcp.imcoord", gcp_imcoord, false); - SetParameterStringList("gcp.geocoord", gcp_geocoord, false); - SetParameterStringList("gcp.info", gcp_infos, false); + SetParameterStringList("gcp.ids", gcp_ids); + SetParameterStringList("gcp.imcoord", gcp_imcoord); + SetParameterStringList("gcp.geocoord", gcp_geocoord); + SetParameterStringList("gcp.info", gcp_infos); - if ( IsParameterEnabled("keywordlist") ) + if ( GetParameterInt("keywordlist") ) { std::ostringstream osskeywordlist; osskeywordlist<<metadataInterface->GetImageKeywordlist() << std::endl; - SetParameterString("keyword", osskeywordlist.str(), false); + SetParameterString("keyword", osskeywordlist.str()); ossOutput << std::endl << "Image OSSIM keywordlist (optional):" << std::endl; ossOutput << "\t" << GetParameterString("keyword") << std::endl; @@ -499,7 +497,7 @@ private: //Display image information in the dedicated logger otbAppLogINFO( << ossOutput.str() ); - if(IsParameterEnabled("outkwl")) + if(IsParameterEnabled("outkwl") && HasValue("outkwl")) { WriteGeometry(metadataInterface->GetImageKeywordlist(),GetParameterString("outkwl")); } diff --git a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx index 90a7f245a6f3e1adf1976c27634ec5bbb12c28fd..90be1a12b3512f386f74760c5e7673cfef4df5ed 100644 --- a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx +++ b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx @@ -289,7 +289,7 @@ private: if (useContext) { // only set the first expression, 'ManyExpression' is disabled. - this->SetParameterString("exp",dummyFilter->GetExpression(0), false); + this->SetParameterString("exp",dummyFilter->GetExpression(0)); } } } diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 829c4f3052c9d95683dd55b0d62b28d5bd1f14f9..3c843fa5ac6112fb1b3e85442bdb9149c9eddc9b 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -197,18 +197,15 @@ private: AddChoice("level.toa", "Image to Top Of Atmosphere reflectance"); AddChoice("level.toatoim", "TOA reflectance to Image"); AddChoice("level.toc", "Image to Top Of Canopy reflectance (atmospheric corrections)"); - SetParameterString("level", "toa", false); + SetParameterString("level", "toa"); - AddParameter(ParameterType_Empty, "milli", "Convert to milli reflectance"); + AddParameter(ParameterType_Bool, "milli", "Convert to milli reflectance"); SetParameterDescription("milli", "Flag to use milli-reflectance instead of reflectance.\n" "This allows saving the image with integer pixel type (in the range [0, 1000] instead of floating point in the range [0, 1]. In order to do that, use this option and set the output pixel type (-out filename double for example)"); - DisableParameter("milli"); - MandatoryOff("milli"); - AddParameter(ParameterType_Empty, "clamp", "Clamp of reflectivity values between [0, 1]"); + AddParameter(ParameterType_Bool, "clamp", "Clamp of reflectivity values between [0, 1]"); SetParameterDescription("clamp", "Clamping in the range [0, 1]. It can be useful to preserve area with specular reflectance."); - EnableParameter("clamp"); - MandatoryOff("clamp"); + SetParameterInt("clamp",1); //Acquisition parameters AddParameter(ParameterType_Group,"acqui","Acquisition parameters"); @@ -429,21 +426,21 @@ private: ossOutput << "Acquisition Minute already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.minute",lImageMetadataInterface->GetMinute(), false); + SetParameterInt("acqui.minute",lImageMetadataInterface->GetMinute()); } if (HasUserValue("acqui.hour")) ossOutput << "Acquisition Hour already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.hour",lImageMetadataInterface->GetHour(), false); + SetParameterInt("acqui.hour",lImageMetadataInterface->GetHour()); } if (HasUserValue("acqui.day")) ossOutput << "Acquisition Day already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.day",lImageMetadataInterface->GetDay(), false); + SetParameterInt("acqui.day",lImageMetadataInterface->GetDay()); if (IsParameterEnabled("acqui.fluxnormcoeff")) DisableParameter("acqui.day"); } @@ -452,7 +449,7 @@ private: ossOutput << "Acquisition Month already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.month",lImageMetadataInterface->GetMonth(), false); + SetParameterInt("acqui.month",lImageMetadataInterface->GetMonth()); if (IsParameterEnabled("acqui.fluxnormcoeff")) DisableParameter("acqui.month"); } @@ -461,28 +458,28 @@ private: ossOutput << "Acquisition Year already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.year",lImageMetadataInterface->GetYear(), false); + SetParameterInt("acqui.year",lImageMetadataInterface->GetYear()); } if (HasUserValue("acqui.sun.elev")) ossOutput << "Acquisition Sun Elevation Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.sun.elev",lImageMetadataInterface->GetSunElevation(), false); + SetParameterFloat("acqui.sun.elev",lImageMetadataInterface->GetSunElevation()); if (HasUserValue("acqui.sun.azim")) ossOutput << "Acquisition Sun Azimuth Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.sun.azim",lImageMetadataInterface->GetSunAzimuth(), false); + SetParameterFloat("acqui.sun.azim",lImageMetadataInterface->GetSunAzimuth()); if (HasUserValue("acqui.view.elev")) ossOutput << "Acquisition Viewing Elevation Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.view.elev",lImageMetadataInterface->GetSatElevation(), false); + SetParameterFloat("acqui.view.elev",lImageMetadataInterface->GetSatElevation()); if (HasUserValue("acqui.view.azim")) ossOutput << "Acquisition Viewing Azimuth Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.view.azim",lImageMetadataInterface->GetSatAzimuth(), false); + SetParameterFloat("acqui.view.azim",lImageMetadataInterface->GetSatAzimuth()); // Set default value so that they are stored somewhere even if // they are overloaded by user values @@ -751,12 +748,12 @@ private: m_ImageToRadianceFilter->SetInput(inImage); m_RadianceToReflectanceFilter->SetInput(m_ImageToRadianceFilter->GetOutput()); - if (IsParameterEnabled("clamp")) + if (GetParameterInt("clamp")) { GetLogger()->Info("Clamp values between [0, 100]\n"); } - m_RadianceToReflectanceFilter->SetUseClamp(IsParameterEnabled("clamp")); + m_RadianceToReflectanceFilter->SetUseClamp(GetParameterInt("clamp")); m_RadianceToReflectanceFilter->UpdateOutputInformation(); m_ScaleFilter->SetInput(m_RadianceToReflectanceFilter->GetOutput()); } @@ -894,7 +891,7 @@ private: } //Rescale the surface reflectance in milli-reflectance - if (!IsParameterEnabled("clamp")) + if (!GetParameterInt("clamp")) { if (!adjComputation) m_ScaleFilter->SetInput(m_ReflectanceToSurfaceReflectanceFilter->GetOutput()); @@ -920,7 +917,7 @@ private: // Output Image double scale = 1.; - if (IsParameterEnabled("milli")) + if (GetParameterInt("milli")) { GetLogger()->Info("Use milli-reflectance\n"); if ( (GetParameterInt("level") == Level_IM_TOA) || (GetParameterInt("level") == Level_TOC) ) diff --git a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx index dfecb742eab6f21f8bbeb72794f15aa68c5c849b..088428ef667cf4a89e8a47a29fe0baade21b9d56 100644 --- a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx @@ -122,8 +122,8 @@ private: otbAppLogINFO( << std::setprecision(10) << "Geographic Point (Long, Lat) : (" << geoPoint[0] << ", " << geoPoint[1] << ")" ); - SetParameterFloat( "long",geoPoint[0] , false); - SetParameterFloat( "lat",geoPoint[1] , false); + SetParameterFloat( "long",geoPoint[0]); + SetParameterFloat( "lat",geoPoint[1]); } }; diff --git a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx index 384c892f14addbc1c66ac4b2f6b66d6ed28b460a..c7e6ee3619254f9e901f058d0b33c46f848b8ab3 100644 --- a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx @@ -130,8 +130,8 @@ private: outputPoint = model->TransformPoint(point); // Set the value computed - SetParameterFloat("output.idx",outputPoint[0], false); - SetParameterFloat("output.idy",outputPoint[1], false); + SetParameterFloat("output.idx",outputPoint[0]); + SetParameterFloat("output.idy",outputPoint[1]); // Set the town and the neaerest city CoordinateToName::Pointer coord2name = CoordinateToName::New(); @@ -139,8 +139,8 @@ private: coord2name->SetLat(outputPoint[1]); coord2name->Evaluate(); - SetParameterString("output.town", coord2name->GetPlaceName(), false); - SetParameterString("output.country", coord2name->GetCountryName(), false); + SetParameterString("output.town", coord2name->GetPlaceName()); + SetParameterString("output.country", coord2name->GetCountryName()); } }; diff --git a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx index 72c9073a536035db0bf7b54dce52958e420590d4..750913f778e08afb6417812b9b05f40f8c26b04f 100644 --- a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx +++ b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx @@ -173,7 +173,7 @@ private: AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation"); SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts."); SetDefaultParameterInt("interpolator.bco.radius", 2); - SetParameterString("interpolator","bco", false); + SetParameterString("interpolator","bco"); AddRAMParameter(); diff --git a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx index 37d0ec7b74b4104ef1ab1e6e893a8dac585d513c..0cfa820b268b01b54df2452170129a0d285ad9f8 100644 --- a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx @@ -93,7 +93,7 @@ private: { int utmZone = otb::Utils::GetZoneFromGeoPoint(GetParameterFloat("lon"), GetParameterFloat("lat")); - SetParameterInt("utm",utmZone, false); + SetParameterInt("utm",utmZone); } }; diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index 3c91403e47100f50b352f436f2a7583d648a14de..5918102d7e096b4a45cf5e23485c0f96951666c7 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -177,13 +177,13 @@ private: MandatoryOff("outputs.lry"); MandatoryOff("outputs.ortho"); - AddParameter(ParameterType_Empty,"outputs.isotropic","Force isotropic spacing by default"); + AddParameter(ParameterType_Bool,"outputs.isotropic","Force isotropic spacing by default"); std::ostringstream isotropOss; isotropOss << "Default spacing (pixel size) values are estimated from the sensor modeling of the image. It can therefore result in a non-isotropic spacing. "; isotropOss << "This option allows you to force default values to be isotropic (in this case, the minimum of spacing in both direction is applied. "; isotropOss << "Values overridden by user are not affected by this option."; SetParameterDescription("outputs.isotropic", isotropOss.str()); - EnableParameter("outputs.isotropic"); + SetParameterInt("outputs.isotropic", 1); AddParameter(ParameterType_Float, "outputs.default", "Default pixel value"); SetParameterDescription("outputs.default","Default value to write when outside of input image."); @@ -259,7 +259,7 @@ private: typedef otb::ImageToGenericRSOutputParameters<FloatVectorImageType> OutputParametersEstimatorType; OutputParametersEstimatorType::Pointer genericRSEstimator = OutputParametersEstimatorType::New(); - if(IsParameterEnabled("outputs.isotropic")) + if(GetParameterInt("outputs.isotropic")) { genericRSEstimator->EstimateIsotropicSpacingOn(); } @@ -274,28 +274,28 @@ private: // Fill the Gui with the computed parameters if (!HasUserValue("outputs.sizex")) - SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0], false); + SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0]); if (!HasUserValue("outputs.sizey")) - SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1], false); + SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1]); if (!HasUserValue("outputs.spacingx")) - SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0]); if (!HasUserValue("outputs.spacingy")) - SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1]); if (!HasUserValue("outputs.ulx")) - SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); if (!HasUserValue("outputs.uly")) - SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); if (!HasUserValue("outputs.lrx")) - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); if (!HasUserValue("outputs.lry")) - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); // Handle the spacing and size field following the mode // chose by the user @@ -336,8 +336,8 @@ private: MandatoryOff("outputs.ortho"); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } break; case Mode_AutomaticSize: @@ -382,16 +382,16 @@ private: genericRSEstimator->Compute(); // Set the processed size relative to this forced spacing - SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0], false); - SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1], false); + SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0]); + SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1]); // Reset Origin to default - SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); - SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } break; case Mode_AutomaticSpacing: @@ -436,16 +436,16 @@ private: genericRSEstimator->Compute(); // Set the processed spacing relative to this forced size - SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0], false); - SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1]); // Reset Origin to default - SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); - SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } break; @@ -489,9 +489,9 @@ private: // Set the processed size relative to this forced spacing if (vcl_abs(spacing[0]) > 0.0) - SetParameterInt("outputs.sizex",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lrx")-GetParameterFloat("outputs.ulx"))/spacing[0])), false); + SetParameterInt("outputs.sizex",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lrx")-GetParameterFloat("outputs.ulx"))/spacing[0]))); if (vcl_abs(spacing[1]) > 0.0) - SetParameterInt("outputs.sizey",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lry")-GetParameterFloat("outputs.uly"))/spacing[1])), false); + SetParameterInt("outputs.sizey",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lry")-GetParameterFloat("outputs.uly"))/spacing[1]))); } break; case Mode_OrthoFit: @@ -541,11 +541,11 @@ private: SetParameterInt("outputs.sizey",size[1]); SetParameterFloat("outputs.spacingx",spacing[0]); SetParameterFloat("outputs.spacingy",spacing[1]); - SetParameterFloat("outputs.ulx",orig[0] - 0.5 * spacing[0], false); - SetParameterFloat("outputs.uly",orig[1] - 0.5 * spacing[1], false); + SetParameterFloat("outputs.ulx",orig[0] - 0.5 * spacing[0]); + SetParameterFloat("outputs.uly",orig[1] - 0.5 * spacing[1]); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } } break; @@ -591,11 +591,11 @@ private: // Use the smallest spacing (more precise grid) double optimalSpacing = std::min( vcl_abs(xgridspacing), vcl_abs(ygridspacing) ); otbAppLogINFO( "Setting grid spacing to " << optimalSpacing ); - SetParameterFloat("opt.gridspacing",optimalSpacing, false); + SetParameterFloat("opt.gridspacing",optimalSpacing); } else // if (m_OutputProjectionRef == otb::GeoInformationConversion::ToWKT(4326)) { - SetParameterFloat("opt.gridspacing",DefaultGridSpacingMeter, false); + SetParameterFloat("opt.gridspacing",DefaultGridSpacingMeter); } // if (m_OutputProjectionRef == otb::GeoInformationConversion::ToWKT(4326)) } // if (!HasUserValue("opt.gridspacing")) } // if (HasValue("io.in")) diff --git a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx index 7b6da7d245c8e9b2d37f7191e56867903a2a76af..01a9d01124657247bdc64c8933b6047c4cf68bd4 100644 --- a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx +++ b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx @@ -159,7 +159,7 @@ private: AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation"); SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts."); SetDefaultParameterInt("interpolator.bco.radius", 2); - SetParameterString("interpolator","bco", false); + SetParameterString("interpolator","bco"); // RAM available AddRAMParameter("ram"); diff --git a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx index 1d1018e8fc74a755fa8b425a86369e4c0afc7d22..2f5786587b999d404edf1f2a82f20dd59ab5fd29 100644 --- a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx +++ b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx @@ -164,7 +164,7 @@ private: if(!HasUserValue("mode") && HasValue("inr") && HasValue("inm") && otb::PleiadesPToXSAffineTransformCalculator::CanCompute(GetParameterImage("inr"),GetParameterImage("inm"))) { otbAppLogWARNING("Forcing PHR mode with PHR data. You need to add \"-mode default\" to force the default mode with PHR images."); - SetParameterString("mode","phr", false); + SetParameterString("mode","phr"); } } diff --git a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx index 751678774184b69c0d048d18f906c2ecdb55694c..0709ad8007ff37fd6dafd0d3fa6b9a00d59ce738 100644 --- a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx +++ b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx @@ -68,9 +68,8 @@ private: AddRAMParameter(); - AddParameter(ParameterType_Empty, "noise", "Disable Noise"); + AddParameter(ParameterType_Bool, "noise", "Disable Noise"); SetParameterDescription("noise", "Flag to disable noise. For 5.2.0 release, the noise values are only read by TerraSARX product."); - MandatoryOff("noise"); AddParameter(ParameterType_Choice, "lut", "Lookup table sigma /gamma/ beta/ DN."); SetParameterDescription("lut", "Lookup table values are not available with all SAR products. Products that provide lookup table with metadata are: Sentinel1, Radarsat2."); @@ -104,17 +103,8 @@ private: // Set the filer input m_CalibrationFilter = CalibrationFilterType::New(); m_CalibrationFilter->SetInput(floatComplexImage); - - if (IsParameterEnabled("noise")) - { - m_CalibrationFilter->SetEnableNoise(false); - } - - short lut = 0; - - lut = GetParameterInt("lut"); - - m_CalibrationFilter->SetLookupSelected(lut); + m_CalibrationFilter->SetEnableNoise( !bool(GetParameterInt("noise")) ); + m_CalibrationFilter->SetLookupSelected(GetParameterInt("lut")); // Set the output image SetParameterOutputImage("out", m_CalibrationFilter->GetOutput()); diff --git a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx index 48dd57c2ad75d5f31c5eddd08ff606239f7aaa2a..7588f4eb873b073f9c101ce568b1c6c0c941ba67 100644 --- a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx @@ -297,10 +297,10 @@ private: m_InstanceFilter->Update(); - SetParameterFloat("rc",m_InstanceFilter->GetMeanRC(), false); - SetParameterFloat("rf",m_InstanceFilter->GetMeanRF(), false); - SetParameterFloat("ra",m_InstanceFilter->GetMeanRA(), false); - SetParameterFloat("rm",m_InstanceFilter->GetMeanRM(), false); + SetParameterFloat("rc",m_InstanceFilter->GetMeanRC()); + SetParameterFloat("rf",m_InstanceFilter->GetMeanRF()); + SetParameterFloat("ra",m_InstanceFilter->GetMeanRA()); + SetParameterFloat("rm",m_InstanceFilter->GetMeanRM()); } ImageToLabelMapFilterType::Pointer m_GTFilter; diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx index 93694cc420dcc271c6dff0ac551d43d519acd2b4..280faee001b8f12462b2799e26a0e187572c4027 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx @@ -139,7 +139,7 @@ private: void RemoveFile(std::string tile) { // Cleanup - if(IsParameterEnabled("cleanup")) + if(GetParameterInt("cleanup")) { // Try to remove the geom file if existing std::string geomfile = tile.substr(0,tile.size() - itksys::SystemTools::GetFilenameExtension(tile.c_str()).size()).append(".geom"); @@ -302,10 +302,9 @@ private: MandatoryOff("tmpdir"); DisableParameter("tmpdir"); - AddParameter(ParameterType_Empty,"cleanup","Temporary files cleaning"); - EnableParameter("cleanup"); + AddParameter(ParameterType_Bool,"cleanup","Temporary files cleaning"); SetParameterDescription("cleanup","If activated, the application will try to remove all temporary files it created."); - MandatoryOff("cleanup"); + SetParameterInt("cleanup",1); // Doc example parameter settings SetDocExampleParameterValue("in","smooth.tif"); @@ -724,7 +723,7 @@ private: // Release input files m_FinalReader = ITK_NULLPTR; - if(IsParameterEnabled("cleanup")) + if(GetParameterInt("cleanup")) { otbAppLogINFO(<<"Final clean-up ..."); diff --git a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx index 27f8da837771c4eada660c43b6628e6fa32ec462..05ca673b6434030bab8d22067c9fcdc7219f4eaf 100644 --- a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx @@ -120,11 +120,10 @@ private: "The output raster image", "It corresponds to the output of the small region merging step."); - AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); - EnableParameter( "cleanup" ); + AddParameter( ParameterType_Bool, "cleanup", "Temporary files cleaning" ); SetParameterDescription( "cleanup", "If activated, the application will try to clean all temporary files it created" ); - MandatoryOff( "cleanup" ); + SetParameterInt("cleanup",1); // Setup RAM ShareParameter("ram","smoothing.ram"); diff --git a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx index 8f63bf13ef99f1062726c988b7c6b18a8aa236d5..d8980392b05ebf8fc2694057e59bda0554de7239 100644 --- a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx +++ b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx @@ -159,10 +159,8 @@ private: SetMinimumParameterFloatValue("rangeramp", 0); MandatoryOff("rangeramp"); - AddParameter(ParameterType_Empty, "modesearch", "Mode search."); + AddParameter(ParameterType_Bool, "modesearch", "Mode search."); SetParameterDescription("modesearch", "If activated pixel iterative convergence is stopped if the path crosses an already converged pixel. Be careful, with this option, the result will slightly depend on thread number and the results will not be stable (see [4] for more details)."); - DisableParameter("modesearch"); - // Doc example parameter settings SetDocExampleParameterValue("in", "maur_rgb.png"); @@ -192,7 +190,7 @@ private: m_Filter->SetThreshold(GetParameterFloat("thres")); m_Filter->SetMaxIterationNumber(GetParameterInt("maxiter")); m_Filter->SetRangeBandwidthRamp(GetParameterFloat("rangeramp")); - m_Filter->SetModeSearch(IsParameterEnabled("modesearch")); + m_Filter->SetModeSearch(GetParameterInt("modesearch")); //Compute the margin used to ensure exact results (tile wise smoothing) //This margin is valid for the default uniform kernel used by the @@ -211,7 +209,7 @@ private: { SetParameterOutputImage("foutpos", m_Filter->GetSpatialOutput()); } - if(!IsParameterEnabled("modesearch")) + if(!GetParameterInt("modesearch")) { otbAppLogINFO(<<"Mode Search is disabled." << std::endl); } diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index 5b3bfd2361f211e9dccf19b383542596fd1b994a..6978349e6401c67aebf778455263f373f64ff3cb 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -282,17 +282,13 @@ private: SetParameterDescription("mode.vector.inmask", "Only pixels whose mask value is strictly positive will be segmented."); MandatoryOff("mode.vector.inmask"); - AddParameter(ParameterType_Empty, "mode.vector.neighbor", "8-neighbor connectivity"); + AddParameter(ParameterType_Bool, "mode.vector.neighbor", "8-neighbor connectivity"); SetParameterDescription("mode.vector.neighbor", "Activate 8-Neighborhood connectivity (default is 4)."); - MandatoryOff("mode.vector.neighbor"); - DisableParameter("mode.vector.neighbor"); - - AddParameter(ParameterType_Empty,"mode.vector.stitch","Stitch polygons"); + AddParameter(ParameterType_Bool,"mode.vector.stitch","Stitch polygons"); SetParameterDescription("mode.vector.stitch", "Scan polygons on each side of tiles and stitch polygons which connect by more than one pixel."); - MandatoryOff("mode.vector.stitch"); - EnableParameter("mode.vector.stitch"); + SetParameterInt("mode.vector.stitch",1); AddParameter(ParameterType_Int, "mode.vector.minsize", "Minimum object size"); SetParameterDescription("mode.vector.minsize", @@ -311,11 +307,11 @@ private: AddParameter(ParameterType_String, "mode.vector.layername", "Layer name"); SetParameterDescription("mode.vector.layername", "Name of the layer in the vector file or database (default is Layer)."); - SetParameterString("mode.vector.layername", "layer", false); + SetParameterString("mode.vector.layername", "layer"); AddParameter(ParameterType_String, "mode.vector.fieldname", "Geometry index field name"); SetParameterDescription("mode.vector.fieldname", "Name of the field holding the geometry index in the output vector file or database."); - SetParameterString("mode.vector.fieldname", "DN", false); + SetParameterString("mode.vector.fieldname", "DN"); AddParameter(ParameterType_Int, "mode.vector.tilesize", "Tiles size"); SetParameterDescription("mode.vector.tilesize", @@ -365,7 +361,7 @@ private: // Retrieve tile size parameter const unsigned int tileSize = static_cast<unsigned int> (this->GetParameterInt("mode.vector.tilesize")); // Retrieve the 8-connected option - bool use8connected = IsParameterEnabled("mode.vector.neighbor"); + bool use8connected = GetParameterInt("mode.vector.neighbor"); // Retrieve min object size parameter const unsigned int minSize = static_cast<unsigned int> (this->GetParameterInt("mode.vector.minsize")); @@ -673,7 +669,7 @@ private: ogrDS->SyncToDisk(); // Stitching mode - if (IsParameterEnabled("mode.vector.stitch")) + if (GetParameterInt("mode.vector.stitch")) { otbAppLogINFO(<<"Segmentation done, stiching polygons ..."); diff --git a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx index 2ec8f7e63a0c00d90c3156c390ea71ce3af63573..41c9257ac04acd9256df53ad382608a17f26110b 100644 --- a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx +++ b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx @@ -202,7 +202,7 @@ private: DisableParameter("io.outmask"); MandatoryOff("io.outmask"); - AddParameter(ParameterType_Empty,"io.outmetric","Flag to output optimal " + AddParameter(ParameterType_Bool,"io.outmetric","Flag to output optimal " "metric values as well"); SetParameterDescription("io.outmetric","If enabled, the output image will " "have a third component with metric optimal values"); @@ -847,7 +847,7 @@ private: m_OutputImageList->PushBack(hdispImage); m_OutputImageList->PushBack(vdispImage); - if(IsParameterEnabled("io.outmetric")) + if(GetParameterInt("io.outmetric")) { m_OutputImageList->PushBack(metricImage); } diff --git a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx index 279c09ad2f9734bf45a95cb612408edb36efb8b8..b077adb1abdae581bc2c5ade1c51828fa5ea0aae 100644 --- a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx @@ -368,7 +368,7 @@ private: "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); + SetParameterString("input.co",""); DisableParameter("input.co"); AddParameter(ParameterType_Int, "input.channel", "Input Image channel"); @@ -385,7 +385,7 @@ private: // // Build the Output Map Projection // for custom map projection MapProjectionParametersHandler::AddMapProjectionParameters(this, "map"); - SetParameterString("map","wgs", false); + SetParameterString("map","wgs"); AddParameter(ParameterType_Float, "output.res","Output resolution"); SetParameterDescription("output.res","Spatial sampling distance of the output elevation : the cell size (in m)"); @@ -525,20 +525,16 @@ 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" + AddParameter(ParameterType_Bool,"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"); + SetParameterInt("postproc.bij", 1); - AddParameter(ParameterType_Empty,"postproc.med","Use median disparities filtering"); + AddParameter(ParameterType_Bool,"postproc.med","Use median disparities filtering"); 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 " @@ -624,7 +620,7 @@ private: } else blockMatcherFilter->MinimizeOff(); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { invBlockMatcherFilter->SetLeftInput(rightImage); invBlockMatcherFilter->SetRightInput(leftImage); @@ -947,7 +943,7 @@ private: m_Filters.push_back(lBandMathFilter.GetPointer()); BandMathFilterType::Pointer finalMaskFilter; - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { finalMaskFilter = BandMathFilterType::New(); finalMaskFilter->SetNthInput(0, lBandMathFilter->GetOutput(), "inmask"); @@ -992,7 +988,7 @@ private: blockMatcherFilterPointer = SSDDivMeanBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invSSDDivMeanBlockMatcherFilter = SSDDivMeanBlockMatchingFilterType::New(); @@ -1025,7 +1021,7 @@ private: blockMatcherFilterPointer = SSDBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invSSDBlockMatcherFilter = SSDBlockMatchingFilterType::New(); @@ -1056,7 +1052,7 @@ private: blockMatcherFilterPointer = NCCBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invNCCBlockMatcherFilter = NCCBlockMatchingFilterType::New(); @@ -1090,7 +1086,7 @@ private: blockMatcherFilterPointer = LPBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invLPBlockMatcherFilter = LPBlockMatchingFilterType::New(); @@ -1119,7 +1115,7 @@ private: break; } - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { otbAppLogINFO(<<"Using reverse block-matching to filter incoherent disparity values."); bijectFilter = BijectionFilterType::New(); @@ -1149,7 +1145,7 @@ private: FloatImageType::Pointer hDispOutput = subPixelFilterPointer->GetOutput(0); FloatImageType::Pointer finalMaskImage=finalMaskFilter->GetOutput(); - if (IsParameterEnabled("postproc.med")) + if (GetParameterInt("postproc.med")) { MedianFilterType::Pointer hMedianFilter = MedianFilterType::New(); hMedianFilter->SetInput(subPixelFilterPointer->GetOutput(0)); @@ -1183,7 +1179,7 @@ private: FloatImageType::Pointer hDispOutput2 = disparityTranslateFilter->GetHorizontalDisparityMapOutput(); FloatImageType::Pointer vDispOutput2 = disparityTranslateFilter->GetVerticalDisparityMapOutput(); FloatImageType::Pointer translatedMaskImage = dispTranslateMaskFilter->GetOutput(); - if (IsParameterEnabled("postproc.med")) + if (GetParameterInt("postproc.med")) { MedianFilterType::Pointer hMedianFilter2 = MedianFilterType::New(); MedianFilterType::Pointer vMedianFilter2 = MedianFilterType::New(); diff --git a/Modules/Applications/AppTest/app/otbTestApplication.cxx b/Modules/Applications/AppTest/app/otbTestApplication.cxx index a2e9ee940da3b473f8e69fbd152eda675c66256d..4407d76ed36a5da9f329b31edd215ba6ebcbaaca 100644 --- a/Modules/Applications/AppTest/app/otbTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbTestApplication.cxx @@ -56,7 +56,8 @@ private: AddDocTag("Test"); //std::cout << "TestApplication::DoInit" << std::endl; - AddParameter(ParameterType_Empty, "boolean", "Boolean"); + AddParameter(ParameterType_Empty, "empty", "Boolean (old impl.)"); + AddParameter(ParameterType_Bool, "boolean", "Boolean"); AddParameter(ParameterType_Int, "int", "Integer"); MandatoryOff("int"); AddParameter(ParameterType_Float, "float", "Float"); diff --git a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx index 748d8f27be36f75205398bcbf7114b4b66343856..9ddef6c295fc4d12a2d60cbeeef7e1242c73be61 100644 --- a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx +++ b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx @@ -132,7 +132,7 @@ private: AddParameter(ParameterType_String,"mode.attribute.field","The attribute field to burn"); SetParameterDescription("mode.attribute.field","Name of the attribute field to burn"); - SetParameterString("mode.attribute.field","DN", false); + SetParameterString("mode.attribute.field","DN"); AddRAMParameter(); diff --git a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx index d55626ed0bb0f79d3696a4a2940c59a870038217..ba625b5f4862f0f0377ee4d0f082193dcd0815e7 100644 --- a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx @@ -98,11 +98,10 @@ private: // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); - AddParameter(ParameterType_Empty, "printclasses", "Displays available key/value classes"); + AddParameter(ParameterType_Bool, "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 SetDocExampleParameterValue("support", "qb_RoadExtract.tif"); @@ -118,15 +117,15 @@ private: // CASE: when the -print option is not required and the User // does not set the option OSMKey or the option Output or does not // set both of them - if ( !this->HasValue("printclasses") ) + if ( GetParameterInt("printclasses") ) { - MandatoryOn("out"); - MandatoryOn("key"); + MandatoryOff("out"); + MandatoryOff("key"); } else { - MandatoryOff("out"); - MandatoryOff("key"); + MandatoryOn("out"); + MandatoryOn("key"); } } @@ -178,7 +177,7 @@ private: // If the user wants to print the Key/Values present in the XML file // downloaded : - if ( this->HasValue("printclasses")) + if ( GetParameterInt("printclasses")) { // Print the classes VectorDataProviderType::KeyMapType keymap = m_VdOSMGenerator->GetKeysMap(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index c6317be14289016f5a5f9636b1af864a1d0c969c..bbc610eeb91e77fff82d2635fda33d40dad34bdc 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -212,6 +212,9 @@ public: bool GetParameterEmpty(std::string paramKey); /** Set HasUserValue flag of parameter with key paramKey + * Note that when this function is called from DoInit, DoUpdateParameters + * or DoExecute, it will always set this flag to false, because this is + * the core behavior of the application. */ void SetParameterUserValue(std::string paramKey, bool value); @@ -1013,6 +1016,10 @@ private: bool m_HaveInXML; bool m_HaveOutXML; bool m_IsInXMLParsed; + + /** Flag is true when executing DoInit, DoUpdateParameters or DoExecute */ + bool m_IsInPrivateDo; + /** * Declare the class * - Wrapper::MapProjectionParametersHandler diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..b2a26670de700f3daf95a9c943477366c59dba50 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h @@ -0,0 +1,87 @@ +/* + * 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 otbWrapperBoolParameter_h +#define otbWrapperBoolParameter_h + +#include "otbWrapperParameter.h" +#include "OTBApplicationEngineExport.h" + +namespace otb +{ +namespace Wrapper +{ + +/** \class BoolParameter + * \brief This class represent a boolean parameter for the wrapper framework + * + * It is intended to replace the deprecated EmptyParameter + * + * \ingroup OTBApplicationEngine + */ +class OTBApplicationEngine_EXPORT BoolParameter + : public Parameter +{ +public: + /** Standard class typedef */ + typedef BoolParameter Self; + typedef Parameter Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(BoolParameter, Parameter); + + /** This parameter is ON/OFF switch, it always has a value */ + bool HasValue() const override + { + return true; + } + + bool GetValue() const; + + std::string GetValueAsString() const; + + void SetValue(bool state); + + void SetValue(const std::string & str); + +protected: + /** Constructor */ + BoolParameter(); + + /** Destructor */ + ~BoolParameter() override + {} + +private: + BoolParameter(const BoolParameter &) = delete; + void operator =(const BoolParameter&) = delete; + + bool m_Value; +}; + +} // end of namespace Wrapper +} // end of namespace otb + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h index 7978c5fb4f7a0345c123a0b8612196495cfafca1..cb34ef1e3ffe9cc583d4f67c2b3a1db4ba1c534f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h @@ -31,6 +31,8 @@ namespace Wrapper /** \class EmptyParameter * \brief This class represent an empty parameter for the wrapper framework (boolean value) * + * \deprecated in OTB 6.6, use BoolParameter instead + * * \ingroup OTBApplicationEngine */ class OTBApplicationEngine_EXPORT EmptyParameter diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 236411f8f21e8b185bed7aa514770bb19ca00b14..5776138606c07ad87371d00aa855f7864156be03 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -31,26 +31,6 @@ namespace otb { namespace Wrapper { -enum DefaultValueMode - { - /** - * This parameter has no default behaviour and should be set by - * the user. - */ - DefaultValueMode_UNKNOWN, - /** - * The default value of this parameter can be estimated from - * other parameters. - */ - DefaultValueMode_RELATIVE, - - /** - * The default value of this parameter is not depending on any - * other parameter. - */ - DefaultValueMode_ABSOLUTE - }; - /** \class Parameter * \brief This class represent a parameter for the wrapper framework @@ -114,20 +94,29 @@ public: /** Toogle the parameter mandatory flag */ itkBooleanMacro(Mandatory); - /** Set the parameter AutomaticValue flag */ - itkSetMacro(AutomaticValue, bool); + /** Set the parameter AutomaticValue flag (which is the opposite of UserValue)*/ + virtual void SetAutomaticValue(bool flag) + { + this->SetUserValue(!flag); + } /** Get the parameter AutomaticValue flag */ - itkGetConstMacro(AutomaticValue, bool); - - /** Toogle the parameter AutomaticValue flag */ - itkBooleanMacro(AutomaticValue); - - /** Set the default value mode */ - itkSetEnumMacro(DefaultValueMode, DefaultValueMode); - - /** Get the default value mode */ - itkGetEnumMacro(DefaultValueMode, DefaultValueMode); + virtual bool GetAutomaticValue() const + { + return !m_UserValue; + } + + /** Toogle ON the parameter AutomaticValue flag */ + void AutomaticValueOn() + { + this->SetAutomaticValue(true); + } + + /** Toogle OFF the parameter AutomaticValue flag */ + void AutomaticValueOff() + { + this->SetAutomaticValue(false); + } /** Set the user access level */ itkSetEnumMacro(UserLevel, UserLevel); @@ -199,20 +188,6 @@ public: return m_ChildrenList; } - /** Store the state of the check box relative to this parameter (TO - * BE MOVED to QtWrapper Model ) - */ - virtual bool IsChecked() const - { - return m_IsChecked; - } - - /** Modify the state of the checkbox relative to this parameter */ - virtual void SetChecked(const bool value) - { - m_IsChecked = value; - } - protected: /** Constructor */ Parameter() : @@ -222,12 +197,9 @@ protected: 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 ) + m_Root( this ) {} /** Destructor */ @@ -248,15 +220,9 @@ protected: /** True if activated (a mandatory parameter is always active) */ bool m_Active; - /** True if the value is set in user mode */ + /** True if the value is set in user mode (otherwise, it is an automatic value)*/ bool m_UserValue; - /** True if the application change the value of this parameter */ - bool m_AutomaticValue; - - /** Default value behaviour */ - DefaultValueMode m_DefaultValueMode; - UserLevel m_UserLevel; /** Default iotype mode */ @@ -268,9 +234,6 @@ protected: /** List of children parameters */ std::vector<Parameter::Pointer > m_ChildrenList; - /** Store the status of the checkbox */ - bool m_IsChecked; - private: Parameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index 8a31e1f2c45040b1a7c69334311bdbc762c4c2fa..a27e22508403dc4fed5069571f16991ea9a07310 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -58,7 +58,8 @@ typedef enum ParameterType_ComplexOutputImage, ParameterType_RAM, ParameterType_OutputProcessXML, - ParameterType_InputProcessXML + ParameterType_InputProcessXML, + ParameterType_Bool } ParameterType; typedef enum diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 858aaaf1afb8e41285b66348c6c1abc0578d1131..115c5a772bc146af0c87c8123920e90a4f33f1bf 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -56,6 +56,7 @@ set( OTBApplicationEngine_SRC otbWrapperStringListParameter.cxx otbWrapperAbstractParameterList.cxx otbWrapperParameterList.cxx + otbWrapperBoolParameter.cxx ) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d38ee1b3c8bb056854863e49179a493b..5c597e94d233d22461c20b69a7f81308c754472e 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -37,7 +37,7 @@ #include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" #include "otbWrapperParameterKey.h" - +#include "otbWrapperBoolParameter.h" #include "otbWrapperAddProcessToWatchEvent.h" @@ -65,7 +65,8 @@ Application::Application() m_Doclink(""), m_HaveInXML(true), m_HaveOutXML(true), - m_IsInXMLParsed(false) + m_IsInXMLParsed(false), + m_IsInPrivateDo(false) { // Don't call Init from the constructor, since it calls a virtual method ! m_Logger->SetName("Application.logger"); @@ -138,6 +139,11 @@ void Application::SetParameterInt(std::string parameter, int value, bool hasUser ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); paramChoice->SetValue(value); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramBool = dynamic_cast<BoolParameter*>(param); + paramBool->SetValue(static_cast<bool>(value)); + } this->SetParameterUserValue(parameter, hasUserValueFlag); } @@ -250,6 +256,11 @@ void Application::SetParameterString(std::string parameter, std::string value, b if ( !paramDown->SetFileName(value) ) otbAppLogCRITICAL( <<"Invalid XML parameter filename " << value <<"."); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); + paramDown->SetValue(value); + } else { otbAppLogWARNING( <<"This parameter can't be set using SetParameterString()."); @@ -293,8 +304,8 @@ void Application::SetParameterStringList(std::string parameter, std::vector<std: void Application::SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag) { - GetParameterByKey(parameter)->SetActive(value); this->SetParameterUserValue(parameter, hasUserValueFlag); + GetParameterByKey(parameter)->SetActive(value); } void Application::SetParameterUserValue(std::string paramKey, bool value) @@ -304,7 +315,14 @@ void Application::SetParameterUserValue(std::string paramKey, bool value) using Application::EnableParameter(); **/ EnableParameter(paramKey); - GetParameterByKey(paramKey)->SetUserValue(value); + if (m_IsInPrivateDo) + { + GetParameterByKey(paramKey)->SetUserValue(false); + } + else + { + GetParameterByKey(paramKey)->SetUserValue(value); + } } const Parameter* Application::GetParameterByKey(std::string name, bool follow) const @@ -320,7 +338,9 @@ void Application::Init() m_ParameterList = ParameterGroup::New(); //reset inXML parse checker in case if reinit-ing m_IsInXMLParsed = false; + m_IsInPrivateDo = true; this->DoInit(); + m_IsInPrivateDo = false; //rashad: global parameters. now used only for inxml and outxml if(this->GetHaveInXML()) @@ -352,7 +372,9 @@ void Application::UpdateParameters() } } } + m_IsInPrivateDo = true; this->DoUpdateParameters(); + m_IsInPrivateDo = false; } void Application::AfterExecuteAndWriteOutputs() @@ -387,7 +409,9 @@ int Application::Execute() itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->Initialize(); } + m_IsInPrivateDo = true; this->DoExecute(); + m_IsInPrivateDo = false; // Ensure that all output image parameter have called UpdateOutputInformation() for (auto it = paramList.begin(); it != paramList.end(); ++it) @@ -724,6 +748,10 @@ ParameterType Application::GetParameterType(std::string paramKey) const { type = ParameterType_InputProcessXML; } + else if (dynamic_cast<const BoolParameter*>(param)) + { + type = ParameterType_Bool; + } else { itkExceptionMacro(<< "Unknown parameter : " << paramKey); @@ -1007,6 +1035,16 @@ int Application::GetParameterInt(std::string parameter) ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); ret = paramChoice->GetValue(); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramBool = dynamic_cast<BoolParameter*>(param); + ret = static_cast<int>(paramBool->GetValue()); + } + else if (dynamic_cast<EmptyParameter*>(param)) + { + // This case is here for compatibility purpose with deprecated EmptyParameter + ret = static_cast<int>(this->IsParameterEnabled(parameter)); + } else { itkExceptionMacro(<<parameter << " parameter can't be casted to int"); @@ -1128,6 +1166,11 @@ std::string Application::GetParameterString(std::string parameter) InputProcessXMLParameter* paramDown = dynamic_cast<InputProcessXMLParameter*>(param); ret = paramDown->GetFileName(); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); + ret = paramDown->GetValueAsString(); + } else { itkExceptionMacro(<<parameter << " : parameter can't be casted to string"); @@ -1450,7 +1493,8 @@ std::string Application::GetParameterAsString(std::string paramKey) || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData || type == ParameterType_OutputImage || type == ParameterType_OutputVectorData || type == ParameterType_ListView || type == ParameterType_Choice - || type == ParameterType_OutputProcessXML || type == ParameterType_InputProcessXML ) + || type == ParameterType_OutputProcessXML || type == ParameterType_InputProcessXML + || type == ParameterType_Bool) { ret = this->GetParameterString( paramKey ); } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d34cb43676fb8faaa382091457f6fafe06d2fdf8 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx @@ -0,0 +1,81 @@ +/* + * 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 "otbWrapperBoolParameter.h" + +namespace otb +{ +namespace Wrapper +{ + +BoolParameter::BoolParameter() + : m_Value(false) +{} + +bool +BoolParameter::GetValue() const +{ + return m_Value; +} + +std::string +BoolParameter::GetValueAsString() const +{ + return std::string(m_Value?"true":"false"); +} + +void +BoolParameter::SetValue(bool state) +{ + if (m_Value != state) + { + m_Value = state; + this->Modified(); + } + this->SetActive(true); +} + +void +BoolParameter::SetValue(const std::string & str) +{ + std::string lowerStr; + // only strings less than 8 characters expected + lowerStr.reserve(8); + for (unsigned int i=0 ; i < std::min(8U,(unsigned int) str.size()) ; i++ ) + { + lowerStr.push_back(tolower(str[i])); + } + if (lowerStr == "1" || lowerStr == "on" || lowerStr == "true" || lowerStr == "yes") + { + this->SetValue(true); + } + else if (lowerStr == "0" || lowerStr == "off" || lowerStr == "false" || lowerStr == "no") + { + this->SetValue(false); + } + else + { + itkGenericExceptionMacro(<< "Wrong value for BoolParameter (" << str << ")," + " accepts: 0, 1, on, off, true, false, yes, no"); + } +} + +} // end of namespace Wrapper +} // end of namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx index 938936ebf64784d0287e9d5e4be25701e2c2c738..8287525aa66b9266a994486b49c613a4a8d9ae24 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx @@ -306,8 +306,9 @@ InputProcessXMLParameter::Read(Application::Pointer this_) } } - if ( type == ParameterType_OutputFilename || type == ParameterType_OutputVectorData || - type == ParameterType_String || type == ParameterType_Choice || type == ParameterType_RAM) + if (type == ParameterType_OutputFilename || type == ParameterType_OutputVectorData || + type == ParameterType_String || type == ParameterType_Choice || + type == ParameterType_RAM || type == ParameterType_Bool) { this_->SetParameterString(key, value); } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx index 493191677c554686770604ca734effe4017c3784..a4d4557c6d58dad4cdd47bec748822eac41d2ffd 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx @@ -50,7 +50,7 @@ void MapProjectionParametersHandler::AddMapProjectionParameters( Application::Po oss.str(""); oss <<key<<".utm" <<".northhem"; - app->AddParameter(ParameterType_Empty, oss.str(), "Northern Hemisphere"); + app->AddParameter(ParameterType_Bool, oss.str(), "Northern Hemisphere"); app->SetParameterDescription(oss.str(),"The transverse mercator projections are defined by their zone number as well as the hemisphere. Activate this parameter if your image is in the northern hemisphere."); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx index 5ba103723d9d93908d66f14330570e515f9caadd..cc2f69e995dc0cdcf1b7e83d4ffa267a8df64c15 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx @@ -235,7 +235,9 @@ OutputProcessXMLParameter::ParseGroup(const std::string& group) } else { - bool paramExists = m_Appli->HasUserValue(key) && m_Appli->IsParameterEnabled(key); + bool paramExists = m_Appli->HasUserValue(key) && + m_Appli->IsParameterEnabled(key) && + m_Appli->GetParameterRole(key) == Role_Input; if ( type == ParameterType_OutputProcessXML ) { paramExists = false; @@ -305,7 +307,7 @@ OutputProcessXMLParameter::ParseGroup(const std::string& group) type == ParameterType_Directory || type == ParameterType_InputImage || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData || type == ParameterType_Choice || type == ParameterType_OutputVectorData || - type == ParameterType_OutputFilename) + type == ParameterType_OutputFilename || type == ParameterType_Bool) { value = m_Appli->GetParameterString(key); } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx index 2ba9ba9307936fba2a190c054c050e69181c696c..9846f99ce4e471a557b30422e8735f483dbe73eb 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx @@ -40,6 +40,7 @@ #include "otbWrapperParameterKey.h" #include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" +#include "otbWrapperBoolParameter.h" #include "otb_boost_string_header.h" @@ -332,6 +333,10 @@ ParameterGroup::GetSelectedItems(std::string paramKey) { return ParameterType_InputProcessXML; } + else if (type == "Bool") + { + return ParameterType_Bool; + } else { std::cerr << "Cannot find parameter type code for type: " << type << std::endl; @@ -466,6 +471,11 @@ std::string ParameterGroup::GetParameterTypeAsString(ParameterType type) paramType = "InputProcessXML"; } break; + case ParameterType_Bool: + { + paramType = "Bool"; + } + break; default: { std::cerr << "Cannot find string version of parameter type" << std::endl; @@ -625,6 +635,11 @@ ParameterGroup::AddParameter(ParameterType type, std::string paramKey, std::stri newParam = InputProcessXMLParameter::New(); } break; + case ParameterType_Bool: + { + newParam = BoolParameter::New(); + } + break; } if (newParam.IsNull()) diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index cf70dc07b7bd8e50922a313f4bc6ff21ecaa973c..670bb484373bee1c0fa7c964c1d3b7b31002a266 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -435,7 +435,8 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() type == ParameterType_InputVectorData || type == ParameterType_OutputVectorData || type == ParameterType_RAM || - type == ParameterType_OutputProcessXML) // || type == ParameterType_InputProcessXML) + type == ParameterType_OutputProcessXML || + type == ParameterType_Bool) // || type == ParameterType_InputProcessXML) { // Single value parameter m_Application->SetParameterString(paramKey, values[0]); @@ -686,7 +687,7 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & { oss << "<int32> "; } - else if (type == ParameterType_Empty ) + else if (type == ParameterType_Empty || type == ParameterType_Bool) { oss << "<boolean> "; } diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..681ef9c6933b622487dd1599813b9e6f96ea4923 --- /dev/null +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h @@ -0,0 +1,66 @@ +/* + * 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 otbWrapperQtWidgetBoolParameter_h +#define otbWrapperQtWidgetBoolParameter_h + +#include <QtGui> +#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility +#include "otbWrapperBoolParameter.h" +#include "otbWrapperQtWidgetParameterBase.h" +#endif //tag=QT4-boost-compatibility + +namespace otb +{ +namespace Wrapper +{ + +/** \class QtWidgetBoolParameter + * \brief + * + * \ingroup OTBQtWidget + */ +class OTBQtWidget_EXPORT QtWidgetBoolParameter : public QtWidgetParameterBase +{ + Q_OBJECT + +public: + QtWidgetBoolParameter(BoolParameter*, QtWidgetModel*); + ~QtWidgetBoolParameter() ITK_OVERRIDE; + +public slots: + void SetValue( bool value ); + +private: + QtWidgetBoolParameter(const QtWidgetBoolParameter&) = delete; + void operator=(const QtWidgetBoolParameter&) = delete; + + void DoCreateWidget() ITK_OVERRIDE; + + void DoUpdateGUI() ITK_OVERRIDE; + + QToolButton *m_Button; +}; + + +} +} + +#endif diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h index db88ca9ace0243f4a10165b560e26dc2967b4869..86b0eeed42228ed64efe2be8a3e8f9c2af5e6ae9 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h @@ -33,6 +33,8 @@ namespace otb namespace Wrapper { +class QtWidgetParameterGroup; + /** \class QtWidgetParameterBase * \brief * @@ -41,12 +43,26 @@ namespace Wrapper class OTBQtWidget_EXPORT QtWidgetParameterBase : public QWidget { Q_OBJECT + friend class QtWidgetParameterGroup; public: QtWidgetParameterBase( Parameter *, QtWidgetModel * ); ~QtWidgetParameterBase() ITK_OVERRIDE; void CreateWidget(); + /** Store the state of the check box relative to this parameter + */ + virtual bool IsChecked() const + { + return m_IsChecked; + } + + /** Modify the state of the checkbox relative to this parameter */ + virtual void SetChecked(const bool value) + { + m_IsChecked = value; + } + public slots: void UpdateGUI(); virtual void SetActivationState( bool value ); @@ -77,6 +93,9 @@ private: QtWidgetModel * m_Model; Parameter * m_Param; + + /** Store the status of the checkbox */ + bool m_IsChecked; }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h index 3e3969739fa821ad30ed26666c5e019e89ea1746..da70434fbf7684fe17fd05c781a9f54bcf50f0ad 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h @@ -59,7 +59,7 @@ private: void DoUpdateGUI() ITK_OVERRIDE; - virtual void ProcessChild(Parameter * currentNode, bool status); + virtual void ProcessChild(QObject* currentNode, bool status); ParameterGroup::Pointer m_ParamList; diff --git a/Modules/Wrappers/QtWidget/src/CMakeLists.txt b/Modules/Wrappers/QtWidget/src/CMakeLists.txt index 28cb58c37691087555171daca7ab833814eed571..a366e0458e9376d11e445ce2f332786d1ad2bb6e 100644 --- a/Modules/Wrappers/QtWidget/src/CMakeLists.txt +++ b/Modules/Wrappers/QtWidget/src/CMakeLists.txt @@ -57,6 +57,7 @@ set(OTBQtWidget_SRC otbWrapperQtWidgetListEditWidget.cxx otbWrapperQtWidgetListEditItemModel.cxx otbWrapperQtWidgetParameterList.cxx + otbWrapperQtWidgetBoolParameter.cxx ) set(OTBQtWidget_MOC_HDR @@ -97,6 +98,7 @@ set(OTBQtWidget_MOC_HDR ../include/otbWrapperQtWidgetListEditWidget.h ../include/otbWrapperQtWidgetListEditItemModel.h ../include/otbWrapperQtWidgetParameterList.h + ../include/otbWrapperQtWidgetBoolParameter.h ) set( OTBQtWidget_FORMS diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..effe1fc5633d5541681928e1a2ce3f6667442129 --- /dev/null +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx @@ -0,0 +1,95 @@ +/* + * 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 "otbWrapperQtWidgetBoolParameter.h" + +namespace otb +{ +namespace Wrapper +{ + +QtWidgetBoolParameter::QtWidgetBoolParameter(BoolParameter* boolParam, QtWidgetModel* m) + : QtWidgetParameterBase(boolParam, m) +{ +} + +QtWidgetBoolParameter::~QtWidgetBoolParameter() +{ +} + +void QtWidgetBoolParameter::SetValue( bool value ) +{ + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(this->GetParam()); + assert(paramDown && "Not a BoolParameter"); + if (paramDown->GetValue() != value) + { + paramDown->SetValue(value); + + QString key( paramDown->GetKey() ); + emit ParameterChanged(key); + } +} + +void QtWidgetBoolParameter::DoUpdateGUI() +{ + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(this->GetParam()); + assert(paramDown && "Not a BoolParameter"); + if (paramDown->GetValue() != m_Button->isChecked()) + { + m_Button->setChecked(paramDown->GetValue()); + } + QString buttonText(paramDown->GetValue()?"On":"Off"); + if (m_Button->text() != buttonText) + { + m_Button->setText(buttonText); + } +} + +void QtWidgetBoolParameter::DoCreateWidget() +{ + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(0); + hLayout->setContentsMargins(0, 0, 0, 0); + + m_Button = new QToolButton; + m_Button->setCheckable(true); + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(this->GetParam()); + assert(paramDown && "Not a BoolParameter"); + if (paramDown->GetValue()) + { + m_Button->setText("On"); + m_Button->setChecked(true); + } + else + { + m_Button->setText("Off"); + } + + connect( m_Button, SIGNAL(toggled(bool)), this, SLOT(SetValue(bool)) ); + connect( m_Button, SIGNAL(toggled(bool)), GetModel(), SLOT(NotifyUpdate()) ); + + hLayout->addWidget(m_Button); + hLayout->addStretch(); + + this->setLayout(hLayout); +} + +} +} diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx index eb44e1a4ee8eca304b95e7e52f11a185c2560c0a..86789e4197d67cdf0848b673b9a4508740e4949b 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx @@ -26,7 +26,9 @@ namespace Wrapper { QtWidgetParameterBase::QtWidgetParameterBase(Parameter * param, QtWidgetModel* m) - : m_Model(m), m_Param(param) + : m_Model(m) + , m_Param(param) + , m_IsChecked( false ) { } @@ -89,7 +91,7 @@ void QtWidgetParameterBase::SetActivationState( bool value ) } this->setEnabled(value); - m_Param->SetChecked(value); + this->SetChecked(value); m_Param->SetActive(value); } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx index 89763c423741832b3c1e21f21ef144ff85690a22..f675050e2347ecbfea6604ee8bdbda458d5f08f3 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx @@ -50,6 +50,7 @@ #include "otbWrapperQtWidgetRAMParameter.h" #include "otbWrapperQtWidgetStringParameter.h" #include "otbWrapperQtWidgetStringListParameter.h" +#include "otbWrapperQtWidgetBoolParameter.h" namespace otb @@ -123,7 +124,7 @@ QtWidgetParameterFactory::CreateQtWidget( Parameter* param, QtWidgetModel* model CREATEWIDGET(InputVectorDataParameter, QtWidgetInputVectorDataParameter) CREATEWIDGET(OutputImageParameter, QtWidgetOutputImageParameter) CREATEWIDGET(OutputVectorDataParameter, QtWidgetOutputVectorDataParameter) - CREATEWIDGET(EmptyParameter, QtWidgetEmptyParameter) + CREATEWIDGET(BoolParameter, QtWidgetBoolParameter) CREATEWIDGET(ParameterGroup, QtWidgetParameterGroup) CREATEWIDGET(RAMParameter, QtWidgetRAMParameter) CREATEWIDGET(OutputProcessXMLParameter, QtWidgetOutputProcessXMLParameter) diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx index 12af047e282ec56f150656711ba4086c238ea647..b9ba4673cb1049c6ebccfced5e5e13774f5fbdba 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx @@ -141,10 +141,10 @@ void QtWidgetParameterGroup::DoCreateWidget() group->setChecked(false); // Update iteratively the children status - for (unsigned int idx = 0; idx < param->GetChildrenList().size(); ++idx) + for (auto child : specificWidget->children()) { // deactivate the children tree - this->ProcessChild(param->GetChildrenList()[idx], false); + this->ProcessChild(child, false); } } else @@ -176,33 +176,35 @@ void QtWidgetParameterGroup::SetActivationState( bool value ) this->setEnabled(value); // Update iteratively the children status - for (unsigned int idx = 0; idx < m_ParamList->GetChildrenList().size(); ++idx) + for (auto child : this->children() ) { - this->ProcessChild(m_ParamList->GetChildrenList()[idx], value); + this->ProcessChild(child, value); } } // Activate iteratively the children -void QtWidgetParameterGroup::ProcessChild(Parameter* currentNode, bool status) +void QtWidgetParameterGroup::ProcessChild(QObject* currentNode, bool status) { // Activate the current node if it was checked - if ( currentNode->IsChecked() && status) + QtWidgetParameterBase* widgetBase = dynamic_cast<QtWidgetParameterBase*>(currentNode); + if(widgetBase) { - currentNode->SetActive(status); - } + if ( widgetBase->IsChecked() && status) + { + widgetBase->GetParam()->SetActive(status); + } - // If the status is false (deactivating) deactivate all the children - // tree - if (!status) - { - currentNode->SetActive(status); + // If the status is false (deactivating) deactivate all the children + // tree + if (!status) + { + widgetBase->GetParam()->SetActive(status); + } } - unsigned int counter = 0; - while(counter < currentNode->GetChildrenList().size()) + for (auto child : currentNode->children() ) { - this->ProcessChild(currentNode->GetChildrenList()[counter], status); - ++counter; + this->ProcessChild(child, status); } } diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 3baf415d1a4ea63bd6e36959b9fd3391fc391ea0..88802af41a2805f1c0921814d7dd1a7f34bcc175 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -74,12 +74,6 @@ namespace otb { namespace Wrapper { - enum DefaultValueMode - { - DefaultValueMode_UNKNOWN, - DefaultValueMode_RELATIVE, - DefaultValueMode_ABSOLUTE - }; typedef enum { @@ -106,7 +100,8 @@ namespace Wrapper ParameterType_ComplexOutputImage, ParameterType_RAM, ParameterType_OutputProcessXML, - ParameterType_InputProcessXML + ParameterType_InputProcessXML, + ParameterType_Bool } ParameterType; typedef enum @@ -502,6 +497,7 @@ class ApplicationProxy(object): ParameterType_Empty : 'ParameterType_Empty', ParameterType_Choice : 'ParameterType_Choice', ParameterType_Group : 'ParameterType_Group', + ParameterType_Bool : 'ParameterType_Bool' }.get(parameter_type, 'ParameterType_UNKNOWN') def __str__(self): @@ -533,6 +529,8 @@ class ApplicationProxy(object): return self.SetParameterFloat(paramKey, value) elif paramType in [ParameterType_Empty]: return self.EnableParameter(paramKey) + elif paramType in [ParameterType_Bool]: + return self.SetParameterString(paramKey, str(value) ) elif paramType in [ParameterType_Group]: return ApplicationProxy(self, paramKey) elif paramType in [ParameterType_Choice]: @@ -567,6 +565,8 @@ class ApplicationProxy(object): return self.GetParameterFloat(paramKey) elif paramType in [ParameterType_Empty]: return self.IsParameterEnabled(paramKey) + elif paramType in [ParameterType_Bool]: + return bool(self.GetParameterInt(paramKey)) elif paramType in [ParameterType_Group, ParameterType_Choice]: return ApplicationProxy(self, paramKey) else: diff --git a/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py b/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py index 4cb17b6fe546d0c2ad2a97222d40e5eca83eae4b..c6cb4f3c4bad06845c8a3e9449f83174cbe35aca 100644 --- a/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py +++ b/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py @@ -84,12 +84,12 @@ def test(otb, argv): cm_assert(app.MAP.UTM.ZONE, 31) # 10 - bool type sub parameters of choice parameter get - app.DisableParameter('map.utm.northhem') + app.SetParameterInt('map.utm.northhem',0) cm_assert(app.MAP.UTM.NORTHHEM, False) # 11 - bool type sub parameters of choice parameter set app.MAP.UTM.NORTHHEM = True - cm_assert(True, app.IsParameterEnabled('map.utm.northhem') ) + cm_assert(True, app.GetParameterInt('map.utm.northhem') ) #12 - simple choice parameter set app.OUTPUTS.MODE = 'auto' @@ -128,7 +128,7 @@ def test(otb, argv): cm_assert(app.IsParameterEnabled('outputs.isotropic'), True) #21 - parameter bool get - app.DisableParameter('outputs.isotropic') + app.SetParameterInt('outputs.isotropic',0) cm_assert(False, app.OUTPUTS.ISOTROPIC) #Do not execute. we need LARGEINPUT. so we tried a small application