1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0028162: Draw Harness - eliminate usage of deprecated Local Context

Create a general draw command 'VRelation' and drop the old 'relation' commands.
Add test cases for new draw command "vrelation".
Add two new methods: Activate and Deactivate which activate/deactivate the given selection mode for all displayed objects.
Eliminate deprecated local context methods in ObjectCommands, QABugs.
Eliminate deprecated local context methods in mfc standard sample and qt samples.
This commit is contained in:
isk
2016-11-28 12:11:43 +03:00
committed by apn
parent 0a8630615d
commit 404c893694
55 changed files with 1886 additions and 3290 deletions

View File

@@ -135,25 +135,34 @@ void COffsetDlg::SetOffsets(Standard_Real theFactor, Standard_Real theUnits)
Standard_ShortReal aFactor = (Standard_ShortReal)theFactor;
Standard_ShortReal aUnits = (Standard_ShortReal)theUnits;
for (aAISContext->InitCurrent();aAISContext->MoreCurrent ();aAISContext->NextCurrent ())
if (aAISContext->IsDisplayed(aAISContext->Current())) OneOrMoreCurrentIsDisplayed=true;
for (aAISContext->InitSelected(); aAISContext->MoreSelected(); aAISContext->NextSelected())
if (aAISContext->IsDisplayed(aAISContext->SelectedInteractive())) OneOrMoreCurrentIsDisplayed=true;
if(OneOrMoreCurrentIsDisplayed){
if((aAISContext->IsCurrent(aOverlappedBox) || aAISContext->IsCurrent(aBox))
// A small trick to avoid complier error (C2668).
const Handle(AIS_InteractiveObject)& anIOOverlappedBox = aOverlappedBox;
const Handle(AIS_InteractiveObject)& anIOBox = aBox;
if((aAISContext->IsSelected(anIOOverlappedBox) || aAISContext->IsSelected(anIOBox))
&& aAISContext->IsDisplayed(aOverlappedBox)){
aOverlappedBox->SetPolygonOffsets(Aspect_POM_Fill,aFactor,aUnits);
Message = "Box2 -> SetPolygonOffsets(Aspect_POM_Fill, Factor, Units);\n";
//myDoc -> AddTextInDialog(Message);
}
if((aAISContext->IsCurrent(aOverlappedCylinder) || aAISContext->IsCurrent(aCylinder))
// A small trick to avoid complier error (C2668).
const Handle(AIS_InteractiveObject)& anIOOverlappedCylinder = aOverlappedCylinder;
const Handle(AIS_InteractiveObject)& anIOCylinder = aCylinder;
if((aAISContext->IsSelected(anIOOverlappedCylinder) || aAISContext->IsSelected(anIOCylinder))
&& aAISContext->IsDisplayed(aOverlappedCylinder)){
aOverlappedCylinder->SetPolygonOffsets(Aspect_POM_Fill,aFactor,aUnits);
Message = Message + "Cylinder2 -> SetPolygonOffsets(Aspect_POM_Fill, Factor, Units);\n";
//myDoc -> AddTextInDialog(Message);
}
if((aAISContext->IsCurrent(aOverlappedSphere) || aAISContext->IsCurrent(aSphere))
// A small trick to avoid complier error (C2668).
const Handle(AIS_InteractiveObject)& anIOOverlappedSphere = aOverlappedSphere;
const Handle(AIS_InteractiveObject)& anIOSphere = aSphere;
if((aAISContext->IsSelected(anIOOverlappedSphere) || aAISContext->IsSelected(anIOSphere))
&& aAISContext->IsDisplayed(aOverlappedSphere)){
aOverlappedSphere->SetPolygonOffsets(Aspect_POM_Fill,aFactor,aUnits);
Message = Message + "Sphere2 -> SetPolygonOffsets(Aspect_POM_Fill, Factor, Units);\n";
@@ -209,18 +218,23 @@ void COffsetDlg::UpdateValues()
BOOL IsOverlappedSphereDisplayed = aAISContext->IsDisplayed(aOverlappedSphere);
BOOL IsOverlappedBoxDisplayed = aAISContext->IsDisplayed(aOverlappedBox);
BOOL IsOverlappedCylinderCurrent = aAISContext->IsCurrent(aOverlappedCylinder);
BOOL IsOverlappedSphereCurrent = aAISContext->IsCurrent(aOverlappedSphere);
BOOL IsOverlappedBoxCurrent = aAISContext->IsCurrent(aOverlappedBox);
const Handle(AIS_InteractiveObject)& anIOOverlappedCylinder = aOverlappedCylinder;
const Handle(AIS_InteractiveObject)& anIOOverlappedSphere = aOverlappedSphere;
const Handle(AIS_InteractiveObject)& anIOOverlappedBox = aOverlappedBox;
BOOL IsOverlappedCylinderCurrent = aAISContext->IsSelected(anIOOverlappedCylinder);
BOOL IsOverlappedSphereCurrent = aAISContext->IsSelected(anIOOverlappedSphere);
BOOL IsOverlappedBoxCurrent = aAISContext->IsSelected(anIOOverlappedBox);
/*BOOL IsAnyOverlappedObjectCurrent =
IsOverlappedCylinderCurrent || IsOverlappedSphereCurrent || IsOverlappedBoxCurrent;*/
BOOL IsCylinderCurrent = aAISContext->IsCurrent(aCylinder);
BOOL IsSphereCurrent = aAISContext->IsCurrent(aSphere);
BOOL IsBoxCurrent = aAISContext->IsCurrent(aBox);
const Handle(AIS_InteractiveObject)& anIOCylinder = aCylinder;
const Handle(AIS_InteractiveObject)& anIOSphere = aSphere;
const Handle(AIS_InteractiveObject)& anIOBox = aBox;
BOOL IsCylinderCurrent = aAISContext->IsSelected(anIOCylinder);
BOOL IsSphereCurrent = aAISContext->IsSelected(anIOSphere);
BOOL IsBoxCurrent = aAISContext->IsSelected(anIOBox);
BOOL IsAnyObjectCurrent =
IsOverlappedCylinderCurrent || IsOverlappedSphereCurrent || IsOverlappedBoxCurrent
@@ -230,8 +244,8 @@ void COffsetDlg::UpdateValues()
IsOverlappedCylinderDisplayed || IsOverlappedSphereDisplayed || IsOverlappedBoxDisplayed;
Standard_Boolean OneOrMoreCurrentIsDisplayed=false;
for (aAISContext->InitCurrent();aAISContext->MoreCurrent ();aAISContext->NextCurrent ())
if (aAISContext->IsDisplayed(aAISContext->Current())) OneOrMoreCurrentIsDisplayed=true;
for (aAISContext->InitSelected();aAISContext->MoreSelected ();aAISContext->NextSelected ())
if (aAISContext->IsDisplayed(aAISContext->SelectedInteractive())) OneOrMoreCurrentIsDisplayed=true;
if(OneOrMoreCurrentIsDisplayed){
if(IsOverlappedBoxDisplayed && (IsBoxCurrent || IsOverlappedBoxCurrent)){

View File

@@ -403,27 +403,34 @@ void CViewer3dDoc::OnUpdateOverlappedBox(CCmdUI* pCmdUI)
void CViewer3dDoc::OnObjectRemove()
{
if(myAISContext->IsCurrent(myBox))
// A small trick to avoid complier error (C2668).
const Handle(AIS_InteractiveObject)& aBox = myBox;
if(myAISContext->IsSelected (aBox))
myBox.Nullify();
if(myAISContext->IsCurrent(myCylinder))
const Handle(AIS_InteractiveObject)& aCylinder = myCylinder;
if(myAISContext->IsSelected (aCylinder))
myCylinder.Nullify();
if(myAISContext->IsCurrent(mySphere))
const Handle(AIS_InteractiveObject)& aSphere = mySphere;
if(myAISContext->IsSelected (aSphere))
mySphere.Nullify();
if(myAISContext->IsCurrent(myOverlappedBox))
const Handle(AIS_InteractiveObject)& anOverlappedBox = myOverlappedBox;
if(myAISContext->IsSelected (anOverlappedBox))
myOverlappedBox.Nullify();
if(myAISContext->IsCurrent(myOverlappedCylinder))
const Handle(AIS_InteractiveObject)& anOverlappedCylinder = myOverlappedCylinder;
if(myAISContext->IsSelected (anOverlappedCylinder))
myOverlappedCylinder.Nullify();
if(myAISContext->IsCurrent(myOverlappedSphere))
const Handle(AIS_InteractiveObject)& anOverlappedSphere = myOverlappedSphere;
if(myAISContext->IsSelected (anOverlappedSphere))
myOverlappedSphere.Nullify();
for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->InitCurrent())
myAISContext->Remove(myAISContext->Current(),Standard_True);
for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->InitSelected())
myAISContext->Remove(myAISContext->SelectedInteractive(),Standard_True);
if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
myOffsetDlg->UpdateValues();
@@ -532,7 +539,6 @@ void CViewer3dDoc::InputEvent(const Standard_Integer /*x*/,
myAISContext->Redisplay (aSelectedObject);
myState = -1;
myAISContext->CloseLocalContext();
}
}
@@ -588,20 +594,20 @@ void CViewer3dDoc::ShiftInputEvent (const Standard_Integer theX,
void CViewer3dDoc::OnObjectColoredMesh()
{
for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent())
if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder)))
for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->NextSelected())
if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder)))
{
myAISContext->ClearPrs(myAISContext->Current(),6,Standard_False);
myAISContext->RecomputePrsOnly(myAISContext->Current(),Standard_False);
myAISContext->SetDisplayMode(myAISContext->Current(),6);
myAISContext->ClearPrs(myAISContext->SelectedInteractive(),6,Standard_False);
myAISContext->RecomputePrsOnly(myAISContext->SelectedInteractive(), Standard_False);
myAISContext->SetDisplayMode(myAISContext->SelectedInteractive(), 6);
}
}
void CViewer3dDoc::OnUpdateObjectColoredMesh(CCmdUI* pCmdUI)
{
bool CylinderIsCurrentAndDisplayed = false;
for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
if(myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder)))
for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
if(myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder)))
CylinderIsCurrentAndDisplayed=true;
pCmdUI->Enable (CylinderIsCurrentAndDisplayed);
}
@@ -609,8 +615,8 @@ void CViewer3dDoc::OnUpdateObjectColoredMesh(CCmdUI* pCmdUI)
void CViewer3dDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI)
{
bool OneOrMoreInShadingOrColoredMesh = false;
for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
if (myAISContext->IsDisplayed(myAISContext->Current(),1) || myAISContext->IsDisplayed(myAISContext->Current(),6))
for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(), 1) || myAISContext->IsDisplayed(myAISContext->SelectedInteractive(), 6))
OneOrMoreInShadingOrColoredMesh=true;
pCmdUI->Enable (OneOrMoreInShadingOrColoredMesh);
}
@@ -619,8 +625,8 @@ void CViewer3dDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI)
void CViewer3dDoc::OnUpdateObjectShading(CCmdUI* pCmdUI)
{
bool OneOrMoreInWireframeOrColoredMesh = false;
for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
if (myAISContext->IsDisplayed(myAISContext->Current(),0) || myAISContext->IsDisplayed(myAISContext->Current(),6))
for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),0) || myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),6))
OneOrMoreInWireframeOrColoredMesh=true;
pCmdUI->Enable (OneOrMoreInWireframeOrColoredMesh);
}
@@ -668,10 +674,10 @@ void CViewer3dDoc::Popup (const Standard_Integer x,
{
myPopupMenuNumber=0;
// Specified check for context menu number to call
myAISContext->InitCurrent();
if (myAISContext->MoreCurrent())
myAISContext->InitSelected();
if (myAISContext->MoreSelected())
{
if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder)))
if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder)))
{
myPopupMenuNumber = 2;
//return;
@@ -683,9 +689,7 @@ void CViewer3dDoc::Popup (const Standard_Integer x,
//Set faces selection mode
void CViewer3dDoc::OnFaces()
{
myAISContext->CloseAllContexts();
myAISContext->OpenLocalContext();
myAISContext->ActivateStandardMode (TopAbs_FACE);
myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_FACE));
myCResultDialog.SetTitle("Standard mode: TopAbs_FACE");
myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
@@ -698,9 +702,7 @@ void CViewer3dDoc::OnFaces()
//Set edges selection mode
void CViewer3dDoc::OnEdges()
{
myAISContext->CloseAllContexts();
myAISContext->OpenLocalContext();
myAISContext->ActivateStandardMode(TopAbs_EDGE);
myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));
myCResultDialog.SetTitle("Standard mode: TopAbs_EDGE");
myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
@@ -713,9 +715,7 @@ void CViewer3dDoc::OnEdges()
// Set vertices selection mode
void CViewer3dDoc::OnVertices()
{
myAISContext->CloseAllContexts();
myAISContext->OpenLocalContext();
myAISContext->ActivateStandardMode (TopAbs_VERTEX);
myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));
myCResultDialog.SetTitle("Standard mode: TopAbs_VERTEX");
myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
@@ -728,8 +728,6 @@ void CViewer3dDoc::OnVertices()
//Neutral selection mode
void CViewer3dDoc::OnNeutral()
{
myAISContext->CloseAllContexts();
myCResultDialog.SetTitle("Standard mode: Neutral");
myCResultDialog.SetText(" myAISContext->CloseAllContexts(); \n"
" \n");
@@ -739,8 +737,7 @@ void CViewer3dDoc::OnNeutral()
// Change the color of faces on a user cylinder
void CViewer3dDoc::OnUsercylinderChangefacecolor()
{
myAISContext->OpenLocalContext();
myAISContext->Activate(myAISContext->Current(),4);
myAISContext->Activate(myAISContext->SelectedInteractive(), 4);
myState = FACE_COLOR;
// see the following of treatment in inputevent
}
@@ -750,13 +747,6 @@ void CViewer3dDoc::OnUsercylinderChangefacecolor()
// before running this function
void CViewer3dDoc::OnFillet3d()
{
if (!myAISContext->HasOpenedContext())
{
AfxMessageBox (L"It is necessary to activate the edges selection mode\n"
L"and select edges on an object before \nrunning this function");
return;
}
myAISContext->InitSelected();
if (myAISContext->MoreSelected())
{

View File

@@ -401,7 +401,6 @@ void CViewer3dView::OnLButtonDown(UINT nFlags, CPoint point)
{
p1 = ConvertClickToPoint(point.x,point.y,myView);
myCurrent_PositionalLight->SetPosition(p1.X(),p1.Y(),p1.Z()) ;
GetDocument()->GetAISContext()->CloseLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
@@ -449,7 +448,6 @@ GetDocument()->UpdateResultMessageDlg("SetAngle",Message);
break;
case CurAction3d_EndSpotLight :
GetDocument()->GetAISContext()->Erase(spotConeShape);
GetDocument()->GetAISContext()->CloseLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
break;
@@ -477,7 +475,6 @@ GetDocument()->UpdateResultMessageDlg("SetDirection",Message);
break;
case CurAction3d_EndDirectionalLight:
GetDocument()->GetAISContext()->Erase(directionalEdgeShape);
GetDocument()->GetAISContext()->CloseLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
break;
@@ -888,7 +885,6 @@ void CViewer3dView::OnDirectionalLight()
UpdateData(TRUE);
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick a first point");
GetDocument()->GetAISContext()->OpenLocalContext();
myCurrentMode = CurAction3d_BeginDirectionalLight;
TCollection_AsciiString Message("\
@@ -914,7 +910,6 @@ void CViewer3dView::OnSpotLight()
return;
}
GetDocument()->GetAISContext()->OpenLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position");
myCurrentMode = CurAction3d_BeginSpotLight;
@@ -941,7 +936,6 @@ void CViewer3dView::OnPositionalLight()
return;
}
GetDocument()->GetAISContext()->OpenLocalContext();
myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),0,0,0,Quantity_NOC_GREEN,1,0);
myView->SetLightOn(myCurrent_PositionalLight);
NbActiveLights++;
@@ -971,11 +965,9 @@ void CViewer3dView::OnAmbientLight()
return;
}
GetDocument()->GetAISContext()->OpenLocalContext();
myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY);
myView->SetLightOn(myCurrent_AmbientLight) ;
NbActiveLights++;
GetDocument()->GetAISContext()->CloseLocalContext();
myView->UpdateLights();