X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_SketchEntity.h;h=3f3e7526a5d0d4c18f223a732f96f00d5cb1ae37;hb=4a800cf754a8ba8485f5320ca1b4b6f308b622a7;hp=eb50851fa4b2552de343f896214801e0163c321a;hpb=3c987a8d1b88765224e3ac1388afb91eae17e4d3;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index eb50851fa..3f3e7526a 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -41,7 +41,7 @@ * This is an abstract class to give * an interface to create the entity features such as line, circle, arc and point. */ -class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_ICustomPrs +class SketchPlugin_SketchEntity : public SketchPlugin_Feature //, public GeomAPI_ICustomPrs { public: /// Reference to the construction type of the feature @@ -65,16 +65,23 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC return MY_COPY_ID; } + /// Reference to the parent feature if exist + inline static const std::string& PARENT_ID() + { + static const std::string& MY_PARENT_ID("ParentFeature"); + return MY_PARENT_ID; + } + /// Width of the auxiliary line - inline static const double SKETCH_LINE_WIDTH_AUXILIARY() + inline static const int SKETCH_LINE_WIDTH_AUXILIARY() { return 2; } /// Width of the line - inline static const double SKETCH_LINE_WIDTH() + inline static const int SKETCH_LINE_WIDTH() { - return 3; + return Config_PropManager::integer("Visualization", "sketch_line_width"); } /// Style of the auxiliary line @@ -111,87 +118,106 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC return false; } + //virtual bool isIncludeToResult() const + //{ + // AttributeBooleanPtr anAttr; + // std::set aRefsToMe = data()->refsToMe(); + // std::set::const_iterator aIt; + // for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) { + // if ((*aIt)->id() == "ProjectedFeature") { + // FeaturePtr aFeature = std::dynamic_pointer_cast((*aIt)->owner()); + // if (aFeature.get()) { + // anAttr = aFeature->data()->boolean("IncludeToResult"); + // if (anAttr.get()) + // return anAttr->value(); + // } + // } + // } + // return true; + //} + // LCOV_EXCL_START /// Customize presentation of the feature - virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, - std::shared_ptr theDefaultPrs) - { - /// 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); - 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*/) - return false; - - // set color from preferences - std::vector aColor; - 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_auxiliary_color"); - } - else if (isExternal()) { - aColor = Config_PropManager::color("Visualization", "sketch_external_color"); - } - else { - aColor = Config_PropManager::color("Visualization", "sketch_entity_color"); - } - if (!aColor.empty()) { - if (theResult.get() && ModelAPI_Session::get()->isOperation()) { - AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); - aColorAttr->setSize(3); - // Set the color attribute in order do not use default colors in the presentation object - for (int i = 0; i < 3; i++) - aColorAttr->setValue(i, aColor[i]); - } - 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(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized; - isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized; - } - else { - isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized; - isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized; - } - } - else if (aShapeType == 7) { // otherwise this is a vertex - // 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; - } - - if (!theResult.get()) { - double aDeflection = Config_PropManager::real("Visualization", "construction_deflection"); - thePrs->setDeflection(aDeflection); - } - return isCustomized; - } + //virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, + // std::shared_ptr theDefaultPrs) + //{ + // /// 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); + // 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*/) + // return false; + + // // set color from preferences + // std::vector aColor; + // 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_auxiliary_color"); + // } + // else if (isExternal()) { + // aColor = Config_PropManager::color("Visualization", "sketch_external_color"); + // } + // else { + // aColor = Config_PropManager::color("Visualization", "sketch_entity_color"); + // } + // if (!aColor.empty()) { + // if (theResult.get() && ModelAPI_Session::get()->isOperation()) { + // AttributeIntArrayPtr aColorAttr = + // theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); + // aColorAttr->setSize(3); + // // Set the color attribute in order do not use default colors in the presentation object + // for (int i = 0; i < 3; i++) + // aColorAttr->setValue(i, aColor[i]); + // } + // 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(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized; + // isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized; + // } + // else { + // isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized; + // isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized; + // } + // } + // else if (aShapeType == 7) { // otherwise this is a vertex + // // 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() && !isIncludeToResult()) { + // double aWidth = thePrs->width(); + // isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized; + // } + + // if (!theResult.get()) { + // double aDeflection = Config_PropManager::real("Visualization", "construction_deflection"); + // thePrs->setDeflection(aDeflection); + // } + // return isCustomized; + //} // LCOV_EXCL_STOP protected: @@ -201,6 +227,9 @@ protected: /// \brief Initializes attributes of derived class. virtual void initDerivedClassAttributes(){}; + /// \brief Initializes attributes of derived class which were added recently. + virtual void initDerivedClassAttributes2(){}; + }; #endif