]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Remove default values from properties requests
authorvsv <vsv@opencascade.com>
Wed, 15 Mar 2017 07:18:32 +0000 (10:18 +0300)
committervsv <vsv@opencascade.com>
Wed, 15 Mar 2017 07:25:42 +0000 (10:25 +0300)
18 files changed:
src/Config/Config_PropManager.cpp
src/Config/Config_PropManager.h
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_PreviewPlanes.cpp
src/PartSet/PartSet_ResultSketchPrs.cpp
src/PartSet/PartSet_WidgetFeaturePointSelector.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/SketchPlugin_SketchEntity.h
src/SketchPlugin/SketchPlugin_Trim.cpp
src/XGUI/XGUI_CustomPrs.cpp

index 1928fbfc38ea8c5a5fef65735ec5f64fe69bb744..205f9b503973fd8269461cd89849114173bf7712 100644 (file)
@@ -13,6 +13,7 @@ bool stringToBoolean(const std::string& theInt);
 
 Config_Properties Config_PropManager::myProps;
 
+
 Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
                                               const std::string& theName,
                                               const std::string& theTitle,
@@ -89,8 +90,7 @@ Config_Properties Config_PropManager::getProperties(const std::string& theSectio
   return aRes;
 }
 
-std::string Config_PropManager::string(const std::string& theSection, const std::string& theName,
-                                       const std::string& theDefault)
+std::string Config_PropManager::string(const std::string& theSection, const std::string& theName)
 {
   Config_Properties aProps = getProperties(theSection);
   Config_Properties::const_iterator aIt;
@@ -99,36 +99,33 @@ std::string Config_PropManager::string(const std::string& theSection, const std:
     if (aProp->name() == theName)
       return aProp->value();
   }
-  return theDefault;
+  std::string aMsg = "Property " + theSection + ":" + theName + " is not registered";
+  throw aMsg.c_str();
 }
 
 std::vector<int> Config_PropManager::color(const std::string& theSection,
-                                           const std::string& theName,
-                                           const std::string& theDefault)
+                                           const std::string& theName)
 {
-  std::string aStr = string(theSection, theName, theDefault);
+  std::string aStr = string(theSection, theName);
   return stringToRGB(aStr);
 }
 
-int Config_PropManager::integer(const std::string& theSection, const std::string& theName,
-                                const std::string& theDefault)
+int Config_PropManager::integer(const std::string& theSection, const std::string& theName)
 {
-  std::string aStr = string(theSection, theName, theDefault);
+  std::string aStr = string(theSection, theName);
   return stringToInteger(aStr);
 }
 
-double Config_PropManager::real(const std::string& theSection, const std::string& theName,
-                                const std::string& theDefault)
+double Config_PropManager::real(const std::string& theSection, const std::string& theName)
 {
-  std::string aStr = string(theSection, theName, theDefault);
+  std::string aStr = string(theSection, theName);
   return stringToDouble(aStr);
 }
 
 bool Config_PropManager::boolean(const std::string& theSection,
-                                 const std::string& theName,
-                                 const std::string& theDefault)
+                                 const std::string& theName)
 {
-  std::string aStr = string(theSection, theName, theDefault);
+  std::string aStr = string(theSection, theName);
   return stringToBoolean(aStr);
 }
 
index bb7854b10fe675eb14be99a650c6ede6027a0160..8ae5cf84c07572b85ffe34c109716ee2eb055095 100644 (file)
@@ -48,24 +48,19 @@ class Config_PropManager
 
   //! Returns value of the property by its owner, section, and name
   CONFIG_EXPORT static std::string string(const std::string& theSection,
-                                          const std::string& theName,
-                                          const std::string& theDefault);
+                                          const std::string& theName);
   //! Returns color by given section and name as 3-element vector {r,g,b}.
   CONFIG_EXPORT static std::vector<int> color(const std::string& theSection,
-                                              const std::string& theName,
-                                              const std::string& theDefault);
+                                              const std::string& theName);
   //! Returns integer by given section and name
   CONFIG_EXPORT static int integer(const std::string& theSection,
-                                   const std::string& theName,
-                                   const std::string& theDefault);
+                                   const std::string& theName);
   //! Returns real by given section and name
   CONFIG_EXPORT static double real(const std::string& theSection,
-                                   const std::string& theName,
-                                   const std::string& theDefault);
+                                   const std::string& theName);
   //! Returns boolean by given section and name
   CONFIG_EXPORT static bool boolean(const std::string& theSection,
-                                   const std::string& theName,
-                                   const std::string& theDefault);
+                                   const std::string& theName);
 
  private:
   CONFIG_EXPORT static Config_Properties myProps; ///< List of all stored properties
index d414192368b6c4ffd25fb208e8b4cab864f14f6a..dc305d29ee3a8c3889ce4c45e3004800d845fdfe 100644 (file)
@@ -139,8 +139,7 @@ bool ConstructionPlugin_Plane::customisePresentation(ResultPtr theResult, AISObj
     }
   }
   if (aColor.empty())
-    aColor = Config_PropManager::color("Visualization", "construction_plane_color",
-                                       ConstructionPlugin_Plane::DEFAULT_COLOR());
+    aColor = Config_PropManager::color("Visualization", "construction_plane_color");
 
   bool isCustomized = false;
   if (aColor.size() == 3)
@@ -167,8 +166,7 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByGeneralEquation
            aC = anAttrC->value(), aD = anAttrD->value();
     std::shared_ptr<GeomAPI_Pln> aPlane =
       std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
-    std::string kDefaultPlaneSize = "200";
-    double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size", kDefaultPlaneSize);
+    double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
     aSize *= 4.;
     aPlaneFace = GeomAlgoAPI_FaceBuilder::squareFace(aPlane, aSize);
   }
index 6c9fe61b90252255cf3b005b5125f641c1e9234f..73f87251a0619a423a880b5a3fff0893277c84f0 100644 (file)
@@ -514,11 +514,9 @@ bool ModelHighAPI_Dumper::isDefaultDeflection(const ResultPtr& theResult) const
     }
   }
   if (isConstruction)
-    aDefault = Config_PropManager::real("Visualization", "construction_deflection",
-                                        ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+    aDefault = Config_PropManager::real("Visualization", "construction_deflection");
   else
-    aDefault = Config_PropManager::real("Visualization", "body_deflection",
-                                        ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+    aDefault = Config_PropManager::real("Visualization", "body_deflection");
 
   return fabs(aCurrent - aDefault) < 1.e-12;
 }
index 8a671f0bbf123fbfd3b78701c1a076da78ba1ebc..dc3187868b5b3c4cefe1219b152dca959f6531ea 100755 (executable)
@@ -412,20 +412,17 @@ void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
 
   double aDeflection;
   if (isConstruction)
-    aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
-                                           ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+    aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
   else
-    aDeflection = Config_PropManager::real("Visualization", "body_deflection",
-                                           ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+    aDeflection = Config_PropManager::real("Visualization", "body_deflection");
 
   theDrawer->SetDeviationCoefficient(aDeflection);
 }
 
 Quantity_Color color(const std::string& theSection,
-                     const std::string& theName,
-                     const std::string& theDefault)
+                     const std::string& theName)
 {
-  std::vector<int> aColor = Config_PropManager::color(theSection, theName, theDefault);
+  std::vector<int> aColor = Config_PropManager::color(theSection, theName);
   return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
 }
 
index 0e1c428ff4b451b192029c35c5e44d76952b7896..1d9d2118c685af95368d01c80bf3d3a67b3bc420 100755 (executable)
@@ -177,11 +177,9 @@ MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theSha
 /// Obtains the color from the property manager and converts it to the OCCT color
 /// \param theSection a property section
 /// \param theName a property item name
-/// \param theDefault a default color value
 /// \return quantity color
 MODULEBASE_EXPORT Quantity_Color color(const std::string& theSection,
-                                       const std::string& theName,
-                                       const std::string& theDefault);
+                                       const std::string& theName);
 
 /// Returns the object from the attribute
 /// \param theObj an object
index 0235e1e5d97ab755a201e7347248976ddf1622ad..cc52284cca9e8e51c1452c7cadf4bd56adfa6603 100755 (executable)
@@ -244,16 +244,13 @@ Quantity_Color PartSet_CustomPrs::getShapeColor(
   Quantity_Color aColor;
   switch(theFlag) {
     case ModuleBase_IModule::CustomizeArguments:
-      aColor = ModuleBase_Tools::color("Visualization", "operation_parameter_color",
-                                       OPERATION_PARAMETER_COLOR());
+      aColor = ModuleBase_Tools::color("Visualization", "operation_parameter_color");
     break;
     case ModuleBase_IModule::CustomizeResults:
-      aColor = ModuleBase_Tools::color("Visualization", "operation_result_color",
-                                       OPERATION_RESULT_COLOR());
+      aColor = ModuleBase_Tools::color("Visualization", "operation_result_color");
     break;
     case ModuleBase_IModule::CustomizeHighlightedObjects:
-      aColor = ModuleBase_Tools::color("Visualization", "operation_highlight_color",
-                                       OPERATION_HIGHLIGHT_COLOR());
+      aColor = ModuleBase_Tools::color("Visualization", "operation_highlight_color");
     break;
     default:
     break;
index 0d8417d63b04a4bdb38308613e949b1fd7f2ebbe..876130044b1ac805dc6fb840ecc6a2c4a46e42f1 100755 (executable)
@@ -38,8 +38,7 @@ bool PartSet_OverconstraintListener::isConflictingObject(const ObjectPtr& theObj
 
 void PartSet_OverconstraintListener::getConflictingColor(std::vector<int>& theColor)
 {
-  Quantity_Color aColor = ModuleBase_Tools::color("Visualization", "sketch_overconstraint_color",
-                                                  SKETCH_OVERCONSTRAINT_COLOR);
+  Quantity_Color aColor = ModuleBase_Tools::color("Visualization", "sketch_overconstraint_color");
   theColor.push_back(aColor.Red()*255.);
   theColor.push_back(aColor.Green()*255.);
   theColor.push_back(aColor.Blue()*255.);
index 344f20ed9782150e08c95f572a50c3f22e9d1637..93084a00797118bad6538a87efd0f8978a6404c2 100755 (executable)
@@ -104,13 +104,16 @@ void PartSet_PreviewPlanes::showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop)
     std::shared_ptr<GeomAPI_Dir> aXZDir(new GeomAPI_Dir(0, -1, 0));
     std::shared_ptr<GeomAPI_Dir> aXYDir(new GeomAPI_Dir(0, 0, 1));
 
-    std::vector<int> aYZRGB, aXZRGB, aXYRGB;
-    aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color",
-                                                        YZ_PLANE_COLOR);
-    aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color",
-                                                        XZ_PLANE_COLOR);
-    aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color",
-                                                        XY_PLANE_COLOR);
+    std::vector<int> aYZRGB(3, 0), aXZRGB(3, 0), aXYRGB(3, 0);
+#ifdef SET_PLANES_COLOR_IN_PREFERENCES
+    aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color");
+    aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color");
+    aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color");
+#else
+    aYZRGB[0] = 225;
+    aXZRGB[1] = 225;
+    aXYRGB[2] = 225;
+#endif
     int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]};
     int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]};
     int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]};
@@ -130,12 +133,12 @@ AISObjectPtr PartSet_PreviewPlanes::createPreviewPlane(std::shared_ptr<GeomAPI_P
                                                        std::shared_ptr<GeomAPI_Dir> theNorm,
                                                        const int theRGB[3])
 {
-  double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size", PLANE_SIZE);
+  double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
   std::shared_ptr<GeomAPI_Shape> aFace =
     GeomAlgoAPI_FaceBuilder::squareFace(theOrigin, theNorm, aSize);
   AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject());
   aAIS->createShape(aFace);
-  aAIS->setWidth(Config_PropManager::integer(SKETCH_TAB_NAME, "planes_thickness", SKETCH_WIDTH));
+  aAIS->setWidth(Config_PropManager::integer(SKETCH_TAB_NAME, "planes_thickness"));
   aAIS->setColor(theRGB[0], theRGB[1], theRGB[2]);
   return aAIS;
 }
index 6b562be08137f2cc6fc54d67c987494c20c999bc..fc8700134024d597d5fd5ad4e3552b709a792c9b 100755 (executable)
@@ -166,8 +166,7 @@ void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)
     debugInfo(aComp, TopAbs_FACE); // 2
 #endif
     Set(aComp);
-    double aBodyDefDeflection = Config_PropManager::real("Visualization", "body_deflection",
-                                                         ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+    double aBodyDefDeflection = Config_PropManager::real("Visualization", "body_deflection");
     Attributes()->SetDeviationCoefficient(aBodyDefDeflection);
     aShapeIsChanged = true;
   }
index 50d0ea0813608042e5df78e3b22bbc9c180d73a0..d93b666ca483dbdd038b84938b5e40b1a89302b6 100644 (file)
@@ -76,8 +76,7 @@ bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActi
   Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle();
   if (toActivate) {
     std::vector<int> aColors;
-    aColors = Config_PropManager::color("Visualization", "sketch_entity_color",
-                                       SKETCH_ENTITY_COLOR);
+  aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
     aColor = Quantity_Color(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255.,
                             Quantity_TOC_RGB);
     myHighlightColor = aHStyle->Color();
index 1daff12aed5978e8391487851d8c945011b30609..bdf32db5416f40a1a99098b50d5841fd250083f1 100644 (file)
@@ -307,7 +307,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
 
     // Rotate view if the sketcher plane is selected only from preview planes
     // Preview planes are created only if there is no any shape
-    bool aRotate = Config_PropManager::boolean(SKETCH_TAB_NAME, "rotate_to_plane", "false");
+    bool aRotate = Config_PropManager::boolean(SKETCH_TAB_NAME, "rotate_to_plane");
     if (aRotate) {
       myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aTwist);
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
index c2d28d3e5f5fee68c9b02916c972bfd17e8f738c..3319be80e6a18e1e155adc9c66675d47d1fddb6a 100644 (file)
@@ -259,8 +259,7 @@ AISObjectPtr SketchPlugin_Arc::getAISObject(AISObjectPtr thePrevious)
         if (!anAIS)
           anAIS = AISObjectPtr(new GeomAPI_AISObject);
         anAIS->createShape(aCompound);
-        double aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
-                                             ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+        double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
         anAIS->setDeflection(aDeflection);
         anAIS->setWidth(3);
         return anAIS;
index afc2536ba8f0249b0345a1ea4d7c423e49a86a12..305aba0bbbb1380c9993748e3745169361950742 100755 (executable)
@@ -362,14 +362,12 @@ AISObjectPtr SketchPlugin_ConstraintSplit::getAISObject(AISObjectPtr thePrevious
       double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
       int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
       if (isConstruction) {
-        aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color",
-                                           SKETCH_AUXILIARY_COLOR);
+        aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
         aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
         aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
       }
       else {
-        aColor = Config_PropManager::color("Visualization", "sketch_entity_color",
-                                            SKETCH_ENTITY_COLOR);
+        aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
       }
       anAIS->setColor(aColor[0], aColor[1], aColor[2]);
       anAIS->setWidth(aWidth + 1);
index 2666bb80785685954ac21d29142f1de7197b51b8..8ad7d8b453ab1e6e3adc2c7aadda609996a60af3 100644 (file)
 #include <GeomDataAPI_Dir.h>
 #include <list>
 
-#define YZ_PLANE_COLOR "225,0,0"
-#define XZ_PLANE_COLOR "0,225,0"
-#define XY_PLANE_COLOR "0,0,225"
+#ifdef SET_PLANES_COLOR_IN_PREFERENCES
+  #define YZ_PLANE_COLOR "225,0,0"
+  #define XZ_PLANE_COLOR "0,225,0"
+  #define XY_PLANE_COLOR "0,0,225"
+#endif
 
 /**\class SketchPlugin_Sketch
  * \ingroup Plugins
index dd7c0d36e805552e1c98da47747de8096d396545..d9f2cec43804291ae4d1bdc9476da88f2542e082 100644 (file)
@@ -115,7 +115,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
       std::string aSection, aName, aDefault;
       theResult->colorConfigInfo(aSection, aName, aDefault);
       std::vector<int> aColor;
-      aColor = Config_PropManager::color(aSection, aName, aDefault);
+      aColor = Config_PropManager::color(aSection, aName);
       thePrs->setColor(aColor[0], aColor[1], aColor[2]);
     }
 
@@ -133,16 +133,13 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
                                     data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
     bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
     if (isConstruction) {
-      aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color",
-                                         SKETCH_AUXILIARY_COLOR);
+      aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
     }
     else if (isExternal()) {
-      aColor = Config_PropManager::color("Visualization", "sketch_external_color",
-                                        SKETCH_EXTERNAL_COLOR);
+      aColor = Config_PropManager::color("Visualization", "sketch_external_color");
     }
     else {
-      aColor = Config_PropManager::color("Visualization", "sketch_entity_color",
-                                          SKETCH_ENTITY_COLOR);
+      aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
     }
     if (!aColor.empty()) {
       thePrs->setColor(aColor[0], aColor[1], aColor[2]);
index d989afb3115b8666262fca9687f10512fef8c7f3..7373e34af0a530b7e28edda53149fe46d0e671e0 100644 (file)
@@ -371,8 +371,7 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
 
     bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
     std::vector<int> aColor;
-    aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color",
-                                        OPERATION_REMOVE_FEATURE_COLOR());
+          aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
     double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
     int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
     if (isConstruction) {
index f4690749783f850042892a955f0ab75a80f5aab2..4044bc806bde38983a3fecd6439f4529055c0f2f 100644 (file)
@@ -65,13 +65,13 @@ void XGUI_CustomPrs::getDefaultColor(ObjectPtr theObject, const bool isEmptyColo
     std::string aSection, aName, aDefault;
     theObject->colorConfigInfo(aSection, aName, aDefault);
     if (!aSection.empty() && !aName.empty()) {
-      theColor = Config_PropManager::color(aSection, aName, aDefault);
+      theColor = Config_PropManager::color(aSection, aName);
     }
   }
   if (!isEmptyColorValid && theColor.empty()) {
     // all AIS objects, where the color is not set, are in black.
     // The color should be defined in XML or set in the attribute
-    theColor = Config_PropManager::color("Visualization", "object_default_color", "#000000");
+    theColor = Config_PropManager::color("Visualization", "object_default_color");
     Events_InfoMessage("XGUI_CustomPrs",
       "A default color is not defined in the preferences for this kind of result").send();
   }
@@ -97,11 +97,9 @@ double XGUI_CustomPrs::getDefaultDeflection(const ObjectPtr& theObject)
       }
     }
     if (isConstruction)
-      aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
-                                             ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+      aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
     else
-      aDeflection = Config_PropManager::real("Visualization", "body_deflection",
-                                             ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+      aDeflection = Config_PropManager::real("Visualization", "body_deflection");
   }
   return aDeflection;
 }