X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_SketchEntity.h;h=8662602b6611c43a92f37997f07ae306c5d53f05;hb=3f1a42a51c7de1911c75453ff7134593d7d2c6b1;hp=489d233455a26c77aa803488d1d79d933faff6bb;hpb=a21c6f9d24c7f0c4bf4f52927905c880fce67e8f;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index 489d23345..8662602b6 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -20,9 +20,10 @@ #include -#define SKETCH_ENTITY_COLOR "#ff0000" -#define SKETCH_EXTERNAL_COLOR "#00ff00" -#define SKETCH_CONSTRUCTION_COLOR "#000000" +#define SKETCH_ENTITY_COLOR "225,0,0" +#define SKETCH_EXTERNAL_COLOR "170,0,225" +#define SKETCH_AUXILIARY_COLOR "0,85,0" +#define SKETCH_OVERCONSTRAINT_COLOR "0,0,0" /**\class SketchPlugin_SketchEntity * \ingroup Plugins @@ -33,10 +34,10 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC { public: /// Reference to the construction type of the feature - inline static const std::string& CONSTRUCTION_ID() + inline static const std::string& AUXILIARY_ID() { - static const std::string MY_CONSTRUCTION_ID("Construction"); - return MY_CONSTRUCTION_ID; + static const std::string MY_AUXILIARY_ID("Auxiliary"); + return MY_AUXILIARY_ID; } /// Reference to the external edge or vertex as a AttributeSelection @@ -46,6 +47,37 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC return MY_EXTERNAL_ID; } + /// Reference to the copy type of the feature + inline static const std::string& COPY_ID() + { + static const std::string MY_COPY_ID("Copy"); + 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(); @@ -58,6 +90,16 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC return false; } + /// Returns true of the feature is a copy of other feature + virtual bool isCopy() const + { + AttributeBooleanPtr anAttr = data()->boolean(COPY_ID()); + if(anAttr.get()) { + return anAttr->value(); + } + return false; + } + /// Customize presentation of the feature virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theDefaultPrs) @@ -70,12 +112,12 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC // set color from preferences std::vector aColor; - std::shared_ptr aConstructionAttr = - data()->boolean(SketchPlugin_SketchEntity::CONSTRUCTION_ID()); - bool isConstruction = aConstructionAttr.get() != NULL && aConstructionAttr->value(); + std::shared_ptr anAuxiliaryAttr = + data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID()); + bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value(); if (isConstruction) { - aColor = Config_PropManager::color("Visualization", "sketch_construction_color", - SKETCH_CONSTRUCTION_COLOR); + aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color", + SKETCH_AUXILIARY_COLOR); } else if (isExternal()) { aColor = Config_PropManager::color("Visualization", "sketch_external_color", @@ -90,16 +132,23 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC 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 - // thePrs->setPointMarker(6, 2.); + // The width value do not have effect on the point presentation. + // It is defined in order to extend selection area of the object. + thePrs->setWidth(17); + // thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol + } + if(isCopy()) { + double aWidth = thePrs->width(); + isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized; } return isCustomized; } @@ -107,6 +156,10 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC protected: /// initializes mySketch SketchPlugin_SketchEntity(); + + /// \brief Initializes attributes of derived class. + virtual void initDerivedClassAttributes(){}; + }; #endif