- misprint in check of global selection existence in AIS_InteractiveContext::SetSelected was corrected;
- remaining occurrencies of hard-coded 0 selection mode were corrected to use global selection mode;
- test case for issue #27983
return;
if(!myObjects.IsBound (theObject))
Display (theObject, Standard_False);
- if (theObject->HasSelection (0))
+ if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
return;
const Handle(Graphic3d_HighlightStyle)& anObjSelStyle =
}
// added to avoid untimely viewer update...
- const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
- if (aSel->IsEmpty())
+ Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
+ if (anOwner.IsNull())
return;
- aSel->Init();
- Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
mySelection->ClearAndSelect (anOwner);
- anOwner->State (1);
- if (anOwner == theObject->GlobalSelOwner())
- {
- Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject);
- aState->SetHilightStatus (Standard_True);
- aState->SetHilightStyle (anObjSelStyle);
- }
+
Handle(Graphic3d_HighlightStyle) aCustomStyle;
if (HighlightStyle (theObject, aCustomStyle))
{
{
HilightWithColor (theObject, anObjSelStyle, Standard_False);
}
+ anOwner->State (1);
if (theToUpdateViewer)
UpdateCurrentViewer();
Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromIO(anIObj);
if(EO.IsNull()){
- //check if in selection number 0 there is an owner that can be triturated...
- if(anIObj->HasSelection(0)){
- const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
- SIOBJ->Init();
- if(SIOBJ->More()){
- Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
- EO = Handle(SelectMgr_EntityOwner)::DownCast (BO);
- }
+ //check if global selection there is an owner that can be triturated...
+ if (anIObj->HasSelection (anIObj->GlobalSelectionMode()))
+ {
+ EO = anIObj->GlobalSelOwner();
}
if(EO.IsNull())
EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
if (EO.IsNull())
{
- if(anIObj->HasSelection(0))
+ if(anIObj->HasSelection (anIObj->GlobalSelectionMode()))
{
- const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
- SIOBJ->Init();
- if(SIOBJ->More()){
- Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
- EO = Handle(SelectMgr_EntityOwner)::DownCast (BO);
- }
+ EO = anIObj->GlobalSelOwner();
}
if(EO.IsNull())
{
return 0;
}
+//========================================================================
+//function : OCC27893
+//purpose : Creates a box and selects it via AIS_InteractiveContext API
+//========================================================================
+static Standard_Integer OCC27893 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
+{
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ if (aCtx.IsNull())
+ {
+ std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
+ return 1;
+ }
+
+ TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
+ Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
+ aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
+ aCtx->SetSelected (aBoxObj, Standard_True);
+
+ return 0;
+}
+
//========================================================================
//function : Commands_19
//purpose :
theCommands.Add ("OCC27818",
"OCC27818: Creates three boxes and highlights one of them with own style",
__FILE__, OCC27818, group);
+ theCommands.Add ("OCC27893",
+ "OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
+ __FILE__, OCC27893, group);
return;
}
if (myGlobal.Contains (theObject))
{
- if (theMode != 0 && theSelector->IsActive (theObject, 0))
+ const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
+ if (theMode != aGlobalSelMode && theSelector->IsActive (theObject, aGlobalSelMode))
{
- theSelector->Deactivate (theObject->Selection (0));
+ theSelector->Deactivate (theObject->Selection (aGlobalSelMode));
}
theSelector->Activate (theObject->Selection (theMode));
}
--- /dev/null
+puts "==========="
+puts "OCC27893"
+puts "==========="
+puts ""
+##########################################################################
+# Visualization - AIS_InteractiveContext::SetSelected does not work
+##########################################################################
+
+pload VISUALIZATION QAcommands
+
+vinit
+OCC27893
+vfit
+
+if {[vnbselected] != "1" || [vreadpixel 204 254 name] != "GRAY80 1"} {
+ puts "ERROR: The box is not selected, AIS_InteractiveContext::SetSelected works incorrect"
+}