X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_SketchEntity.h;h=a29b09695f9772966e508297f519b57fed08d151;hb=3a5afc79fc52a9ab688f830ab0d173e492b0ec7e;hp=20f1e46f732205e98545e914308135dc613ef898;hpb=a8d47776cf43a5535c262115d529e2f9f445cef3;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index 20f1e46f7..a29b09695 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -54,6 +54,30 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC return MY_COPY_ID; } + /// Width of the auxiliary line + inline static const double SKETCH_LINE_WIDTH_AUXILIARY() + { + return 2; + } + + /// Width of the line + inline static const double SKETCH_LINE_WIDTH() + { + return 3; + } + + /// Style of the auxiliary line + inline static const int SKETCH_LINE_STYLE_AUXILIARY() + { + return 3; + } + + /// Style of the line + inline static const int SKETCH_LINE_STYLE() + { + return 0; + } + /// Request for initialization of data model of the feature: adding all attributes virtual void initAttributes(); @@ -62,7 +86,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC { AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID()); if (aAttr) - return aAttr->context().get() != NULL; + return aAttr->context().get() != NULL && !aAttr->isInvalid(); return false; } @@ -80,7 +104,22 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theDefaultPrs) { - bool isCustomized = false; + /// Store previous color values of the presentation to check it after setting specific entity + /// color. Default color is set into presentation to have not modified isCustomized state + /// after default customize prs is completed. + std::vector aPrevColor; + aPrevColor.resize(3); + thePrs->getColor(aPrevColor[0], aPrevColor[1], aPrevColor[2]); + if (theResult.get()) { + std::string aSection, aName, aDefault; + theResult->colorConfigInfo(aSection, aName, aDefault); + std::vector aColor; + aColor = Config_PropManager::color(aSection, aName, aDefault); + thePrs->setColor(aColor[0], aColor[1], aColor[2]); + } + + bool isCustomized = theDefaultPrs.get() != NULL && + theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs); int aShapeType = thePrs->getShapeType(); // a compound is processed like the edge because the arc feature uses the compound for presentable AIS if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/) @@ -103,17 +142,20 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC aColor = Config_PropManager::color("Visualization", "sketch_entity_color", SKETCH_ENTITY_COLOR); } - if (!aColor.empty()) - isCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]) || isCustomized; + if (!aColor.empty()) { + thePrs->setColor(aColor[0], aColor[1], aColor[2]); + for (int i = 0; i < 3 && !isCustomized; i++) + isCustomized = aColor[i] != aPrevColor[i]; + } if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound if (isConstruction) { - isCustomized = thePrs->setWidth(1) || isCustomized; - isCustomized = thePrs->setLineStyle(3) || isCustomized; + isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized; + isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized; } else { - isCustomized = thePrs->setWidth(3) || isCustomized; - isCustomized = thePrs->setLineStyle(0) || isCustomized; + isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized; + isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized; } } else if (aShapeType == 7) { // otherwise this is a vertex