Hugin trunk 0.1
Loading...
Searching...
No Matches
StitcherOptions.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
9/* This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this software. If not, see
21 * <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#include "StitcherOptions.h"
26#include "hugin_utils/utils.h"
27
28namespace HuginBase
29{
30namespace Nona
31{
32
33bool GetAdvancedOption(const AdvancedOptions& opts, const std::string& name, const bool defaultValue)
34{
35 AdvancedOptions::const_iterator it = opts.find(name);
36 if (it != opts.end())
37 {
38 //option is stored
39 const std::string value(it->second);
40 if (value == "true" || value == "1")
41 {
42 return true;
43 }
44 return false;
45 }
46 else
47 {
48 return defaultValue;
49 };
50};
51
52std::string GetAdvancedOption(const AdvancedOptions& opts, const std::string& name, const std::string& defaultValue)
53{
54 AdvancedOptions::const_iterator it = opts.find(name);
55 if (it != opts.end())
56 {
57 //option is stored
58 return it->second;
59 }
60 else
61 {
62 return defaultValue;
63 };
64};
65
66float GetAdvancedOption(const AdvancedOptions& opts, const std::string& name, const float defaultValue)
67{
68 AdvancedOptions::const_iterator it = opts.find(name);
69 if (it != opts.end())
70 {
71 //option is stored
72 double value;
73 if (hugin_utils::stringToDouble(it->second, value))
74 {
75 return static_cast<float>(value);
76 }
77 else
78 {
79 return defaultValue;
80 };
81 }
82 else
83 {
84 return defaultValue;
85 };
86};
87
88void SetAdvancedOption(AdvancedOptions& opts, const std::string& name, const bool value)
89{
90 if (value)
91 {
92 opts[name] = "true";
93 }
94 else
95 {
96 opts[name] = "false";
97 };
98};
99
100void SetAdvancedOption(AdvancedOptions& opts, const std::string& name, const std::string& value)
101{
102 opts[name] = value;
103};
104
105void SetAdvancedOption(AdvancedOptions& opts, const std::string& name, const float value)
106{
107 opts[name] = hugin_utils::doubleToString(value);
108};
109
110} // namespace Nona
111} // namespace HuginBase
Helper class for storing different options.
std::map< std::string, std::string > AdvancedOptions
void SetAdvancedOption(AdvancedOptions &opts, const std::string &name, const bool value)
store the option with name in AdvancedOptions
bool GetAdvancedOption(const AdvancedOptions &opts, const std::string &name, const bool defaultValue)
check if given option is saved and return its boolean value, otherwise return defaultValue
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition wxcms.cpp:39
std::string doubleToString(double d, int digits)
convert a double to a string, suitable for display within a GUI.
Definition utils.cpp:228
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
Definition utils.h:114
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41