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.
const Handle(V3d_View)& theView)
{
Standard_Integer PopupMenuNumber=0;
- GetAISContext()->InitCurrent();
- if (GetAISContext()->MoreCurrent())
+ GetAISContext()->InitSelected();
+ if (GetAISContext()->MoreSelected())
{
PopupMenuNumber=1;
}
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);
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);
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 ("\
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);
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);
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 ("\
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);
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);
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\
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
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);
TopoDS_Shape LawevolvedBox = afillet.Shape();
ais2->Set(LawevolvedBox);
myAISContext->Redisplay(ais2,Standard_False);
- myAISContext->SetCurrentObject(ais2,Standard_False);
+ myAISContext->SetSelected(anIO2,Standard_False);
Fit();
}
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);
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);
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);
ais1->Set(res1);
myAISContext->Redisplay(ais1,Standard_False);
- myAISContext->SetCurrentObject(ais1,Standard_False);
+ myAISContext->SetSelected(anIO1,Standard_False);
Fit();
Sleep(500);
ais1->Set(res2);
myAISContext->Redisplay(ais1);
- myAISContext->SetCurrentObject(ais1,Standard_False);
+ myAISContext->SetSelected(anIO1,Standard_False);
Fit();
TCollection_AsciiString Message ("\
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();
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);
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 ("\
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);
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);
ais1->Set(res1);
myAISContext->Redisplay(ais1);
- myAISContext->SetCurrentObject(ais1,Standard_False);
+ myAISContext->SetSelected(anIO1,Standard_False);
Fit();
Sleep(1000);
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);
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);
ais4->Set(res2);
myAISContext->Redisplay(ais4,Standard_False);
- myAISContext->SetCurrentObject(ais4,Standard_False);
+ myAISContext->SetSelected(anIO4,Standard_False);
Fit();
Sleep(1000);
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);
ais1->Set(res1);
myAISContext->Redisplay(ais1,Standard_False);
- myAISContext->SetCurrentObject(ais1,Standard_False);
+ myAISContext->SetSelected(anIO1,Standard_False);
Fit();
TCollection_AsciiString Message ("\
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);
TopoDS_Shape res = aform.Shape();
ais1->Set(res);
myAISContext->Redisplay(ais1,Standard_False);
- myAISContext->SetCurrentObject(ais1);
+ myAISContext->SetSelected(anIO1);
Fit();
TCollection_AsciiString Message ("\
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);
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\
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);
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);
Handle(AIS_Shape) anAISShell = new AIS_Shape(aShell);
myAISContext->SetDisplayMode(anAISShell,0);
myAISContext->Display(anAISShell,Standard_False);
- //myAISContext->SetCurrentObject(anAISShell);
+ //myAISContext->SetSelected(anAISShell);
Fit();
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;
if(OnFileImportBrep_WithInitDir (L"HoleFilling") == 1)
return;
myAISContext->DisplayedObjects(LI);
- myAISContext->SetCurrentObject(LI.First());
+ myAISContext->SetSelected(LI.First());
OnButtonFill();
return;
}
}
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);
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("");
}
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());
}
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;
}
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
myAISContext->DisplayedObjects(LI);
- myAISContext->SetCurrentObject(LI.First());
+ myAISContext->SetSelected(LI.First());
Sleep(700);
flag = 1;
OnFillwithtang();
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");
}
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");
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;
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;
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);
}
void CViewer2dDoc::OnBUTTONErase()
{
- if(myAISContext->HasOpenedContext())
- myAISContext->CloseAllContexts();
myAISContext->EraseAll();
}
void CViewer2dDoc::OnBUTTONTestFace()
{
//erase all
- if(myAISContext->HasOpenedContext())
- myAISContext->CloseAllContexts();
myAISContext->EraseAll();
CFileDialog dlg(TRUE,
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);
TCollection_AsciiString aFileName ((const wchar_t* )aFilePath);
//erase viewer
- if(myAISContext->HasOpenedContext())
- myAISContext->CloseAllContexts();
myAISContext->EraseAll();
Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
TCollection_AsciiString aFileName ((const wchar_t* )aFilePath);
//erase viewer
- if(myAISContext->HasOpenedContext())
- myAISContext->CloseAllContexts();
myAISContext->EraseAll();
//create images
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";
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
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)){
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();
myAISContext->Redisplay (aSelectedObject);
myState = -1;
- myAISContext->CloseLocalContext();
}
}
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);
}
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);
}
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);
}
{
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;
//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"
//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"
// 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"
//Neutral selection mode
void CViewer3dDoc::OnNeutral()
{
- myAISContext->CloseAllContexts();
-
myCResultDialog.SetTitle("Standard mode: Neutral");
myCResultDialog.SetText(" myAISContext->CloseAllContexts(); \n"
" \n");
// 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
}
// 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())
{
{
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;
break;
case CurAction3d_EndSpotLight :
GetDocument()->GetAISContext()->Erase(spotConeShape);
- GetDocument()->GetAISContext()->CloseLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
break;
break;
case CurAction3d_EndDirectionalLight:
GetDocument()->GetAISContext()->Erase(directionalEdgeShape);
- GetDocument()->GetAISContext()->CloseLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
break;
UpdateData(TRUE);
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick a first point");
- GetDocument()->GetAISContext()->OpenLocalContext();
myCurrentMode = CurAction3d_BeginDirectionalLight;
TCollection_AsciiString Message("\
return;
}
- GetDocument()->GetAISContext()->OpenLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position");
myCurrentMode = CurAction3d_BeginSpotLight;
return;
}
- GetDocument()->GetAISContext()->OpenLocalContext();
myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),0,0,0,Quantity_NOC_GREEN,1,0);
myView->SetLightOn(myCurrent_PositionalLight);
NbActiveLights++;
return;
}
- GetDocument()->GetAISContext()->OpenLocalContext();
myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY);
myView->SetLightOn(myCurrent_AmbientLight) ;
NbActiveLights++;
- GetDocument()->GetAISContext()->CloseLocalContext();
myView->UpdateLights();
const Handle(V3d_View)& aView )
{
Standard_Integer PopupMenuNumber=0;
- myAISContext->InitCurrent();
- if (myAISContext->MoreCurrent())
+ myAISContext->InitSelected();
+ if (myAISContext->MoreSelected())
PopupMenuNumber=1;
CMenu menu;
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);
}
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());
}
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());
}
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
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();
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++)
{
void COcafDoc::OnUpdateObjectDelete(CCmdUI* pCmdUI)
{
- myAISContext->InitCurrent();
- pCmdUI->Enable (myAISContext->MoreCurrent());
+ myAISContext->InitSelected();
+ pCmdUI->Enable (myAISContext->MoreSelected());
}
void COcafDoc::DisplayPrs()
const Handle(V3d_View)& aView )
{
Standard_Integer PopupMenuNumber=0;
- myAISContext->InitCurrent();
- if (myAISContext->MoreCurrent())
+ myAISContext->InitSelected();
+ if (myAISContext->MoreSelected())
PopupMenuNumber=1;
CMenu menu;
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);
}
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)
{
// 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;
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())
{
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);
}
}
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);
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);
}
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;
// 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{
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"),
return;
}
- myFirstVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape());
- myAISContext->LocalContext()->ClearSelected();
+ myFirstVertex = TopoDS::Vertex (myAISContext->SelectedShape());
+ myAISContext->ClearSelected();
}
//=======================================================================
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();
}
//=======================================================================
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);
}
}
anAngleDim->SetDimensionAspect (anAspect);
- myAISContext->CloseAllContexts();
myAISContext->Display (anAngleDim);
- myAISContext->OpenLocalContext();
- myAISContext->ActivateStandardMode (TopAbs_VERTEX);
+ myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));
}
void CDimensionDlg::OnBnClickedOk()
{
- if (myAISContext->HasOpenedContext())
- {
- myAISContext->CloseAllContexts();
- }
-
OnOK();
}
void CDimensionDlg::UpdateStandardModeForAngle()
{
int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetCurSel();
- myAISContext->CloseAllContexts();
- myAISContext->OpenLocalContext();
TopAbs_ShapeEnum aMode;
if (aTabNum == 1)
aMode = TopAbs_EDGE;
}
- myAISContext->ActivateStandardMode (aMode);
+ myAISContext->Activate (AIS_Shape::SelectionMode (aMode));
}
//=======================================================================
void CDimensionDlg::UpdateStandardModeForLength()
{
int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetCurSel();
- myAISContext->CloseAllContexts();
- myAISContext->OpenLocalContext();
+
TopAbs_ShapeEnum aMode;
if (aTabNum == 1)
{
aMode = TopAbs_EDGE;
}
- myAISContext->ActivateStandardMode (aMode);
+ myAISContext->Activate (AIS_Shape::SelectionMode (aMode));
}
//=======================================================================
case IDC_DimRadius:
case IDC_DimDiameter:
{
- myAISContext->OpenLocalContext();
- myAISContext->ActivateStandardMode (TopAbs_EDGE);
+ myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));
}
break;
}
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);
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);
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();
}
//=======================================================================
void CDimensionDlg::OnDestroy()
{
- if (myAISContext->HasOpenedContext())
- {
- myAISContext->CloseAllContexts();
- }
CWnd *aWnd;
TC_ITEM anItem;
anItem.mask = TCIF_PARAM;
void CDimensionDlg::OnClose()
{
- if (myAISContext->HasOpenedContext())
- {
- myAISContext->CloseAllContexts();
- }
CDialog::OnClose();
}
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;
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();
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;
}
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;
}
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;
}
//----------------------------------------------------------------------
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;
}
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;
}
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;
}
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);
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);
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));
}
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"),
myFirstEdge = TopoDS::Edge (myAISContext->SelectedShape());
- myAISContext->LocalContext()->ClearSelected();
+ myAISContext->ClearSelected();
}
//=======================================================================
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"),
mySecondEdge = TopoDS::Edge (myAISContext->SelectedShape());
- myAISContext->LocalContext()->ClearSelected();
+ myAISContext->ClearSelected();
// Build plane through three points
BRepAdaptor_Curve aCurve1 (myFirstEdge);
CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner());
- myAISContext->CloseAllContexts();
-
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
anAspect->MakeArrows3d (Standard_False);
anAspect->MakeText3d (aDimDlg->GetTextType());
myAISContext->Display (aLenDim);
}
- myAISContext->OpenLocalContext();
- myAISContext->ActivateStandardMode (TopAbs_EDGE);
+ myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));
}
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();
}
//=======================================================================
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);
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));
}
//=======================================================================
// Base check which context menu to call
if (!myPopupMenuNumber)
{
- myAISContext->InitCurrent();
- if (myAISContext->MoreCurrent())
+ myAISContext->InitSelected();
+ if (myAISContext->MoreSelected())
myPopupMenuNumber=1;
}
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);
}
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 {
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);
}
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);
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);
}
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);
}
// 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;
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);
}
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);
}
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));
}
#include "ParamsFacesPage.h"
#include "DimensionDlg.h"
#include <AIS_InteractiveContext.hxx>
-#include <AIS_LocalContext.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_AngleDimension.hxx>
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"),
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"),
}
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);
myAISContext->Display (aLenDim);
}
- myAISContext->OpenLocalContext();
- myAISContext->ActivateStandardMode (TopAbs_FACE);
+ myAISContext->Activate (aSelectionMode);
}
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);
}
}
- myAISContext->LocalContext()->ClearSelected();
+ myAISContext->ClearSelected();
CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner());
// Try to create dimension if it is possible
Handle(AIS_Dimension) aDim;
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));
}
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 );
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();
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();
{
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 );
{
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()
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()
{
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();
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();
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))
{
if (aStatus->IsHilighted())
{
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (IsCurrent (theIObj))
{
AddOrRemoveCurrentObject (theIObj, Standard_False);
{
unhighlightGlobal (theIObj, aStatus->DisplayMode());
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
}
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
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();
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
//! 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
//! 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);
//! 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);
//! 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();
//! 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;
//! 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();
//! 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;
//! 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();
//! 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.
//! 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.
//! 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
//! 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
//! 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
//! 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
//! 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;
//! 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
//! 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
//! 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.
//! 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;
//! shape selection modes activation.
//! = False, <anIobj> 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);
//! 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);
//! 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);
//! 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;
//! 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;
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
//! 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);
//! 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
return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
+ Standard_ENABLE_DEPRECATION_WARNINGS
if (aCurrentShape.IsNull())
{
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,
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"<<endl;
//function : CloseAllContexts
//purpose :
//=======================================================================
-
+Standard_DISABLE_DEPRECATION_WARNINGS
void AIS_InteractiveContext::CloseAllContexts(const Standard_Boolean updateviewer)
{
-
while(!myLocalContexts.IsEmpty()){
CloseLocalContext(myCurLocalIndex,Standard_False);
}
-
+
ResetOriginalState(Standard_False);
if(updateviewer) myMainVwr->Update();
}
+Standard_ENABLE_DEPRECATION_WARNINGS
//=======================================================================
//function : IndexOfCurrentLocal
}
}
+// ============================================================================
+// 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 :
}
}
+// ============================================================================
+// 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 :
--- /dev/null
+// 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
// 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());
AIS_InteractiveObject.lxx
AIS_KindOfDimension.hxx
AIS_KindOfInteractive.hxx
+AIS_KindOfRelation.hxx
AIS_KindOfSurface.hxx
AIS_KindOfUnit.hxx
AIS_LengthDimension.cxx
return;
}
- Presentation (thePrsObj, theMode)->SetVisible (theValue);
+ Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ if (!aPrs.IsNull())
+ {
+ aPrs->SetVisible (theValue);
+ }
}
// =======================================================================
#include <BRepAdaptor_Curve.hxx>
#include <GC_MakePlane.hxx>
+Standard_DISABLE_DEPRECATION_WARNINGS
static Standard_Integer OCC328bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
return 0;
}
+Standard_ENABLE_DEPRECATION_WARNINGS
static Standard_Integer OCC159bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if(AISObj.IsNull()){
di << argv[1] << " : No interactive object\n";
return 1;
- }
- if (!aContext->HasOpenedContext()) {
- aContext->OpenLocalContext();
}
aContext->Erase(AISObj, updateviewer);
aContext->UpdateCurrentViewer();
return 1;
}
- if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts();
anAISCtx->EraseAll();
//load primitives to context
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 )
return 1;
}
AISObj->ResetTransformation();
- if (!aContext->HasOpenedContext()) {
- aContext->OpenLocalContext();
- }
+
aContext->Erase(AISObj, updateviewer);
aContext->UpdateCurrentViewer();
aContext->Display(AISObj, updateviewer);
return 0;
}
-#include <Quantity_NameOfColor.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <Geom_Curve.hxx>
-#include <AIS_InteractiveObject.hxx>
-Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- // Check the command arguments
- if (argc != 2)
- {
- di <<"Error: "<<argv[0]<<" - invalid number of arguments\n";
- di << "Usage : " << argv[0] << " mode(0/1)\n";
- return 1; //TCL_ERROR
- }
-
- const Standard_Integer aMode = Draw::Atoi(argv[1]);
-
- //===================================================================
-
- Handle(AIS_InteractiveContext) aisContext = ViewerTest::GetAISContext();
- if (aisContext.IsNull())
- {
- di <<"Error: call 'vinit' first\n";
- return 1; //TCL_ERROR
- }
-
- if (aisContext->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";
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;
}
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 );
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;
}
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 <BRepBndLib.hxx>
#include <Draw.hxx>
//=======================================================================
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);
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)
// 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();
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();
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;
}
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();
// 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);
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();
}
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;
}
const Standard_Integer aCtxToClose = Draw::Atoi (theArgv[1]);
+ Standard_DISABLE_DEPRECATION_WARNINGS
aCtx->CloseLocalContext (aCtxToClose);
+ Standard_ENABLE_DEPRECATION_WARNINGS
return 0;
}
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);
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;
}
}
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;
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;
#include <V3d_View.hxx>
#include <gce_MakePln.hxx>
-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
//=======================================================================
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 <BRepBndLib.hxx>
#include <Bnd_HArray1OfBox.hxx>
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);
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 :
void ViewerTest::Clear()
{
if ( !a3DView().IsNull() ) {
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
while ( it.More() ) {
cout << "Remove " << it.Key2() << endl;
//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()) {
// 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="???";
}
if(theactivatedmodes.Contains(mode))
- { // Desactivate
- aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
- theactivatedmodes.Remove(mode);
- cout<<"Mode "<< cmode <<" OFF"<<endl;
- }
+ { // Desactivate
+ aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
+ theactivatedmodes.Remove(mode);
+ cout<<"Mode "<< cmode <<" OFF"<<endl;
+ }
else
- { // Activate
- aContext->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
return 1;
}
- if (aCtx->HasOpenedContext())
- {
- aCtx->CloseLocalContext();
- }
for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
isFirst = Standard_False;
}
- if (aCtx->HasOpenedContext())
- {
- aCtx->CloseLocalContext();
- }
-
// special case for -defaults parameter.
// all changed values will be set to DefaultDrawer.
if (isDefaults)
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (aCtx->HasOpenedContext())
{
aCtx->CloseLocalContext();
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toRemoveLocal && !aCtx->HasOpenedContext())
{
std::cerr << "Error: local selection context is not open.\n";
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
NCollection_List<TCollection_AsciiString> anIONameList;
if (toRemoveAll)
// 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;
}
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toEraseLocal && !aCtx->HasOpenedContext())
{
std::cerr << "Error: local selection context is not open.\n";
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
if (!aNamesOfEraseIO.IsEmpty())
{
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toDisplayLocal && !aCtx->HasOpenedContext())
{
std::cerr << "Error: local selection context is not open.\n";
{
aCtx->CloseLocalContext (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
}
// Prepare context for display
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toDisplayLocal && !aCtx->HasOpenedContext())
{
aCtx->OpenLocalContext (Standard_False);
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
// Display interactive objects
for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
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;
// Verifications
const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
-
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
-
if (argc < 3) {
myDevCoef = 0.0008;
} else {
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
}
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->OpenLocalContext(Standard_False);
+ Standard_ENABLE_DEPRECATION_WARNINGS
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it (GetMapOfAIS());
while(it.More()){
}
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()){
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)
{
}
NCollection_Map<Handle(AIS_InteractiveObject)> 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
theDI << "\n";
}
printLocalSelectionInfo (aCtx, theDI);
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (aCtx->HasOpenedContext())
printLocalSelectionInfo (aCtx->LocalContext(), theDI);
+ Standard_ENABLE_DEPRECATION_WARNINGS
return 0;
}
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){
arr->SetValue(i,IO2);
}
-
- if(curindex>0)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ if (curindex > 0)
+ {
TheAISContext()->CloseLocalContext(curindex);
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
return Standard_True;
}
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
IO = TheAISContext()->SelectedInteractive();
}
- if(curindex!=0)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ if (curindex != 0)
+ {
TheAISContext()->CloseLocalContext(curindex);
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
return IO;
}
{
// 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){
else{
Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
TheAISContext()->AddFilter(TF);
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->ActivateStandardMode(TheType);
-
+ Standard_ENABLE_DEPRECATION_WARNINGS
}
}
}
- if(curindex>0)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ if (curindex > 0)
+ {
TheAISContext()->CloseLocalContext(curindex);
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
return result;
}
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);
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...
}
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->CloseLocalContext(curindex);
+ Standard_ENABLE_DEPRECATION_WARNINGS
return Standard_True;
}
}
// Prepare context
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (isLocal && !aCtx->HasOpenedContext())
{
aCtx->OpenLocalContext (Standard_False);
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
// Load selection of interactive objects
for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
#include <Standard_Boolean.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopTools_HArray1OfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
#include <AIS_KindOfInteractive.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <TColStd_HArray1OfTransient.hxx>
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,
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 <AIS_PlaneTrihedron.hxx>
+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<<argv[0]<<" error\n"; return 1;}
+ TopoDS_Face aFace = TopoDS::Face (aShape);
+ TopExp_Explorer aFaceExp (aFace, TopAbs_EDGE);
+ TopoDS_Edge anEdge0 = TopoDS::Edge (aFaceExp.Current());
- // Declarations
- Standard_Integer myCurrentIndex;
- // Fermeture des contextes
- 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 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;
}
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;}
// Verification des arguments
if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
- // Declarations
- Standard_Integer myCurrentIndex;
- // Fermeture des contextes locaux
- TheAISContext()->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;
}
// Declarations
Standard_Boolean HasArg;
TCollection_AsciiString name;
- Standard_Integer MyCurrentIndex;
// Verification
if (argc<2 || argc>8 ) {di<<" Syntaxe error\n";return 1;}
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)
// 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);
// 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);
}
// 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);
// Declarations
Standard_Boolean HasArg;
TCollection_AsciiString name;
- Standard_Integer myCurrentIndex;
// Verification
if (argc<2 || argc>5 ) {di<<" Syntaxe error\n";return 1;}
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) {
}
// 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 );
// Declarations
Standard_Boolean hasArg;
TCollection_AsciiString aName;
- Standard_Integer aCurrentIndex;
// Verification
if (argc<2 || argc>6 )
hasArg=Standard_False;
aName=argv[1];
- // Close all contexts
- TheAISContext()->CloseAllContexts();
// There are some arguments
if (hasArg)
// 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);
}
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);
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);
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)
return 1;
}
}
+ else
+ {
+ std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n";
+ return 1;
+ }
}
// Function vPlanePara
// 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;
}
}
// 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;
}
}
}
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;
// 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;
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)
// 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;
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;
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);
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);
}
DisplayCircle(theGeomCircle, aName, isFilled);
-
}
-
+ else
+ {
+ std::cerr << "Error: You should select face and vertex or three vertices.\n";
+ return 1;
+ }
}
return 0;
return 1;
}
- // close local context
- if (aContextAIS->HasOpenedContext ())
- aContextAIS->CloseLocalContext ();
-
Handle(HLRBRep_PolyAlgo) aPolyAlgo = new HLRBRep_PolyAlgo();
HLRBRep_PolyHLRToShape aHLRToShape;
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)
{
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);
}
}
{
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);
}
}
return 1; // TCL_ERROR
}
- TheAISContext()->CloseAllContexts();
-
// Get and check values
TCollection_AsciiString aName(argv[1]);
return 1; // TCL_ERROR
}
- TheAISContext()->CloseAllContexts();
-
// Get and check arguments
TCollection_AsciiString aName(argv[1]);
Handle(AIS_Point) aPoint1, aPoint2;
#include <AIS_FixRelation.hxx>
#include <AIS_IdenticRelation.hxx>
#include <AIS_InteractiveContext.hxx>
+#include <AIS_KindOfRelation.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
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)
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."<<endl;return 1;}
+ BRepAdaptor_Curve aCurveA (anEdgeA);
+ BRepAdaptor_Curve aCurveB (anEdgeB);
- // 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_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;
-
}
//=======================================================================
}
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" };
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"
" -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"
" -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]"
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";
}
di << "Error: export of image to " << aFormatStr << " failed";
di << " (exception: " << Standard_Failure::Caught()->GetMessageString() << ")";
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
return 0;
}
di << "use 'vinit' command before " << argv[0] << "\n";
return 1;
}
- aContext->CloseAllContexts(Standard_False);
+
di << aContext->PurgeDisplay() << "\n";
return 0;
}
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 );
}
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 );
}
--- /dev/null
+set subgroup "dimensions"
+vinit View1
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
-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" } {
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
018 point_cloud
019 manipulator
020 anim
+021 dimensions