X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_ResultSketchPrs.cpp;h=ede7d144d93d8789e347d74cfc40f2f374ed4881;hb=f85d1c600b80b23dfc3d9904571ce27beae7b6dd;hp=f0db6da461c1ce429b9462e372b856a8bc7d799b;hpb=e892b35a396a675c38a2808477956dcfb935fe1a;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index f0db6da46..ede7d144d 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) @@ -84,38 +83,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) return; } - { - std::vector aColor; - aColor = Config_PropManager::color("Visualization", "result_body_color", - ("200,200,230")); - Standard_Real anAuxiliaryWidth = 3.; - Standard_Integer anAuxiliaryLineStyle = 0; - - SetColor(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; - - Aspect_TypeOfLine aType = (Aspect_TypeOfLine)anAuxiliaryLineStyle; - if (aDrawer->HasOwnLineAspect()) { - aLineAspect = aDrawer->LineAspect(); - } - if (aDrawer->HasOwnWireAspect()) { - aLineAspect = aDrawer->WireAspect(); - } - Quantity_Color aCurrentColor; - Aspect_TypeOfLine aPrevLineType; - Standard_Real aCurrentWidth; - aLineAspect->Aspect()->Values(aCurrentColor, aPrevLineType, aCurrentWidth); - bool isChangedLineType = aType != aPrevLineType; - if (isChangedLineType) { - aLineAspect->SetTypeOfLine(aType); - } - // end of set line style - } + setAuxiliaryPresentationStyle(false); myFacesList.clear(); ResultConstructionPtr aConstruction = @@ -126,7 +94,6 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) myFacesList.push_back(aConstruction->face(aFaceIndex)); } } - myOriginalShape = aShapePtr->impl(); if (!myOriginalShape.IsNull()) { Set(myOriginalShape); @@ -138,12 +105,12 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) else Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs"); - - // create auxiliary shapes + // visualize auxiliary shapes and sketch construction elements(point, center of a circle) FeaturePtr aResultFeature = ModelAPI_Feature::feature(myResult); 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,47 +122,31 @@ 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); - Standard_Real aPrevWidth = Width(); - - std::vector aColor; - aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color", - SKETCH_AUXILIARY_COLOR); - Standard_Real anAuxiliaryWidth = 1.; - Standard_Integer anAuxiliaryLineStyle = 3; - - SetColor(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; - Aspect_TypeOfLine aType = (Aspect_TypeOfLine)anAuxiliaryLineStyle; - if (aDrawer->HasOwnLineAspect()) { - aLineAspect = aDrawer->LineAspect(); - } - if (aDrawer->HasOwnWireAspect()) { - aLineAspect = aDrawer->WireAspect(); - } - Quantity_Color aCurrentColor; - Aspect_TypeOfLine aPrevLineType; - Standard_Real aCurrentWidth; - aLineAspect->Aspect()->Values(aCurrentColor, aPrevLineType, aCurrentWidth); - bool isChangedLineType = aType != aPrevLineType; - if (isChangedLineType) { - aLineAspect->SetTypeOfLine(aType); - } - // end of set line style + if (anAuxiliaryResults.size() > 0) { + setAuxiliaryPresentationStyle(true); BRep_Builder aBuilder; TopoDS_Compound aComp; aBuilder.MakeCompound(aComp); - std::list::const_iterator anIt = anAuxiliaryResults.begin(), aLast = anAuxiliaryResults.end(); for (; anIt != aLast; anIt++) { @@ -210,14 +161,8 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d) } } myAuxiliaryCompound = aComp; + Handle(Prs3d_Drawer) aDrawer = Attributes(); StdPrs_WFDeflectionShape::Add(thePresentation, aComp, aDrawer); - - // restore presentation properties - //SetColor(aPrevColor); - //setWidth(aDrawer, aPrevWidth); - //if (isChangedLineType) { - // aLineAspect->SetTypeOfLine(aPrevLineType); - //} } } @@ -302,3 +247,47 @@ void PartSet_ResultSketchPrs::appendShapeSelection(const Handle(SelectMgr_Select } catch ( Standard_Failure ) { } } + +void PartSet_ResultSketchPrs::setAuxiliaryPresentationStyle(const bool isAuxiliary) +{ + std::vector aColor; + Standard_Real aWidth; + Standard_Integer aLineStyle; + + if (!isAuxiliary) { + aColor = Config_PropManager::color("Visualization", "result_construction_color", + ModelAPI_ResultConstruction::DEFAULT_COLOR()); + aWidth = PartSet_Tools::getAISDefaultWidth();// default width value + aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE(); + } + else { + aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color", + SKETCH_AUXILIARY_COLOR); + aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY(); + aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY(); + } + + Handle(Prs3d_Drawer) aDrawer = Attributes(); + setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., + Quantity_TOC_RGB)); + + setWidth(aDrawer, aWidth); + // set line style + Handle(Prs3d_LineAspect) aLineAspect; + + Aspect_TypeOfLine aType = (Aspect_TypeOfLine)aLineStyle; + if (aDrawer->HasOwnLineAspect()) { + aLineAspect = aDrawer->LineAspect(); + } + if (aDrawer->HasOwnWireAspect()) { + aLineAspect = aDrawer->WireAspect(); + } + Quantity_Color aCurrentColor; + Aspect_TypeOfLine aPrevLineType; + Standard_Real aCurrentWidth; + aLineAspect->Aspect()->Values(aCurrentColor, aPrevLineType, aCurrentWidth); + bool isChangedLineType = aType != aPrevLineType; + if (isChangedLineType) { + aLineAspect->SetTypeOfLine(aType); + } +}