#include <V3d_SpotLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-#include <Visual3d_View.hxx>
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
}
}
+//=======================================================================
+//function : unhighlightSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
+{
+ AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
+ Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
+ NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
+ for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
+ {
+ const Handle(SelectMgr_EntityOwner) anOwner =
+ Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
+ if (anOwner.IsNull() || !anOwner->HasSelectable())
+ continue;
+
+ const Handle(AIS_InteractiveObject) anInteractive =
+ Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (anOwner->IsAutoHilight())
+ {
+ const Standard_Integer aHiMode = anInteractive->HasHilightMode() ? anInteractive->HilightMode() : 0;
+ anOwner->Unhilight (myMainPM, aHiMode);
+ if (theIsToHilightSubIntensity)
+ {
+ if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn())
+ {
+ anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode);
+ }
+ }
+ }
+ else
+ {
+ if (!anObjToClear.Contains (anInteractive))
+ anObjToClear.Add (anInteractive);
+ }
+ anOwner->State (0);
+ if (anOwner == anInteractive->GlobalSelOwner())
+ {
+ myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
+ }
+ }
+ for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
+ const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
+ myMainPM->Unhighlight (anObj, aHiMode);
+ anObj->ClearSelected();
+ }
+}
+
//=======================================================================
//function : MoveTo
//purpose :
myLastPicked.Nullify();
}
- if (toUpdateViewer)
+ if (toUpdateViewer
+ && theToRedrawOnUpdate)
{
- if (theToRedrawOnUpdate)
- {
- theView->Viewer()->Update();
- }
- else
- {
- theView->Viewer()->Invalidate();
- }
+ theView->Viewer()->Update();
}
mylastmoveview = theView;
for (aSelector->Init(); aSelector->More(); aSelector->Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
}
else
{
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aSelection = AIS_Selection::CurrentSelection();
- NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
- {
- const Handle(SelectMgr_EntityOwner) anOwner
- = Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Value());
-
- if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
- continue;
-
- const Handle(AIS_InteractiveObject) anObject =
- Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- anOwner->State (0);
- if (anOwner == anObject->GlobalSelOwner())
- {
- Handle(AIS_GlobalStatus) aStatus = myObjects (anObject);
- aStatus->SetHilightStatus (Standard_False);
- aStatus->SetHilightColor (Quantity_NOC_WHITE);
- anObject->State (0);
- }
- if (!anOwner->IsAutoHilight())
- {
- if (!anObjToClear.Contains (anObject))
- anObjToClear.Add (anObject);
- }
- else
- {
- const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
- anOwner->Unhilight (myMainPM, aHiMode);
- if (myObjects.IsBound (anObject) && myObjects(anObject)->IsSubIntensityOn())
- {
- anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode);
- }
- }
- }
- while (!anObjToClear.IsEmpty())
- {
- anObjToClear.FindKey (anObjToClear.Size())->ClearSelected();
- anObjToClear.RemoveLast();
- }
+ unhighlightSelected (Standard_True);
AIS_Selection::Select();
if (toUpdateViewer && myWasLastMain)
AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
for (aSelector->Init(); aSelector->More(); aSelector->Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
for (aSelector->Init(); aSelector->More(); aSelector->Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
if (anOwner == anObj->GlobalSelOwner())
{
- anObj->State (1);
+ Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj);
+ aState->SetHilightStatus (Standard_True);
+ aState->SetHilightColor (mySelectionColor);
}
anOwner->State (1);
if (!anOwner->IsAutoHilight())
Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
if (anOwner == anObj->GlobalSelOwner())
{
- anObj->State (0);
+ myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
}
anOwner->State (0);
const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0;
if (NbSelected() == 0)
return;
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aSel = AIS_Selection::CurrentSelection();
- NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
- for (aSel->Init(); aSel->More(); aSel->Next())
- {
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
- if (!anOwner.IsNull() && anOwner->HasSelectable())
- {
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (anOwner == anObj->GlobalSelOwner())
- {
- anObj->State (0);
- }
- anOwner->State (0);
- if (!anOwner->IsAutoHilight())
- {
- if (!anObjToClear.Contains (anObj))
- anObjToClear.Add (anObj);
- }
- else
- {
- const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
- anOwner->Unhilight (myMainPM, aHiMode);
- }
- }
- }
-
- while (!anObjToClear.IsEmpty())
- {
- anObjToClear.FindKey (anObjToClear.Size())->ClearSelected();
- anObjToClear.RemoveLast();
- }
+ unhighlightSelected();
AIS_Selection::Select();
myMainPM->ClearImmediateDraw();
if (theObject->HasSelection (0))
return;
- if (NbSelected() == 1 && theObject->State() == 1)
+ if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
{
Quantity_NameOfColor aHiCol;
Standard_Boolean hasHiCol = Standard_False;
{
const Handle(SelectMgr_EntityOwner) anOwner =
Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
- if (anOwner.IsNull() || !anOwner->HasSelectable())
+ if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
Handle(AIS_InteractiveObject) aSelectable =
Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
Unhilight (aSelectable, Standard_False);
anOwner->State (0);
- aSelectable->State (0);
+ if (anOwner == aSelectable->GlobalSelOwner())
+ {
+ myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
+ }
}
// added to avoid untimely viewer update...
Handle(SelectMgr_EntityOwner) anOwner =
Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
AIS_Selection::ClearAndSelect (anOwner);
- theObject->State (1);
anOwner->State (1);
+ if (anOwner == theObject->GlobalSelOwner())
+ {
+ Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject);
+ aState->SetHilightStatus (Standard_True);
+ aState->SetHilightColor (mySelectionColor);
+ }
Quantity_NameOfColor aHiCol;
Standard_Boolean hasHiCol = Standard_False;
if (IsHilighted (theObject, hasHiCol, aHiCol))
void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Boolean theToUpdateViewer)
{
- if (theOwner.IsNull() || !theOwner->HasSelectable())
+ if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
return;
const Handle(AIS_InteractiveObject) anObject =
if (!myObjects.IsBound (anObject))
Display (anObject, Standard_False);
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
- for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
- {
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
- if (!anOwner->HasSelectable())
- continue;
- const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
- anOwner->Unhilight (myMainPM, aHiMode);
- anOwner->State (0);
- }
+ unhighlightSelected();
AIS_Selection::ClearAndSelect (theOwner);
theOwner->State (1);
highlightSelected (theOwner, mySelectionColor);
}
+ if (theOwner == anObject->GlobalSelOwner())
+ {
+ Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
+ aState->SetHilightStatus (Standard_True);
+ aState->SetHilightColor (mySelectionColor);
+ }
+
if (theToUpdateViewer)
UpdateCurrentViewer();
}
void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
const Standard_Boolean theToUpdateViewer)
{
- if (!theObject->HasInteractiveContext())
- theObject->SetContext (this);
+ if (theObject.IsNull())
+ return;
if (HasOpenedContext())
return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
- if (theObject.IsNull() || !myObjects.IsBound (theObject) || !theObject->HasSelection (0))
+ const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
+ if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
return;
- const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
-
- if (aSel->IsEmpty())
- return;
+ if (!theObject->HasInteractiveContext())
+ theObject->SetContext (this);
- aSel->Init();
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
+ const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
if (anOwner.IsNull() || !anOwner->HasSelectable())
return;
const Handle(AIS_InteractiveObject) anObj =
Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
- if (isGlobal)
- anObj->State (aState);
- const Handle(AIS_GlobalStatus)& aStatus = myObjects (anObj);
+ Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
if (aState == 1)
{
break;
}
}
- if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated)
+ if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
return Standard_False;
- return theObj->State() == 1;
+ return theObj->GlobalSelOwner()->State() == 1;
}
//=======================================================================