Config_Properties Config_PropManager::myProps;
+
Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
const std::string& theName,
const std::string& theTitle,
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;
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);
}
//! 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
}
}
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)
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);
}
}
}
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;
}
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);
}
/// 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
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;
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.);
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]};
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;
}
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;
}
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();
// 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());
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;
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);
#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
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]);
}
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]);
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) {
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();
}
}
}
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;
}