X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_PropManager.cpp;h=17ad00b5377db2cca95dc8b1cb81b9961af763e5;hb=aa941d4038c5880146ea98adc84e5d02fc729c49;hp=a1e2e6b03a03ee34b4ef6afdcdd6d483c599e413;hpb=d0dddc3ca2a60e5dd20432a407d6da23091e138e;p=modules%2Fshaper.git diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp index a1e2e6b03..17ad00b53 100644 --- a/src/Config/Config_PropManager.cpp +++ b/src/Config/Config_PropManager.cpp @@ -1,23 +1,52 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: Config_PropManager.cpp -// Created: 13 Aug 2014 -// Author: Vitaly SMETANNIKOV +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "Config_PropManager.h" +bool Config_PropManager::autoColorStatus = false; + std::vector 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, const std::string& theTitle, Config_Prop::PropType theType, - const std::string& theDefaultValue) + const std::string& theDefaultValue, + const std::string& theMin, + const std::string& theMax) { Config_Prop* aProp = findProp(theSection, theName); @@ -32,10 +61,15 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection, aProp->setType(theType); aProp->setTitle(theTitle); } + if (theMin != "") + aProp->setMin(theMin); + if (theMax != "") + aProp->setMax(theMax); } else { - aProp = new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue); - myProps.push_back(aProp); + aProp = + new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue, theMin, theMax); + props().push_back(aProp); } return aProp; } @@ -43,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; @@ -55,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); @@ -68,7 +104,8 @@ std::list Config_PropManager::getSections() // Return only non disabled sections std::list 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()); @@ -81,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); @@ -182,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, ".");