Salome HOME
updated copyright message
[modules/shaper.git] / src / Config / Config_PropManager.cpp
index 4f6530dd38ee216084b6a5e8f87d2b70cb6d22f8..480c1cdaea5f27ec6753c62d8fb30092719da45d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "Config_PropManager.h"
 
+bool Config_PropManager::autoColorStatus = false;
+
 std::vector<int> stringToRGB(const std::string& theColor);
 int stringToInteger(const std::string& theInt);
 bool stringToBoolean(const std::string& theInt);
 
-Config_Properties Config_PropManager::myProps;
+Config_Properties& Config_PropManager::props() {
+  static Config_Properties* confProps = new Config_Properties();
+  return *confProps;
+}
 
+bool Config_PropManager::getAutoColorStatus()
+{
+    return Config_PropManager::autoColorStatus;
+}
+
+void Config_PropManager::setAutoColorStatus(const bool theValue)
+{
+    Config_PropManager::autoColorStatus = theValue;
+}
 
 Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
                                               const std::string& theName,
@@ -48,13 +61,15 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
       aProp->setType(theType);
       aProp->setTitle(theTitle);
     }
-    aProp->setMin(theMin);
-    aProp->setMax(theMax);
+    if (theMin != "")
+      aProp->setMin(theMin);
+    if (theMax != "")
+      aProp->setMax(theMax);
   }
   else {
     aProp =
       new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue, theMin, theMax);
-    myProps.push_back(aProp);
+    props().push_back(aProp);
   }
   return aProp;
 }
@@ -62,7 +77,8 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
 Config_Prop* Config_PropManager::findProp(const std::string& theSection, const std::string& theName)
 {
   Config_Properties::const_iterator aIt;
-  for (aIt = myProps.cbegin(); aIt != myProps.cend(); ++aIt) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
     Config_Prop* aProp = (*aIt);
     if ((aProp->section() == theSection) && (aProp->name() == theName))
       return aProp;
@@ -74,7 +90,8 @@ Config_Properties Config_PropManager::getProperties()
 {
   Config_Properties aRes;
   Config_Properties::const_iterator aIt;
-  for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
     Config_Prop* aProp = (*aIt);
     if (aProp->type() != Config_Prop::Disabled)
       aRes.push_back(aProp);
@@ -87,7 +104,8 @@ std::list<std::string> Config_PropManager::getSections()
   // Return only non disabled sections
   std::list<std::string> aSections;
   Config_Properties::const_iterator aIt;
-  for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
     const Config_Prop* aProp = (*aIt);
     if (aProp->type() != Config_Prop::Disabled)
       aSections.push_back(aProp->section());
@@ -100,7 +118,8 @@ Config_Properties Config_PropManager::getProperties(const std::string& theSectio
 {
   Config_Properties aRes;
   Config_Properties::iterator aIt;
-  for (aIt = myProps.begin(); aIt != myProps.end(); aIt++) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.begin(); aIt != aProps.end(); aIt++) {
     Config_Prop* aProp = (*aIt);
     if ((aProp->section() == theSection) && (aProp->type() != Config_Prop::Disabled))
       aRes.push_back(aProp);
@@ -201,7 +220,7 @@ double Config_PropManager::stringToDouble(const std::string& theDouble)
   // change locale and convert "," to "." if exists
   std::string aCurLocale = setlocale(LC_NUMERIC, 0);
   setlocale(LC_NUMERIC, "C");
-  int dotpos = (int)aStr.find(',');
+  size_t dotpos = aStr.find(',');
   if (dotpos != std::string::npos)
     aStr.replace(dotpos, 1, ".");