diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp index 15d44fc49d..e68c1a2090 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp @@ -527,20 +527,10 @@ void CViewer3dDoc::InputEvent(const Standard_Integer /*x*/, GetBValue (MSColor)/255.0, Quantity_TOC_RGB); - TopoDS_Shape S = myAISContext->SelectedShape(); - Handle(Geom_Surface) Surface = BRep_Tool::Surface (TopoDS::Face(S)); - if (Surface->IsKind (STANDARD_TYPE (Geom_Plane))) - { - Handle(User_Cylinder)::DownCast (myAISContext->SelectedInteractive()) - ->SetPlanarFaceColor (CSFColor.Name()); - } - else - { - Handle(User_Cylinder)::DownCast (myAISContext->SelectedInteractive()) - ->SetCylindricalFaceColor (CSFColor.Name()); - } + Handle(AIS_InteractiveObject) aSelectedObject = myAISContext->SelectedInteractive(); + Handle(User_Cylinder)::DownCast (aSelectedObject)->SetColor (CSFColor.Name()); - myAISContext->Redisplay (myAISContext->SelectedInteractive()); + myAISContext->Redisplay (aSelectedObject); myState = -1; myAISContext->CloseLocalContext(); } diff --git a/samples/mfc/standard/Common/User_Cylinder.cxx b/samples/mfc/standard/Common/User_Cylinder.cxx index 17124c14eb..11ff4d4e0f 100755 --- a/samples/mfc/standard/Common/User_Cylinder.cxx +++ b/samples/mfc/standard/Common/User_Cylinder.cxx @@ -34,8 +34,7 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant) myShape = S.Shape(); SetHilightMode(0); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); - myPlanarFaceColor = Quantity_NOC_FIREBRICK3; - myCylindricalFaceColor = Quantity_NOC_GRAY; + myColor = Quantity_NOC_GRAY; } User_Cylinder::User_Cylinder(const gp_Ax2 CylAx2, const Standard_Real R, const Standard_Real H) : @@ -47,8 +46,7 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant) myShape = aNurbsConvert.Shape(); SetHilightMode(0); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); - myPlanarFaceColor = Quantity_NOC_FIREBRICK3; - myCylindricalFaceColor = Quantity_NOC_KHAKI4; + myColor = Quantity_NOC_KHAKI4; } void User_Cylinder::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, @@ -56,33 +54,20 @@ void User_Cylinder::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPrese const Standard_Integer aMode ) { switch (aMode) { -case 0: - StdPrs_WFShape::Add(aPresentation,myShape, myDrawer ); - break; -case 1: +case AIS_WireFrame: + { + StdPrs_WFShape::Add(aPresentation,myShape, myDrawer ); + break; + } +case AIS_Shaded: { - Standard_Real aTransparency = Transparency(); Graphic3d_NameOfMaterial aMaterial = Material(); - TopExp_Explorer Ex; - Handle(Geom_Surface) Surface; - - for (Ex.Init(myShape,TopAbs_FACE); Ex.More(); Ex.Next()) - { - - Surface = BRep_Tool::Surface(TopoDS::Face(Ex.Current())); - myDrawer->ShadingAspect()->SetMaterial(aMaterial); - if (Surface->IsKind(STANDARD_TYPE(Geom_Plane))) - myDrawer->ShadingAspect()->SetColor(myPlanarFaceColor); - else - myDrawer->ShadingAspect()->SetColor(myCylindricalFaceColor); - - - myDrawer->ShadingAspect()->SetTransparency (aTransparency); - StdPrs_ShadedShape::Add(aPresentation,Ex.Current(), myDrawer); - } + myDrawer->ShadingAspect()->SetMaterial(aMaterial); + myDrawer->ShadingAspect()->SetColor(myColor); + myDrawer->ShadingAspect()->SetTransparency (aTransparency); + StdPrs_ShadedShape::Add(aPresentation,myShape, myDrawer); break; - } case 6: //color { @@ -309,7 +294,11 @@ case 6: //color void User_Cylinder::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) { - myDrawer->EnableDrawHiddenLine(); + Handle (Prs3d_Drawer) aDefDrawer = GetContext()->DefaultDrawer(); + if (aDefDrawer->DrawHiddenLine()) + myDrawer->EnableDrawHiddenLine(); + else + myDrawer->DisableDrawHiddenLine(); StdPrs_HLRPolyShape::Add(aPresentation,myShape,myDrawer,aProjector); } @@ -337,16 +326,6 @@ Standard_Boolean User_Cylinder::AcceptShapeDecomposition() const return Standard_True; } -void User_Cylinder::SetPlanarFaceColor(const Quantity_Color acolor) -{ - myPlanarFaceColor = acolor; -} - -void User_Cylinder::SetCylindricalFaceColor(const Quantity_Color acolor) -{ - myCylindricalFaceColor = acolor; -} - Standard_Boolean User_Cylinder::TriangleIsValid(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3) const { gp_Vec V1(P1,P2);// V1=(P1,P2) @@ -496,6 +475,5 @@ Quantity_Color User_Cylinder::Color(gp_Pnt& thePoint,Standard_Real AltMin,Standa void User_Cylinder::SetColor(const Quantity_Color &aColor) { AIS_InteractiveObject::SetColor(aColor); - SetPlanarFaceColor(aColor); - SetCylindricalFaceColor(aColor); + myColor = aColor; } diff --git a/samples/mfc/standard/Common/User_Cylinder.hxx b/samples/mfc/standard/Common/User_Cylinder.hxx index 807444537b..9021d7d8ef 100755 --- a/samples/mfc/standard/Common/User_Cylinder.hxx +++ b/samples/mfc/standard/Common/User_Cylinder.hxx @@ -22,8 +22,6 @@ public: ~User_Cylinder(){}; Standard_Boolean AcceptShapeDecomposition() const; - void Standard_EXPORT SetCylindricalFaceColor(const Quantity_Color acolor); - void Standard_EXPORT SetPlanarFaceColor(const Quantity_Color); Standard_Integer NbPossibleSelection() const; void SetColor(const Quantity_Color &aColor); @@ -41,10 +39,7 @@ private: // DEFINE_STANDARD_RTTIEXT(User_Cylinder,AIS_InteractiveObject) private: -// Quantity_NameOfColor myCylindricalFaceColor; -// Quantity_NameOfColor myPlanarFaceColor; - Quantity_Color myCylindricalFaceColor; - Quantity_Color myPlanarFaceColor; + Quantity_Color myColor; TopoDS_Shape myShape; Handle(Graphic3d_AspectFillArea3d) myAspect;