#include <TCollection_ExtendedString.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TopLoc_Location.hxx>
-#include <TopoDS_Shape.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_Light.hxx>
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
+namespace
+{
+ TopoDS_Shape AIS_myDummyShape;
+}
+
//=======================================================================
//function : highlightWithColor
//purpose :
//=======================================================================
void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Quantity_NameOfColor theColor,
const Handle(V3d_Viewer)& theViewer)
{
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
if (anObj.IsNull())
+ {
return;
- const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
+ }
+
+ const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner);
+ const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
myMainPM->BeginImmediateDraw();
- theOwner->HilightWithColor (myMainPM, theColor, aHiMode);
+ theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
}
//function : highlightSelected
//purpose :
//=======================================================================
-void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Quantity_NameOfColor theSelColor)
+void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
{
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
if (anObj.IsNull())
+ {
return;
- const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
+ }
if (!theOwner->IsAutoHilight())
{
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- const Handle(AIS_Selection)& aCurSel = AIS_Selection::CurrentSelection();
SelectMgr_SequenceOfOwner aSeq;
- for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner) aSelOwnr =
- Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
- if (aSelOwnr->Selectable() != anObj)
- continue;
- aSeq.Append (aSelOwnr);
+ if (aSelIter.Value()->IsSameSelectable (anObj))
+ {
+ aSeq.Append (aSelIter.Value());
+ }
}
anObj->HilightSelected (myMainPM, aSeq);
}
else
{
- theOwner->HilightWithColor (myMainPM, theSelColor, aHiMode);
+ const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
+ const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
+ theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
+ }
+}
+
+//=======================================================================
+//function : highlightGlobal
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
+ const Handle(Prs3d_Drawer)& theStyle,
+ const Standard_Integer theDispMode) const
+{
+ if (theObj.IsNull())
+ {
+ return;
+ }
+
+ const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode);
+ const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
+
+ if (aGlobOwner.IsNull())
+ {
+ myMainPM->Color (theObj, theStyle, aHiMode);
+ return;
+ }
+
+ if (!aGlobOwner->IsAutoHilight())
+ {
+ SelectMgr_SequenceOfOwner aSeq;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ if (aSelIter.Value()->IsSameSelectable (theObj))
+ {
+ aSeq.Append (aSelIter.Value());
+ }
+ }
+ theObj->HilightSelected (myMainPM, aSeq);
+ }
+ else
+ {
+ aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode);
}
}
//=======================================================================
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())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
- if (anOwner.IsNull() || !anOwner->HasSelectable())
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
+ const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ Handle(AIS_GlobalStatus) aStatus;
+ if (!myObjects.Find (anInteractive, aStatus))
+ {
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);
+ anOwner->Unhilight (myMainPM);
if (theIsToHilightSubIntensity)
{
- if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn())
+ if (aStatus->IsSubIntensityOn())
{
- anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode);
+ const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode());
+ highlightWithSubintensity (anOwner, aHiMode);
}
}
}
else
{
- if (!anObjToClear.Contains (anInteractive))
- anObjToClear.Add (anInteractive);
+ anObjToClear.Add (anInteractive);
}
- anOwner->State (0);
+ anOwner->SetSelected (Standard_False);
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);
+ myMainPM->Unhighlight (anObj);
anObj->ClearSelected();
}
}
+//=======================================================================
+//function : unhighlightGlobal
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const
+{
+ if (theObj.IsNull())
+ {
+ return;
+ }
+
+ const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
+ if (aGlobOwner.IsNull())
+ {
+ myMainPM->Unhighlight (theObj);
+ return;
+ }
+
+ if (aGlobOwner->IsAutoHilight())
+ {
+ aGlobOwner->Unhilight (myMainPM);
+ }
+ else
+ {
+ myMainPM->Unhighlight (theObj);
+ theObj->ClearSelected();
+ }
+}
+
+//=======================================================================
+//function : turnOnSubintensity
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Integer theDispMode,
+ const Standard_Boolean theIsDisplayedOnly) const
+{
+ // the only differ with selection highlight is color, so sync transparency values
+ const Handle(Prs3d_Drawer)& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
+ aSubStyle->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
+
+ if (theObject.IsNull())
+ {
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next())
+ {
+ const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value();
+ if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
+ continue;
+
+ aStatus->SubIntensityOn();
+ myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
+ }
+ }
+ else
+ {
+ Handle(AIS_GlobalStatus) aStatus;
+ if (!myObjects.Find (theObject, aStatus))
+ return;
+
+ if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
+ return;
+
+ aStatus->SubIntensityOn();
+ myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
+ }
+}
+
+//=======================================================================
+//function : highlightWithSubintensity
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Integer theMode) const
+{
+ // the only differ with selection highlight is color, so
+ // sync transparency values
+ myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
+
+ myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
+}
+
+//=======================================================================
+//function : highlightWithSubintensity
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Standard_Integer theMode) const
+{
+ // the only differ with selection highlight is color, so
+ // sync transparency values
+ myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
+
+ theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
+}
+
//=======================================================================
//function : MoveTo
//purpose :
return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
}
- myAISCurDetected = 0;
- myAISDetectedSeq.Clear();
+ myCurDetected = 0;
+ myCurHighlighted = 0;
+ myDetectedSeq.Clear();
if (theView->Viewer() != myMainVwr)
{
{
aNewDetected = aDetIter;
}
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (!anObj.IsNull())
- {
- myAISDetectedSeq.Append (anObj);
- }
+
+ myDetectedSeq.Append (aDetIter);
}
if (aNewDetected >= 1)
{
- // does nothing if previously detected object is equal to the current one
+ myCurHighlighted = myDetectedSeq.Lower();
+
+ // Does nothing if previously detected object is equal to the current one.
+ // However in advanced selection modes the owners comparison
+ // is not effective because in that case only one owner manage the
+ // selection in current selection mode. It is necessary to check the current detected
+ // entity and hilight it only if the detected entity is not the same as
+ // previous detected (IsForcedHilight call)
Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
- if (aNewPickedOwner == myLastPicked)
+ if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
{
return myLastPicked->IsSelected()
? AIS_SOD_Selected
// method call. As result it is necessary to rehighligt it with mySelectionColor.
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
- myMainPM->ClearImmediateDraw();
- const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
- const Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
- if (!myLastPicked->IsSelected())
- {
- myLastPicked->Unhilight (myMainPM, aHiMod);
- toUpdateViewer = Standard_True;
- }
- else if (myToHilightSelected)
- {
- highlightWithColor (aNewPickedOwner, mySelectionColor, theView->Viewer());
- toUpdateViewer = Standard_True;
- }
+ clearDynamicHighlight();
+ toUpdateViewer = Standard_True;
}
// initialize myLastPicked field with currently detected object
{
if (!myLastPicked->IsSelected() || myToHilightSelected)
{
- highlightWithColor (myLastPicked, myHilightColor, theView->Viewer());
+ highlightWithColor (myLastPicked, theView->Viewer());
toUpdateViewer = Standard_True;
}
aStatus = AIS_SOD_Nothing;
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
- myMainPM->ClearImmediateDraw();
- const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
- Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
- if (!myLastPicked->IsSelected())
- {
- if (myLastPicked->IsAutoHilight())
- {
- myLastPicked->Unhilight (myMainPM, aHiMod);
- }
- toUpdateViewer = Standard_True;
- }
- else if (myToHilightSelected)
- {
- highlightSelected (myLastPicked, mySelectionColor);
- toUpdateViewer = Standard_True;
- }
+ clearDynamicHighlight();
+ toUpdateViewer = Standard_True;
}
myLastinMain.Nullify();
return aStatus;
}
+//=======================================================================
+//function : AddSelect
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
+{
+ if (HasOpenedContext())
+ {
+ return myLocalContexts(myCurLocalIndex)->AddSelect (theObject);
+ }
+ mySelection->AddSelect (theObject);
+
+ Standard_Integer aSelNum = NbSelected();
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
+}
+
//=======================================================================
//function : Select
//purpose :
}
aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
-
- for (aSelector->Init(); aSelector->More(); aSelector->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked();
+ const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter);
if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
continue;
- AIS_Selection::Select (aCurOwner);
- aCurOwner->State (1);
+ mySelection->Select (aCurOwner);
+ aCurOwner->SetSelected (Standard_True);
}
HilightSelected (toUpdateViewer);
}
aSelector->Pick (thePolyline, theView);
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
-
- for (aSelector->Init(); aSelector->More(); aSelector->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
- AIS_Selection::Select (anOwner);
- anOwner->State (1);
+ mySelection->Select (anOwner);
+ anOwner->SetSelected (Standard_True);
}
HilightSelected (toUpdateViewer);
}
}
- myMainPM->ClearImmediateDraw();
+ clearDynamicHighlight();
if (myWasLastMain && !myLastinMain.IsNull())
{
- if(!myLastinMain->IsSelected())
+ if (!myLastinMain->IsSelected() || myLastinMain->IsForcedHilight())
{
SetSelected (myLastinMain, Standard_False);
if(toUpdateViewer)
{
unhighlightSelected (Standard_True);
- AIS_Selection::Select();
+ mySelection->Clear();
if (toUpdateViewer && myWasLastMain)
{
UpdateCurrentViewer();
}
}
- myMainPM->ClearImmediateDraw();
+ clearDynamicHighlight();
if (myWasLastMain && !myLastinMain.IsNull())
{
AddOrRemoveSelected (myLastinMain, toUpdateViewer);
}
aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- for (aSelector->Init(); aSelector->More(); aSelector->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
- AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
- Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
- anOwner->State (aState);
+ AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
+ anOwner->SetSelected (aSelStatus == AIS_SS_Added);
}
HilightSelected (toUpdateViewer);
}
aSelector->Pick (thePolyline, theView);
-
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- for (aSelector->Init(); aSelector->More(); aSelector->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
- AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
- Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
- anOwner->State (aState);
+ AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
+ anOwner->SetSelected (aSelStatus == AIS_SS_Added);
}
HilightSelected (toUpdateViewer);
}
// In case of selection without using local context
- myMainPM->ClearImmediateDraw();
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
+ clearDynamicHighlight();
AIS_MapOfObjSelectedOwners anObjOwnerMap;
- for (aSel->Init(); aSel->More(); aSel->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
- if (!anOwner.IsNull() && anOwner->HasSelectable())
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
+ Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
+ if (anOwner == anObj->GlobalSelOwner())
{
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (anOwner == anObj->GlobalSelOwner())
- {
- Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj);
- aState->SetHilightStatus (Standard_True);
- aState->SetHilightColor (mySelectionColor);
- }
- anOwner->State (1);
- if (!anOwner->IsAutoHilight())
+ aState->SetHilightStatus (Standard_True);
+ aState->SetHilightStyle (anObjSelStyle);
+ }
+ anOwner->SetSelected (Standard_True);
+ if (!anOwner->IsAutoHilight())
+ {
+ NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
+ if (anObjOwnerMap.Find (anObj, aSeq))
{
- NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
- if (anObjOwnerMap.Find (anObj, aSeq))
- {
- aSeq->Append (anOwner);
- }
- else
- {
- aSeq = new SelectMgr_SequenceOfOwner();
- aSeq->Append (anOwner);
- anObjOwnerMap.Bind (anObj, aSeq);
- }
+ aSeq->Append (anOwner);
}
else
{
- const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
- anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
+ aSeq = new SelectMgr_SequenceOfOwner();
+ aSeq->Append (anOwner);
+ anObjOwnerMap.Bind (anObj, aSeq);
}
}
+ else
+ {
+ const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode());
+ anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
+ }
}
if (!anObjOwnerMap.IsEmpty())
return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
}
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
- for (aSel->Init(); aSel->More(); aSel->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
- if (!anOwner.IsNull() && anOwner->HasSelectable())
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (anOwner == anObj->GlobalSelOwner())
{
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (anOwner == anObj->GlobalSelOwner())
- {
- myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
- }
- anOwner->State (0);
- const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0;
- anOwner->Unhilight (myMainPM, aHiMode);
+ myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
}
+
+ anOwner->SetSelected (Standard_False);
+ anOwner->Unhilight (myMainPM);
}
if (theToUpdateViewer)
unhighlightSelected();
- AIS_Selection::Select();
- myMainPM->ClearImmediateDraw();
+ mySelection->Clear();
+ clearDynamicHighlight();
if (theToUpdateViewer)
UpdateCurrentViewer();
void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
const Standard_Boolean theToUpdateViewer)
{
- if(HasOpenedContext())
+ if (HasOpenedContext())
{
return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
}
if (theObject.IsNull())
+ {
return;
- if(!myObjects.IsBound (theObject))
+ }
+
+ if (!myObjects.IsBound (theObject))
+ {
Display (theObject, Standard_False);
- if (theObject->HasSelection (0))
+ }
+ if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
+ {
return;
+ }
+ Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
+ if (anOwner.IsNull())
+ {
+ return;
+ }
+ const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
{
- Quantity_NameOfColor aHiCol;
- Standard_Boolean hasHiCol = Standard_False;
- if (IsHilighted (theObject, hasHiCol, aHiCol))
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (HighlightStyle (theObject, aCustomStyle))
{
- if (hasHiCol && aHiCol!= mySelectionColor)
+ if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
{
- HilightWithColor (theObject, mySelectionColor, theToUpdateViewer);
+ HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
}
}
return;
}
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
- for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
+ for (mySelection->Init(); mySelection->More(); mySelection->Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
- if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
+ const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value();
+ if (!myFilters->IsOk (aSelOwner))
+ {
continue;
+ }
- Handle(AIS_InteractiveObject) aSelectable =
- Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
Unhilight (aSelectable, Standard_False);
- anOwner->State (0);
- if (anOwner == aSelectable->GlobalSelOwner())
+ aSelOwner->SetSelected (Standard_False);
+ if (aSelOwner == aSelectable->GlobalSelOwner())
{
myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
}
}
// added to avoid untimely viewer update...
- const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
- if (aSel->IsEmpty())
- return;
- aSel->Init();
- Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
- AIS_Selection::ClearAndSelect (anOwner);
- 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))
+ mySelection->ClearAndSelect (anOwner);
+
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (HighlightStyle (theObject, aCustomStyle))
{
- if (hasHiCol && aHiCol!= mySelectionColor)
+ if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
{
- HilightWithColor (theObject, mySelectionColor, Standard_False);
+ HilightWithColor (theObject, anObjSelStyle, Standard_False);
}
}
else
{
- HilightWithColor (theObject, mySelectionColor, Standard_False);
+ HilightWithColor (theObject, anObjSelStyle, Standard_False);
}
+ anOwner->SetSelected (Standard_True);
if (theToUpdateViewer)
UpdateCurrentViewer();
if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
return;
- const Handle(AIS_InteractiveObject) anObject =
- Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
-
- if (NbSelected() == 1 && theOwner->IsSelected())
+ const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
+ if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
{
- Quantity_NameOfColor aCustomColor;
- Standard_Boolean isCustomColorSet;
- if (IsHilighted (theOwner, isCustomColorSet, aCustomColor))
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (HighlightStyle (theOwner, aCustomStyle))
{
- if (isCustomColorSet && aCustomColor != mySelectionColor)
+ if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
{
const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
- theOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
+ theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
}
}
return;
unhighlightSelected();
- AIS_Selection::ClearAndSelect (theOwner);
- theOwner->State (1);
- Quantity_NameOfColor aCustomColor;
- Standard_Boolean isCustomColorSet;
- if (!IsHilighted (theOwner, isCustomColorSet, aCustomColor) || (isCustomColorSet && aCustomColor!= mySelectionColor))
+ mySelection->ClearAndSelect (theOwner);
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (!HighlightStyle (theOwner, aCustomStyle) ||
+ (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
{
- highlightSelected (theOwner, mySelectionColor);
+ theOwner->SetSelected (Standard_True);
+ highlightSelected (theOwner);
}
+ theOwner->SetSelected (Standard_True);
if (theOwner == anObject->GlobalSelOwner())
{
Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
aState->SetHilightStatus (Standard_True);
- aState->SetHilightColor (mySelectionColor);
+ aState->SetHilightStyle (anObjSelStyle);
}
if (theToUpdateViewer)
if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
return;
- if (!theObject->HasInteractiveContext())
- theObject->SetContext (this);
-
+ setContextToObject (theObject);
const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
if (anOwner.IsNull() || !anOwner->HasSelectable())
if (theOwner.IsNull() || !theOwner->HasSelectable())
return;
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
- Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
-
- AIS_SelectStatus aSelStat = AIS_Selection::Select (theOwner);
-
- Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0;
- theOwner->State (aState);
+ AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
+ theOwner->SetSelected (aSelStat == AIS_SS_Added);
const Handle(AIS_InteractiveObject) anObj =
Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
- const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
- if (aState == 1)
+ if (theOwner->IsSelected())
{
- highlightSelected (theOwner, mySelectionColor);
+ highlightSelected (theOwner);
if (isGlobal)
{
aStatus->SetHilightStatus (Standard_True);
- aStatus->SetHilightColor (mySelectionColor);
+ aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
}
}
else
{
if (theOwner->IsAutoHilight())
- theOwner->Unhilight (myMainPM, aHiMode);
+ {
+ theOwner->Unhilight (myMainPM);
+ }
else
+ {
anObj->ClearSelected();
+ }
aStatus->SetHilightStatus (Standard_False);
- aStatus->SetHilightColor (Quantity_NOC_WHITE);
+ aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
}
if (theToUpdateViewer)
if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
return Standard_False;
- return theObj->GlobalSelOwner()->State() == 1;
+ return theObj->GlobalSelOwner()->IsSelected();
}
//=======================================================================
return;
}
- AIS_Selection::Selection (myCurrentName.ToCString())->Init();
+ mySelection->Init();
}
//=======================================================================
if (HasOpenedContext())
return myLocalContexts (myCurLocalIndex)->MoreSelected();
- return AIS_Selection::Selection (myCurrentName.ToCString())->More();
+ return mySelection->More();
}
//=======================================================================
if(HasOpenedContext())
{
return myLocalContexts (myCurLocalIndex)->NextSelected();
- return;
}
- AIS_Selection::Selection (myCurrentName.ToCString())->Next();
+ mySelection->Next();
}
//=======================================================================
{
return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
}
+ if (!mySelection->More())
+ return Standard_False;
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
- return !aShape.IsNull();
+ const Handle(StdSelect_BRepOwner) anOwner =
+ Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
+
+ return !anOwner.IsNull() && anOwner->HasShape();
}
//=======================================================================
return myLocalContexts (myCurLocalIndex)->SelectedShape();
}
- if (AIS_Selection::Selection (myCurrentName.ToCString())->Extent() == 0)
+ if (!mySelection->More())
return TopoDS_Shape();
const Handle(StdSelect_BRepOwner) anOwner =
- Handle(StdSelect_BRepOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
- if (!anOwner->HasSelectable())
+ Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
+ if (anOwner.IsNull() || !anOwner->HasSelectable())
return TopoDS_Shape();
return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
}
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
- if (anOwner.IsNull() || !anOwner->HasSelectable())
- return NULL;
-
- return Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ return !mySelection->More()
+ ? Handle(AIS_InteractiveObject)()
+ : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
}
//=======================================================================
//function : SelectedOwner
return myLocalContexts(myCurLocalIndex)->SelectedOwner();
}
- Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
-
- return aCurSel->Extent() > 0 ?
- Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()) : NULL;
+ return !mySelection->More()
+ ? Handle(SelectMgr_EntityOwner)()
+ : mySelection->Value();
}
//=======================================================================
return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
}
-
+//=======================================================================
+//function : HasNextDetected
+//purpose :
+//=======================================================================
Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
{
- if(!HasOpenedContext())
- return Standard_False; // temporaire
- else
+ if (HasOpenedContext())
+ {
return myLocalContexts(myCurLocalIndex)->HasNextDetected();
-
+ }
+
+ return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
}
Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
const Standard_Boolean theToRedrawImmediate)
{
- return HasOpenedContext()
- ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
- : 0;
-
+ if (HasOpenedContext())
+ {
+ return myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate);
+ }
+
+ myMainPM->ClearImmediateDraw();
+ if (myDetectedSeq.IsEmpty())
+ {
+ return 0;
+ }
+
+ if (++myCurHighlighted > myDetectedSeq.Upper())
+ {
+ myCurHighlighted = myDetectedSeq.Lower();
+ }
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
+ if (anOwner.IsNull())
+ {
+ return 0;
+ }
+
+ highlightWithColor (anOwner, theView->Viewer());
+ myLastPicked = anOwner;
+ myLastinMain = myLastPicked;
+
+ if (theToRedrawImmediate)
+ {
+ myMainPM->RedrawImmediate (theView->Viewer());
+ myMainVwr->RedrawImmediate();
+ }
+
+ return myCurHighlighted;
}
//=======================================================================
-//function : HilightNextDetected
+//function : HilightPreviousDetected
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
const Standard_Boolean theToRedrawImmediate)
{
- return HasOpenedContext()
- ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
- : 0;
-
+ if (HasOpenedContext())
+ {
+ return myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate);
+ }
+
+ myMainPM->ClearImmediateDraw();
+ if (myDetectedSeq.IsEmpty())
+ {
+ return 0;
+ }
+
+ if (--myCurHighlighted < myDetectedSeq.Lower())
+ {
+ myCurHighlighted = myDetectedSeq.Upper();
+ }
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
+ if (anOwner.IsNull())
+ {
+ return 0;
+ }
+
+ highlightWithColor (anOwner, theView->Viewer());
+ myLastPicked = anOwner;
+ myLastinMain = myLastPicked;
+
+ if (theToRedrawImmediate)
+ {
+ myMainPM->RedrawImmediate (theView->Viewer());
+ myMainVwr->RedrawImmediate();
+ }
+
+ return myCurHighlighted;
}
//=======================================================================
{
if (HasOpenedContext())
{
- myLocalContexts(myCurLocalIndex)->InitDetected();
+ myLocalContexts (myCurLocalIndex)->InitDetected();
return;
}
- if(myAISDetectedSeq.Length() != 0)
+ if (!myDetectedSeq.IsEmpty())
{
- myAISCurDetected = 1;
+ myCurDetected = myDetectedSeq.Lower();
}
}
{
if (HasOpenedContext())
{
- return myLocalContexts(myCurLocalIndex)->MoreDetected();
+ return myLocalContexts (myCurLocalIndex)->MoreDetected();
}
- return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
- Standard_True : Standard_False;
+ return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper();
}
//=======================================================================
//=======================================================================
void AIS_InteractiveContext::NextDetected()
{
- if(HasOpenedContext())
+ if (HasOpenedContext())
{
- myLocalContexts(myCurLocalIndex)->NextDetected();
+ myLocalContexts (myCurLocalIndex)->NextDetected();
return;
}
- myAISCurDetected++;
+ myCurDetected++;
}
//=======================================================================
return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
}
- static TopoDS_Shape aDummyShape;
-
+ Standard_DISABLE_DEPRECATION_WARNINGS
Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
+ Standard_ENABLE_DEPRECATION_WARNINGS
if (aCurrentShape.IsNull())
{
- return aDummyShape;
+ return AIS_myDummyShape;
}
return aCurrentShape->Shape();
return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
}
- return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
+ return MoreDetected()
+ ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
+ : NULL;
}
//=======================================================================