From 404c893694dc8c8105f604fcf2f353358e48e927 Mon Sep 17 00:00:00 2001 From: isk Date: Mon, 28 Nov 2016 12:11:43 +0300 Subject: [PATCH] 0028162: Draw Harness - eliminate usage of deprecated Local Context Create a general draw command 'VRelation' and drop the old 'relation' commands. Add test cases for new draw command "vrelation". Add two new methods: Activate and Deactivate which activate/deactivate the given selection mode for all displayed objects. Eliminate deprecated local context methods in ObjectCommands, QABugs. Eliminate deprecated local context methods in mfc standard sample and qt samples. --- .../standard/01_Geometry/src/GeometryDoc.cpp | 4 +- .../standard/02_Modeling/src/ModelingDoc.cpp | 178 +- .../standard/03_Viewer2d/src/Viewer2dDoc.cpp | 9 - .../standard/04_Viewer3d/src/OffsetDlg.cpp | 42 +- .../standard/04_Viewer3d/src/Viewer3dDoc.cpp | 76 +- .../standard/04_Viewer3d/src/Viewer3dView.cpp | 8 - .../05_ImportExport/src/ImportExportDoc.cpp | 16 +- samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp | 32 +- samples/mfc/standard/08_HLR/src/HLRDoc.cpp | 14 +- .../standard/08_HLR/src/SelectionDialog.cpp | 16 +- samples/mfc/standard/Common/AISDialogs.cpp | 40 +- .../Common/AngleParamsVerticesPage.cpp | 40 +- samples/mfc/standard/Common/DimensionDlg.cpp | 44 +- .../Common/ImportExport/ImportExport.cpp | 31 +- .../standard/Common/LengthParamsEdgePage.cpp | 10 +- .../standard/Common/LengthParamsEdgesPage.cpp | 29 +- .../Common/LengthParamsVerticesPage.cpp | 32 +- samples/mfc/standard/Common/OCC_3dBaseDoc.cpp | 82 +- .../mfc/standard/Common/ParamsFacesPage.cpp | 21 +- .../mfc/standard/Common/RadiusParamsPage.cpp | 11 +- samples/qt/Common/src/ApplicationCommon.cxx | 6 +- samples/qt/Common/src/DocumentCommon.cxx | 24 +- samples/qt/Interface/src/Translate.cxx | 4 +- samples/qt/Tutorial/src/DocumentTut.cxx | 3 +- src/AIS/AIS_InteractiveContext.cxx | 9 +- src/AIS/AIS_InteractiveContext.hxx | 61 +- src/AIS/AIS_InteractiveContext_1.cxx | 2 + src/AIS/AIS_InteractiveContext_2.cxx | 58 +- src/AIS/AIS_KindOfRelation.hxx | 33 + src/AIS/AIS_LocalContext.cxx | 2 + src/AIS/FILES | 1 + src/PrsMgr/PrsMgr_PresentationManager.cxx | 6 +- src/QABugs/QABugs_1.cxx | 5 +- src/QABugs/QABugs_11.cxx | 64 +- src/QABugs/QABugs_17.cxx | 84 +- src/QABugs/QABugs_19.cxx | 18 +- src/QABugs/QABugs_3.cxx | 82 +- src/ViewerTest/ViewerTest.cxx | 131 +- src/ViewerTest/ViewerTest.hxx | 5 + src/ViewerTest/ViewerTest_ObjectCommands.cxx | 1186 +++------ .../ViewerTest_RelationCommands.cxx | 2153 ++++------------- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 6 +- src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 12 +- tests/v3d/dimensions/begin | 2 + tests/v3d/dimensions/concentric | 21 + tests/v3d/dimensions/equaldistance | 38 + tests/v3d/dimensions/equalradius | 31 + tests/v3d/dimensions/fix | 18 + tests/v3d/dimensions/identic | 37 + tests/v3d/dimensions/offset | 22 + tests/v3d/dimensions/parallel | 23 + tests/v3d/dimensions/perpendicular | 22 + tests/v3d/dimensions/symmetric | 41 + tests/v3d/end | 4 +- tests/v3d/grids.list | 1 + 55 files changed, 1773 insertions(+), 3177 deletions(-) create mode 100644 src/AIS/AIS_KindOfRelation.hxx create mode 100644 tests/v3d/dimensions/begin create mode 100644 tests/v3d/dimensions/concentric create mode 100644 tests/v3d/dimensions/equaldistance create mode 100644 tests/v3d/dimensions/equalradius create mode 100644 tests/v3d/dimensions/fix create mode 100644 tests/v3d/dimensions/identic create mode 100644 tests/v3d/dimensions/offset create mode 100644 tests/v3d/dimensions/parallel create mode 100644 tests/v3d/dimensions/perpendicular create mode 100644 tests/v3d/dimensions/symmetric diff --git a/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp b/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp index bab3bb1ab5..9fb99ca299 100755 --- a/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp +++ b/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp @@ -325,8 +325,8 @@ void CGeometryDoc::Popup (const Standard_Integer theMouseX, const Handle(V3d_View)& theView) { Standard_Integer PopupMenuNumber=0; - GetAISContext()->InitCurrent(); - if (GetAISContext()->MoreCurrent()) + GetAISContext()->InitSelected(); + if (GetAISContext()->MoreSelected()) { PopupMenuNumber=1; } diff --git a/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp b/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp index a6529e3590..d4635bcfc6 100755 --- a/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp +++ b/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp @@ -1093,7 +1093,8 @@ myAISContext->SetDisplayMode(ais1,1,Standard_False); myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); -myAISContext->SetCurrentObject(ais1,Standard_False); +const Handle(AIS_InteractiveObject)& anIO1 = ais1; +myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(1000); @@ -1104,7 +1105,8 @@ myAISContext->SetDisplayMode(ais2,1,Standard_False); myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais2,Standard_False); -myAISContext->SetCurrentObject(ais2,Standard_False); +const Handle(AIS_InteractiveObject)& anIO2 = ais2; +myAISContext->SetSelected (anIO2, Standard_False); Fit(); Sleep(1000); @@ -1118,7 +1120,8 @@ myAISContext->SetDisplayMode(aSection,1,Standard_False); myAISContext->SetColor(aSection,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(aSection,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(aSection,Standard_False); -myAISContext->SetCurrentObject(aSection,Standard_False); +const Handle(AIS_InteractiveObject)& anIOSection = aSection; +myAISContext->SetSelected (anIOSection, Standard_False); Fit(); TCollection_AsciiString Message ("\ @@ -1158,7 +1161,8 @@ Handle (AIS_Shape) ais1 = new AIS_Shape(theBox1); myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); -myAISContext->SetCurrentObject(ais1,Standard_False); +const Handle(AIS_InteractiveObject)& anIO1 = ais1; +myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(1000); @@ -1167,7 +1171,8 @@ Handle (AIS_Shape) ais2 = new AIS_Shape(theBox2); myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais2,Standard_False); -myAISContext->SetCurrentObject(ais2,Standard_False); +const Handle(AIS_InteractiveObject)& anIO2 = ais2; +myAISContext->SetSelected (anIO2, Standard_False); Fit(); Sleep(1000); @@ -1181,7 +1186,8 @@ myAISContext->SetDisplayMode(aFusion,1,Standard_False); myAISContext->SetColor(aFusion,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(aFusion,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(aFusion,Standard_False); -myAISContext->SetCurrentObject(aFusion,Standard_False); +const Handle(AIS_InteractiveObject)& anIOFusion = aFusion; +myAISContext->SetSelected (anIOFusion, Standard_False); Fit(); TCollection_AsciiString Message ("\ @@ -1213,7 +1219,8 @@ myAISContext->SetMaterial(aboxshape,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->SetDisplayMode(aboxshape,1,Standard_False); myAISContext->SetTransparency(aboxshape,0.2,Standard_False); myAISContext->Display(aboxshape,Standard_False); -myAISContext->SetCurrentObject(aboxshape,Standard_False); +const Handle(AIS_InteractiveObject)& anIOBoxShape = aboxshape; +myAISContext->SetSelected (anIOBoxShape, Standard_False); Fit(); Sleep(500); @@ -1224,7 +1231,8 @@ myAISContext->SetColor(awedge,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(awedge,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->SetTransparency(awedge,0.0,Standard_False); myAISContext->Display(awedge,Standard_False); -myAISContext->SetCurrentObject(awedge,Standard_False); +const Handle(AIS_InteractiveObject)& anIOWedge = awedge; +myAISContext->SetSelected (anIOWedge, Standard_False); Fit(); Sleep(500); @@ -1237,7 +1245,8 @@ Handle(AIS_Shape) acommon = new AIS_Shape(theCommonSurface); myAISContext->SetColor(acommon,Quantity_NOC_GREEN,Standard_False); myAISContext->SetMaterial(acommon,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(acommon,Standard_False); -myAISContext->SetCurrentObject(acommon); +const Handle(AIS_InteractiveObject)& anIOCommon = acommon; +myAISContext->SetSelected (anIOCommon, Standard_False); TCollection_AsciiString Message ("\ \n\ @@ -1336,7 +1345,8 @@ myAISContext->SetColor(atorus,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(atorus,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->SetTransparency(atorus,0.1,Standard_False); myAISContext->Display(atorus,Standard_False); -myAISContext->SetCurrentObject(atorus,Standard_False); +const Handle(AIS_InteractiveObject)& anIOTorus = atorus; +myAISContext->SetSelected (anIOTorus, Standard_False); Fit(); Sleep(500); @@ -1344,7 +1354,8 @@ gp_Pln aplane(1,0.25,3,4); Handle (Geom_Plane) thePlane = new Geom_Plane(aplane); Handle (AIS_Plane) ais1 = new AIS_Plane(thePlane); myAISContext->Display(ais1,Standard_False); -myAISContext->SetCurrentObject(ais1,Standard_False); +const Handle(AIS_InteractiveObject)& anIO1 = ais1; +myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(300); @@ -1386,7 +1397,8 @@ Handle(AIS_Shape) ais1 = new AIS_Shape(Box); myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); -myAISContext->SetCurrentObject(ais1,Standard_False); +const Handle(AIS_InteractiveObject)& anIO1 = ais1; +myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -1404,7 +1416,8 @@ Handle(AIS_Shape) aBlendbox = new AIS_Shape(blendedBox); myAISContext->SetColor(aBlendbox,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(aBlendbox,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(aBlendbox,Standard_False); -myAISContext->SetCurrentObject(aBlendbox,Standard_False); +const Handle(AIS_InteractiveObject)& anIOBlendBox = aBlendbox; +myAISContext->SetSelected (anIOBlendBox, Standard_False); Fit(); Sleep(500); @@ -1418,7 +1431,8 @@ Handle(AIS_Shape) ais2 = new AIS_Shape(fusedShape); myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais2,Standard_False); -myAISContext->SetCurrentObject(ais2,Standard_False); +const Handle(AIS_InteractiveObject)& anIO2 = ais2; +myAISContext->SetSelected (anIO2, Standard_False); Fit(); BRepFilletAPI_MakeFillet fill(fusedShape); @@ -1503,7 +1517,8 @@ Handle(AIS_Shape) ais1 = new AIS_Shape(theBox); myAISContext->SetColor(ais1,Quantity_NOC_BROWN,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); -myAISContext->SetCurrentObject(ais1,Standard_False); +const Handle(AIS_InteractiveObject)& anIO1 = ais1; +myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -1520,7 +1535,7 @@ if (Rake.IsDone() ){ TopoDS_Shape evolvedBox = Rake.Shape(); ais1->Set(evolvedBox); myAISContext->Redisplay(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + myAISContext->SetSelected(anIO1, Standard_False); Fit(); Sleep(500); @@ -1531,7 +1546,8 @@ Handle(AIS_Shape) ais3 = new AIS_Shape(theCylinder); myAISContext->SetColor(ais3,Quantity_NOC_GREEN,Standard_False); myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais3,Standard_False); -myAISContext->SetCurrentObject(ais3,Standard_False); +const Handle(AIS_InteractiveObject)& anIO3 = ais3; +myAISContext->SetSelected (anIO3, Standard_False); Fit(); Sleep(500); @@ -1551,7 +1567,7 @@ if (fillet.IsDone() ){ TopoDS_Shape LawEvolvedCylinder = fillet.Shape(); ais3->Set(LawEvolvedCylinder); myAISContext->Redisplay(ais3,Standard_False); - myAISContext->SetCurrentObject(ais3,Standard_False); + myAISContext->SetSelected(anIO3,Standard_False); Fit(); Sleep(500); } @@ -1562,7 +1578,8 @@ Handle(AIS_Shape) ais2 = new AIS_Shape(theBox2); myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais2,Standard_False); -myAISContext->SetCurrentObject(ais2,Standard_False); +const Handle(AIS_InteractiveObject)& anIO2 = ais2; +myAISContext->SetSelected (anIO2, Standard_False); Fit(); Sleep(500); @@ -1597,7 +1614,7 @@ if (afillet.IsDone() ){ TopoDS_Shape LawevolvedBox = afillet.Shape(); ais2->Set(LawevolvedBox); myAISContext->Redisplay(ais2,Standard_False); - myAISContext->SetCurrentObject(ais2,Standard_False); + myAISContext->SetSelected(anIO2,Standard_False); Fit(); } @@ -1698,7 +1715,8 @@ Handle(AIS_Shape) ais1 = new AIS_Shape(theBox); myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); -myAISContext->SetCurrentObject(ais1,Standard_False); +const Handle(AIS_InteractiveObject)& anIO1 = ais1; +myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -1717,7 +1735,8 @@ Handle(AIS_Shape) aBlendedBox = new AIS_Shape(ChanfrenedBox); myAISContext->SetColor(aBlendedBox,Quantity_NOC_YELLOW,Standard_False); myAISContext->SetMaterial(aBlendedBox,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(aBlendedBox,Standard_False); -myAISContext->SetCurrentObject(aBlendedBox,Standard_False); +const Handle(AIS_InteractiveObject)& anIOBlendedBox = aBlendedBox; +myAISContext->SetSelected (anIOBlendedBox, Standard_False); Fit(); Sleep(500); @@ -1757,7 +1776,8 @@ void CModelingDoc::OnPrismLocal() myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -1800,7 +1820,7 @@ void CModelingDoc::OnPrismLocal() ais1->Set(res1); myAISContext->Redisplay(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + myAISContext->SetSelected(anIO1,Standard_False); Fit(); Sleep(500); @@ -1834,7 +1854,7 @@ void CModelingDoc::OnPrismLocal() ais1->Set(res2); myAISContext->Redisplay(ais1); - myAISContext->SetCurrentObject(ais1,Standard_False); + myAISContext->SetSelected(anIO1,Standard_False); Fit(); TCollection_AsciiString Message ("\ @@ -1954,14 +1974,15 @@ void CModelingDoc::OnDprismLocal() TopoDS_Shape res1 = MKDP.Shape(); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); ais1->Set(res1); myAISContext->Redisplay(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + myAISContext->SetSelected(anIO1,Standard_False); Fit(); @@ -2011,7 +2032,8 @@ void CModelingDoc::OnRevolLocal() myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -2053,7 +2075,8 @@ void CModelingDoc::OnRevolLocal() myAISContext->Remove(ais1); Handle(AIS_Shape) ais2 = new AIS_Shape(res1); myAISContext->Display(ais2,Standard_False); - myAISContext->SetCurrentObject(ais2,Standard_False); + const Handle(AIS_InteractiveObject)& anIO2 = ais2; + myAISContext->SetSelected (anIO2, Standard_False); Fit(); TCollection_AsciiString Message ("\ @@ -2109,7 +2132,8 @@ void CModelingDoc::OnGlueLocal() myAISContext->SetColor(ais1,Quantity_NOC_ORANGE,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(1000); @@ -2127,7 +2151,8 @@ void CModelingDoc::OnGlueLocal() myAISContext->SetColor(ais2,Quantity_NOC_AZURE,Standard_False); myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais2,Standard_False); - myAISContext->SetCurrentObject(ais2,Standard_False); + const Handle(AIS_InteractiveObject)& anIO2 = ais2; + myAISContext->SetSelected (anIO2, Standard_False); Fit(); Sleep(1000); @@ -2146,7 +2171,7 @@ void CModelingDoc::OnGlueLocal() ais1->Set(res1); myAISContext->Redisplay(ais1); - myAISContext->SetCurrentObject(ais1,Standard_False); + myAISContext->SetSelected(anIO1,Standard_False); Fit(); Sleep(1000); @@ -2156,7 +2181,8 @@ void CModelingDoc::OnGlueLocal() myAISContext->SetColor(ais3,Quantity_NOC_ORANGE,Standard_False); myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais3,Standard_False); - myAISContext->SetCurrentObject(ais3,Standard_False); + const Handle(AIS_InteractiveObject)& anIO3 = ais3; + myAISContext->SetSelected (anIO3, Standard_False); Fit(); Sleep(1000); @@ -2174,7 +2200,8 @@ void CModelingDoc::OnGlueLocal() myAISContext->SetColor(ais4,Quantity_NOC_AZURE,Standard_False); myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais4,Standard_False); - myAISContext->SetCurrentObject(ais4,Standard_False); + const Handle(AIS_InteractiveObject)& anIO4 = ais4; + myAISContext->SetSelected (anIO4, Standard_False); Fit(); Sleep(1000); @@ -2196,7 +2223,7 @@ void CModelingDoc::OnGlueLocal() ais4->Set(res2); myAISContext->Redisplay(ais4,Standard_False); - myAISContext->SetCurrentObject(ais4,Standard_False); + myAISContext->SetSelected(anIO4,Standard_False); Fit(); Sleep(1000); @@ -2269,7 +2296,8 @@ void CModelingDoc::OnPipeLocal() myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -2314,7 +2342,7 @@ void CModelingDoc::OnPipeLocal() ais1->Set(res1); myAISContext->Redisplay(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + myAISContext->SetSelected(anIO1,Standard_False); Fit(); TCollection_AsciiString Message ("\ @@ -2396,7 +2424,8 @@ void CModelingDoc::OnLinearLocal() myAISContext->SetColor(ais1,Quantity_NOC_CYAN2,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -2410,7 +2439,7 @@ void CModelingDoc::OnLinearLocal() TopoDS_Shape res = aform.Shape(); ais1->Set(res); myAISContext->Redisplay(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1); + myAISContext->SetSelected(anIO1); Fit(); TCollection_AsciiString Message ("\ @@ -2462,7 +2491,8 @@ void CModelingDoc::OnSplitLocal() myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(500); @@ -2499,7 +2529,8 @@ void CModelingDoc::OnSplitLocal() myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->SetDisplayMode(ais2,1,Standard_False); myAISContext->Display(ais2,Standard_False); - myAISContext->SetCurrentObject(ais2,Standard_False); + const Handle(AIS_InteractiveObject)& anIO2 = ais2; + myAISContext->SetSelected (anIO2, Standard_False); Fit(); TCollection_AsciiString Message ("\ \n\ @@ -2549,7 +2580,8 @@ void CModelingDoc::OnThickLocal() myAISContext->SetColor(abox1,Quantity_NOC_WHITE); myAISContext->SetMaterial(abox1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(abox1,Standard_False); - myAISContext->SetCurrentObject(abox1,Standard_False); + const Handle(AIS_InteractiveObject)& anIOBox1 = abox1; + myAISContext->SetSelected (anIOBox1, Standard_False); Fit(); Sleep(1000); @@ -2567,7 +2599,8 @@ void CModelingDoc::OnThickLocal() myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False); myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); myAISContext->Display(ais1,Standard_False); - myAISContext->SetCurrentObject(ais1,Standard_False); + const Handle(AIS_InteractiveObject)& anIO1 = ais1; + myAISContext->SetSelected (anIO1, Standard_False); Fit(); Sleep(1000); @@ -3286,7 +3319,7 @@ void CModelingDoc::OnShell() Handle(AIS_Shape) anAISShell = new AIS_Shape(aShell); myAISContext->SetDisplayMode(anAISShell,0); myAISContext->Display(anAISShell,Standard_False); - //myAISContext->SetCurrentObject(anAISShell); + //myAISContext->SetSelected(anAISShell); Fit(); @@ -4598,10 +4631,9 @@ gp_Mat I = System.MatrixOfInertia();\n\ void CModelingDoc::OnButtonFill() { // TODO: Add your command handler code here - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) { - AIS1 = Handle(AIS_Shape)::DownCast(myAISContext->Current()); - myAISContext->OpenLocalContext(); + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) { + AIS1 = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive()); myAISContext->Unhilight(AIS1); myAISContext->Activate(AIS1,2); myState = SELECT_EDGE_PLATE; @@ -4613,7 +4645,7 @@ void CModelingDoc::OnButtonFill() if(OnFileImportBrep_WithInitDir (L"HoleFilling") == 1) return; myAISContext->DisplayedObjects(LI); - myAISContext->SetCurrentObject(LI.First()); + myAISContext->SetSelected(LI.First()); OnButtonFill(); return; } @@ -4725,7 +4757,6 @@ void CModelingDoc::OnStopStop() } if (!BRepAlgo::IsValid(aface)) MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The plate face is not valid!", L"CasCade Error", MB_ICONERROR); - myAISContext->CloseLocalContext(); myState = -1; Handle(AIS_Shape) anAISShape = new AIS_Shape(aface); myAISContext->SetColor(anAISShape,Quantity_NOC_AZURE); @@ -4741,9 +4772,9 @@ void CModelingDoc::OnFillwithtang() if (flag == 1){ flag = 0; Handle(AIS_InteractiveObject) aObject; - myAISContext ->InitCurrent(); - if(myAISContext->MoreCurrent()) - aObject = myAISContext->Current(); + myAISContext ->InitSelected(); + if(myAISContext->MoreSelected()) + aObject = myAISContext->SelectedInteractive(); ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with second face"); if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1){ ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage(""); @@ -4755,12 +4786,12 @@ void CModelingDoc::OnFillwithtang() } return; } - myAISContext->SetCurrentObject(aObject); + myAISContext->SetSelected(aObject); } - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) { - Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->Current()); + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) { + Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive()); try { THE_F1 = TopoDS::Face(ashape->Shape()); } @@ -4771,7 +4802,6 @@ void CModelingDoc::OnFillwithtang() Please, select a face to continue\nthe creation of a tangent surface."); return; } - myAISContext->OpenLocalContext(); myAISContext->Activate(ashape,2); myState = SELECT_EDGE_PLATE_TGTES_1; @@ -4795,7 +4825,7 @@ Please, select a face to continue\nthe creation of a tangent surface."); } ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage(""); myAISContext->DisplayedObjects(LI); - myAISContext->SetCurrentObject(LI.First()); + myAISContext->SetSelected(LI.First()); Sleep(700); flag = 1; OnFillwithtang(); @@ -4814,21 +4844,19 @@ void CModelingDoc::InputEvent(const Standard_Integer /*x*/, myAISContext->InitSelected(); if (myAISContext->MoreSelected()) { THE_E1 = TopoDS::Edge(myAISContext->SelectedShape()); - myAISContext->CloseLocalContext(); myState = SELECT_EDGE_PLATE_TGTES_2; AIS_ListOfInteractive aLI; myAISContext->DisplayedObjects(aLI); if(aLI.Extent() == 2){ myState = SELECT_EDGE_PLATE_TGTES_2; - if (myAISContext->IsCurrent(aLI.First())) - myAISContext->SetCurrentObject(aLI.Last()); + if (myAISContext->IsSelected(aLI.First())) + myAISContext->SetSelected(aLI.Last()); else - myAISContext->SetCurrentObject(aLI.First()); - myAISContext->InitCurrent(); - Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->Current()); + myAISContext->SetSelected(aLI.First()); + myAISContext->InitSelected(); + Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive()); THE_F2 = TopoDS::Face(ashape->Shape()); - myAISContext->OpenLocalContext(); myAISContext->Activate(ashape,2); myState = SELECT_EDGE_PLATE_TGTES_3; ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face"); @@ -4848,11 +4876,10 @@ void CModelingDoc::InputEvent(const Standard_Integer /*x*/, } else if (myState == SELECT_EDGE_PLATE_TGTES_2) { - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) { - Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->Current()); - THE_F2 = TopoDS::Face(ashape->Shape()); - myAISContext->OpenLocalContext(); + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) { + Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive()); + THE_F2 = TopoDS::Face(ashape->Shape()); myAISContext->Activate(ashape,2); myState = SELECT_EDGE_PLATE_TGTES_3; ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face"); @@ -4864,7 +4891,6 @@ void CModelingDoc::InputEvent(const Standard_Integer /*x*/, myAISContext->InitSelected(); if (myAISContext->MoreSelected()) { THE_E2 = TopoDS::Edge(myAISContext->SelectedShape()); - myAISContext->CloseLocalContext(); Standard_Integer i, nbPntsOnFaces=10; Standard_Real u,First, Last, Delta, Tol=0.001, TolProj; @@ -5042,10 +5068,10 @@ void CModelingDoc::Popup(const Standard_Integer x, const Handle(V3d_View)& aView) { Standard_Integer PopupMenuNumber=0; - myAISContext->InitCurrent(); + myAISContext->InitSelected(); if (myState == SELECT_EDGE_PLATE) PopupMenuNumber=2; - else if (myAISContext->MoreCurrent()) + else if (myAISContext->MoreSelected()) PopupMenuNumber=1; CMenu menu; @@ -5056,8 +5082,8 @@ void CModelingDoc::Popup(const Standard_Integer x, if (PopupMenuNumber == 1) // more than 1 object. { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; if(!OneOrMoreInShading) pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); } diff --git a/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp b/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp index a625a10ec7..27d85c5b11 100755 --- a/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp +++ b/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp @@ -56,8 +56,6 @@ void CViewer2dDoc::Dump(CDumpContext& dc) const void CViewer2dDoc::OnBUTTONErase() { - if(myAISContext->HasOpenedContext()) - myAISContext->CloseAllContexts(); myAISContext->EraseAll(); } @@ -214,8 +212,6 @@ void CViewer2dDoc::OnBUTTONTestLine() void CViewer2dDoc::OnBUTTONTestFace() { //erase all - if(myAISContext->HasOpenedContext()) - myAISContext->CloseAllContexts(); myAISContext->EraseAll(); CFileDialog dlg(TRUE, @@ -255,7 +251,6 @@ void CViewer2dDoc::OnBUTTONTestFace() Handle(Sample2D_Face) anAISFace = new Sample2D_Face(aFaceShape); myAISContext->Display(anAISFace,Standard_True); //activate selection mode for edges selection - myAISContext->OpenLocalContext(); myAISContext->Activate(anAISFace,2); FitAll2DViews(Standard_False); @@ -328,8 +323,6 @@ void CViewer2dDoc::OnBUTTONTestImage() TCollection_AsciiString aFileName ((const wchar_t* )aFilePath); //erase viewer - if(myAISContext->HasOpenedContext()) - myAISContext->CloseAllContexts(); myAISContext->EraseAll(); Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName); @@ -362,8 +355,6 @@ void CViewer2dDoc::OnBUTTONMultipleImage() TCollection_AsciiString aFileName ((const wchar_t* )aFilePath); //erase viewer - if(myAISContext->HasOpenedContext()) - myAISContext->CloseAllContexts(); myAISContext->EraseAll(); //create images diff --git a/samples/mfc/standard/04_Viewer3d/src/OffsetDlg.cpp b/samples/mfc/standard/04_Viewer3d/src/OffsetDlg.cpp index bf805a9eb6..8162759941 100755 --- a/samples/mfc/standard/04_Viewer3d/src/OffsetDlg.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/OffsetDlg.cpp @@ -135,25 +135,34 @@ void COffsetDlg::SetOffsets(Standard_Real theFactor, Standard_Real theUnits) Standard_ShortReal aFactor = (Standard_ShortReal)theFactor; Standard_ShortReal aUnits = (Standard_ShortReal)theUnits; - for (aAISContext->InitCurrent();aAISContext->MoreCurrent ();aAISContext->NextCurrent ()) - if (aAISContext->IsDisplayed(aAISContext->Current())) OneOrMoreCurrentIsDisplayed=true; + for (aAISContext->InitSelected(); aAISContext->MoreSelected(); aAISContext->NextSelected()) + if (aAISContext->IsDisplayed(aAISContext->SelectedInteractive())) OneOrMoreCurrentIsDisplayed=true; if(OneOrMoreCurrentIsDisplayed){ - if((aAISContext->IsCurrent(aOverlappedBox) || aAISContext->IsCurrent(aBox)) + // A small trick to avoid complier error (C2668). + const Handle(AIS_InteractiveObject)& anIOOverlappedBox = aOverlappedBox; + const Handle(AIS_InteractiveObject)& anIOBox = aBox; + if((aAISContext->IsSelected(anIOOverlappedBox) || aAISContext->IsSelected(anIOBox)) && aAISContext->IsDisplayed(aOverlappedBox)){ aOverlappedBox->SetPolygonOffsets(Aspect_POM_Fill,aFactor,aUnits); Message = "Box2 -> SetPolygonOffsets(Aspect_POM_Fill, Factor, Units);\n"; //myDoc -> AddTextInDialog(Message); } - if((aAISContext->IsCurrent(aOverlappedCylinder) || aAISContext->IsCurrent(aCylinder)) + // A small trick to avoid complier error (C2668). + const Handle(AIS_InteractiveObject)& anIOOverlappedCylinder = aOverlappedCylinder; + const Handle(AIS_InteractiveObject)& anIOCylinder = aCylinder; + if((aAISContext->IsSelected(anIOOverlappedCylinder) || aAISContext->IsSelected(anIOCylinder)) && aAISContext->IsDisplayed(aOverlappedCylinder)){ aOverlappedCylinder->SetPolygonOffsets(Aspect_POM_Fill,aFactor,aUnits); Message = Message + "Cylinder2 -> SetPolygonOffsets(Aspect_POM_Fill, Factor, Units);\n"; //myDoc -> AddTextInDialog(Message); } - if((aAISContext->IsCurrent(aOverlappedSphere) || aAISContext->IsCurrent(aSphere)) + // A small trick to avoid complier error (C2668). + const Handle(AIS_InteractiveObject)& anIOOverlappedSphere = aOverlappedSphere; + const Handle(AIS_InteractiveObject)& anIOSphere = aSphere; + if((aAISContext->IsSelected(anIOOverlappedSphere) || aAISContext->IsSelected(anIOSphere)) && aAISContext->IsDisplayed(aOverlappedSphere)){ aOverlappedSphere->SetPolygonOffsets(Aspect_POM_Fill,aFactor,aUnits); Message = Message + "Sphere2 -> SetPolygonOffsets(Aspect_POM_Fill, Factor, Units);\n"; @@ -209,18 +218,23 @@ void COffsetDlg::UpdateValues() BOOL IsOverlappedSphereDisplayed = aAISContext->IsDisplayed(aOverlappedSphere); BOOL IsOverlappedBoxDisplayed = aAISContext->IsDisplayed(aOverlappedBox); - BOOL IsOverlappedCylinderCurrent = aAISContext->IsCurrent(aOverlappedCylinder); - BOOL IsOverlappedSphereCurrent = aAISContext->IsCurrent(aOverlappedSphere); - BOOL IsOverlappedBoxCurrent = aAISContext->IsCurrent(aOverlappedBox); + const Handle(AIS_InteractiveObject)& anIOOverlappedCylinder = aOverlappedCylinder; + const Handle(AIS_InteractiveObject)& anIOOverlappedSphere = aOverlappedSphere; + const Handle(AIS_InteractiveObject)& anIOOverlappedBox = aOverlappedBox; + BOOL IsOverlappedCylinderCurrent = aAISContext->IsSelected(anIOOverlappedCylinder); + BOOL IsOverlappedSphereCurrent = aAISContext->IsSelected(anIOOverlappedSphere); + BOOL IsOverlappedBoxCurrent = aAISContext->IsSelected(anIOOverlappedBox); /*BOOL IsAnyOverlappedObjectCurrent = IsOverlappedCylinderCurrent || IsOverlappedSphereCurrent || IsOverlappedBoxCurrent;*/ - - BOOL IsCylinderCurrent = aAISContext->IsCurrent(aCylinder); - BOOL IsSphereCurrent = aAISContext->IsCurrent(aSphere); - BOOL IsBoxCurrent = aAISContext->IsCurrent(aBox); + const Handle(AIS_InteractiveObject)& anIOCylinder = aCylinder; + const Handle(AIS_InteractiveObject)& anIOSphere = aSphere; + const Handle(AIS_InteractiveObject)& anIOBox = aBox; + BOOL IsCylinderCurrent = aAISContext->IsSelected(anIOCylinder); + BOOL IsSphereCurrent = aAISContext->IsSelected(anIOSphere); + BOOL IsBoxCurrent = aAISContext->IsSelected(anIOBox); BOOL IsAnyObjectCurrent = IsOverlappedCylinderCurrent || IsOverlappedSphereCurrent || IsOverlappedBoxCurrent @@ -230,8 +244,8 @@ void COffsetDlg::UpdateValues() IsOverlappedCylinderDisplayed || IsOverlappedSphereDisplayed || IsOverlappedBoxDisplayed; Standard_Boolean OneOrMoreCurrentIsDisplayed=false; - for (aAISContext->InitCurrent();aAISContext->MoreCurrent ();aAISContext->NextCurrent ()) - if (aAISContext->IsDisplayed(aAISContext->Current())) OneOrMoreCurrentIsDisplayed=true; + for (aAISContext->InitSelected();aAISContext->MoreSelected ();aAISContext->NextSelected ()) + if (aAISContext->IsDisplayed(aAISContext->SelectedInteractive())) OneOrMoreCurrentIsDisplayed=true; if(OneOrMoreCurrentIsDisplayed){ if(IsOverlappedBoxDisplayed && (IsBoxCurrent || IsOverlappedBoxCurrent)){ diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp index e68c1a2090..50536f86e5 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp @@ -403,27 +403,34 @@ void CViewer3dDoc::OnUpdateOverlappedBox(CCmdUI* pCmdUI) void CViewer3dDoc::OnObjectRemove() { - if(myAISContext->IsCurrent(myBox)) + // A small trick to avoid complier error (C2668). + const Handle(AIS_InteractiveObject)& aBox = myBox; + if(myAISContext->IsSelected (aBox)) myBox.Nullify(); - if(myAISContext->IsCurrent(myCylinder)) + const Handle(AIS_InteractiveObject)& aCylinder = myCylinder; + if(myAISContext->IsSelected (aCylinder)) myCylinder.Nullify(); - if(myAISContext->IsCurrent(mySphere)) + const Handle(AIS_InteractiveObject)& aSphere = mySphere; + if(myAISContext->IsSelected (aSphere)) mySphere.Nullify(); - if(myAISContext->IsCurrent(myOverlappedBox)) + const Handle(AIS_InteractiveObject)& anOverlappedBox = myOverlappedBox; + if(myAISContext->IsSelected (anOverlappedBox)) myOverlappedBox.Nullify(); - if(myAISContext->IsCurrent(myOverlappedCylinder)) + const Handle(AIS_InteractiveObject)& anOverlappedCylinder = myOverlappedCylinder; + if(myAISContext->IsSelected (anOverlappedCylinder)) myOverlappedCylinder.Nullify(); - if(myAISContext->IsCurrent(myOverlappedSphere)) + const Handle(AIS_InteractiveObject)& anOverlappedSphere = myOverlappedSphere; + if(myAISContext->IsSelected (anOverlappedSphere)) myOverlappedSphere.Nullify(); - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->InitCurrent()) - myAISContext->Remove(myAISContext->Current(),Standard_True); + for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->InitSelected()) + myAISContext->Remove(myAISContext->SelectedInteractive(),Standard_True); if(myOffsetDlg && myOffsetDlg->IsWindowVisible()) myOffsetDlg->UpdateValues(); @@ -532,7 +539,6 @@ void CViewer3dDoc::InputEvent(const Standard_Integer /*x*/, myAISContext->Redisplay (aSelectedObject); myState = -1; - myAISContext->CloseLocalContext(); } } @@ -588,20 +594,20 @@ void CViewer3dDoc::ShiftInputEvent (const Standard_Integer theX, void CViewer3dDoc::OnObjectColoredMesh() { - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent()) - if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder))) + for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->NextSelected()) + if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder))) { - myAISContext->ClearPrs(myAISContext->Current(),6,Standard_False); - myAISContext->RecomputePrsOnly(myAISContext->Current(),Standard_False); - myAISContext->SetDisplayMode(myAISContext->Current(),6); + myAISContext->ClearPrs(myAISContext->SelectedInteractive(),6,Standard_False); + myAISContext->RecomputePrsOnly(myAISContext->SelectedInteractive(), Standard_False); + myAISContext->SetDisplayMode(myAISContext->SelectedInteractive(), 6); } } void CViewer3dDoc::OnUpdateObjectColoredMesh(CCmdUI* pCmdUI) { bool CylinderIsCurrentAndDisplayed = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if(myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder))) + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if(myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder))) CylinderIsCurrentAndDisplayed=true; pCmdUI->Enable (CylinderIsCurrentAndDisplayed); } @@ -609,8 +615,8 @@ void CViewer3dDoc::OnUpdateObjectColoredMesh(CCmdUI* pCmdUI) void CViewer3dDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI) { bool OneOrMoreInShadingOrColoredMesh = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1) || myAISContext->IsDisplayed(myAISContext->Current(),6)) + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(), 1) || myAISContext->IsDisplayed(myAISContext->SelectedInteractive(), 6)) OneOrMoreInShadingOrColoredMesh=true; pCmdUI->Enable (OneOrMoreInShadingOrColoredMesh); } @@ -619,8 +625,8 @@ void CViewer3dDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI) void CViewer3dDoc::OnUpdateObjectShading(CCmdUI* pCmdUI) { bool OneOrMoreInWireframeOrColoredMesh = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),0) || myAISContext->IsDisplayed(myAISContext->Current(),6)) + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),0) || myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),6)) OneOrMoreInWireframeOrColoredMesh=true; pCmdUI->Enable (OneOrMoreInWireframeOrColoredMesh); } @@ -668,10 +674,10 @@ void CViewer3dDoc::Popup (const Standard_Integer x, { myPopupMenuNumber=0; // Specified check for context menu number to call - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) { - if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder))) + if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder))) { myPopupMenuNumber = 2; //return; @@ -683,9 +689,7 @@ void CViewer3dDoc::Popup (const Standard_Integer x, //Set faces selection mode void CViewer3dDoc::OnFaces() { - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_FACE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_FACE)); myCResultDialog.SetTitle("Standard mode: TopAbs_FACE"); myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n" @@ -698,9 +702,7 @@ void CViewer3dDoc::OnFaces() //Set edges selection mode void CViewer3dDoc::OnEdges() { - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode(TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); myCResultDialog.SetTitle("Standard mode: TopAbs_EDGE"); myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n" @@ -713,9 +715,7 @@ void CViewer3dDoc::OnEdges() // Set vertices selection mode void CViewer3dDoc::OnVertices() { - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_VERTEX); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX)); myCResultDialog.SetTitle("Standard mode: TopAbs_VERTEX"); myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n" @@ -728,8 +728,6 @@ void CViewer3dDoc::OnVertices() //Neutral selection mode void CViewer3dDoc::OnNeutral() { - myAISContext->CloseAllContexts(); - myCResultDialog.SetTitle("Standard mode: Neutral"); myCResultDialog.SetText(" myAISContext->CloseAllContexts(); \n" " \n"); @@ -739,8 +737,7 @@ void CViewer3dDoc::OnNeutral() // Change the color of faces on a user cylinder void CViewer3dDoc::OnUsercylinderChangefacecolor() { - myAISContext->OpenLocalContext(); - myAISContext->Activate(myAISContext->Current(),4); + myAISContext->Activate(myAISContext->SelectedInteractive(), 4); myState = FACE_COLOR; // see the following of treatment in inputevent } @@ -750,13 +747,6 @@ void CViewer3dDoc::OnUsercylinderChangefacecolor() // before running this function void CViewer3dDoc::OnFillet3d() { - if (!myAISContext->HasOpenedContext()) - { - AfxMessageBox (L"It is necessary to activate the edges selection mode\n" - L"and select edges on an object before \nrunning this function"); - return; - } - myAISContext->InitSelected(); if (myAISContext->MoreSelected()) { diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp index cd24c093df..161a9cc173 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp @@ -401,7 +401,6 @@ void CViewer3dView::OnLButtonDown(UINT nFlags, CPoint point) { p1 = ConvertClickToPoint(point.x,point.y,myView); myCurrent_PositionalLight->SetPosition(p1.X(),p1.Y(),p1.Z()) ; - GetDocument()->GetAISContext()->CloseLocalContext(); ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready"); myCurrentMode = CurAction3d_Nothing; @@ -449,7 +448,6 @@ GetDocument()->UpdateResultMessageDlg("SetAngle",Message); break; case CurAction3d_EndSpotLight : GetDocument()->GetAISContext()->Erase(spotConeShape); - GetDocument()->GetAISContext()->CloseLocalContext(); ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready"); myCurrentMode = CurAction3d_Nothing; break; @@ -477,7 +475,6 @@ GetDocument()->UpdateResultMessageDlg("SetDirection",Message); break; case CurAction3d_EndDirectionalLight: GetDocument()->GetAISContext()->Erase(directionalEdgeShape); - GetDocument()->GetAISContext()->CloseLocalContext(); ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready"); myCurrentMode = CurAction3d_Nothing; break; @@ -888,7 +885,6 @@ void CViewer3dView::OnDirectionalLight() UpdateData(TRUE); ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick a first point"); - GetDocument()->GetAISContext()->OpenLocalContext(); myCurrentMode = CurAction3d_BeginDirectionalLight; TCollection_AsciiString Message("\ @@ -914,7 +910,6 @@ void CViewer3dView::OnSpotLight() return; } - GetDocument()->GetAISContext()->OpenLocalContext(); ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position"); myCurrentMode = CurAction3d_BeginSpotLight; @@ -941,7 +936,6 @@ void CViewer3dView::OnPositionalLight() return; } - GetDocument()->GetAISContext()->OpenLocalContext(); myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),0,0,0,Quantity_NOC_GREEN,1,0); myView->SetLightOn(myCurrent_PositionalLight); NbActiveLights++; @@ -971,11 +965,9 @@ void CViewer3dView::OnAmbientLight() return; } - GetDocument()->GetAISContext()->OpenLocalContext(); myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY); myView->SetLightOn(myCurrent_AmbientLight) ; NbActiveLights++; - GetDocument()->GetAISContext()->CloseLocalContext(); myView->UpdateLights(); diff --git a/samples/mfc/standard/05_ImportExport/src/ImportExportDoc.cpp b/samples/mfc/standard/05_ImportExport/src/ImportExportDoc.cpp index 8caada501a..df7cbcf5ff 100755 --- a/samples/mfc/standard/05_ImportExport/src/ImportExportDoc.cpp +++ b/samples/mfc/standard/05_ImportExport/src/ImportExportDoc.cpp @@ -190,8 +190,8 @@ void CImportExportDoc::Popup(const Standard_Integer x, const Handle(V3d_View)& aView ) { Standard_Integer PopupMenuNumber=0; - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) PopupMenuNumber=1; CMenu menu; @@ -202,8 +202,8 @@ void CImportExportDoc::Popup(const Standard_Integer x, if (PopupMenuNumber == 1) // more than 1 object. { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; if(!OneOrMoreInShading) pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); } @@ -260,8 +260,8 @@ void CImportExportDoc::OnCylinder() void CImportExportDoc::OnObjectRemove() { - for(GetAISContext()->InitCurrent();GetAISContext()->MoreCurrent();GetAISContext()->NextCurrent()) { - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(GetAISContext()->Current()); + for(GetAISContext()->InitSelected();GetAISContext()->MoreSelected();GetAISContext()->NextSelected()) { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(GetAISContext()->SelectedInteractive()); if(!aShape.IsNull()) { m_pcoloredshapeList->Remove(aShape->Shape()); } @@ -272,8 +272,8 @@ void CImportExportDoc::OnObjectRemove() void CImportExportDoc::OnObjectErase() { - for(GetAISContext()->InitCurrent();GetAISContext()->MoreCurrent();GetAISContext()->NextCurrent()) { - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(GetAISContext()->Current()); + for(GetAISContext()->InitSelected();GetAISContext()->MoreSelected();GetAISContext()->NextSelected()) { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(GetAISContext()->SelectedInteractive()); if(!aShape.IsNull()) { m_pcoloredshapeList->Remove(aShape->Shape()); } diff --git a/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp b/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp index e6d43c95d8..bcca144a6d 100755 --- a/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp +++ b/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp @@ -316,8 +316,8 @@ D->CommitCommand(); \n\ void COcafDoc::OnModify() { // Get the selected interactive object - myAISContext->InitCurrent(); - Handle(AIS_InteractiveObject) curAISObject = myAISContext->Current(); + myAISContext->InitSelected(); + Handle(AIS_InteractiveObject) curAISObject = myAISContext->SelectedInteractive(); // Get the main label of the selected object @@ -678,17 +678,17 @@ D->CommitCommand(); \n\ void COcafDoc::OnUpdateModify(CCmdUI* pCmdUI) { // Disable the "modify" button if there is no selected object or several selected objects - myAISContext->InitCurrent(); - if(myAISContext->NbCurrents()!=1) + myAISContext->InitSelected(); + if(myAISContext->NbSelected()!=1) { pCmdUI->Enable(Standard_False); return; } // Get the root label of the selected object using its TPrsStd_AISPresentation - myAISContext->InitCurrent(); + myAISContext->InitSelected(); Handle(TPrsStd_AISPresentation) ObjectPrs = - Handle(TPrsStd_AISPresentation)::DownCast(myAISContext->Current()->GetOwner()); + Handle(TPrsStd_AISPresentation)::DownCast(myAISContext->SelectedInteractive()->GetOwner()); if (!ObjectPrs.IsNull()){ TDF_Label LabObject = ObjectPrs->Label(); @@ -815,10 +815,10 @@ void COcafDoc::OnObjectDelete() D->NewCommand(); AIS_SequenceOfInteractive aSequence; - for(myAISContext->InitCurrent(); - myAISContext->MoreCurrent(); - myAISContext->NextCurrent()) - aSequence.Append(myAISContext->Current()); + for(myAISContext->InitSelected(); + myAISContext->MoreSelected(); + myAISContext->NextSelected()) + aSequence.Append(myAISContext->SelectedInteractive()); for(int iter=1;iter <=aSequence.Length();iter++) { @@ -860,8 +860,8 @@ void COcafDoc::OnObjectDelete() void COcafDoc::OnUpdateObjectDelete(CCmdUI* pCmdUI) { - myAISContext->InitCurrent(); - pCmdUI->Enable (myAISContext->MoreCurrent()); + myAISContext->InitSelected(); + pCmdUI->Enable (myAISContext->MoreSelected()); } void COcafDoc::DisplayPrs() @@ -1172,8 +1172,8 @@ void COcafDoc::Popup(const Standard_Integer x, const Handle(V3d_View)& aView ) { Standard_Integer PopupMenuNumber=0; - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) PopupMenuNumber=1; CMenu menu; @@ -1184,8 +1184,8 @@ void COcafDoc::Popup(const Standard_Integer x, if (PopupMenuNumber == 1) // more than 1 object. { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; if(!OneOrMoreInShading) pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); } diff --git a/samples/mfc/standard/08_HLR/src/HLRDoc.cpp b/samples/mfc/standard/08_HLR/src/HLRDoc.cpp index 3a8f553401..d5ebad740e 100755 --- a/samples/mfc/standard/08_HLR/src/HLRDoc.cpp +++ b/samples/mfc/standard/08_HLR/src/HLRDoc.cpp @@ -182,20 +182,20 @@ void CHLRDoc::Fit() void CHLRDoc::OnObjectErase() { Standard_Boolean toUpdateDisplayable = Standard_False; - myAISContext->InitCurrent(); - while (myAISContext->MoreCurrent()) + myAISContext->InitSelected(); + while (myAISContext->MoreSelected()) { - if (myAISContext->Current()->Type() == AIS_KOI_Shape && myCSelectionDialogIsCreated) + if (myAISContext->SelectedInteractive()->Type() == AIS_KOI_Shape && myCSelectionDialogIsCreated) { - myCSelectionDialog->DiplayableShape()->Remove (Handle(AIS_Shape)::DownCast (myAISContext->Current())->Shape()); + myCSelectionDialog->DiplayableShape()->Remove (Handle(AIS_Shape)::DownCast (myAISContext->SelectedInteractive())->Shape()); toUpdateDisplayable = Standard_True; } - myAISContext->Erase (myAISContext->Current(), Standard_True); - myAISContext->InitCurrent(); + myAISContext->Erase (myAISContext->SelectedInteractive(), Standard_True); + myAISContext->InitSelected(); } - myAISContext->ClearCurrents(); + myAISContext->ClearSelected(); if (toUpdateDisplayable) { diff --git a/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp b/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp index a0a5a0982b..4e68ef6ccc 100644 --- a/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp +++ b/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp @@ -174,11 +174,11 @@ void CSelectionDialog::UpdateViews() // Display chosen shapes in the HLR dialog view. Standard_Boolean OneOrMoreFound = Standard_False; - for (myDoc->GetAISContext()->InitCurrent(); - myDoc->GetAISContext()->MoreCurrent(); - myDoc->GetAISContext()->NextCurrent()) + for (myDoc->GetAISContext()->InitSelected(); + myDoc->GetAISContext()->MoreSelected(); + myDoc->GetAISContext()->NextSelected()) { - Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (myDoc->GetAISContext()->Current()); + Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (myDoc->GetAISContext()->SelectedInteractive()); if (!anAISShape.IsNull()) { OneOrMoreFound = Standard_True; @@ -207,11 +207,11 @@ void CSelectionDialog::OnGetSelectedShapes() myInteractiveContext->Display (myTrihedron); Standard_Boolean OneOrMoreFound = Standard_False; - for (myDoc->GetAISContext()->InitCurrent(); - myDoc->GetAISContext()->MoreCurrent(); - myDoc->GetAISContext()->NextCurrent()) + for (myDoc->GetAISContext()->InitSelected(); + myDoc->GetAISContext()->MoreSelected(); + myDoc->GetAISContext()->NextSelected()) { - Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (myDoc->GetAISContext()->Current()); + Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (myDoc->GetAISContext()->SelectedInteractive()); if (!anAISShape.IsNull()) { diff --git a/samples/mfc/standard/Common/AISDialogs.cpp b/samples/mfc/standard/Common/AISDialogs.cpp index 944c506d3a..d7b0a2dbc9 100755 --- a/samples/mfc/standard/Common/AISDialogs.cpp +++ b/samples/mfc/standard/Common/AISDialogs.cpp @@ -312,10 +312,10 @@ void CDialogMaterial::OnMaterial(UINT nID) void CDialogMaterial::SetMaterial(Graphic3d_NameOfMaterial Material) { Standard_Real aTransparency; - for (myCurrentIC->InitCurrent();myCurrentIC->MoreCurrent ();myCurrentIC->NextCurrent ()){ - aTransparency = myCurrentIC->Current()->Transparency(); - myCurrentIC->SetMaterial (myCurrentIC->Current(),(Graphic3d_NameOfMaterial)(Material)); - myCurrentIC->SetTransparency (myCurrentIC->Current(),aTransparency); + for (myCurrentIC->InitSelected();myCurrentIC->MoreSelected ();myCurrentIC->NextSelected ()){ + aTransparency = myCurrentIC->SelectedInteractive()->Transparency(); + myCurrentIC->SetMaterial (myCurrentIC->SelectedInteractive(),(Graphic3d_NameOfMaterial)(Material)); + myCurrentIC->SetTransparency (myCurrentIC->SelectedInteractive(),aTransparency); } } @@ -358,11 +358,11 @@ CDialogTransparency::CDialogTransparency(Handle(AIS_InteractiveContext) CurrentI Standard_Real temp = 10; Standard_Real t; - for (myCurrentIC->InitCurrent(); - myCurrentIC->MoreCurrent (); - myCurrentIC->NextCurrent ()) + for (myCurrentIC->InitSelected(); + myCurrentIC->MoreSelected (); + myCurrentIC->NextSelected ()) { - t = CurrentIC->Current()->Transparency(); + t = CurrentIC->SelectedInteractive()->Transparency(); if (temp > t) temp = t; //myCurrentIC->SetTransparency (myCurrentIC->Current(), m_TransValue); @@ -372,11 +372,11 @@ CDialogTransparency::CDialogTransparency(Handle(AIS_InteractiveContext) CurrentI if (Abs(m_TransValue - temp * 10) > 0.01) m_TransValue = int (temp * 10) + 1; - for (myCurrentIC->InitCurrent(); - myCurrentIC->MoreCurrent (); - myCurrentIC->NextCurrent ()) + for (myCurrentIC->InitSelected(); + myCurrentIC->MoreSelected (); + myCurrentIC->NextSelected ()) { - myCurrentIC->SetTransparency (myCurrentIC->Current(), temp); + myCurrentIC->SetTransparency (myCurrentIC->SelectedInteractive(), temp); } @@ -414,11 +414,11 @@ void CDialogTransparency::OnDeltaposSpinaistransp(NMHDR* pNMHDR, LRESULT* pResul UpdateData (false); - for (myCurrentIC->InitCurrent(); - myCurrentIC->MoreCurrent (); - myCurrentIC->NextCurrent()) + for (myCurrentIC->InitSelected(); + myCurrentIC->MoreSelected (); + myCurrentIC->NextSelected()) { - myCurrentIC->SetTransparency (myCurrentIC->Current(), m_TransValue/10.0); + myCurrentIC->SetTransparency (myCurrentIC->SelectedInteractive(), m_TransValue/10.0); } *pResult = 0; @@ -431,11 +431,11 @@ void CDialogTransparency::OnChangeEditaistransp() // TODO: Add your control notification handler code here int temp = m_TransValue; if (UpdateData (true)){ - for (myCurrentIC->InitCurrent(); - myCurrentIC->MoreCurrent (); - myCurrentIC->NextCurrent()) + for (myCurrentIC->InitSelected(); + myCurrentIC->MoreSelected (); + myCurrentIC->NextSelected()) { - myCurrentIC->SetTransparency (myCurrentIC->Current(), m_TransValue/10.0); + myCurrentIC->SetTransparency (myCurrentIC->SelectedInteractive(), m_TransValue/10.0); } } else{ diff --git a/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp b/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp index d3f478399a..327d09498e 100644 --- a/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp +++ b/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp @@ -63,20 +63,12 @@ END_MESSAGE_MAP() void CAngleParamsVerticesPage::OnBnClickedVertex1Btn() { - // Open local context and choose the vertex for angle dimensions - if (!myAISContext->HasOpenedContext()) - { - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode(TopAbs_VERTEX); - AfxMessageBox (_T ("Local context was not opened. Choose the edge and press the button again"), - MB_ICONINFORMATION | MB_OK); - return; - } + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX)); - // Now it's ok, local context is opened and edge selection mode is activated + // Now it's ok, edge selection mode is activated // Check if some vertex is selected - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_VERTEX) { AfxMessageBox (_T ("Choose the vertex and press the button again"), @@ -84,8 +76,8 @@ void CAngleParamsVerticesPage::OnBnClickedVertex1Btn() return; } - myFirstVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myFirstVertex = TopoDS::Vertex (myAISContext->SelectedShape()); + myAISContext->ClearSelected(); } //======================================================================= @@ -95,17 +87,17 @@ void CAngleParamsVerticesPage::OnBnClickedVertex1Btn() void CAngleParamsVerticesPage::OnBnClickedVertex2Btn() { - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_VERTEX) { AfxMessageBox ( _T("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); return; } - mySecondVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + mySecondVertex = TopoDS::Vertex (myAISContext->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); } //======================================================================= @@ -115,15 +107,15 @@ void CAngleParamsVerticesPage::OnBnClickedVertex2Btn() void CAngleParamsVerticesPage::OnBnClickedVertex3Btn() { - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected()) + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected()) { AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); return; } - myThirdVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myThirdVertex = TopoDS::Vertex (myAISContext->SelectedShape()); + myAISContext->ClearSelected(); //Build dimension here TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge (myFirstVertex, mySecondVertex); @@ -159,8 +151,6 @@ void CAngleParamsVerticesPage::OnBnClickedVertex3Btn() } } anAngleDim->SetDimensionAspect (anAspect); - myAISContext->CloseAllContexts(); myAISContext->Display (anAngleDim); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_VERTEX); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX)); } diff --git a/samples/mfc/standard/Common/DimensionDlg.cpp b/samples/mfc/standard/Common/DimensionDlg.cpp index 9bd20223e0..e2a8c47e53 100644 --- a/samples/mfc/standard/Common/DimensionDlg.cpp +++ b/samples/mfc/standard/Common/DimensionDlg.cpp @@ -139,11 +139,6 @@ void CDimensionDlg::DoDataExchange (CDataExchange* pDX) void CDimensionDlg::OnBnClickedOk() { - if (myAISContext->HasOpenedContext()) - { - myAISContext->CloseAllContexts(); - } - OnOK(); } @@ -297,8 +292,6 @@ void CDimensionDlg::CreateDiameterParamsTab() void CDimensionDlg::UpdateStandardModeForAngle() { int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetCurSel(); - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); TopAbs_ShapeEnum aMode; if (aTabNum == 1) @@ -314,7 +307,7 @@ void CDimensionDlg::UpdateStandardModeForAngle() aMode = TopAbs_EDGE; } - myAISContext->ActivateStandardMode (aMode); + myAISContext->Activate (AIS_Shape::SelectionMode (aMode)); } //======================================================================= @@ -325,8 +318,7 @@ void CDimensionDlg::UpdateStandardModeForAngle() void CDimensionDlg::UpdateStandardModeForLength() { int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetCurSel(); - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); + TopAbs_ShapeEnum aMode; if (aTabNum == 1) @@ -341,7 +333,7 @@ void CDimensionDlg::UpdateStandardModeForLength() { aMode = TopAbs_EDGE; } - myAISContext->ActivateStandardMode (aMode); + myAISContext->Activate (AIS_Shape::SelectionMode (aMode)); } //======================================================================= @@ -363,8 +355,7 @@ void CDimensionDlg::UpdateStandardMode() case IDC_DimRadius: case IDC_DimDiameter: { - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); } break; } @@ -414,9 +405,7 @@ void CDimensionDlg::OnBnClickedDimAngle() void CDimensionDlg::OnBnClickedDimDiameter() { // Update parameters - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); GetDlgItem (IDC_LengthTab)->ShowWindow (SW_HIDE); GetDlgItem (IDC_AngleTab)->ShowWindow (SW_HIDE); @@ -435,9 +424,7 @@ void CDimensionDlg::OnBnClickedDimDiameter() void CDimensionDlg::OnBnClickedDimRadius() { // Update parameters - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); GetDlgItem (IDC_LengthTab)->ShowWindow (SW_HIDE); GetDlgItem (IDC_AngleTab)->ShowWindow (SW_HIDE); GetDlgItem (IDC_RadiusTab)->ShowWindow (SW_SHOW); @@ -530,16 +517,7 @@ void CDimensionDlg::OnTcnSelChangingAngleTab (NMHDR * /*pNMHDR*/, LRESULT *pResu void CDimensionDlg::DeactivateAllStandardModes() { - if (myAISContext->HasOpenedContext()) - { - myAISContext->CloseAllContexts(); - for (TColStd_ListIteratorOfListOfInteger anIt (myAISContext->LocalContext()->StandardModes()); - anIt.More(); - anIt.Next()) - { - myAISContext->LocalContext()->DeactivateStandardMode ((TopAbs_ShapeEnum)anIt.Value()); - } - } + myAISContext->Deactivate(); } //======================================================================= @@ -549,10 +527,6 @@ void CDimensionDlg::DeactivateAllStandardModes() void CDimensionDlg::OnDestroy() { - if (myAISContext->HasOpenedContext()) - { - myAISContext->CloseAllContexts(); - } CWnd *aWnd; TC_ITEM anItem; anItem.mask = TCIF_PARAM; @@ -754,9 +728,5 @@ const Quantity_Color CDimensionDlg::GetDimensionColor() const void CDimensionDlg::OnClose() { - if (myAISContext->HasOpenedContext()) - { - myAISContext->CloseAllContexts(); - } CDialog::OnClose(); } diff --git a/samples/mfc/standard/Common/ImportExport/ImportExport.cpp b/samples/mfc/standard/Common/ImportExport/ImportExport.cpp index 36644fa931..02d5ca8141 100755 --- a/samples/mfc/standard/Common/ImportExport/ImportExport.cpp +++ b/samples/mfc/standard/Common/ImportExport/ImportExport.cpp @@ -56,7 +56,7 @@ Handle(TopTools_HSequenceOfShape) CImportExport::BuildSequenceFromContext(const Handle(TColStd_HArray1OfReal)& anArrayOfTransparencies) { Handle(TopTools_HSequenceOfShape) aSequence; - Standard_Integer nb = anInteractiveContext->NbCurrents(), i = 1; + Standard_Integer nb = anInteractiveContext->NbSelected(), i = 1; if (!nb) return aSequence; @@ -65,10 +65,10 @@ Handle(TopTools_HSequenceOfShape) CImportExport::BuildSequenceFromContext(const anArrayOfTransparencies = new TColStd_HArray1OfReal (1, nb); Handle(AIS_InteractiveObject) picked; - for(anInteractiveContext->InitCurrent();anInteractiveContext->MoreCurrent();anInteractiveContext->NextCurrent()) + for (anInteractiveContext->InitSelected(); anInteractiveContext->MoreSelected(); anInteractiveContext->NextSelected()) { - picked = anInteractiveContext->Current(); - if (anInteractiveContext->Current()->IsKind(STANDARD_TYPE(AIS_Shape))) + picked = anInteractiveContext->SelectedInteractive(); + if (picked->IsKind (STANDARD_TYPE (AIS_Shape))) { Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast(picked); TopoDS_Shape aShape = aisShape->Shape(); @@ -103,7 +103,8 @@ int CImportExport::ReadBREP (const Handle(AIS_InteractiveContext)& anInteractive aShape = new AIS_Shape(aSequence->Value(i)); anInteractiveContext->SetDisplayMode(aShape, 1, Standard_False); anInteractiveContext->Display(aShape, Standard_False); - anInteractiveContext->SetCurrentObject(aShape, Standard_False); + const Handle(AIS_InteractiveObject)& aPrs = aShape; // A small trick to avoid compiler error (C2668). + anInteractiveContext->SetSelected (aPrs, Standard_False); } return 0; } @@ -167,8 +168,8 @@ Standard_Boolean CImportExport::ReadBREP(CString aFileName, void CImportExport::SaveBREP(const Handle(AIS_InteractiveContext)& anInteractiveContext) { - anInteractiveContext->InitCurrent(); - if (anInteractiveContext->NbCurrents() == 0){ + anInteractiveContext->InitSelected(); + if (anInteractiveContext->NbSelected() == 0){ AfxMessageBox (L"No shape selected for export!"); return; } @@ -305,8 +306,8 @@ Standard_Integer CImportExport::ReadIGES(const Standard_CString& aFileName, void CImportExport::SaveIGES(const Handle(AIS_InteractiveContext)& anInteractiveContext) { - anInteractiveContext->InitCurrent(); - if (anInteractiveContext->NbCurrents() == 0){ + anInteractiveContext->InitSelected(); + if (anInteractiveContext->NbSelected() == 0){ AfxMessageBox (L"No shape selected for export!"); return; } @@ -456,8 +457,8 @@ IFSelect_ReturnStatus CImportExport::ReadSTEP(const Standard_CString& aFileName, //---------------------------------------------------------------------- void CImportExport::SaveSTEP(const Handle(AIS_InteractiveContext)& anInteractiveContext) { - anInteractiveContext->InitCurrent(); - if (anInteractiveContext->NbCurrents() == 0){ + anInteractiveContext->InitSelected(); + if (anInteractiveContext->NbSelected() == 0){ AfxMessageBox (L"No shape selected for export!"); return; } @@ -576,8 +577,8 @@ const STEPControl_StepModelType aValue /* =TopoDSToCc1Act_ManifoldSolidBrep */ ) void CImportExport::SaveSTL(const Handle(AIS_InteractiveContext)& anInteractiveContext) { - anInteractiveContext->InitCurrent(); - if (anInteractiveContext->NbCurrents() == 0){ + anInteractiveContext->InitSelected(); + if (anInteractiveContext->NbSelected() == 0){ AfxMessageBox (L"No shape selected for export!"); return; } @@ -663,8 +664,8 @@ Standard_Boolean CImportExport::SaveSTL(const Standard_CString& aFileName, void CImportExport::SaveVRML(const Handle(AIS_InteractiveContext)& anInteractiveContext) { - anInteractiveContext->InitCurrent(); - if (anInteractiveContext->NbCurrents() == 0){ + anInteractiveContext->InitSelected(); + if (anInteractiveContext->NbSelected() == 0){ AfxMessageBox (L"No shape selected for export!"); return; } diff --git a/samples/mfc/standard/Common/LengthParamsEdgePage.cpp b/samples/mfc/standard/Common/LengthParamsEdgePage.cpp index de8e3b55ea..5bc78bdd1c 100644 --- a/samples/mfc/standard/Common/LengthParamsEdgePage.cpp +++ b/samples/mfc/standard/Common/LengthParamsEdgePage.cpp @@ -67,9 +67,9 @@ CButton* CLengthParamsEdgePage::GetButton() void CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn() { - myAISContext->LocalContext()->InitSelected(); + myAISContext->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_EDGE) { AfxMessageBox ( _T("Choose the edge and press the button again"), MB_ICONINFORMATION | MB_OK); @@ -79,7 +79,7 @@ void CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn() TopoDS_Shape aSelShape = myAISContext->SelectedShape(); const TopoDS_Edge& anEdge = TopoDS::Edge (aSelShape); - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); TopoDS_Vertex aFirstVertex, aSecondVertex; TopExp::Vertices (TopoDS::Edge (anEdge), aFirstVertex, aSecondVertex); @@ -108,8 +108,6 @@ void CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn() aLenDim->SetDimensionAspect (anAspect); aLenDim->SetFlyout (aDimDlg->GetFlyout()); - myAISContext->CloseAllContexts(); myAISContext->Display (aLenDim); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode(TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); } diff --git a/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp b/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp index 966eaa78db..fd6a2e102e 100644 --- a/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp +++ b/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp @@ -58,20 +58,12 @@ END_MESSAGE_MAP() void CLengthParamsEdgesPage::OnBnClickedEdge1Btn() { - // Open local context and choose the edge for length dimensions - if (!myAISContext->HasOpenedContext()) - { - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_EDGE); - AfxMessageBox (_T("Local context was not opened. Choose the edge and press the button again"), - MB_ICONINFORMATION | MB_OK); - return; - } + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); - // Now it's ok, local context is opened and edge selection mode is activated + // Now it's ok, edge selection mode is activated // Check if some edge is selected - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_EDGE) { AfxMessageBox(_T("Choose the edge and press the button again"), @@ -81,7 +73,7 @@ void CLengthParamsEdgesPage::OnBnClickedEdge1Btn() myFirstEdge = TopoDS::Edge (myAISContext->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); } //======================================================================= @@ -91,8 +83,8 @@ void CLengthParamsEdgesPage::OnBnClickedEdge1Btn() void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() { - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_EDGE) { AfxMessageBox (_T("Choose the edge and press the button again"), @@ -102,7 +94,7 @@ void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() mySecondEdge = TopoDS::Edge (myAISContext->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); // Build plane through three points BRepAdaptor_Curve aCurve1 (myFirstEdge); @@ -118,8 +110,6 @@ void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); - myAISContext->CloseAllContexts(); - Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); anAspect->MakeArrows3d (Standard_False); anAspect->MakeText3d (aDimDlg->GetTextType()); @@ -162,6 +152,5 @@ void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() myAISContext->Display (aLenDim); } - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); } diff --git a/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp b/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp index a9d4ab1f97..2f6086c273 100644 --- a/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp +++ b/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp @@ -59,29 +59,21 @@ END_MESSAGE_MAP() void CLengthParamsVerticesPage::OnBnClickedVertex1Btn() { - // Open local context and choose the edge for length dimensions - if (!myAISContext->HasOpenedContext()) - { - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode(TopAbs_VERTEX); - AfxMessageBox(_T("Local context was not opened. Choose the vertices and press the button again"), - MB_ICONINFORMATION | MB_OK); - return; - } + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX)); - // Now it's ok, local context is opened and edge selection mode is activated + // Now it's ok, edge selection mode is activated // Check if some edge is selected - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_VERTEX) { AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); return; } - myFirstVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + myFirstVertex = TopoDS::Vertex (myAISContext->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); } //======================================================================= @@ -91,16 +83,16 @@ void CLengthParamsVerticesPage::OnBnClickedVertex1Btn() void CLengthParamsVerticesPage::OnBnClickedVertex2Btn() { - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_VERTEX) { AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); return; } - mySecondVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + mySecondVertex = TopoDS::Vertex (myAISContext->SelectedShape()); + myAISContext->ClearSelected(); //Build dimension here gp_Pnt aP1=BRep_Tool::Pnt (myFirstVertex); @@ -128,10 +120,8 @@ void CLengthParamsVerticesPage::OnBnClickedVertex2Btn() aLenDim->SetDimensionAspect (anAspect); aLenDim->SetFlyout (aDimDlg->GetFlyout()); - myAISContext->CloseAllContexts(); myAISContext->Display (aLenDim); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_VERTEX); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX)); } //======================================================================= diff --git a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp index 9bcf11984e..5f5bd22c89 100755 --- a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp +++ b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp @@ -202,8 +202,8 @@ void OCC_3dBaseDoc::Popup (const Standard_Integer theMouseX, // Base check which context menu to call if (!myPopupMenuNumber) { - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) + myAISContext->InitSelected(); + if (myAISContext->MoreSelected()) myPopupMenuNumber=1; } @@ -215,8 +215,8 @@ void OCC_3dBaseDoc::Popup (const Standard_Integer theMouseX, if (myPopupMenuNumber == 1) // more than 1 object. { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; if(!OneOrMoreInShading) pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); } @@ -261,10 +261,10 @@ void OCC_3dBaseDoc::OnObjectColor() COLORREF MSColor ; Quantity_Color CSFColor ; - myAISContext->InitCurrent(); - Current = myAISContext->Current(); + myAISContext->InitSelected(); + Current = myAISContext->SelectedInteractive(); if ( Current->HasColor () ) { - CSFColor = myAISContext->Color(myAISContext->Current()); + CSFColor = myAISContext->Color(Current); MSColor = RGB (CSFColor.Red()*255.,CSFColor.Green()*255.,CSFColor.Blue()*255.); } else { @@ -277,16 +277,16 @@ void OCC_3dBaseDoc::OnObjectColor() MSColor = dlgColor.GetColor(); CSFColor = Quantity_Color (GetRValue(MSColor)/255.,GetGValue(MSColor)/255., GetBValue(MSColor)/255.,Quantity_TOC_RGB); - for (;myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - myAISContext->SetColor (myAISContext->Current(),CSFColor.Name()); + for (;myAISContext->MoreSelected ();myAISContext->NextSelected ()) + myAISContext->SetColor (myAISContext->SelectedInteractive(),CSFColor.Name()); } } void OCC_3dBaseDoc::OnUpdateObjectColor(CCmdUI* pCmdUI) { bool OneOrMoreIsShadingOrWireframe = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),0) - ||myAISContext->IsDisplayed(myAISContext->Current(),1)) + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),0) + ||myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreIsShadingOrWireframe=true; pCmdUI->Enable (OneOrMoreIsShadingOrWireframe); } @@ -294,14 +294,14 @@ void OCC_3dBaseDoc::OnUpdateObjectColor(CCmdUI* pCmdUI) void OCC_3dBaseDoc::OnObjectErase() { myAISContext->EraseSelected(); - myAISContext->ClearCurrents(); + myAISContext->ClearSelected(); } void OCC_3dBaseDoc::OnUpdateObjectErase(CCmdUI* pCmdUI) { bool OneOrMoreIsDisplayed = false; - for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent()) + for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected()) { - if (myAISContext->IsDisplayed (myAISContext->Current())) + if (myAISContext->IsDisplayed (myAISContext->SelectedInteractive())) OneOrMoreIsDisplayed = true; } pCmdUI->Enable (OneOrMoreIsDisplayed); @@ -309,28 +309,28 @@ void OCC_3dBaseDoc::OnUpdateObjectErase(CCmdUI* pCmdUI) void OCC_3dBaseDoc::OnObjectWireframe() { - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent()) - myAISContext->SetDisplayMode(myAISContext->Current(),0); + for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->NextSelected()) + myAISContext->SetDisplayMode(myAISContext->SelectedInteractive(),0); } void OCC_3dBaseDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI) { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; pCmdUI->Enable (OneOrMoreInShading); } void OCC_3dBaseDoc::OnObjectShading() { - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent()) - myAISContext->SetDisplayMode(myAISContext->Current(),1); + for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->NextSelected()) + myAISContext->SetDisplayMode(myAISContext->SelectedInteractive(),1); } void OCC_3dBaseDoc::OnUpdateObjectShading(CCmdUI* pCmdUI) { bool OneOrMoreInWireframe = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),0)) OneOrMoreInWireframe=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),0)) OneOrMoreInWireframe=true; pCmdUI->Enable (OneOrMoreInWireframe); } @@ -346,8 +346,8 @@ void OCC_3dBaseDoc::OnObjectMaterial() void OCC_3dBaseDoc::OnUpdateObjectMaterial(CCmdUI* pCmdUI) { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; pCmdUI->Enable (OneOrMoreInShading); } @@ -357,10 +357,10 @@ BOOL OCC_3dBaseDoc::OnObjectMaterialRange(UINT nID) // continue with the same values as enumeration Type Of Material Standard_Real aTransparency; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()){ - aTransparency = myAISContext->Current()->Transparency(); - myAISContext->SetMaterial (myAISContext->Current(),(Graphic3d_NameOfMaterial)(nID-ID_OBJECT_MATERIAL_BRASS)); - myAISContext->SetTransparency (myAISContext->Current(),aTransparency); + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()){ + aTransparency = myAISContext->SelectedInteractive()->Transparency(); + myAISContext->SetMaterial (myAISContext->SelectedInteractive(),(Graphic3d_NameOfMaterial)(nID-ID_OBJECT_MATERIAL_BRASS)); + myAISContext->SetTransparency (myAISContext->SelectedInteractive(),aTransparency); } return true; @@ -369,11 +369,11 @@ BOOL OCC_3dBaseDoc::OnObjectMaterialRange(UINT nID) void OCC_3dBaseDoc::OnUpdateObjectMaterialRange(CCmdUI* pCmdUI) { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; pCmdUI->Enable (OneOrMoreInShading); - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->Current()->Material() - (pCmdUI->m_nID - ID_OBJECT_MATERIAL_BRASS) == 0) + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->SelectedInteractive()->Material() - (pCmdUI->m_nID - ID_OBJECT_MATERIAL_BRASS) == 0) pCmdUI->SetCheck(1); } @@ -391,8 +391,8 @@ void OCC_3dBaseDoc::OnObjectTransparency() void OCC_3dBaseDoc::OnUpdateObjectTransparency(CCmdUI* pCmdUI) { bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true; pCmdUI->Enable (OneOrMoreInShading); } @@ -419,22 +419,22 @@ void OCC_3dBaseDoc::OnUpdateObjectDisplayall(CCmdUI* pCmdUI) void OCC_3dBaseDoc::OnObjectRemove() { - for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->InitCurrent()) - myAISContext->Remove(myAISContext->Current(),Standard_True); + for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->InitSelected()) + myAISContext->Remove(myAISContext->SelectedInteractive(),Standard_True); } void OCC_3dBaseDoc::OnUpdateObjectRemove(CCmdUI* pCmdUI) { bool OneOrMoreIsDisplayed = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current())) OneOrMoreIsDisplayed=true; + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive())) OneOrMoreIsDisplayed=true; pCmdUI->Enable (OneOrMoreIsDisplayed); } void OCC_3dBaseDoc::SetMaterial(Graphic3d_NameOfMaterial Material) { - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - myAISContext->SetMaterial (myAISContext->Current(), + for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ()) + myAISContext->SetMaterial (myAISContext->SelectedInteractive(), (Graphic3d_NameOfMaterial)(Material)); } diff --git a/samples/mfc/standard/Common/ParamsFacesPage.cpp b/samples/mfc/standard/Common/ParamsFacesPage.cpp index 55b2b3186e..f8febe7227 100644 --- a/samples/mfc/standard/Common/ParamsFacesPage.cpp +++ b/samples/mfc/standard/Common/ParamsFacesPage.cpp @@ -5,7 +5,6 @@ #include "ParamsFacesPage.h" #include "DimensionDlg.h" #include -#include #include #include @@ -43,8 +42,8 @@ END_MESSAGE_MAP() void CParamsFacesPage::OnBnClickedFacesbtn1() { // Check if face is selected - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_FACE) { AfxMessageBox(_T("Choose the face and press the button again"), @@ -54,14 +53,16 @@ void CParamsFacesPage::OnBnClickedFacesbtn1() myFirstFace = TopoDS::Face (myAISContext->SelectedShape()); - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); } void CParamsFacesPage::OnBnClickedFacesbtn2() { + const Standard_Integer aSelectionMode = AIS_Shape::SelectionMode (TopAbs_FACE); + // Check if face is selected - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_FACE) { AfxMessageBox(_T("Choose the face and press the button again"), @@ -70,12 +71,11 @@ void CParamsFacesPage::OnBnClickedFacesbtn2() } mySecondFace = TopoDS::Face (myAISContext->SelectedShape()); - - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); - myAISContext->CloseAllContexts(); + myAISContext->Deactivate (aSelectionMode); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); anAspect->MakeArrows3d (Standard_False); @@ -120,6 +120,5 @@ void CParamsFacesPage::OnBnClickedFacesbtn2() myAISContext->Display (aLenDim); } - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_FACE); + myAISContext->Activate (aSelectionMode); } diff --git a/samples/mfc/standard/Common/RadiusParamsPage.cpp b/samples/mfc/standard/Common/RadiusParamsPage.cpp index 1a80ed3ef9..b249f03a5b 100644 --- a/samples/mfc/standard/Common/RadiusParamsPage.cpp +++ b/samples/mfc/standard/Common/RadiusParamsPage.cpp @@ -58,8 +58,8 @@ END_MESSAGE_MAP() void CRadiusParamsPage::OnBnClickedObjectBtn() { //Build dimension here - myAISContext->LocalContext()->InitSelected(); - if (!myAISContext->LocalContext()->MoreSelected() || + myAISContext->InitSelected(); + if (!myAISContext->MoreSelected() || myAISContext->SelectedShape().ShapeType() != TopAbs_EDGE) { AfxMessageBox (_T ("Choose the edge and press the button again"), MB_ICONINFORMATION | MB_OK); @@ -94,7 +94,7 @@ void CRadiusParamsPage::OnBnClickedObjectBtn() } } - myAISContext->LocalContext()->ClearSelected(); + myAISContext->ClearSelected(); CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner()); // Try to create dimension if it is possible Handle(AIS_Dimension) aDim; @@ -124,10 +124,7 @@ void CRadiusParamsPage::OnBnClickedObjectBtn() aDim->SetDimensionAspect (anAspect); // Display dimension in the neutral point - myAISContext->CloseAllContexts(); myAISContext->Display (aDim); - - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode (TopAbs_EDGE); + myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE)); } diff --git a/samples/qt/Common/src/ApplicationCommon.cxx b/samples/qt/Common/src/ApplicationCommon.cxx index 05a86b82a4..c3e9bf722f 100755 --- a/samples/qt/Common/src/ApplicationCommon.cxx +++ b/samples/qt/Common/src/ApplicationCommon.cxx @@ -544,11 +544,11 @@ void ApplicationCommonWindow::onSelectionChanged() int numSel = context->NbSelected(); if ( numSel ) { - for ( context->InitCurrent(); context->MoreCurrent(); context->NextCurrent() ) + for ( context->InitSelected(); context->MoreSelected(); context->NextSelected() ) { - if ( context->IsDisplayed( context->Current(), 1 ) ) + if ( context->IsDisplayed( context->SelectedInteractive(), 1 ) ) OneOrMoreInShading = true; - if ( context->IsDisplayed( context->Current(), 0 ) ) + if ( context->IsDisplayed( context->SelectedInteractive(), 0 ) ) OneOrMoreInWireframe = true; } myToolActions.at( ToolWireframeId )->setEnabled( OneOrMoreInShading ); diff --git a/samples/qt/Common/src/DocumentCommon.cxx b/samples/qt/Common/src/DocumentCommon.cxx index 871e087e73..1071bf483e 100755 --- a/samples/qt/Common/src/DocumentCommon.cxx +++ b/samples/qt/Common/src/DocumentCommon.cxx @@ -159,8 +159,8 @@ void DocumentCommon::fitAll() void DocumentCommon::onWireframe() { QApplication::setOverrideCursor( Qt::WaitCursor ); - for( myContext->InitCurrent(); myContext->MoreCurrent(); myContext->NextCurrent() ) - myContext->SetDisplayMode( myContext->Current(), 0, false ); + for( myContext->InitSelected(); myContext->MoreSelected(); myContext->NextSelected() ) + myContext->SetDisplayMode( myContext->SelectedInteractive(), 0, false ); myContext->UpdateCurrentViewer(); getApplication()->onSelectionChanged(); QApplication::restoreOverrideCursor(); @@ -169,8 +169,8 @@ void DocumentCommon::onWireframe() void DocumentCommon::onShading() { QApplication::setOverrideCursor( Qt::WaitCursor ); - for( myContext->InitCurrent(); myContext->MoreCurrent(); myContext->NextCurrent() ) - myContext->SetDisplayMode( myContext->Current(), 1, false ); + for( myContext->InitSelected(); myContext->MoreSelected(); myContext->NextSelected() ) + myContext->SetDisplayMode( myContext->SelectedInteractive(), 1, false ); myContext->UpdateCurrentViewer(); getApplication()->onSelectionChanged(); QApplication::restoreOverrideCursor(); @@ -180,8 +180,8 @@ void DocumentCommon::onColor() { QColor aColor ; Quantity_Color aShapeColor; - myContext->InitCurrent(); - Handle(AIS_InteractiveObject) Current = myContext->Current() ; + myContext->InitSelected(); + Handle(AIS_InteractiveObject) Current = myContext->SelectedInteractive() ; if ( Current->HasColor () ) { aShapeColor = myContext->Color( Current ); @@ -195,15 +195,15 @@ void DocumentCommon::onColor() { Quantity_Color color( aRetColor.red() / 255., aRetColor.green() / 255., aRetColor.blue() / 255., Quantity_TOC_RGB ); - for (; myContext->MoreCurrent(); myContext->NextCurrent() ) - myContext->SetColor( myContext->Current(), color.Name() ); + for (; myContext->MoreSelected(); myContext->NextSelected() ) + myContext->SetColor( myContext->SelectedInteractive(), color.Name() ); } } void DocumentCommon::onMaterial( int theMaterial ) { - for ( myContext->InitCurrent(); myContext->MoreCurrent (); myContext->NextCurrent () ) - myContext->SetMaterial( myContext->Current(), (Graphic3d_NameOfMaterial)theMaterial ); + for ( myContext->InitSelected(); myContext->MoreSelected (); myContext->NextSelected () ) + myContext->SetMaterial( myContext->SelectedInteractive(), (Graphic3d_NameOfMaterial)theMaterial ); } void DocumentCommon::onMaterial() @@ -215,8 +215,8 @@ void DocumentCommon::onMaterial() void DocumentCommon::onTransparency( int theTrans ) { - for( myContext->InitCurrent(); myContext->MoreCurrent(); myContext->NextSelected() ) - myContext->SetTransparency( myContext->Current(), ((Standard_Real)theTrans) / 10.0 ); + for( myContext->InitSelected(); myContext->MoreSelected(); myContext->NextSelected() ) + myContext->SetTransparency( myContext->SelectedInteractive(), ((Standard_Real)theTrans) / 10.0 ); } void DocumentCommon::onTransparency() diff --git a/samples/qt/Interface/src/Translate.cxx b/samples/qt/Interface/src/Translate.cxx index 61f78a3632..50cb24427f 100755 --- a/samples/qt/Interface/src/Translate.cxx +++ b/samples/qt/Interface/src/Translate.cxx @@ -275,9 +275,9 @@ Handle(TopTools_HSequenceOfShape) Translate::getShapes( const Handle(AIS_Interac { Handle(TopTools_HSequenceOfShape) aSequence; Handle(AIS_InteractiveObject) picked; - for ( ic->InitCurrent(); ic->MoreCurrent(); ic->NextCurrent() ) + for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() ) { - Handle(AIS_InteractiveObject) obj = ic->Current(); + Handle(AIS_InteractiveObject) obj = ic->SelectedInteractive(); if ( obj->IsKind( STANDARD_TYPE( AIS_Shape ) ) ) { TopoDS_Shape shape = Handle(AIS_Shape)::DownCast(obj)->Shape(); diff --git a/samples/qt/Tutorial/src/DocumentTut.cxx b/samples/qt/Tutorial/src/DocumentTut.cxx index 3b938c7da7..5a27d54920 100755 --- a/samples/qt/Tutorial/src/DocumentTut.cxx +++ b/samples/qt/Tutorial/src/DocumentTut.cxx @@ -27,7 +27,8 @@ void DocumentTut::onMakeBottle() getContext()->SetMaterial(AISBottle,Graphic3d_NOM_GOLD); getContext()->SetDisplayMode(AISBottle,1,Standard_False); getContext()->Display(AISBottle, Standard_False); - getContext()->SetCurrentObject(AISBottle,Standard_False); + const Handle(AIS_InteractiveObject)& anIOAISBottle = AISBottle; + getContext()->SetSelected(anIOAISBottle,Standard_False); emit selectionChanged(); fitAll(); QApplication::restoreOverrideCursor(); diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 99e6efbb2c..13191a1940 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -928,7 +928,10 @@ Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_Interacti return myObjects (theObj)->IsHilighted(); } - for (Standard_Integer aCtxIdx = HighestIndex(); aCtxIdx >= 1; aCtxIdx--) + Standard_DISABLE_DEPRECATION_WARNINGS + Standard_Integer aCtxIdx = HighestIndex(); + Standard_ENABLE_DEPRECATION_WARNINGS + for (; aCtxIdx >= 1; aCtxIdx--) { if (myLocalContexts.IsBound (aCtxIdx)) { @@ -2268,6 +2271,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t if (aStatus->IsHilighted()) { + Standard_DISABLE_DEPRECATION_WARNINGS if (IsCurrent (theIObj)) { AddOrRemoveCurrentObject (theIObj, Standard_False); @@ -2276,6 +2280,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t { unhighlightGlobal (theIObj, aStatus->DisplayMode()); } + Standard_ENABLE_DEPRECATION_WARNINGS } myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False); @@ -2354,6 +2359,7 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t myMainPM->Erase (theIObj, -1); // Object removes from Detected sequence + Standard_DISABLE_DEPRECATION_WARNINGS for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper(); ++aDetIter) { Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); @@ -2363,6 +2369,7 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t myDetectedSeq.Remove (aDetIter); } } + Standard_ENABLE_DEPRECATION_WARNINGS // remove IO from the selection manager to avoid memory leaks const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 6b2d261929..6481d43286 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -237,6 +237,7 @@ public: //! inWhichLocal gives the local context in which anIObj //! is displayed. By default, the index -1 refers to the last //! Local Context opened. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Boolean KeepTemporary (const Handle(AIS_InteractiveObject)& anIObj, const Standard_Integer InWhichLocal = -1); //! Empties the graphic presentation of the mode @@ -966,6 +967,7 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void SetCurrentObject (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Boolean updateviewer = Standard_True); @@ -973,6 +975,7 @@ public: //! correspondingly. Is valid for global context only; for local context use method AddOrRemoveSelected. //! Since this method makes sence only for neutral point selection of a whole object, if 0 selection //! of the object is empty this method simply does nothing. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj, const Standard_Boolean theIsToUpdateViewer = Standard_True); @@ -981,6 +984,7 @@ public: //! Objects selected when there is no open local context //! are called current objects; those selected in open //! local context, selected objects. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void UpdateCurrent(); @@ -988,14 +992,17 @@ public: //! Objects selected when there is no open local context //! are called current objects; those selected in open //! local context, selected objects. - Standard_Boolean WasCurrentTouched() const; + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") + Standard_Boolean WasCurrentTouched() const; - void SetOkCurrent(); + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") + void SetOkCurrent(); //! Returns true if there is a non-null interactive object in Neutral Point. //! Objects selected when there is no open local context are called current objects; //! those selected in open local context, selected objects. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Boolean IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const; @@ -1004,6 +1011,7 @@ public: //! Objects selected when there is no open local context //! are called current objects; those selected in open //! local context, selected objects. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void InitCurrent(); @@ -1012,6 +1020,7 @@ public: //! Objects selected when there is no open local context //! are called current objects; those selected in open //! local context, selected objects. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Boolean MoreCurrent() const; @@ -1020,6 +1029,7 @@ public: //! Objects selected when there is no open local context //! are called current objects; those selected in open //! local context, selected objects. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void NextCurrent(); @@ -1027,8 +1037,10 @@ public: //! Objects selected when there is no open local context //! are called current objects; those selected in open //! local context, selected objects. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Handle(AIS_InteractiveObject) Current() const; - + + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Integer NbCurrents(); //! Highlights current objects. @@ -1039,6 +1051,7 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void HilightCurrents (const Standard_Boolean theToUpdateViewer = Standard_True); //! Removes highlighting from current objects. @@ -1049,6 +1062,7 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void UnhilightCurrents (const Standard_Boolean updateviewer = Standard_True); //! Empties previous current objects in order to get the @@ -1061,14 +1075,16 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void ClearCurrents (const Standard_Boolean theToUpdateViewer = Standard_True); //! @return current mouse-detected shape or empty (null) shape, if current interactive object //! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const; - //! @return current mouse-detected interactive object or null object, if there is no - //! currently detected interactives + //! @return current mouse-detected interactive object or null object, if there is no currently detected interactives + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Handle(AIS_InteractiveObject) DetectedCurrentObject() const; //! @name COMMON SELECTION METHODS VALID FOR BOTH GLOBAL AND LOCAL CONTEXT @@ -1123,6 +1139,7 @@ public: //! No right to Add a selected Shape (Internal Management //! of shape Selection). //! A Previous selected shape may only be removed. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void AddOrRemoveSelected (const TopoDS_Shape& aShape, const Standard_Boolean updateviewer = Standard_True); //! Allows to highlight or unhighlight the owner given depending on its selection status @@ -1268,6 +1285,7 @@ public: //! selections which will disappear once the local context is closed. //! You can open several local contexts, but only the last //! one will be active. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Integer OpenLocalContext (const Standard_Boolean UseDisplayedObjects = Standard_True, const Standard_Boolean AllowShapeDecomposition = Standard_True, const Standard_Boolean AcceptEraseOfObjects = Standard_False, const Standard_Boolean BothViewers = Standard_False); //! Allows you to close local contexts. For greater @@ -1285,9 +1303,11 @@ public: //! is closed. This option can be dangerous, as other //! Interactive Functions can open local contexts //! without necessarily warning the user. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void CloseLocalContext (const Standard_Integer Index = -1, const Standard_Boolean updateviewer = Standard_True); //! returns -1 if no opened local context. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Integer IndexOfCurrentLocal() const; @@ -1297,6 +1317,7 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void CloseAllContexts (const Standard_Boolean updateviewer = Standard_True); //! to be used only with no opened @@ -1304,15 +1325,17 @@ public: //! original state before local contexts were opened... Standard_EXPORT void ResetOriginalState (const Standard_Boolean updateviewer = Standard_True); - //! clears Objects/Filters/Activated Modes list in the current opened - //! local context. + //! clears Objects/Filters/Activated Modes list in the current opened local context. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void ClearLocalContext (const AIS_ClearMode TheMode = AIS_CM_All); - + + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void UseDisplayedObjects(); //! when a local Context is opened, one is able to //! use/not use the displayed objects at neutral point //! at anytime. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void NotUseDisplayedObjects(); //! initializes the list of presentations to be displayed @@ -1355,6 +1378,10 @@ public: //! Activates the selection mode aMode whose index is //! given, for the given interactive entity anIobj. Standard_EXPORT void Activate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode = 0, const Standard_Boolean theIsForce = Standard_False); + + //! Activates the given selection mode for the all displayed objects. + Standard_EXPORT void Activate (const Standard_Integer theMode, + const Standard_Boolean theIsForce = Standard_False); //! Deactivates all the activated selection modes //! of an object. @@ -1364,7 +1391,12 @@ public: //! Deactivates all the activated selection modes of the //! interactive object anIobj with a given selection mode aMode. Standard_EXPORT void Deactivate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode); - + + //! Deactivates the given selection mode for all displayed objects. + Standard_EXPORT void Deactivate (const Standard_Integer theMode); + + //! Deactivates all the activated selection mode at all displayed objects. + Standard_EXPORT void Deactivate(); //! Returns the list of activated selection modes in an open context. Standard_EXPORT void ActivatedModes (const Handle(AIS_InteractiveObject)& anIobj, TColStd_ListOfInteger& theList) const; @@ -1375,6 +1407,7 @@ public: //! shape selection modes activation. //! = False, will not be senstive //! any more. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void SetShapeDecomposition (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Boolean aStatus); @@ -1385,6 +1418,7 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void SetTemporaryAttributes (const Handle(AIS_InteractiveObject)& anObj, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Boolean updateviewer = Standard_True); @@ -1447,6 +1481,7 @@ public: //! objects of the "Shape" type are also activated with //! the same modes. You can act on the state of these //! "Standard" objects by using SetShapeDecomposition(Status). + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void ActivateStandardMode (const TopAbs_ShapeEnum aStandardActivation); @@ -1455,11 +1490,13 @@ public: //! effect of deactivating the corresponding selection //! mode aStandardActivation for all objects in Local //! Context which accept decomposition into sub-shapes. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void DeactivateStandardMode (const TopAbs_ShapeEnum aStandardActivation); //! Returns the list of activated standard selection modes //! available in a local context. + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT const TColStd_ListOfInteger& ActivatedStandardModes() const; @@ -1530,7 +1567,8 @@ public: //! together. Otherwise, you should use other (non-internal) methods of //! class AIS_InteractiveContext without trying to obtain an instance of //! AIS_LocalContext. - Handle(AIS_LocalContext) LocalContext() const; + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") + Handle(AIS_LocalContext) LocalContext() const; const Handle(SelectMgr_SelectionManager)& SelectionManager() const; @@ -1538,6 +1576,7 @@ public: const Handle(StdSelect_ViewerSelector3d)& MainSelector() const; + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Handle(StdSelect_ViewerSelector3d) LocalSelector() const; //! Clears all the structures which don't @@ -1546,6 +1585,7 @@ public: //! returns the number of removed structures from the viewers. Standard_EXPORT Standard_Integer PurgeDisplay(); + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Integer HighestIndex() const; Standard_EXPORT void DisplayActiveSensitive (const Handle(V3d_View)& aView); @@ -1561,6 +1601,7 @@ public: //! returns if possible, //! the first local context where the object is seen + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Standard_Boolean IsInLocal (const Handle(AIS_InteractiveObject)& anObject, Standard_Integer& TheIndex) const; //! Rebuilds 1st level of BVH selection forcibly diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 0af8ae068a..b869d7870c 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -1685,7 +1685,9 @@ const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape(); } + Standard_DISABLE_DEPRECATION_WARNINGS Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject()); + Standard_ENABLE_DEPRECATION_WARNINGS if (aCurrentShape.IsNull()) { diff --git a/src/AIS/AIS_InteractiveContext_2.cxx b/src/AIS/AIS_InteractiveContext_2.cxx index f5d04ef424..e05c201518 100644 --- a/src/AIS/AIS_InteractiveContext_2.cxx +++ b/src/AIS/AIS_InteractiveContext_2.cxx @@ -74,7 +74,9 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects, myLastPicked.Nullify(); myWasLastMain = Standard_True; + Standard_DISABLE_DEPRECATION_WARNINGS myCurLocalIndex = HighestIndex() + 1; + Standard_ENABLE_DEPRECATION_WARNINGS Handle(AIS_LocalContext) NewLocal= new AIS_LocalContext(this,myCurLocalIndex, UseDisplayedObjects, @@ -144,7 +146,9 @@ void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index, myLocalContexts.UnBind(GoodIndex); // the current is closed... if(GoodIndex==myCurLocalIndex){ + Standard_DISABLE_DEPRECATION_WARNINGS myCurLocalIndex = HighestIndex(); + Standard_ENABLE_DEPRECATION_WARNINGS } else if(debugmode) cout<<"a No Current Local Context WasClosed"<Update(); } +Standard_ENABLE_DEPRECATION_WARNINGS //======================================================================= //function : IndexOfCurrentLocal @@ -237,6 +241,24 @@ Activate(const Handle(AIS_InteractiveObject)& anIObj, } } +// ============================================================================ +// function : Activate +// purpose : +// ============================================================================ +void AIS_InteractiveContext::Activate (const Standard_Integer theMode, + const Standard_Boolean theIsForce) +{ + AIS_ListOfInteractive aDisplayedObjects; + DisplayedObjects (aDisplayedObjects); + + for (AIS_ListIteratorOfListOfInteractive anIter (aDisplayedObjects); anIter.More(); anIter.Next()) + { + Load (anIter.Value(), -1, Standard_True); + Activate (anIter.Value(), theMode, theIsForce); + } + +} + //======================================================================= //function : LocalSelector //purpose : @@ -295,6 +317,36 @@ void AIS_InteractiveContext::Deactivate(const Handle(AIS_InteractiveObject)& anI } } +// ============================================================================ +// function : Deactivate +// purpose : +// ============================================================================ +void AIS_InteractiveContext::Deactivate (const Standard_Integer theMode) +{ + AIS_ListOfInteractive aDisplayedObjects; + DisplayedObjects (aDisplayedObjects); + + for (AIS_ListIteratorOfListOfInteractive anIter (aDisplayedObjects); anIter.More(); anIter.Next()) + { + Deactivate (anIter.Value(), theMode); + } +} + +// ============================================================================ +// function : Deactivate +// purpose : +// ============================================================================ +void AIS_InteractiveContext::Deactivate() +{ + AIS_ListOfInteractive aDisplayedObjects; + DisplayedObjects (aDisplayedObjects); + + for (AIS_ListIteratorOfListOfInteractive anIter (aDisplayedObjects); anIter.More(); anIter.Next()) + { + Deactivate (anIter.Value()); + } +} + //======================================================================= //function : ActivatedModes //purpose : diff --git a/src/AIS/AIS_KindOfRelation.hxx b/src/AIS/AIS_KindOfRelation.hxx new file mode 100644 index 0000000000..d503082d0f --- /dev/null +++ b/src/AIS/AIS_KindOfRelation.hxx @@ -0,0 +1,33 @@ +// Created on: 2016-11-25 +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _AIS_KindOfRelation_HeaderFile +#define _AIS_KindOfRelation_HeaderFile + +enum AIS_KindOfRelation +{ + AIS_KOR_NONE = 0, + AIS_KOR_CONCENTRIC, + AIS_KOR_EQUALDISTANCE, + AIS_KOR_EQUALRADIUS, + AIS_KOR_FIX, + AIS_KOR_IDENTIC, + AIS_KOR_OFFSET, + AIS_KOR_PARALLEL, + AIS_KOR_PERPENDICULAR, + AIS_KOR_TANGENT, + AIS_KOR_SYMMETRIC +}; + +#endif diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 80123e9a23..910d391081 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -715,8 +715,10 @@ void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) // chieck if by hazard the object is somewhere else... Standard_Integer Indx; + Standard_DISABLE_DEPRECATION_WARNINGS Standard_Boolean IsSomeWhereElse = myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); + Standard_ENABLE_DEPRECATION_WARNINGS const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); myMainPM->Unhighlight(anObject,Att->HilightMode()); diff --git a/src/AIS/FILES b/src/AIS/FILES index 4c878ef9ff..67ec0e6747 100644 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -92,6 +92,7 @@ AIS_InteractiveObject.hxx AIS_InteractiveObject.lxx AIS_KindOfDimension.hxx AIS_KindOfInteractive.hxx +AIS_KindOfRelation.hxx AIS_KindOfSurface.hxx AIS_KindOfUnit.hxx AIS_LengthDimension.cxx diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 50f3463777..8da2864560 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -153,7 +153,11 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO return; } - Presentation (thePrsObj, theMode)->SetVisible (theValue); + Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); + if (!aPrs.IsNull()) + { + aPrs->SetVisible (theValue); + } } // ======================================================================= diff --git a/src/QABugs/QABugs_1.cxx b/src/QABugs/QABugs_1.cxx index 1f326ddd13..1152fb8847 100644 --- a/src/QABugs/QABugs_1.cxx +++ b/src/QABugs/QABugs_1.cxx @@ -66,6 +66,7 @@ static TColStd_MapOfInteger theactivatedmodes(8); #include #include +Standard_DISABLE_DEPRECATION_WARNINGS static Standard_Integer OCC328bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); @@ -178,6 +179,7 @@ static Standard_Integer OCC328bug (Draw_Interpretor& di, Standard_Integer argc, return 0; } +Standard_ENABLE_DEPRECATION_WARNINGS static Standard_Integer OCC159bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { @@ -415,9 +417,6 @@ static Standard_Integer OCC74bug_set (Draw_Interpretor& di, Standard_Integer arg if(AISObj.IsNull()){ di << argv[1] << " : No interactive object\n"; return 1; - } - if (!aContext->HasOpenedContext()) { - aContext->OpenLocalContext(); } aContext->Erase(AISObj, updateviewer); aContext->UpdateCurrentViewer(); diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 74c8ad23ba..26adbc8deb 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -215,7 +215,6 @@ static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, con return 1; } - if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts(); anAISCtx->EraseAll(); //load primitives to context @@ -747,8 +746,7 @@ static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape()); myAISContext->SetAutoActivateSelection (Standard_False); myAISContext->Display(anAISBox, 1); - Standard_Integer myLocContInd = myAISContext->OpenLocalContext(); - myAISContext->CloseLocalContext(myLocContInd); + TColStd_ListOfInteger anActivatedModes; myAISContext->ActivatedModes (anAISBox, anActivatedModes); if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 ) @@ -1687,9 +1685,7 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con return 1; } AISObj->ResetTransformation(); - if (!aContext->HasOpenedContext()) { - aContext->OpenLocalContext(); - } + aContext->Erase(AISObj, updateviewer); aContext->UpdateCurrentViewer(); aContext->Display(AISObj, updateviewer); @@ -5254,61 +5250,6 @@ Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const cha return 0; } -#include -#include -#include -#include -Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - // Check the command arguments - if (argc != 2) - { - di <<"Error: "<HasOpenedContext()) - { - aisContext->CloseAllContexts(); - aisContext->RemoveAll(false); - aisContext->EraseSelected(false); - } - aisContext->EraseAll(false); - Handle(Geom_Axis2Placement) trihedronAxis = new Geom_Axis2Placement(gp::XOY()); - Handle(AIS_Trihedron) trihedron = new AIS_Trihedron(trihedronAxis); - if (aMode) - aisContext->SetAutoActivateSelection (Standard_False); // if selection must not be activated - trihedron->SetSize(20); - trihedron->SetColor(Quantity_NOC_GRAY30); - trihedron->SetArrowColor(Quantity_NOC_GRAY30); - trihedron->SetTextColor(Quantity_NOC_DARKSLATEBLUE); - - //trihedron->SetColor(Quantity_NameOfColor::Quantity_NOC_GRAY30); - //trihedron->SetArrowColor(Quantity_NameOfColor::Quantity_NOC_GRAY30); - //trihedron->SetTextColor(Quantity_NameOfColor::Quantity_NOC_DARKSLATEBLUE); - - - aisContext->Display(trihedron, true); - aisContext->OpenLocalContext(); - //aisContext->ActivateStandardMode(TopAbs_ShapeEnum::TopAbs_EDGE); - aisContext->ActivateStandardMode(TopAbs_EDGE); - aisContext->SetPixelTolerance(8); - - return 0; //TCL_OK -} - void QABugs::Commands_11(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -5416,6 +5357,5 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) { theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group); theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group); theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group); - theCommands.Add("CR23234", "CR23234 mode(0/1)", __FILE__, CR23234, group); return; } diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index c9b6811ad6..580329e84b 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -262,7 +262,9 @@ static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, c aTrihedron=new AIS_Trihedron(aTrihedronAxis); myAISContext->Display(aTrihedron); + Standard_DISABLE_DEPRECATION_WARNINGS myAISContext->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS myAISContext->Load(aTrihedron,0); myAISContext->SetAutomaticHilight( Standard_False ); @@ -586,10 +588,11 @@ static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer /*argc*/ Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID); aContext->AddFilter(filt); + Standard_DISABLE_DEPRECATION_WARNINGS aContext->CloseAllContexts(); aContext->OpenLocalContext(); aContext->ActivateStandardMode(TopAbs_SOLID); - + Standard_ENABLE_DEPRECATION_WARNINGS return 0; } @@ -633,84 +636,6 @@ static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc return 0; } -static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv) -{ - Handle(AIS_InteractiveContext) aContext1 = ViewerTest::GetAISContext(); - if(aContext1.IsNull()) { - di << "use 'vinit' command before " << argv[0] << "\n"; - return 1; - } - Handle(AIS_InteractiveContext) aContext2 = ViewerTest::GetAISContext(); - if(aContext2.IsNull()) { - di << "use 'vinit' command before " << argv[0] << "\n"; - return 1; - } - - BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100)); - BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300, 300)); - BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500, 500)); - - Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape()); - Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape()); - Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape()); - - aContext1->Display(ais1); - aContext1->Display(ais2); - aContext1->Display(ais3); - - aContext2->Display(ais1); - aContext2->Display(ais2); - aContext2->Display(ais3); - - aContext1->AddOrRemoveSelected(ais1); - aContext1->AddOrRemoveSelected(ais2); - aContext1->AddOrRemoveSelected(ais3); - - di << "\n Stage : 1"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n"; - - di << "\n aContext1->IsSelected = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " "; - - aContext2->AddOrRemoveSelected(ais1); - aContext2->AddOrRemoveSelected(ais2); - aContext2->AddOrRemoveSelected(ais3); - - di << "\n Stage : 2"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n"; - - aContext1->InitSelected(); - int count1 = 1; - while(aContext1->MoreSelected()) - { - di << "\n count1 is = " << count1++; - Handle(AIS_InteractiveObject) ais = aContext1->SelectedInteractive(); - aContext1->AddOrRemoveSelected(ais); - aContext1->InitSelected(); - } - - di << "\n Stage : 3"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n"; - - aContext2->InitSelected(); - int count2 = 1; - while(aContext2->MoreSelected()) - { - di << "\n count2 is = " << count2++; - Handle(AIS_InteractiveObject) ais = aContext2->SelectedInteractive(); - aContext2->AddOrRemoveSelected(ais); - aContext2->InitSelected(); - } - - di << "\n\n Stage : 4"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected(); - - return 0; -} - #include #include //======================================================================= @@ -1755,7 +1680,6 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) { theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group); theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group); theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group); - theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group); theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group); theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group); diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 0acfbd04ab..c2b877059c 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -3311,7 +3311,9 @@ static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theA aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX)); aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE)); + Standard_DISABLE_DEPRECATION_WARNINGS anAISContext->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS anAISContext->Deactivate (aTestAISShape); anAISContext->Load (aTestAISShape, -1, true); for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt) @@ -3321,6 +3323,7 @@ static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theA // select entities in vertex selection mode Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1)); + Standard_DISABLE_DEPRECATION_WARNINGS for (aSelection->Init(); aSelection->More(); aSelection->Next()) { Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); @@ -3339,9 +3342,11 @@ static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theA anAISContext->LocalContext()->AddOrRemoveSelected (anOwner); } + Standard_ENABLE_DEPRECATION_WARNINGS // select entities in edge selection mode aSelection = aTestAISShape->Selection (aModes (2)); + Standard_DISABLE_DEPRECATION_WARNINGS for (aSelection->Init(); aSelection->More(); aSelection->Next()) { Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); @@ -3360,10 +3365,13 @@ static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theA anAISContext->LocalContext()->AddOrRemoveSelected (anOwner); } + Standard_ENABLE_DEPRECATION_WARNINGS // deactivate vertex mode and check clearing of outdated selection anAISContext->Deactivate (aTestAISShape, aModes (1)); + Standard_DISABLE_DEPRECATION_WARNINGS anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true); + Standard_ENABLE_DEPRECATION_WARNINGS return 0; } @@ -4162,7 +4170,6 @@ static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*th Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape()); const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); - aCtx->OpenLocalContext(); aCtx->Display (aBox1, 0, 2); aCtx->Display (aBox2, 0, 2); ViewerTest::CurrentView()->FitAll(); @@ -4857,7 +4864,9 @@ static Standard_Integer BUC26658 (Draw_Interpretor& theDI, // visualization of the box in the local mode with possibility to // select box vertices + Standard_DISABLE_DEPRECATION_WARNINGS aContext->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS int aDispMode = 0;// wireframe anAISIO->SetDisplayMode(aDispMode); @@ -4898,7 +4907,9 @@ static Standard_Integer BUC26658 (Draw_Interpretor& theDI, aContext->AddFilter(aFilter); // update previous selection by hand + Standard_DISABLE_DEPRECATION_WARNINGS aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true); + Standard_ENABLE_DEPRECATION_WARNINGS // check that there are no selected vertices aContext->Select(); @@ -4941,8 +4952,10 @@ static Standard_Integer OCC26945_open (Draw_Interpretor& theDI, Standard_Integer } const TopAbs_ShapeEnum aSelType = AIS_Shape::SelectionType (Draw::Atoi (theArgv[1])); + Standard_DISABLE_DEPRECATION_WARNINGS Standard_Integer aLocalCtxIdx = aCtx->OpenLocalContext(); aCtx->ActivateStandardMode (aSelType); + Standard_ENABLE_DEPRECATION_WARNINGS theDI << aLocalCtxIdx; return 0; @@ -4969,7 +4982,9 @@ static Standard_Integer OCC26945_close (Draw_Interpretor& theDI, Standard_Intege } const Standard_Integer aCtxToClose = Draw::Atoi (theArgv[1]); + Standard_DISABLE_DEPRECATION_WARNINGS aCtx->CloseLocalContext (aCtxToClose); + Standard_ENABLE_DEPRECATION_WARNINGS return 0; } @@ -5140,7 +5155,6 @@ static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theA TColStd_SequenceOfInteger aModes; aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX)); - anAISContext->OpenLocalContext(); anAISContext->Deactivate (aTestAISShape); anAISContext->Load (aTestAISShape, -1, true); anAISContext->Activate (aTestAISShape, 0); diff --git a/src/QABugs/QABugs_3.cxx b/src/QABugs/QABugs_3.cxx index 54137a8279..5aa31c08aa 100644 --- a/src/QABugs/QABugs_3.cxx +++ b/src/QABugs/QABugs_3.cxx @@ -86,8 +86,12 @@ static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** a Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); myAISContext->Display( anAISShape, Standard_True ); + + Standard_DISABLE_DEPRECATION_WARNINGS myAISContext->OpenLocalContext(); myAISContext->ActivateStandardMode(TopAbs_FACE); + Standard_ENABLE_DEPRECATION_WARNINGS + return 0; } @@ -111,8 +115,11 @@ static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** a } Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); myAISContext->Display( anAISShape, Standard_True ); + + Standard_DISABLE_DEPRECATION_WARNINGS myAISContext->OpenLocalContext(); myAISContext->ActivateStandardMode(TopAbs_COMPOUND); + Standard_ENABLE_DEPRECATION_WARNINGS // myAISContext->ActivateStandardMode(TopAbs_SOLID); // di.Eval("vfit"); // cout << "vfini" << endl; @@ -340,8 +347,11 @@ static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, c TopLoc_Location aLoc(aTrsf); myAISContext->SetLocation(atri,aLoc); myAISContext->Display(atri,0,-1,Standard_True, Standard_True); - myAISContext->OpenLocalContext(Standard_False, - Standard_True,Standard_False,Standard_False); + + Standard_DISABLE_DEPRECATION_WARNINGS + myAISContext->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False); + Standard_ENABLE_DEPRECATION_WARNINGS + myAISContext->Load(atri,3,Standard_True); return 0; @@ -357,39 +367,6 @@ static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, c #include #include -static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a) -{ - - Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); - if(myAISContext.IsNull()) { - di << "use 'vinit' command before " << a[0] << "\n"; - return -1; - } - TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid(); - TopAbs_ShapeEnum theType = B1.ShapeType(); - if ( theType == TopAbs_SOLID ) { - di << "It is a solid." << "\n"; - } else { - di << "It is not solid." << "\n"; - } - myAISContext->Display(new AIS_Shape(B1)); - myAISContext->OpenLocalContext(); - TopAbs_ShapeEnum amode = TopAbs_SOLID; - myAISContext->ActivateStandardMode(amode); - di.Eval("vfit"); - di.Eval("QAMoveTo 200 200"); - di.Eval("QASelect 200 200"); - myAISContext->InitSelected() ; - if ( myAISContext->MoreSelected() ) { - if (myAISContext->HasSelectedShape() ) { - di << "has selected shape : OK" << "\n"; - } else { - di << "has selected shape : bugged - Faulty " << "\n"; - } - } - return 0; -} - #define DEFAULT_COLOR Quantity_NOC_GOLDENROD //======================================================================= @@ -494,39 +471,6 @@ switch (argc){ return 0; } -static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv ) -{ - Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); - if(myAISContext.IsNull()) { - di << "use 'vinit' command before " << argv[0] << "\n"; - return -1; - } - - if(argc != 2) { - di << "Usage : " << argv[0] << " 0/1\n"; - } - - if(Draw::Atoi(argv[1]) == 0) { - myAISContext->CloseAllContexts(); - BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.); - Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape()); - myAISContext->Display(aBox); - } else if(Draw::Atoi(argv[1]) == 1) { - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode(TopAbs_EDGE); - } else if(Draw::Atoi(argv[1]) == 2) { - myAISContext->CloseAllContexts(); - myAISContext->OpenLocalContext(); - myAISContext->ActivateStandardMode(TopAbs_FACE); - } else { - di << "Usage : " << argv[0] << " 0/1\n"; - return -1; - } - - return 0; -} - #include #include @@ -1780,11 +1724,9 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) { theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group); theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group); - theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group); theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group); theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group); - theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group); theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group); theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group); theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group); diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 3b83d6cd1f..3c6df45d50 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -174,6 +174,22 @@ Standard_Boolean ViewerTest::ParseOnOff (Standard_CString theArg, return Standard_False; } +//======================================================================= +//function : GetSelectedShapes +//purpose : +//======================================================================= +void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes) +{ + for (GetAISContext()->InitSelected(); GetAISContext()->MoreSelected(); GetAISContext()->NextSelected()) + { + TopoDS_Shape aShape = GetAISContext()->SelectedShape(); + if (!aShape.IsNull()) + { + theSelectedShapes.Append (aShape); + } + } +} + //======================================================================= //function : ParseLineType //purpose : @@ -526,8 +542,6 @@ Handle(AIS_Shape) GetAISShapeFromName(const char* name) void ViewerTest::Clear() { if ( !a3DView().IsNull() ) { - if (TheAISContext()->HasOpenedContext()) - TheAISContext()->CloseLocalContext(); ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS()); while ( it.More() ) { cout << "Remove " << it.Key2() << endl; @@ -546,12 +560,15 @@ void ViewerTest::Clear() //purpose : Activate a selection mode, vertex, edge, wire ..., in a local // Context //============================================================================== +Standard_DISABLE_DEPRECATION_WARNINGS void ViewerTest::StandardModeActivation(const Standard_Integer mode ) { Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); if(mode==0) { if (TheAISContext()->HasOpenedContext()) + { aContext->CloseLocalContext(); + } } else { if(!aContext->HasOpenedContext()) { @@ -560,14 +577,16 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode ) // Open a local Context in order to be able to select subshape from // the selected shape if any or for all if there is no selection if (!aContext->FirstSelectedObject().IsNull()){ - aContext->OpenLocalContext(Standard_False); + aContext->OpenLocalContext(Standard_False); for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){ aContext->Load( aContext->SelectedInteractive(),-1,Standard_True); } } else - aContext->OpenLocalContext(); + { + aContext->OpenLocalContext(); + } } const char *cmode="???"; @@ -585,19 +604,20 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode ) } if(theactivatedmodes.Contains(mode)) - { // Desactivate - aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode)); - theactivatedmodes.Remove(mode); - cout<<"Mode "<< cmode <<" OFF"<DeactivateStandardMode(AIS_Shape::SelectionType(mode)); + theactivatedmodes.Remove(mode); + cout<<"Mode "<< cmode <<" OFF"<ActivateStandardMode(AIS_Shape::SelectionType(mode)); - theactivatedmodes.Add(mode); - cout<<"Mode "<< cmode << " ON" << endl; - } + { // Activate + aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode)); + theactivatedmodes.Add(mode); + cout<<"Mode "<< cmode << " ON" << endl; + } } } +Standard_ENABLE_DEPRECATION_WARNINGS //============================================================================== //function : CopyIsoAspect @@ -1462,10 +1482,6 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI, return 1; } - if (aCtx->HasOpenedContext()) - { - aCtx->CloseLocalContext(); - } for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next()) { const Handle(AIS_InteractiveObject)& anIO = anIter.Current(); @@ -2237,11 +2253,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, isFirst = Standard_False; } - if (aCtx->HasOpenedContext()) - { - aCtx->CloseLocalContext(); - } - // special case for -defaults parameter. // all changed values will be set to DefaultDrawer. if (isDefaults) @@ -2553,10 +2564,12 @@ static int VDonly2 (Draw_Interpretor& , return 1; } + Standard_DISABLE_DEPRECATION_WARNINGS if (aCtx->HasOpenedContext()) { aCtx->CloseLocalContext(); } + Standard_ENABLE_DEPRECATION_WARNINGS Standard_Integer anArgIter = 1; for (; anArgIter < theArgNb; ++anArgIter) @@ -2678,6 +2691,7 @@ int VRemove (Draw_Interpretor& theDI, return 1; } + Standard_DISABLE_DEPRECATION_WARNINGS if (toRemoveLocal && !aCtx->HasOpenedContext()) { std::cerr << "Error: local selection context is not open.\n"; @@ -2687,6 +2701,7 @@ int VRemove (Draw_Interpretor& theDI, { aCtx->CloseAllContexts (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS NCollection_List anIONameList; if (toRemoveAll) @@ -2754,11 +2769,13 @@ int VRemove (Draw_Interpretor& theDI, // Close local context if it is empty TColStd_MapOfTransient aLocalIO; + Standard_DISABLE_DEPRECATION_WARNINGS if (aCtx->HasOpenedContext() && !aCtx->LocalContext()->DisplayedObjects (aLocalIO)) { aCtx->CloseAllContexts (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS return 0; } @@ -2816,6 +2833,7 @@ int VErase (Draw_Interpretor& theDI, return 1; } + Standard_DISABLE_DEPRECATION_WARNINGS if (toEraseLocal && !aCtx->HasOpenedContext()) { std::cerr << "Error: local selection context is not open.\n"; @@ -2825,6 +2843,7 @@ int VErase (Draw_Interpretor& theDI, { aCtx->CloseAllContexts (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS if (!aNamesOfEraseIO.IsEmpty()) { @@ -2948,6 +2967,7 @@ static int VDisplayAll (Draw_Interpretor& , return 1; } + Standard_DISABLE_DEPRECATION_WARNINGS if (toDisplayLocal && !aCtx->HasOpenedContext()) { std::cerr << "Error: local selection context is not open.\n"; @@ -2957,6 +2977,7 @@ static int VDisplayAll (Draw_Interpretor& , { aCtx->CloseLocalContext (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next()) @@ -3799,6 +3820,7 @@ static int VDisplay2 (Draw_Interpretor& theDI, } // Prepare context for display + Standard_DISABLE_DEPRECATION_WARNINGS if (toDisplayLocal && !aCtx->HasOpenedContext()) { aCtx->OpenLocalContext (Standard_False); @@ -3807,6 +3829,7 @@ static int VDisplay2 (Draw_Interpretor& theDI, { aCtx->CloseAllContexts (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS // Display interactive objects for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter) @@ -4008,9 +4031,6 @@ static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, con static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) { OSD_Timer myTimer; - if (TheAISContext()->HasOpenedContext()) - TheAISContext()->CloseLocalContext(); - Standard_Real Step=4*M_PI/180; Standard_Real Angle=0; @@ -4082,10 +4102,6 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv) // Verifications const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0); - - if (TheAISContext()->HasOpenedContext()) - TheAISContext()->CloseLocalContext(); - if (argc < 3) { myDevCoef = 0.0008; } else { @@ -4151,15 +4167,20 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch if (argc<2||argc>3) { di<<" Syntaxe error\n";return 1;} ThereIsName = (argc == 3); } - else { + else + { + Standard_DISABLE_DEPRECATION_WARNINGS // vunsetam if (argc>1) {di<<" Syntaxe error\n";return 1;} else { di<<" R.A.Z de tous les modes de selecion\n"; di<<" Fermeture du Context local\n"; if (TheAISContext()->HasOpenedContext()) + { TheAISContext()->CloseLocalContext(); + } } + Standard_ENABLE_DEPRECATION_WARNINGS } // IL n'y a aps de nom de shape passe en argument @@ -4192,7 +4213,9 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch } } + Standard_DISABLE_DEPRECATION_WARNINGS TheAISContext()->OpenLocalContext(Standard_False); + Standard_ENABLE_DEPRECATION_WARNINGS ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS()); while(it.More()){ @@ -4295,7 +4318,9 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch } if( !TheAISContext()->HasOpenedContext() ) { + Standard_DISABLE_DEPRECATION_WARNINGS TheAISContext()->OpenLocalContext(Standard_False); + Standard_ENABLE_DEPRECATION_WARNINGS // On charge tous les objets de la map ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS()); while(it.More()){ @@ -4496,7 +4521,9 @@ static Standard_Integer VState (Draw_Interpretor& theDI, if (toPrintEntities) { theDI << "Detected entities:\n"; + Standard_DISABLE_DEPRECATION_WARNINGS Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector(); + Standard_ENABLE_DEPRECATION_WARNINGS SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager(); for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter) { @@ -4546,10 +4573,12 @@ static Standard_Integer VState (Draw_Interpretor& theDI, } NCollection_Map aDetected; + Standard_DISABLE_DEPRECATION_WARNINGS for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected()) { aDetected.Add (aCtx->DetectedCurrentObject()); } + Standard_ENABLE_DEPRECATION_WARNINGS const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*'); if (theArgNb >= 2 @@ -4615,8 +4644,10 @@ static Standard_Integer VState (Draw_Interpretor& theDI, theDI << "\n"; } printLocalSelectionInfo (aCtx, theDI); + Standard_DISABLE_DEPRECATION_WARNINGS if (aCtx->HasOpenedContext()) printLocalSelectionInfo (aCtx->LocalContext(), theDI); + Standard_ENABLE_DEPRECATION_WARNINGS return 0; } @@ -4630,7 +4661,9 @@ Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar const Standard_Integer MaxPick) { Handle(AIS_InteractiveObject) IO; + Standard_DISABLE_DEPRECATION_WARNINGS Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS // step 1: prepare the data if(curindex !=0){ @@ -4670,9 +4703,12 @@ Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar arr->SetValue(i,IO2); } - - if(curindex>0) + Standard_DISABLE_DEPRECATION_WARNINGS + if (curindex > 0) + { TheAISContext()->CloseLocalContext(curindex); + } + Standard_ENABLE_DEPRECATION_WARNINGS return Standard_True; } @@ -4687,7 +4723,9 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive const Standard_Integer MaxPick) { Handle(AIS_InteractiveObject) IO; + Standard_DISABLE_DEPRECATION_WARNINGS Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS // step 1: prepare the data @@ -4718,8 +4756,12 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive IO = TheAISContext()->SelectedInteractive(); } - if(curindex!=0) + Standard_DISABLE_DEPRECATION_WARNINGS + if (curindex != 0) + { TheAISContext()->CloseLocalContext(curindex); + } + Standard_ENABLE_DEPRECATION_WARNINGS return IO; } @@ -4734,8 +4776,9 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType, { // step 1: prepare the data - + Standard_DISABLE_DEPRECATION_WARNINGS Standard_Integer curindex = TheAISContext()->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS TopoDS_Shape result; if(TheType==TopAbs_SHAPE){ @@ -4745,8 +4788,9 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType, else{ Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); TheAISContext()->AddFilter(TF); + Standard_DISABLE_DEPRECATION_WARNINGS TheAISContext()->ActivateStandardMode(TheType); - + Standard_ENABLE_DEPRECATION_WARNINGS } @@ -4778,8 +4822,12 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType, } } - if(curindex>0) + Standard_DISABLE_DEPRECATION_WARNINGS + if (curindex > 0) + { TheAISContext()->CloseLocalContext(curindex); + } + Standard_ENABLE_DEPRECATION_WARNINGS return result; } @@ -4799,7 +4847,9 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType, cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n"; // step 1: prepare the data + Standard_DISABLE_DEPRECATION_WARNINGS Standard_Integer curindex = TheAISContext()->OpenLocalContext(); + Standard_ENABLE_DEPRECATION_WARNINGS if(TheType==TopAbs_SHAPE){ Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape); TheAISContext()->AddFilter(F1); @@ -4807,8 +4857,9 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType, else{ Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); TheAISContext()->AddFilter(TF); + Standard_DISABLE_DEPRECATION_WARNINGS TheAISContext()->ActivateStandardMode(TheType); - + Standard_ENABLE_DEPRECATION_WARNINGS } // step 2 : wait for the selection... @@ -4845,7 +4896,9 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType, } } + Standard_DISABLE_DEPRECATION_WARNINGS TheAISContext()->CloseLocalContext(curindex); + Standard_ENABLE_DEPRECATION_WARNINGS return Standard_True; } @@ -5458,6 +5511,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/, } // Prepare context + Standard_DISABLE_DEPRECATION_WARNINGS if (isLocal && !aCtx->HasOpenedContext()) { aCtx->OpenLocalContext (Standard_False); @@ -5466,6 +5520,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/, { aCtx->CloseAllContexts (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS // Load selection of interactive objects for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter) diff --git a/src/ViewerTest/ViewerTest.hxx b/src/ViewerTest/ViewerTest.hxx index aefdfb789b..1e16d9a71b 100644 --- a/src/ViewerTest/ViewerTest.hxx +++ b/src/ViewerTest/ViewerTest.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -190,6 +191,10 @@ public: Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg, Standard_Boolean& theIsOn); + //! Returns list of selected shapes. + Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes); + + //! Parses line type argument. //! Handles either enumeration (integer) value or string constant. Standard_EXPORT static Standard_Boolean ParseLineType (Standard_CString theArg, diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 569a4a3c8d..2899bdb087 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -147,85 +147,62 @@ extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theNam extern int ViewerMainLoop(Standard_Integer argc, const char** argv); extern Handle(AIS_InteractiveContext)& TheAISContext(); - //============================================================================== //function : Vtrihedron 2d //purpose : Create a plane with a 2D trihedron from a faceselection //Draw arg : vtri2d name //============================================================================== #include +static int VTrihedron2D (Draw_Interpretor& /*theDI*/, + Standard_Integer theArgsNum, + const char** theArgVec) +{ + if (theArgsNum != 2) + { + std::cerr << theArgVec[0]<< " error.\n"; + return 1; + } + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); + if (aShapes.Extent() != 1) + { + std::cerr << "Error: wrong number of selected shapes.\n"; + return 1; + } -static int VTrihedron2D (Draw_Interpretor& di, Standard_Integer argc, const char** argv) + const TopoDS_Shape& aShape = aShapes.First(); -{ - // Verification des arguments - if ( argc!=2) {di<CloseAllContexts(); - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - // On active les modes de selections faces. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select a face .\n"; - - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - TopoDS_Face FaceB=TopoDS::Face(ShapeB); - - // Construction du Plane - // recuperation des edges des faces. - TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE); - - TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() ); - // declarations gp_Pnt A,B,C; - - // si il y a plusieurs edges - if (FaceExpB.More() ) { - FaceExpB.Next(); - TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() ); - BRepAdaptor_Curve theCurveB(EdgeB); - BRepAdaptor_Curve theCurveC(EdgeC); - A=theCurveC.Value(0.1); - B=theCurveC.Value(0.9); - C=theCurveB.Value(0.5); + if (aFaceExp.More()) + { + aFaceExp.Next(); + TopoDS_Edge anEdge1 = TopoDS::Edge (aFaceExp.Current() ); + BRepAdaptor_Curve aCurve0 (anEdge0); + BRepAdaptor_Curve aCurve1 (anEdge1); + A = aCurve1.Value (0.1); + B = aCurve1.Value (0.9); + C = aCurve0.Value (0.5); } - else { - // FaceB a 1 unique edge courbe - BRepAdaptor_Curve theCurveB(EdgeB); - A=theCurveB.Value(0.1); - B=theCurveB.Value(0.9); - C=theCurveB.Value(0.5); + else + { + BRepAdaptor_Curve aCurve0 (anEdge0); + A = aCurve0.Value (0.1); + B = aCurve0.Value (0.9); + C = aCurve0.Value (0.5); } - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Construction de l'AIS_PlaneTrihedron - Handle(AIS_PlaneTrihedron) theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane ); + GC_MakePlane aMkPlane (A,B,C); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); + Handle(AIS_PlaneTrihedron) anAISPlaneTri = new AIS_PlaneTrihedron (aMkPlane.Value()); + TCollection_AsciiString aName (theArgVec[1]); - // on le display & bind - TheAISContext()->Display(theAISPlaneTri ); - GetMapOfAIS().Bind ( theAISPlaneTri ,argv[1]); + VDisplayAISObject (aName, anAISPlaneTri); return 0; } @@ -391,10 +368,6 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv else if (argc==2) {ThereIsName=Standard_False;value=Draw::Atof(argv[1]);} else {ThereIsName=Standard_True;value=Draw::Atof(argv[2]);} - // On ferme le contexte local pour travailler dans le contexte global - if(TheAISContext()->HasOpenedContext()) - TheAISContext()->CloseLocalContext(); - // On set le booleen ThereIsCurrent if (TheAISContext() -> NbSelected() > 0) {ThereIsCurrent=Standard_True;} else {ThereIsCurrent=Standard_False;} @@ -531,57 +504,22 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c // Verification des arguments if ( argc!=2) {di<CloseAllContexts(); - - // On recupere tous les trihedrons de la GetMapOfAIS() - // et on active le mode de selection par face. - // ================================================= - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(Standard_False); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName - it (GetMapOfAIS()); - while(it.More()){ - Handle(AIS_InteractiveObject) ShapeA = - Handle(AIS_InteractiveObject)::DownCast(it.Key1()); - // On verifie que c'est bien un trihedron - if (!ShapeA.IsNull() && - ShapeA->Type()==AIS_KOI_Datum && ShapeA->Signature()==3 ) { - // on le downcast - Handle(AIS_Trihedron) TrihedronA =(Handle(AIS_Trihedron)::DownCast (ShapeA)); - // on le charge dans le contexte et on active le mode Plane. - TheAISContext()->Load(TrihedronA,0,Standard_False); - TheAISContext()->Activate(TrihedronA,3); - } - it.Next(); + if (TheAISContext()->NbSelected() != 1) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; } - di<<" Select a plane.\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - Handle(AIS_InteractiveObject) theIOB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - theIOB = TheAISContext()->SelectedInteractive(); + TheAISContext()->InitSelected(); + Handle(AIS_InteractiveObject) aTest = TheAISContext()->SelectedInteractive(); + Handle(AIS_Plane) aPlane = Handle(AIS_Plane)::DownCast (aTest); + if (aPlane.IsNull()) + { + std::cerr << "Error: Selected shape is not a plane.\n"; + return 1; } - // on le downcast - Handle(AIS_Plane) PlaneB =(Handle(AIS_Plane)::DownCast (theIOB)); - - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // on le display & bind - TheAISContext()->Display(PlaneB ); - GetMapOfAIS().Bind ( PlaneB ,argv[1]); + VDisplayAISObject (argv[1], aPlane); return 0; } @@ -613,7 +551,6 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char* // Declarations Standard_Boolean HasArg; TCollection_AsciiString name; - Standard_Integer MyCurrentIndex; // Verification if (argc<2 || argc>8 ) {di<<" Syntaxe error\n";return 1;} @@ -621,8 +558,9 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char* else HasArg=Standard_False; name=argv[1]; - // Fermeture des contextes - TheAISContext()->CloseAllContexts(); + + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); // Cas ou il y a des arguments // Purpose: Teste le constructeur AIS_Axis::AIS_Axis(x: Line from Geom) @@ -645,70 +583,41 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char* // fonction vaxis // Purpose: Teste le constructeur AIS_Axis::AIS_Axis (x:Axis1Placement from Geom) if ( !strcasecmp(argv[0], "vaxis")) { - TheAISContext()->OpenLocalContext(); - MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // Active le mode edge et le mode vertex - TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) ); - TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) ); - di<<" Select an edge or a vertex.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - // recuperation de la shape. - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - // recuperation de l'AIS_InteractiveObject - //Handle(AIS_InteractiveObject) myAISio=TheAISContext()->Current(); - // down cast en AIS_Point si sig et type - // AIS_Point -> Geom_Pnt .... - - if (ShapeA.ShapeType()==TopAbs_VERTEX) { - // on desactive le mode edge - TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) ); - di<<" Select a different vertex.\n"; - - TopoDS_Shape ShapeB; - do { - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - + if (aShapes.Extent() != 2 && aShapes.Extent() != 1) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } - } while(ShapeB.IsSame(ShapeA) ); + const TopoDS_Shape& aShapeA = aShapes.First(); + if (aShapeA.ShapeType() == TopAbs_VERTEX) + { + if (aShapes.Extent() != 2) + { + std::cerr << "Error: Wron number of selected shapes.\n"; + return 1; + } - // Fermeture du context local - TheAISContext()->CloseLocalContext(MyCurrentIndex); + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (aShapeB.ShapeType() != TopAbs_VERTEX) + { + std::cerr << "Syntax error: You should select two vertices or one edge.\n"; + return 1; + } // Construction de l'axe - gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) ); - gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); - gp_Vec V (A,B); - gp_Dir D (V); + gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA)); + gp_Pnt B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB)); + gp_Vec V (A,B); + gp_Dir D (V); Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (A,D); Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect); GetMapOfAIS().Bind (TheAxis,name); TheAISContext()->Display(TheAxis); } - else { - // Un unique edge (ShapeA) a ete picke - // Fermeture du context local - TheAISContext()->CloseLocalContext(MyCurrentIndex); - // Constuction de l'axe - TopoDS_Edge ed =TopoDS::Edge(ShapeA); + else + { + TopoDS_Edge ed =TopoDS::Edge (aShapeA); TopoDS_Vertex Va,Vb; TopExp::Vertices(ed,Va,Vb ); gp_Pnt A=BRep_Tool::Pnt(Va); @@ -725,49 +634,25 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char* // Fonction axispara // Purpose: Teste le constructeur AIS_Axis::AIS_Axis(x: Axis2Placement from Geom, y: TypeOfAxis from AIS) - else if ( !strcasecmp(argv[0], "vaxispara")) { - - TheAISContext()->OpenLocalContext(); - MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // Active le mode edge - TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) ); - di<<" Select an edge.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - // Active le mode vertex et deactive edges - TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) ); - di<<" Select a vertex.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - // On peut choisir un pnt sur l'edge - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - // Fermeture du context local - TheAISContext()->CloseLocalContext(MyCurrentIndex); + else if ( !strcasecmp(argv[0], "vaxispara")) + { + if (aShapes.Extent() != 2) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } - // Construction de l'axe - TopoDS_Edge ed=TopoDS::Edge(ShapeA) ; - gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (!(aShapeA.ShapeType() == TopAbs_EDGE + && aShapeB.ShapeType() == TopAbs_VERTEX)) + { + std::cerr << "Syntax error: You should select face and then vertex.\n"; + return 1; + } + + TopoDS_Edge ed=TopoDS::Edge (aShapeA); + gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(aShapeB)); TopoDS_Vertex Va,Vc; TopExp::Vertices(ed,Va,Vc ); gp_Pnt A=BRep_Tool::Pnt(Va); @@ -782,48 +667,26 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char* } // Fonction axisortho - else { - TheAISContext()->OpenLocalContext(); - MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // Active le mode edge - TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) ); - di<<" Select an edge.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - // Active le mode vertex et deactive edges - TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) ); - di<<" Slect a vertex.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - // On peut choisir un pnt sur l'edge - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - // Fermeture du context local - TheAISContext()->CloseLocalContext(MyCurrentIndex); + else + { + if (aShapes.Extent() != 2) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } + + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (!(aShapeA.ShapeType() == TopAbs_EDGE + && aShapeB.ShapeType() == TopAbs_VERTEX)) + { + std::cerr << "Syntax error: You should select face and then vertex.\n"; + return 1; + } // Construction de l'axe - TopoDS_Edge ed=TopoDS::Edge(ShapeA) ; - gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); + TopoDS_Edge ed=TopoDS::Edge(aShapeA) ; + gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(aShapeB) ); TopoDS_Vertex Va,Vc; TopExp::Vertices(ed,Va,Vc ); gp_Pnt A=BRep_Tool::Pnt(Va); @@ -866,7 +729,6 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char // Declarations Standard_Boolean HasArg; TCollection_AsciiString name; - Standard_Integer myCurrentIndex; // Verification if (argc<2 || argc>5 ) {di<<" Syntaxe error\n";return 1;} @@ -874,8 +736,6 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char else HasArg=Standard_False; name=argv[1]; - // Fermeture des contextes - TheAISContext()->CloseAllContexts(); // Il y a des arguments: teste l'unique constructeur AIS_Pnt::AIS_Pnt(Point from Geom) if (HasArg) { @@ -889,46 +749,31 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char } // Il n'a pas d'arguments - else { - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // Active le mode Vertex et Edges - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select a vertex or an edge(build the middle)\n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle + else + { + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); - TopoDS_Shape ShapeA; - for (TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA= TheAISContext()->SelectedShape(); + if (aShapes.Extent() != 1) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + std::cerr << "\tYou should select one edge or vertex.\n"; + return 1; } - if (ShapeA.ShapeType()==TopAbs_VERTEX ) { - // Un vertex a ete selectionne - // Fermeture du context local - TheAISContext()->CloseLocalContext(myCurrentIndex); + const TopoDS_Shape& aShapeA = aShapes.First(); - // Construction du point - gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA ) ); + if (aShapeA.ShapeType()==TopAbs_VERTEX ) + { + gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(aShapeA ) ); Handle(Geom_CartesianPoint) myGeomPoint= new Geom_CartesianPoint (A ); Handle(AIS_Point) myAISPoint = new AIS_Point (myGeomPoint ); GetMapOfAIS().Bind(myAISPoint,name); TheAISContext()->Display(myAISPoint); } - else { - // Un Edge a ete selectionne - // Fermeture du context local - TheAISContext()->CloseLocalContext(myCurrentIndex); - - // Construction du point milieu de l'edge - TopoDS_Edge myEdge=TopoDS::Edge(ShapeA); + else + { + TopoDS_Edge myEdge=TopoDS::Edge(aShapeA); TopoDS_Vertex myVertexA,myVertexB; TopExp::Vertices (myEdge ,myVertexA ,myVertexB ); gp_Pnt A=BRep_Tool::Pnt(myVertexA ); @@ -972,7 +817,6 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, // Declarations Standard_Boolean hasArg; TCollection_AsciiString aName; - Standard_Integer aCurrentIndex; // Verification if (argc<2 || argc>6 ) @@ -986,8 +830,6 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, hasArg=Standard_False; aName=argv[1]; - // Close all contexts - TheAISContext()->CloseAllContexts(); // There are some arguments if (hasArg) @@ -1228,103 +1070,32 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, // There are no arguments else { + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); + // Function vplane // Test the constructor AIS_Plane::AIS_Plane(Geom_Plane, Standard_Boolean ) if (!strcasecmp(argv[0], "vplane")) { - TheAISContext()->OpenLocalContext(); - aCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // Active modes Vertex, Edge and Face - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4)); - std::cout<<"Select a vertex, a face or an edge\n"; - - // Wait for picking - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // end of the loop - - TopoDS_Shape aShapeA; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) + if (aShapes.Extent() < 1 || aShapes.Extent() > 3) { - aShapeA = TheAISContext()->SelectedShape(); + std::cerr << "Error: Wront number of selected shapes.\n"; + std::cerr << "\tYou should one of variant: face, edge and vertex or three vertices.\n"; + return 1; } - // aShapeA is a Vertex - if (aShapeA.ShapeType()==TopAbs_VERTEX ) + const TopoDS_Shape& aShapeA = aShapes.First(); + if (aShapeA.ShapeType() == TopAbs_VERTEX) { - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4)); - std::cout<<" Select an edge or a different vertex\n"; - - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop - - TopoDS_Shape aShapeB; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) - { - aShapeB = TheAISContext()->SelectedShape(); - } - // aShapeB is a Vertex - if (aShapeB.ShapeType()==TopAbs_VERTEX) + if (aShapes.Extent() == 2) { - // A and B are the same - if (aShapeB.IsSame(aShapeA)) + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (aShapeB.ShapeType() != TopAbs_EDGE) { - std::cout<<" vplane: error, same points selected\n"; - return 1; - } - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2)); - std::cout<<" Select a different vertex\n"; - - // Wait for picking - Standard_Integer argcccc = 5; - const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvvv = (const char **) buffff; - while (ViewerMainLoop( argcccc, argvvvv) ) { } - // end of the loop - - TopoDS_Shape aShapeC; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) - { - aShapeC = TheAISContext()->SelectedShape(); - } - // aShapeC is the same as A or B - if (aShapeC.IsSame(aShapeA)||aShapeC.IsSame(aShapeB)) - { - std::cout<<" vplane: error, same points selected\n"; + std::cerr << "Syntax error: Together with vertex should be edge.\n"; return 1; } - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); - - // Construction of plane - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB)); - gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(aShapeC)); - GC_MakePlane MkPlane(A, B, C); - Handle(Geom_Plane) aGeomPlane = MkPlane.Value(); - Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane); - GetMapOfAIS().Bind (anAISPlane, aName); - TheAISContext()->Display(anAISPlane); - } - // ShapeB is an edge - else - { // Verify that the vertex is not on the edge ShapeB TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB); TopoDS_Vertex aVertA = TopoDS::Vertex(aShapeA); @@ -1338,9 +1109,6 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, } else { - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); - // Construction of plane gp_Pnt A = BRep_Tool::Pnt(aVertA); TopoDS_Vertex aVBa, aVBb; TopExp::Vertices(anEdgeB ,aVBa ,aVBb); @@ -1353,29 +1121,53 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, TheAISContext()->Display(anAISPlane); } } + else if (aShapes.Extent() == 3) + { + TopTools_ListOfShape::Iterator anIter (aShapes); + + anIter.Next(); + const TopoDS_Shape& aShapeB = anIter.Value(); + + anIter.Next(); + const TopoDS_Shape& aShapeC = anIter.Value(); + + if (!(aShapeB.ShapeType() == TopAbs_VERTEX + && aShapeC.ShapeType() == TopAbs_VERTEX)) + { + std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n"; + return 1; + } + + gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA)); + gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB)); + gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(aShapeC)); + GC_MakePlane MkPlane(A, B, C); + Handle(Geom_Plane) aGeomPlane = MkPlane.Value(); + Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane); + GetMapOfAIS().Bind (anAISPlane, aName); + TheAISContext()->Display(anAISPlane); + } + else + { + std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n"; + return 1; + } } - // aShapeA is an edge - else if (aShapeA.ShapeType()==TopAbs_EDGE) + else if (aShapeA.ShapeType() == TopAbs_EDGE) { - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4)); - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2)); - std::cout<<" Select a vertex that don't belong to the edge\n"; - - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop + if (aShapes.Extent() != 2) + { + std::cerr << "Error: wrong number of selected shapes.\n"; + return 1; + } - TopoDS_Shape aShapeB; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (aShapeB.ShapeType() != TopAbs_VERTEX) { - aShapeB = TheAISContext()->SelectedShape(); + std::cerr << "Syntax error: Together with edge should be vertex.\n"; + return 1; } - // aShapeB should be a Vertex + // Check that the vertex aShapeB is not on the edge TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA); TopoDS_Vertex aVertB = TopoDS::Vertex(aShapeB); @@ -1387,29 +1179,20 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, std::cout<<" vplane: error point is on the edge\n"; return 1; } - else - { - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); - // Construction of plane - gp_Pnt B = BRep_Tool::Pnt(aVertB); - TopoDS_Vertex aVAa, aVAb; - TopExp::Vertices(anEdgeA, aVAa, aVAb); - gp_Pnt Aa = BRep_Tool::Pnt(aVAa); - gp_Pnt Ab = BRep_Tool::Pnt(aVAb); - GC_MakePlane MkPlane (B,Aa,Ab); - Handle(Geom_Plane) aGeomPlane = MkPlane.Value(); - Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane); - GetMapOfAIS().Bind (anAISPlane ,aName); - TheAISContext()->Display(anAISPlane); - } + + gp_Pnt B = BRep_Tool::Pnt(aVertB); + TopoDS_Vertex aVAa, aVAb; + TopExp::Vertices(anEdgeA, aVAa, aVAb); + gp_Pnt Aa = BRep_Tool::Pnt(aVAa); + gp_Pnt Ab = BRep_Tool::Pnt(aVAb); + GC_MakePlane MkPlane (B,Aa,Ab); + Handle(Geom_Plane) aGeomPlane = MkPlane.Value(); + Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane); + GetMapOfAIS().Bind (anAISPlane ,aName); + TheAISContext()->Display(anAISPlane); } - // aShapeA is a Face - else + else if (aShapeA.ShapeType() == TopAbs_FACE) { - // Close the local context: nothing to select - TheAISContext()->CloseLocalContext(aCurrentIndex); - // Construction of plane TopoDS_Face aFace = TopoDS::Face(aShapeA); BRepAdaptor_Surface aSurface (aFace, Standard_False); if (aSurface.GetType()==GeomAbs_Plane) @@ -1426,6 +1209,11 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, return 1; } } + else + { + std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n"; + return 1; + } } // Function vPlanePara @@ -1433,120 +1221,44 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt) else if (!strcasecmp(argv[0], "vplanepara")) { - TheAISContext()->OpenLocalContext(); - aCurrentIndex = TheAISContext()->IndexOfCurrentLocal(); - - // Activate modes Vertex and Face - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4)); - std::cout<<" Select a vertex or a face\n"; - - // Wait for picking - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // end of the loop - - TopoDS_Shape aShapeA; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) + if (aShapes.Extent() != 2) { - aShapeA = TheAISContext()->SelectedShape(); + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; } - if (aShapeA.ShapeType()==TopAbs_VERTEX ) + const TopoDS_Shape* aShapeA = &aShapes.First(); + const TopoDS_Shape* aShapeB = &aShapes.Last(); + if (aShapeA->ShapeType() != TopAbs_VERTEX) { - // aShapeA is a vertex - // Deactivate the mode Vertex - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(1)); - std::cout<<" Select a face\n"; - - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop - - TopoDS_Shape aShapeB; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) - { - // A vertex ShapeA can be on Face ShapeB - aShapeB = TheAISContext()->SelectedShape(); - } + std::swap (aShapeA, aShapeB); + } - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); + if (!(aShapeA->ShapeType() == TopAbs_VERTEX + && aShapeB->ShapeType() == TopAbs_FACE)) + { + std::cerr << "Syntax error: you should select face and vertex.\n"; + return 1; + } - // Construction of plane - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA)); + gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(*aShapeA)); - TopoDS_Face aFace = TopoDS::Face(aShapeB); - BRepAdaptor_Surface aSurface (aFace, Standard_False); - if (aSurface.GetType()==GeomAbs_Plane ) - { - gp_Pln aPlane = aSurface.Plane(); - // Construct a plane parallel to aGeomPlane through A - aPlane.SetLocation(A); - Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); - Handle(AIS_Plane) aAISPlane = new AIS_Plane (aGeomPlane, A); - GetMapOfAIS().Bind (aAISPlane ,aName); - TheAISContext()->Display(aAISPlane); - } - else - { - std::cout<<" vplanepara: error\n"; - return 1; - } + TopoDS_Face aFace = TopoDS::Face(*aShapeB); + BRepAdaptor_Surface aSurface (aFace, Standard_False); + if (aSurface.GetType() == GeomAbs_Plane) + { + gp_Pln aPlane = aSurface.Plane(); + // Construct a plane parallel to aGeomPlane through A + aPlane.SetLocation(A); + Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); + Handle(AIS_Plane) aAISPlane = new AIS_Plane (aGeomPlane, A); + GetMapOfAIS().Bind (aAISPlane ,aName); + TheAISContext()->Display(aAISPlane); } else { - // ShapeA is a Face - // Deactive the mode Face - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4)); - std::cout<<" Select a vertex\n"; - - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop - - TopoDS_Shape aShapeB; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) - { - // A vertex ShapeB can be on Face ShapeA - aShapeB = TheAISContext()->SelectedShape(); - } - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); - - // Construction of plane - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB)); - - TopoDS_Face aFace=TopoDS::Face(aShapeA); - BRepAdaptor_Surface aSurface (aFace, Standard_False); - if (aSurface.GetType()==GeomAbs_Plane ) - { - gp_Pln aPlane = aSurface.Plane(); - aPlane.SetLocation(B); - Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); - // Construct a plane parallel to aGeomPlane through B - Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, B); - GetMapOfAIS().Bind (anAISPlane, aName); - TheAISContext()->Display(anAISPlane); - } - else - { - std::cout<<" vplanepara: error\n";return 1; - } + std::cerr << "Error: Builded surface is not a plane.\n"; + return 1; } } @@ -1555,165 +1267,70 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/, // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt,gp_Pnt,gp_Pnt) else { - TheAISContext()->OpenLocalContext(); - aCurrentIndex = TheAISContext()->IndexOfCurrentLocal(); - - // Activate the modes Edge and Face - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4)); - std::cout<<" Select a face and an edge coplanar\n"; + if (aShapes.Extent() != 2) + { + std::cerr << "Error: wrong number of selected shapes.\n"; + return 1; + } - // Wait for picking - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // end of the loop + const TopoDS_Shape* aShapeA = &aShapes.First(); + const TopoDS_Shape* aShapeB = &aShapes.Last(); - TopoDS_Shape aShapeA; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) + if (aShapeA->ShapeType() != TopAbs_EDGE) { - aShapeA = TheAISContext()->SelectedShape(); + std::swap (aShapeA, aShapeB); } - if (aShapeA.ShapeType()==TopAbs_EDGE ) + if (!(aShapeA->ShapeType() == TopAbs_EDGE + && aShapeB->ShapeType() == TopAbs_FACE)) { - // ShapeA is an edge, deactivate the mode Edge... - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2)); - std::cout<<" Select a face\n"; - - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop - - TopoDS_Shape aShapeB; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) - { - // Edge ShapeA can be on Face ShapeB - aShapeB = TheAISContext()->SelectedShape(); - } - - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); + std::cerr << "Error: you should select edge and face.\n"; + return 1; + } - // Construction of plane - TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA); - TopoDS_Vertex aVAa, aVAb; - TopExp::Vertices(anEdgeA, aVAa, aVAb); - gp_Pnt Aa = BRep_Tool::Pnt(aVAa); - gp_Pnt Ab = BRep_Tool::Pnt(aVAb); - gp_Vec ab (Aa,Ab); - - gp_Dir Dab (ab); - // Creation of rotation axis - gp_Ax1 aRotAxis (Aa,Dab); - - TopoDS_Face aFace = TopoDS::Face(aShapeB); - // The edge must be parallel to the face - BRepExtrema_ExtPF aHeightA (aVAa, aFace); - BRepExtrema_ExtPF aHeightB (aVAb, aFace); - // Compare to heights - if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1))) - >Precision::Confusion()) - { - // the edge is not parallel to the face - std::cout<<" vplaneortho error: the edge is not parallel to the face\n"; - return 1; - } - // the edge is OK - BRepAdaptor_Surface aSurface (aFace, Standard_False); - if (aSurface.GetType()==GeomAbs_Plane) - { - gp_Pln aPlane = aSurface.Plane(); - // It rotates a half turn round the axis of rotation - aPlane.Rotate(aRotAxis , M_PI/2); + // Construction of plane + TopoDS_Edge anEdgeA = TopoDS::Edge(*aShapeA); + TopoDS_Vertex aVAa, aVAb; + TopExp::Vertices(anEdgeA, aVAa, aVAb); + gp_Pnt Aa = BRep_Tool::Pnt(aVAa); + gp_Pnt Ab = BRep_Tool::Pnt(aVAb); + gp_Vec ab (Aa,Ab); + + gp_Dir Dab (ab); + // Creation of rotation axis + gp_Ax1 aRotAxis (Aa,Dab); + + TopoDS_Face aFace = TopoDS::Face(*aShapeB); + // The edge must be parallel to the face + BRepExtrema_ExtPF aHeightA (aVAa, aFace); + BRepExtrema_ExtPF aHeightB (aVAb, aFace); + // Compare to heights + if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1))) + >Precision::Confusion()) + { + // the edge is not parallel to the face + std::cout<<" vplaneortho error: the edge is not parallel to the face\n"; + return 1; + } + // the edge is OK + BRepAdaptor_Surface aSurface (aFace, Standard_False); + if (aSurface.GetType()==GeomAbs_Plane) + { + gp_Pln aPlane = aSurface.Plane(); + // It rotates a half turn round the axis of rotation + aPlane.Rotate(aRotAxis , M_PI/2); - Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); - // constructed aGeomPlane parallel to a plane containing the edge (center mid-edge) - gp_Pnt aMiddle ((Aa.X()+Ab.X() )/2 ,(Aa.Y()+Ab.Y() )/2 ,(Aa.Z()+Ab.Z() )/2 ); - Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle); - GetMapOfAIS().Bind (anAISPlane, aName); - TheAISContext()->Display(anAISPlane); - } - else - { - std::cout<<" vplaneortho: error\n"; - return 1; - } + Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); + // constructed aGeomPlane parallel to a plane containing the edge (center mid-edge) + gp_Pnt aMiddle ((Aa.X()+Ab.X() )/2 ,(Aa.Y()+Ab.Y() )/2 ,(Aa.Z()+Ab.Z() )/2 ); + Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle); + GetMapOfAIS().Bind (anAISPlane, aName); + TheAISContext()->Display(anAISPlane); } else { - // ShapeA is a Face, deactive the mode Face. - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4)); - std::cout<<" Select an edge\n"; - - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop - - TopoDS_Shape aShapeB; - for (TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected()) - { - // Edge ShapeB can be on Face ShapeA - aShapeB = TheAISContext()->SelectedShape(); - } - // Close the local context - TheAISContext()->CloseLocalContext(aCurrentIndex); - - // Construction of plane - TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB); - TopoDS_Vertex aVBa, aVBb; - TopExp::Vertices(anEdgeB, aVBa, aVBb); - gp_Pnt aBa = BRep_Tool::Pnt(aVBa); - gp_Pnt aBb = BRep_Tool::Pnt(aVBb); - gp_Vec ab (aBa,aBb); - gp_Dir Dab (ab); - // Creation of rotation axe - gp_Ax1 aRotAxis (aBa,Dab); - - TopoDS_Face aFace = TopoDS::Face(aShapeA); - // The edge must be parallel to the face - BRepExtrema_ExtPF aHeightA (aVBa, aFace); - BRepExtrema_ExtPF aHeightB (aVBb, aFace); - // Comparing the two heights - if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1))) - >Precision::Confusion()) - { - // the edge is not parallel to the face - std::cout<<" vplaneortho error: the edge is not parallel to the face\n"; - return 1; - } - // The edge is OK - BRepAdaptor_Surface aSurface (aFace, Standard_False); - if (aSurface.GetType()==GeomAbs_Plane) - { - gp_Pln aPlane = aSurface.Plane(); - // It rotates a half turn round the axis of rotation - aPlane.Rotate(aRotAxis , M_PI/2); - Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); - // constructed aGeomPlane parallel to a plane containing the edge theGeomPlane (center mid-edge) - gp_Pnt aMiddle ((aBa.X()+aBb.X() )/2 , (aBa.Y()+aBb.Y() )/2 , (aBa.Z()+aBb.Z() )/2 ); - Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle); - GetMapOfAIS().Bind (anAISPlane ,aName); - TheAISContext()->Display(anAISPlane); - } - else - { - std::cout<<" vplaneortho: error\n"; - return 1; - } + std::cout<<" vplaneortho: error\n"; + return 1; } } } @@ -1844,11 +1461,8 @@ static int VChangePlane (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - Standard_Integer myCurrentIndex; // Verifications if (argc!=4 && argc!=8 && argc!=2 ) {di<<"vline error: number of arguments not correct \n";return 1; } - // Fermeture des contextes - TheAISContext()->CloseAllContexts(); // On recupere les parametres Handle(AIS_InteractiveObject) theShapeA; @@ -1920,67 +1534,36 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char* // Pas de parametres: Selection dans le viewer. // ============================================ - else { - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // Active le mode Vertex. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) ); - di<<" Select a vertex \n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); + else + { + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); + if (aShapes.Extent() != 2) + { + std::cerr << "Error: wrong number of selected shapes.\n"; + return 1; } - // ShapeA est un Vertex - if (ShapeA.ShapeType()==TopAbs_VERTEX ) { - - di<<" Select a different vertex.\n"; + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); - TopoDS_Shape ShapeB; - do { - - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - - } while(ShapeB.IsSame(ShapeA) ); - - // Fermeture du context local - TheAISContext()->CloseLocalContext(myCurrentIndex); - - // Construction de la line - gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) ); - gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); - - Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint(A); - Handle(Geom_CartesianPoint ) myCartPointB=new Geom_CartesianPoint(B); + if (!(aShapeA.ShapeType() == TopAbs_VERTEX + && aShapeB.ShapeType() == TopAbs_VERTEX)) + { + std::cerr << "Error: you should select two different vertex.\n"; + return 1; + } - Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB ); - GetMapOfAIS().Bind(theAISLine,argv[1] ); - TheAISContext()->Display(theAISLine ); + // Construction de la line + gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA)); + gp_Pnt B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB)); - } - else { - di<<"vline error.\n"; - } + Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint(A); + Handle(Geom_CartesianPoint ) myCartPointB=new Geom_CartesianPoint(B); + Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB ); + GetMapOfAIS().Bind(theAISLine,argv[1] ); + TheAISContext()->Display(theAISLine ); } return 0; @@ -2132,14 +1715,12 @@ void DisplayCircle (Handle (Geom_Circle) theGeomCircle, static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv) { - Standard_Integer myCurrentIndex; // Verification of the arguments if (argc>6 || argc<2) { std::cout << "vcircle error: expect 4 arguments.\n"; return 1; // TCL_ERROR } - TheAISContext()->CloseAllContexts(); // There are all arguments if (argc == 6) @@ -2298,85 +1879,40 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const // Get the name of the circle TCollection_AsciiString aName(argv[1]); - TheAISContext()->OpenLocalContext(); - myCurrentIndex = TheAISContext()->IndexOfCurrentLocal(); - - // Activate selection mode for vertices and faces - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - std::cout << " Select a vertex or a face\n"; - - // Wait for picking - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // end of the loop - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected() ) + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); + if (aShapes.Extent() != 3 && aShapes.Extent() != 2) { - ShapeA = TheAISContext()->SelectedShape(); + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; } - // ShapeA is a Vertex - if (ShapeA.ShapeType() == TopAbs_VERTEX ) + const TopoDS_Shape& aShapeA = aShapes.First(); + if (aShapeA.ShapeType() == TopAbs_VERTEX ) { - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) ); - std::cout << " Select a different vertex\n"; - - TopoDS_Shape ShapeB; - do + if (aShapes.Extent() != 3) { - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop + std::cerr << "Error: wrong number of selected shapes.\n"; + return 1; + } - for(TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected() ) - { - ShapeB = TheAISContext()->SelectedShape(); - } - } while(ShapeB.IsSame(ShapeA) ); + TopTools_ListOfShape::Iterator anIter (aShapes); - // Selection of ShapeC - std::cout << " Select the last vertex\n"; - TopoDS_Shape ShapeC; - do - { - // Wait for picking - Standard_Integer argcccc = 5; - const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvvv = (const char **) buffff; - while (ViewerMainLoop( argcccc, argvvvv) ) { } - // end of the loop + anIter.Next(); + const TopoDS_Shape& aShapeB = anIter.Value(); - for(TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected() ) - { - ShapeC = TheAISContext()->SelectedShape(); - } - } while(ShapeC.IsSame(ShapeA) || ShapeC.IsSame(ShapeB) ); + anIter.Next(); + const TopoDS_Shape& aShapeC = anIter.Value(); // Get isFilled Standard_Boolean isFilled; std::cout << "Enter filled status (0 or 1)\n"; cin >> isFilled; - // Close the local context - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction of the circle - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC)); + gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA)); + gp_Pnt B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB)); + gp_Pnt C = BRep_Tool::Pnt (TopoDS::Vertex (aShapeC)); GC_MakeCircle Cir = GC_MakeCircle (A, B, C); Handle (Geom_Circle) theGeomCircle; @@ -2393,26 +1929,9 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const DisplayCircle(theGeomCircle, aName, isFilled); } - // Shape is a face - else + else if (aShapeA.ShapeType() == TopAbs_FACE) { - std::cout << " Select a vertex (in your face)\n"; - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) ); - - TopoDS_Shape ShapeB; - // Wait for picking - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // end of the loop - - for(TheAISContext()->InitSelected(); - TheAISContext()->MoreSelected(); - TheAISContext()->NextSelected() ) - { - ShapeB = TheAISContext()->SelectedShape(); - } + const TopoDS_Shape& aShapeB = aShapes.Last(); // Recover the radius Standard_Real theRad; @@ -2427,12 +1946,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const std::cout << "Enter filled status (0 or 1)\n"; cin >> isFilled; - // Close the local context - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction of the circle - // Recover the normal to the plane. tag - TopoDS_Face myFace = TopoDS::Face(ShapeA); + TopoDS_Face myFace = TopoDS::Face(aShapeA); BRepAdaptor_Surface mySurface (myFace, Standard_False); gp_Pln myPlane = mySurface.Plane(); Handle(Geom_Plane) theGeomPlane = new Geom_Plane (myPlane); @@ -2441,7 +1956,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const gp_Dir theDir = thegpAxe.Direction(); // Recover the center - gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); + gp_Pnt theCenter = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB)); // Construct the circle GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,theRad); @@ -2457,9 +1972,12 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const } DisplayCircle(theGeomCircle, aName, isFilled); - } - + else + { + std::cerr << "Error: You should select face and vertex or three vertices.\n"; + return 1; + } } return 0; @@ -3284,10 +2802,6 @@ static int VComputeHLR (Draw_Interpretor& di, return 1; } - // close local context - if (aContextAIS->HasOpenedContext ()) - aContextAIS->CloseLocalContext (); - Handle(HLRBRep_PolyAlgo) aPolyAlgo = new HLRBRep_PolyAlgo(); HLRBRep_PolyHLRToShape aHLRToShape; @@ -4596,10 +4110,12 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, const Standard_Integer aSelectionMode = Draw::Atoi (anArgNb == 3 ? theArgv[1] : theArgv[2]); const Standard_Boolean toTurnOn = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]) != 0; + Standard_DISABLE_DEPRECATION_WARNINGS if (aSelectionMode == 0 && anAISContext->HasOpenedContext()) { anAISContext->CloseLocalContext(); } + Standard_ENABLE_DEPRECATION_WARNINGS if (aSelectionMode == 0) { @@ -4635,23 +4151,19 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, if (aSelectionMode != 0 && toTurnOn) // Turn on specified mode { + Standard_DISABLE_DEPRECATION_WARNINGS if (!anAISContext->HasOpenedContext() && isToOpenLocalCtx) { anAISContext->OpenLocalContext (Standard_False); } + Standard_ENABLE_DEPRECATION_WARNINGS for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next()) { const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value(); - if (InList (anAISContext, anIO, 0)) - { - anAISContext->Deactivate (anIO, 0); - } - if (!InList (anAISContext, anIO, aSelectionMode)) - { - anAISContext->Load (anIO, -1, Standard_True); - anAISContext->Activate (anIO, aSelectionMode); - } + anAISContext->Deactivate (anIO, 0); + anAISContext->Load (anIO, -1, Standard_True); + anAISContext->Activate (anIO, aSelectionMode); } } @@ -4659,11 +4171,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, { for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next()) { - const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value(); - if (InList (anAISContext, anIO, aSelectionMode)) - { - anAISContext->Deactivate (anIO, aSelectionMode); - } + anAISContext->Deactivate (aSelectionMode); } } @@ -4839,8 +4347,6 @@ static Standard_Integer VTriangle (Draw_Interpretor& /*di*/, return 1; // TCL_ERROR } - TheAISContext()->CloseAllContexts(); - // Get and check values TCollection_AsciiString aName(argv[1]); @@ -4981,8 +4487,6 @@ static Standard_Integer VSegment (Draw_Interpretor& /*di*/, return 1; // TCL_ERROR } - TheAISContext()->CloseAllContexts(); - // Get and check arguments TCollection_AsciiString aName(argv[1]); Handle(AIS_Point) aPoint1, aPoint2; diff --git a/src/ViewerTest/ViewerTest_RelationCommands.cxx b/src/ViewerTest/ViewerTest_RelationCommands.cxx index 64103dd67b..99614da925 100644 --- a/src/ViewerTest/ViewerTest_RelationCommands.cxx +++ b/src/ViewerTest/ViewerTest_RelationCommands.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -247,6 +248,24 @@ static int ParseDimensionParams (Standard_Integer theArgNum, theAspect->MakeUnitsDisplayed (Standard_False); continue; } + else if (aParam.IsEqual ("-selected")) + { + if (!theShapeList) + { + std::cerr << "Error: unknown parameter '" << aParam << "'\n"; + return 1; + } + + for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected()) + { + TopoDS_Shape aShape = TheAISContext()->SelectedShape(); + if (!aShape.IsNull()) + { + theShapeList->Append (new AIS_Shape (aShape)); + } + } + continue; + } // Before all non-boolean flags parsing check if a flag have at least one value. if (anIt + 1 >= theArgNum) @@ -920,1718 +939,602 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/, return 0; } -//======================================================================= -//function : VAngleDimBuilder -//purpose : -//======================================================================= - -static int VAngleDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +namespace { - Standard_Integer aCurrentIndex; - if (argc!=2) - { - di << argv[0] << " error : wrong number of parameters.\n"; - return 1; - } - - TheAISContext()->CloseAllContexts(); - aCurrentIndex = TheAISContext()->OpenLocalContext(); - // Set selection mode for edges. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2)); - di << "Select two edges coplanar or not.\n"; - - Standard_Integer anArgsNum = 5; - const char *aBuffer[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **anArgsVec = (const char **) aBuffer; - while (ViewerMainLoop (anArgsNum, anArgsVec)) { } - - TopoDS_Shape aFirstShape; - for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected()) - { - aFirstShape = TheAISContext()->SelectedShape(); - } - - if (aFirstShape.IsNull()) - { - di << argv[0] << " error : no picked shape.\n"; - return 1; - } - - if (aFirstShape.ShapeType()== TopAbs_EDGE) + //! If the given shapes are edges then check whether they are parallel else return true. + Standard_Boolean IsParallel (const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2) { - while (ViewerMainLoop (anArgsNum, anArgsVec)) { } - - TopoDS_Shape aSecondShape; - for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected()) - { - aSecondShape = TheAISContext()->SelectedShape(); - } - - if (aSecondShape.IsNull()) - { - di << argv[0] << " error : no picked shape.\n"; - return 1; - } - - if (aSecondShape.ShapeType() != TopAbs_EDGE) + if (theShape1.ShapeType() == TopAbs_EDGE + && theShape2.ShapeType() == TopAbs_EDGE) { - di << argv[0] <<" error: you should have selected an edge.\n"; return 1; + BRepExtrema_ExtCC aDelta (TopoDS::Edge (theShape1), + TopoDS::Edge (theShape2)); + return aDelta.IsParallel(); } - // Close local context to draw dimension in the neutral point. - TheAISContext()->CloseLocalContext (aCurrentIndex); - - // Construct the dimension. - Handle (AIS_AngleDimension) aDim= new AIS_AngleDimension (TopoDS::Edge(aFirstShape) ,TopoDS::Edge(aSecondShape)); - VDisplayAISObject (argv[1], aDim); - } - else - { - di << argv[0] << " error: you must select 2 edges.\n"; - return 1; + return Standard_True; } - - return 0; } - -//============================================================================== -//function : VDiameterDim -//purpose : Display the diameter dimension of a face or an edge. -//Draw arg : vdiameterdim Name -//============================================================================== - -static int VDiameterDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +//======================================================================= +//function : VRelationBuilder +//purpose : Command for building realation presentation +//======================================================================= +static int VRelationBuilder (Draw_Interpretor& /*theDi*/, + Standard_Integer theArgsNb, + const char** theArgs) { - // Declarations - Standard_Integer aCurrentIndex; - - // Verification - if (argc != 2) + if (theArgsNb < 2) { - di<<" vdiameterdim error\n"; + std::cerr << "Error: wrong number of arguments.\n"; return 1; } - // Close all local contexts - TheAISContext()->CloseAllContexts(); - // Open local context and get its index for recovery - TheAISContext()->OpenLocalContext(); - aCurrentIndex = TheAISContext()->IndexOfCurrentLocal(); - - // Activate 'edge' selection mode - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select an circled edge.\n"; - - // Loop that will handle the picking. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // end of the loop. - - TopoDS_Shape aShape; - for(TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected()) - { - aShape = TheAISContext()->SelectedShape(); - } + TCollection_AsciiString aName (theArgs[1]); + TCollection_AsciiString aType (theArgs[2]); - if (aShape.IsNull()) + AIS_KindOfRelation aKindOfRelation = AIS_KOR_NONE; + if (aType == "-concentric") { - di << argv[0] << ": no shape is selected.\n"; - return 1; + aKindOfRelation = AIS_KOR_CONCENTRIC; } - - if (aShape.ShapeType() != TopAbs_EDGE) + else if (aType == "-equaldistance") { - di << " vdiameterdim error: the selection of a face or an edge was expected.\n"; - return 1; + aKindOfRelation = AIS_KOR_EQUALDISTANCE; } - - // Compute the radius - BRepAdaptor_Curve aCurve (TopoDS::Edge (aShape)); - - if (aCurve.GetType() != GeomAbs_Circle) + else if (aType == "-equalradius") { - di << "vdiameterdim error: the edge is not a circular one.\n"; - return 1; - } - - // Construction of the diameter dimension. - TheAISContext()->CloseLocalContext (aCurrentIndex); - Handle (AIS_DiameterDimension) aDiamDim= new AIS_DiameterDimension (aShape); - VDisplayAISObject (argv[1], aDiamDim); - - return 0; -} - - -//============================================================================== -// Fonction vconcentric -// ----------------- Uniquement par selection dans le viewer. -//============================================================================== - -//============================================================================== -//function : VConcentric -//purpose : Display the concentric relation between two surfaces. -//Draw arg : vconcentric Name -//============================================================================== -static int VConcentricBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<"vconcentric error.\n";return 1;} - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Edges et Faces. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select a circled edge.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - // ShapeA est un edge - // ================== - if (ShapeA.ShapeType()==TopAbs_EDGE ) { - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select an edge.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - if (ShapeB.ShapeType()!=TopAbs_EDGE ) { - di<<" vconcentric error: select an edge.\n";return 1; - } - - // Construction du plane. - // On recupere le centre du cercle A. - BRepAdaptor_Curve theCurveA(TopoDS::Edge(ShapeA) ); - gp_Circ theCircleA=theCurveA.Circle(); - gp_Pnt theCenterA=theCircleA.Location(); - // On recupere deux points sur le cercle A - gp_Pnt B= theCurveA.Value(0.25); - gp_Pnt C= theCurveA.Value(0.75); - // Construction du plane. - GC_MakePlane MkPlane(theCenterA ,B ,C ); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - - // Fermeture du context local - TheAISContext()->CloseLocalContext(myCurrentIndex); - - Handle (AIS_ConcentricRelation) myConcentry= new AIS_ConcentricRelation(ShapeA, ShapeB, theGeomPlane ); - TheAISContext()->Display(myConcentry ); - GetMapOfAIS().Bind (myConcentry,argv[1]); - } - - - else { - di<<" vconcentric error: the selection of a face or an edge was expected.\n";return 1; - } - - return 0; - - - - -} - -//============================================================================== -//function : VEqualDistRelation -//purpose : -//Draw arg : vdiameterdim Name DiameterValue -//============================================================================== -static int VEqualDistRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vequaldistrelation error: no arguments allowed.\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Edges et Vertexes. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) ); - di<<" Select an edge or a vertex\n"; - - // Boucle d'attente waitpick. - Standard_Integer argc1 = 5; - const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv1 = (const char **) buf1; - while (ViewerMainLoop( argc1, argv1) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - di<<" Select an edge or a vertex\n"; - // Boucle d'attente waitpick. - Standard_Integer argc2 = 5; - const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv2 = (const char **) buf2; - while (ViewerMainLoop( argc2, argv2) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - // Verification des resultats. - if (ShapeA.ShapeType()==TopAbs_EDGE && ShapeB.ShapeType()==TopAbs_EDGE ) { - // A et B sont des edges ils doivent etre paralleles - BRepExtrema_ExtCC myDeltaEdge (TopoDS::Edge(ShapeA) ,TopoDS::Edge(ShapeB) ); - // on verifie qu'ils sont pas paralleles. - if (!myDeltaEdge.IsParallel() ) {di<<"vequaldist error: non parallel edges.\n";return 1; } - - } - - - di<<" Select an edge or a vertex\n"; - // Boucle d'attente waitpick. - Standard_Integer argc3 = 5; - const char *buf3[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv3 = (const char **) buf3; - while (ViewerMainLoop( argc3, argv3) ) { } - // fin de la boucle - - TopoDS_Shape ShapeC; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeC = TheAISContext()->SelectedShape(); - } - - di<<" Select an edge or a vertex\n"; - // Boucle d'attente waitpick. - Standard_Integer argc4 = 5; - const char *buf4[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv4 = (const char **) buf4; - while (ViewerMainLoop( argc4, argv4) ) { } - // fin de la boucle - - TopoDS_Shape ShapeD; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeD = TheAISContext()->SelectedShape(); - } - // Verification des resultats. - if (ShapeC.ShapeType()==TopAbs_EDGE && ShapeD.ShapeType()==TopAbs_EDGE ) { - // C et D sont des edges ils doivent etre paralleles - BRepExtrema_ExtCC myDeltaEdge2 (TopoDS::Edge(ShapeC) ,TopoDS::Edge(ShapeD) ); - // on verifie qu'ils sont pas paralleles. - if (!myDeltaEdge2.IsParallel() ) {di<<"vequaldist error: non parallel edges.\n";return 1; } - - } - - // Creation du plan porteur de la contrainte.Methode lourde! - gp_Pnt A,B,C; - if (ShapeA.ShapeType()==TopAbs_EDGE) { - // A est un edge - TopoDS_Vertex Va,Vb; - TopExp::Vertices (TopoDS::Edge(ShapeA) ,Va ,Vb ); - A=BRep_Tool::Pnt(Va); - B=BRep_Tool::Pnt(Vb); - - if (ShapeB.ShapeType()==TopAbs_EDGE) { - // B est un edge aussi - TopoDS_Vertex Vc,Vd; - TopExp::Vertices (TopoDS::Edge(ShapeB) ,Vc ,Vd ); - // besoin que de 1 point. - C=BRep_Tool::Pnt(Vc); - - } - else { - // B est un vertex - C=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); - } - } - else { - // A est un vertex - A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) ); - - if (ShapeB.ShapeType()==TopAbs_EDGE ) { - // B est un edge - TopoDS_Vertex Vb,Vc; - TopExp::Vertices (TopoDS::Edge(ShapeB) ,Vb ,Vc ); - // besoin que de 2 points. - B=BRep_Tool::Pnt(Vb); - C=BRep_Tool::Pnt(Vc); - - } - else { - // B est un vertex - B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); - C.SetX(B.X()+5.); - C.SetY(B.Y()+5.); - C.SetZ(B.Z()+5.); - - } - } - - // Fermeture du context local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - - // construction du plane - GC_MakePlane MkPlane(A ,B ,C ); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - - // Construction de l'AIS_EqualDistanceRelation - Handle (AIS_EqualDistanceRelation ) myRelation= new AIS_EqualDistanceRelation (ShapeA, ShapeB, ShapeC ,ShapeD , theGeomPlane ); - TheAISContext()->Display(myRelation ); - GetMapOfAIS().Bind (myRelation,argv[1]); - - - - return 0; - -} - -//============================================================================== -//function : VEqualRadiusRelation -//purpose : -//Draw arg : vdiameterdim Name DiameterValue -//============================================================================== -static int VEqualRadiusRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vequalrad error: no arguments allowed.\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Edges. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select an circled edge \n"; - - // Boucle d'attente waitpick. - Standard_Integer argc1 = 5; - const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv1 = (const char **) buf1; - while (ViewerMainLoop( argc1, argv1) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - di<<" Select the last circled edge.\n"; - // Boucle d'attente waitpick. - Standard_Integer argc2 = 5; - const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv2 = (const char **) buf2; - while (ViewerMainLoop( argc2, argv2) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - // creation du plan qui contient la contrainte. - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB); - BRepAdaptor_Curve theCurveA(EdgeA); - // On recupere 3 points A,B,C de la curve. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.5); - gp_Pnt C=theCurveA.Value(0.9); - - // fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - - // Creation du plane. - GC_MakePlane MkPlane (A ,B ,C ); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Construction de l'AIS_EqualRadiusRelation - Handle (AIS_EqualRadiusRelation ) myRelation= new AIS_EqualRadiusRelation (EdgeA,EdgeB, theGeomPlane ); - TheAISContext()->Display(myRelation ); - GetMapOfAIS().Bind (myRelation,argv[1]); - - return 0; - -} - - -//============================================================================== -//function : VFixRelation -//purpose : -//Draw arg : vdiameterdim Name DiameterValue -//============================================================================== -static int VFixRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vfix error: no arguments allowed.\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections edge. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select an edge. \n"; - - // Boucle d'attente waitpick. - Standard_Integer argc1 = 5; - const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv1 = (const char **) buf1; - while (ViewerMainLoop( argc1, argv1) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - // creation du plan qui contient la contrainte. - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - BRepAdaptor_Curve theCurveA(EdgeA); - // On recupere 3 points A,B,C de la curve. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.5); - gp_Pnt D=theCurveA.Value(0.9); - gp_Pnt C(B.X()+5,B.Y()+5,B.Z()+5); - - // fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - - // Creation du plane. - GC_MakePlane MkPlane (A ,D ,C ); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Construction de l'AIS_EqualRadiusRelation - Handle (AIS_FixRelation) myRelation= new AIS_FixRelation (EdgeA,theGeomPlane ); - TheAISContext()->Display(myRelation ); - GetMapOfAIS().Bind (myRelation,argv[1]); - - - return 0; - -} - -//============================================================================== -//function : VIdenticRelation -//purpose : -//Draw arg : vdiameterdim Name DiameterValue -//============================================================================== -static int VIdenticRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" videntity error: no arguments allowed.\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections vertex et face. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select an edge, a face or a vertex. \n"; - - // Boucle d'attente waitpick. - Standard_Integer argc1 = 5; - const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv1 = (const char **) buf1; - while (ViewerMainLoop( argc1, argv1) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); + aKindOfRelation = AIS_KOR_EQUALRADIUS; } - - di<<" Select an edge, a face or a vertex. \n"; - // Boucle d'attente waitpick. - Standard_Integer argc2 = 5; - const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv2 = (const char **) buf2; - while (ViewerMainLoop( argc2, argv2) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - // Recuperation de points pour construir le Geom_Plnae. - gp_Pnt A,B,C; - if (ShapeA.ShapeType()==TopAbs_EDGE) { - // A est un edge; on peut supposer qu'il sera element d'une face ou possesseur d'un vertex ou identic a un autre edge. - // on recupere deux points sur l'edge (il peut etre rectiligne) - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - BRepAdaptor_Curve theCurveA(EdgeA); - // Creation des 3 points. - A=theCurveA.Value(0.1); - B=theCurveA.Value(0.9); - C.SetX(B.X()+5.); - C.SetY(B.Y()+5.); - C.SetZ(B.Z()+5.); - } - else if (ShapeA.ShapeType()==TopAbs_VERTEX ) { - // SahpeA est un Vertex - // On va utiliser ShapeB - if (ShapeB.ShapeType()==TopAbs_EDGE) { - // B est un edge - TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB); - BRepAdaptor_Curve theCurveB(EdgeB); - // Creation des 3 points. - A=theCurveB.Value(0.1); - B=theCurveB.Value(0.9); - C.SetX(B.X()+5.); - C.SetY(B.Y()+5.); - C.SetZ(B.Z()+5.); - - } - else if (ShapeB.ShapeType()==TopAbs_FACE ) { - // Shape B est une face - TopoDS_Face FaceB=TopoDS::Face(ShapeB); - // On recupere 1 edge de FaceB(la face n'a pas forcement de vertex) (l'element A est forcement dans B). - TopExp_Explorer FaceExp(FaceB,TopAbs_EDGE); - TopoDS_Edge EdgeFromB=TopoDS::Edge(FaceExp.Current() ); - // On recupere les 3 points de l'edge de face B - BRepAdaptor_Curve theCurveB(EdgeFromB); - // On recupere 3 points A,B,C de la curve. - A=theCurveB.Value(0.1); - B=theCurveB.Value(0.5); - C=theCurveB.Value(0.9); - - } - else { - // B ets un vetex aussi - A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) ); - B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) ); - C.SetX(B.X()+5.); - C.SetY(B.Y()+5.); - C.SetZ(B.Z()+5.); - - } - + else if (aType == "-fix") + { + aKindOfRelation = AIS_KOR_FIX; } - else { - // A est une face. - TopoDS_Face FaceA=TopoDS::Face(ShapeA); - // On recupere 1 edge de FaceA - TopExp_Explorer FaceExp(FaceA,TopAbs_EDGE); - TopoDS_Edge EdgeFromA=TopoDS::Edge(FaceExp.Current() ); - // On recupere les 3 points de l'edge - BRepAdaptor_Curve theCurveA(EdgeFromA); - // On recupere 3 points A,B,C de la curve. - A=theCurveA.Value(0.1); - B=theCurveA.Value(0.5); - C=theCurveA.Value(0.9); - + else if (aType == "-identic") + { + aKindOfRelation = AIS_KOR_IDENTIC; } - - // Fermeture du context local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // On construit le plane - GC_MakePlane MkPlane (A ,B ,C ); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - - // Construction de l'AIS_IdenticRelation - Handle ( AIS_IdenticRelation ) myRelation= new AIS_IdenticRelation (ShapeA ,ShapeB, theGeomPlane ); - TheAISContext()->Display(myRelation ); - GetMapOfAIS().Bind (myRelation,argv[1]); - - - - return 0; - -} -//============================================================================== -//function : VLengthDimension -//purpose : Display the diameter dimension of a face or an edge. -//Draw arg : vdiameterdim Name DiameterValue -//============================================================================== -static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer aCurrentIndex; - // Verification - if (argc != 2) + else if (aType == "-offset") { - di << argv[0] << " error: wrong number of arguments.\n"; - return 1; + aKindOfRelation = AIS_KOR_OFFSET; } - - // Close all local contexts - TheAISContext()->CloseAllContexts(); - - // Open local context - aCurrentIndex = TheAISContext()->OpenLocalContext(); - // Activate 'edge', 'face' and 'vertex' selection modes. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4)); - - // First shape picking - di << " Select an edge, a face or a vertex. \n"; - // Loop that will handle the picking. - Standard_Integer argc1 = 5; - const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv1 = (const char **) buf1; - while (ViewerMainLoop( argc1, argv1) ) { } - // end of the loop. - - TopoDS_Shape aFirstShape; - for(TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected()) + else if (aType == "-parallel") { - aFirstShape = TheAISContext()->SelectedShape(); + aKindOfRelation = AIS_KOR_PARALLEL; } - - if (aFirstShape.IsNull()) + else if (aType == "-perpendicular") { - di << argv[0] << "error: no first picked shape.\n"; - return 1; + aKindOfRelation = AIS_KOR_PERPENDICULAR; } - - // Second shape picking - di << " Select an edge, a face or a vertex. \n"; - // Loop that will handle the picking. - Standard_Integer argc2 = 5; - const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argv2 = (const char **) buf2; - while (ViewerMainLoop( argc2, argv2) ) { } - - TopoDS_Shape aSecondShape; - for(TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected()) + else if (aType == "-tangent") { - aSecondShape = TheAISContext()->SelectedShape(); + aKindOfRelation = AIS_KOR_TANGENT; } - - if (aSecondShape.IsNull()) + else if (aType == "-symmetric") { - di << argv[0] << "error: no second picked shape.\n"; - return 1; + aKindOfRelation = AIS_KOR_SYMMETRIC; } - if (aFirstShape.ShapeType() == TopAbs_EDGE) - { - TopoDS_Edge EdgeA = TopoDS::Edge (aFirstShape); + TopTools_ListOfShape aShapes; + ViewerTest::GetSelectedShapes (aShapes); - if (aSecondShape.ShapeType() == TopAbs_EDGE) + // Build relation. + Handle(AIS_Relation) aRelation; + switch (aKindOfRelation) + { + case AIS_KOR_CONCENTRIC: { - TopoDS_Edge EdgeB = TopoDS::Edge (aSecondShape); - BRepExtrema_ExtCC myDeltaEdge (EdgeA ,EdgeB); - - if (!myDeltaEdge.IsParallel()) + if (aShapes.Extent() != 2) { - di << argv[0] << " error: non parallel edges.\n"; + std::cerr << "Error: Wrong number of selected shapes.\n"; return 1; } - // 3 points of edges is recovered to build a plane - TopoDS_Vertex aVertex1, aVertex2, aVertex3, aVertex4; - TopExp::Vertices (EdgeA, aVertex1, aVertex2); - TopExp::Vertices (EdgeB, aVertex3, aVertex4); - gp_Pnt A = BRep_Tool::Pnt (aVertex1); - gp_Pnt B = BRep_Tool::Pnt (aVertex2); - gp_Pnt C = BRep_Tool::Pnt (aVertex3); + const TopoDS_Shape& aShape1 = aShapes.First(); + const TopoDS_Shape& aShape2 = aShapes.Last(); - gce_MakePln aMakePlane (A,B,C); - gp_Pln aPlane= aMakePlane.Value(); + if (!(aShape1.ShapeType() == TopAbs_EDGE + && aShape2.ShapeType() == TopAbs_EDGE)) + { + std::cerr << "Syntax error: selected shapes are not edges.\n"; + return 1; + } - // Close local context - TheAISContext()->CloseLocalContext (aCurrentIndex); + BRepAdaptor_Curve aCurve1 (TopoDS::Edge (aShape1)); + gp_Circ aCircle1 = aCurve1.Circle(); + gp_Pnt aCenter1 = aCircle1.Location(); + gp_Pnt B = aCurve1.Value (0.25); + gp_Pnt C = aCurve1.Value (0.75); + GC_MakePlane aMkPlane (aCenter1, B, C); - // Construct the dimension - Handle(AIS_LengthDimension ) aLenghtDim = new AIS_LengthDimension (EdgeA, EdgeB, aPlane); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); - } + aRelation = new AIS_ConcentricRelation (aShape1, aShape2, aMkPlane.Value()); - else if (aSecondShape.ShapeType() == TopAbs_VERTEX) - { - TopoDS_Vertex aVertex = TopoDS::Vertex (aSecondShape); - BRepExtrema_ExtPC myDeltaEdgeVertex (aVertex ,EdgeA); - - TopoDS_Vertex aVertex1, aVertex2; - TopExp::Vertices (EdgeA, aVertex1, aVertex2); - gp_Pnt A=BRep_Tool::Pnt (aVertex1); - gp_Pnt B=BRep_Tool::Pnt (aVertex2); - gp_Pnt C=BRep_Tool::Pnt (aVertex); - - gce_MakePln aMakePlane (A,B,C); - gp_Pln aPlane= aMakePlane.Value(); - - TheAISContext()->CloseLocalContext (aCurrentIndex); - Handle(AIS_LengthDimension) aLenghtDim=new AIS_LengthDimension (EdgeA, aVertex, aPlane); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); + break; } - // Second shape is a face - else + case AIS_KOR_EQUALDISTANCE: { - TopoDS_Face FaceB = TopoDS::Face (aSecondShape); - BRepExtrema_ExtCF aDeltaEdgeFace (EdgeA,FaceB); - - if (!aDeltaEdgeFace.IsParallel()) + if (aShapes.Extent() != 4) { - di << argv[0] << "error: the edge isn't parallel to the face;can't compute the distance.\n"; + std::cerr << "Error: Wrong number of selected shapes.\n"; return 1; } - Handle(AIS_LengthDimension) aLenghtDim = new AIS_LengthDimension (FaceB, EdgeA); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); - } - } - else if (aFirstShape.ShapeType() == TopAbs_VERTEX) - { - TopoDS_Vertex VertexA = TopoDS::Vertex (aFirstShape); - if (aSecondShape.ShapeType() == TopAbs_EDGE ) - { - TopoDS_Edge EdgeB=TopoDS::Edge (aSecondShape); - BRepExtrema_ExtPC aDeltaEdgeVertex (VertexA, EdgeB); + TopoDS_Shape aSelectedShapes[4]; - TopoDS_Vertex aVertex1, aVertex2; - TopExp::Vertices(EdgeB, aVertex1, aVertex2); - gp_Pnt A = BRep_Tool::Pnt (aVertex1); - gp_Pnt B = BRep_Tool::Pnt (aVertex2); - gp_Pnt C = BRep_Tool::Pnt (VertexA); + Standard_Integer anIdx = 0; + TopTools_ListOfShape::Iterator anIter (aShapes); + for (; anIter.More(); anIter.Next(), ++anIdx) + { + aSelectedShapes[anIdx] = anIter.Value(); + } - gce_MakePln aMakePlane (A,B,C); - gp_Pln aPlane = aMakePlane.Value(); + if (!IsParallel (aSelectedShapes[0], aSelectedShapes[1]) + || !IsParallel (aSelectedShapes[2], aSelectedShapes[3])) + { + std::cerr << "Syntax error: non parallel edges.\n"; + return 1; + } - // Close local contex by its index. - TheAISContext()->CloseLocalContext (aCurrentIndex); + gp_Pnt A, B, C; + if (aSelectedShapes[0].ShapeType() == TopAbs_EDGE) + { + TopoDS_Vertex Va, Vb; + TopExp::Vertices (TopoDS::Edge (aSelectedShapes[0]), Va, Vb); + A = BRep_Tool::Pnt (Va); + B = BRep_Tool::Pnt (Vb); - // Construct the dimension. - Handle(AIS_LengthDimension) aLenghtDim = new AIS_LengthDimension (EdgeB,VertexA, aPlane); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); - } + if (aSelectedShapes[1].ShapeType() == TopAbs_EDGE) + { + TopoDS_Vertex Vc, Vd; + TopExp::Vertices (TopoDS::Edge (aSelectedShapes[1]), Vc, Vd); + C = BRep_Tool::Pnt (Vc); + } + else + { + C = BRep_Tool::Pnt (TopoDS::Vertex (aSelectedShapes[1])); + } + } + else + { + A = BRep_Tool::Pnt (TopoDS::Vertex (aSelectedShapes[0])); - else if (aSecondShape.ShapeType() == TopAbs_VERTEX) - { - TopoDS_Vertex VertexB = TopoDS::Vertex (aSecondShape); + if (aSelectedShapes[1].ShapeType() == TopAbs_EDGE) + { + TopoDS_Vertex Vb, Vc; + TopExp::Vertices (TopoDS::Edge (aSelectedShapes[1]), Vb, Vc); + B = BRep_Tool::Pnt (Vb); + C = BRep_Tool::Pnt (Vc); - gp_Pnt A = BRep_Tool::Pnt (VertexA); - gp_Pnt B = BRep_Tool::Pnt (VertexB); - gp_Pnt C(B.X() + 10.0, B.Y() + 10.0, B.Z() + 10.0); + } + else + { + B = BRep_Tool::Pnt (TopoDS::Vertex (aSelectedShapes[1])); + C.SetX (B.X() + 5.0); + C.SetY (B.Y() + 5.0); + C.SetZ (B.Z() + 5.0); - gce_MakePln aMakePlane (A,B,C); - gp_Pln aPlane= aMakePlane.Value(); + } + } - TheAISContext()->CloseLocalContext (aCurrentIndex); + GC_MakePlane aMkPlane (A, B, C); + aRelation = new AIS_EqualDistanceRelation (aSelectedShapes[0], + aSelectedShapes[1], + aSelectedShapes[2], + aSelectedShapes[3], + aMkPlane.Value()); - Handle(AIS_LengthDimension ) aLenghtDim = new AIS_LengthDimension (VertexA, VertexB, aPlane); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); + break; } - // The second shape is face - else - { - TopoDS_Face FaceB = TopoDS::Face (aSecondShape); - BRepExtrema_ExtPF aDeltaVertexFace (VertexA, FaceB); + case AIS_KOR_EQUALRADIUS: + { + if (aShapes.Extent() != 2 && aShapes.Extent() != 1) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } - gp_Pnt A = BRep_Tool::Pnt (VertexA); + const TopoDS_Shape& aShape1 = aShapes.First(); + const TopoDS_Shape& aShape2 = (aShapes.Extent() == 2) ? aShapes.Last() : aShape1; + if (!(aShape1.ShapeType() == TopAbs_EDGE + && aShape2.ShapeType() == TopAbs_EDGE)) + { + std::cerr << "Syntax error: selected shapes are not edges.\n"; + return 1; + } - // Recover edge from face. - TopExp_Explorer aFaceExp (FaceB,TopAbs_EDGE); - TopoDS_Edge aSecondEdge = TopoDS::Edge (aFaceExp.Current()); + TopoDS_Edge anEdge1 = TopoDS::Edge (aShape1); + TopoDS_Edge anEdge2 = TopoDS::Edge (aShape2); + BRepAdaptor_Curve aCurve1 (anEdge1); + gp_Pnt A = aCurve1.Value (0.1); + gp_Pnt B = aCurve1.Value (0.5); + gp_Pnt C = aCurve1.Value (0.9); + GC_MakePlane aMkPlane (A, B, C); - TopoDS_Vertex aVertex1, aVertex2; - TopExp::Vertices (aSecondEdge, aVertex1, aVertex2); - gp_Pnt C = BRep_Tool::Pnt (aVertex2); + aRelation = new AIS_EqualRadiusRelation (anEdge1, anEdge2, aMkPlane.Value()); + break; + } - gp_Pnt aProjA = aDeltaVertexFace.Point(1); - BRepBuilderAPI_MakeVertex aVertexMaker (aProjA); - TopoDS_Vertex aVertexAProj = aVertexMaker.Vertex(); + case AIS_KOR_FIX: + { + if (aShapes.Extent() != 1) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } - // Create working plane for the dimension. - gce_MakePln aMakePlane (A, aProjA, C); - gp_Pln aPlane = aMakePlane.Value(); + const TopoDS_Shape& aShape = aShapes.First(); + if (aShape.ShapeType() != TopAbs_EDGE) + { + std::cerr << "Syntax error: selected shapes are not edges.\n"; + return 1; + } - TheAISContext()->CloseLocalContext (aCurrentIndex); + TopoDS_Edge anEdge = TopoDS::Edge (aShape); + BRepAdaptor_Curve aCurve (anEdge); + gp_Pnt A = aCurve.Value(0.1); + gp_Pnt B = aCurve.Value(0.5); + gp_Pnt D = aCurve.Value(0.9); + gp_Pnt C (B.X() + 5.0, B.Y() + 5.0, B.Z() + 5.0); + GC_MakePlane aMkPlane (A, D, C); - // Construct the dimension. - Handle(AIS_LengthDimension ) aLenghtDim = new AIS_LengthDimension (VertexA, aVertexAProj, aPlane); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); + aRelation = new AIS_FixRelation (anEdge, aMkPlane.Value()); + break; } - } - // The first shape is a face. - else - { - TopoDS_Face FaceA = TopoDS::Face (aFirstShape); - - if (aSecondShape.ShapeType() == TopAbs_EDGE) + case AIS_KOR_IDENTIC: { - TopoDS_Edge EdgeB = TopoDS::Edge (aSecondShape); - BRepExtrema_ExtCF aDeltaEdgeFace (EdgeB,FaceA ); - - if (!aDeltaEdgeFace.IsParallel()) + if (aShapes.Extent() != 2) { - di << argv[0] << " error: the edge isn't parallel to the face;can't compute the distance. \n"; + std::cerr << "Error: Wrong number of selected shapes.\n"; return 1; } - Handle(AIS_LengthDimension) aLenghtDim = new AIS_LengthDimension (FaceA, EdgeB); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); + + gp_Pnt A,B,C; + if (aShapeA.ShapeType() == TopAbs_EDGE) + { + TopoDS_Edge anEdgeA = TopoDS::Edge (aShapeA); + BRepAdaptor_Curve aCurveA (anEdgeA); + + A = aCurveA.Value (0.1); + B = aCurveA.Value (0.9); + C.SetX (B.X() + 5.0); + C.SetY (B.Y() + 5.0); + C.SetZ (B.Z() + 5.0); + } + else if (aShapeA.ShapeType() == TopAbs_VERTEX) + { + if (aShapeB.ShapeType() == TopAbs_EDGE) + { + TopoDS_Edge anEdgeB = TopoDS::Edge (aShapeB); + BRepAdaptor_Curve aCurveB (anEdgeB); + + A = aCurveB.Value (0.1); + B = aCurveB.Value (0.9); + C.SetX (B.X() + 5.0); + C.SetY (B.Y() + 5.0); + C.SetZ (B.Z() + 5.0); + } + else if (aShapeB.ShapeType() == TopAbs_FACE) + { + TopoDS_Face aFaceB = TopoDS::Face (aShapeB); + TopExp_Explorer aFaceExp (aFaceB, TopAbs_EDGE); + TopoDS_Edge anEdgeFromB = TopoDS::Edge (aFaceExp.Current()); + BRepAdaptor_Curve aCurveB (anEdgeFromB); + A = aCurveB.Value (0.1); + B = aCurveB.Value (0.5); + C = aCurveB.Value (0.9); + } + else + { + A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA)); + B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB)); + C.SetX (B.X() + 5.0); + C.SetY (B.Y() + 5.0); + C.SetZ (B.Z() + 5.0); + } + } + else + { + TopoDS_Face aFaceA = TopoDS::Face (aShapeA); + TopExp_Explorer aFaceExp (aFaceA, TopAbs_EDGE); + TopoDS_Edge anEdgeFromA = TopoDS::Edge (aFaceExp.Current()); + BRepAdaptor_Curve aCurveA (anEdgeFromA); + A = aCurveA.Value (0.1); + B = aCurveA.Value (0.5); + C = aCurveA.Value (0.9); + } + + GC_MakePlane aMkPlane (A ,B ,C); + aRelation = new AIS_IdenticRelation (aShapeA, aShapeB, aMkPlane.Value()); + break; } - else if (aSecondShape.ShapeType() == TopAbs_VERTEX) + case AIS_KOR_OFFSET: { - TopoDS_Vertex VertexB = TopoDS::Vertex (aSecondShape); - BRepExtrema_ExtPF aDeltaVertexFace (VertexB, FaceA); + if (aShapes.Extent() != 2) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } - gp_Pnt B = BRep_Tool::Pnt (VertexB); + const TopoDS_Shape& aShape1 = aShapes.First(); + const TopoDS_Shape& aShape2 = aShapes.Last(); + if (!(aShape1.ShapeType() == TopAbs_FACE + && aShape2.ShapeType() == TopAbs_FACE)) + { + std::cerr << "Syntax error: selected shapes are not faces.\n"; + return 1; + } - TopExp_Explorer aFaceExp (FaceA, TopAbs_EDGE); - TopoDS_Edge anEdgeFromA = TopoDS::Edge (aFaceExp.Current()); - TopoDS_Vertex aVertex1, aVertex2; - TopExp::Vertices(anEdgeFromA, aVertex1, aVertex2); - gp_Pnt A=BRep_Tool::Pnt(aVertex1); + TopoDS_Face aFace1 = TopoDS::Face (aShape1); + TopoDS_Face aFace2 = TopoDS::Face (aShape2); -#ifdef OCCT_DEBUG - gp_Pnt C = BRep_Tool::Pnt(aVertex2); (void)C; -#endif + BRepExtrema_ExtFF aDelta (aFace1, aFace2); + if (!aDelta.IsParallel()) + { + std::cerr << "Syntax error: the faces are not parallel.\n"; + return 1; + } - gp_Pnt aProjB = aDeltaVertexFace.Point(1); - BRepBuilderAPI_MakeVertex aVertexMaker (aProjB); - TopoDS_Vertex aVertexBProj = aVertexMaker.Vertex(); - gce_MakePln aMakePlane (A, B, aProjB); - gp_Pln aPlane= aMakePlane.Value(); + Standard_Real aDist = Round (sqrt (aDelta.SquareDistance (1)) * 10.0) / 10.0; + TCollection_ExtendedString aMessage (TCollection_ExtendedString ("offset=") + TCollection_ExtendedString (aDist)); - TheAISContext()->CloseLocalContext(aCurrentIndex); + aRelation = new AIS_OffsetDimension (aFace1, aFace2, aDist, aMessage); - Handle(AIS_LengthDimension) aLenghtDim =new AIS_LengthDimension (VertexB, aVertexBProj, aPlane); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); + break; } - // the second shape is face. - else - { - TopoDS_Face FaceB = TopoDS::Face (aSecondShape); - BRepExtrema_ExtFF aDeltaFaceFace (FaceA, FaceB); - if (!aDeltaFaceFace.IsParallel()) + case AIS_KOR_PARALLEL: + { + if (aShapes.Extent() != 2) { - di << argv[0] << " error: the faces are not parallel. \n"; + std::cerr << "Error: wrong number of selected shapes.\n"; return 1; } - TheAISContext()->CloseLocalContext (aCurrentIndex); + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (aShapeA.ShapeType() == TopAbs_EDGE) + { + TopoDS_Edge anEdgeA = TopoDS::Edge (aShapeA); + TopoDS_Edge anEdgeB = TopoDS::Edge (aShapeB); + BRepExtrema_ExtCC aDeltaEdge (anEdgeA, anEdgeB); - Handle(AIS_LengthDimension) aLenghtDim = new AIS_LengthDimension (FaceA,FaceB); - TheAISContext()->Display (aLenghtDim); - GetMapOfAIS().Bind (aLenghtDim, argv[1]); - } - } + if (!aDeltaEdge.IsParallel()) + { + std::cerr << "Error: the edges are not parallel.\n"; + return 1; + } - return 0; -} + BRepAdaptor_Curve aCurveA (anEdgeA); + BRepAdaptor_Curve aCurveB (anEdgeB); + gp_Pnt A = aCurveA.Value (0.1); + gp_Pnt B = aCurveA.Value (0.9); + gp_Pnt C = aCurveB.Value (0.5); -//============================================================================== -//function : VRadiusDim -//purpose : Display the radius dimension of a face or an edge. -//Draw arg : vradiusdim Name -//============================================================================== -static int VRadiusDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer aCurrentIndex; - TopoDS_Edge anEdge; - // Verification - if (argc != 2) - { - di << argv[0] << " error: wrong number of parameters.\n"; - return 1; - } + GC_MakePlane aMkPlane (A, B, C); - // Close all local contexts - TheAISContext()->CloseAllContexts(); + aRelation = new AIS_ParallelRelation (anEdgeA, anEdgeB, aMkPlane.Value()); + } + else + { + TopoDS_Face aFaceA = TopoDS::Face (aShapeA); + TopoDS_Face aFaceB = TopoDS::Face (aShapeB); - // Open local context and get its index for recovery. - TheAISContext()->OpenLocalContext(); - aCurrentIndex = TheAISContext()->IndexOfCurrentLocal(); + BRepExtrema_ExtFF aDeltaFace (aFaceA, aFaceB); + if (!aDeltaFace.IsParallel()) + { + std::cerr << "Error: the faces are not parallel.\n"; + return 1; + } - // Current selection modes - faces and edges - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2)); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4)); - di << " Select a circled edge or face.\n"; + TopExp_Explorer aFaceExpA (aFaceA, TopAbs_EDGE); + TopExp_Explorer aFaceExpB (aFaceB, TopAbs_EDGE); - // Loop that will be handle picking. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop (argcc, argvv)) { } - // end of the loop + TopoDS_Edge anEdgeA = TopoDS::Edge (aFaceExpA.Current()); + TopoDS_Edge anEdgeB = TopoDS::Edge (aFaceExpB.Current()); - TopoDS_Shape aShape; + BRepAdaptor_Curve aCurveA (anEdgeA); + BRepAdaptor_Curve aCurveB (anEdgeB); + gp_Pnt A = aCurveA.Value (0.1); + gp_Pnt B = aCurveA.Value (0.9); + gp_Pnt C = aCurveB.Value (0.5); - for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ) - { - aShape = TheAISContext()->SelectedShape(); - } + GC_MakePlane aMkPlane (A, B, C); - if (aShape.IsNull()) - { - di << argv[0] << ": no shape is selected.\n"; - return 1; - } + aRelation = new AIS_ParallelRelation (aFaceA, aFaceB, aMkPlane.Value()); + } + break; + } - if (aShape.ShapeType() != TopAbs_EDGE && aShape.ShapeType() != TopAbs_FACE) - { - di << argv[0] << " error: the selection of a face or an edge was expected.\n"; - return 1; - } + case AIS_KOR_PERPENDICULAR: + { + if (aShapes.Extent() != 2) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } - if (aShape.ShapeType() == TopAbs_EDGE) - { - anEdge = TopoDS::Edge (aShape); - } - else // Face - { - // Recover an edge of the face. - TopoDS_Face aFace = TopoDS::Face (aShape); + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); - TopExp_Explorer aFaceExp (aFace,TopAbs_EDGE); - anEdge = TopoDS::Edge (aFaceExp.Current()); - } + if (aShapeA.ShapeType() == TopAbs_EDGE) + { + TopoDS_Edge anEdgeA = TopoDS::Edge (aShapeA); + TopoDS_Edge anEdgeB = TopoDS::Edge (aShapeB); - // Compute the radius - BRepAdaptor_Curve aCurve (anEdge); - if (aCurve.GetType() != GeomAbs_Circle) - { - di << argv[0] << " error: the edge is not a circular one.\n"; - return 1; - } - // Close the context - TheAISContext()->CloseLocalContext (aCurrentIndex); + BRepAdaptor_Curve aCurveA (anEdgeA); + BRepAdaptor_Curve aCurveB (anEdgeB); - // Construct radius dimension - Handle (AIS_RadiusDimension) aRadDim= new AIS_RadiusDimension (aShape); - VDisplayAISObject (argv[1], aRadDim); + gp_Pnt A = aCurveA.Value (0.1); + gp_Pnt B = aCurveA.Value (0.9); + gp_Pnt C = aCurveB.Value (0.5); - return 0; -} + GC_MakePlane aMkPlane (A, B, C); + aRelation = new AIS_PerpendicularRelation (anEdgeA, anEdgeB, aMkPlane.Value()); + } + else + { + TopoDS_Face aFaceA = TopoDS::Face (aShapeA); + TopoDS_Face aFaceB = TopoDS::Face (aShapeB); + TopExp_Explorer aFaceExpA (aFaceA, TopAbs_EDGE); + TopExp_Explorer aFaceExpB (aFaceB, TopAbs_EDGE); -//============================================================================== -//function : VOffsetDim -//purpose : Display the offset dimension -//Draw arg : voffsetdim Name -//============================================================================== -static int VOffsetDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - Standard_Real theDist; - - // Verification - if (argc!=2) {di<<" voffsetdim error\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Faces. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select a face.\n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - di<<" Select a face.\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - - // Shape A et B est une face - if (ShapeA.ShapeType()==TopAbs_FACE && ShapeB.ShapeType()==TopAbs_FACE ) { - - TopoDS_Face FaceA=TopoDS::Face(ShapeA); - TopoDS_Face FaceB=TopoDS::Face(ShapeB); - - BRepExtrema_ExtFF myDeltaFaceFace (FaceA ,FaceB ); - // On verifie que les deux faces sont bien parelles. - if (!myDeltaFaceFace.IsParallel() ) {di<<"vdistdim error: the faces are not parallel. \n";return 1; } - - // On saisit la distance et on l'arrondit! - theDist=Round (sqrt (myDeltaFaceFace.SquareDistance(1))*10. )/10.; - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction du texte. - TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("offset=")+TCollection_ExtendedString(theDist ) ); - - // on construit l'AIS_OffsetDimension - Handle(AIS_OffsetDimension) myOffsetDim=new AIS_OffsetDimension (FaceA,FaceB,theDist,TheMessage_Str ); - TheAISContext()->Display(myOffsetDim ); - GetMapOfAIS().Bind (myOffsetDim ,argv[1]); - - - - } - - else { - di<<" voffsetdim error: the selection of a face was expected.\n";return 1; - } - - return 0; - -} + TopoDS_Edge anEdgeA = TopoDS::Edge (aFaceExpA.Current()); + TopoDS_Edge anEdgeB = TopoDS::Edge (aFaceExpB.Current()); + BRepAdaptor_Curve aCurveA (anEdgeA); + BRepAdaptor_Curve aCurveB (anEdgeB); + gp_Pnt A = aCurveA.Value (0.1); + gp_Pnt B = aCurveA.Value (0.9); + gp_Pnt C = aCurveB.Value (0.5); + GC_MakePlane aMkPlane (A, B, C); -//============================================================================== -//function : VParallel -//purpose : Display the parallel relation -//Draw arg : vparallel Name -//============================================================================== -static int VParallelBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vparallel error\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Edges. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select an edge or a face \n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - // SahpeA est un edge. - // =================== - if (ShapeA.ShapeType()==TopAbs_EDGE ) { - - // desactivation du mode face - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - // recuperation des edges. - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB); - BRepExtrema_ExtCC myDeltaEdge (EdgeA ,EdgeB ); - // on verifie qu'ils ne sont pas paralleles. - if (!myDeltaEdge.IsParallel() ) {di<<"vparallel error: non parallel edges.\n";return 1; } - - - // On recupere les vertexes extremites des edge A et B. - BRepAdaptor_Curve theCurveA(EdgeA); - BRepAdaptor_Curve theCurveB(EdgeB); - // On recupere 3 points A,B,C des curves. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.9); - gp_Pnt C=theCurveB.Value(0.5); - - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_ParallelRelation - Handle(AIS_ParallelRelation) myParaRelation= new AIS_ParallelRelation(EdgeA ,EdgeB ,theGeomPlane ); - TheAISContext()->Display(myParaRelation ); - GetMapOfAIS().Bind (myParaRelation ,argv[1]); - - - } - - // Shape A est une face - // ==================== - else { - - // desactivation du mode edge - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); + aRelation = new AIS_PerpendicularRelation (aFaceA, aFaceB); + } + + break; } - - TopoDS_Face FaceA=TopoDS::Face(ShapeA); - TopoDS_Face FaceB=TopoDS::Face(ShapeB); - - BRepExtrema_ExtFF myDeltaFaceFace (FaceA ,FaceB ); - // On verifie que les deux faces sont bien parelles. - if (!myDeltaFaceFace.IsParallel() ) {di<<"vdistdim error: the faces are not parallel. \n";return 1; } - - // recuperation des edges des faces. - TopExp_Explorer FaceExpA(FaceA,TopAbs_EDGE); - TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE); - - TopoDS_Edge EdgeA=TopoDS::Edge(FaceExpA.Current() ); - TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() ); - - // On recupere les vertexes extremites des edge A et B. - BRepAdaptor_Curve theCurveA(EdgeA); - BRepAdaptor_Curve theCurveB(EdgeB); - // On recupere 3 points A,B,C des curves. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.9); - gp_Pnt C=theCurveB.Value(0.5); - - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_ParallelRelation - Handle(AIS_ParallelRelation) myParaRelation= new AIS_ParallelRelation(FaceA ,FaceB ,theGeomPlane ); - TheAISContext()->Display(myParaRelation ); - GetMapOfAIS().Bind (myParaRelation ,argv[1]); - - - - } - - - return 0; - -} + case AIS_KOR_TANGENT: + { + if (aShapes.Extent() != 2) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } + const TopoDS_Shape& aShapeA = aShapes.First(); + const TopoDS_Shape& aShapeB = aShapes.Last(); + if (aShapeA.ShapeType() == TopAbs_EDGE) + { + TopoDS_Edge anEdgeA = TopoDS::Edge (aShapeA); + TopoDS_Edge anEdgeB = TopoDS::Edge (aShapeB); -//============================================================================== -//function : VPerpendicularRelation -//purpose : Display the Perpendicular Relation -//Draw arg : vperpendicular Name -//============================================================================== -static int VPerpendicularBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vortho error\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Edges. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select an edge or a face \n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - // ShapeA est un edge. - // =================== - if (ShapeA.ShapeType()==TopAbs_EDGE ) { - - // desactivation du mode face - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - // recuperation des edges. - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB); - - // On recupere les curves - BRepAdaptor_Curve theCurveA(EdgeA); - BRepAdaptor_Curve theCurveB(EdgeB); - // on verifie si les edges sont orthogonaux. - //gp_Lin theLineA=theCurveA.Line(); - //gp_Lin theLineB=theCurveB.Line(); - //if (abs(theLineA.Angle(theLineB) ) != M_PI/2 ) {cout<<"vperpendicular error: Edges are not othogonals."<CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_ParallelRelation - Handle(AIS_PerpendicularRelation) myOrthoRelation= new AIS_PerpendicularRelation (EdgeA ,EdgeB ,theGeomPlane ); - TheAISContext()->Display(myOrthoRelation ); - GetMapOfAIS().Bind (myOrthoRelation ,argv[1]); - - - } - - // Shape A est une face - // ==================== - else { - - // desactivation du mode edge - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - // pas de verification d'orthogonalite. - TopoDS_Face FaceA=TopoDS::Face(ShapeA); - TopoDS_Face FaceB=TopoDS::Face(ShapeB); - - // recuperation des edges des faces. - TopExp_Explorer FaceExpA(FaceA,TopAbs_EDGE); - TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE); - - TopoDS_Edge EdgeA=TopoDS::Edge(FaceExpA.Current() ); - TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() ); - - // On recupere les vertexes extremites des edge A et B. - BRepAdaptor_Curve theCurveA(EdgeA); - BRepAdaptor_Curve theCurveB(EdgeB); - // On recupere 3 points A,B,C des curves. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.9); - gp_Pnt C=theCurveB.Value(0.5); - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_PerpendicularRelation - Handle(AIS_PerpendicularRelation) myOrthoRelation= new AIS_PerpendicularRelation(FaceA ,FaceB ); - TheAISContext()->Display(myOrthoRelation ); - GetMapOfAIS().Bind (myOrthoRelation ,argv[1]); - - - - } - - - return 0; - -} + gp_Pnt A = aCurveA.Value (0.1); + gp_Pnt B = aCurveA.Value (0.9); + gp_Pnt C = aCurveB.Value (0.5); + GC_MakePlane aMkPlane (A,B,C); -//============================================================================== -//function : VTangentRelation -//purpose : Display the tangent Relation -//Draw arg : vtangent Name -//============================================================================== -static int VTangentBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vtangent error\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections Edges. - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select two coplanar edges(First the circular edge then the tangent edge) or two faces \n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - - // ShapeA est un edge. - // =================== - if (ShapeA.ShapeType()==TopAbs_EDGE ) { - - // desactivation du mode face - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - // recuperation des edges. - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB); - - // On recupere les curves - BRepAdaptor_Curve theCurveA(EdgeA); - BRepAdaptor_Curve theCurveB(EdgeB); - - // On recupere 3 points A,B,C des curves. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.9); - gp_Pnt C=theCurveB.Value(0.5); - - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_TangentRelation - Handle(AIS_TangentRelation) myTanRelation= new AIS_TangentRelation (EdgeA ,EdgeB ,theGeomPlane ); - TheAISContext()->Display(myTanRelation ); - GetMapOfAIS().Bind (myTanRelation ,argv[1]); - - - } - - // Shape A est une face - // ==================== - else { - - // desactivation du mode edge - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle + aRelation = new AIS_TangentRelation (anEdgeA, anEdgeB, aMkPlane.Value()); + } + else + { + TopoDS_Face aFaceA = TopoDS::Face (aShapeA); + TopoDS_Face aFaceB = TopoDS::Face (aShapeB); + + TopExp_Explorer aFaceExpA (aFaceA, TopAbs_EDGE); + TopExp_Explorer aFaceExpB (aFaceB, TopAbs_EDGE); - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); + TopoDS_Edge anEdgeA = TopoDS::Edge (aFaceExpA.Current()); + TopoDS_Edge anEdgeB = TopoDS::Edge (aFaceExpB.Current()); + + BRepAdaptor_Curve aCurveA (anEdgeA); + BRepAdaptor_Curve aCurveB (anEdgeB); + + gp_Pnt A = aCurveA.Value (0.1); + gp_Pnt B = aCurveA.Value (0.9); + gp_Pnt C = aCurveB.Value (0.5); + + GC_MakePlane aMkPlane (A,B,C); + + aRelation = new AIS_TangentRelation (aFaceA, aFaceB, aMkPlane.Value()); + } + break; } - - TopoDS_Face FaceA=TopoDS::Face(ShapeA); - TopoDS_Face FaceB=TopoDS::Face(ShapeB); - - // recuperation des edges des faces. - TopExp_Explorer FaceExpA(FaceA,TopAbs_EDGE); - TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE); - - TopoDS_Edge EdgeA=TopoDS::Edge(FaceExpA.Current() ); - TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() ); - - // On recupere les vertexes extremites des edge A et B. - BRepAdaptor_Curve theCurveA(EdgeA); - BRepAdaptor_Curve theCurveB(EdgeB); - // On recupere 3 points A,B,C des curves. - gp_Pnt A=theCurveA.Value(0.1); - gp_Pnt B=theCurveA.Value(0.9); - gp_Pnt C=theCurveB.Value(0.5); - - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_PerpendicularRelation - Handle(AIS_TangentRelation) myTanRelation= new AIS_TangentRelation(FaceA ,FaceB,theGeomPlane ); - TheAISContext()->Display(myTanRelation ); - GetMapOfAIS().Bind (myTanRelation ,argv[1]); - - - - } - - - return 0; - -} -//============================================================================== -//function : VSymetricalRelation -//purpose : Display the Symetrical Relation -//Draw arg : vsymetric Name -//============================================================================== -static int VSymmetricBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Integer myCurrentIndex; - - // Verification - if (argc!=2) {di<<" vSymmetric error\n";return 1;} - - // Fermeture des contextes locaux - TheAISContext()->CloseAllContexts(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAISContext()->OpenLocalContext(); - myCurrentIndex=TheAISContext()->IndexOfCurrentLocal(); - - // On active les modes de selections - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select an edge:the axis of symetry \n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop( argcc, argvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeA; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeA = TheAISContext()->SelectedShape(); - } - // recuperation des edges. - TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA); - - // On active les modes de selections - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) ); - TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) ); - di<<" Select two edges or two vertices. \n"; - - // Boucle d'attente waitpick. - Standard_Integer argcc2 = 5; -// const char *buff2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv2 = (const char **) buff; - while (ViewerMainLoop( argcc2, argvv2) ) { } - // fin de la boucle - - TopoDS_Shape ShapeB; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeB = TheAISContext()->SelectedShape(); - } - - - - - - // ShapeB est un edge. - // =================== - if (ShapeB.ShapeType()==TopAbs_EDGE ) { - - // desactivation du mode vertex - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(1) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeC; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeC = TheAISContext()->SelectedShape(); + case AIS_KOR_SYMMETRIC: + { + if (aShapes.Extent() != 3) + { + std::cerr << "Error: Wrong number of selected shapes.\n"; + return 1; + } + + TopoDS_Shape aSelectedShapes[3]; + Standard_Integer anIdx = 0; + TopTools_ListOfShape::Iterator anIter (aShapes); + for (; anIter.More(); anIter.Next(), ++anIdx) + { + aSelectedShapes[anIdx] = anIter.Value(); + } + + TopoDS_Edge anEdgeA = TopoDS::Edge (aSelectedShapes[0]); + if (aSelectedShapes[1].ShapeType() == TopAbs_EDGE) + { + // 1 - edge, 2 - edge, 3 - edge. + TopoDS_Edge anEdgeB = TopoDS::Edge (aSelectedShapes[1]); + TopoDS_Edge anEdgeC = TopoDS::Edge (aSelectedShapes[2]); + + BRepExtrema_ExtCC aDeltaEdgeAB (anEdgeA, anEdgeB); + BRepExtrema_ExtCC aDeltaEdgeAC (anEdgeA, anEdgeC); + + if (!aDeltaEdgeAB.IsParallel()) + { + std::cerr << "Syntax error: the edges are not parallel.\n"; + return 1; + } + if (!aDeltaEdgeAC.IsParallel()) + { + std::cerr << "Syntax error: the edges are not parallel.\n"; + return 1; + } + + TopoDS_Vertex Va, Vb, Vc, Vd; + TopExp::Vertices (anEdgeB, Va, Vb); + TopExp::Vertices (anEdgeC, Vc, Vd); + gp_Pnt A = BRep_Tool::Pnt (Va); + gp_Pnt B = BRep_Tool::Pnt (Vc); + gp_Pnt C = Get3DPointAtMousePosition(); + + GC_MakePlane aMkPlane (A, B, C); + + aRelation = new AIS_SymmetricRelation (anEdgeA, anEdgeB, anEdgeC, aMkPlane.Value()); + } + else + { + // 1 - edge, 2 - vertex, 3 - vertex + TopoDS_Vertex aVertexB = TopoDS::Vertex (aSelectedShapes[1]); + TopoDS_Vertex aVertexC = TopoDS::Vertex (aSelectedShapes[2]); + + gp_Pnt B = BRep_Tool::Pnt (aVertexB); + gp_Pnt C = BRep_Tool::Pnt (aVertexC); + + TopoDS_Vertex Va, Vb; + TopExp::Vertices (anEdgeA, Va, Vb); + gp_Pnt A = BRep_Tool::Pnt (Va); + + GC_MakePlane aMkPlane(A, B, C); + aRelation = new AIS_SymmetricRelation (anEdgeA, aVertexB, aVertexC, aMkPlane.Value()); + } + + break; } - - // recuperation des edges. - TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB); - TopoDS_Edge EdgeC=TopoDS::Edge(ShapeC); - // on verifie que les edges sont paralleles - BRepExtrema_ExtCC myDeltaEdgeAB (EdgeA ,EdgeB ); - BRepExtrema_ExtCC myDeltaEdgeAC (EdgeA ,EdgeC ); - // on verifie qu'ils sont paralleles. - if (!myDeltaEdgeAB.IsParallel() ) {di<<"vsymetric error: non parallel edges.\n";return 1; } - if (!myDeltaEdgeAC.IsParallel() ) {di<<"vsymetric error: non parallel edges.\n";return 1; } - // on recupere les vertexs - TopoDS_Vertex Va,Vb,Vc,Vd; - TopExp::Vertices(EdgeB,Va,Vb ); - TopExp::Vertices(EdgeC,Vc,Vd ); - gp_Pnt A=BRep_Tool::Pnt(Va); - gp_Pnt B=BRep_Tool::Pnt(Vc); - gp_Pnt C = Get3DPointAtMousePosition(); - - // gp_Pnt C=BRep_Tool::Pnt(Vc); - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_SymmetricRelation - Handle(AIS_SymmetricRelation) mySymRelation= new AIS_SymmetricRelation (EdgeA ,EdgeB ,EdgeC, theGeomPlane ); - TheAISContext()->Display(mySymRelation ); - GetMapOfAIS().Bind (mySymRelation ,argv[1]); - - - } - - // Shape B est un vertex - // ===================== - else { - - // desactivation du mode edge - TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) ); - di<<" Select a second edge\n"; - // Boucle d'attente waitpick. - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - while (ViewerMainLoop( argccc, argvvv) ) { } - // fin de la boucle - - TopoDS_Shape ShapeC; - for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - ShapeC = TheAISContext()->SelectedShape(); + + case AIS_KOR_NONE: + { + std::cerr << "Error: Unknown type of relation!\n"; + return 1; } - - // recuperation des Vertex - TopoDS_Vertex VertexB=TopoDS::Vertex(ShapeB); - TopoDS_Vertex VertexC=TopoDS::Vertex(ShapeC); - // transfo en gp_Pnt - gp_Pnt B=BRep_Tool::Pnt(VertexB); - gp_Pnt C=BRep_Tool::Pnt(VertexC); - - // on recupere les vertexes de l'axe de sym - TopoDS_Vertex Va,Vb; - TopExp::Vertices(EdgeA,Va,Vb ); - gp_Pnt A=BRep_Tool::Pnt(Va); - // Construction du Geom_Plane - GC_MakePlane MkPlane(A,B,C); - Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); - // Fermeture du contexte local. - TheAISContext()->CloseLocalContext(myCurrentIndex); - // Construction de l'AIS_SymmetricRelation - Handle(AIS_SymmetricRelation) mySymRelation= new AIS_SymmetricRelation (EdgeA ,VertexB ,VertexC, theGeomPlane ); - TheAISContext()->Display(mySymRelation ); - GetMapOfAIS().Bind (mySymRelation ,argv[1]); - - - } - - + + VDisplayAISObject (aName, aRelation); return 0; - } //======================================================================= @@ -2804,12 +1707,6 @@ static int VMoveDim (Draw_Interpretor& theDi, Standard_Integer theArgNum, const } else // Pick dimension or relation { - // Close all local contexts - TheAISContext()->CloseAllContexts(); - - // Open local context and get its index for recovery. - TheAISContext()->OpenLocalContext(); - // Loop that will be handle picking. Standard_Integer anArgNum = 5; const char *aBuffer[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; @@ -2931,7 +1828,9 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands) const char *group = "AISRelations"; theCommands.Add("vdimension", - "vdimension name {-angle|-length|-radius|-diameter} -shapes shape1 [shape2 [shape3]]\n" + "vdimension name {-angle|-length|-radius|-diameter}" + "[-shapes shape1 [shape2 [shape3]]\n" + "[-selected]\n" "[-text 3d|2d wf|sh|wireframe|shading IntegerSize]\n" "[-font FontName]\n" "[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]\n" @@ -2950,6 +1849,21 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands) " -See also: vdimparam, vmovedim.\n", __FILE__,VDimBuilder,group); + theCommands.Add ("vrelation", + "vrelation name {-concentric|-equaldistance|-equalradius|-fix|-identic|-offset|-parallel|-perpendicular|-tangent|-symmetric}" + "\n\t\t: concentric - 2 circled edges." + "\n\t\t: equaldistance - 4 vertex/edges." + "\n\t\t: equalradius - 1 or 2 circled edges." + "\n\t\t: fix - 1 edge." + "\n\t\t: identic - 2 faces, edges or vertices." + "\n\t\t: offset - 2 faces." + "\n\t\t: parallel - 2 faces or 2 edges." + "\n\t\t: perpendicular - 2 faces or 2 edges." + "\n\t\t: tangent - two coplanar edges (first the circular edge then the tangent edge) or two faces." + "\n\t\t: symmetric - 3 edges or 1 edge and 2 vertices." + "-Builds specific relation from selected objects.", + __FILE__, VRelationBuilder, group); + theCommands.Add("vdimparam", "vdimparam name" "[-text 3d|2d wf|sh|wireframe|shading IntegerSize]\n" @@ -2969,68 +1883,11 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands) " -See also: vmovedim, vdimension.\n", __FILE__,VDimParam,group); - theCommands.Add("vangledim", - "vangledim Name:Selection in the viewer only ", - __FILE__,VAngleDimBuilder,group); - theCommands.Add("vangleparam", "vangleparam name" "[-type interior|exterior]\n" "[-showarrow first|second|both|none]\n", __FILE__,VAngleParam,group); - - theCommands.Add("vdiameterdim", - "vdiameterdim Name : Selection in the viewer only ", - __FILE__,VDiameterDimBuilder,group); - - theCommands.Add("vconcentric", - "vconcentric Name : Selection in the viewer only ", - __FILE__,VConcentricBuilder,group); - - theCommands.Add("vequaldist", - "vequaldist Name Selection in the viewer only ", - __FILE__,VEqualDistRelation ,group); - - theCommands.Add("vequalrad", - "vequalrad Name Selection in the viewer only ", - __FILE__,VEqualRadiusRelation ,group); - - theCommands.Add("vfix", - "vfix Name Selection in the viewer only ", - __FILE__,VFixRelation ,group); - - theCommands.Add("videntity", - "videntity Name Selection in the viewer only ", - __FILE__,VIdenticRelation ,group); - - theCommands.Add("vdistdim", - "vdistdim Name Selection in the viewer only ", - __FILE__,VLenghtDimension ,group); - - theCommands.Add("vradiusdim", - "vradiusdim Name Selection in the viewer only ", - __FILE__,VRadiusDimBuilder ,group); - - theCommands.Add("voffsetdim", - "voffsetdim Name Selection in the viewer only ", - __FILE__,VOffsetDimBuilder ,group); - - theCommands.Add("vparallel", - "vparallel Name Selection in the viewer only ", - __FILE__,VParallelBuilder ,group); - - theCommands.Add("vortho", - "vortho Name Selection in the viewer only ", - __FILE__,VPerpendicularBuilder ,group); - - theCommands.Add("vtangent", - "vtangent Name Selection in the viewer only ", - __FILE__,VTangentBuilder ,group); - - - theCommands.Add("vsymetric", - "vsymetric Name Selection in the viewer only ", - __FILE__,VSymmetricBuilder ,group); theCommands.Add("vmovedim", "vmovedim : vmovedim [name] [x y z]" diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index c4b213dcac..717221728b 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -3411,11 +3411,10 @@ static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** arg return 1; } + Standard_DISABLE_DEPRECATION_WARNINGS try { - Standard_DISABLE_DEPRECATION_WARNINGS if (!V3dView->Export (argv[1], anExpFormat)) - Standard_ENABLE_DEPRECATION_WARNINGS { di << "Error: export of image to " << aFormatStr << " failed!\n"; } @@ -3425,6 +3424,7 @@ static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** arg di << "Error: export of image to " << aFormatStr << " failed"; di << " (exception: " << Standard_Failure::Caught()->GetMessageString() << ")"; } + Standard_ENABLE_DEPRECATION_WARNINGS return 0; } @@ -6984,7 +6984,7 @@ static Standard_Integer VPurgeDisplay (Draw_Interpretor& di, di << "use 'vinit' command before " << argv[0] << "\n"; return 1; } - aContext->CloseAllContexts(Standard_False); + di << aContext->PurgeDisplay() << "\n"; return 0; } diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index c7e9818cd2..f657be4f04 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -512,8 +512,12 @@ static Standard_Integer mdisplay di << "The context is null\n"; else { - if( aContext->HasOpenedContext() ) + Standard_DISABLE_DEPRECATION_WARNINGS + if (aContext->HasOpenedContext()) + { aContext->CloseLocalContext(); + } + Standard_ENABLE_DEPRECATION_WARNINGS aContext->Display( aMesh ); } @@ -538,8 +542,12 @@ static Standard_Integer merase di << "The context is null\n"; else { - if( aContext->HasOpenedContext() ) + Standard_DISABLE_DEPRECATION_WARNINGS + if (aContext->HasOpenedContext()) + { aContext->CloseLocalContext(); + } + Standard_ENABLE_DEPRECATION_WARNINGS aContext->Erase( aMesh ); } diff --git a/tests/v3d/dimensions/begin b/tests/v3d/dimensions/begin new file mode 100644 index 0000000000..374295ad12 --- /dev/null +++ b/tests/v3d/dimensions/begin @@ -0,0 +1,2 @@ +set subgroup "dimensions" +vinit View1 diff --git a/tests/v3d/dimensions/concentric b/tests/v3d/dimensions/concentric new file mode 100644 index 0000000000..a762d25b77 --- /dev/null +++ b/tests/v3d/dimensions/concentric @@ -0,0 +1,21 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select two circled edges" +puts "====================================================================" + +vclear +vinit + +pcylinder c 15 30 +vdisplay c +vfit + +vselmode c 2 1 +vselect 205 174 + +set shift 1 +vselect 205 377 $shift + +vrelation r -concentric + +vdump $imagedir/${casename}.png diff --git a/tests/v3d/dimensions/equaldistance b/tests/v3d/dimensions/equaldistance new file mode 100644 index 0000000000..d17a3902cb --- /dev/null +++ b/tests/v3d/dimensions/equaldistance @@ -0,0 +1,38 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 4 edges or vertices" +puts "====================================================================" + +vclear +vinit + +box b 10 20 30 +vdisplay b +vfit +set shift 1 + +# Create an equaldistance relation from 4 edges. +vselmode b 2 1 +vselect 123 112 +vselect 280 23 $shift +vselect 123 382 $shift +vselect 280 293 $shift + +vrelation r4edges -equaldistance +vzoom 0.5 + +vdump $imagedir/${casename}_edges.png + +# Create an equaldistance relation from 4 vertices. +vremove r4edges +vfit + +vselect 0 0 +vselmode b 2 0 +vselmode b 1 1 + +vselect 75 0 335 140 +vrelation r4vertices -equaldistance +vzoom 0.5 + +vdump $imagedir/${casename}_vertices.png diff --git a/tests/v3d/dimensions/equalradius b/tests/v3d/dimensions/equalradius new file mode 100644 index 0000000000..678b08fdce --- /dev/null +++ b/tests/v3d/dimensions/equalradius @@ -0,0 +1,31 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 1 or 2 circled edges" +puts "====================================================================" + +vclear +vinit + +pcylinder c 15 30 +vdisplay c +vfit + +# Create relation from 1 selected circled edge. +vselmode c 2 1 +vselect 205 174 + +vrelation r1 -equalradius + +vdump $imagedir/${casename}_1.png + +# Create relation from 2 selected circled edges. +vremove r1 + +vselect 205 377 + +set shift 1 +vselect 205 174 $shift + +vrelation r2 -equalradius + +vdump $imagedir/${casename}_2.png \ No newline at end of file diff --git a/tests/v3d/dimensions/fix b/tests/v3d/dimensions/fix new file mode 100644 index 0000000000..3360bde1e8 --- /dev/null +++ b/tests/v3d/dimensions/fix @@ -0,0 +1,18 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 1 edge" +puts "====================================================================" + +vclear +vinit + +box b 10 20 30 +vdisplay b +vfit + +vselmode b 2 1 +vselect 10 10 100 380 + +vrelation r -fix + +vdump $imagedir/${casename}.png diff --git a/tests/v3d/dimensions/identic b/tests/v3d/dimensions/identic new file mode 100644 index 0000000000..09b7fe314a --- /dev/null +++ b/tests/v3d/dimensions/identic @@ -0,0 +1,37 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 2 edges or vertices" +puts "====================================================================" + +vclear +vinit + +box b 10 20 30 +vdisplay b +vfit + +set shift 1 + +# Create an identic relation from 2 edges. +#vremove rfaces +vselmode b 4 0 +vselmode b 2 1 + +vselect 87 170 +vselect 165 170 $shift + +vrelation redgess -identic + +vdump $imagedir/${casename}_edges.png + +# Create an identic relation from 2 vertices. +vremove redges +vselmode b 2 0 +vselmode b 1 1 + +vselect 160 130 170 140 +vselect 240 0 250 10 $shift + +vrelation rvertices -identic + +vdump $imagedir/${casename}_vertices.png diff --git a/tests/v3d/dimensions/offset b/tests/v3d/dimensions/offset new file mode 100644 index 0000000000..f077afea54 --- /dev/null +++ b/tests/v3d/dimensions/offset @@ -0,0 +1,22 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 2 faces" +puts "====================================================================" + +vclear +vinit + +box b -5 -10 -15 10 20 30 +vdisplay b +vfit + +set shift 1 + +vselmode b 4 1 +vselect 100 200 +vlocation b -rotate 0 0 0 0 0 1 180 +vselect 100 200 $shift + +vrelation r -offset + +vdump $imagedir/${casename}.png diff --git a/tests/v3d/dimensions/parallel b/tests/v3d/dimensions/parallel new file mode 100644 index 0000000000..8f149afda5 --- /dev/null +++ b/tests/v3d/dimensions/parallel @@ -0,0 +1,23 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 2 edges" +puts "====================================================================" + +vclear +vinit + +box b -5 -10 -15 10 20 30 +vdisplay b +vfit + +set shift 1 + +# Create a parallel relation from 2 edges. +vselmode b 2 1 +vselect 87 170 +vselect 165 170 $shift + +vrelation r -parallel +vzoom 0.5 + +vdump $imagedir/${casename}_edges.png diff --git a/tests/v3d/dimensions/perpendicular b/tests/v3d/dimensions/perpendicular new file mode 100644 index 0000000000..b894b7d1da --- /dev/null +++ b/tests/v3d/dimensions/perpendicular @@ -0,0 +1,22 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 2 edges" +puts "====================================================================" + +vclear +vinit + +box b -5 -10 -15 10 20 30 +vdisplay b +vfit + +set shift 1 + +# Create a perpendicular relation from 2 edges. +vselmode b 2 1 + +vselect 87 145 +vselect 135 119 $shift +vrelation r -perpendicular + +vdump $imagedir/${casename}_edges.png diff --git a/tests/v3d/dimensions/symmetric b/tests/v3d/dimensions/symmetric new file mode 100644 index 0000000000..72df387c36 --- /dev/null +++ b/tests/v3d/dimensions/symmetric @@ -0,0 +1,41 @@ +puts "====================================================================" +puts "OCC28162: Draw Harness - eliminate usage of deprecated Local Context" +puts "Select 3 edges or 1 edge and 2 vertices" +puts "====================================================================" + +vclear +vinit + +box b 10 20 30 +vdisplay b +vfit + +set shift 1 + +# Create a symmetric relation from 3 edges. +vselmode b 2 1 + +vselect 280 23 +vselect 123 112 $shift +vselect 123 382 $shift + +vrelation r3edges -symmetric + +vdump $imagedir/${casename}_3edges.png + +# Create a symmetric relation from edge and 2 vertices. +vremove r3edges + +vselect 0 0 +# Select an edge. +vselect 123 112 + +vselmode b 2 0 +vselmode b 1 1 + +# Select 2 vertices. +vselect 230 0 325 55 $shift + +vrelation redge2vertices -symmetric + +vdump $imagedir/${casename}_edge_2vertices.png diff --git a/tests/v3d/end b/tests/v3d/end index ec78119b1c..6aafde8dfa 100755 --- a/tests/v3d/end +++ b/tests/v3d/end @@ -1,4 +1,4 @@ -if { [info exists subgroup] && $subgroup != "motion" && $subgroup != "ivtk" } { +if { [info exists subgroup] && $subgroup != "motion" && $subgroup != "ivtk" && $subgroup != "dimensions" } { catch { vfit } } if { [info exists subgroup] && $subgroup == "raytrace" } { @@ -26,6 +26,8 @@ if { [info exists subgroup] && $subgroup == "raytrace" } { puts $catch_result } } +} elseif { [info exists subgroup] && $subgroup == "dimensions" } { + # skip these test cases. } elseif { ![info exists subgroup] || $subgroup != "mesh" } { # dump final image for common visualization tests diff --git a/tests/v3d/grids.list b/tests/v3d/grids.list index 778d7df34c..faed1c1403 100644 --- a/tests/v3d/grids.list +++ b/tests/v3d/grids.list @@ -17,3 +17,4 @@ 018 point_cloud 019 manipulator 020 anim +021 dimensions -- 2.20.1