// Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
-#define BUC60577 //GG_101099 Enable to compute correctly
-// transparency with more than one object in the view.
-
-#define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
-// method, compute only authorized presentation.
-
-#define BUC60688 //GG 25/05/00 Add SetSensitivity() methods.
-
-#define BUC60722 //GG 04/09/00 Always enable viewer update when erasing something
-
-#define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
-
-#define OCC172 //SAV clear static map before destroying context.
-
-#define OCC204 //SAV 26/02/02 : pass <updateviewer> flag to
-// AddOrRemoveCurrentObject method from ClearGlobal.
-
-#define OCC4373 //SAN 10/11/03 : improve display mode management in
-// Display( IO, updateviewer ) and
-// SetDisplayMode( IO, mode, updateviewer ) methods
-
-#include <AIS_InteractiveContext.ixx>
-
-//#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfTransient.hxx>
-#include <AIS_LocalContext.hxx>
-#include <AIS_LocalStatus.hxx>
-#include <Precision.hxx>
-#include <AIS_Selection.hxx>
-#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
-#include <AIS_ConnectedShape.hxx>
-#include <AIS_MultipleConnectedShape.hxx>
+#include <AIS_ConnectedInteractive.hxx>
#include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
+#include <AIS_DataMapIteratorOfDataMapOfIOStatus.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 <PrsMgr_ModedPresentation.hxx>
-#include <Visual3d_ViewManager.hxx>
-#include <Prs3d_ShadingAspect.hxx>
+#include <AIS_MultipleConnectedInteractive.hxx>
+#include <AIS_Selection.hxx>
#include <AIS_Shape.hxx>
+#include <AIS_Trihedron.hxx>
+#include <Geom_Axis2Placement.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <HLRBRep.hxx>
-#include <Prs3d_IsoAspect.hxx>
+#include <OSD_Environment.hxx>
+#include <Precision.hxx>
+#include <Prs3d_BasicAspect.hxx>
#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentableObject.hxx>
+#include <Quantity_Color.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_OrFilter.hxx>
+#include <SelectMgr_SelectionManager.hxx>
#include <Standard_Atomic.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfTransient.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Shape.hxx>
#include <UnitsAPI.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
-#include <AIS_Trihedron.hxx>
-#include <Geom_Axis2Placement.hxx>
-#include <OSD_Environment.hxx>
-
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-
-// In the method GetDefModes() the returned value of the selection mode
-// is always equal to 0 if it is -1.
-#define BUC61051
-
-// The local context is closed the method ::ResetOriginalState() sets the selection mode equal to 0
-// in spite of the selection mode of the interactive object in Natural Point.
-#define OCC166
-
-static Standard_Boolean AISDebugModeOn()
-{
-// static OSD_Environment aisdb("AISDEBUGMODE");
-// return !aisdb.Value().IsEmpty();
- static Standard_Integer isDebugMode(-1);
- if (isDebugMode < 0) {
- isDebugMode = 1;
- OSD_Environment aisdb("AISDEBUGMODE");
- if (aisdb.Value().IsEmpty())
- isDebugMode = 0;
- }
- return (isDebugMode != 0);
-}
-
+//#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
namespace
{
static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
return TCollection_AsciiString ("AIS_CurContext_")
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
}
-};
+
+ typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
+ typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners;
+}
//=======================================================================
//function : AIS_InteractiveContext
AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
mgrSelector(new SelectMgr_SelectionManager()),
-myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
+myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())),
myMainVwr(MainViewer),
myMainSel(new StdSelect_ViewerSelector3d()),
-myToHilightSelected( Standard_False ),
+myWasLastMain(Standard_False),
+myCurrentTouched(Standard_False),
+mySelectedTouched(Standard_False),
+myToHilightSelected(Standard_True),
myFilters(new SelectMgr_OrFilter()),
myDefaultDrawer(new Prs3d_Drawer()),
myDefaultColor(Quantity_NOC_GOLDENROD),
mySubIntensity(Quantity_NOC_GRAY40),
myDisplayMode(0),
myCurLocalIndex(0),
-#ifdef IMP051001
+myAISCurDetected(0),
myZDetectionFlag(0),
-#endif
myIsAutoActivateSelMode( Standard_True )
{
InitAttributes();
void AIS_InteractiveContext::Delete() const
{
- //Clear the static current selection. Else the memory
- //is not release
+ // clear the static current selection
AIS_Selection::ClearCurrentSelection();
-#ifdef OCC172
+
// to avoid an exception
- if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
- AIS_Selection::Remove( mySelectionName.ToCString() );
+ if (AIS_Selection::Find (mySelectionName.ToCString()))
+ {
+ AIS_Selection::Remove (mySelectionName.ToCString());
+ }
// to avoid an exception
- if ( AIS_Selection::Find( myCurrentName.ToCString() ) )
- AIS_Selection::Remove( myCurrentName.ToCString() );
+ if (AIS_Selection::Find (myCurrentName.ToCString()))
+ {
+ AIS_Selection::Remove (myCurrentName.ToCString());
+ }
// let's remove one reference explicitly. this operation's supposed to
// be performed when mgrSelector will be destroyed but anyway...
- mgrSelector->Remove( myMainSel );
-#endif
- AIS_ListOfInteractive aList;
-
- AIS_DataMapIteratorOfDataMapOfIOStatus anIt(myObjects);
+ const Handle(SelectMgr_ViewerSelector)& aSelector = myMainSel; // to avoid ambiguity
+ mgrSelector->Remove (aSelector);
+
Handle(AIS_InteractiveContext) aNullContext;
- for(; anIt.More() ; anIt.Next())
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
- Handle(AIS_InteractiveObject) anObj = anIt.Key();
- anObj->SetContext(aNullContext);
-
+ Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
+ anObj->SetContext (aNullContext);
+ for (anObj->Init(); anObj->More(); anObj->Next())
+ {
+ anObj->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Renew);
+ }
}
MMgt_TShared::Delete();
}
//=======================================================================
//function : DisplayedObjects
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
- const Standard_Boolean OnlyFromNeutral) const
-{
-#ifdef DEBUG
- cout<<"AIS_IC::DisplayedObjects"<<endl;
-#endif
-
- AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
- if(!HasOpenedContext() || OnlyFromNeutral){
- for(;It.More();It.Next()){
- if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
- aListOfIO.Append(It.Key());
- }
- }
- else{
- TColStd_MapOfTransient theMap;
- // neutral point
- for(;It.More();It.Next()){
- if(It.Value()->GraphicStatus()==AIS_DS_Displayed)
- theMap.Add(It.Key());
- }
-#ifdef DEBUG
- cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl;
-#endif
-
- //parse all local contexts...
-#ifdef DEBUG
- Standard_Integer NbDisp;
- for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
- const Handle(AIS_LocalContext)& LC = it1.Value();
- NbDisp = LC->DisplayedObjects(theMap);
- cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
- }
-#endif
- Handle(AIS_InteractiveObject) curIO;
- Handle(Standard_Transient) Tr;
- for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
- Tr = it2.Key();
- curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
- aListOfIO.Append(curIO);
+void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
+ const Standard_Boolean theOnlyFromNeutral) 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());
+ }
+ }
+
+ // 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);
+ }
}
+
//=======================================================================
//function : DisplayedObjects
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind,
- const Standard_Integer TheSign,
- AIS_ListOfInteractive& aListOfIO,
- const Standard_Boolean /*OnlyFromNeutral*/) const
+void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
+ const Standard_Integer theSign,
+ AIS_ListOfInteractive& theListOfIO,
+ const Standard_Boolean /*OnlyFromNeutral*/) const
{
- ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
+ ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
}
//=======================================================================
//function : ErasedObjects
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const
+void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const
{
- ObjectsByDisplayStatus( AIS_DS_Erased, theListOfIO );
+ ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO);
}
//=======================================================================
//function : ErasedObjects
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
- const Standard_Integer TheSign,
- AIS_ListOfInteractive& theListOfIO) const
+void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind,
+ const Standard_Integer theSign,
+ AIS_ListOfInteractive& theListOfIO) const
{
- ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, theListOfIO );
+ ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO);
}
//=======================================================================
//function : ObjectsByDisplayStatus
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus,
- AIS_ListOfInteractive& theListOfIO) const
+void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus,
+ AIS_ListOfInteractive& theListOfIO) const
{
- AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
- for(;It.More();It.Next()){
- if(It.Value()->GraphicStatus() == theStatus)
- theListOfIO.Append(It.Key());
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ if (anObjIter.Value()->GraphicStatus() == theStatus)
+ {
+ theListOfIO.Append (anObjIter.Key());
+ }
}
}
//=======================================================================
//function : ObjectsByDisplayStatus
-//purpose :
+//purpose :
//=======================================================================
+void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind,
+ const Standard_Integer theSign,
+ const AIS_DisplayStatus theStatus,
+ AIS_ListOfInteractive& theListOfIO) const
+{
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ if (theStatus != AIS_DS_None
+ && anObjIter.Value()->GraphicStatus() != theStatus)
+ {
+ continue;
+ }
+ else if (anObjIter.Key()->Type() != theKind)
+ {
+ continue;
+ }
-void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind,
- const Standard_Integer TheSign,
- const AIS_DisplayStatus theStatus,
- AIS_ListOfInteractive& theListOfIO) const
-{
- AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
- for(;It.More();It.Next()){
- if(It.Value()->GraphicStatus()==theStatus){
- if(It.Key()->Type()==TheKind){
- if(TheSign ==-1)
- theListOfIO.Append(It.Key());
- else{
- if(It.Key()->Signature()==TheSign)
- theListOfIO.Append(It.Key());
- }
- }
+ if (theSign == -1
+ || anObjIter.Key()->Signature() == theSign)
+ {
+ theListOfIO.Append (anObjIter.Key());
}
}
}
//=======================================================================
//function : ObjectsInside
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO,
- const AIS_KindOfInteractive TheKind,
- const Standard_Integer TheSign) const
+void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO,
+ const AIS_KindOfInteractive theKind,
+ const Standard_Integer theSign) const
{
- AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
- if(TheKind==AIS_KOI_None && TheSign ==-1){
- for(;It.More();It.Next()){
- aListOfIO.Append(It.Key());
+ if (theKind == AIS_KOI_None
+ && theSign == -1)
+ {
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ theListOfIO.Append (anObjIter.Key());
}
+ return;
}
- else{
- for(;It.More();It.Next()){
- if(It.Key()->Type()==TheKind){
- if(TheSign ==-1)
- aListOfIO.Append(It.Key());
- else{
- if(It.Key()->Signature()==TheSign)
- aListOfIO.Append(It.Key());
- }
- }
+
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ if (anObjIter.Key()->Type() != theKind)
+ {
+ continue;
+ }
+
+ if (theSign == -1
+ || anObjIter.Key()->Signature() == theSign)
+ {
+ theListOfIO.Append (anObjIter.Key());
}
}
}
//=======================================================================
-//function : Display
-//purpose :
+//function : ObjectsForView
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer )
+void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theIsVisibleInView,
+ const AIS_DisplayStatus theStatus) const
{
- if(anIObj.IsNull()) return;
-
- Standard_Integer DispMode,HiMod,SelMode;
-
- GetDefModes(anIObj,DispMode,HiMod,SelMode);
-
- Handle (AIS_InteractiveContext) aThis = this;
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(aThis);
-
- //NO LOCAL CONTEXT OPEN
- if(!HasOpenedContext()) {
-#ifndef OCC4373
- // SAN : Do not return here. Perform advanced display mode analysis a bit later...
- if(IsDisplayed(anIObj)) return;
-#endif
-
- // it did not yet exist
- if(!myObjects.IsBound(anIObj)){
-
- Handle(AIS_GlobalStatus) STATUS=
-#ifdef OCC166
- new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode);
-#else
- new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0);
-#endif
- myObjects.Bind (anIObj,STATUS);
- myMainPM->Display(anIObj,DispMode);
- if( myIsAutoActivateSelMode )
- {
- if(!mgrSelector->Contains(anIObj))
- mgrSelector->Load(anIObj);
- mgrSelector->Activate(anIObj,SelMode,myMainSel);
- }
-
- if(updateviewer) myMainVwr->Update();
- }
- // it is somewhere else...
- else {
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
- // ENDCLE
- if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
- {
- // SAN : erase presentations for all display modes different from <DispMode>;
- // then make sure <DispMode> is displayed and maybe highlighted;
- // Finally, activate selection mode <SelMode> if not yet activated.
- TColStd_ListOfInteger aModesToRemove;
- TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
- for(;ItL.More();ItL.Next()){
-
- Standard_Integer OldMode = ItL.Value();
-
- if(OldMode!=DispMode){
- aModesToRemove.Append(OldMode);
- if(myMainPM->IsHighlighted(anIObj,OldMode))
- myMainPM->Unhighlight(anIObj,OldMode);
- myMainPM->Erase(anIObj,OldMode);
- }
- }
-
- for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
- STATUS->RemoveDisplayMode(ItL.Value());
-
- if(!STATUS->IsDModeIn(DispMode))
- STATUS->AddDisplayMode(DispMode);
-
- myMainPM->Display(anIObj,DispMode);
- if (STATUS->GraphicStatus() == AIS_DS_Erased)
- {
- STATUS->SetGraphicStatus(AIS_DS_Displayed);
- }
- if(STATUS->IsHilighted()){
- myMainPM->Highlight(anIObj,HiMod);
- }
- if( myIsAutoActivateSelMode )
- {
- if(!mgrSelector->Contains(anIObj))
- mgrSelector->Load(anIObj);
- if(!mgrSelector->IsActivated(anIObj,SelMode))
- mgrSelector->Activate(anIObj,SelMode,myMainSel);
- }
- }
- }
-
- if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
- myMainVwr->Viewer()->SetTransparency(Standard_True);
- if(updateviewer) myMainVwr->Update();
- }
-
- // LOCAL CONTEXT OPEN
- else
+ Handle(Graphic3d_CView) aViewImpl = theView->View();
+ const Standard_Integer aViewId = aViewImpl->Identification();
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
- myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
-
- if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
- myMainVwr->Viewer()->SetTransparency(Standard_True);
-
-
- if(updateviewer) myMainVwr->Update();
+ if (theStatus != AIS_DS_None
+ && anObjIter.Value()->GraphicStatus() != theStatus)
+ {
+ theListOfIO.Append (anObjIter.Key());
+ continue;
+ }
+
+ Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key());
+ const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
+ if (isVisible == theIsVisibleInView)
+ {
+ theListOfIO.Append (anObjIter.Key());
+ }
}
}
//=======================================================================
//function : Display
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer aDisplayMode,
- const Standard_Integer aSelectionMode,
- const Standard_Boolean updateviewer,
- const Standard_Boolean allowdecomposition)
+void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return;
-
- if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
-
- // if no local context...
- if(!HasOpenedContext()) {
- // if(!anIObj->HasDisplayMode())
- // anIObj->SetDisplayMode(aDisplayMode);
-
- if(!myObjects.IsBound(anIObj)){
- Handle(AIS_GlobalStatus) STATUS=
- new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode);
- myObjects.Bind (anIObj,STATUS);
- myMainPM->Display(anIObj,aDisplayMode);
- if(aSelectionMode!=-1){
- if(!mgrSelector->Contains(anIObj))
- mgrSelector->Load(anIObj,aSelectionMode);
- mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
- }
- if(updateviewer) myMainVwr->Update();
- }
- // anIObj->SelectionMode(aSelectionMode);
- else{
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
- // ENDCLE
- if(!STATUS->IsDModeIn(aDisplayMode)){
- myMainPM->Display(anIObj,aDisplayMode);
- STATUS->AddDisplayMode(aDisplayMode);
- if(STATUS->IsSubIntensityOn())
- myMainPM->Color(anIObj,mySubIntensity,aDisplayMode);
- }
- if(aSelectionMode!=-1){
- STATUS->AddSelectionMode(aSelectionMode);
- mgrSelector->Activate(anIObj,aSelectionMode,myMainSel);
- }
- if(updateviewer) myMainVwr->Update();
-
- }
+ if (theIObj.IsNull())
+ {
+ return;
}
- else
- {
- myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode);
- if(updateviewer) myMainVwr->Update();
- }
-}
+ Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
+ GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
+
+ Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
+ theToUpdateViewer, theIObj->AcceptShapeDecomposition());
+}
//=======================================================================
-//function : Load
-//purpose :
+//function : SetViewAffinity
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer SelMode,
- const Standard_Boolean AllowDecomposition)
+void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theIsVisible)
{
- if(anIObj.IsNull()) return;
- if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
-
+ if (theIObj.IsNull()
+ || !myObjects.IsBound (theIObj))
+ {
+ return;
+ }
- if(!HasOpenedContext()) {
- if(SelMode==-1 && !AllowDecomposition){
- Standard_Integer DispMode,HiMod,SelModeDef;
-
- GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
- Handle(AIS_GlobalStatus) STATUS=
- new AIS_GlobalStatus(AIS_DS_Erased,DispMode,SelModeDef);
- myObjects.Bind (anIObj,STATUS);
- return;
- }
+ Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj);
+ Handle(Graphic3d_CView) aViewImpl = theView->View();
+ anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True);
+ if (theIsVisible)
+ {
+ theView->View()->ChangeHiddenObjects()->Remove (theIObj.get());
+ }
+ else
+ {
+ theView->View()->ChangeHiddenObjects()->Add (theIObj.get());
}
- myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode);
}
-
//=======================================================================
-//function : Erase
-//purpose :
+//function : Display
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theDispMode,
+ const Standard_Integer theSelectionMode,
+ const Standard_Boolean theToUpdateViewer,
+ const Standard_Boolean theToAllowDecomposition,
+ const AIS_DisplayStatus theDispStatus)
{
- if(anIObj.IsNull()) return;
-
- if ( !anIObj->IsAutoHilight() )
- anIObj->ClearSelected();
-
- if(!HasOpenedContext()){
- EraseGlobal(anIObj,updateviewer);
+ if (theIObj.IsNull())
+ {
+ return;
}
- else
+
+ 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)
{
- // 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...
-
- Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj);
-// if(!WasInCtx) {
- AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
- for (;It.More();It.Next()){
- if(It.Value()->AcceptErase())
-#ifdef BUC60722
- WasInCtx |= It.Value()->Erase(anIObj);
-#else
- WasInCtx = It.Value()->Erase(anIObj);
-#endif
+ myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
}
-
- if(!WasInCtx)
- EraseGlobal(anIObj,updateviewer);
- else
- if(updateviewer) myMainVwr->Update();
+ return;
}
-}
-
-//=======================================================================
-//function : EraseAll
-//purpose :
-//=======================================================================
+ }
-void AIS_InteractiveContext::EraseAll(const Standard_Boolean updateviewer)
-{
- if(!HasOpenedContext())
+ if (!myObjects.IsBound (theIObj))
{
- for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); ItM.More(); ItM.Next())
+ Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
+ myObjects.Bind (theIObj, aStatus);
+ Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->RegisterObject (theIObj);
+ myMainPM->Display(theIObj, theDispMode);
+ if (theSelectionMode != -1)
{
- if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
- Erase(ItM.Key(),Standard_False);
+ const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
+ if (!mgrSelector->Contains (anObj))
+ {
+ mgrSelector->Load (theIObj);
+ }
+ mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
}
- if(updateviewer)
+ }
+ else
+ {
+ Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
+ if (aStatus->GraphicStatus() == AIS_DS_Temporary)
{
- myMainVwr->Update();
+ return;
}
- }
-}
-//=======================================================================
-//function : DisplayAll
-//purpose :
-//=======================================================================
+ // Erase presentations for all display modes 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 = aDispModeIter.Value();
+ if (anOldMode != theDispMode)
+ {
+ aModesToRemove.Append (anOldMode);
+ if(myMainPM->IsHighlighted (theIObj, anOldMode))
+ {
+ myMainPM->Unhighlight (theIObj, anOldMode);
+ }
+ myMainPM->Erase (theIObj, anOldMode);
+ }
+ }
-void AIS_InteractiveContext::DisplayAll(const Standard_Boolean updateviewer)
-{
- if(!HasOpenedContext()){
+ for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
+ {
+ aStatus->RemoveDisplayMode (aRemModeIter.Value());
+ }
- AIS_DisplayStatus aStatus;
+ if (!aStatus->IsDModeIn (theDispMode))
+ {
+ aStatus->AddDisplayMode (theDispMode);
+ }
- if (!HasOpenedContext())
+ myMainPM->Display (theIObj, theDispMode);
+ aStatus->SetGraphicStatus (AIS_DS_Displayed);
+ if (aStatus->IsHilighted())
{
- for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM (myObjects); ItM.More(); ItM.Next())
+ const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
+ myMainPM->Color (theIObj, aStatus->HilightColor(), aHiMod);
+ }
+ if (theSelectionMode != -1)
+ {
+ const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
+ if (!mgrSelector->Contains (anObj))
{
- aStatus = ItM.Value()->GraphicStatus();
- if (aStatus == AIS_DS_Erased)
- Display(ItM.Key(),Standard_False);
+ mgrSelector->Load (theIObj);
}
- if(updateviewer)
+ if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
{
- myMainVwr->Update();
+ if (!aStatus->IsSModeIn (theSelectionMode))
+ aStatus->AddSelectionMode (theSelectionMode);
+ mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
}
}
}
-
+
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
}
//=======================================================================
-//function : DisplaySelected
-//purpose :
+//function : Load
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theSelMode,
+ const Standard_Boolean theToAllowDecomposition)
{
-
- if (!HasOpenedContext())
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+
+ if (HasOpenedContext())
+ {
+ myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
+ return;
+ }
+
+ if (theSelMode == -1
+ && !theToAllowDecomposition)
{
- Standard_Boolean found = Standard_False;
- Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
- Handle(AIS_InteractiveObject) iObj;
- for (sel->Init(); sel->More(); sel->Next())
+ if (!myObjects.IsBound (theIObj))
{
- iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
- Display(iObj,Standard_False);
- found = Standard_True;
+ 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);
}
- if (found && updateviewer)
+
+ // 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))
{
- myMainVwr->Update();
+ mgrSelector->Load (theIObj);
}
}
}
-
//=======================================================================
-//function : EraseSelected
-//purpose :
+//function : Erase
+//purpose :
//=======================================================================
+void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theIObj->IsAutoHilight())
+ {
+ 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);
+ }
+
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
+}
-void AIS_InteractiveContext::EraseSelected(const Standard_Boolean updateviewer)
+//=======================================================================
+//function : EraseAll
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
{
- if (!HasOpenedContext())
+ if (HasOpenedContext())
{
- Standard_Boolean found = Standard_False;
- Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
- Handle(AIS_InteractiveObject) iObj;
- for (sel->Init();sel->More();sel->Next())
+ return;
+ }
+
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
{
- iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
- Erase(iObj,Standard_False);
- found = Standard_True;
+ Erase (anObjIter.Key(), Standard_False);
}
- if(found && updateviewer)
+ }
+
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
+}
+
+//=======================================================================
+//function : DisplayAll
+//purpose :
+//=======================================================================
+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();
+ if (aStatus == AIS_DS_Erased)
{
- myMainVwr->Update();
+ Display (anObjIter.Key(), Standard_False);
}
}
+
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
+}
+
+//=======================================================================
+//function : DisplaySelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
+{
+ if (HasOpenedContext())
+ {
+ return;
+ }
+
+ Standard_Boolean isFound = Standard_False;
+ Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
+ for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
+ {
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
+ Display (anObj, Standard_False);
+ isFound = Standard_True;
+ }
+
+ if (isFound && theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
+}
+
+//=======================================================================
+//function : EraseSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
+{
+ if (HasOpenedContext())
+ {
+ return;
+ }
+
+ Standard_Boolean isFound = Standard_False;
+ Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString());
+
+ aSelIter->Init();
+ while (aSelIter->More())
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelIter->Value());
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+
+ Erase (anObj, Standard_False);
+ isFound = Standard_True;
+
+ aSelIter->Init();
+ }
+
+ if (isFound && theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
}
+
//=======================================================================
//function :
//purpose :
return Standard_True;
}
-
//=======================================================================
-//purpose :
+//function : DisplayStatus
+//purpose :
//=======================================================================
-
-AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const
+AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
{
- if(anIObj.IsNull()) return AIS_DS_None;
-
- if(myObjects.IsBound(anIObj))
- return myObjects(anIObj)->GraphicStatus();
+ if (theIObj.IsNull())
+ {
+ return AIS_DS_None;
+ }
+ else if (myObjects.IsBound (theIObj))
+ {
+ return myObjects (theIObj)->GraphicStatus();
+ }
- AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
- for(;ItM.More();ItM.Next()){
- if(ItM.Value()->IsIn(anIObj))
+ 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 :
+//purpose :
//=======================================================================
-
-const TColStd_ListOfInteger& AIS_InteractiveContext::
-DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const
+const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
{
- return myObjects(anIObj)->DisplayedModes();
+ return myObjects (theIObj)->DisplayedModes();
}
-
//=======================================================================
//function : Remove
-//purpose :
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
-
- if(anIObj.IsNull()) return;
-
- if(!HasOpenedContext()){
- ClearGlobal(anIObj,updateviewer);
+ if (theIObj.IsNull())
+ {
+ return;
}
- else
+
+ if (HasOpenedContext())
+ {
+ myLocalContexts (myCurLocalIndex)->Remove (theIObj);
+ for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
{
- myLocalContexts(myCurLocalIndex)->Remove(anIObj);
- AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
- for (;It.More() ;It.Next()){
- if(It.Value()->AcceptErase())
- It.Value()->Remove(anIObj);
-
+ if (aCtxIter.Value()->AcceptErase())
+ {
+ aCtxIter.Value()->Remove (theIObj);
}
- // if(!WasInCtx)
- ClearGlobal(anIObj,updateviewer);
-// else
-// if(updateviewer) myMainVwr->Update();
}
+ }
+
+ ClearGlobal (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : RemoveAll
-//purpose :
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
{
AIS_ListOfInteractive aList;
- ObjectsInside(aList);
- AIS_ListIteratorOfListOfInteractive aListIterator;
- for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
- Remove(aListIterator.Value(), Standard_False);
+ ObjectsInside (aList);
+ for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
+ {
+ Remove (aListIterator.Value(), Standard_False);
}
-
- if(updateviewer)
- myMainVwr->Update();
-}
-
-//=======================================================================
-//function : Clear
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
-{
- if(anIObj.IsNull()) return;
-
- if(!HasOpenedContext()){
- ClearGlobal(anIObj,updateviewer);
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
}
- else
- {
-
- Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
- AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
- for (;It.More() ;It.Next()){
- if(It.Value()->AcceptErase())
- WasInCtx = It.Value()->Remove(anIObj);
-
- }
- if(!WasInCtx)
- ClearGlobal(anIObj,updateviewer);
- else
- if(updateviewer) myMainVwr->Update();
- }
}
-
-
-
//=======================================================================
//function : ClearPrs
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer aMode,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theMode,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return;
+ if (theIObj.IsNull())
+ {
+ return;
+ }
- if(!HasOpenedContext()){
- ClearGlobalPrs(anIObj,aMode,updateviewer);
+ if (!HasOpenedContext())
+ {
+ ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
+ return;
}
- else
+
+ Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
+ for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
+ {
+ if (aCtxIter.Value()->AcceptErase())
{
- Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode);
- AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
- for (;It.More() ;It.Next()){
- if(It.Value()->AcceptErase())
- WasInCtx = It.Value()->ClearPrs(anIObj,aMode);
- }
- if(!WasInCtx)
- ClearGlobalPrs(anIObj,aMode,updateviewer);
- else
- if(updateviewer) myMainVwr->Update();
-
+ wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
}
+ }
+ if (!wasInCtx)
+ {
+ ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
+ }
+ else if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
}
//=======================================================================
//function : Hilight
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return;
+ if (theIObj.IsNull())
+ {
+ return;
+ }
- if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
if (!HasOpenedContext())
{
- if(!myObjects.IsBound(anIObj)) return;
-
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
-
- // ENDCLE
- STATUS->SetHilightStatus (Standard_True);
+ if (!myObjects.IsBound (theIObj))
+ {
+ return;
+ }
- if (STATUS->GraphicStatus() == AIS_DS_Displayed)
+ Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
+ aStatus->SetHilightStatus (Standard_True);
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
- Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
- myMainPM->Highlight (anIObj, aHilightMode);
+ Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
+ myMainPM->Highlight (theIObj, aHilightMode);
}
}
else
{
- myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
+ myLocalContexts (myCurLocalIndex)->Hilight (theIObj);
}
- if(updateviewer) myMainVwr->Update();
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
}
//=======================================================================
//function : Hilight
{
if(!myObjects.IsBound(anIObj)) return;
- const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- STATUS->SetHilightStatus (Standard_True);
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
+ aStatus->SetHilightStatus (Standard_True);
- if (STATUS->GraphicStatus() == AIS_DS_Displayed)
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
- Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
+ const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
myMainPM->Color (anIObj, aCol, aHilightMode);
- STATUS->SetHilightColor (aCol);
+ aStatus->SetHilightColor (aCol);
}
}
else
{
if(!myObjects.IsBound(anIObj)) return;
- const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- STATUS->SetHilightStatus (Standard_False);
- STATUS->SetHilightColor(Quantity_NOC_WHITE);
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
+ aStatus->SetHilightStatus (Standard_False);
+ aStatus->SetHilightColor(Quantity_NOC_WHITE);
- if (STATUS->GraphicStatus() == AIS_DS_Displayed)
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{
Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
myMainPM->Unhighlight (anIObj, aHilightMode);
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)
+ {
+ theIsCustomColor = Standard_True;
+ theCustomColorName = anObjStatus->HilightColor();
+ }
+ else
+ {
+ theIsCustomColor = Standard_False;
+ }
+
+ return Standard_True;
+ }
+ return Standard_False;
+}
//=======================================================================
//function : IsDisplayed
//=======================================================================
//function : IsDisplayed
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::
-IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer aMode) const
+Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theMode) const
{
- if(anIObj.IsNull()) return Standard_False;
- if(myObjects.IsBound(anIObj)) {
- if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed &&
- myObjects(anIObj)->IsDModeIn(aMode))
+ if (theIObj.IsNull())
+ {
+ 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;
+ }
}
-
- AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
- for(;ItM.More();ItM.Next()){
- if(ItM.Value()->IsDisplayed(anIObj,aMode))
+
+ for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
+ {
+ if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
+ {
return Standard_True;
+ }
}
return Standard_False;
}
-
//=======================================================================
//function : DisplayPriority
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Integer AIS_InteractiveContext::
-DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const
+Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
{
- if(anIObj.IsNull()) return -1;
-
- if (myObjects.IsBound(anIObj))
+ if (theIObj.IsNull())
{
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
- if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
- {
- Standard_Integer aDispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
- (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
- return myMainPM->DisplayPriority (anIObj, aDispMode);
- }
+ return -1;
}
- return 0;
-}
+ else if (!myObjects.IsBound (theIObj))
+ {
+ return 0;
+ }
+
+ Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed
+ || aStatus->GraphicStatus() == AIS_DS_Erased)
+ {
+ Standard_Integer aDispMode = theIObj->HasDisplayMode()
+ ? theIObj->DisplayMode()
+ : (theIObj->AcceptDisplayMode (myDisplayMode)
+ ? myDisplayMode
+ : 0);
+ return myMainPM->DisplayPriority (theIObj, aDispMode);
+ }
+ return 0;
+}
+
//=======================================================================
//function : SetDisplayPriority
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer aPriority)
+void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer thePriority)
{
- if(anIObj.IsNull())
+ if (theIObj.IsNull())
+ {
return;
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- if(myObjects.IsBound(anIObj))
+ }
+
+ if (!theIObj->HasInteractiveContext())
{
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
+ theIObj->SetContext (this);
+ }
- if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
+ if (myObjects.IsBound (theIObj))
+ {
+ Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed
+ || aStatus->GraphicStatus() == AIS_DS_Erased)
{
- Standard_Integer aDisplayMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
- (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
- myMainPM->SetDisplayPriority (anIObj, aDisplayMode, aPriority);
+ Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
+ ? theIObj->DisplayMode()
+ : (theIObj->AcceptDisplayMode (myDisplayMode)
+ ? myDisplayMode
+ : 0);
+ myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
}
}
else if (HasOpenedContext())
{
- myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);
+ myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
}
}
//=======================================================================
//function : Redisplay
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer,
- const Standard_Boolean allmodes)
+void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer,
+ const Standard_Boolean theAllModes)
{
- if(AISDebugModeOn()){
- cout<<"===>AIS_InteractiveContext::Redisplay de :";
- cout<<anIObj->DynamicType()->Name()<<endl;
- }
-
- RecomputePrsOnly(anIObj,updateviewer,allmodes);
- RecomputeSelectionOnly(anIObj);
+ RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
+ RecomputeSelectionOnly (theIObj);
}
//=======================================================================
//function : Redisplay
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
- const Standard_Integer /*Sign*/,
- const Standard_Boolean updateviewer)
-{
- Standard_Boolean found_viewer(Standard_False);
- // update
- for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
- // CLE
- // const Handle(AIS_InteractiveObject)& IO = It.Key();
- Handle(AIS_InteractiveObject) IO = It.Key();
- // ENDCLE
- if(IO->Type()== KOI){
-#ifdef DEB
-// Standard_Boolean good = (Sign==-1)? Standard_True :
-// ((IO->Signature()==Sign)? Standard_True:Standard_False);
-#endif
- Redisplay(IO,Standard_False);
- if (It.Value()->GraphicStatus() == AIS_DS_Displayed)
- {
- found_viewer = Standard_True;
- }
+void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
+ const Standard_Integer /*theSign*/,
+ const Standard_Boolean theToUpdateViewer)
+{
+ Standard_Boolean isRedisplayed = Standard_False;
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
+ if (anObj->Type() != theKOI)
+ {
+ continue;
}
+
+ Redisplay (anObj, Standard_False);
+ isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
+ || isRedisplayed;
}
- // update viewer...
- if(updateviewer && found_viewer)
+
+ if (theToUpdateViewer
+ && isRedisplayed)
{
myMainVwr->Update();
}
}
-
//=======================================================================
//function : RecomputePrsOnly
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer,
- const Standard_Boolean allmodes)
+void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer,
+ const Standard_Boolean theAllModes)
{
- if(anIObj.IsNull()) return;
- anIObj->Update(allmodes);
+ if (theIObj.IsNull())
+ {
+ return;
+ }
- if (!updateviewer)
+ theIObj->Update (theAllModes);
+ if (!theToUpdateViewer)
{
return;
}
- if (HasOpenedContext() ||
- (myObjects.IsBound(anIObj) && myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed))
+ if (HasOpenedContext()
+ || (myObjects.IsBound (theIObj)
+ && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
{
myMainVwr->Update();
}
//function : RecomputeSelectionOnly
//purpose :
//=======================================================================
-void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj)
+void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
{
- if(anIObj.IsNull()) return;
- mgrSelector->RecomputeSelection(anIObj);
-
-
+ if (theIO.IsNull())
+ {
+ return;
+ }
- TColStd_ListOfInteger LI;
- TColStd_ListIteratorOfListOfInteger Lit;
- ActivatedModes(anIObj,LI);
- if(!HasOpenedContext()){
- if(!myObjects.IsBound(anIObj)) return;
+ mgrSelector->RecomputeSelection (theIO);
- if (myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
+ if (HasOpenedContext())
+ {
+ for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
{
- for(Lit.Initialize(LI);Lit.More();Lit.Next())
- {
- mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
- }
+ myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
}
+ return;
+ }
+
+ if (!myObjects.IsBound (theIO) ||
+ myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
+ {
+ return;
+ }
+
+ TColStd_ListOfInteger aModes;
+ ActivatedModes (theIO, aModes);
+ TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
+ for (; aModesIter.More(); aModesIter.Next())
+ {
+ mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
}
}
//=======================================================================
//function : Update
-//purpose :
+//purpose :
//=======================================================================
void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Boolean theUpdateViewer)
+ const Standard_Boolean theUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
- TColStd_ListOfInteger aListOfFlaggedPrsModes;
- theIObj->ToBeUpdated (aListOfFlaggedPrsModes);
-
- TColStd_ListIteratorOfListOfInteger aPrsModesIt (aListOfFlaggedPrsModes);
- for ( ; aPrsModesIt.More(); aPrsModesIt.Next())
+ TColStd_ListOfInteger aPrsModes;
+ theIObj->ToBeUpdated (aPrsModes);
+ for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
{
theIObj->Update (aPrsModesIt.Value(), Standard_False);
}
mgrSelector->Update(theIObj);
+ for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
+ {
+ myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
+ }
+
if (theUpdateViewer)
{
if (!myObjects.IsBound (theIObj))
//=======================================================================
//function : SetLocation
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj,
- const TopLoc_Location& aLoc)
+void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
+ const TopLoc_Location& theLoc)
{
- if(anIObj.IsNull()) return;
-
+ if (theIObj.IsNull())
+ {
+ return;
+ }
- if(anIObj->HasLocation() && aLoc.IsIdentity()){
- anIObj->ResetLocation();
- mgrSelector->Update(anIObj,Standard_False);
+ if (theIObj->HasTransformation()
+ && theLoc.IsIdentity())
+ {
+ theIObj->ResetTransformation();
+ mgrSelector->Update (theIObj, Standard_False);
+ return;
+ }
+ else if (theLoc.IsIdentity())
+ {
return;
}
- if(aLoc.IsIdentity()) return ;
// first reset the previous location to properly clean everything...
- if(anIObj->HasLocation())
- anIObj->ResetLocation();
+ if (theIObj->HasTransformation())
+ {
+ theIObj->ResetTransformation();
+ }
+ theIObj->SetLocalTransformation (theLoc.Transformation());
- anIObj->SetLocation(aLoc);
-
- if(!HasOpenedContext())
- mgrSelector->Update(anIObj,Standard_False);
+ if (!HasOpenedContext())
+ {
+ mgrSelector->Update (theIObj, Standard_False);
+ }
else
- {
- // CLE
- // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
- Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector();
- // ENDCLE
- mgrSelector->Update(anIObj,tempSel,Standard_False);
- }
+ {
+ Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
+ mgrSelector->Update (theIObj, aTempSel, Standard_False);
+ }
}
+
//=======================================================================
//function : ResetLocation
-//purpose :
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj)
+void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
{
- if(anIObj.IsNull()) return;
+ if (theIObj.IsNull())
+ {
+ return;
+ }
- anIObj->ResetLocation();
- mgrSelector->Update(anIObj,Standard_False);
+ theIObj->ResetTransformation();
+ mgrSelector->Update (theIObj, Standard_False);
}
//=======================================================================
//function : HasLocation
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::
-HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
+Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
{
- if(anIObj.IsNull()) return Standard_False;
-
- return anIObj->HasLocation();
+ return !theIObj.IsNull()
+ && theIObj->HasTransformation();
}
-const TopLoc_Location& AIS_InteractiveContext::
-Location(const Handle(AIS_InteractiveObject)& anIObj) const
+//=======================================================================
+//function : Location
+//purpose :
+//=======================================================================
+TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
{
- return anIObj->Location();
+ return theIObj->Transformation();
}
//=======================================================================
//function : SetDeviationCoefficient
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient)
+void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
{
- myDefaultDrawer->SetDeviationCoefficient(aCoefficient);
+ myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
}
+
//=======================================================================
//function : SetDeviationAngle
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
+void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
{
- myDefaultDrawer->SetDeviationCoefficient(anAngle);
+ myDefaultDrawer->SetDeviationAngle (theAngle);
}
//=======================================================================
//function : DeviationAngle
//purpose : Gets deviationAngle
//=======================================================================
-
Standard_Real AIS_InteractiveContext::DeviationAngle() const
{
- //return M_PI/180.0e0 ;
- return myDefaultDrawer->DeviationAngle();
+ return myDefaultDrawer->DeviationAngle();
}
//=======================================================================
//function : DeviationCoefficient
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
+Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
{
return myDefaultDrawer->DeviationCoefficient();
}
+
//=======================================================================
//function : SetHLRDeviationCoefficient
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient)
+void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
{
- myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient);
+ myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
}
//=======================================================================
//function : HLRDeviationCoefficient
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
+Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
{
return myDefaultDrawer->HLRDeviationCoefficient();
}
//=======================================================================
//function : SetHLRAngle
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle)
+void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
{
- myDefaultDrawer->SetHLRAngle(anAngle);
+ myDefaultDrawer->SetHLRAngle (theAngle);
}
//=======================================================================
// and set them in myHLRAngle and in myHLRDeviationCoefficient
// of myDefaultDrawer
//=======================================================================
-
-void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle)
+void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
{
+ Standard_Real anOutAngl, anOutDefl;
+ HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
- Standard_Real OutAngl,OutDefl;
- HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
-
- myDefaultDrawer->SetHLRAngle(OutAngl);
- myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl);
-
+ myDefaultDrawer->SetHLRAngle (anOutAngl);
+ myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
}
//=======================================================================
//function : HLRAngle
-//purpose :
+//purpose :
//=======================================================================
-
Standard_Real AIS_InteractiveContext::HLRAngle() const
{
return myDefaultDrawer->HLRAngle();
//=======================================================================
//function : SetDisplayMode
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
+ const Standard_Boolean theToUpdateViewer)
{
- if(aMode==myDisplayMode) return;
- AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
+ if (theMode == myDisplayMode)
+ {
+ return;
+ }
- for(;It.More();It.Next()){
- // CLE
- // const Handle(AIS_InteractiveObject)& anObj = It.Key();
- Handle(AIS_InteractiveObject) anObj = It.Key();
- // ENDCLE
- Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
- anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) ||
- anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) );
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
+ {
+ Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
+ Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
+ || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
+ || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
- if ((!anObj->HasDisplayMode()) && Processed)
+ if (!toProcess
+ || anObj->HasDisplayMode()
+ || !anObj->AcceptDisplayMode (theMode))
+ {
+ continue;
+ }
+
+ Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
+ if (aStatus->IsDModeIn (myDisplayMode))
+ {
+ aStatus->RemoveDisplayMode (myDisplayMode);
+ }
+
+ aStatus->AddDisplayMode (theMode);
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
+ {
+ myMainPM->Display (anObj, theMode);
+ if (!myLastPicked.IsNull() && myLastPicked->Selectable() == anObj)
{
- if(anObj->AcceptDisplayMode(aMode)){
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = It.Value();
- Handle(AIS_GlobalStatus) STATUS = It.Value();
- // ENDCLE
- if(STATUS->IsDModeIn(myDisplayMode))
- STATUS->RemoveDisplayMode(myDisplayMode);
-
- STATUS->AddDisplayMode(aMode);
-
- if(STATUS->GraphicStatus()== AIS_DS_Displayed){
- myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
- myMainPM->Display(anObj, aMode);
- if(STATUS->IsSubIntensityOn())
- myMainPM->Color(anObj,mySubIntensity,aMode);
- }
- // myDisplayMode = aMode;
- }
+ myMainPM->BeginImmediateDraw();
+ myMainPM->Unhighlight (anObj, myDisplayMode);
+ myMainPM->EndImmediateDraw (myMainVwr);
}
-
- }
- myDisplayMode = aMode;
- if(updateviewer) myMainVwr->Update();
+ if (aStatus->IsSubIntensityOn())
+ {
+ myMainPM->Color (anObj, mySubIntensity, theMode);
+ }
+ myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
+ }
+ }
+
+ myDisplayMode = theMode;
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
}
//=======================================================================
//function : SetDisplayMode
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer aMode,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theMode,
+ const Standard_Boolean theToUpdateViewer)
{
-
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- if(!HasOpenedContext()){
-
- if(!myObjects.IsBound(anIObj))
- anIObj->SetDisplayMode(aMode);
- else if( anIObj->AcceptDisplayMode(aMode) )
- {
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
- // ENDCLE
- // SAN : erase presentations for all display modes different from <aMode>
- if(STATUS->GraphicStatus()==AIS_DS_Displayed){
- TColStd_ListOfInteger aModesToRemove;
- TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
- for(;ItL.More();ItL.Next()){
-
- Standard_Integer OldMode = ItL.Value();
-
- if(OldMode!=aMode){
- aModesToRemove.Append(OldMode);
- if(myMainPM->IsHighlighted(anIObj,OldMode))
- myMainPM->Unhighlight(anIObj,OldMode);
- myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
- }
- }
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext(this);
+ }
- for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next())
- STATUS->RemoveDisplayMode(ItL.Value());
+ if (!myObjects.IsBound (theIObj))
+ {
+ theIObj->SetDisplayMode (theMode);
+ return;
+ }
+ else if (!theIObj->AcceptDisplayMode (theMode))
+ {
+ return;
+ }
- if(!STATUS->IsDModeIn(aMode))
- STATUS->AddDisplayMode(aMode);
+ Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
+ if (aStatus->GraphicStatus() != AIS_DS_Displayed)
+ {
+ theIObj->SetDisplayMode (theMode);
+ return;
+ }
- myMainPM->Display(anIObj,aMode);
- Standard_Integer DM,HM,SM;
- GetDefModes(anIObj,DM,HM,SM);
- if(STATUS->IsHilighted()){
- myMainPM->Highlight(anIObj,HM);
- }
- if(STATUS->IsSubIntensityOn()){
- myMainPM->Color(anIObj,mySubIntensity,aMode);
- }
- if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
- myMainVwr->Viewer()->SetTransparency(Standard_True);
-
- if(updateviewer) myMainVwr->Update();
+ // 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 = aDispModeIter.Value();
+ if (anOldMode != theMode)
+ {
+ aModesToRemove.Append (anOldMode);
+ if (myMainPM->IsHighlighted (theIObj, anOldMode))
+ {
+ myMainPM->Unhighlight (theIObj, anOldMode);
}
- anIObj->SetDisplayMode(aMode);
+ 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);
+ }
+
+ myMainPM->Display (theIObj, theMode);
+ Standard_Integer aDispMode, aHiMode, aSelMode;
+ GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
+ if (aStatus->IsHilighted())
+ {
+ myMainPM->Highlight (theIObj, aHiMode);
+ }
+ if (aStatus->IsSubIntensityOn())
+ {
+ myMainPM->Color (theIObj, mySubIntensity, theMode);
+ }
+
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
+ theIObj->SetDisplayMode (theMode);
}
//=======================================================================
//function : UnsetDisplayMode
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::
-UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- if(!anIObj->HasDisplayMode()) return;
-
- if(!myObjects.IsBound(anIObj))
- anIObj->UnsetDisplayMode();
- else
+ if (theIObj.IsNull()
+ || !theIObj->HasDisplayMode())
+ {
+ return;
+ }
+
+ if (!myObjects.IsBound (theIObj))
+ {
+ theIObj->UnsetDisplayMode();
+ return;
+ }
+
+ const Standard_Integer anOldMode = theIObj->DisplayMode();
+ if (myDisplayMode == anOldMode)
+ {
+ return;
+ }
+
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
+ aStatus->RemoveDisplayMode (anOldMode);
+ if (!aStatus->IsDModeIn(myDisplayMode))
+ {
+ aStatus->AddDisplayMode (myDisplayMode);
+ }
+
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed)
+ {
+ if (myMainPM->IsHighlighted (theIObj, anOldMode))
{
- Standard_Integer OldMode = anIObj->DisplayMode();
- if(myDisplayMode==OldMode) return;
- const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- STATUS->RemoveDisplayMode(OldMode);
- if(!STATUS->IsDModeIn(myDisplayMode))
- STATUS->AddDisplayMode(myDisplayMode);
- if(STATUS->GraphicStatus()==AIS_DS_Displayed){
- if(myMainPM->IsHighlighted(anIObj,OldMode))
- myMainPM->Unhighlight(anIObj,OldMode);
- myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
- myMainPM->Display(anIObj,myDisplayMode);
- Standard_Integer DM,HM,SM;
- GetDefModes(anIObj,DM,HM,SM);
- if(STATUS->IsHilighted()){
- myMainPM->Highlight(anIObj,HM);
- }
- if(STATUS->IsSubIntensityOn()){
- myMainPM->Color(anIObj,mySubIntensity,myDisplayMode);
- }
- if(updateviewer) myMainVwr->Update();
- }
- anIObj->UnsetDisplayMode();
-
+ myMainPM->Unhighlight (theIObj, anOldMode);
+ }
+ myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
+ myMainPM->Display (theIObj, myDisplayMode);
+
+ Standard_Integer aDispMode, aHiMode, aSelMode;
+ GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
+ if (aStatus->IsHilighted())
+ {
+ myMainPM->Highlight (theIObj, aHiMode);
+ }
+ if (aStatus->IsSubIntensityOn())
+ {
+ myMainPM->Color (theIObj, mySubIntensity, myDisplayMode);
+ }
+
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
}
+ }
+
+ theIObj->UnsetDisplayMode();
}
//=======================================================================
//function : SetCurrentFacingModel
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetCurrentFacingModel(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Aspect_TypeOfFacingModel aModel)
+void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
+ const Aspect_TypeOfFacingModel theModel)
{
- if ( !anIObj.IsNull () )
- anIObj->SetCurrentFacingModel(aModel);
+ if (!theIObj.IsNull())
+ {
+ theIObj->SetCurrentFacingModel (theModel);
+ }
}
//=======================================================================
-//function : SetColor
-//purpose :
+//function : redisplayPrsRecModes
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
- const Quantity_NameOfColor aColor,
- const Standard_Boolean updateviewer)
-{
- SetColor(anIObj,Quantity_Color(aColor),updateviewer);
-}
-
-void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj,
- const Quantity_Color &aColor,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
-
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- anIObj->SetColor(aColor);
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
+ if (theIObj->RecomputeEveryPrs())
+ {
+ theIObj->Update (Standard_True);
+ theIObj->UpdateSelection();
+ }
else
+ {
+ for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
{
- Standard_Integer NbDisp=0;
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
- anIObj->SetRecomputeOk();
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- }
-
-
-#ifdef DEB
-// // pour isg
-// if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){
-// Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj);
-// Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength();
-// gp_Trsf T;
-// gp_Dir D =Tr->Component()->XDirection();
-// gp_Pnt O = Tr->Component()->Location();
-// gp_Vec V(D);V*=Lx/5.;
-// T.SetRotation(gp_Ax1(O,D),M_PI/6.);
-// T.SetTranslationPart(V);
-// TopLoc_Location L,IncLoc(T);
-
-// for(Standard_Integer I=1;I<90;I++){
-// if(anIObj->HasLocation())
-// L = anIObj->Location() * IncLoc;
-// else
-// L = IncLoc;
-// SetLocation(anIObj,L);
-// UpdateCurrentViewer();
-// }
-// for(I=1;I<90;I++){
-// L = anIObj->Location() /IncLoc;
-// SetLocation(anIObj,L);
-// UpdateCurrentViewer();
-// }
-// ResetLocation(anIObj);
-// }
- #endif
- if(updateviewer) UpdateCurrentViewer();
+ theIObj->Update (aModes.Value(), Standard_False);
+ }
+ theIObj->UpdateSelection();
+ theIObj->SetRecomputeOk();
+ }
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
-//function : SetDeviationCoefficient
-//purpose :
+//function : redisplayPrsModes
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetDeviationCoefficient(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real aCoefficient,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
-// cout<<" Coefficient:"<< aCoefficient <<endl;
- if(anIObj.IsNull()) return ;
-
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
-
- // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
- if(anIObj->Signature()!=0) return;
- (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient);
-
-
-
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
+ 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())
{
- Standard_Integer NbDisp=0;
- TColStd_ListOfInteger LL;
- anIObj->ToBeUpdated(LL);
- TColStd_ListIteratorOfListOfInteger ITI(LL);
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
- anIObj->SetRecomputeOk();
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
+ theIObj->Update (aModeIter.Value(), Standard_False);
}
- if(updateviewer) UpdateCurrentViewer();
+ theIObj->SetRecomputeOk();
+ }
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
//=======================================================================
-//function : SetHLRDeviationCoefficient
-//purpose :
+//function : SetColor
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetHLRDeviationCoefficient(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real aCoefficient,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
+ const Quantity_NameOfColor theColor,
+ const Standard_Boolean theToUpdateViewer)
{
-// cout<<" HLRCoefficient:"<< aCoefficient <<endl;
- if(anIObj.IsNull()) return ;
-
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return;
- if(anIObj->Signature()!=0) return;
- (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient);
+ SetColor (theIObj, Quantity_Color(theColor), theToUpdateViewer);
+}
+//=======================================================================
+//function : SetColor
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
+ const Quantity_Color& theColor,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+ theIObj->SetColor (theColor);
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
+}
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- Standard_Integer NbDisp=0;
+//=======================================================================
+//function : SetIsoOnTriangulation
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theIsEnabled,
+ const Handle(AIS_InteractiveObject)& theObject)
+{
+ if (theObject.IsNull())
+ {
+ return;
+ }
- TColStd_ListOfInteger LL;
- anIObj->ToBeUpdated(LL);
- TColStd_ListIteratorOfListOfInteger ITI(LL);
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
- anIObj->SetRecomputeOk();
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- }
- if(updateviewer) UpdateCurrentViewer();
+ theObject->SetIsoOnTriangulation (theIsEnabled);
}
-
//=======================================================================
-//function : SetDeviationAngle
-//purpose :
+//function : SetDeviationCoefficient
+//purpose :
//=======================================================================
+void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theCoefficient,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
-void AIS_InteractiveContext::SetDeviationAngle(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real anAngle,
- const Standard_Boolean updateviewer)
+ 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)
{
-// cout<<" Angle:"<< anAngle <<endl;
- if(anIObj.IsNull()) return ;
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if(anIObj->Type()!=AIS_KOI_Shape) return;
- if(anIObj->Signature()!=0) return;
- (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle);
-
+ if (theIObj->Type() != AIS_KOI_Object
+ && theIObj->Type() != AIS_KOI_Shape)
+ {
+ return;
+ }
+ else if (theIObj->Signature() != 0)
+ {
+ return;
+ }
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- Standard_Integer NbDisp=0;
- TColStd_ListOfInteger LL;
- anIObj->ToBeUpdated(LL);
- TColStd_ListIteratorOfListOfInteger ITI(LL);
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
- anIObj->SetRecomputeOk();
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- }
- if(updateviewer) UpdateCurrentViewer();
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
+ aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
+ redisplayPrsModes (theIObj, theToUpdateViewer);
}
+
//=======================================================================
//function : SetDeviationAngle
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetAngleAndDeviation(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real anAngle,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theAngle,
+ const Standard_Boolean theToUpdateViewer)
{
-// cout<<" Angle:"<< anAngle <<endl;
- if(anIObj.IsNull()) return ;
-// Standard_Real anAngleRad = M_PI*anAngle/180; test rob...
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
+ 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(anIObj->Type()!=AIS_KOI_Shape) return;
- if(anIObj->Signature()!=0) return;
- (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle);
-
+ if (theIObj->Type() != AIS_KOI_Shape)
+ {
+ return;
+ }
+ else if (theIObj->Signature() != 0)
+ {
+ return;
+ }
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- Update(anIObj,updateviewer);
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
+ aShape->SetOwnDeviationAngle (theAngle);
+ redisplayPrsModes (theIObj, theToUpdateViewer);
}
//=======================================================================
-//function : SetDeviationAngle
-//purpose :
+//function : SetAngleAndDeviation
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetHLRAngleAndDeviation(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real anAngle,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theAngle,
+ const Standard_Boolean theToUpdateViewer)
{
-// cout<<" Angle:"<< anAngle <<endl;
+ if (theIObj.IsNull())
+ {
+ return;
+ }
- if(anIObj.IsNull()) return ;
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if(anIObj->Type()!=AIS_KOI_Shape) return;
- if(anIObj->Signature()!=0) return;
- (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle);
+ if (theIObj->Type() != AIS_KOI_Shape)
+ {
+ return;
+ }
+ if (theIObj->Signature() != 0)
+ {
+ return;
+ }
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
+ aShape->SetAngleAndDeviation (theAngle);
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
+ if (theIObj->RecomputeEveryPrs())
+ {
+ theIObj->Update (Standard_True);
+ theIObj->UpdateSelection();
+ }
else
- {
- Standard_Integer NbDisp=0;
+ {
+ Update (theIObj, theToUpdateViewer);
+ }
+}
- TColStd_ListOfInteger LL;
- anIObj->ToBeUpdated(LL);
- TColStd_ListIteratorOfListOfInteger ITI(LL);
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
- anIObj->SetRecomputeOk();
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- }
- if(updateviewer) UpdateCurrentViewer();
+//=======================================================================
+//function : SetHLRAngleAndDeviation
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetHLRAngleAndDeviation (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;
+ }
+ if (theIObj->Signature() != 0)
+ {
+ return;
+ }
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
+ aShape->SetHLRAngleAndDeviation (theAngle);
+ redisplayPrsModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : SetHLRDeviationAngle
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetHLRDeviationAngle(
- const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real anAngle,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theAngle,
+ const Standard_Boolean theToUpdateViewer)
{
-// cout<<" HLRAngle:"<< anAngle <<endl;
- if(anIObj.IsNull()) return ;
-
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
- if( anIObj->Type()!=AIS_KOI_Shape) return;
- if(anIObj->Signature()!=0) return;
- (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle);
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- Standard_Integer NbDisp=0;
- TColStd_ListOfInteger LL;
- anIObj->ToBeUpdated(LL);
- TColStd_ListIteratorOfListOfInteger ITI(LL);
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
- anIObj->SetRecomputeOk();
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- }
- if(updateviewer) UpdateCurrentViewer();
+ // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
+ if (theIObj->Type() != AIS_KOI_Shape)
+ {
+ return;
+ }
+ if (theIObj->Signature() != 0)
+ {
+ return;
+ }
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
+ aShape->SetOwnHLRDeviationAngle (theAngle);
+ redisplayPrsModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : UnsetColor
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- anIObj->UnsetColor();
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- Standard_Integer NbDisp =0;
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- anIObj->SetRecomputeOk();
- }
- if(updateviewer)
- UpdateCurrentViewer();
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ theIObj->UnsetColor();
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : HasColor
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const
+Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
{
- return anIObj->HasColor();
-
+ return theIObj->HasColor();
}
//=======================================================================
//function : Color
-//purpose :
+//purpose :
//=======================================================================
-
-Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const
+Quantity_NameOfColor AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj) const
{
- return anIObj->Color();
+ return theIObj->Color();
}
-void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
- Quantity_Color &aColor) const
+//=======================================================================
+//function : Color
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
+ Quantity_Color& theColor) const
{
- anIObj->Color(aColor);
+ theIObj->Color (theColor);
}
//=======================================================================
//function : Width
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const
+Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
{
- return anIObj->Width();
+ return theIObj->Width();
}
//=======================================================================
//function : SetWidth
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real aValue,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theWidth,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
-
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- anIObj->SetWidth(aValue);
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+
+ theIObj->SetWidth (theWidth);
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
+ if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj)
+ {
+ if (myLastinMain->IsAutoHilight())
{
- Standard_Integer NbDisp=0;
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- NbDisp++;
- }
-#ifdef DEB
- cout<<"nb of modes to recalculate : "<<NbDisp<<endl;
-#endif
- anIObj->SetRecomputeOk();
+ const Standard_Integer aHiMode =
+ theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
+ myLastinMain->HilightWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, aHiMode);
}
- if(updateviewer)
- UpdateCurrentViewer();
+ else
+ {
+ theIObj->HilightOwnerWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, myLastinMain);
+ }
+ }
}
//=======================================================================
//function : UnsetWidth
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- anIObj->UnsetWidth();
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- }
- anIObj->SetRecomputeOk();
- }
- if(updateviewer)
- UpdateCurrentViewer();
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ theIObj->UnsetWidth();
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : SetMaterial
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
-//POP pour K4L
- const Graphic3d_NameOfMaterial aName,
-// const Graphic3d_NameOfPhysicalMaterial aName,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
+ const Graphic3d_NameOfMaterial theName,
+ const Standard_Boolean theToUpdateViewer)
{
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- anIObj->SetMaterial(aName);
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- }
- anIObj->SetRecomputeOk();
- }
- if(updateviewer)
- UpdateCurrentViewer();
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+
+ theIObj->SetMaterial (theName);
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : UnsetMaterial
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- anIObj->UnsetMaterial();
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- }
- anIObj->SetRecomputeOk();
- }
- if(updateviewer)
- UpdateCurrentViewer();
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+ theIObj->UnsetMaterial();
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : SetTransparency
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Real aValue,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Real theValue,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
+ if (theIObj.IsNull())
+ {
+ return;
+ }
-#ifdef BUC60577 //right optimization
- if(!anIObj->IsTransparent() && aValue<=0.05) return;
-#else
-// if(!anIObj->IsTransparent() && aValue<=0.05) return;
-#endif
- if(aValue<=0.05){
- UnsetTransparency(anIObj,updateviewer);
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+
+ if (!theIObj->IsTransparent()
+ && theValue <= 0.05)
+ {
return;
}
-
- if(!myMainVwr->Viewer()->Transparency())
- myMainVwr->Viewer()->SetTransparency(Standard_True);
- anIObj->SetTransparency(aValue);
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- }
- anIObj->SetRecomputeOk();
- }
- if(updateviewer)
- UpdateCurrentViewer();
+
+ if (theValue <= 0.05)
+ {
+ UnsetTransparency (theIObj, theToUpdateViewer);
+ return;
+ }
+
+ theIObj->SetTransparency (theValue);
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
}
//=======================================================================
//function : UnsetTransparency
-//purpose :
+//purpose :
//=======================================================================
+void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
-void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+ theIObj->UnsetTransparency();
+ redisplayPrsRecModes (theIObj, theToUpdateViewer);
+}
+
+//=======================================================================
+//function : SetSelectedAspect
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
+ const Standard_Boolean theIsGlobalChange,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- anIObj->UnsetTransparency();
- if(anIObj->RecomputeEveryPrs())
- anIObj->Redisplay();
- else
- {
- TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes());
- for (;ITI.More();ITI.Next())
- {
- anIObj->Update(ITI.Value(),Standard_False);
- }
- anIObj->SetRecomputeOk();
- }
+ if (HasOpenedContext())
+ {
+ return;
+ }
- // To Unset transparency in the viewer, if no other object is transparent ...(Speed)
- AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
- Standard_Boolean FoundTransp(Standard_False);
- for(;It.More() && !FoundTransp ;It.Next()){
- if(It.Key()->IsTransparent())
- FoundTransp = Standard_True;
+ Standard_Boolean isFound = Standard_False;
+ Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
+ for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
+ {
+ isFound = Standard_True;
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
+ anObj->SetAspect (theAspect, theIsGlobalChange);
+ }
+
+ if (isFound
+ && theToUpdateViewer)
+ {
+ myMainVwr->Update();
}
- if(!FoundTransp)
- myMainVwr->Viewer()->SetTransparency(Standard_False);
-
-
- if(updateviewer)
- UpdateCurrentViewer();
}
//=======================================================================
-//function : SetSelectedAspect
-//purpose :
+//function : SetLocalAttributes
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetSelectedAspect(
- const Handle(Prs3d_BasicAspect)& anAspect,
- const Standard_Boolean globalChange,
- const Standard_Boolean updateViewer)
-{
- if( !HasOpenedContext() ) {
- Standard_Boolean found = Standard_False;
- Handle(AIS_Selection) sel =
- AIS_Selection::Selection(myCurrentName.ToCString());
- Handle(AIS_InteractiveObject) object;
- for( sel->Init() ; sel->More() ; sel->Next()) {
- found = Standard_True;
- object = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
- object->SetAspect(anAspect,globalChange);
- }
- if( found && updateViewer) {
- myMainVwr->Update();
+void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
+ const Handle(Prs3d_Drawer)& theDrawer,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+
+ theIObj->SetAttributes (theDrawer);
+ Update (theIObj, theToUpdateViewer);
+}
+
+//=======================================================================
+//function : UnsetLocalAttributes
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theIObj->HasInteractiveContext())
+ {
+ theIObj->SetContext (this);
+ }
+ theIObj->UnsetAttributes();
+ Update (theIObj, theToUpdateViewer);
+}
+
+//=======================================================================
+//function : Status
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
+ TCollection_ExtendedString& theStatus) const
+{
+ theStatus = "";
+ if (theIObj.IsNull()
+ || !myObjects.IsBound (theIObj))
+ {
+ return;
+ }
+
+ theStatus += "\t ____________________________________________";
+ theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
+ switch (aStatus->GraphicStatus())
+ {
+ case AIS_DS_Displayed:
+ {
+ theStatus += "\t| -->Displayed\n";
+ break;
+ }
+ case AIS_DS_Erased:
+ {
+ theStatus += "\t| -->Erased\n";
+ break;
}
+ default:
+ break;
+ }
+
+ 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";
}
+ if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
+
+ theStatus += "\t| Active Selection Modes in the MainViewer :\n";
+ for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
+ {
+ theStatus += "\t\t Mode ";
+ theStatus += TCollection_AsciiString (aSelModeIter.Value());
+ theStatus += "\n";
+ }
+ theStatus += "\t ____________________________________________";
}
//=======================================================================
-//function : SetLocalAttributes
-//purpose :
+//function : GetDefModes
+//purpose :
//=======================================================================
+void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
+ Standard_Integer& theDispMode,
+ Standard_Integer& theHiMode,
+ Standard_Integer& theSelMode) const
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
-void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
- const Handle(AIS_Drawer)& aDrawer,
- const Standard_Boolean updateviewer)
-{
- if(anIObj.IsNull()) return ;
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- anIObj->SetAttributes(aDrawer);
- Update(anIObj,updateviewer);
-
+ theDispMode = theIObj->HasDisplayMode()
+ ? theIObj->DisplayMode()
+ : (theIObj->AcceptDisplayMode (myDisplayMode)
+ ? myDisplayMode
+ : 0);
+ theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
+ theSelMode = theIObj->GlobalSelectionMode();
}
//=======================================================================
-//function : UnsetLocalAttributes
-//purpose :
+//function : EraseGlobal
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateviewer)
{
- if(anIObj.IsNull()) return ;
- if(!anIObj->HasInteractiveContext())
- anIObj->SetContext(this);
- anIObj->UnsetAttributes();
- Update(anIObj,updateviewer);
-}
-
+ if (theIObj.IsNull()
+ || !myObjects.IsBound (theIObj))
+ {
+ return;
+ }
-//=======================================================================
-//function : Status
-//purpose :
-//=======================================================================
+ Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
-void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const
-{
- astatus = "";
+ const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
+ if (aStatus->GraphicStatus() == AIS_DS_Temporary
+ || aStatus->GraphicStatus() == AIS_DS_Erased)
+ {
+ return;
+ }
- if(anIObj.IsNull()) return ;
- if(myObjects.IsBound(anIObj)){
- astatus += "\t ____________________________________________";
- astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
- const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj);
- switch(ST->GraphicStatus()){
- case AIS_DS_Displayed:
+ for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+ {
+ if (aStatus->IsHilighted())
+ {
+ if (IsCurrent (theIObj))
{
- astatus +="\t| -->Displayed\n";
- break;
+ AddOrRemoveCurrentObject (theIObj, Standard_False);
}
- case AIS_DS_Erased:
+ else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
{
- astatus +="\t| -->Erased\n";
- break;
+ myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
}
- default:
- break;
}
- astatus += "\t| Active Display Modes in the MainViewer :\n";
- TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes());
- for(;ItL.More();ItL.Next()){
- astatus += "\t|\t Mode ";
- astatus += TCollection_AsciiString(ItL.Value());
- astatus+="\n";
- }
- if(IsCurrent(anIObj)) astatus +="\t| Current\n";
- if(IsSelected(anIObj)) astatus +="\t| Selected\n";
- astatus += "\t| Active Selection Modes in the MainViewer :\n";
- for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){
- astatus += "\t\t Mode ";
- astatus += TCollection_AsciiString(ItL.Value());
- astatus+="\n";
- }
- astatus += "\t ____________________________________________";
-
- }
-}
+ myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
+ }
+ if (IsSelected (theIObj)
+ && !aStatus->IsDModeIn (aDispMode))
+ {
+ myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
+ }
-//=======================================================================
-//function : GetDefModes
-//purpose :
-//=======================================================================
+ for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
+ {
+ mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
+ }
+ aStatus->ClearSelectionModes();
+ aStatus->SetGraphicStatus (AIS_DS_Erased);
-void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj,
- Standard_Integer& DispMode,
- Standard_Integer& HiMode,
- Standard_Integer& SelMode) const
-{
- if(anIObj.IsNull()) return ;
- DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() :
- (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
-
- HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode;
-#ifdef BUC61051
- SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1;
-#else
- SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0;
-#endif
+ if (theToUpdateviewer)
+ {
+ myMainVwr->Update();
+ }
}
-
//=======================================================================
-//function : EraseGlobal
-//purpose :
+//function : unhighlightOwners
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject)
{
- if(anIObj.IsNull()) return ;
- if(!myObjects.IsBound(anIObj)) return;
-
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
- // ENDCLE
- Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
- if(STATUS->GraphicStatus()==AIS_DS_Displayed){
-
- TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
- for(;ItL.More();ItL.Next()){
- if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
- myMainPM->Unhighlight(anIObj,ItL.Value());
- myMainPM->SetVisibility (anIObj, ItL.Value(), Standard_False);
- }
- if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
- myMainPM->SetVisibility (anIObj, Dmode, Standard_False);
-
- for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
- mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
- if(updateviewer) myMainVwr->Update();
+ Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
+ aSel->Init();
+ while (aSel->More())
+ {
+ const Handle(SelectMgr_EntityOwner) anOwner =
+ Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
+ if (anOwner->Selectable() == theObject)
+ {
+ if (anOwner->IsSelected())
+ {
+ AddOrRemoveSelected (anOwner, Standard_False);
+ aSel->Init();
+ continue;
+ }
+ }
+ aSel->Next();
}
- STATUS->SetGraphicStatus(AIS_DS_Erased);
-
}
//=======================================================================
//function : ClearGlobal
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Boolean theToUpdateviewer)
{
- if(anIObj.IsNull()) return ;
- if(!myObjects.IsBound(anIObj)) return;
- // CLE
- // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
- Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
- // ENDCLE
- TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
- for(;ItL.More();ItL.Next()){
- if(STATUS->IsHilighted()){
- if(IsCurrent(anIObj))
-#ifdef OCC204
- AddOrRemoveCurrentObject( anIObj, updateviewer );
-#else
- AddOrRemoveCurrentObject(anIObj);
-#endif
- else if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
- myMainPM->Unhighlight(anIObj,ItL.Value());
- }
- myMainPM->Erase(anIObj,ItL.Value());
- myMainPM->Clear(anIObj,ItL.Value());
- if(anIObj->HasHilightMode()){
- Standard_Integer im = anIObj->HilightMode();
- myMainPM->Unhighlight(anIObj,im);
- myMainPM->Erase(anIObj,im);
-
- }
- }
+ if (theIObj.IsNull()
+ || !myObjects.IsBound (theIObj))
+ {
+ // for cases when reference shape of connected interactives was not displayed
+ // but its selection primitives were calculated
+ const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
+ mgrSelector->Remove (anObj);
+ 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());
+ }
- //Object removes from Detected sequence
- Standard_Integer i = 1;
- for(i = 1; i < myAISDetectedSeq.Length(); i++)
+ // Object removes from Detected sequence
+ for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
{
Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
- if( !anObj.IsNull() && anObj != anIObj )
- myAISDetectedSeq.Remove( i );
+ if (!anObj.IsNull()
+ && anObj != theIObj)
+ {
+ myAISDetectedSeq.Remove (aDetIter);
+ }
}
- if(myLastinMain == anIObj)
- myLastinMain.Nullify();
+ // remove IO from the selection manager to avoid memory leaks
+ const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
+ mgrSelector->Remove (anObj);
- if(myLastPicked == anIObj)
- myLastPicked.Nullify();
+ myObjects.UnBind (theIObj);
+ myMainVwr->StructureManager()->UnregisterObject (theIObj);
+ for (myMainVwr->InitDefinedViews(); myMainVwr->MoreDefinedViews(); myMainVwr->NextDefinedViews())
+ {
+ myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
+ }
- // OCC21671: Remove IO from the selection manager in any case
- // to avoid memory leaks
- mgrSelector->Remove(anIObj);
+ if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj)
+ myLastinMain.Nullify();
+ if (!myLastPicked.IsNull() && myLastPicked->Selectable() == theIObj)
+ myLastPicked.Nullify();
+ myMainPM->ClearImmediateDraw();
- if (updateviewer && (STATUS->GraphicStatus() == AIS_DS_Displayed))
+ if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed)
{
myMainVwr->Update();
}
-
- myObjects.UnBind(anIObj);
-
}
//=======================================================================
//function : ClearGlobalPrs
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Integer aMode,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theMode,
+ const Standard_Boolean theToUpdateViewer)
{
- if(anIObj.IsNull()) return ;
- if(!myObjects.IsBound(anIObj)) return;
- const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
-
- Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
- if(STATUS->IsDModeIn(aMode)){
- if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode))
- myMainPM->Unhighlight(anIObj,aMode);
-
- myMainPM->Erase(anIObj,aMode);
- myMainPM->Clear(anIObj,aMode);
+ if (theIObj.IsNull()
+ || !myObjects.IsBound (theIObj))
+ {
+ return;
+ }
+
+ const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
+ if (aStatus->IsDModeIn (theMode))
+ {
+ const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
+ if (aDispMode == theMode
+ && myMainPM->IsHighlighted (theIObj, theMode))
+ {
+ myMainPM->Unhighlight (theIObj, theMode);
+ }
+
+ myMainPM->Erase (theIObj, theMode);
+ myMainPM->Clear (theIObj, theMode);
}
-
- if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
+ if (aStatus->GraphicStatus() == AIS_DS_Displayed
+ && theToUpdateViewer)
+ {
myMainVwr->Update();
+ }
}
//=======================================================================
//function : DrawHiddenLine
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const {
-
+Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
+{
return myDefaultDrawer->DrawHiddenLine();
}
//=======================================================================
//function : EnableDrawHiddenLine
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::EnableDrawHiddenLine () const {
+void AIS_InteractiveContext::EnableDrawHiddenLine() const
+{
myDefaultDrawer->EnableDrawHiddenLine();
}
//=======================================================================
//function : DisableDrawHiddenLine
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::DisableDrawHiddenLine () const {
+void AIS_InteractiveContext::DisableDrawHiddenLine() const
+{
myDefaultDrawer->DisableDrawHiddenLine();
}
//=======================================================================
//function : HiddenLineAspect
-//purpose :
+//purpose :
//=======================================================================
-
-Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const {
+Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
+{
return myDefaultDrawer->HiddenLineAspect();
}
//=======================================================================
//function : SetHiddenLineAspect
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const {
- myDefaultDrawer->SetHiddenLineAspect(anAspect);
+void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
+{
+ myDefaultDrawer->SetHiddenLineAspect (theAspect);
}
//=======================================================================
//function : SetIsoNumber
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type)
+void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
+ const AIS_TypeOfIso theType)
{
- switch(Type){
- case AIS_TOI_IsoU:
- myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
- break;
- case AIS_TOI_IsoV:
- myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
- break;
- case AIS_TOI_Both:
- myDefaultDrawer->UIsoAspect()->SetNumber(Nb);
- myDefaultDrawer->VIsoAspect()->SetNumber(Nb);
- break;
-
+ switch (theType)
+ {
+ case AIS_TOI_IsoU:
+ myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
+ break;
+ case AIS_TOI_IsoV:
+ myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
+ break;
+ case AIS_TOI_Both:
+ myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
+ myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
+ break;
}
}
+
//=======================================================================
//function : IsoNumber
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type)
+Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
{
-
- switch(Type){
- case AIS_TOI_IsoU:
- return myDefaultDrawer->UIsoAspect()->Number();
- case AIS_TOI_IsoV:
- return myDefaultDrawer->VIsoAspect()->Number();
- case AIS_TOI_Both:
- return (myDefaultDrawer->UIsoAspect()->Number()==
- myDefaultDrawer->VIsoAspect()->Number()) ?
- myDefaultDrawer->UIsoAspect()->Number(): -1;
+ switch (theType)
+ {
+ case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
+ case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
+ case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
+ ? myDefaultDrawer->UIsoAspect()->Number()
+ : -1;
}
return 0;
}
//=======================================================================
//function : IsoOnPlane
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn)
+void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
{
- myDefaultDrawer->SetIsoOnPlane(SwitchOn);
+ myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
}
//=======================================================================
//function : IsoOnPlane
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
+Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
{
return myDefaultDrawer->IsoOnPlane();
}
//=======================================================================
-//function : SetSelectionMode
-//purpose :
+//function : IsoOnTriangulation
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetSelectionMode(const Handle(AIS_InteractiveObject)&, const Standard_Integer )
+void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theToSwitchOn)
{
+ myDefaultDrawer->SetIsoOnTriangulation (theToSwitchOn);
}
//=======================================================================
-//function : UnsetSelectionMode
-//purpose :
+//function : IsoOnTriangulation
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::UnsetSelectionMode(const Handle(AIS_InteractiveObject)&)
+Standard_Boolean AIS_InteractiveContext::IsoOnTriangulation() const
{
+ 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
//=======================================================================
-//function : SetSensitivityMode
-//purpose :
-//=======================================================================
-
-void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
-
- if( HasOpenedContext() )
- myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
- else {
- myMainSel->SetSensitivityMode(aMode);
+void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
+{
+ if (HasOpenedContext())
+ {
+ myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
}
-}
-
-//=======================================================================
-//function : SensitivityMode
-//purpose :
-//=======================================================================
-
-StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
-
- if( HasOpenedContext() )
- return myLocalContexts(myCurLocalIndex)->SensitivityMode();
- return myMainSel->SensitivityMode();
-}
-
-//=======================================================================
-//function : SetSensitivity
-//purpose :
-//=======================================================================
-
-void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
-
- if( HasOpenedContext() )
- myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
- else {
- myMainSel->SetSensitivity(aPrecision);
+ else
+ {
+ myMainSel->SetPixelTolerance (thePrecision);
}
}
//=======================================================================
-//function : Sensitivity
-//purpose :
+//function : PixelTolerance
+//purpose :
//=======================================================================
-
-Standard_Real AIS_InteractiveContext::Sensitivity() const {
-
- if( HasOpenedContext() )
- return myLocalContexts(myCurLocalIndex)->Sensitivity();
- return myMainSel->Sensitivity();
+Standard_Integer AIS_InteractiveContext::PixelTolerance() const
+{
+ return HasOpenedContext()
+ ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
+ : myMainSel->PixelTolerance();
}
//=======================================================================
-//function : SetPixelTolerance
-//purpose :
+//function : SetSelectionSensitivity
+//purpose : Allows to manage sensitivity of a particular selection of interactive object theObject
//=======================================================================
-
-void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
-
- if( HasOpenedContext() )
- myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
- else {
- myMainSel->SetPixelTolerance(aPrecision);
+void AIS_InteractiveContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Integer theMode,
+ const Standard_Integer theNewSensitivity)
+{
+ if (HasOpenedContext())
+ {
+ myLocalContexts (myCurLocalIndex)->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
+ return;
}
-}
-
-//=======================================================================
-//function : PixelTolerance
-//purpose :
-//=======================================================================
-
-Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
- if( HasOpenedContext() )
- return myLocalContexts(myCurLocalIndex)->PixelTolerance();
- return myMainSel->PixelTolerance();
+ mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
}
//=======================================================================
//function : IsInLocal
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle(AIS_InteractiveObject)& anIObj,
- Standard_Integer& TheIndex) const
+Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
+ Standard_Integer& theIndex) const
{
- if(anIObj.IsNull()) return Standard_False;
+ if (theIObj.IsNull())
+ {
+ return Standard_False;
+ }
+
// if it exists at neutral point 0 index is returned
- if(myObjects.IsBound(anIObj)) {
- TheIndex = 0;
+ if (myObjects.IsBound (theIObj))
+ {
+ theIndex = 0;
return Standard_False;
}
- for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){
- if(myLocalContexts.IsBound(I)){
- if(myLocalContexts(I)->IsIn(anIObj)){
- TheIndex = I;
+
+ 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;
+ theIndex = -1;
return Standard_False;
-}
-
+}
+
//=======================================================================
//function : InitAttributes
-//purpose :
+//purpose :
//=======================================================================
-
void AIS_InteractiveContext::InitAttributes()
{
-
- mgrSelector->Add(myMainSel);
+ mgrSelector->Add (myMainSel);
myCurrentName = AIS_Context_NewCurName();
mySelectionName = AIS_Context_NewSelName();
- AIS_Selection::CreateSelection(mySelectionName.ToCString());
- AIS_Selection::CreateSelection(myCurrentName.ToCString());
+ AIS_Selection::CreateSelection (mySelectionName.ToCString());
+ AIS_Selection::CreateSelection (myCurrentName.ToCString());
-
- myDefaultDrawer->SetShadingAspectGlobal(Standard_False);
- Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS);
- myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
+ myDefaultDrawer->SetShadingAspectGlobal (Standard_False);
+ Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
+ myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
// myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
- Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect();
- HLA->SetColor(Quantity_NOC_GRAY20);
- HLA->SetWidth(1);
- HLA->SetTypeOfLine(Aspect_TOL_DASH);
+ Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
+ aLineAspect->SetColor (Quantity_NOC_GRAY20);
+ aLineAspect->SetWidth (1.0);
+ aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
- // tolerance to 4 pixels...
- SetPixelTolerance();
+ // tolerance to 2 pixels...
+ SetPixelTolerance (2);
// Customizing the drawer for trihedrons and planes...
+ 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);
- Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect();
- Standard_Real aLength(100.);
- DA->SetAxisLength(aLength,aLength,aLength);
- Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4;
- DA->FirstAxisAspect()->SetColor(col);
- DA->SecondAxisAspect()->SetColor(col);
- DA->ThirdAxisAspect()->SetColor(col);
-
- Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect();
- aLength =200.;
- PA->SetPlaneLength(aLength,aLength);
- PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
-
-
+ Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
+ const Standard_Real aPlaneLength = 200.0;
+ aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
+ aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
}
-
//=======================================================================
//function : TrihedronSize
-//purpose :
+//purpose :
//=======================================================================
Standard_Real AIS_InteractiveContext::TrihedronSize() const
{
return myDefaultDrawer->DatumAspect()->FirstAxisLength();
}
+
//=======================================================================
//function : SetTrihedronSize
-//purpose :
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/)
+void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
+ const Standard_Boolean /*updateviewer*/)
{
- myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal);
- Redisplay(AIS_KOI_Datum,3,Standard_False);
- Redisplay(AIS_KOI_Datum,4,Standard_True);
+ myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
+ Redisplay (AIS_KOI_Datum, 3, Standard_False);
+ Redisplay (AIS_KOI_Datum, 4, Standard_True);
}
-
-
//=======================================================================
//function : SetPlaneSize
-//purpose :
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX,
- const Standard_Real aValY,
+void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
+ const Standard_Real theValY,
const Standard_Boolean /*updateviewer*/)
{
- myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY);
- Redisplay(AIS_KOI_Datum,7);
+ myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
+ Redisplay (AIS_KOI_Datum, 7);
}
//=======================================================================
//function : SetPlaneSize
-//purpose :
+//purpose :
//=======================================================================
-
-void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal,
- const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
+ const Standard_Boolean theToUpdateViewer)
{
- SetPlaneSize(aVal,aVal,updateviewer);
+ SetPlaneSize (theVal, theVal, theToUpdateViewer);
}
//=======================================================================
//function : PlaneSize
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const
+Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
+ Standard_Real& theY) const
{
- LX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
- LY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
- return (Abs(LX-LY)<=Precision::Confusion());
+ theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
+ theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
+ return (Abs (theX - theY) <= Precision::Confusion());
}
-
-
//=======================================================================
-//function :
-//purpose :
+//function : SetAutoActivateSelection
+//purpose :
//=======================================================================
-void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto )
+void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
{
- myIsAutoActivateSelMode = Auto;
+ myIsAutoActivateSelMode = theIsAuto;
}
//=======================================================================
-//function :
-//purpose :
+//function : GetAutoActivateSelection
+//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
{
//=======================================================================
//function : SetZLayer
-//purpose :
+//purpose :
//=======================================================================
-
void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Integer theLayerId)
{
- if (theIObj.IsNull ())
+ if (theIObj.IsNull())
return;
- if (myObjects.IsBound (theIObj))
+ theIObj->SetZLayer (theLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
+{
+ return !theIObj.IsNull()
+ ? theIObj->ZLayer()
+ : Graphic3d_ZLayerId_UNKNOWN;
+}
+
+//=======================================================================
+//function : RebuildSelectionStructs
+//purpose : Rebuilds 1st level of BVH selection forcibly
+//=======================================================================
+void AIS_InteractiveContext::RebuildSelectionStructs()
+{
+ myMainSel->RebuildObjectsTree (Standard_True);
+}
+
+//=======================================================================
+//function : Disconnect
+//purpose : Disconnects selectable object from an assembly and updates selection structures
+//=======================================================================
+void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly,
+ const Handle(AIS_InteractiveObject)& theObjToDisconnect)
+{
+ if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive"))
{
- if (myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed || myObjects (theIObj)->GraphicStatus() == AIS_DS_Erased)
- {
- theIObj->SetZLayer (myMainPM, theLayerId);
- }
+ Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly));
+ theObj->Disconnect (theObjToDisconnect);
+ const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity
+ mgrSelector->Remove (anObj);
}
- else if (HasOpenedContext ())
+ else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull())
{
- myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
+ Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly));
+ theObj->Disconnect();
+ const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity
+ mgrSelector->Remove (anObj);
}
+ else
+ return;
}
//=======================================================================
-//function : GetZLayer
-//purpose :
+//function : FitSelected
+//purpose : Fits the view corresponding to the bounds of selected objects
//=======================================================================
-
-Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
+void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
+ const Standard_Real theMargin,
+ const Standard_Boolean theToUpdate)
{
- if (theIObj.IsNull ())
- return -1;
+ Standard_CString aSelName = HasOpenedContext() ?
+ myLocalContexts (myCurLocalIndex)->SelectionName().ToCString()
+ : myCurrentName.ToCString();
- if (myObjects.IsBound (theIObj))
+ Bnd_Box aBndSelected;
+
+ const Handle(AIS_Selection)& aSelection = AIS_Selection::Selection (aSelName);
+ AIS_MapOfObjectOwners anObjectOwnerMap;
+ for (aSelection->Init(); aSelection->More(); aSelection->Next())
{
- return theIObj->GetZLayer (myMainPM);
+ Handle(AIS_InteractiveObject) anObj (Handle(AIS_InteractiveObject)::DownCast (aSelection->Value()));
+ if (!anObj.IsNull())
+ {
+ if (anObj->IsInfinite())
+ continue;
+
+ 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))
+ {
+ anOwnerMap = new SelectMgr_IndexedMapOfOwner();
+ anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap);
+ }
+
+ anOwnerMap->Add (anOwner);
+ }
}
- else if (HasOpenedContext ())
+
+ for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next())
{
- return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);
+ const Handle(SelectMgr_SelectableObject) anObject = anIter.Key();
+ Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue());
+ aBndSelected.Add (aTmpBox);
}
- return -1;
+ anObjectOwnerMap.Clear();
+
+ if (aBndSelected.IsVoid())
+ return;
+
+ theView->FitAll (aBndSelected, theMargin, theToUpdate);
}