// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-// Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
+#include <AIS_InteractiveContext.hxx>
-#include <AIS_ConnectedInteractive.hxx>
-#include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
+#include <AIS_ConnectedInteractive.hxx>
#include <AIS_GlobalStatus.hxx>
-#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <AIS_LocalContext.hxx>
-#include <AIS_LocalStatus.hxx>
#include <AIS_MapIteratorOfMapOfInteractive.hxx>
#include <AIS_MultipleConnectedInteractive.hxx>
#include <AIS_Shape.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
-#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentableObject.hxx>
#include <Quantity_Color.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
-//#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
namespace
{
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners;
+
+ //! Initialize default highlighting attributes.
+ static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer,
+ const Quantity_Color& theColor)
+ {
+ theDrawer->SetMethod (Aspect_TOHM_COLOR);
+ theDrawer->SetDisplayMode (0);
+ theDrawer->SetColor (theColor);
+
+ theDrawer->SetupOwnShadingAspect();
+ theDrawer->SetupOwnPointAspect();
+ theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
+ theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
+ theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect());
+ *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect();
+ theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
+ theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
+ theDrawer->SetDatumAspect (new Prs3d_DatumAspect());
+
+ theDrawer->ShadingAspect()->SetColor (theColor);
+ theDrawer->WireAspect()->SetColor (theColor);
+ theDrawer->LineAspect()->SetColor (theColor);
+ theDrawer->PlaneAspect()->ArrowAspect()->SetColor (theColor);
+ theDrawer->PlaneAspect()->IsoAspect()->SetColor (theColor);
+ theDrawer->PlaneAspect()->EdgesAspect()->SetColor (theColor);
+ theDrawer->FreeBoundaryAspect()->SetColor (theColor);
+ theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
+ theDrawer->PointAspect()->SetColor (theColor);
+ for (Standard_Integer aPartIter = 0; aPartIter < Prs3d_DP_None; ++aPartIter)
+ {
+ if (Handle(Prs3d_LineAspect) aLineAsp = theDrawer->DatumAspect()->LineAspect ((Prs3d_DatumParts )aPartIter))
+ {
+ aLineAsp->SetColor (theColor);
+ }
+ }
+
+ theDrawer->WireAspect()->SetWidth (2.0);
+ theDrawer->LineAspect()->SetWidth (2.0);
+ theDrawer->PlaneAspect()->EdgesAspect()->SetWidth (2.0);
+ theDrawer->FreeBoundaryAspect() ->SetWidth (2.0);
+ theDrawer->UnFreeBoundaryAspect()->SetWidth (2.0);
+ theDrawer->PointAspect()->SetTypeOfMarker (Aspect_TOM_O_POINT);
+ theDrawer->PointAspect()->SetScale (2.0);
+
+ // the triangulation should be computed using main presentation attributes,
+ // and should not be overridden by highlighting
+ theDrawer->SetAutoTriangulation (Standard_False);
+ }
}
//=======================================================================
//=======================================================================
AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
-mgrSelector(new SelectMgr_SelectionManager()),
myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())),
myMainVwr(MainViewer),
myMainSel(new StdSelect_ViewerSelector3d()),
-myWasLastMain(Standard_False),
-myCurrentTouched(Standard_False),
-mySelectedTouched(Standard_False),
myToHilightSelected(Standard_True),
-myFilters(new SelectMgr_OrFilter()),
-myDefaultDrawer(new Prs3d_Drawer()),
mySelection(new AIS_Selection()),
-myDefaultColor(Quantity_NOC_GOLDENROD),
-myHilightColor(Quantity_NOC_CYAN1),
-mySelectionColor(Quantity_NOC_GRAY80),
-myPreselectionColor(Quantity_NOC_GREEN),
-mySubIntensity(Quantity_NOC_GRAY40),
-myDisplayMode(0),
-myCurLocalIndex(0),
-myAISCurDetected(0),
-myZDetectionFlag(0),
+myFilters (new SelectMgr_AndOrFilter(SelectMgr_FilterType_OR)),
+myDefaultDrawer(new Prs3d_Drawer()),
+myCurDetected(0),
+myCurHighlighted(0),
+myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable),
+myAutoHilight(Standard_True),
myIsAutoActivateSelMode(Standard_True)
-{
+{
+ mgrSelector = new SelectMgr_SelectionManager (myMainSel);
+
+ myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
+ myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer();
+ myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer();
+ myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer();
+ myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer();
+ myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer();
+
+ myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default);
+ myDefaultDrawer->SetDisplayMode(0);
+ {
+ const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic];
+ aStyle->Link (myDefaultDrawer);
+ initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1);
+ aStyle->SetZLayer(Graphic3d_ZLayerId_Top);
+ }
+ {
+ const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic];
+ aStyle->Link (myDefaultDrawer);
+ initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1);
+ aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost);
+ }
+ {
+ const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected];
+ aStyle->Link (myDefaultDrawer);
+ initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80);
+ aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
+ }
+ {
+ const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected];
+ aStyle->Link (myDefaultDrawer);
+ initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80);
+ aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
+ }
+ {
+ const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
+ aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
+ aStyle->SetMethod(Aspect_TOHM_COLOR);
+ aStyle->SetColor (Quantity_NOC_GRAY40);
+ }
+
InitAttributes();
}
-void AIS_InteractiveContext::Delete() const
+//=======================================================================
+//function : ~AIS_InteractiveContext
+//purpose :
+//=======================================================================
+AIS_InteractiveContext::~AIS_InteractiveContext()
{
// clear the current selection
- mySelection->Select();
-
- // let's remove one reference explicitly. this operation's supposed to
- // be performed when mgrSelector will be destroyed but anyway...
- const Handle(SelectMgr_ViewerSelector)& aSelector = myMainSel; // to avoid ambiguity
- mgrSelector->Remove (aSelector);
+ mySelection->Clear();
+ mgrSelector.Nullify();
Handle(AIS_InteractiveContext) aNullContext;
for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
- Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
+ const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key();
anObj->SetContext (aNullContext);
- for (anObj->Init(); anObj->More(); anObj->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- anObj->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Renew);
+ aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew);
}
}
- MMgt_TShared::Delete();
}
//=======================================================================
-//function : UpdateCurrentViewer
-//purpose :
+//function : LastActiveView
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::UpdateCurrentViewer()
+Handle(V3d_View) AIS_InteractiveContext::LastActiveView() const
{
- if (!myMainVwr.IsNull())
- myMainVwr->Update();
-}
+ if (myLastActiveView == NULL
+ || myMainVwr.IsNull())
+ {
+ return Handle(V3d_View)();
+ }
+ // as a precaution - check that myLastActiveView pointer is a valid active View
+ for (V3d_ListOfViewIterator aViewIter = myMainVwr->ActiveViewIterator(); aViewIter.More(); aViewIter.Next())
+ {
+ if (aViewIter.Value() == myLastActiveView)
+ {
+ return aViewIter.Value();
+ }
+ }
+ return Handle(V3d_View)();
+}
//=======================================================================
-//function : DomainOfMainViewer
+//function : UpdateCurrentViewer
//purpose :
//=======================================================================
-Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
+void AIS_InteractiveContext::UpdateCurrentViewer()
{
- return myMainVwr->Domain();
-
+ if (!myMainVwr.IsNull())
+ myMainVwr->Update();
}
//=======================================================================
//function : DisplayedObjects
//purpose :
//=======================================================================
-void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
- const Standard_Boolean theOnlyFromNeutral) const
+void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO) const
{
- if (!HasOpenedContext()
- || theOnlyFromNeutral)
- {
- for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
- {
- if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
- {
- theListOfIO.Append (anObjIter.Key());
- }
- }
- return;
- }
-
- // neutral point
- TColStd_MapOfTransient aDispMap;
for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
{
- aDispMap.Add (anObjIter.Key());
+ theListOfIO.Append (anObjIter.Key());
}
}
-
- // parse all local contexts...
- for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
- {
- const Handle(AIS_LocalContext)& aLocCtx = aCtxIter.Value();
- aLocCtx->DisplayedObjects (aDispMap);
- }
-
- Handle(AIS_InteractiveObject) anObj;
- for (TColStd_MapIteratorOfMapOfTransient aDispMapIter (aDispMap); aDispMapIter.More(); aDispMapIter.Next())
- {
- const Handle(Standard_Transient)& aTransient = aDispMapIter.Key();
- anObj = Handle(AIS_InteractiveObject)::DownCast (aTransient);
- theListOfIO.Append (anObj);
- }
}
//=======================================================================
//=======================================================================
void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
const Standard_Integer theSign,
- AIS_ListOfInteractive& theListOfIO,
- const Standard_Boolean /*OnlyFromNeutral*/) const
+ AIS_ListOfInteractive& theListOfIO) const
{
ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
}
Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
-
- Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
- theToUpdateViewer, theIObj->AcceptShapeDecomposition());
+ Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1, theToUpdateViewer);
}
//=======================================================================
const Standard_Integer theDispMode,
const Standard_Integer theSelectionMode,
const Standard_Boolean theToUpdateViewer,
- const Standard_Boolean theToAllowDecomposition,
const AIS_DisplayStatus theDispStatus)
{
if (theIObj.IsNull())
if (theDispStatus == AIS_DS_Erased)
{
Erase (theIObj, theToUpdateViewer);
- Load (theIObj, theSelectionMode, theToAllowDecomposition);
- return;
- }
-
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- if (theDispStatus == AIS_DS_Temporary
- && !HasOpenedContext())
- {
- return;
- }
- else if (HasOpenedContext())
- {
- if (theDispStatus == AIS_DS_None
- || theDispStatus == AIS_DS_Temporary)
+ Load (theIObj, theSelectionMode);
+ if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theIObj))
{
- myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
- if (theToUpdateViewer)
- {
- myMainVwr->Update();
- }
- return;
+ (*aStatusPtr)->SetDisplayMode (theDispMode);
}
+ return;
}
+ setContextToObject (theIObj);
if (!myObjects.IsBound (theIObj))
{
- Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
- myObjects.Bind (theIObj, aStatus);
- Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->RegisterObject (theIObj);
+ setObjectStatus (theIObj, AIS_DS_Displayed, theDispMode, theSelectionMode);
+ myMainVwr->StructureManager()->RegisterObject (theIObj);
myMainPM->Display(theIObj, theDispMode);
if (theSelectionMode != -1)
{
{
mgrSelector->Load (theIObj);
}
- mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
+ mgrSelector->Activate (theIObj, theSelectionMode);
}
}
else
{
Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
- if (aStatus->GraphicStatus() == AIS_DS_Temporary)
- {
- return;
- }
- // Erase presentations for all display modes different from aDispMode.
+ // Mark the presentation modes hidden of interactive object different from aDispMode.
// Then make sure aDispMode is displayed and maybe highlighted.
// Finally, activate selection mode <SelMode> if not yet activated.
- TColStd_ListOfInteger aModesToRemove;
- for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+ const Standard_Integer anOldMode = aStatus->DisplayMode();
+ if (anOldMode != theDispMode)
{
- const Standard_Integer anOldMode = aDispModeIter.Value();
- if (anOldMode != theDispMode)
+ if(myMainPM->IsHighlighted (theIObj, anOldMode))
{
- aModesToRemove.Append (anOldMode);
- if(myMainPM->IsHighlighted (theIObj, anOldMode))
- {
- myMainPM->Unhighlight (theIObj, anOldMode);
- }
- myMainPM->Erase (theIObj, anOldMode);
+ unhighlightGlobal (theIObj);
}
+ myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
}
- for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
- {
- aStatus->RemoveDisplayMode (aRemModeIter.Value());
- }
-
- if (!aStatus->IsDModeIn (theDispMode))
- {
- aStatus->AddDisplayMode (theDispMode);
- }
+ aStatus->SetDisplayMode (theDispMode);
myMainPM->Display (theIObj, theDispMode);
aStatus->SetGraphicStatus (AIS_DS_Displayed);
if (aStatus->IsHilighted())
{
- const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
- myMainPM->Color (theIObj, aStatus->HilightColor(), aHiMod);
+ highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode);
}
if (theSelectionMode != -1)
{
{
if (!aStatus->IsSModeIn (theSelectionMode))
aStatus->AddSelectionMode (theSelectionMode);
- mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
+ mgrSelector->Activate (theIObj, theSelectionMode);
}
}
}
//purpose :
//=======================================================================
void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Integer theSelMode,
- const Standard_Boolean theToAllowDecomposition)
+ const Standard_Integer theSelMode)
{
if (theIObj.IsNull())
{
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- if (HasOpenedContext())
+ setContextToObject (theIObj);
+ if (!myObjects.IsBound (theIObj))
{
- myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
- return;
+ Standard_Integer aDispMode, aHiMod, aSelModeDef;
+ GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
+ setObjectStatus (theIObj, AIS_DS_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef);
+ myMainVwr->StructureManager()->RegisterObject (theIObj);
}
- if (theSelMode == -1
- && !theToAllowDecomposition)
+ // Register theIObj in the selection manager to prepare further activation of selection
+ const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
+ if (!mgrSelector->Contains (anObj))
{
- if (!myObjects.IsBound (theIObj))
- {
- Standard_Integer aDispMode, aHiMod, aSelModeDef;
- GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
- Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, aSelModeDef);
- myObjects.Bind (theIObj, aStatus);
- }
-
- // Register theIObj in the selection manager to prepare further activation of selection
- const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
- if (!mgrSelector->Contains (anObj))
- {
- mgrSelector->Load (theIObj);
- }
+ mgrSelector->Load (theIObj);
}
}
theIObj->ClearSelected();
}
- Standard_Boolean wasInCtx = Standard_False;
- if (HasOpenedContext())
- {
- // First it is checked if it is possible to remove in the current local context
- // then one tries to remove in other local contexts, if they allow it...
- wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
- for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
- {
- if (aCtxIter.Value()->AcceptErase())
- {
- wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
- }
- }
- }
-
- if (!wasInCtx)
- {
- EraseGlobal (theIObj, Standard_False);
- }
-
+ EraseGlobal (theIObj, Standard_False);
if (theToUpdateViewer)
{
myMainVwr->Update();
//=======================================================================
void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
{
- if (HasOpenedContext())
- {
- return;
- }
-
for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
//=======================================================================
void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
{
- if (HasOpenedContext())
- {
- return;
- }
-
for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
//=======================================================================
void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
{
- if (HasOpenedContext())
- {
- return;
- }
-
- Standard_Boolean isFound = Standard_False;
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value());
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
Display (anObj, Standard_False);
- isFound = Standard_True;
}
- if (isFound && theToUpdateViewer)
+ if (theToUpdateViewer && !mySelection->Objects().IsEmpty())
{
myMainVwr->Update();
}
//=======================================================================
void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
{
- if (HasOpenedContext())
- {
- return;
- }
-
- Standard_Boolean isFound = Standard_False;
- mySelection->Init();
- while (mySelection->More())
+ Standard_Boolean isFound = Standard_False;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects()))
{
- Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value());
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
-
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
Erase (anObj, Standard_False);
isFound = Standard_True;
-
- mySelection->Init();
}
if (isFound && theToUpdateViewer)
}
}
-//=======================================================================
-//function :
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer WhichContext)
-{
- if(anIObj.IsNull()) return Standard_False;
-
- if(!HasOpenedContext()) return Standard_False;
- if(myObjects.IsBound(anIObj)) return Standard_False;
- if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
-
- // Protection : if one tries to preserve a temporary object
- // which is not in the local active context... rob 11-06-97
-
- Standard_Integer IsItInLocal = myCurLocalIndex;
- Standard_Boolean Found(Standard_False);
-
- while(IsItInLocal>0 && !Found){
- if(!myLocalContexts.IsBound(IsItInLocal))
- IsItInLocal--;
- else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
- Found = Standard_True;
- else
- IsItInLocal--;
- }
-
- if(!Found) return Standard_False;
-
-
-// const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
-// myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
- // CLE
- // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
- Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
- // ENDCLE
-
-
- if(LS->IsTemporary()){
- Standard_Integer DM,HM,SM;
- GetDefModes(anIObj,DM,HM,SM);
-
- SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
- if(LS->DisplayMode()!= DM ){
- Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
- myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
- }
-
- Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
- DM,
- SM,
- Standard_False);
-// GS->SubIntensityOn();
- myObjects.Bind(anIObj,GS);
- mgrSelector->Load(anIObj);
- mgrSelector->Activate(anIObj,SM,myMainSel);
-
- LS->SetTemporary(Standard_False);
- }
- return Standard_True;
-}
-
//=======================================================================
//function : DisplayStatus
//purpose :
{
return AIS_DS_None;
}
- else if (myObjects.IsBound (theIObj))
- {
- return myObjects (theIObj)->GraphicStatus();
- }
-
- for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
- {
- if (aCtxIter.Value()->IsIn (theIObj))
- {
- return AIS_DS_Temporary;
- }
- }
- return AIS_DS_None;
-}
-
-//=======================================================================
-//function : DisplayedModes
-//purpose :
-//=======================================================================
-const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
-{
- return myObjects (theIObj)->DisplayedModes();
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj);
+ return aStatus != NULL ? (*aStatus)->GraphicStatus() : AIS_DS_None;
}
//=======================================================================
return;
}
- if (HasOpenedContext())
+ if (theIObj->HasInteractiveContext())
{
- myLocalContexts (myCurLocalIndex)->Remove (theIObj);
- for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
+ if (theIObj->myCTXPtr != this)
{
- if (aCtxIter.Value()->AcceptErase())
- {
- aCtxIter.Value()->Remove (theIObj);
- }
+ throw Standard_ProgramError("AIS_InteractiveContext - object has been displayed in another context!");
}
+ theIObj->SetContext (Handle(AIS_InteractiveContext)());
}
-
ClearGlobal (theIObj, theToUpdateViewer);
}
}
//=======================================================================
-//function : ClearPrs
-//purpose :
+//function : HilightWithColor
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Integer theMode,
- const Standard_Boolean theToUpdateViewer)
+void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj,
+ const Handle(Prs3d_Drawer)& theStyle,
+ const Standard_Boolean theIsToUpdate)
{
- if (theIObj.IsNull())
- {
+ if (theObj.IsNull())
return;
- }
- if (!HasOpenedContext())
- {
- ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
+ setContextToObject (theObj);
+ if (!myObjects.IsBound (theObj))
return;
- }
- Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
- for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
- {
- if (aCtxIter.Value()->AcceptErase())
- {
- wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
- }
- }
- if (!wasInCtx)
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj);
+ aStatus->SetHilightStatus (Standard_True);
+
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
- ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
+ highlightGlobal (theObj, theStyle, aStatus->DisplayMode());
+ aStatus->SetHilightStyle (theStyle);
}
- else if (theToUpdateViewer)
- {
+
+ if (theIsToUpdate)
myMainVwr->Update();
- }
}
//=======================================================================
-//function : Hilight
-//purpose :
+//function : Unhilight
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Boolean theToUpdateViewer)
+void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
{
- if (theIObj.IsNull())
- {
- return;
- }
+ if(anIObj.IsNull()) return;
+ if(!myObjects.IsBound(anIObj)) return;
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
- if (!HasOpenedContext())
- {
- if (!myObjects.IsBound (theIObj))
- {
- return;
- }
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
+ aStatus->SetHilightStatus (Standard_False);
+ aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
- Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
- aStatus->SetHilightStatus (Standard_True);
- if (aStatus->GraphicStatus() == AIS_DS_Displayed)
- {
- Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
- myMainPM->Highlight (theIObj, aHilightMode);
- }
- }
- else
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
- myLocalContexts (myCurLocalIndex)->Hilight (theIObj);
+ unhighlightGlobal (anIObj);
}
- if (theToUpdateViewer)
- {
- myMainVwr->Update();
- }
+ if(updateviewer) myMainVwr->Update();
}
+
//=======================================================================
-//function : Hilight
-//purpose :
+//function : IsHilighted
+//purpose : Returns true if the objects global status is set to highlighted.
//=======================================================================
+Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const
+{
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ return aStatus != NULL
+ && (*aStatus)->IsHilighted();
+}
-void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
- const Quantity_NameOfColor aCol,
- const Standard_Boolean updateviewer)
+//=======================================================================
+//function : IsHilighted
+//purpose : Returns true if the owner is highlighted with selection style.
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const
{
- if(anIObj.IsNull()) return;
+ if (theOwner.IsNull() || !theOwner->HasSelectable())
+ return Standard_False;
- if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
+ const Handle(AIS_InteractiveObject) anObj =
+ Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
- if (!HasOpenedContext())
+ if (anObj->GlobalSelOwner() == theOwner)
{
- if(!myObjects.IsBound(anIObj)) return;
-
- const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
- aStatus->SetHilightStatus (Standard_True);
+ if (!myObjects.IsBound (anObj))
+ return Standard_False;
- if (aStatus->GraphicStatus() == AIS_DS_Displayed)
- {
- const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
- myMainPM->Color (anIObj, aCol, aHilightMode);
- aStatus->SetHilightColor (aCol);
- }
+ return myObjects (anObj)->IsHilighted();
}
- else
+
+ const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
+ const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
+ return theOwner->IsHilighted (myMainPM, aHiMode);
+}
+
+//=======================================================================
+//function : HighlightStyle
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj,
+ Handle(Prs3d_Drawer)& theStyle) const
+{
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ if (aStatus != NULL
+ && (*aStatus)->IsHilighted())
{
- myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
+ theStyle = (*aStatus)->HilightStyle();
+ return Standard_True;
}
- if(updateviewer) myMainVwr->Update();
+
+ theStyle.Nullify();
+ return Standard_False;
}
//=======================================================================
-//function : Unhilight
-//purpose :
+//function : HighlightStyle
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
+Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
+ Handle(Prs3d_Drawer)& theStyle) const
{
- if(anIObj.IsNull()) return;
+ if (theOwner.IsNull() || !theOwner->HasSelectable())
+ return Standard_False;
- if (!HasOpenedContext())
+ if (IsHilighted (theOwner))
{
- if(!myObjects.IsBound(anIObj)) return;
-
- const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
- aStatus->SetHilightStatus (Standard_False);
- aStatus->SetHilightColor(Quantity_NOC_WHITE);
-
- if (aStatus->GraphicStatus() == AIS_DS_Displayed)
- {
- Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
- myMainPM->Unhighlight (anIObj, aHilightMode);
- }
- }
- else
- {
- myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
- }
- if(updateviewer) myMainVwr->Update();
-}
-
-//=======================================================================
-//function : IsHilighted
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
-{
- if(anIObj.IsNull()) return Standard_False;
-
- if (!HasOpenedContext()){
- if(!myObjects.IsBound(anIObj))
- return Standard_False;
- return myObjects(anIObj)->IsHilighted();
- }
- AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
- for(;ItM.More();ItM.Next()){
- if(ItM.Value()->IsHilighted(anIObj))
- return Standard_True;
- }
- return Standard_False;
-}
-
-Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
- Standard_Boolean& WithColor,
- Quantity_NameOfColor& TheHiCol) const
-{
- if(!HasOpenedContext()){
- if(myObjects.IsBound(anIObj)){
- const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
- if(STAT->IsHilighted()){
- if(STAT->HilightColor()!=Quantity_NOC_WHITE){
- WithColor=Standard_True;
- TheHiCol = STAT->HilightColor();
- }
- else
- WithColor = Standard_False;
- return Standard_True;
- }
- }
- return Standard_False;
- }
- Standard_Integer MaxIndex = HighestIndex();
- for(Standard_Integer i=MaxIndex;i>=1 ; i--){
- if(myLocalContexts.IsBound(i)){
- if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
- return Standard_True;
- }
-
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : IsHilighted
-//purpose : Returns true if the objects global status is set to highlighted.
-// theIsCustomColor flag defines if highlight color is not equal to OCCT's
-// default Quantity_NOC_WHITE color. If theIsCustomColor is true,
-// custom highlight color name will be stored to theCustomColorName
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner,
- Standard_Boolean& theIsCustomColor,
- Quantity_NameOfColor& theCustomColorName) const
-{
- if (theOwner.IsNull() || !theOwner->HasSelectable())
- return Standard_False;
-
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
-
- if (!myObjects.IsBound (anObj))
- return Standard_False;
-
- const Handle(AIS_GlobalStatus)& anObjStatus = myObjects (anObj);
- if (anObjStatus->IsHilighted())
- {
- if (anObjStatus->HilightColor() != Quantity_NOC_WHITE)
+ const Handle(AIS_InteractiveObject) anObj =
+ Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ if (anObj->GlobalSelOwner() == theOwner)
{
- theIsCustomColor = Standard_True;
- theCustomColorName = anObjStatus->HilightColor();
+ theStyle = myObjects (anObj)->HilightStyle();
}
else
{
- theIsCustomColor = Standard_False;
+ // since part selection style is not stored in global status,
+ // check if the object has own selection style. If not, it can
+ // only be highlighted with default selection style (because
+ // sub-intensity does not modify any selection states)
+ theStyle = getSelStyle (anObj, theOwner);
}
-
return Standard_True;
}
-
- return Standard_False;
+ else
+ {
+ theStyle.Nullify();
+ return Standard_False;
+ }
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
+Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& theObj) const
{
- if(anIObj.IsNull()) return Standard_False;
+ if(theObj.IsNull()) return Standard_False;
-
- if(myObjects.IsBound(anIObj))
- if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
- return Standard_True;
-
- AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
- for(;ItM.More();ItM.Next()){
- if(ItM.Value()->IsDisplayed(anIObj))
- return Standard_True;
- }
- return Standard_False;
-
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ return aStatus != NULL
+ && (*aStatus)->GraphicStatus() == AIS_DS_Displayed;
}
//=======================================================================
return Standard_False;
}
- if (myObjects.IsBound (theIObj))
- {
- Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
- if (aStatus->GraphicStatus() == AIS_DS_Displayed
- && aStatus->IsDModeIn (theMode))
- {
- return Standard_True;
- }
- }
-
- for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
- {
- if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
- {
- return Standard_True;
- }
- }
- return Standard_False;
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj);
+ return aStatus != NULL
+ && (*aStatus)->GraphicStatus() == AIS_DS_Displayed
+ && (*aStatus)->DisplayMode() == theMode;
}
//=======================================================================
{
return -1;
}
- else if (!myObjects.IsBound (theIObj))
- {
- return 0;
- }
- Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
- if (aStatus->GraphicStatus() == AIS_DS_Displayed
- || aStatus->GraphicStatus() == AIS_DS_Erased)
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj);
+ if (aStatus != NULL
+ && ((*aStatus)->GraphicStatus() == AIS_DS_Displayed
+ || (*aStatus)->GraphicStatus() == AIS_DS_Erased))
{
Standard_Integer aDispMode = theIObj->HasDisplayMode()
? theIObj->DisplayMode()
- : (theIObj->AcceptDisplayMode (myDisplayMode)
- ? myDisplayMode
+ : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
+ ? myDefaultDrawer->DisplayMode()
: 0);
return myMainPM->DisplayPriority (theIObj, aDispMode);
}
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- if (myObjects.IsBound (theIObj))
- {
- Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
- if (aStatus->GraphicStatus() == AIS_DS_Displayed
- || aStatus->GraphicStatus() == AIS_DS_Erased)
- {
- Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
- ? theIObj->DisplayMode()
- : (theIObj->AcceptDisplayMode (myDisplayMode)
- ? myDisplayMode
- : 0);
- myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
- }
- }
- else if (HasOpenedContext())
+ setContextToObject (theIObj);
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj);
+ if (aStatus != NULL
+ && ((*aStatus)->GraphicStatus() == AIS_DS_Displayed
+ || (*aStatus)->GraphicStatus() == AIS_DS_Erased))
{
- myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
+ Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
+ ? theIObj->DisplayMode()
+ : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
+ ? myDefaultDrawer->DisplayMode()
+ : 0);
+ myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
}
}
return;
}
- theIObj->Update (theAllModes);
+ theIObj->SetToUpdate();
+ theIObj->UpdatePresentations (theAllModes);
if (!theToUpdateViewer)
{
return;
}
- if (HasOpenedContext()
- || (myObjects.IsBound (theIObj)
- && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj);
+ if (aStatus != NULL
+ && (*aStatus)->GraphicStatus() == AIS_DS_Displayed)
{
myMainVwr->Update();
}
mgrSelector->RecomputeSelection (theIO);
- if (HasOpenedContext())
- {
- for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
- {
- myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
- }
- return;
- }
-
- if (!myObjects.IsBound (theIO) ||
- myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIO);
+ if (aStatus == NULL
+ || (*aStatus)->GraphicStatus() != AIS_DS_Displayed)
{
return;
}
TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
for (; aModesIter.More(); aModesIter.Next())
{
- mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
+ mgrSelector->Activate (theIO, aModesIter.Value());
}
}
return;
}
- TColStd_ListOfInteger aPrsModes;
- theIObj->ToBeUpdated (aPrsModes);
- for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
- {
- theIObj->Update (aPrsModesIt.Value(), Standard_False);
- }
-
+ theIObj->UpdatePresentations();
mgrSelector->Update(theIObj);
- for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
- {
- myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
- }
-
if (theUpdateViewer)
{
- if (!myObjects.IsBound (theIObj))
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj);
+ if (aStatus != NULL
+ && (*aStatus)->GraphicStatus() == AIS_DS_Displayed)
{
- return;
- }
-
- switch (myObjects (theIObj)->GraphicStatus())
- {
- case AIS_DS_Displayed:
- case AIS_DS_Temporary:
- myMainVwr->Update();
- break;
- default:
- break;
+ myMainVwr->Update();
}
}
}
theIObj->SetLocalTransformation (theLoc.Transformation());
- if (!HasOpenedContext())
- {
- mgrSelector->Update (theIObj, Standard_False);
- }
- else
- {
- Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
- mgrSelector->Update (theIObj, aTempSel, Standard_False);
- }
+ mgrSelector->Update (theIObj, Standard_False);
// if the object or its part is highlighted dynamically, it is necessary to apply location transformation
// to its highlight structure immediately
- if (!myLastPicked.IsNull() && myLastPicked->Selectable() == theIObj)
+ if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj))
{
+ const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
myLastPicked->UpdateHighlightTrsf (myMainVwr,
myMainPM,
- theIObj->HasDisplayMode() ? theIObj->DisplayMode() : 0);
+ aHiMod);
}
}
return myDefaultDrawer->DeviationCoefficient();
}
-//=======================================================================
-//function : SetHLRDeviationCoefficient
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
-{
- myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
-}
-
-//=======================================================================
-//function : HLRDeviationCoefficient
-//purpose :
-//=======================================================================
-Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
-{
- return myDefaultDrawer->HLRDeviationCoefficient();
-}
-
-//=======================================================================
-//function : SetHLRAngle
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
-{
- myDefaultDrawer->SetHLRAngle (theAngle);
-}
-
-//=======================================================================
-//function : SetHLRAngleAndDeviation
-//purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
-// and set them in myHLRAngle and in myHLRDeviationCoefficient
-// of myDefaultDrawer
-//=======================================================================
-void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
-{
- Standard_Real anOutAngl, anOutDefl;
- HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
-
- myDefaultDrawer->SetHLRAngle (anOutAngl);
- myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
-}
-
-//=======================================================================
-//function : HLRAngle
-//purpose :
-//=======================================================================
-Standard_Real AIS_InteractiveContext::HLRAngle() const
-{
- return myDefaultDrawer->HLRAngle();
-}
-
//=======================================================================
//function : SetDisplayMode
//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
- const Standard_Boolean theToUpdateViewer)
+void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode,
+ const Standard_Boolean theToUpdateViewer)
{
- if (theMode == myDisplayMode)
+ if (theMode == myDefaultDrawer->DisplayMode())
{
return;
}
}
Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
- if (aStatus->IsDModeIn (myDisplayMode))
- {
- aStatus->RemoveDisplayMode (myDisplayMode);
- }
+ aStatus->SetDisplayMode (theMode);
- aStatus->AddDisplayMode (theMode);
if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
myMainPM->Display (anObj, theMode);
- if (!myLastPicked.IsNull() && myLastPicked->Selectable() == anObj)
+ if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj))
{
myMainPM->BeginImmediateDraw();
- myMainPM->Unhighlight (anObj, myDisplayMode);
+ unhighlightGlobal (anObj);
myMainPM->EndImmediateDraw (myMainVwr);
}
if (aStatus->IsSubIntensityOn())
{
- myMainPM->Color (anObj, mySubIntensity, theMode);
+ highlightWithSubintensity (anObj, theMode);
}
- myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
+ myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False);
}
}
- myDisplayMode = theMode;
+ myDefaultDrawer->SetDisplayMode (theMode);
if (theToUpdateViewer)
{
myMainVwr->Update();
const Standard_Integer theMode,
const Standard_Boolean theToUpdateViewer)
{
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext(this);
- }
-
+ setContextToObject (theIObj);
if (!myObjects.IsBound (theIObj))
{
theIObj->SetDisplayMode (theMode);
Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
if (aStatus->GraphicStatus() != AIS_DS_Displayed)
{
+ aStatus->SetDisplayMode (theMode);
theIObj->SetDisplayMode (theMode);
return;
}
// erase presentations for all display modes different from <aMode>
- TColStd_ListOfInteger aModesToRemove;
- for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+ const Standard_Integer anOldMode = aStatus->DisplayMode();
+ if (anOldMode != theMode)
{
- const Standard_Integer anOldMode = aDispModeIter.Value();
- if (anOldMode != theMode)
+ if (myMainPM->IsHighlighted (theIObj, anOldMode))
{
- aModesToRemove.Append (anOldMode);
- if (myMainPM->IsHighlighted (theIObj, anOldMode))
- {
- myMainPM->Unhighlight (theIObj, anOldMode);
- }
- myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
+ unhighlightGlobal (theIObj);
}
+ myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
}
- for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
- {
- aStatus->RemoveDisplayMode (aRemModeIter.Value());
- }
-
- if (!aStatus->IsDModeIn (theMode))
- {
- aStatus->AddDisplayMode (theMode);
- }
+ aStatus->SetDisplayMode (theMode);
myMainPM->Display (theIObj, theMode);
- Standard_Integer aDispMode, aHiMode, aSelMode;
- GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
if (aStatus->IsHilighted())
{
- myMainPM->Highlight (theIObj, aHiMode);
+ highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode);
}
if (aStatus->IsSubIntensityOn())
{
- myMainPM->Color (theIObj, mySubIntensity, theMode);
+ highlightWithSubintensity (theIObj, theMode);
}
if (theToUpdateViewer)
}
const Standard_Integer anOldMode = theIObj->DisplayMode();
- if (myDisplayMode == anOldMode)
+ if (myDefaultDrawer->DisplayMode() == anOldMode)
{
return;
}
const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
- aStatus->RemoveDisplayMode (anOldMode);
- if (!aStatus->IsDModeIn(myDisplayMode))
- {
- aStatus->AddDisplayMode (myDisplayMode);
- }
+ aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode());
if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
if (myMainPM->IsHighlighted (theIObj, anOldMode))
{
- myMainPM->Unhighlight (theIObj, anOldMode);
+ unhighlightGlobal (theIObj);
}
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
- myMainPM->Display (theIObj, myDisplayMode);
-
- Standard_Integer aDispMode, aHiMode, aSelMode;
- GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
+ myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode());
if (aStatus->IsHilighted())
{
- myMainPM->Highlight (theIObj, aHiMode);
+ highlightSelected (theIObj->GlobalSelOwner());
}
if (aStatus->IsSubIntensityOn())
{
- myMainPM->Color (theIObj, mySubIntensity, myDisplayMode);
+ highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode());
}
if (theToUpdateViewer)
}
}
-//=======================================================================
-//function : redisplayPrsRecModes
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theIObj->RecomputeEveryPrs())
- {
- theIObj->Update (Standard_True);
- theIObj->UpdateSelection();
- }
- else
- {
- for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
- {
- theIObj->Update (aModes.Value(), Standard_False);
- }
- theIObj->UpdateSelection();
- theIObj->SetRecomputeOk();
- }
-
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
-}
-
-//=======================================================================
-//function : redisplayPrsModes
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theIObj->RecomputeEveryPrs())
- {
- theIObj->Update (Standard_True);
- theIObj->UpdateSelection();
- }
- else
- {
- TColStd_ListOfInteger aModes;
- theIObj->ToBeUpdated (aModes);
- for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
- {
- theIObj->Update (aModeIter.Value(), Standard_False);
- }
- theIObj->SetRecomputeOk();
- }
-
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
-}
-
-//=======================================================================
-//function : SetColor
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
- const Quantity_NameOfColor theColor,
- const Standard_Boolean theToUpdateViewer)
-{
- SetColor (theIObj, Quantity_Color(theColor), theToUpdateViewer);
-}
-
//=======================================================================
//function : SetColor
//purpose :
return;
}
- if (!theIObj->HasInteractiveContext())
+ setContextToObject (theIObj);
+ theIObj->SetColor (theColor);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
{
- theIObj->SetContext (this);
+ UpdateCurrentViewer();
}
- theIObj->SetColor (theColor);
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//=======================================================================
//function : SetDeviationCoefficient
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Real theCoefficient,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theIObj.IsNull())
- {
- return;
- }
-
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if (theIObj->Type() != AIS_KOI_Object
- && theIObj->Type() != AIS_KOI_Shape)
- {
- return;
- }
- else if (theIObj->Signature() != 0)
- {
- return;
- }
-
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
- aShape->SetOwnDeviationCoefficient (theCoefficient);
- redisplayPrsModes (theIObj, theToUpdateViewer);
-}
-
-//=======================================================================
-//function : SetHLRDeviationCoefficient
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Real theCoefficient,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theIObj.IsNull())
- {
- return;
- }
-
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if (theIObj->Type() != AIS_KOI_Object
- && theIObj->Type() != AIS_KOI_Shape)
- {
- return;
- }
- else if (theIObj->Signature() != 0)
- {
- return;
- }
-
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
- aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
- redisplayPrsModes (theIObj, theToUpdateViewer);
-}
-
-//=======================================================================
-//function : SetDeviationAngle
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Real theAngle,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theIObj.IsNull())
- {
- return;
- }
-
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if (theIObj->Type() != AIS_KOI_Shape)
- {
- return;
- }
- else if (theIObj->Signature() != 0)
- {
- return;
- }
-
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
- aShape->SetOwnDeviationAngle (theAngle);
- redisplayPrsModes (theIObj, theToUpdateViewer);
-}
-
-//=======================================================================
-//function : SetAngleAndDeviation
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Real theAngle,
- const Standard_Boolean theToUpdateViewer)
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theCoefficient,
+ const Standard_Boolean theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
- // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if (theIObj->Type() != AIS_KOI_Shape)
+ // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
+ setContextToObject (theIObj);
+ if (theIObj->Type() != AIS_KOI_Object
+ && theIObj->Type() != AIS_KOI_Shape)
{
return;
}
- if (theIObj->Signature() != 0)
+ else if (theIObj->Signature() != 0)
{
return;
}
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
- aShape->SetAngleAndDeviation (theAngle);
-
- if (theIObj->RecomputeEveryPrs())
- {
- theIObj->Update (Standard_True);
- theIObj->UpdateSelection();
- }
- else
+ aShape->SetOwnDeviationCoefficient (theCoefficient);
+ aShape->UpdatePresentations();
+ if (theToUpdateViewer)
{
- Update (theIObj, theToUpdateViewer);
+ UpdateCurrentViewer();
}
}
//=======================================================================
-//function : SetHLRAngleAndDeviation
+//function : SetDeviationAngle
//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Real theAngle,
- const Standard_Boolean theToUpdateViewer)
+void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theAngle,
+ const Standard_Boolean theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+ setContextToObject (theIObj);
if (theIObj->Type() != AIS_KOI_Shape)
{
return;
}
- if (theIObj->Signature() != 0)
+ else if (theIObj->Signature() != 0)
{
return;
}
+
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
- aShape->SetHLRAngleAndDeviation (theAngle);
- redisplayPrsModes (theIObj, theToUpdateViewer);
+ aShape->SetOwnDeviationAngle (theAngle);
+ aShape->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
-//function : SetHLRDeviationAngle
+//function : SetAngleAndDeviation
//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
+void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Real theAngle,
const Standard_Boolean theToUpdateViewer)
{
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+ setContextToObject (theIObj);
if (theIObj->Type() != AIS_KOI_Shape)
{
return;
{
return;
}
+
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
- aShape->SetOwnHLRDeviationAngle (theAngle);
- redisplayPrsModes (theIObj, theToUpdateViewer);
+ aShape->SetAngleAndDeviation (theAngle);
+ aShape->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
}
theIObj->UnsetColor();
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
return theIObj->HasColor();
}
-//=======================================================================
-//function : Color
-//purpose :
-//=======================================================================
-Quantity_NameOfColor AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj) const
-{
- return theIObj->Color();
-}
-
//=======================================================================
//function : Color
//purpose :
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
+ setContextToObject (theIObj);
theIObj->SetWidth (theWidth);
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
- if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj)
+ theIObj->UpdatePresentations();
+ if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj))
{
- if (myLastinMain->IsAutoHilight())
+ if (myLastPicked->IsAutoHilight())
{
- const Standard_Integer aHiMode =
- theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
- myLastinMain->HilightWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, aHiMode);
+ const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
+ myLastPicked->HilightWithColor (myMainPM,
+ myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked),
+ aHiMode);
}
else
{
- theIObj->HilightOwnerWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, myLastinMain);
+ theIObj->HilightOwnerWithColor (myMainPM,
+ myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked),
+ myLastPicked);
}
}
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
}
theIObj->UnsetWidth();
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
- const Graphic3d_NameOfMaterial theName,
+ const Graphic3d_MaterialAspect& theMaterial,
const Standard_Boolean theToUpdateViewer)
{
if (theIObj.IsNull())
return;
}
- if (!theIObj->HasInteractiveContext())
+ setContextToObject (theIObj);
+ theIObj->SetMaterial (theMaterial);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
{
- theIObj->SetContext (this);
+ UpdateCurrentViewer();
}
-
- theIObj->SetMaterial (theName);
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
return;
}
theIObj->UnsetMaterial();
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
+ setContextToObject (theIObj);
if (!theIObj->IsTransparent()
- && theValue <= 0.05)
+ && theValue <= 0.005)
{
return;
}
- if (theValue <= 0.05)
+ if (theValue <= 0.005)
{
UnsetTransparency (theIObj, theToUpdateViewer);
return;
}
theIObj->SetTransparency (theValue);
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
}
theIObj->UnsetTransparency();
- redisplayPrsRecModes (theIObj, theToUpdateViewer);
+ theIObj->UpdatePresentations();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
- const Standard_Boolean theIsGlobalChange,
const Standard_Boolean theToUpdateViewer)
{
- if (HasOpenedContext())
- {
- return;
- }
-
+ Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Boolean isFound = Standard_False;
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
isFound = Standard_True;
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value());
- anObj->SetAspect (theAspect, theIsGlobalChange);
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
+ anObj->SetAspect (theAspect);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
if (isFound && theToUpdateViewer)
{
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
-
+ setContextToObject (theIObj);
theIObj->SetAttributes (theDrawer);
Update (theIObj, theToUpdateViewer);
}
return;
}
- if (!theIObj->HasInteractiveContext())
- {
- theIObj->SetContext (this);
- }
+ setContextToObject (theIObj);
theIObj->UnsetAttributes();
Update (theIObj, theToUpdateViewer);
}
}
theStatus += "\t| Active Display Modes in the MainViewer :\n";
- for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
- {
- theStatus += "\t|\t Mode ";
- theStatus += TCollection_AsciiString (aDispModeIter.Value());
- theStatus += "\n";
- }
+ theStatus += "\t|\t Mode ";
+ theStatus += TCollection_AsciiString (aStatus->DisplayMode());
+ theStatus += "\n";
+
if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
theStatus += "\t| Active Selection Modes in the MainViewer :\n";
theDispMode = theIObj->HasDisplayMode()
? theIObj->DisplayMode()
- : (theIObj->AcceptDisplayMode (myDisplayMode)
- ? myDisplayMode
+ : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
+ ? myDefaultDrawer->DisplayMode()
: 0);
theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
theSelMode = theIObj->GlobalSelectionMode();
void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateviewer)
{
+ Handle(AIS_GlobalStatus) aStatus;
if (theIObj.IsNull()
- || !myObjects.IsBound (theIObj))
+ || !myObjects.Find (theIObj, aStatus)
+ || aStatus->GraphicStatus() == AIS_DS_Erased)
{
return;
}
- Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
-
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
- if (aStatus->GraphicStatus() == AIS_DS_Temporary
- || aStatus->GraphicStatus() == AIS_DS_Erased)
- {
- return;
- }
+ unselectOwners (theIObj);
+ myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
- for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+ if (!myLastPicked.IsNull()
+ && myLastPicked->IsSameSelectable (theIObj))
{
- if (aStatus->IsHilighted())
- {
- if (IsCurrent (theIObj))
- {
- AddOrRemoveCurrentObject (theIObj, Standard_False);
- }
- else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
- {
- myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
- }
- }
-
- myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
+ clearDynamicHighlight();
}
+ // make sure highlighting presentations are properly erased
+ theIObj->ErasePresentations (false);
+
if (IsSelected (theIObj)
- && !aStatus->IsDModeIn (aDispMode))
+ && aStatus->DisplayMode() != aDispMode)
{
myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
}
for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
{
- mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
+ mgrSelector->Deactivate (theIObj, aSelModeIter.Value());
}
aStatus->ClearSelectionModes();
aStatus->SetGraphicStatus (AIS_DS_Erased);
}
//=======================================================================
-//function : unhighlightOwners
+//function : unselectOwners
//purpose :
//=======================================================================
-void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject)
+void AIS_InteractiveContext::unselectOwners (const Handle(AIS_InteractiveObject)& theObject)
{
- mySelection->Init();
- while (mySelection->More())
+ SelectMgr_SequenceOfOwner aSeq;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value());
- if (anOwner->Selectable() == theObject)
+ if (aSelIter.Value()->IsSameSelectable (theObject))
{
- if (anOwner->IsSelected())
- {
- AddOrRemoveSelected (anOwner, Standard_False);
- mySelection->Init();
- continue;
- }
+ aSeq.Append (aSelIter.Value());
}
- mySelection->Next();
+ }
+ for (SelectMgr_SequenceOfOwner::Iterator aDelIter (aSeq); aDelIter.More(); aDelIter.Next())
+ {
+ AddOrRemoveSelected (aDelIter.Value(), Standard_False);
}
}
void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateviewer)
{
+ Handle(AIS_GlobalStatus) aStatus;
if (theIObj.IsNull()
- || !myObjects.IsBound (theIObj))
+ || !myObjects.Find (theIObj, aStatus))
{
// for cases when reference shape of connected interactives was not displayed
// but its selection primitives were calculated
return;
}
- Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
- unhighlightOwners (theIObj);
- for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
- {
- myMainPM->Erase (theIObj, aDispModeIter.Value());
- myMainPM->Clear (theIObj, aDispModeIter.Value());
- }
+ unselectOwners (theIObj);
+
+ myMainPM->Erase (theIObj, -1);
+ theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased
// Object removes from Detected sequence
- for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();)
{
- Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
+ Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter));
+ Handle(AIS_InteractiveObject) anObj;
+ if (!aPicked.IsNull())
+ {
+ anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable());
+ }
+
if (!anObj.IsNull()
- && anObj != theIObj)
+ && anObj == theIObj)
+ {
+ myDetectedSeq.Remove (aDetIter);
+ if (myCurDetected == aDetIter)
+ {
+ myCurDetected = Min (myDetectedSeq.Upper(), aDetIter);
+ }
+ if (myCurHighlighted == aDetIter)
+ {
+ myCurHighlighted = 0;
+ }
+ }
+ else
{
- myAISDetectedSeq.Remove (aDetIter);
+ aDetIter++;
}
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
// remove IO from the selection manager to avoid memory leaks
const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
mgrSelector->Remove (anObj);
- myObjects.UnBind (theIObj);
+ setObjectStatus (theIObj, AIS_DS_None, -1, -1);
myMainVwr->StructureManager()->UnregisterObject (theIObj);
- for (myMainVwr->InitDefinedViews(); myMainVwr->MoreDefinedViews(); myMainVwr->NextDefinedViews())
+
+ for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next())
{
- myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
+ aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
}
- if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj)
- myLastinMain.Nullify();
- if (!myLastPicked.IsNull() && myLastPicked->Selectable() == theIObj)
- myLastPicked.Nullify();
- myMainPM->ClearImmediateDraw();
+ if (!myLastPicked.IsNull())
+ {
+ if (myLastPicked->IsSameSelectable (theIObj))
+ {
+ clearDynamicHighlight();
+ myLastPicked.Nullify();
+ }
+ }
if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed)
{
}
const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
- if (aStatus->IsDModeIn (theMode))
+ if (aStatus->DisplayMode() == theMode)
{
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
if (aDispMode == theMode
&& myMainPM->IsHighlighted (theIObj, theMode))
{
- myMainPM->Unhighlight (theIObj, theMode);
+ unhighlightGlobal (theIObj);
}
myMainPM->Erase (theIObj, theMode);
- myMainPM->Clear (theIObj, theMode);
}
if (aStatus->GraphicStatus() == AIS_DS_Displayed
}
}
+//=======================================================================
+//function : ClearDetected
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRedrawImmediate)
+{
+ myCurDetected = 0;
+ myCurHighlighted = 0;
+ myDetectedSeq.Clear();
+ Standard_Boolean toUpdate = Standard_False;
+ if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
+ {
+ toUpdate = Standard_True;
+ clearDynamicHighlight();
+ }
+ myLastPicked.Nullify();
+ myMainSel->ClearPicked();
+ if (toUpdate && theToRedrawImmediate)
+ {
+ myMainVwr->RedrawImmediate();
+ }
+ return toUpdate;
+}
+
//=======================================================================
//function : DrawHiddenLine
//purpose :
return myDefaultDrawer->IsoOnTriangulation();
}
+//=======================================================================
//function : SetPixelTolerance
-//purpose : Disables the mechanism of adaptive tolerance calculation in
-// SelectMgr_ViewerSelector and sets the given tolerance for ALL
-// sensitive entities activated. For more information, see
-// SelectMgr_ViewerSelector.hxx
+//purpose :
//=======================================================================
void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
{
- if (HasOpenedContext())
- {
- myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
- }
- else
- {
- myMainSel->SetPixelTolerance (thePrecision);
- }
+ myMainSel->SetPixelTolerance (thePrecision);
}
//=======================================================================
//=======================================================================
Standard_Integer AIS_InteractiveContext::PixelTolerance() const
{
- return HasOpenedContext()
- ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
- : myMainSel->PixelTolerance();
+ return myMainSel->PixelTolerance();
}
//=======================================================================
const Standard_Integer theMode,
const Standard_Integer theNewSensitivity)
{
- if (HasOpenedContext())
- {
- myLocalContexts (myCurLocalIndex)->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
- return;
- }
-
mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
}
-//=======================================================================
-//function : IsInLocal
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
- Standard_Integer& theIndex) const
-{
- if (theIObj.IsNull())
- {
- return Standard_False;
- }
-
- // if it exists at neutral point 0 index is returned
- if (myObjects.IsBound (theIObj))
- {
- theIndex = 0;
- return Standard_False;
- }
-
- for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
- {
- if (myLocalContexts.IsBound (aCtxIter))
- {
- if(myLocalContexts (aCtxIter)->IsIn (theIObj))
- {
- theIndex = aCtxIter;
- return Standard_True;
- }
- }
- }
- theIndex = -1;
- return Standard_False;
-}
-
//=======================================================================
//function : InitAttributes
//purpose :
//=======================================================================
void AIS_InteractiveContext::InitAttributes()
{
- mgrSelector->Add (myMainSel);
-
- myDefaultDrawer->SetShadingAspectGlobal (Standard_False);
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
const Standard_Real aLength = 100.0;
aTrihAspect->SetAxisLength (aLength, aLength, aLength);
- const Quantity_NameOfColor aColor = Quantity_NOC_LIGHTSTEELBLUE4;
- aTrihAspect->FirstAxisAspect() ->SetColor (aColor);
- aTrihAspect->SecondAxisAspect()->SetColor (aColor);
- aTrihAspect->ThirdAxisAspect() ->SetColor (aColor);
+ const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4;
+ aTrihAspect->LineAspect(Prs3d_DP_XAxis)->SetColor (aColor);
+ aTrihAspect->LineAspect(Prs3d_DP_YAxis)->SetColor (aColor);
+ aTrihAspect->LineAspect(Prs3d_DP_ZAxis)->SetColor (aColor);
Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
const Standard_Real aPlaneLength = 200.0;
//=======================================================================
Standard_Real AIS_InteractiveContext::TrihedronSize() const
{
- return myDefaultDrawer->DatumAspect()->FirstAxisLength();
+ return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis);
}
//=======================================================================
//=======================================================================
void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
const Standard_Real theValY,
- const Standard_Boolean /*updateviewer*/)
+ const Standard_Boolean theToUpdateViewer)
{
myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
- Redisplay (AIS_KOI_Datum, 7);
+ Redisplay (AIS_KOI_Datum, 7, theToUpdateViewer);
}
//=======================================================================
return (Abs (theX - theY) <= Precision::Confusion());
}
-//=======================================================================
-//function : SetAutoActivateSelection
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
-{
- myIsAutoActivateSelMode = theIsAuto;
-}
-
-//=======================================================================
-//function : GetAutoActivateSelection
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
-{
- return myIsAutoActivateSelMode;
-}
-
//=======================================================================
//function : SetZLayer
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Integer theLayerId)
+ const Graphic3d_ZLayerId theLayerId)
{
if (theIObj.IsNull())
return;
//function : GetZLayer
//purpose :
//=======================================================================
-Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
+Graphic3d_ZLayerId AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
{
return !theIObj.IsNull()
? theIObj->ZLayer()
{
Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly));
theObj->Disconnect (theObjToDisconnect);
+ if (!myObjects.IsBound (theObjToDisconnect))
+ {
+ // connected presentation might contain displayed presentations
+ myMainPM->Erase (theObjToDisconnect, -1);
+ theObjToDisconnect->ErasePresentations (true);
+ }
+
const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity
mgrSelector->Remove (anObj);
}
//function : FitSelected
//purpose : Fits the view corresponding to the bounds of selected objects
//=======================================================================
-void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
- const Standard_Real theMargin,
- const Standard_Boolean theToUpdate)
+void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
{
- const Handle(AIS_Selection)& aSelection = HasOpenedContext() ?
- myLocalContexts(myCurLocalIndex)->Selection() : mySelection;
+ FitSelected (theView, 0.01, Standard_True);
+}
+//=======================================================================
+//function : BoundingBoxOfSelection
+//purpose :
+//=======================================================================
+Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
+{
Bnd_Box aBndSelected;
-
AIS_MapOfObjectOwners anObjectOwnerMap;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- Handle(AIS_InteractiveObject) anObj (Handle(AIS_InteractiveObject)::DownCast (aSelection->Value()));
- if (!anObj.IsNull())
+ const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ if (anObj->IsInfinite())
{
- if (anObj->IsInfinite())
- continue;
+ continue;
+ }
+ if (anOwner == anObj->GlobalSelOwner())
+ {
Bnd_Box aTmpBnd;
anObj->BoundingBox (aTmpBnd);
aBndSelected.Add (aTmpBnd);
}
else
{
- Handle(SelectMgr_EntityOwner) anOwner (Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Value()));
- if (anOwner.IsNull())
- continue;
-
Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap;
if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap))
{
aBndSelected.Add (aTmpBox);
}
- anObjectOwnerMap.Clear();
+ return aBndSelected;
+}
+
+//=======================================================================
+//function : FitSelected
+//purpose : Fits the view corresponding to the bounds of selected objects
+//=======================================================================
+void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
+ const Standard_Real theMargin,
+ const Standard_Boolean theToUpdate)
+{
+ Bnd_Box aBndSelected = BoundingBoxOfSelection();
+ if (!aBndSelected.IsVoid())
+ {
+ theView->FitAll (aBndSelected, theMargin, theToUpdate);
+ }
+}
- if (aBndSelected.IsVoid())
+//=======================================================================
+//function : SetTransformPersistence
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
+{
+ theObject->SetTransformPersistence (theTrsfPers);
+ if (!myObjects.IsBound (theObject))
+ {
return;
+ }
+
+ mgrSelector->UpdateSelection (theObject);
+
+ const Standard_Integer aLayerId = myObjects.Find (theObject)->GetLayerIndex();
+ const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
+ for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ anActiveViewIter.Value()->View()->InvalidateBVHData (aLayerId);
+ anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId);
+ }
+}
+
+//=======================================================================
+//function : GravityPoint
+//purpose :
+//=======================================================================
+gp_Pnt AIS_InteractiveContext::GravityPoint (const Handle(V3d_View)& theView) const
+{
+ return theView->GravityPoint();
+}
+//=======================================================================
+//function : setObjectStatus
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj,
+ const AIS_DisplayStatus theStatus,
+ const Standard_Integer theDispMode,
+ const Standard_Integer theSelectionMode)
+{
+ if (theStatus != AIS_DS_None)
+ {
+ Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
+ myObjects.Bind (theIObj, aStatus);
+ }
+ else
+ myObjects.UnBind (theIObj);
- theView->FitAll (aBndSelected, theMargin, theToUpdate);
+ for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (theIObj->Children()); aPrsIter.More(); aPrsIter.Next())
+ {
+ Handle(AIS_InteractiveObject) aChild (Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value()));
+ if (aChild.IsNull())
+ continue;
+
+ setObjectStatus (aChild, theStatus, theDispMode, theSelectionMode);
+ }
}