Salome HOME
projects
/
modules
/
shaper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
crash fix: mirror (line, axis of sketch), select with rectangle, delete
[modules/shaper.git]
/
src
/
Config
/
Config_PropManager.cpp
diff --git
a/src/Config/Config_PropManager.cpp
b/src/Config/Config_PropManager.cpp
index c296cc864772f6b0c66a95cc8bd7b8d07f47898d..ad5ceca9b779bb2a0b0c3865c6625219646e1b86 100644
(file)
--- a/
src/Config/Config_PropManager.cpp
+++ b/
src/Config/Config_PropManager.cpp
@@
-1,3
+1,5
@@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
// File: Config_PropManager.cpp
// Created: 13 Aug 2014
// Author: Vitaly SMETANNIKOV
// File: Config_PropManager.cpp
// Created: 13 Aug 2014
// Author: Vitaly SMETANNIKOV
@@
-7,25
+9,33
@@
std::vector<int> stringToRGB(const std::string& theColor);
int stringToInteger(const std::string& theInt);
double stringToDouble(const std::string& theDouble);
std::vector<int> stringToRGB(const std::string& theColor);
int stringToInteger(const std::string& theInt);
double stringToDouble(const std::string& theDouble);
+bool stringToBoolean(const std::string& theInt);
Config_Properties Config_PropManager::myProps;
Config_Properties Config_PropManager::myProps;
-
bool
Config_PropManager::registerProp(const std::string& theSection, const std::string& theName,
- const std::string& theTitle, Config_Prop::PropType theType,
-
const std::string& the
Value)
+
Config_Prop*
Config_PropManager::registerProp(const std::string& theSection, const std::string& theName,
+
const std::string& theTitle, Config_Prop::PropType theType,
+
const std::string& theDefault
Value)
{
Config_Prop* aProp = findProp(theSection, theName);
{
Config_Prop* aProp = findProp(theSection, theName);
+
if (aProp) {
if (aProp) {
+ if (aProp->value() == "") {
+ aProp->setValue(theDefaultValue);
+ }
+ if (aProp->defaultValue() == "") {
+ aProp->setDefaultValue(theDefaultValue);
+ }
if (aProp->type() == Config_Prop::Disabled) {
aProp->setType(theType);
aProp->setTitle(theTitle);
if (aProp->type() == Config_Prop::Disabled) {
aProp->setType(theType);
aProp->setTitle(theTitle);
- return true;
}
}
- return false;
}
}
- aProp = new Config_Prop(theSection, theName, theTitle, theType, theValue);
- myProps.push_back(aProp);
- return true;
+ else {
+ aProp = new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue);
+ myProps.push_back(aProp);
+ }
+ return aProp;
}
Config_Prop* Config_PropManager::findProp(const std::string& theSection, const std::string& theName)
}
Config_Prop* Config_PropManager::findProp(const std::string& theSection, const std::string& theName)
@@
-112,6
+122,14
@@
double Config_PropManager::real(const std::string& theSection, const std::string
return stringToDouble(aStr);
}
return stringToDouble(aStr);
}
+bool Config_PropManager::boolean(const std::string& theSection,
+ const std::string& theName,
+ const std::string& theDefault)
+{
+ std::string aStr = string(theSection, theName, theDefault);
+ return stringToBoolean(aStr);
+}
+
std::vector<int> stringToRGB(const std::string& theColor)
{
std::vector<int> aRes(3);
std::vector<int> stringToRGB(const std::string& theColor)
{
std::vector<int> aRes(3);
@@
-164,3
+182,8
@@
double stringToDouble(const std::string& theDouble)
char* p;
return strtod(theDouble.c_str(), &p);
}
char* p;
return strtod(theDouble.c_str(), &p);
}
+
+bool stringToBoolean(const std::string& theBoolean)
+{
+ return theBoolean == "true";
+}