From: nds Date: Mon, 28 Mar 2016 09:32:08 +0000 (+0300) Subject: #1371 Using auxilliary Sketch elements in any Feature: we need to use setColor instea... X-Git-Tag: V_2.3.0~317 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4f80737cf8e3e3b418e1b9e75a1da5ff5a7e406c;p=modules%2Fshaper.git #1371 Using auxilliary Sketch elements in any Feature: we need to use setColor instead of SetColor in order to AIS_Shape use the color as own union color. --- diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index f0db6da46..ec87b9dc4 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.cpp +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -71,7 +71,6 @@ bool PartSet_ResultSketchPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseTy return aValid; } - void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) @@ -86,15 +85,15 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) { std::vector aColor; - aColor = Config_PropManager::color("Visualization", "result_body_color", - ("200,200,230")); - Standard_Real anAuxiliaryWidth = 3.; - Standard_Integer anAuxiliaryLineStyle = 0; + aColor = Config_PropManager::color("Visualization", "result_construction_color", + ModelAPI_ResultConstruction::DEFAULT_COLOR()); + Standard_Real anAuxiliaryWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH(); + Standard_Integer anAuxiliaryLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE(); - SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB)); + Handle(Prs3d_Drawer) aDrawer = Attributes(); + setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB)); //thePresentation->Clear(); - Handle(Prs3d_Drawer) aDrawer = Attributes(); setWidth(aDrawer, anAuxiliaryWidth); // set line style Handle(Prs3d_LineAspect) aLineAspect; @@ -144,6 +143,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast (aResultFeature); std::list anAuxiliaryResults; + /// append auxiliary shapes for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) { FeaturePtr aFeature = aSketchFeature->subFeature(i); if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) { @@ -155,7 +155,25 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) anAuxiliaryResults.push_back(aResult); } } + else { + /// append not-edges shapes, e.g. center of a circle, an arc, a point feature + const std::list >& aRes = aFeature->results(); + std::list >::const_iterator aResIter = aRes.cbegin(); + for (; aResIter != aRes.cend(); aResIter++) { + std::shared_ptr aConstr = std::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(*aResIter); + if (aConstr) { + std::shared_ptr aGeomShape = aConstr->shape(); + if (aGeomShape.get()) { + const TopoDS_Shape& aShape = aGeomShape->impl(); + if (aShape.ShapeType() != TopAbs_EDGE) + anAuxiliaryResults.push_back(aConstr); + } + } + } + } } + if (anAuxiliaryResults.size() > 0) { Quantity_Color aPrevColor; Color(aPrevColor); @@ -164,13 +182,13 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) std::vector aColor; aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color", SKETCH_AUXILIARY_COLOR); - Standard_Real anAuxiliaryWidth = 1.; - Standard_Integer anAuxiliaryLineStyle = 3; + Standard_Real anAuxiliaryWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY(); + Standard_Integer anAuxiliaryLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY(); - SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB)); + Handle(Prs3d_Drawer) aDrawer = Attributes(); + setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB)); //thePresentation->Clear(); - Handle(Prs3d_Drawer) aDrawer = Attributes(); setWidth(aDrawer, anAuxiliaryWidth); // set line style Handle(Prs3d_LineAspect) aLineAspect; diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index 20f1e46f7..864b25b41 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 1; + } + + /// 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(); @@ -108,12 +132,12 @@ 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