From: vsv Date: Wed, 15 Mar 2017 07:18:32 +0000 (+0300) Subject: Remove default values from properties requests X-Git-Tag: V_2.7.0~227^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de93e11325cc65d1067e0c3484cbb5c836bdcde6;p=modules%2Fshaper.git Remove default values from properties requests --- diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp index 1928fbfc3..205f9b503 100644 --- a/src/Config/Config_PropManager.cpp +++ b/src/Config/Config_PropManager.cpp @@ -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 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); } diff --git a/src/Config/Config_PropManager.h b/src/Config/Config_PropManager.h index bb7854b10..8ae5cf84c 100644 --- a/src/Config/Config_PropManager.h +++ b/src/Config/Config_PropManager.h @@ -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 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 diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index d41419236..dc305d29e 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -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 ConstructionPlugin_Plane::createByGeneralEquation aC = anAttrC->value(), aD = anAttrD->value(); std::shared_ptr aPlane = std::shared_ptr(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); } diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 6c9fe61b9..73f87251a 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 8a671f0bb..dc3187868 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -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 aColor = Config_PropManager::color(theSection, theName, theDefault); + std::vector aColor = Config_PropManager::color(theSection, theName); return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB); } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 0e1c428ff..1d9d2118c 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -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 diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index 0235e1e5d..cc52284cc 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -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; diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index 0d8417d63..876130044 100755 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -38,8 +38,7 @@ bool PartSet_OverconstraintListener::isConflictingObject(const ObjectPtr& theObj void PartSet_OverconstraintListener::getConflictingColor(std::vector& 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.); diff --git a/src/PartSet/PartSet_PreviewPlanes.cpp b/src/PartSet/PartSet_PreviewPlanes.cpp index 344f20ed9..93084a007 100755 --- a/src/PartSet/PartSet_PreviewPlanes.cpp +++ b/src/PartSet/PartSet_PreviewPlanes.cpp @@ -104,13 +104,16 @@ void PartSet_PreviewPlanes::showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop) std::shared_ptr aXZDir(new GeomAPI_Dir(0, -1, 0)); std::shared_ptr aXYDir(new GeomAPI_Dir(0, 0, 1)); - std::vector 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 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 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 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; } diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index 6b562be08..fc8700134 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.cpp +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -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; } diff --git a/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp b/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp index 50d0ea081..d93b666ca 100644 --- a/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp +++ b/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp @@ -76,8 +76,7 @@ bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActi Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle(); if (toActivate) { std::vector 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(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 1daff12ae..bdf32db54 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -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(myWorkshop->module()); diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index c2d28d3e5..3319be80e 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -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; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index afc2536ba..305aba0bb 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -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); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 2666bb807..8ad7d8b45 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -20,9 +20,11 @@ #include #include -#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 diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index dd7c0d36e..d9f2cec43 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -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 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]); diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index d989afb31..7373e34af 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -371,8 +371,7 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious) bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value(); std::vector 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) { diff --git a/src/XGUI/XGUI_CustomPrs.cpp b/src/XGUI/XGUI_CustomPrs.cpp index f46907497..4044bc806 100644 --- a/src/XGUI/XGUI_CustomPrs.cpp +++ b/src/XGUI/XGUI_CustomPrs.cpp @@ -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; }