From: vpa Date: Fri, 24 Jul 2015 13:42:00 +0000 (+0300) Subject: 0026272: Visualization - provide a possibility to activate selection modes without... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=872d7549ece43e5bda1c567ae84868733c468a38;p=occt-copy.git 0026272: Visualization - provide a possibility to activate selection modes without opening local context - picked or selected objects are now highlighted via owners instead of interactive objects; - support methods for owners were added to AIS_InteractiveContext; - selected owners are highlighted in immediate mode in AIS_InteractiveContext; - selection without opening of local context is enabled by default; - added "-local" key to vselmode command to enable selection in local context; - selection filters are now completely supported in AIS_InteractiveContext; - the idea of differencing of selected items onto current (in interactive context) and selected (local selection) was eliminated; - all calls to "current" were replaced by calls to "selected" in terms of future local context removal; - AIS_InteractiveObject::mySelectionMode was removed; - now each selectable object can define own selection mode for "global" selection of the whole object; - whole object selection mode is 0 by default for all standard interactive objects. - added support of drawing immediate structures in different layers; - unused code for immediate mode was removed; - vfeedback and vexport commands now produce correct output for raytrace mode; - do not add TKD3DHost to projects list due to usage of c++11-specific structures that are not supported in vc11. --- diff --git a/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp b/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp index d567d6e8ae..6a72e7f757 100755 --- a/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp +++ b/samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp @@ -293,7 +293,7 @@ void CViewer2dDoc::OnBUTTONTestRect() Handle_AIS_Shape aRect2 = new AIS_Shape(W2); myAISContext->Display(aRect2); myAISContext->SetColor(aRect2,Quantity_NOC_YELLOW); - myAISContext->SetSelectionMode(aRect2,2); + myAISContext->Activate(aRect2,2); FitAll2DViews(Standard_True); // Update Viewer } diff --git a/samples/mfc/standard/Common/User_Cylinder.cxx b/samples/mfc/standard/Common/User_Cylinder.cxx index cac51bb93e..314da9a092 100755 --- a/samples/mfc/standard/Common/User_Cylinder.cxx +++ b/samples/mfc/standard/Common/User_Cylinder.cxx @@ -34,7 +34,6 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant) BRepPrimAPI_MakeCylinder S(R,H); myShape = S.Shape(); SetHilightMode(0); - SetSelectionMode(0); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); myPlanarFaceColor = Quantity_NOC_FIREBRICK3; myCylindricalFaceColor = Quantity_NOC_GRAY; @@ -48,7 +47,6 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant) BRepBuilderAPI_NurbsConvert aNurbsConvert(S.Shape()); myShape = aNurbsConvert.Shape(); SetHilightMode(0); - SetSelectionMode(0); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); myPlanarFaceColor = Quantity_NOC_FIREBRICK3; myCylindricalFaceColor = Quantity_NOC_KHAKI4; diff --git a/src/AIS/AIS_InteractiveContext.cdl b/src/AIS/AIS_InteractiveContext.cdl index 8026b714fc..1207dd353a 100644 --- a/src/AIS/AIS_InteractiveContext.cdl +++ b/src/AIS/AIS_InteractiveContext.cdl @@ -50,7 +50,7 @@ class InteractiveContext from AIS inherits TShared from MMgt -- - working on only a few objects, -- - working on a single object. -- 1. When you want ot work on one type of entity, you - -- should open a local context with the option + -- may open a local context with the option -- UseDisplayedObjects set to false. DisplayedObjects -- allows you to recover the visualized Interactive -- Objects which have a given Type and @@ -80,6 +80,14 @@ class InteractiveContext from AIS inherits TShared from MMgt -- of setting up the different contexts of -- selection/presentation according to the operation -- which you want to perform. + -- + -- Selection of parts of the objects can also be done without opening a local context. + -- Interactive context itself supports decomposed object selection with selection filters + -- support. Note that each selectable object must specify the selection mode that is + -- responsible for selection of object as a whole (global selection mode). By default, global + -- selection mode is equal to 0, but it might be redefined if needed. Sub-part selection + -- of the objects without using local context provides a possibility to activate part + -- selection modes along with global selection mode. uses Address from Standard, @@ -416,17 +424,6 @@ is -- Standard_False, the presentation of the Interactive -- Object returns to the default selection mode; the -- object is displayed but no viewer will be updated. - SetSelectionMode(me:mutable; - aniobj:InteractiveObject from AIS; - aMode :Integer from Standard); ----Purpose: --- Sets the selection mode of Interactive Objects. --- aMode provides the selection mode index of the entity aniobj. - UnsetSelectionMode(me : mutable; - aniobj : InteractiveObject from AIS); ----Purpose: --- Removes selection mode from Interactive Objects. --- aMode provides the selection mode index of the entity aniobj. SetPixelTolerance(me:mutable; aPrecision: Real from Standard = 2.0); @@ -700,14 +697,22 @@ is returns Boolean from Standard; IsHilighted(me; - anIobj : InteractiveObject from AIS; - WithColor: out Boolean from Standard; - theHiCol : out NameOfColor from Quantity) + anIobj : InteractiveObject from AIS; + WithColor: out Boolean from Standard; + theHiCol : out NameOfColor from Quantity) returns Boolean from Standard; ---Purpose: if is hilighted with a specific color -- will be returned TRUE -- gives the name of the hilightcolor + IsHilighted (me; + theOwner : EntityOwner from SelectMgr; + theIsCustomColor : out Boolean from Standard; + theCustomColorName : out NameOfColor from Quantity) + returns Boolean from Standard; + ---Purpose: if is hilighted with a specific color, than will be set + -- to true and will have the name of the color stored + DisplayPriority(me;anIobj: InteractiveObject from AIS) returns Integer from Standard; ---Purpose: @@ -1130,136 +1135,159 @@ is -- The Selected objects are objects picked -- when a local context is opened + ---Category: Obsolete methods that are valid for local context only SetCurrentObject(me:mutable; - aniobj: InteractiveObject from AIS; - updateviewer : Boolean from Standard = Standard_True); ---- Purpose: --- Updates the view of the current object in open context. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. - - AddOrRemoveCurrentObject(me:mutable; - aniobj : InteractiveObject from AIS; - updateviewer : Boolean from Standard = Standard_True); ----Purpose: --- Allows you to add a current object to the list of current --- objects or remove it from that list. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. + aniobj: InteractiveObject from AIS; + updateviewer : Boolean from Standard = Standard_True); + --- Purpose: + -- Updates the view of the current object in open context. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. + + AddOrRemoveCurrentObject (me : mutable; + theObj : InteractiveObject from AIS; + theIsToUpdateViewer : Boolean from Standard = Standard_True); + ---Purpose: + -- Allows to add or remove the object given to the list of current and highlight/unhighlight it + -- correspondingly. Is valid for global context only; for local context use method AddOrRemoveSelected. + -- Since this method makes sence only for neutral point selection of a whole object, if 0 selection + -- of the object is empty this method simply does nothing. + UpdateCurrent (me:mutable); ---Purpose: Updates the list of current objects, i.e. hilights new --- current objects, removes hilighting from former current objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. - -- + -- current objects, removes hilighting from former current objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. WasCurrentTouched(me) returns Boolean from Standard; - ---Purpose: - -- Returns the current selection touched by the cursor. - -- Objects selected when there is no open local context - -- are called current objects; those selected in open - -- local context, selected objects. - ---C++: inline + ---Purpose: + -- Returns the current selection touched by the cursor. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + ---C++: inline SetOkCurrent(me:mutable); ---C++: inline - IsCurrent(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard; ---- Purpose: --- Returns true if there is a non-null interactive object in Neutral Point. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. - + IsCurrent (me; + theObject : InteractiveObject from AIS) + returns Boolean from Standard; + --- Purpose: Returns true if there is a non-null interactive object in Neutral Point. + -- Objects selected when there is no open local context are called current objects; + -- those selected in open local context, selected objects. + InitCurrent(me:mutable); ---- Purpose: --- Initializes a scan of the current selected objects in --- Neutral Point. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. - - MoreCurrent(me) returns Boolean from Standard; ---- Purpose: --- Returns true if there is another object found by the --- scan of the list of current objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. - - NextCurrent(me:mutable); ----Purpose: --- Continues the scan to the next object in the list of --- current objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. - - Current(me) returns InteractiveObject from AIS; ----Purpose: --- Returns the current interactive object. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. - + --- Purpose: + -- Initializes a scan of the current selected objects in + -- Neutral Point. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + + MoreCurrent(me) returns Boolean from Standard; + --- Purpose: + -- Returns true if there is another object found by the + -- scan of the list of current objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + + NextCurrent(me:mutable); + ---Purpose: + -- Continues the scan to the next object in the list of + -- current objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + + Current(me) returns InteractiveObject from AIS; + ---Purpose: + -- Returns the current interactive object. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + NbCurrents(me:mutable) returns Integer from Standard; - - FirstCurrentObject(me:mutable) returns InteractiveObject from AIS; ----Purpose: --- Returns the first current object in the list of current objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. + + HilightCurrents (me : mutable; + theToUpdateViewer : Boolean from Standard = Standard_True); + ---Purpose: + --- Highlights current objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. - HilightCurrents(me : mutable; - updateviewer : Boolean from Standard=Standard_True); - ---Purpose: ---- Highlights current objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. - UnhilightCurrents(me : mutable; - updateviewer : Boolean from Standard=Standard_True); ----Purpose: --- Removes highlighting from current objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. - - ClearCurrents(me:mutable; - updateviewer : Boolean from Standard=Standard_True); ----Purpose: --- Empties previous current objects in order to get the --- current objects detected by the selector using --- UpdateCurrent. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. + updateviewer : Boolean from Standard=Standard_True); + ---Purpose: + -- Removes highlighting from current objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. + + ClearCurrents (me : mutable; + theToUpdateViewer : Boolean from Standard = Standard_True); + ---Purpose: + -- Empties previous current objects in order to get the + -- current objects detected by the selector using + -- UpdateCurrent. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. + + DetectedCurrentShape(me) returns Shape from TopoDS; + ---C++: return const & + ---Purpose: + -- @return current mouse-detected shape or empty (null) shape, if current interactive object + -- is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all. + DetectedCurrentObject(me) returns InteractiveObject from AIS; + --Purpose: + -- @return current mouse-detected interactive object or null object if there is no current detected. + + ---Category: Selection mehods valid for both local and interactive context + + SetSelected (me : mutable; + theOwners : EntityOwner from SelectMgr; + theToUpdateViewer : Boolean from Standard = Standard_True); + ---Purpose: Unhighlights previously selected owners and marks them as not selected. + -- Marks owner given as selected and highlights it. + + AddOrRemoveSelected (me : mutable; + theOwner : EntityOwner from SelectMgr; + theToUpdateViewer : Boolean from Standard = Standard_True); + ---Purpose: Allows to highlight or unhighlight the owner given depending on its selection status + + IsSelected (me; + theOwner : EntityOwner from SelectMgr) + returns Boolean from Standard; + ---Purpose: Returns true is the owner given is selected + + FirstSelectedObject(me:mutable) returns InteractiveObject from AIS; + ---Purpose: + -- Returns the first current object in the list of current objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. SetSelected(me:mutable;aniObj: InteractiveObject from AIS; updateviewer : Boolean from Standard=Standard_True); @@ -1270,8 +1298,6 @@ is -- Object activates the selection mode; the object is -- displayed but no viewer will be updated. - SetSelectedCurrent(me:mutable); - ---Purpose: puts the selected list in the current objects List. UpdateSelected(me:mutable; updateviewer : Boolean from Standard=Standard_True); ---Purpose: updates the list of selected objects @@ -1281,126 +1307,120 @@ is aniobj : InteractiveObject from AIS; updateviewer : Boolean from Standard=Standard_True); ---Purpose:Allows you to add a selected object to the list of --- selected objects or remove it from that list. This entity --- can be an Interactive Object aniobj or its owner --- aShape as can be seen in the two syntaxes above. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. + -- selected objects or remove it from that list. This entity + -- can be an Interactive Object aniobj or its owner + -- aShape as can be seen in the two syntaxes above. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. HilightSelected(me : mutable; updateviewer : Boolean from Standard=Standard_True); ----Purpose: --- Highlights selected objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. + ---Purpose: + -- Highlights selected objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. UnhilightSelected(me : mutable; updateviewer : Boolean from Standard=Standard_True); ----Purpose: --- Removes highlighting from selected objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. + ---Purpose: + -- Removes highlighting from selected objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. ClearSelected(me:mutable; updateviewer : Boolean from Standard=Standard_True); ----Purpose: --- Empties previous selected objects in order to get the --- selected objects detected by the selector using --- UpdateSelected. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. --- If a local context is open and if updateviewer equals --- Standard_False, the presentation of the Interactive --- Object activates the selection mode; the object is --- displayed but no viewer will be updated. + ---Purpose: + -- Empties previous selected objects in order to get the + -- selected objects detected by the selector using + -- UpdateSelected. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. + -- If a local context is open and if updateviewer equals + -- Standard_False, the presentation of the Interactive + -- Object activates the selection mode; the object is + -- displayed but no viewer will be updated. AddOrRemoveSelected(me:mutable;aShape:Shape from TopoDS; updateviewer : Boolean from Standard=Standard_True); - ---Purpose: No right to Add a selected Shape (Internal Management - -- of shape Selection). - -- A Previous selected shape may only be removed. - - - AddOrRemoveSelected(me:mutable;anOwner : EntityOwner from SelectMgr; - updateviewer: Boolean from Standard=Standard_True); - ---Purpose: allows to add/remove in the selected list the entities - -- represented by in the selection process. + ---Purpose: No right to Add a selected Shape (Internal Management + -- of shape Selection). + -- A Previous selected shape may only be removed. ---Category: Selection Process IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard; - --- Purpose: --- Finds the selected object aniobj in local context and --- returns its name. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. + --- Purpose: + -- Finds the selected object aniobj in local context and + -- returns its name. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. InitSelected(me:mutable); ----Purpose: --- Initializes a scan of the selected objects in local context. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. + ---Purpose: + -- Initializes a scan of the selected objects in local context. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. MoreSelected(me) returns Boolean from Standard; ----Purpose: --- Returns true if there is another object found by the --- scan of the list of selected objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. + ---Purpose: + -- Returns true if there is another object found by the + -- scan of the list of selected objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. NextSelected(me:mutable); ----Purpose: --- Continues the scan to the next object in the list of --- selected objects. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. + ---Purpose: + -- Continues the scan to the next object in the list of + -- selected objects. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. NbSelected(me:mutable) returns Integer from Standard; HasSelectedShape(me) returns Boolean from Standard; ---- Purpose: --- Returns true if the interactive context has a shape --- selected in it which results from the decomposition of --- another entity in local context. --- If HasSelectedShape returns true, SelectedShape --- returns the shape which has been shown to be --- selected. Interactive returns the Interactive Object --- from which the shape has been selected. --- If HasSelectedShape returns false, Interactive --- returns the interactive entity selected by the click of the mouse. + --- Purpose: + -- Returns true if the interactive context has a shape + -- selected in it which results from the decomposition of + -- another entity in local context. + -- If HasSelectedShape returns true, SelectedShape + -- returns the shape which has been shown to be + -- selected. Interactive returns the Interactive Object + -- from which the shape has been selected. + -- If HasSelectedShape returns false, Interactive + -- returns the interactive entity selected by the click of the mouse. SelectedShape(me) returns Shape from TopoDS; ----Purpose: --- Returns the selected shape in the open local context. --- Objects selected when there is no open local context --- are called current objects; those selected in open --- local context, selected objects. + ---Purpose: + -- Returns the selected shape in the open local context. + -- Objects selected when there is no open local context + -- are called current objects; those selected in open + -- local context, selected objects. SelectedOwner(me) returns EntityOwner from SelectMgr; ----Purpose: --- Returns the owner of the selected entity resulting --- from the decomposition of another entity in local context. + ---Purpose: + -- Returns the owner of the selected entity resulting + -- from the decomposition of another entity in local context. EntityOwners(me; theOwners : out IndexedMapOfOwner from SelectMgr; theIObj : InteractiveObject from AIS; @@ -1410,8 +1430,6 @@ is --- the selection mode theMode (in all active modes --- if the Mode == -1) - Interactive(me) returns InteractiveObject from AIS; - ---Purpose: Returns the location of the selected Interactive Object. SelectedInteractive(me) returns InteractiveObject from AIS; HasApplicative(me) returns Boolean from Standard; @@ -1480,14 +1498,6 @@ is ---Purpose: -- Gets next current object during iteration through mouse-detected -- interactive objects. - DetectedCurrentShape(me) returns Shape from TopoDS; - ---C++: return const & - ---Purpose: - -- @return current mouse-detected shape or empty (null) shape, if current interactive object - -- is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all. - DetectedCurrentObject(me) returns InteractiveObject from AIS; - --Purpose: - -- @return current mouse-detected interactive object or null object if there is no current detected. ---Category: SPECIFIC LOCAL CONTEXT ACTIONS. @@ -1998,6 +2008,12 @@ is theStatus : DisplayStatus from AIS = AIS_DS_None) is static; ---Purpose: Query objects visible or hidden in specified view due to affinity mask. + RedrawImmediate (me : mutable; + theViewer : Viewer from V3d) + is static; + ---Purpose: Redraws immediate structures in all views of the viewer given taking into + -- account their visibility. + InitAttributes(me:mutable) is static private; @@ -2014,6 +2030,30 @@ is theToUpdateViewer : Boolean from Standard = Standard_True) is static private; ---Purpose: UNKNOWN + unhighlightOwners (me : mutable; + theObject : InteractiveObject from AIS) + is static private; + ---Purpose: Helper function to unhighlight all entity owners currently highlighted with seleciton color. + + highlightWithColor (me : mutable; + theOwner : EntityOwner from SelectMgr; + theColor : NameOfColor from Quantity; + theViewer : Viewer from V3d = NULL) + is static private; + ---Purpose: Helper function that highlights the owner given with without + -- performing AutoHighlight checks, e.g. is used for dynamic highlight. + -- If the parameter is set and is true, highlight will be synchronized + -- automatically in all views of the viewer. + + highlightSelected (me : mutable; + theOwner : EntityOwner from SelectMgr; + theSelColor : NameOfColor from Quantity) + is static private; + ---Purpose: Helper function that highlights the owner given with with check + -- for AutoHighlight, e.g. is used for selection. + -- If the parameter is set and is true, selection color will be synchronized + -- automatically in all views of the viewer. + fields myObjects : DataMapOfIOStatus from AIS; @@ -2030,8 +2070,8 @@ fields mySelectionName : AsciiString from TCollection; myCurrentName : AsciiString from TCollection; - myLastPicked : InteractiveObject from AIS; - myLastinMain : InteractiveObject from AIS; + myLastPicked : EntityOwner from SelectMgr; + myLastinMain : EntityOwner from SelectMgr; myWasLastMain : Boolean from Standard; diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index e653481028..4fc4ef2558 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -126,6 +126,10 @@ void AIS_InteractiveContext::Delete() const { 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(); } @@ -1049,7 +1053,44 @@ Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_Interactiv 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 @@ -1521,6 +1562,12 @@ void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode, if (aStatus->GraphicStatus() == AIS_DS_Displayed) { myMainPM->Display (anObj, theMode); + if (!myLastPicked.IsNull() && myLastPicked->Selectable() == anObj) + { + myMainPM->BeginImmediateDraw(); + myMainPM->Unhighlight (anObj, myDisplayMode); + myMainPM->EndImmediateDraw (myMainVwr); + } if (aStatus->IsSubIntensityOn()) { myMainPM->Color (anObj, mySubIntensity, theMode); @@ -2054,6 +2101,19 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI theIObj->SetWidth (theWidth); redisplayPrsRecModes (theIObj, theToUpdateViewer); + if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj) + { + if (myLastinMain->IsAutoHilight()) + { + const Standard_Integer aHiMode = + theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; + myLastinMain->HilightWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, aHiMode); + } + else + { + theIObj->HilightOwnerWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, myLastinMain); + } + } } //======================================================================= @@ -2270,7 +2330,6 @@ void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIOb theStatus += TCollection_AsciiString (aDispModeIter.Value()); theStatus += "\n"; } - if (IsCurrent (theIObj)) theStatus +="\t| Current\n"; if (IsSelected(theIObj)) theStatus +="\t| Selected\n"; theStatus += "\t| Active Selection Modes in the MainViewer :\n"; @@ -2303,7 +2362,7 @@ void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& t ? myDisplayMode : 0); theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; - theSelMode = theIObj->HasSelectionMode() ? theIObj->SelectionMode() : -1; + theSelMode = theIObj->GlobalSelectionMode(); } //======================================================================= @@ -2338,7 +2397,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False); } - if (IsCurrent (theIObj) + if (IsSelected (theIObj) && !aStatus->IsDModeIn (aDispMode)) { myMainPM->SetVisibility (theIObj, aDispMode, Standard_False); @@ -2348,6 +2407,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t { mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel); } + aStatus->ClearSelectionModes(); aStatus->SetGraphicStatus (AIS_DS_Erased); if (theToUpdateviewer) @@ -2356,6 +2416,31 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t } } +//======================================================================= +//function : unhighlightOwners +//purpose : +//======================================================================= +void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject) +{ + 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(); + } +} + //======================================================================= //function : ClearGlobal //purpose : @@ -2373,27 +2458,11 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t } Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); + unhighlightOwners (theIObj); for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next()) { - if (aStatus->IsHilighted()) - { - if (IsCurrent (theIObj)) - { - AddOrRemoveCurrentObject (theIObj, theToUpdateviewer); - } - else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value())) - { - myMainPM->Unhighlight (theIObj, aDispModeIter.Value()); - } - } myMainPM->Erase (theIObj, aDispModeIter.Value()); myMainPM->Clear (theIObj, aDispModeIter.Value()); - if (theIObj->HasHilightMode()) - { - Standard_Integer im = theIObj->HilightMode(); - myMainPM->Unhighlight (theIObj, im); - myMainPM->Erase (theIObj, im); - } } // Object removes from Detected sequence @@ -2407,15 +2476,6 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t } } - if (myLastinMain == theIObj) - { - myLastinMain.Nullify(); - } - if (myLastPicked == theIObj) - { - myLastPicked.Nullify(); - } - // remove IO from the selection manager to avoid memory leaks mgrSelector->Remove (theIObj); @@ -2426,8 +2486,13 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj); } - if (theToUpdateviewer - && aStatus->GraphicStatus() == AIS_DS_Displayed) + if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj) + myLastinMain.Nullify(); + if (!myLastPicked.IsNull() && myLastPicked->Selectable() == theIObj) + myLastPicked.Nullify(); + myMainPM->ClearImmediateDraw(); + + if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed) { myMainVwr->Update(); } @@ -2570,25 +2635,6 @@ Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const return myDefaultDrawer->IsoOnPlane(); } -//======================================================================= -//function : SetSelectionMode -//purpose : -//======================================================================= -void AIS_InteractiveContext::SetSelectionMode (const Handle(AIS_InteractiveObject)& , - const Standard_Integer ) -{ - // -} - -//======================================================================= -//function : UnsetSelectionMode -//purpose : -//======================================================================= -void AIS_InteractiveContext::UnsetSelectionMode (const Handle(AIS_InteractiveObject)& ) -{ - // -} - //======================================================================= //function : SetPixelTolerance //purpose : Disables the mechanism of adaptive tolerance calculation in diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index d82f767c21..8498627a3f 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -15,6 +15,7 @@ // commercial license or contractual agreement. #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include +#include #include #include @@ -44,6 +46,61 @@ #include #include +typedef NCollection_DataMap > AIS_MapOfObjSelectedOwners; + +//======================================================================= +//function : highlightWithColor +//purpose : +//======================================================================= +void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner, + const Quantity_NameOfColor theColor, + const Handle(V3d_Viewer)& theViewer) +{ + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + if (anObj.IsNull()) + return; + const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + + myMainPM->BeginImmediateDraw(); + theOwner->HilightWithColor (myMainPM, theColor, aHiMode); + myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer); +} + +//======================================================================= +//function : highlightSelected +//purpose : +//======================================================================= +void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner, + const Quantity_NameOfColor theSelColor) +{ + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + if (anObj.IsNull()) + return; + const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + + if (!theOwner->IsAutoHilight()) + { + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + const Handle(AIS_Selection)& aCurSel = AIS_Selection::CurrentSelection(); + SelectMgr_SequenceOfOwner aSeq; + for (aCurSel->Init(); aCurSel->More(); aCurSel->Next()) + { + const Handle(SelectMgr_EntityOwner) aSelOwnr = + Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()); + if (aSelOwnr->Selectable() != anObj) + continue; + aSeq.Append (aSelOwnr); + } + anObj->HilightSelected (myMainPM, aSeq); + } + else + { + theOwner->HilightWithColor (myMainPM, theSelColor, aHiMode); + } +} + //======================================================================= //function : MoveTo //purpose : @@ -104,9 +161,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th { // does nothing if previously detected object is equal to the current one Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected); - if (aNewPickedOwner->Selectable() == myLastPicked) + if (aNewPickedOwner == myLastPicked) { - return myLastPicked->State() == 1 + return myLastPicked->IsSelected() ? AIS_SOD_Selected : AIS_SOD_OnlyOneDetected; } @@ -116,56 +173,62 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th // is needed only if myToHilightSelected flag is true. In this case previously detected // object has been already highlighted with myHilightColor during previous MoveTo() // method call. As result it is necessary to rehighligt it with mySelectionColor. - if (!myLastPicked.IsNull()) + if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) { - const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; - if (myLastPicked->State() != 1) + myMainPM->ClearImmediateDraw(); + const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); + const Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0; + if (!myLastPicked->IsSelected()) { - myMainPM->Unhighlight (myLastPicked, aHiMod); + myLastPicked->Unhilight (myMainPM, aHiMod); toUpdateViewer = Standard_True; } else if (myToHilightSelected) { - myMainPM->Color (myLastPicked, mySelectionColor, aHiMod); + highlightWithColor (aNewPickedOwner, mySelectionColor, theView->Viewer()); toUpdateViewer = Standard_True; } } // initialize myLastPicked field with currently detected object - myLastPicked = Handle(AIS_InteractiveObject)::DownCast (aNewPickedOwner->Selectable()); + myLastPicked = aNewPickedOwner; myLastinMain = myLastPicked; // highlight detected object if it is not selected or myToHilightSelected flag is true - if (!myLastPicked.IsNull()) + if (myLastPicked->HasSelectable()) { - if (myLastPicked->State() != 1 || myToHilightSelected) + if (!myLastPicked->IsSelected() || myToHilightSelected) { - const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; - myMainPM->Color (myLastPicked, myHilightColor, aHiMod); + highlightWithColor (myLastPicked, myHilightColor, theView->Viewer()); toUpdateViewer = Standard_True; } - aStatus = myLastPicked->State() == 1 + aStatus = myLastPicked->IsSelected() ? AIS_SOD_Selected : AIS_SOD_OnlyOneDetected; } } - else + else { // previously detected object is unhilighted if it is not selected or hilighted // with selection color if it is selected aStatus = AIS_SOD_Nothing; - if (!myLastPicked.IsNull()) + if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) { - Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; - if (myLastPicked->State() != 1) + myMainPM->ClearImmediateDraw(); + const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); + Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0; + if (!myLastPicked->IsSelected()) { - myMainPM->Unhighlight (myLastPicked, aHiMod); + if (myLastPicked->IsAutoHilight()) + { + myLastPicked->Unhilight (myMainPM, aHiMod); + } toUpdateViewer = Standard_True; } else if (myToHilightSelected) { - myMainPM->Color (myLastPicked, mySelectionColor, aHiMod); + highlightSelected (myLastPicked, mySelectionColor); toUpdateViewer = Standard_True; } } @@ -211,7 +274,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi theView, toUpdateViewer); } - ClearCurrents (Standard_False); + ClearSelected (Standard_False); Handle(StdSelect_ViewerSelector3d) aSelector; @@ -224,27 +287,19 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - AIS_MapOfInteractive anObjectsToSelect; for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - Handle(AIS_InteractiveObject) anObj = - Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); - if (!anObj.IsNull()) - { - anObjectsToSelect.Add (anObj); - } - } + const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked(); + if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner)) + continue; - AIS_MapIteratorOfMapOfInteractive anIt (anObjectsToSelect); - for ( ; anIt.More(); anIt.Next()) - { - AIS_Selection::Select (anIt.Key()); - anIt.Key()->State (1); + AIS_Selection::Select (aCurOwner); + aCurOwner->State (1); } - HilightCurrents (toUpdateViewer); + HilightSelected (toUpdateViewer); - Standard_Integer aSelNum = NbCurrents(); + Standard_Integer aSelNum = NbSelected(); return (aSelNum == 0) ? AIS_SOP_NothingSelected : (aSelNum == 1) ? AIS_SOP_OneSelected @@ -268,7 +323,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer); } - ClearCurrents (Standard_False); + ClearSelected (Standard_False); Handle(StdSelect_ViewerSelector3d) aSelector; @@ -281,27 +336,20 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the aSelector->Pick (thePolyline, theView); AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - AIS_MapOfInteractive anObjectsToSelect; for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - Handle(AIS_InteractiveObject) anObj = - Handle( AIS_InteractiveObject )::DownCast (aSelector->Picked()->Selectable()); - if (!anObj.IsNull()) - { - anObjectsToSelect.Add (anObj); - } - } + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked()); + if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) + continue; - AIS_MapIteratorOfMapOfInteractive anIt (anObjectsToSelect); - for ( ; anIt.More(); anIt.Next()) - { - AIS_Selection::Select (anIt.Key()); - anIt.Key()->State (1); + AIS_Selection::Select (anOwner); + anOwner->State (1); } - HilightCurrents (toUpdateViewer); + HilightSelected (toUpdateViewer); - Standard_Integer aSelNum = NbCurrents(); + Standard_Integer aSelNum = NbSelected(); return (aSelNum == 0) ? AIS_SOP_NothingSelected : (aSelNum == 1) ? AIS_SOP_OneSelected @@ -323,16 +371,17 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate } else { - myLocalContexts(myCurLocalIndex)->SetSelected (myLastPicked, toUpdateViewer); + myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer); return AIS_SOP_OneSelected; } } + myMainPM->ClearImmediateDraw(); if (myWasLastMain && !myLastinMain.IsNull()) { - if(myLastinMain->State() != 1) + if(!myLastinMain->IsSelected()) { - SetCurrentObject (myLastinMain,Standard_False); + SetSelected (myLastinMain, Standard_False); if(toUpdateViewer) { UpdateCurrentViewer(); @@ -343,16 +392,44 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate { AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); Handle(AIS_Selection) aSelection = AIS_Selection::CurrentSelection(); - Handle(AIS_InteractiveObject) anObj; + NCollection_IndexedMap anObjToClear; for (aSelection->Init(); aSelection->More(); aSelection->Next()) { - anObj = Handle(AIS_InteractiveObject)::DownCast (aSelection->Value()); - anObj->State (0); - Unhilight (anObj,Standard_False); - if (myObjects.IsBound (anObj) && myObjects(anObj)->IsSubIntensityOn()) + const Handle(SelectMgr_EntityOwner) anOwner + = Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Value()); + + if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) + continue; + + const Handle(AIS_InteractiveObject) anObject = + Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + anOwner->State (0); + if (anOwner == anObject->GlobalSelOwner()) + { + Handle(AIS_GlobalStatus) aStatus = myObjects (anObject); + aStatus->SetHilightStatus (Standard_False); + aStatus->SetHilightColor (Quantity_NOC_WHITE); + anObject->State (0); + } + if (!anOwner->IsAutoHilight()) { - HilightWithColor (anObj, mySubIntensity, Standard_False); + if (!anObjToClear.Contains (anObject)) + anObjToClear.Add (anObject); } + else + { + const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0; + anOwner->Unhilight (myMainPM, aHiMode); + if (myObjects.IsBound (anObject) && myObjects(anObject)->IsSubIntensityOn()) + { + anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode); + } + } + } + while (!anObjToClear.IsEmpty()) + { + anObjToClear.FindKey (anObjToClear.Size())->ClearSelected(); + anObjToClear.RemoveLast(); } AIS_Selection::Select(); @@ -362,7 +439,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate } } - Standard_Integer aSelNum = NbCurrents(); + Standard_Integer aSelNum = NbSelected(); return (aSelNum == 0) ? AIS_SOP_NothingSelected : (aSelNum == 1) ? AIS_SOP_OneSelected @@ -392,16 +469,17 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toU } } + myMainPM->ClearImmediateDraw(); if (myWasLastMain && !myLastinMain.IsNull()) { - AddOrRemoveCurrentObject (myLastinMain, toUpdateViewer); + AddOrRemoveSelected (myLastinMain, toUpdateViewer); } - Standard_Integer aCurrentSelNum = NbCurrents(); + Standard_Integer aSelNum = NbSelected(); - return (aCurrentSelNum == 0) ? AIS_SOP_NothingSelected - : (aCurrentSelNum == 1) ? AIS_SOP_OneSelected - : AIS_SOP_SeveralSelected; + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; } //======================================================================= @@ -421,7 +499,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the theView, toUpdateViewer); } - UnhilightCurrents (Standard_False); + UnhilightSelected (Standard_False); Handle(StdSelect_ViewerSelector3d) aSelector; if (theView->Viewer() == myMainVwr) @@ -438,18 +516,18 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - Handle(AIS_InteractiveObject) anObjToSelect = Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); - if (!anObjToSelect.IsNull()) - { - AIS_SelectStatus aSelStatus = AIS_Selection::Select (anObjToSelect); - Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; - anObjToSelect->State (aState); - } + const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked()); + if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) + continue; + + AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner); + Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; + anOwner->State (aState); } - HilightCurrents (toUpdateViewer); + HilightSelected (toUpdateViewer); - Standard_Integer aSelNum = NbCurrents(); + Standard_Integer aSelNum = NbSelected(); return (aSelNum == 0) ? AIS_SOP_NothingSelected : (aSelNum == 1) ? AIS_SOP_OneSelected @@ -470,7 +548,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer); } - UnhilightCurrents (Standard_False); + UnhilightSelected (Standard_False); Handle(StdSelect_ViewerSelector3d) aSelector; @@ -489,18 +567,18 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - Handle(AIS_InteractiveObject) anObjToSelect = Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); - if (!anObjToSelect.IsNull()) - { - AIS_SelectStatus aSelStatus = AIS_Selection::Select (anObjToSelect); - Standard_Integer aState = (aSelStatus == AIS_SS_Added ) ? 1 : 0; - anObjToSelect->State (aState); - } + const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked()); + if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) + continue; + + AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner); + Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; + anOwner->State (aState); } - HilightCurrents (toUpdateViewer); + HilightSelected (toUpdateViewer); - Standard_Integer aSelNum = NbCurrents(); + Standard_Integer aSelNum = NbSelected(); return (aSelNum == 0) ? AIS_SOP_NothingSelected : (aSelNum == 1) ? AIS_SOP_OneSelected @@ -509,403 +587,487 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d //======================================================================= //function : SetCurrentObject -//purpose : +//purpose : OBSOLETE, please use SetSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= -void AIS_InteractiveContext::SetCurrentObject(const Handle(AIS_InteractiveObject)& anIObj, - const Standard_Boolean updateviewer) +void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject, + const Standard_Boolean theToUpdateViewer) { - // single case processing... - if(NbCurrents()==1 && anIObj->State()==1){ - Quantity_NameOfColor HiCol; - Standard_Boolean HasHiCol; - if(IsHilighted(anIObj,HasHiCol,HiCol)){ - if(HasHiCol && HiCol!= mySelectionColor) { - HilightWithColor(anIObj,mySelectionColor,updateviewer); - } - } + if (HasOpenedContext()) return; - } - - // - if(!HasOpenedContext()) { - if(anIObj.IsNull()) return; - if(!myObjects.IsBound(anIObj)) - Display(anIObj,Standard_False); - - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); - Handle(Standard_Transient) TR; - Handle(AIS_InteractiveObject) IO; - sel->Init(); - while (sel->More()) { - TR = sel->Value(); - IO = *((Handle(AIS_InteractiveObject)*)&TR); - Unhilight(IO,Standard_False); - IO->State(0); - sel->Next(); - } - - // added to avoid untimely viewer update... - AIS_Selection::ClearAndSelect(anIObj); - anIObj->State(1); - Quantity_NameOfColor HiCol; - Standard_Boolean HasHiCol; - if(IsHilighted(anIObj,HasHiCol,HiCol)){ - if(HasHiCol && HiCol!= mySelectionColor) { - HilightWithColor(anIObj,mySelectionColor,Standard_False); - } - } - else{ - HilightWithColor(anIObj,mySelectionColor,Standard_False); - } - if (updateviewer) - UpdateCurrentViewer(); - } - else{ -#ifdef OCCT_DEBUG - cout<<"Nothing Done : Opened Local Context"<State(mod); - if(mod==1) - HilightWithColor(anIObj,mySelectionColor,Standard_False); - else - Unhilight(anIObj,Standard_False); - - - if(updateviewer) - UpdateCurrentViewer(); - } - else{ -#ifdef OCCT_DEBUG - cout<<"Nothing Done : Opened Local Context"<State()==1); - - // Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); - // sel->Init(); - // while (sel->More()) { - // if (anIObj == sel->Value()) return Standard_True; - // sel->Next(); - // } - // return Standard_False; - + return IsSelected (theObject); } //======================================================================= //function : InitCurrent -//purpose : +//purpose : OBSOLETE, please use InitSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= - void AIS_InteractiveContext::InitCurrent() { - AIS_Selection::Selection(myCurrentName.ToCString())->Init(); + if (HasOpenedContext()) + return; + + InitSelected(); } //======================================================================= //function : MoreCurrent -//purpose : +//purpose : OBSOLETE, please use MoreSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= - Standard_Boolean AIS_InteractiveContext::MoreCurrent() const { - return AIS_Selection::Selection(myCurrentName.ToCString())->More(); - + return !HasOpenedContext() && MoreSelected(); } //======================================================================= //function : NextCurrent -//purpose : +//purpose : OBSOLETE, please use NextSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= - void AIS_InteractiveContext::NextCurrent() { - AIS_Selection::Selection(myCurrentName.ToCString())->Next(); + if (HasOpenedContext()) + return; + + NextSelected(); } //======================================================================= //function : Current -//purpose : +//purpose : OBSOLETE, please use SelectedInteractive() instead +//TODO : Remove in process of local context deletion //======================================================================= - Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const { - Handle(Standard_Transient) TR = AIS_Selection::Selection(myCurrentName.ToCString())->Value(); - Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR); - return IO; -} - -//======================================================================= -//function : FirstCurrentObject -//purpose : -//======================================================================= -Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstCurrentObject() -{ - Handle(AIS_InteractiveObject) IO ; - InitCurrent(); - if(MoreCurrent()){ - return Current(); - } - return IO; + return HasOpenedContext() ? NULL : SelectedInteractive(); } //======================================================================= //function : NbCurrents -//purpose : +//purpose : OBSOLETE, please use NbSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= Standard_Integer AIS_InteractiveContext::NbCurrents() { - Standard_Integer i(0); - for(InitCurrent();MoreCurrent();NextCurrent()) - {i++;} - return i; + return HasOpenedContext() ? -1 : NbSelected(); } //======================================================================= //function : HilightCurrents -//purpose : +//purpose : OBSOLETE, please use HilightSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= -void AIS_InteractiveContext::HilightCurrents(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer) { - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); - Handle(Standard_Transient) TR; - Handle(AIS_InteractiveObject) IO; - sel->Init(); - while (sel->More()) { - TR = sel->Value(); - IO = *((Handle(AIS_InteractiveObject)*)&TR); - HilightWithColor(IO,mySelectionColor,Standard_False); - sel->Next(); - } - if(updateviewer) - UpdateCurrentViewer(); + if (HasOpenedContext()) + return; + + HilightSelected (theToUpdateViewer); } //======================================================================= //function : UnhilightCurrents -//purpose : +//purpose : OBSOLETE, please use UnhilightSelected() instead +//TODO : Remove in process of local context deletion //======================================================================= - -void AIS_InteractiveContext::UnhilightCurrents(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer) { - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); - Handle(Standard_Transient) TR; - Handle(AIS_InteractiveObject) IO; - sel->Init(); - while (sel->More()) { - TR = sel->Value(); - IO = *((Handle(AIS_InteractiveObject)*)&TR); - Unhilight(IO,Standard_False); - sel->Next(); - } - if(updateviewer) - UpdateCurrentViewer(); + if (HasOpenedContext()) + return; + + UnhilightSelected (theToUpdateViewer); } //======================================================================= //function : ClearCurrents -//purpose : +//purpose : OBSOLETE, please use ClearCurrents() instead +//TODO : Remove in process of local context deletion //======================================================================= - -void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer) { - if(NbCurrents()==0) return; - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); - Handle(Standard_Transient) Tr; - Handle(AIS_InteractiveObject) IO; - for(S->Init();S->More();S->Next()){ - Tr = S->Value(); - IO = (*((Handle(AIS_InteractiveObject)*)&Tr)); - IO->State(0); - Unhilight(IO,Standard_False); - } - AIS_Selection::Select(); - if(updateviewer) - UpdateCurrentViewer(); + if (HasOpenedContext()) + return; + + ClearSelected (theToUpdateViewer); } //======================================================================= //function : HilightSelected -//purpose : +//purpose : //======================================================================= - -void AIS_InteractiveContext::HilightSelected(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer) { - if(!HasOpenedContext()){ - AIS_Selection::SetCurrentSelection(mySelectionName.ToCString()); - Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); - Handle(Standard_Transient) TR; - Handle(AIS_InteractiveObject) IO; - sel->Init(); - while (sel->More()) { - TR = sel->Value(); - IO = *((Handle(AIS_InteractiveObject)*)&TR); - HilightWithColor(IO,mySelectionColor,Standard_False); - sel->Next(); + if (HasOpenedContext()) + { + return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer); + } + + // In case of selection without using local context + myMainPM->ClearImmediateDraw(); + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString()); + AIS_MapOfObjSelectedOwners anObjOwnerMap; + for (aSel->Init(); aSel->More(); aSel->Next()) + { + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value()); + if (!anOwner.IsNull() && anOwner->HasSelectable()) + { + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + if (anOwner == anObj->GlobalSelOwner()) + { + anObj->State (1); + } + anOwner->State (1); + if (!anOwner->IsAutoHilight()) + { + NCollection_Handle aSeq; + if (anObjOwnerMap.Find (anObj, aSeq)) + { + aSeq->Append (anOwner); + } + else + { + aSeq = new SelectMgr_SequenceOfOwner(); + aSeq->Append (anOwner); + anObjOwnerMap.Bind (anObj, aSeq); + } + } + else + { + const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode); + } } } - else + + if (!anObjOwnerMap.IsEmpty()) + { + for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next()) { - myLocalContexts(myCurLocalIndex)->HilightPicked(updateviewer); + anIter.Key()->HilightSelected (myMainPM, *anIter.Value()); } - if(updateviewer) + anObjOwnerMap.Clear(); + } + + if (theToUpdateViewer) UpdateCurrentViewer(); } //======================================================================= //function : UnhilightSelected -//purpose : +//purpose : //======================================================================= - -void AIS_InteractiveContext::UnhilightSelected(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer) { - if(!HasOpenedContext()){ - AIS_Selection::SetCurrentSelection(mySelectionName.ToCString()); - Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); - Handle(Standard_Transient) TR; - Handle(AIS_InteractiveObject) IO; - sel->Init(); - while (sel->More()) { - TR = sel->Value(); - IO = *((Handle(AIS_InteractiveObject)*)&TR); - Unhilight(IO,Standard_False); - sel->Next(); - } - if(updateviewer) - UpdateCurrentViewer(); + if (HasOpenedContext()) + { + return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer); } - else + + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString()); + for (aSel->Init(); aSel->More(); aSel->Next()) + { + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value()); + if (!anOwner.IsNull() && anOwner->HasSelectable()) { - myLocalContexts(myCurLocalIndex)->UnhilightPicked(updateviewer); + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + if (anOwner == anObj->GlobalSelOwner()) + { + anObj->State (0); + } + anOwner->State (0); + const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0; + anOwner->Unhilight (myMainPM, aHiMode); } + } + + if (theToUpdateViewer) + UpdateCurrentViewer(); } //======================================================================= //function : ClearSelected -//purpose : +//purpose : //======================================================================= - -void AIS_InteractiveContext::ClearSelected(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer) { - if(!HasOpenedContext()) - ClearCurrents(updateviewer); - else - myLocalContexts(myCurLocalIndex)->ClearSelected(updateviewer); - -} + if (HasOpenedContext()) + return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer); + if (NbSelected() == 0) + return; -//======================================================================= -//function : SetSelectedCurrent -//purpose : -//======================================================================= + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aSel = AIS_Selection::CurrentSelection(); + NCollection_IndexedMap anObjToClear; + for (aSel->Init(); aSel->More(); aSel->Next()) + { + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value()); + if (!anOwner.IsNull() && anOwner->HasSelectable()) + { + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + if (anOwner == anObj->GlobalSelOwner()) + { + anObj->State (0); + } + anOwner->State (0); + if (!anOwner->IsAutoHilight()) + { + if (!anObjToClear.Contains (anObj)) + anObjToClear.Add (anObj); + } + else + { + const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + anOwner->Unhilight (myMainPM, aHiMode); + } + } + } -void AIS_InteractiveContext::SetSelectedCurrent() -{ + while (!anObjToClear.IsEmpty()) + { + anObjToClear.FindKey (anObjToClear.Size())->ClearSelected(); + anObjToClear.RemoveLast(); + } + AIS_Selection::Select(); + myMainPM->ClearImmediateDraw(); -#ifdef OCCT_DEBUG - cout<<"Not Yet Implemented"<UpdateSelected (theToUpdateViewer); + } -void AIS_InteractiveContext::UpdateSelected(const Standard_Boolean updateviewer) + HilightSelected (theToUpdateViewer); +} + +//======================================================================= +//function : SetSelected +//purpose : Sets the whole object as selected and highlights it with selection color +//======================================================================= +void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject, + const Standard_Boolean theToUpdateViewer) { - if(!HasOpenedContext()) { - HilightSelected(); -#ifndef BUG + if(HasOpenedContext()) + { + return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer); + } + + if (theObject.IsNull()) return; -#endif + if(!myObjects.IsBound (theObject)) + Display (theObject, Standard_False); + if (theObject->HasSelection (0)) + return; + + if (NbSelected() == 1 && theObject->State() == 1) + { + Quantity_NameOfColor aHiCol; + Standard_Boolean hasHiCol = Standard_False; + if (IsHilighted (theObject, hasHiCol, aHiCol)) + { + if (hasHiCol && aHiCol!= mySelectionColor) + { + HilightWithColor (theObject, mySelectionColor, theToUpdateViewer); + } + } + return; + } + + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); + for (aCurSel->Init(); aCurSel->More(); aCurSel->Next()) + { + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()); + if (anOwner.IsNull() || !anOwner->HasSelectable()) + continue; + + Handle(AIS_InteractiveObject) aSelectable = + Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + Unhilight (aSelectable, Standard_False); + anOwner->State (0); + aSelectable->State (0); + } + + // added to avoid untimely viewer update... + const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0); + if (aSel->IsEmpty()) + return; + aSel->Init(); + Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId()); + AIS_Selection::ClearAndSelect (anOwner); + theObject->State (1); + anOwner->State (1); + Quantity_NameOfColor aHiCol; + Standard_Boolean hasHiCol = Standard_False; + if (IsHilighted (theObject, hasHiCol, aHiCol)) + { + if (hasHiCol && aHiCol!= mySelectionColor) + { + HilightWithColor (theObject, mySelectionColor, Standard_False); + } } - myLocalContexts(myCurLocalIndex)->UpdateSelected(updateviewer); + else + { + HilightWithColor (theObject, mySelectionColor, Standard_False); + } + + if (theToUpdateViewer) + UpdateCurrentViewer(); } //======================================================================= -//function : SetCurrentObject -//purpose : +//function : SetSelected +//purpose : Sets the whole object as selected and highlights it with selection color //======================================================================= -void AIS_InteractiveContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,const Standard_Boolean updateviewer) +void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner, + const Standard_Boolean theToUpdateViewer) { - if(!HasOpenedContext()) - SetCurrentObject(anIObj,updateviewer); - else - myLocalContexts(myCurLocalIndex)->SetSelected(anIObj,updateviewer); + if (theOwner.IsNull() || !theOwner->HasSelectable()) + return; + + const Handle(AIS_InteractiveObject) anObject = + Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + + if (NbSelected() == 1 && theOwner->IsSelected()) + { + Quantity_NameOfColor aCustomColor; + Standard_Boolean isCustomColorSet; + if (IsHilighted (theOwner, isCustomColorSet, aCustomColor)) + { + if (isCustomColorSet && aCustomColor != mySelectionColor) + { + const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0; + theOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode); + } + } + return; + } + + if (!myObjects.IsBound (anObject)) + Display (anObject, Standard_False); + + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); + for (aCurSel->Init(); aCurSel->More(); aCurSel->Next()) + { + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()); + if (!anOwner->HasSelectable()) + continue; + const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0; + anOwner->Unhilight (myMainPM, aHiMode); + anOwner->State (0); + } + + AIS_Selection::ClearAndSelect (theOwner); + theOwner->State (1); + Quantity_NameOfColor aCustomColor; + Standard_Boolean isCustomColorSet; + if (!IsHilighted (theOwner, isCustomColorSet, aCustomColor) || (isCustomColorSet && aCustomColor!= mySelectionColor)) + { + highlightSelected (theOwner, mySelectionColor); + } + + if (theToUpdateViewer) + UpdateCurrentViewer(); } //======================================================================= //function : AddOrRemoveSelected -//purpose : +//purpose : Adds or removes current object from AIS selection and highlights/unhighlights it. +// Since this method makes sence only for neutral point selection of a whole object, +// if 0 selection of the object is empty this method simply does nothing. //======================================================================= - -void AIS_InteractiveContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& anIObj, - const Standard_Boolean updateviewer) +void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject, + const Standard_Boolean theToUpdateViewer) { - if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); - if(!HasOpenedContext()) - AddOrRemoveCurrentObject(anIObj,updateviewer); - else - myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(anIObj,updateviewer); - + if (!theObject->HasInteractiveContext()) + theObject->SetContext (this); + + if (HasOpenedContext()) + return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer); + + if (theObject.IsNull() || !myObjects.IsBound (theObject) || !theObject->HasSelection (0)) + return; + + const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0); + + if (aSel->IsEmpty()) + return; + + aSel->Init(); + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId()); + + if (anOwner.IsNull() || !anOwner->HasSelectable()) + return; + + AddOrRemoveSelected (anOwner, theToUpdateViewer); } //======================================================================= //function : AddOrRemoveSelected //purpose : //======================================================================= -void AIS_InteractiveContext::AddOrRemoveSelected(const TopoDS_Shape& aShap, +void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap, const Standard_Boolean updateviewer) { if(!HasOpenedContext()) { @@ -919,160 +1081,215 @@ void AIS_InteractiveContext::AddOrRemoveSelected(const TopoDS_Shape& aShap, if(updateviewer) UpdateCurrentViewer(); } + //======================================================================= //function : AddOrRemoveSelected -//purpose : +//purpose : Allows to highlight or unhighlight the owner given depending on +// its selection status //======================================================================= +void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner, + const Standard_Boolean theToUpdateViewer) +{ + if (HasOpenedContext()) + return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer); -void AIS_InteractiveContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& Own, - const Standard_Boolean updateviewer) -{ - if(!HasOpenedContext()) { -#ifdef OCCT_DEBUG - cout<<" Attempt to remove a selected ownr with no opened local context"<HasSelectable()) return; + + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); + + AIS_SelectStatus aSelStat = AIS_Selection::Select (theOwner); + + Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0; + theOwner->State (aState); + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner; + if (isGlobal) + anObj->State (aState); + const Handle(AIS_GlobalStatus)& aStatus = myObjects (anObj); + const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + if (aState == 1) + { + highlightSelected (theOwner, mySelectionColor); + if (isGlobal) + { + aStatus->SetHilightStatus (Standard_True); + aStatus->SetHilightColor (mySelectionColor); + } + } + else + { + if (theOwner->IsAutoHilight()) + theOwner->Unhilight (myMainPM, aHiMode); + else + anObj->ClearSelected(); + aStatus->SetHilightStatus (Standard_False); + aStatus->SetHilightColor (Quantity_NOC_WHITE); } - - myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(Own,Standard_False); - if(updateviewer) UpdateCurrentViewer(); - -} + if (theToUpdateViewer) + UpdateCurrentViewer(); +} //======================================================================= //function : IsSelected -//purpose : +//purpose : //======================================================================= - -Standard_Boolean AIS_InteractiveContext:: -IsSelected(const Handle(AIS_InteractiveObject)& anIObj) const +Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const { - if (anIObj.IsNull()) return Standard_False; - - if(!HasOpenedContext()) - return (anIObj->State()==1); - else - return myLocalContexts(myCurLocalIndex)->IsSelected(anIObj); + if(HasOpenedContext()) + return myLocalContexts(myCurLocalIndex)->IsSelected (theObj); + + if (theObj.IsNull() || !myObjects.IsBound (theObj)) + return Standard_False; + + const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode(); + const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes(); + Standard_Boolean isGlobalModeActivated = Standard_False; + for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next()) + { + if (aModeIter.Value() == aGlobalSelMode) + { + isGlobalModeActivated = Standard_True; + break; + } + } + if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated) + return Standard_False; + + return theObj->State() == 1; } +//======================================================================= +//function : IsSelected +//purpose : Returns true is the owner given is selected +//======================================================================= +Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const +{ + if (HasOpenedContext()) + return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner); + + if (theOwner.IsNull()) + return Standard_False; + + return theOwner->IsSelected(); +} //======================================================================= //function : InitSelected -//purpose : +//purpose : //======================================================================= - void AIS_InteractiveContext::InitSelected() { - if(!HasOpenedContext()) - AIS_Selection::Selection(myCurrentName.ToCString())->Init(); - else - myLocalContexts(myCurLocalIndex)->InitSelected(); + if (HasOpenedContext()) + { + myLocalContexts (myCurLocalIndex)->InitSelected(); + return; + } + + AIS_Selection::Selection (myCurrentName.ToCString())->Init(); } //======================================================================= //function : MoreSelected -//purpose : +//purpose : //======================================================================= - -Standard_Boolean AIS_InteractiveContext::MoreSelected() const +Standard_Boolean AIS_InteractiveContext::MoreSelected() const { - if(!HasOpenedContext()) - return AIS_Selection::Selection(myCurrentName.ToCString())->More(); - return myLocalContexts(myCurLocalIndex)->MoreSelected(); + if (HasOpenedContext()) + return myLocalContexts (myCurLocalIndex)->MoreSelected(); + + return AIS_Selection::Selection (myCurrentName.ToCString())->More(); } //======================================================================= //function : NextSelected -//purpose : +//purpose : //======================================================================= - void AIS_InteractiveContext::NextSelected() { - if(!HasOpenedContext()) - AIS_Selection::Selection(myCurrentName.ToCString())->Next(); - else - myLocalContexts(myCurLocalIndex)->NextSelected(); + if(HasOpenedContext()) + { + return myLocalContexts (myCurLocalIndex)->NextSelected(); + return; + } + + AIS_Selection::Selection (myCurrentName.ToCString())->Next(); } //======================================================================= //function : HasSelectedShape -//purpose : +//purpose : //======================================================================= - -Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const +Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const { - if(!HasOpenedContext()) { - Handle(AIS_Shape) shape = - Handle(AIS_Shape)::DownCast(SelectedInteractive()); - if( !shape.IsNull() ) return Standard_True; - return Standard_False; + if(HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->HasSelectedShape(); } - return myLocalContexts(myCurLocalIndex)->HasSelectedShape(); + + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive()); + return !aShape.IsNull(); } //======================================================================= //function : SelectedShape -//purpose : +//purpose : //======================================================================= - -TopoDS_Shape AIS_InteractiveContext::SelectedShape() const +TopoDS_Shape AIS_InteractiveContext::SelectedShape() const { - if (!HasOpenedContext()) - { - TopoDS_Shape aResShape; - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive()); - if (!aShape.IsNull()) - { - TopLoc_Location aLocTrsf = SelectedInteractive()->Transformation().Form() == gp_Identity ? - TopLoc_Location() : TopLoc_Location (SelectedInteractive()->Transformation()); - aResShape = aShape->Shape().Located (aLocTrsf * aShape->Shape().Location()); - } - - return aResShape; - } - else + if (HasOpenedContext()) { return myLocalContexts (myCurLocalIndex)->SelectedShape(); } -} -//======================================================================= -//function : Interactive -//purpose : -//======================================================================= + if (AIS_Selection::Selection (myCurrentName.ToCString())->Extent() == 0) + return TopoDS_Shape(); -Handle(AIS_InteractiveObject) AIS_InteractiveContext::Interactive() const -{ - return SelectedInteractive(); + const Handle(StdSelect_BRepOwner) anOwner = + Handle(StdSelect_BRepOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value()); + if (!anOwner->HasSelectable()) + return TopoDS_Shape(); + + return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location()); } +//======================================================================= +//function : SelectedInteractive +//purpose : +//======================================================================= Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const { - if(!HasOpenedContext()){ - if (AIS_Selection::Selection(myCurrentName.ToCString())->Extent() == 0) - return NULL; - Handle(Standard_Transient) TR =AIS_Selection::Selection(myCurrentName.ToCString())->Value(); - Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR); - return IO;} - - return myLocalContexts(myCurLocalIndex)->SelectedInteractive(); - + if (HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->SelectedInteractive(); + } + + const Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value()); + if (anOwner.IsNull() || !anOwner->HasSelectable()) + return NULL; + + return Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); } //======================================================================= -//function : Interactive -//purpose : +//function : SelectedOwner +//purpose : //======================================================================= - -Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const +Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const { - if(!HasOpenedContext()){ - Handle(SelectMgr_EntityOwner) Ownr; - return Ownr; + if(HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->SelectedOwner(); } - return myLocalContexts(myCurLocalIndex)->SelectedOwner(); - + + Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); + + return aCurSel->Extent() > 0 ? + Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()) : NULL; } //======================================================================= @@ -1115,46 +1332,49 @@ void AIS_InteractiveContext::EntityOwners(SelectMgr_IndexedMapOfOwner& theOwners } } -Standard_Integer AIS_InteractiveContext::NbSelected() +//======================================================================= +//function : NbSelected +//purpose : +//======================================================================= +Standard_Integer AIS_InteractiveContext::NbSelected() { - Standard_Integer i(0); - for(InitSelected();MoreSelected();NextSelected()) - {i++;} - return i; + Standard_Integer aNbSelected = 0; + for (InitSelected(); MoreSelected(); NextSelected()) + { + aNbSelected++; + } + + return aNbSelected; } //======================================================================= //function : HasApplicative -//purpose : +//purpose : //======================================================================= - Standard_Boolean AIS_InteractiveContext::HasApplicative() const { - return Interactive()->HasOwner(); + return SelectedInteractive()->HasOwner(); } //======================================================================= //function : Applicative -//purpose : +//purpose : //======================================================================= - Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const { - return Interactive()->GetOwner(); + return SelectedInteractive()->GetOwner(); } - - //================================================== -// Function: +// Function: HasDetected // Purpose : //================================================== -Standard_Boolean AIS_InteractiveContext::HasDetected() const +Standard_Boolean AIS_InteractiveContext::HasDetected() const { if(HasOpenedContext()) return myLocalContexts(myCurLocalIndex)->HasDetected(); - else - return !myLastPicked.IsNull(); + + return !myLastPicked.IsNull(); } //======================================================================= @@ -1182,15 +1402,14 @@ AIS_InteractiveContext::DetectedShape() const //======================================================================= //function : DetectedInteractive -//purpose : +//purpose : //======================================================================= - -Handle(AIS_InteractiveObject) -AIS_InteractiveContext::DetectedInteractive() const +Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const { - if(HasOpenedContext()) + if (HasOpenedContext()) return myLocalContexts(myCurLocalIndex)->DetectedInteractive(); - return myLastPicked; + + return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); } @@ -1210,12 +1429,11 @@ Standard_Boolean AIS_InteractiveContext::HasNextDetected() const //======================================================================= Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const { - if(HasOpenedContext()) + if (HasOpenedContext()) return myLocalContexts(myCurLocalIndex)->DetectedOwner(); - Handle(SelectMgr_EntityOwner) Ownr; - return Ownr; -} + return myLastPicked; +} //======================================================================= //function : HilightNextDetected @@ -1327,3 +1545,31 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() co return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL; } + +//======================================================================= +//function : FirstSelectedObject +//purpose : +//======================================================================= +Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject() +{ + Handle(AIS_InteractiveObject) anObject; + + if (HasOpenedContext()) + return anObject; + + InitSelected(); + if (MoreSelected()) + { + return SelectedInteractive(); + } + return anObject; +} + +//======================================================================= +//function : RedrawImmediate +//purpose : Redisplays immediate strucures of the viewer given according to their visibility +//======================================================================= +void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer) +{ + myMainPM->RedrawImmediate (theViewer); +} diff --git a/src/AIS/AIS_InteractiveContext_2.cxx b/src/AIS/AIS_InteractiveContext_2.cxx index 0fef9640fa..a18936d29e 100644 --- a/src/AIS/AIS_InteractiveContext_2.cxx +++ b/src/AIS/AIS_InteractiveContext_2.cxx @@ -44,10 +44,12 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects, { // the entities eventually detected just before the context was opened are unhighlighted... - if(!IsCurrent(myLastPicked)){ + if(!IsSelected(myLastPicked)){ if(!myLastPicked.IsNull()){ - Standard_Integer HiMod = myLastPicked->HasHilightMode()?myLastPicked->HilightMode():0; - myMainPM->Unhighlight(myLastPicked,HiMod); + const Handle(AIS_InteractiveObject) aLastPickedAIS = + Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); + Standard_Integer HiMod = aLastPickedAIS->HasHilightMode()?aLastPickedAIS->HilightMode():0; + myMainPM->Unhighlight (aLastPickedAIS, HiMod); }} if(!mylastmoveview.IsNull()){ @@ -739,7 +741,7 @@ Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_Interact Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView) { return HasOpenedContext() - && myLocalContexts (myCurLocalIndex)->EndImmediateDraw (theView); + && myLocalContexts (myCurLocalIndex)->EndImmediateDraw (theView->Viewer()); } //======================================================================= @@ -761,7 +763,7 @@ Standard_Boolean AIS_InteractiveContext::EndImmediateDraw() } Handle(V3d_View) aView = myMainVwr->ActiveView(); - return myLocalContexts (myCurLocalIndex)->EndImmediateDraw (aView); + return myLocalContexts (myCurLocalIndex)->EndImmediateDraw (aView->Viewer()); } diff --git a/src/AIS/AIS_InteractiveObject.cdl b/src/AIS/AIS_InteractiveObject.cdl index 601a008340..dc16e31700 100644 --- a/src/AIS/AIS_InteractiveObject.cdl +++ b/src/AIS/AIS_InteractiveObject.cdl @@ -306,43 +306,6 @@ is -- - AIS_Shaded -- This range can, however, be extended through the -- creation of new display modes. - - - HasSelectionMode(me) returns Boolean from Standard; - ---Purpose: Allows you to change the selection mode of an - -- Interactive Object. - -- The default selection mode setting is 0. - -- For shapes, for example, the selection modes are as follows: - -- - mode 0 - selection of the shape itself - -- - mode 1 - selection of vertices - -- - mode 2 - selection of edges - -- - mode 3 - selection of wires - -- - mode 4 - selection of faces - -- - mode 5 - selection of shells - -- - mode 6 - selection of solids - -- - mode 7 - selection of compounds - -- For trihedra, on the other hand, the selection modes are the following four: - -- - mode 0 - selection of a trihedron - -- - mode 1 - selection of its origin - -- - mode 2 - selection of its axes - -- - mode 3 - selection of its planes - - SelectionMode(me) returns Integer from Standard; - ---Purpose: Returns the selection mode of the interactive object. - - SetSelectionMode(me:mutable; aMode: Integer from Standard); - ---Purpose: You can change the default selection mode index - -- aMode of an Interactive Object. - -- This is only of interest if you decide that mode 0 - -- adopted by convention will not do. - - UnsetSelectionMode(me:mutable); - ---Purpose: You can change the default selection mode index of - -- an Interactive Object. - -- This is only of interest if you decide that the 0 mode - -- adopted by convention will not do. - ---C++: inline - SelectionPriority(me) returns Integer from Standard; ---C++: inline @@ -604,7 +567,6 @@ fields ---myOwnMaterial : NameOfPhysicalMaterial from Graphic3d is protected; mySelPriority : Integer from Standard; myDisplayMode : Integer from Standard ; - mySelectionMode : Integer from Standard; myHilightMode : Integer from Standard is protected; myOwnWidth : Real from Standard is protected; myInfiniteState : Boolean from Standard is protected; diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index cc4dad7bee..30b17d7ee0 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -60,7 +60,6 @@ myRecomputeEveryPrs(Standard_True), myCTXPtr(NULL), mySelPriority(-1), myDisplayMode (-1), -mySelectionMode(0), mystate(0) { Handle (AIS_InteractiveContext) Bid; @@ -193,18 +192,6 @@ void AIS_InteractiveObject::SetDisplayMode(const Standard_Integer aMode) if( AcceptDisplayMode(aMode) ) myDisplayMode = aMode; } - - -//======================================================================= -//function : -//purpose : -//======================================================================= -void AIS_InteractiveObject::SetSelectionMode(const Standard_Integer aMode) -{ - mySelectionMode = aMode; -} - - //======================================================================= //function : diff --git a/src/AIS/AIS_InteractiveObject.lxx b/src/AIS/AIS_InteractiveObject.lxx index 0f91cefdb4..cadc41bc0c 100644 --- a/src/AIS/AIS_InteractiveObject.lxx +++ b/src/AIS/AIS_InteractiveObject.lxx @@ -44,17 +44,6 @@ inline void AIS_InteractiveObject::UnsetDisplayMode() inline Standard_Integer AIS_InteractiveObject::DisplayMode() const {return myDisplayMode;} -inline Standard_Boolean AIS_InteractiveObject::HasSelectionMode() const -{return mySelectionMode!=-1;} - -inline void AIS_InteractiveObject::UnsetSelectionMode() -{mySelectionMode =-1;} - -inline Standard_Integer AIS_InteractiveObject::SelectionMode() const -{return mySelectionMode;} - - - inline Quantity_NameOfColor AIS_InteractiveObject::Color() const { return myOwnColor.Name(); diff --git a/src/AIS/AIS_LocalContext.cdl b/src/AIS/AIS_LocalContext.cdl index 5a9b10424f..9da8310aef 100644 --- a/src/AIS/AIS_LocalContext.cdl +++ b/src/AIS/AIS_LocalContext.cdl @@ -50,6 +50,7 @@ uses ShapeEnum from TopAbs, Shape from TopoDS, View from V3d, + Viewer from V3d, PresentationManager3d from PrsMgr, IndexedMapOfOwner from SelectMgr, EntityOwner from SelectMgr, @@ -465,10 +466,10 @@ is ---Purpose: Stores presentation theMode of object theObj in the transient list of presentations to be displayed in immediate mode. -- Will be taken in account in EndImmediateDraw method. - EndImmediateDraw (me : mutable; - theView : View from V3d) + EndImmediateDraw (me : mutable; + theViewer : Viewer from V3d) returns Boolean from Standard; - ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background. + ---Purpose: Allows rapid drawing of the each view in theViewer by avoiding an update of the whole background. IsImmediateModeOn (me) returns Boolean from Standard; ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode. diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 259cf016f6..fbfbe67107 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -308,10 +308,10 @@ Erase(const Handle(AIS_InteractiveObject)& anInteractive) // Deactivate selectable entities of interactive object if (mySM->Contains (anInteractive)) { - TColStd_ListIteratorOfListOfInteger aModeIter (STAT->SelectionModes()); - for (; aModeIter.More(); aModeIter.Next()) + while (!STAT->SelectionModes().IsEmpty()) { - mySM->Deactivate (anInteractive, aModeIter.Value(), myMainVS); + mySM->Deactivate (anInteractive, STAT->SelectionModes().Last(), myMainVS); + STAT->RemoveSelectionMode (STAT->SelectionModes().Last()); } } @@ -625,13 +625,6 @@ void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) AIS_Selection::Select(); AIS_Selection::Remove(mySelName.ToCString()); - Handle(V3d_Viewer) aViewer = myCTX->CurrentViewer(); - for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) - { - Handle(V3d_View) aView = aViewer->ActiveView(); - aView->View()->ClearImmediate(); - } - Handle(V3d_View) aDummyView; myMainVS->ClearSensitive (aDummyView); @@ -1110,14 +1103,14 @@ Standard_Boolean AIS_LocalContext::ImmediateAdd (const Handle(AIS_InteractiveObj //function : EndImmediateDraw //purpose : //======================================================================= -Standard_Boolean AIS_LocalContext::EndImmediateDraw (const Handle(V3d_View)& theView) +Standard_Boolean AIS_LocalContext::EndImmediateDraw (const Handle(V3d_Viewer)& theViewer) { if (!myMainPM->IsImmediateModeOn()) { return Standard_False; } - myMainPM->EndImmediateDraw (theView); + myMainPM->EndImmediateDraw (theViewer); return Standard_True; } diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 04c094d896..98688f1a31 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -474,7 +474,7 @@ void AIS_LocalContext::Hilight (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable())); myMainPM->BeginImmediateDraw(); theOwner->HilightWithColor (myMainPM, myCTX->HilightColor(), aHilightMode); - myMainPM->EndImmediateDraw (theView); + myMainPM->EndImmediateDraw (theView->Viewer()); } //================================================== @@ -1389,7 +1389,7 @@ Standard_Boolean AIS_LocalContext::UnhilightLastDetected (const Handle(V3d_View) : 0; myMapOfOwner (mylastindex)->Unhilight (myMainPM, aHilightMode); - myMainPM->EndImmediateDraw (theView); + myMainPM->EndImmediateDraw (theView->Viewer()); mylastindex = 0; return Standard_True; } diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cdl b/src/AIS/AIS_MultipleConnectedInteractive.cdl index ddc1dcc7fb..c5c864d808 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cdl +++ b/src/AIS/AIS_MultipleConnectedInteractive.cdl @@ -37,6 +37,7 @@ uses Projector from Prs3d, Transformation from Geom, Integer from Standard, + EntityOwner from SelectMgr, Selection from SelectMgr, Trsf from gp, Pnt from gp, @@ -126,6 +127,10 @@ is ---Purpose: Informs the graphic context that the interactive Object -- may be decomposed into sub-shapes for dynamic selection. + GlobalSelOwner(me) + returns EntityOwner from SelectMgr + is redefined virtual; + ---Purpose: Returns the owner of mode for selection of object as a whole. ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; aMode : Integer from Standard) diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 82ac598c1e..635f19c84a 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -385,3 +385,12 @@ void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_ } } } + +//======================================================================= +//function : GlobalSelOwner +//purpose : +//======================================================================= +Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() const +{ + return myAssemblyOwner; +} diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl index dfcc02e7df..5d249c6076 100644 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl @@ -378,16 +378,6 @@ is -- But it works in any case and is especially useful for view dump because the dump image is read from the back buffer. -- @return previous mode. - DisplayImmediateStructure ( me : mutable; - theCView : CView from Graphic3d; - theStructure : Structure from Graphic3d ) - is deferred; - ---Purpose: Display structure in immediate mode on top of general presentation - - ---C++: alias " - //! Erases immediate structure - Standard_EXPORT virtual void EraseImmediateStructure (const Graphic3d_CView& theCView, const Graphic3d_CStructure& theCStructure) = 0;" - ------------------------------- -- Category: Layer mode methods ------------------------------- diff --git a/src/Graphic3d/Graphic3d_ViewAffinity.hxx b/src/Graphic3d/Graphic3d_ViewAffinity.hxx index 0835726167..d9d97d1327 100644 --- a/src/Graphic3d/Graphic3d_ViewAffinity.hxx +++ b/src/Graphic3d/Graphic3d_ViewAffinity.hxx @@ -28,7 +28,7 @@ public: //! Empty constructor. Graphic3d_ViewAffinity() { - ::memset (&myMask, 0xFF, sizeof(myMask)); + SetVisible (Standard_True); } //! Return visibility flag. @@ -38,6 +38,12 @@ public: return (myMask & aBit) != 0; } + //! Setup visibility flag for all views. + void SetVisible (const Standard_Boolean theIsVisible) + { + ::memset (&myMask, theIsVisible ? 0xFF : 0x00, sizeof(myMask)); + } + //! Setup visibility flag. void SetVisible (const Standard_Integer theViewId, const bool theIsVisible) diff --git a/src/MeshVS/MeshVS_Mesh.cxx b/src/MeshVS/MeshVS_Mesh.cxx index 315d2b911b..a14e9dd330 100644 --- a/src/MeshVS/MeshVS_Mesh.cxx +++ b/src/MeshVS/MeshVS_Mesh.cxx @@ -991,6 +991,8 @@ void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)& IsNeedToRedisplay = Standard_True; + aSelectionPrs->SetZLayer (Graphic3d_ZLayerId_Top); + if ( IsNeedToRedisplay ) { aSelectionPrs->SetDisplayPriority(9); @@ -1105,6 +1107,8 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage } } + aHilightPrs->SetZLayer (Graphic3d_ZLayerId_Topmost); + if (PM->IsImmediateModeOn()) { PM->AddToImmediateList (aHilightPrs); diff --git a/src/OS/Visualization.tcl b/src/OS/Visualization.tcl index 8eadc996d8..13ee5fe81d 100644 --- a/src/OS/Visualization.tcl +++ b/src/OS/Visualization.tcl @@ -29,7 +29,7 @@ proc Visualization:toolkits { } { if { "$::tcl_platform(platform)" == "windows" } { if { [info exists ::env(HAVE_D3D)] && "$::env(HAVE_D3D)" == "true" } { lappend aResult "TKD3DHost" - } elseif { [info exists ::env(VCVER)] && "$::env(VCVER)" != "vc8" && "$::env(VCVER)" != "vc9" && "$::env(VCVER)" != "vc10" } { + } elseif { [info exists ::env(VCVER)] && "$::env(VCVER)" != "vc8" && "$::env(VCVER)" != "vc9" && "$::env(VCVER)" != "vc10" && "$::env(VCVER)" != "vc11" } { lappend aResult "TKD3DHost" } } diff --git a/src/OpenGl/OpenGl_Caps.cxx b/src/OpenGl/OpenGl_Caps.cxx index 16ca279835..d1dda20fe2 100755 --- a/src/OpenGl/OpenGl_Caps.cxx +++ b/src/OpenGl/OpenGl_Caps.cxx @@ -30,8 +30,10 @@ OpenGl_Caps::OpenGl_Caps() keepArrayData (Standard_False), #if !defined(GL_ES_VERSION_2_0) ffpEnable (Standard_True), + useSystemBuffer (Standard_False), #else ffpEnable (Standard_False), + useSystemBuffer (Standard_True), #endif buffersNoSwap (Standard_False), contextStereo (Standard_False), @@ -64,6 +66,7 @@ OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy) pntSpritesDisable = theCopy.pntSpritesDisable; keepArrayData = theCopy.keepArrayData; ffpEnable = theCopy.ffpEnable; + useSystemBuffer = theCopy.useSystemBuffer; buffersNoSwap = theCopy.buffersNoSwap; contextStereo = theCopy.contextStereo; contextDebug = theCopy.contextDebug; diff --git a/src/OpenGl/OpenGl_Caps.hxx b/src/OpenGl/OpenGl_Caps.hxx index fa60482a49..937778a0ed 100755 --- a/src/OpenGl/OpenGl_Caps.hxx +++ b/src/OpenGl/OpenGl_Caps.hxx @@ -31,6 +31,7 @@ public: //! @name flags to disable particular functionality, should be used only Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default) Standard_Boolean keepArrayData; //!< Disables freeing CPU memory after building VBOs (OFF by default) Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (ON by default on desktop OpenGL and OFF on OpenGL ES) + Standard_Boolean useSystemBuffer; //!< Enables usage of system backbuffer for blitting (OFF by default on desktop OpenGL and ON on OpenGL ES for testing) public: //! @name context creation parameters diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 311190f50e..35e0b8856b 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -415,40 +415,6 @@ Standard_Boolean OpenGl_GraphicDriver::SetImmediateModeDrawToFront (const Graphi return Standard_False; } -// ======================================================================= -// function : DisplayImmediateStructure -// purpose : -// ======================================================================= -void OpenGl_GraphicDriver::DisplayImmediateStructure (const Graphic3d_CView& theCView, - const Handle(Graphic3d_Structure)& theStructure) -{ - OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; - if (aCView == NULL) - { - return; - } - - aCView->View->DisplayImmediateStructure (theStructure); -} - -// ======================================================================= -// function : EraseImmediateStructure -// purpose : -// ======================================================================= -void OpenGl_GraphicDriver::EraseImmediateStructure (const Graphic3d_CView& theCView, - const Graphic3d_CStructure& theCStructure) -{ - OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; - OpenGl_Structure* aStructure = (OpenGl_Structure* )&theCStructure; - if (aCView == NULL) - { - return; - } - - aCView->View->EraseImmediateStructure (aStructure); -} - - // ======================================================================= // function : Print // purpose : diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index c3b7e09666..9d100054da 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -131,10 +131,6 @@ public: // Methods for graphical structures Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Graphic3d_CView& theCView, const Standard_Boolean theDrawToFrontBuffer); - Standard_EXPORT void DisplayImmediateStructure (const Graphic3d_CView& theCView, - const Handle(Graphic3d_Structure)& theStructure); - Standard_EXPORT void EraseImmediateStructure (const Graphic3d_CView& theCView, - const Graphic3d_CStructure& theCStructure); public: diff --git a/src/OpenGl/OpenGl_StructureShadow.cxx b/src/OpenGl/OpenGl_StructureShadow.cxx index 9cfe62b99f..abc0f1221b 100644 --- a/src/OpenGl/OpenGl_StructureShadow.cxx +++ b/src/OpenGl/OpenGl_StructureShadow.cxx @@ -42,6 +42,8 @@ OpenGl_StructureShadow::OpenGl_StructureShadow (const Handle(Graphic3d_Structure } } + UpdateTransformation(); + myInstancedStructure = const_cast (myParent->InstancedStructure()); TransformPersistence.IsSet = myParent->TransformPersistence.IsSet; TransformPersistence.Flag = myParent->TransformPersistence.Flag; TransformPersistence.Point = myParent->TransformPersistence.Point; diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 99886ea273..806686bd22 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -135,12 +135,6 @@ class OpenGl_View : public MMgt_TShared //! Erase structure from display list. void EraseStructure (const Handle(Graphic3d_Structure)& theStructure); - //! Add structure to the list of immediate structures. - void DisplayImmediateStructure (const Handle(Graphic3d_Structure)& theStructure); - - //! Erase structure from display list. - void EraseImmediateStructure (const OpenGl_Structure* theStructure); - //! Insert a new top-level z layer with ID void AddZLayer (const Graphic3d_ZLayerId theLayerId); @@ -200,17 +194,10 @@ class OpenGl_View : public MMgt_TShared //! marks primitive set for rebuild. void InvalidateBVHData (const Standard_Integer theLayerId); - //! Returns list of immediate structures rendered on top of main presentation - const OpenGl_SequenceOfStructure& ImmediateStructures() const - { - return myImmediateList; - } - //! Returns true if there are immediate structures to display bool HasImmediateStructures() const { - return !myImmediateList.IsEmpty() - || myZLayers.NbImmediateStructures() != 0; + return myZLayers.NbImmediateStructures() != 0; } protected: @@ -267,8 +254,7 @@ protected: //View_LABDepthCueing - fixed index used - OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers - OpenGl_SequenceOfStructure myImmediateList; //!< list of immediate structures rendered on top of main presentation + OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers const TEL_TRANSFORM_PERSISTENCE *myTransPers; Standard_Boolean myIsTransPers; diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 3abea5156f..dcdf5dcdf1 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -568,7 +568,9 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& theWorkspace, } Standard_Boolean toRenderGL = theToDrawImmediate || - theCView.RenderParams.Method != Graphic3d_RM_RAYTRACING || myRaytraceInitStatus == OpenGl_RT_FAIL; + theCView.RenderParams.Method != Graphic3d_RM_RAYTRACING || + myRaytraceInitStatus == OpenGl_RT_FAIL || + aCtx->IsFeedback(); if (!toRenderGL) { @@ -911,26 +913,6 @@ void OpenGl_View::DisplayStructure (const Handle(Graphic3d_Structure)& theStruct myZLayers.AddStructure (aStruct, aZLayer, thePriority); } -//======================================================================= -//function : DisplayImmediateStructure -//purpose : -//======================================================================= - -void OpenGl_View::DisplayImmediateStructure (const Handle(Graphic3d_Structure)& theStructure) -{ - const OpenGl_Structure* aStruct = reinterpret_cast (theStructure->CStructure().operator->()); - for (OpenGl_SequenceOfStructure::Iterator anIter (myImmediateList); - anIter.More(); anIter.Next()) - { - if (anIter.Value() == aStruct) - { - return; - } - } - - myImmediateList.Append (aStruct); -} - //======================================================================= //function : EraseStructure //purpose : @@ -941,24 +923,6 @@ void OpenGl_View::EraseStructure (const Handle(Graphic3d_Structure)& theStructur myZLayers.RemoveStructure (theStructure); } -//======================================================================= -//function : EraseImmediateStructure -//purpose : -//======================================================================= - -void OpenGl_View::EraseImmediateStructure (const OpenGl_Structure* theStructure) -{ - for (OpenGl_SequenceOfStructure::Iterator anIter (myImmediateList); - anIter.More(); anIter.Next()) - { - if (anIter.Value() == theStructure) - { - myImmediateList.Remove (anIter); - return; - } - } -} - //======================================================================= //function : ChangeZLayer //purpose : diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 58f05e2f29..a50adddd9e 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -742,7 +742,7 @@ bool OpenGl_Workspace::blitBuffers (OpenGl_FrameBuffer* theReadFbo, OpenGl_FrameBuffer* theDrawFbo, const Standard_Boolean theToFlip) { - if (theReadFbo == NULL) + if (theReadFbo == NULL || myGlContext->IsFeedback()) { return false; } @@ -939,8 +939,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView, { myMainSceneFbos[0]->Init (myGlContext, aSizeX, aSizeY); } - if (myToFlipOutput - && myMainSceneFbos[0]->IsValid()) + if (!myGlContext->caps->useSystemBuffer && myMainSceneFbos[0]->IsValid()) { myImmediateSceneFbos[0]->InitLazy (myGlContext, aSizeX, aSizeY); } @@ -1040,8 +1039,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView, { OpenGl_FrameBuffer* aMainFbo = myMainSceneFbos[0]->IsValid() ? myMainSceneFbos[0].operator->() : NULL; OpenGl_FrameBuffer* anImmFbo = aFrameBuffer; - if (myToFlipOutput - && myImmediateSceneFbos[0]->IsValid()) + if (!myGlContext->caps->useSystemBuffer && myImmediateSceneFbos[0]->IsValid()) { anImmFbo = myImmediateSceneFbos[0].operator->(); } @@ -1360,8 +1358,7 @@ void OpenGl_Workspace::RedrawImmediate (const Graphic3d_CView& theCView, { OpenGl_FrameBuffer* aMainFbo = myMainSceneFbos[0]->IsValid() ? myMainSceneFbos[0].operator->() : NULL; OpenGl_FrameBuffer* anImmFbo = aFrameBuffer; - if (myToFlipOutput - && myImmediateSceneFbos[0]->IsValid()) + if (!myGlContext->caps->useSystemBuffer && myImmediateSceneFbos[0]->IsValid()) { anImmFbo = myImmediateSceneFbos[0].operator->(); } @@ -1477,21 +1474,6 @@ bool OpenGl_Workspace::redrawImmediate (const Graphic3d_CView& theCView, myView->Render (myPrintContext, aWS, theDrawFbo, theProjection, theCView, theCUnderLayer, theCOverLayer, Standard_True); - if (!myView->ImmediateStructures().IsEmpty()) - { - glDisable (GL_DEPTH_TEST); - } - for (OpenGl_SequenceOfStructure::Iterator anIter (myView->ImmediateStructures()); - anIter.More(); anIter.Next()) - { - const OpenGl_Structure* aStructure = anIter.Value(); - if (!aStructure->IsVisible()) - { - continue; - } - - aStructure->Render (aWS); - } return !toCopyBackToFront; } diff --git a/src/Prs3d/Prs3d_PresentationShadow.cxx b/src/Prs3d/Prs3d_PresentationShadow.cxx index c73bece695..88c729338f 100644 --- a/src/Prs3d/Prs3d_PresentationShadow.cxx +++ b/src/Prs3d/Prs3d_PresentationShadow.cxx @@ -24,7 +24,9 @@ IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PresentationShadow, Prs3d_Presentation) //======================================================================= Prs3d_PresentationShadow::Prs3d_PresentationShadow (const Handle(Graphic3d_StructureManager)& theViewer, const Handle(Prs3d_Presentation)& thePrs) -: Prs3d_Presentation (theViewer, thePrs) +: Prs3d_Presentation (theViewer, thePrs), + myParentStructId (thePrs->Identification()), + myParentAffinity (thePrs->CStructure()->ViewAffinity) { // } diff --git a/src/Prs3d/Prs3d_PresentationShadow.hxx b/src/Prs3d/Prs3d_PresentationShadow.hxx index cc8ae2cb48..46a992f663 100644 --- a/src/Prs3d/Prs3d_PresentationShadow.hxx +++ b/src/Prs3d/Prs3d_PresentationShadow.hxx @@ -28,10 +28,20 @@ public: Standard_EXPORT Prs3d_PresentationShadow (const Handle(Graphic3d_StructureManager)& theViewer, const Handle(Prs3d_Presentation)& thePrs); + //! Returns the id of the parent presentation + Standard_EXPORT inline Standard_Integer ParentId() const { return myParentStructId; } + + //! Returns view affinity of the parent presentation + Standard_EXPORT inline const Handle(Graphic3d_ViewAffinity)& ParentAffinity() const { return myParentAffinity; } + private: DEFINE_STANDARD_RTTI(Prs3d_PresentationShadow) +private: + Standard_Integer myParentStructId; + Handle(Graphic3d_ViewAffinity) myParentAffinity; + }; DEFINE_STANDARD_HANDLE(Prs3d_PresentationShadow, Prs3d_Presentation) diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cdl b/src/PrsMgr/PrsMgr_PresentationManager.cdl index cc0f813a39..08ca9feb10 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cdl +++ b/src/PrsMgr/PrsMgr_PresentationManager.cdl @@ -25,6 +25,7 @@ inherits TShared from MMgt uses StructureManager from Graphic3d, + ZLayerId from Graphic3d, PresentableObject from PrsMgr, ListOfPresentations from PrsMgr, Length,NameOfColor from Quantity, @@ -32,7 +33,7 @@ uses Transformation from Geom, NameOfMaterial from Graphic3d, Presentation from PrsMgr, - View from V3d, + Viewer from V3d, ViewManager from Visual3d, ShadingAspect from Prs3d, Presentation from Prs3d @@ -148,29 +149,39 @@ is ---Purpose: Resets the transient list of presentations previously displayed in immediate mode -- and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls. - ClearImmediateDraw (me : mutable); + ClearImmediateDraw (me : mutable) + is static; ---Purpose: Resets the transient list of presentations previously displayed in immediate mode. AddToImmediateList (me : mutable; - thePrs : Presentation from Prs3d); + thePrs : Presentation from Prs3d) + is static; ---Purpose: Stores thePrs in the transient list of presentations to be displayed in immediate mode. -- Will be taken in account in EndImmediateDraw method. - EndImmediateDraw (me : mutable; - theView : View from V3d); - ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background. + EndImmediateDraw (me : mutable; + theViewer : Viewer from V3d) + is static; + ---Purpose: Allows rapid drawing of the each view in theViewer by avoiding an update of the whole background. - IsImmediateModeOn (me) returns Boolean from Standard; + RedrawImmediate (me : mutable; + theViewer : Viewer from V3d) + is static; + ---Purpose: Clears and redisplays immediate structures of the viewer taking into account its affinity + + IsImmediateModeOn (me) returns Boolean from Standard + is static; ---C++: inline ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode. ---Category: Hilighting methods. - Color (me : mutable; - thePrsObject : PresentableObject from PrsMgr; - theColor : NameOfColor from Quantity = Quantity_NOC_YELLOW; - theMode : Integer from Standard = 0; - theSelObj : PresentableObject from PrsMgr = NULL) + Color (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theColor : NameOfColor from Quantity = Quantity_NOC_YELLOW; + theMode : Integer from Standard = 0; + theSelObj : PresentableObject from PrsMgr = NULL; + theImmediateStructLayerId : ZLayerId from Graphic3d = Graphic3d_ZLayerId_Topmost) ---Purpose: Highlights the graphic object thePrsObject in the color theColor. -- thePrsObject has the display mode theMode; -- this has the default value of 0, that is, the wireframe display mode. @@ -251,12 +262,17 @@ is ---Purpose: Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject has the display mode theMode. is protected; + displayImmediate (me : mutable; + theViewer : Viewer from V3d); + ---Purpose: Handles the structures from and displays it separating view-dependent structures and taking into account + -- structure visibility by setting proper affinity. + fields - myStructureManager : ViewManager from Visual3d is protected; - myImmediateModeOn : Integer from Standard is protected; - myImmediateList : ListOfPresentations from PrsMgr is protected; - myImmediateView : View from V3d is protected; - mySelectionColor : Color from Quantity is protected; + myStructureManager : ViewManager from Visual3d is protected; + myImmediateModeOn : Integer from Standard is protected; + myImmediateList : ListOfPresentations from PrsMgr is protected; + myViewDependentImmediateList : ListOfPresentations from PrsMgr is protected; + mySelectionColor : Color from Quantity is protected; end PresentationManager from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 702faad79a..bfd4a1b26c 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -317,40 +317,108 @@ void PrsMgr_PresentationManager::BeginImmediateDraw() // ======================================================================= void PrsMgr_PresentationManager::ClearImmediateDraw() { - if (myImmediateView.IsNull()) + for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) { - myImmediateList.Clear(); - return; + anIter.Value()->Erase(); } - for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) + for (PrsMgr_ListOfPresentations::Iterator anIter (myViewDependentImmediateList); anIter.More(); anIter.Next()) { - myImmediateView->View()->EraseImmediate (anIter.Value()); + anIter.Value()->Erase(); } myImmediateList.Clear(); - myImmediateView.Nullify(); + myViewDependentImmediateList.Clear(); +} + +// ======================================================================= +// function : displayImmediate +// purpose : Handles the structures from myImmediateList and its visibility +// in all views of the viewer given by setting proper affinity +// ======================================================================= +void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& theViewer) +{ + for (theViewer->InitActiveViews(); theViewer->MoreActiveViews(); theViewer->NextActiveViews()) + { + const Handle(Visual3d_View)& aView = theViewer->ActiveView()->View(); + for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) + { + const Handle(Prs3d_Presentation)& aPrs = anIter.Value(); + if (aPrs.IsNull()) + continue; + + Handle(Prs3d_Presentation) aViewDepPrs; + Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs); + if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs)) + { + aShadowPrs.Nullify(); + aShadowPrs = new Prs3d_PresentationShadow (myStructureManager, aViewDepPrs); + aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer()); + aShadowPrs->SetClipPlanes (aViewDepPrs->GetClipPlanes()); + aShadowPrs->CStructure()->IsForHighlight = 1; + aShadowPrs->Highlight (Aspect_TOHM_COLOR, aPrs->HighlightColor()); + myViewDependentImmediateList.Append (aShadowPrs); + } + // handles custom highlight presentations which were defined in overriden + // HilightOwnerWithColor method of a custom AIS objects and maintain its + // visibility in different views on their own + else if (aShadowPrs.IsNull()) + { + aPrs->Display(); + continue; + } + + if (!aShadowPrs->IsDisplayed()) + { + aShadowPrs->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity(); + aShadowPrs->CStructure()->ViewAffinity->SetVisible (Standard_False); + aShadowPrs->Display(); + } + + Standard_Integer aViewId = aView->Identification(); + bool isParentVisible = aShadowPrs->ParentAffinity().IsNull() ? + Standard_True : aShadowPrs->ParentAffinity()->IsVisible (aViewId); + aShadowPrs->CStructure()->ViewAffinity->SetVisible (aViewId, isParentVisible); + } + } } // ======================================================================= // function : EndImmediateDraw // purpose : // ======================================================================= -void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_View)& theView) +void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_Viewer)& theViewer) { if (--myImmediateModeOn > 0) { return; } + displayImmediate (theViewer); +} + +// ======================================================================= +// function : RedrawImmediate +// purpose : Clears all immediate structures and redisplays with proper +// affinity +//======================================================================= +void PrsMgr_PresentationManager::RedrawImmediate (const Handle(V3d_Viewer)& theViewer) +{ + if (myImmediateList.IsEmpty()) + return; + + // Clear previously displayed structures for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) { - theView->View()->DisplayImmediate (anIter.Value(), Standard_True); + anIter.Value()->Erase(); } - if (!myImmediateList.IsEmpty()) + for (PrsMgr_ListOfPresentations::Iterator anIter (myViewDependentImmediateList); anIter.More(); anIter.Next()) { - myImmediateView = theView; + anIter.Value()->Erase(); } + myViewDependentImmediateList.Clear(); + + displayImmediate (theViewer); } // ======================================================================= @@ -519,11 +587,12 @@ void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObjec void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Quantity_NameOfColor theColor, const Standard_Integer theMode, - const Handle(PrsMgr_PresentableObject)& theSelObj) + const Handle(PrsMgr_PresentableObject)& theSelObj, + const Standard_Integer theImmediateStructLayerId) { for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) { - Color (anIter.Value(), theColor, theMode); + Color (anIter.Value(), theColor, theMode, NULL, theImmediateStructLayerId); } if (!thePrsObj->HasOwnPresentations()) { @@ -539,6 +608,9 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& if (myImmediateModeOn > 0) { Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); + aShadow->SetZLayer (theImmediateStructLayerId); + aShadow->SetClipPlanes (aPrs->Presentation()->GetClipPlanes()); + aShadow->CStructure()->IsForHighlight = 1; aShadow->Highlight (Aspect_TOHM_COLOR, theColor); AddToImmediateList (aShadow); } diff --git a/src/QABugs/QABugs_1.cxx b/src/QABugs/QABugs_1.cxx index 73e5f95a06..f09261d330 100644 --- a/src/QABugs/QABugs_1.cxx +++ b/src/QABugs/QABugs_1.cxx @@ -417,13 +417,14 @@ static Standard_Integer OCC74bug_set (Draw_Interpretor& di, Standard_Integer arg di << argv[1] << " : No interactive object" << "\n"; return 1; } - AISObj->SetSelectionMode(SelectMode); if (!aContext->HasOpenedContext()) { aContext->OpenLocalContext(); } aContext->Erase(AISObj, updateviewer); aContext->UpdateCurrentViewer(); + aContext->SetAutoActivateSelection (Standard_False); aContext->Display(AISObj, updateviewer); + aContext->Activate (AISObj, SelectMode); aContext->UpdateCurrentViewer(); } return 0; @@ -456,8 +457,10 @@ static Standard_Integer OCC74bug_get (Draw_Interpretor& di, Standard_Integer arg di << argv[1] << " : No interactive object" << "\n"; return 1; } - Standard_Integer SelectMode = AISObj->SelectionMode(); - di << SelectMode << "\n"; + TColStd_ListOfInteger anActivatedModes; + aContext->ActivatedModes (AISObj, anActivatedModes); + Standard_Integer aMode = anActivatedModes.IsEmpty() ? -1 : anActivatedModes.Last(); + di << aMode << "\n"; } return 0; diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 31b2467c5d..7bfd26cfe8 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -229,11 +229,11 @@ static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, con anAISCtx->Display(aSh4); //set selected - anAISCtx->InitCurrent(); - anAISCtx->AddOrRemoveCurrentObject(aSh1); - anAISCtx->AddOrRemoveCurrentObject(aSh2); - anAISCtx->AddOrRemoveCurrentObject(aSh3); - anAISCtx->AddOrRemoveCurrentObject(aSh4); + anAISCtx->InitSelected(); + anAISCtx->AddOrRemoveSelected(aSh1); + anAISCtx->AddOrRemoveSelected(aSh2); + anAISCtx->AddOrRemoveSelected(aSh3); + anAISCtx->AddOrRemoveSelected(aSh4); //remove all this objects from context anAISCtx->Remove (aSh1, Standard_False); @@ -738,12 +738,13 @@ static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100); Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape()); + myAISContext->SetAutoActivateSelection (Standard_False); myAISContext->Display(anAISBox, 1); - anAISBox->SetSelectionMode(-1); Standard_Integer myLocContInd = myAISContext->OpenLocalContext(); myAISContext->CloseLocalContext(myLocContInd); - Standard_Integer aSelMode = ((Handle(AIS_InteractiveObject)) anAISBox)->SelectionMode(); - if(aSelMode != -1) + TColStd_ListOfInteger anActivatedModes; + myAISContext->ActivatedModes (anAISBox, anActivatedModes); + if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 ) return 1; return 0; @@ -5255,7 +5256,7 @@ Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const cha Handle(Geom_Axis2Placement) trihedronAxis = new Geom_Axis2Placement(gp::XOY()); Handle(AIS_Trihedron) trihedron = new AIS_Trihedron(trihedronAxis); if (aMode) - trihedron->UnsetSelectionMode(); // this line causes an exception on OpenLocalContext + aisContext->SetAutoActivateSelection (Standard_False); // if selection must not be activated trihedron->SetSize(20); trihedron->SetColor(Quantity_NOC_GRAY30); trihedron->SetArrowColor(Quantity_NOC_GRAY30); diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 7a3ea386af..6d53d3f9af 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -398,21 +398,21 @@ static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/ aContext->Display(ais2); aContext->Display(ais3); - aContext->AddOrRemoveCurrentObject(ais1); - aContext->AddOrRemoveCurrentObject(ais2); - aContext->AddOrRemoveCurrentObject(ais3); + aContext->AddOrRemoveSelected(ais1); + aContext->AddOrRemoveSelected(ais2); + aContext->AddOrRemoveSelected(ais3); - di << "\n No of currents = " << aContext->NbCurrents(); + di << "\n No of currents = " << aContext->NbSelected(); - aContext->InitCurrent(); + aContext->InitSelected(); int count = 1; - while(aContext->MoreCurrent()) + while(aContext->MoreSelected()) { di << "\n count is = " << count++; - Handle(AIS_InteractiveObject) ais = aContext->Current(); - aContext->AddOrRemoveCurrentObject(ais); - aContext->InitCurrent(); + Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive(); + aContext->AddOrRemoveSelected(ais); + aContext->InitSelected(); } return 0; @@ -694,51 +694,51 @@ static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/ aContext2->Display(ais2); aContext2->Display(ais3); - aContext1->AddOrRemoveCurrentObject(ais1); - aContext1->AddOrRemoveCurrentObject(ais2); - aContext1->AddOrRemoveCurrentObject(ais3); + aContext1->AddOrRemoveSelected(ais1); + aContext1->AddOrRemoveSelected(ais2); + aContext1->AddOrRemoveSelected(ais3); di << "\n Stage : 1"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n"; + di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); + di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n"; - di << "\n aContext1->IsCurrent = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " "; + di << "\n aContext1->IsSelected = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " "; - aContext2->AddOrRemoveCurrentObject(ais1); - aContext2->AddOrRemoveCurrentObject(ais2); - aContext2->AddOrRemoveCurrentObject(ais3); + aContext2->AddOrRemoveSelected(ais1); + aContext2->AddOrRemoveSelected(ais2); + aContext2->AddOrRemoveSelected(ais3); di << "\n Stage : 2"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n"; + di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); + di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n"; - aContext1->InitCurrent(); + aContext1->InitSelected(); int count1 = 1; - while(aContext1->MoreCurrent()) + while(aContext1->MoreSelected()) { di << "\n count1 is = " << count1++; - Handle(AIS_InteractiveObject) ais = aContext1->Current(); - aContext1->AddOrRemoveCurrentObject(ais); - aContext1->InitCurrent(); + Handle(AIS_InteractiveObject) ais = aContext1->SelectedInteractive(); + aContext1->AddOrRemoveSelected(ais); + aContext1->InitSelected(); } di << "\n Stage : 3"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n"; + di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); + di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n"; - aContext2->InitCurrent(); + aContext2->InitSelected(); int count2 = 1; - while(aContext2->MoreCurrent()) + while(aContext2->MoreSelected()) { di << "\n count2 is = " << count2++; - Handle(AIS_InteractiveObject) ais = aContext2->Current(); - aContext2->AddOrRemoveCurrentObject(ais); - aContext2->InitCurrent(); + Handle(AIS_InteractiveObject) ais = aContext2->SelectedInteractive(); + aContext2->AddOrRemoveSelected(ais); + aContext2->InitSelected(); } di << "\n\n Stage : 4"; - di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents(); - di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents(); + di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected(); + di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected(); return 0; } diff --git a/src/QABugs/QABugs_8.cxx b/src/QABugs/QABugs_8.cxx index bdc82ef8bc..e374f4a864 100644 --- a/src/QABugs/QABugs_8.cxx +++ b/src/QABugs/QABugs_8.cxx @@ -67,7 +67,7 @@ static Standard_Integer OCC172 (Draw_Interpretor& di, Standard_Integer /*argc*/ AIS_ListIteratorOfListOfInteractive It; for (It.Initialize(aListOfIO);It.More();It.Next()) { - aContext->AddOrRemoveCurrentObject(It.Value()); + aContext->AddOrRemoveSelected(It.Value()); } return 0; @@ -104,21 +104,21 @@ static Standard_Integer OCC204 (Draw_Interpretor& di, Standard_Integer argc, co aContext->Display(ais2); aContext->Display(ais3); - aContext->AddOrRemoveCurrentObject(ais1); - aContext->AddOrRemoveCurrentObject(ais2); - aContext->AddOrRemoveCurrentObject(ais3); + aContext->AddOrRemoveSelected(ais1); + aContext->AddOrRemoveSelected(ais2); + aContext->AddOrRemoveSelected(ais3); //printf("\n No of currents = %d", aContext->NbCurrents()); - aContext->InitCurrent(); + aContext->InitSelected(); //int count = 1; - while(aContext->MoreCurrent()) + while(aContext->MoreSelected()) { //printf("\n count is = %d", count++); - Handle(AIS_InteractiveObject) ais = aContext->Current(); + Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive(); aContext->Remove(ais, UpdateViewer); - aContext->InitCurrent(); + aContext->InitSelected(); } return 0; diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index 8a0b522ca1..ee39aa700a 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -86,7 +86,11 @@ void SelectMgr_EntityOwner::HilightWithColor(const Handle(PrsMgr_PresentationMan { if( HasSelectable() ) { if( IsAutoHilight() ) - PM->Color(mySelectable,aColor,aMode); + { + const Graphic3d_ZLayerId aLayerId = mySelectable->GlobalSelOwner().Access() == this ? + Graphic3d_ZLayerId_Top : Graphic3d_ZLayerId_Topmost; + PM->Color(mySelectable,aColor,aMode, NULL, aLayerId); + } else mySelectable->HilightOwnerWithColor( PM, aColor, this ); } diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cdl b/src/SelectMgr/SelectMgr_SelectableObject.cdl index 6231ea3b32..193b66d719 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cdl +++ b/src/SelectMgr/SelectMgr_SelectableObject.cdl @@ -239,6 +239,22 @@ is ---C++: return const& ---Purpose: Returns common entity owner if the object is an assembly + GlobalSelectionMode (me) + returns Integer from Standard; + ---C++: inline + ---Purpose: Returns the mode for selection of object as a whole + + GlobalSelOwner (me) + returns EntityOwner from SelectMgr + is virtual; + ---Purpose: Returns the owner of mode for selection of object as a whole + + setGlobalSelMode (me : mutable; + theMode : Integer from Standard) + is static protected; + ---Purpose: Allows derived classes to redefine global selection mode. + ---C++: inline + fields myselections : SequenceOfSelection is protected; @@ -250,6 +266,7 @@ fields mySelectionPrs : Presentation from Prs3d; myHilightPrs : Presentation from Prs3d; + myGlobalSelMode : Integer from Standard; friends class SelectionManager from SelectMgr diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index 3985350d93..11a5186b10 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -50,12 +50,13 @@ static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq, // Purpose : //================================================== -SelectMgr_SelectableObject::SelectMgr_SelectableObject( const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): - PrsMgr_PresentableObject (aTypeOfPresentation3d), +SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) +: PrsMgr_PresentableObject (aTypeOfPresentation3d), myDrawer (new Prs3d_Drawer()), myHilightDrawer (new Prs3d_Drawer()), myAssemblyOwner (NULL), - myAutoHilight (Standard_True) + myAutoHilight (Standard_True), + myGlobalSelMode (0) { InitDefaultHilightAttributes (myHilightDrawer); myHilightDrawer->Link (myDrawer); @@ -580,3 +581,25 @@ const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwne { return myAssemblyOwner; } + +//======================================================================= +//function : GlobalSelOwner +//purpose : Returns entity owner corresponding to selection of the object as a whole +//======================================================================= +Handle(SelectMgr_EntityOwner) SelectMgr_SelectableObject::GlobalSelOwner() const +{ + Handle(SelectMgr_EntityOwner) anOwner; + + if (!HasSelection (myGlobalSelMode)) + return anOwner; + + const Handle(SelectMgr_Selection)& aGlobalSel = Selection (myGlobalSelMode); + if (aGlobalSel->IsEmpty()) + return anOwner; + + aGlobalSel->Init(); + anOwner = + Handle(SelectMgr_EntityOwner)::DownCast (aGlobalSel->Sensitive()->BaseSensitive()->OwnerId()); + + return anOwner; +} diff --git a/src/SelectMgr/SelectMgr_SelectableObject.lxx b/src/SelectMgr/SelectMgr_SelectableObject.lxx index 31ddd4a8ea..214dbbe7ff 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.lxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.lxx @@ -32,3 +32,21 @@ Attributes() const inline const Handle(Prs3d_Drawer)& SelectMgr_SelectableObject:: HilightAttributes() const {return myHilightDrawer;} + +//======================================================================= +//function : GlobalSelectionMode +//purpose : +//======================================================================= +inline Standard_Integer SelectMgr_SelectableObject::GlobalSelectionMode() const +{ + return myGlobalSelMode; +} + +//======================================================================= +//function : setGlobalSelMode +//purpose : +//======================================================================= +inline void SelectMgr_SelectableObject::setGlobalSelMode (const Standard_Integer theMode) +{ + myGlobalSelMode = theMode > 0 ? theMode : 0; +} diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx index 41af9cd91b..05c54b22ca 100644 --- a/src/StdSelect/StdSelect_BRepOwner.cxx +++ b/src/StdSelect/StdSelect_BRepOwner.cxx @@ -128,6 +128,8 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag const Standard_Integer aMode) { Standard_Integer M = (aMode < 0) ? myCurMode : aMode; + Graphic3d_ZLayerId aHiLayer = this == Selectable()->GlobalSelOwner().Access() ? + Graphic3d_ZLayerId_Top : Graphic3d_ZLayerId_Topmost; Handle(SelectMgr_SelectableObject) aSel = Selectable(); if (myFromDecomposition) { @@ -169,17 +171,17 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag } // highlight with color and set layer - PM->Color (myPrsSh, aCol, M, aSel); + PM->Color (myPrsSh, aCol, M, aSel, aHiLayer); } else { if (!myPrsSh.IsNull()) { - PM->Color (myPrsSh, aCol, M, aSel); + PM->Color (myPrsSh, aCol, M, aSel, aHiLayer); } else { - PM->Color (aSel, aCol, M); + PM->Color (aSel, aCol, M, NULL, aHiLayer); } } } diff --git a/src/TPrsStd/TPrsStd_AISPresentation.cxx b/src/TPrsStd/TPrsStd_AISPresentation.cxx index 70c171c3db..9becd2c828 100644 --- a/src/TPrsStd/TPrsStd_AISPresentation.cxx +++ b/src/TPrsStd/TPrsStd_AISPresentation.cxx @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -570,17 +572,12 @@ void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelecti { // OCC2932 correction if(hasOwnSelectionMode && mySelectionMode == theSelectionMode && !myAIS.IsNull()) - if(myAIS->SelectionMode() == theSelectionMode ) return; Backup(); mySelectionMode = theSelectionMode; hasOwnSelectionMode = Standard_True; if( myAIS.IsNull() ) AISUpdate(); - if( !myAIS.IsNull() ) { - if( myAIS->SelectionMode() == theSelectionMode ) return; - myAIS->SetSelectionMode(theSelectionMode); - } } //======================================================================= @@ -590,15 +587,12 @@ void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelecti void TPrsStd_AISPresentation::UnsetSelectionMode() { if(!hasOwnSelectionMode && !myAIS.IsNull()) - if(!myAIS->HasSelectionMode()) return; Backup(); hasOwnSelectionMode = Standard_False; if( myAIS.IsNull() ) AISUpdate(); - if( !myAIS.IsNull() && myAIS->HasSelectionMode() ) { - myAIS->UnsetSelectionMode(); - } + mySelectionMode = myAIS->GlobalSelectionMode(); } //======================================================================= @@ -915,9 +909,25 @@ void TPrsStd_AISPresentation::AISUpdate () } - if (hasOwnSelectionMode) { - if (myAIS->SelectionMode() != mySelectionMode ) { - myAIS->SetSelectionMode(mySelectionMode); + if (hasOwnSelectionMode) { + const Handle(AIS_InteractiveContext) aContext = + ctx.IsNull() ? myAIS->GetContext() : ctx; + if (!aContext.IsNull()) + { + TColStd_ListOfInteger anActivatedModes; + aContext->ActivatedModes (myAIS, anActivatedModes); + Standard_Boolean isActivated = Standard_False; + for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next()) + { + if (aModeIter.Value() == mySelectionMode) + { + isActivated = Standard_True; + break; + } + } + + if (!isActivated) + aContext->Activate (myAIS, mySelectionMode, Standard_False); } } diff --git a/src/V3d/V3d_Viewer_4.cxx b/src/V3d/V3d_Viewer_4.cxx index d01d0f6cf0..63c199e8f3 100644 --- a/src/V3d/V3d_Viewer_4.cxx +++ b/src/V3d/V3d_Viewer_4.cxx @@ -85,7 +85,7 @@ void V3d_Viewer::DeactivateGrid() if (myGridEcho && !myGridEchoStructure.IsNull()) { - ActiveView()->View()->EraseImmediate (myGridEchoStructure); + myGridEchoStructure->Erase(); } } Update(); @@ -241,10 +241,7 @@ void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid) return; } - for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) - { - ActiveView()->View()->EraseImmediate (myGridEchoStructure); - } + myGridEchoStructure->Erase(); } // ======================================================================= @@ -308,7 +305,12 @@ void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView, anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z()); myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints); - theView->View()->DisplayImmediate (myGridEchoStructure, Standard_True); + myGridEchoStructure->SetZLayer (Graphic3d_ZLayerId_Topmost); + myGridEchoStructure->SetInfiniteState (Standard_True); + myGridEchoStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity(); + myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (Standard_False); + myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (theView->View()->Identification(), true); + myGridEchoStructure->Display(); } // ======================================================================= @@ -323,5 +325,7 @@ void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView) } myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast()); - theView->View()->EraseImmediate (myGridEchoStructure); + const Handle(Graphic3d_ViewAffinity)& anAffinity = myGridEchoStructure->CStructure()->ViewAffinity; + if (!anAffinity.IsNull() && anAffinity->IsVisible (theView->View()->Identification())) + myGridEchoStructure->Erase(); } diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index dc78b59bd2..1cdaeaf4e4 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -516,14 +516,14 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode ) if(!aContext->HasOpenedContext()) { // To unhilight the preselected object - aContext->UnhilightCurrents(Standard_False); + aContext->UnhilightSelected(Standard_False); // Open a local Context in order to be able to select subshape from // the selected shape if any or for all if there is no selection - if (!aContext->FirstCurrentObject().IsNull()){ + if (!aContext->FirstSelectedObject().IsNull()){ aContext->OpenLocalContext(Standard_False); - for(aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent()){ - aContext->Load( aContext->Current(),-1,Standard_True); + for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){ + aContext->Load( aContext->SelectedInteractive(),-1,Standard_True); } } else @@ -992,18 +992,13 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar //unset displaymode.. comportement particulier... if(TypeOfOperation==4){ if(argc==1){ - if(Ctx->NbCurrents()==0 || - Ctx->NbSelected()==0){ + if(Ctx->NbSelected()==0){ Handle(AIS_InteractiveObject) IO; VwrTst_DispErase(IO,-1,4,Standard_False); } - else if(!Ctx->HasOpenedContext()){ - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - VwrTst_DispErase(Ctx->Current(),-1,4,Standard_False); - } else{ for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - VwrTst_DispErase(Ctx->Interactive(),-1,4,Standard_False);} + VwrTst_DispErase(Ctx->SelectedInteractive(),-1,4,Standard_False);} Ctx->UpdateCurrentViewer(); } else{ @@ -1018,20 +1013,20 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar } else if(argc==2){ Standard_Integer Dmode = Draw::Atoi(argv[1]); - if(Ctx->NbCurrents()==0 && TypeOfOperation==3){ + if(Ctx->NbSelected()==0 && TypeOfOperation==3){ Handle(AIS_InteractiveObject) IO; VwrTst_DispErase(IO,Dmode,TypeOfOperation,Standard_True); } if(!Ctx->HasOpenedContext()){ // set/unset display mode sur le Contexte... - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){ - VwrTst_DispErase(Ctx->Current(),Dmode,TypeOfOperation,Standard_False); + for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){ + VwrTst_DispErase(Ctx->SelectedInteractive(),Dmode,TypeOfOperation,Standard_False); } Ctx->UpdateCurrentViewer(); } else{ for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - Ctx->Display(Ctx->Interactive(),Dmode); + Ctx->Display(Ctx->SelectedInteractive(),Dmode); } } else{ @@ -1056,30 +1051,22 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg Standard_Integer On = Draw::Atoi(argv[1]); const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext(); - if(argc==2){ - - if(!Ctx->HasOpenedContext()){ - di<<"sub intensite "; - if(On==1) di<<"On"; - else di<<"Off"; - di<<" pour "<NbCurrents()<<" objets"<<"\n"; - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){ - if(On==1){ - Ctx->SubIntensityOn(Ctx->Current(),Standard_False);} - else{ - di <<"passage dans off"<<"\n"; - Ctx->SubIntensityOff(Ctx->Current(),Standard_False); - } + if(argc==2) + { + TCollection_AsciiString isOnOff = On == 1 ? "on" : "off"; + di << "Sub intensite is turned " << isOnOff << " for " << Ctx->NbSelected() << "objects\n"; + for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected()) + { + if(On==1) + { + Ctx->SubIntensityOn (Ctx->SelectedInteractive(), Standard_False); } - } - else{ - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){ - if(On==1){ - Ctx->SubIntensityOn(Ctx->Interactive(),Standard_False);} - else{ - Ctx->SubIntensityOff(Ctx->Interactive(),Standard_False);} + else + { + Ctx->SubIntensityOff (Ctx->SelectedInteractive(), Standard_False); } } + Ctx->UpdateCurrentViewer(); } else { @@ -1134,11 +1121,11 @@ public: mySource = IterSource_List; mySeqIter = NCollection_Sequence::Iterator (mySeq); } - else if (aCtx->NbCurrents() > 0) + else if (aCtx->NbSelected() > 0) { mySource = IterSource_Selected; mySelIter = aCtx; - mySelIter->InitCurrent(); + mySelIter->InitSelected(); } else { @@ -1170,7 +1157,7 @@ public: { case IterSource_All: return myMapIter.More(); case IterSource_List: return mySeqIter.More(); - case IterSource_Selected: return mySelIter->MoreCurrent(); + case IterSource_Selected: return mySelIter->MoreSelected(); } return Standard_False; } @@ -1195,7 +1182,7 @@ public: } case IterSource_Selected: { - mySelIter->NextCurrent(); + mySelIter->NextSelected(); break; } } @@ -1235,10 +1222,10 @@ private: } case IterSource_Selected: { - if (mySelIter->MoreCurrent()) + if (mySelIter->MoreSelected()) { - myCurrentName = GetMapOfAIS().Find1 (mySelIter->Current()); - myCurrent = mySelIter->Current(); + myCurrentName = GetMapOfAIS().Find1 (mySelIter->SelectedInteractive()); + myCurrent = mySelIter->SelectedInteractive(); } break; } @@ -2237,14 +2224,14 @@ static int VDonly2 (Draw_Interpretor& , if (anArgIter >= theArgNb) { // display only selected objects - if (aCtx->NbCurrents() < 1) + if (aCtx->NbSelected() < 1) { return 0; } - for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent()) + for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) { - aDispSet.Add (aCtx->Current()); + aDispSet.Add (aCtx->SelectedInteractive()); } } else @@ -2579,7 +2566,7 @@ int VErase (Draw_Interpretor& theDI, } } } - else if (!toEraseAll && aCtx->NbCurrents() > 0) + else if (!toEraseAll && aCtx->NbSelected() > 0) { // Erase selected objects for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); @@ -2587,7 +2574,7 @@ int VErase (Draw_Interpretor& theDI, { const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); if (!anIO.IsNull() - && aCtx->IsCurrent (anIO)) + && aCtx->IsSelected (anIO)) { theDI << anIter.Key2().ToCString() << " "; if (toEraseInView) @@ -2861,12 +2848,12 @@ int VBounding (Draw_Interpretor& theDI, bndPresentation (theDI, aPrs, aName, anAction); } } - else if (aCtx->NbCurrents() > 0) + else if (aCtx->NbSelected() > 0) { // remove all currently selected objects - for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent()) + for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) { - Handle(AIS_InteractiveObject) anIO = aCtx->Current(); + Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive(); Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); if (!aPrs.IsNull()) { @@ -3498,7 +3485,7 @@ static int VDisplay2 (Draw_Interpretor& theDI, && aCtx->GetAutoActivateSelection() && aShape->GetTransformPersistenceMode() == 0)) { - aSelMode = aShape->HasSelectionMode() ? aShape->SelectionMode() : -1; + aSelMode = aShape->GlobalSelectionMode(); } aCtx->Display (aShape, aDispMode, aSelMode, @@ -3555,7 +3542,7 @@ static int VDisplay2 (Draw_Interpretor& theDI, && aCtx->GetAutoActivateSelection() && aShape->GetTransformPersistenceMode() == 0)) { - aSelMode = aShape->HasSelectionMode() ? aShape->SelectionMode() : -1; + aSelMode = aShape->GlobalSelectionMode(); } if (aShape->Type() == AIS_KOI_Datum) @@ -3963,11 +3950,11 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch // on load tous les objets displayees et on Activate les objets de la liste AIS_ListOfInteractive ListOfIO; // on sauve dans une AISListOfInteractive tous les objets currents - if (TheAISContext()->NbCurrents()>0 ){ - TheAISContext()->UnhilightCurrents(Standard_False); + if (TheAISContext()->NbSelected()>0 ){ + TheAISContext()->UnhilightSelected(Standard_False); - for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){ - ListOfIO.Append(TheAISContext()->Current() ); + for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){ + ListOfIO.Append(TheAISContext()->SelectedInteractive() ); } } @@ -4015,7 +4002,7 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch TheAISContext()->UnhilightSelected(Standard_False); // il y a des objets selected,on les parcourt for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){ - Handle(AIS_InteractiveObject) aIO=TheAISContext()->Interactive(); + Handle(AIS_InteractiveObject) aIO=TheAISContext()->SelectedInteractive(); if (HaveMode(aIO,aMode) ) { @@ -4346,12 +4333,12 @@ static Standard_Integer VState (Draw_Interpretor& theDI, return 0; } - if (aCtx->NbCurrents() > 0 + if (aCtx->NbSelected() > 0 && !toShowAll) { - for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent()) + for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) { - Handle(AIS_InteractiveObject) anObj = aCtx->Current(); + Handle(AIS_InteractiveObject) anObj = aCtx->SelectedInteractive(); TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj); aName.LeftJustify (20, ' '); theDI << aName << " "; @@ -5012,7 +4999,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/, } aCtx->Load (aShape, -1, Standard_False); - aCtx->Activate (aShape, aShape->SelectionMode(), Standard_True); + aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True); } } diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index d482be6afe..de5b7f32d6 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -318,7 +318,7 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv TheAISContext()->CloseLocalContext(); // On set le booleen ThereIsCurrent - if (TheAISContext() -> NbCurrents() > 0) {ThereIsCurrent=Standard_True;} + if (TheAISContext() -> NbSelected() > 0) {ThereIsCurrent=Standard_True;} else {ThereIsCurrent=Standard_False;} @@ -337,7 +337,7 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv Handle(AIS_InteractiveObject) aShape= Handle(AIS_InteractiveObject)::DownCast(it.Key1()); - if (!aShape.IsNull() && TheAISContext()->IsCurrent(aShape) ) + if (!aShape.IsNull() && TheAISContext()->IsSelected(aShape) ) { // On verifie que l'AIS InteraciveObject selectionne est bien @@ -493,7 +493,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c Handle(AIS_InteractiveObject) theIOB; for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) { - theIOB = TheAISContext()->Interactive(); + theIOB = TheAISContext()->SelectedInteractive(); } // on le downcast Handle(AIS_Plane) PlaneB =((*(Handle(AIS_Plane)*)&theIOB)); @@ -4212,16 +4212,21 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, } // Check the arguments - if (theArgc != 3 && theArgc != 4) + if (theArgc < 3 && theArgc > 5) { std::cerr << "vselmode error : expects at least 2 arguments.\n" << "Type help "<< theArgv[0] <<" for more information." << std::endl; return 1; } + TCollection_AsciiString aLastArg (theArgv[theArgc - 1]); + aLastArg.LowerCase(); + Standard_Boolean isToOpenLocalCtx = aLastArg == "-local"; + // get objects to change selection mode AIS_ListOfInteractive aTargetIOs; - if (theArgc == 3) + Standard_Integer anArgNb = isToOpenLocalCtx ? theArgc - 1 : theArgc; + if (anArgNb == 3) { anAISContext->DisplayedObjects (aTargetIOs); } @@ -4241,8 +4246,8 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, } } - const Standard_Integer aSelectionMode = Draw::Atoi (theArgc == 3 ? theArgv[1] : theArgv[2]); - const Standard_Boolean toTurnOn = Draw::Atoi (theArgc == 3 ? theArgv[2] : theArgv[3]); + const Standard_Integer aSelectionMode = Draw::Atoi (anArgNb == 3 ? theArgv[1] : theArgv[2]); + const Standard_Boolean toTurnOn = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]); if (aSelectionMode == 0 && anAISContext->HasOpenedContext()) { anAISContext->CloseLocalContext(); @@ -4255,6 +4260,12 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next()) { const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value(); + TColStd_ListOfInteger anActiveModes; + anAISContext->ActivatedModes (anIO, anActiveModes); + if (!anActiveModes.IsEmpty()) + { + anAISContext->Deactivate (anIO); + } if (!InList (anAISContext, anIO, aSelectionMode)) { anAISContext->Activate (anIO); @@ -4276,7 +4287,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, if (aSelectionMode != 0 && toTurnOn) // Turn on specified mode { - if (!anAISContext->HasOpenedContext()) + if (!anAISContext->HasOpenedContext() && isToOpenLocalCtx) { anAISContext->OpenLocalContext (Standard_False); } @@ -4284,6 +4295,10 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next()) { const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value(); + if (InList (anAISContext, anIO, 0)) + { + anAISContext->Deactivate (anIO, 0); + } if (!InList (anAISContext, anIO, aSelectionMode)) { anAISContext->Load (anIO, -1, Standard_True); @@ -4294,11 +4309,6 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/, if (aSelectionMode != 0 && !toTurnOn) // Turn off specified mode { - if (!anAISContext->HasOpenedContext()) - { - return 0; - } - for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next()) { const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value(); diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index d32cf23d83..97ee615de0 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -683,6 +683,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft // NIS setup Handle(NIS_View) aView = new NIS_View (a3DViewer, VT_GetWindow()); + ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer); ViewerTest::CurrentView(aView); ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView); @@ -1372,7 +1373,7 @@ void VT_ProcessKeyPress (const char* buf_ret) aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_PolyAlgo); else aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_Algo); - if (aContext->NbCurrents()==0 || aContext->NbSelected() == 0) + if (aContext->NbSelected()==0) { AIS_ListOfInteractive aListOfShapes; aContext->DisplayedObjects(aListOfShapes); @@ -1391,9 +1392,9 @@ void VT_ProcessKeyPress (const char* buf_ret) } else { - for (aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent()) + for (aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()) { - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->Current()); + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->SelectedInteractive()); if (aShape.IsNull()) continue; if(aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo) @@ -1412,18 +1413,11 @@ void VT_ProcessKeyPress (const char* buf_ret) std::cout << "setup Shaded display mode" << std::endl; Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); - if(Ctx->NbCurrents()==0 || - Ctx->NbSelected()==0) + if(Ctx->NbSelected()==0) Ctx->SetDisplayMode(AIS_Shaded); else{ - if(Ctx->HasOpenedContext()){ - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - Ctx->SetDisplayMode(Ctx->Interactive(),1,Standard_False); - } - else{ - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - Ctx->SetDisplayMode(Ctx->Current(),1,Standard_False); - } + for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) + Ctx->SetDisplayMode(Ctx->SelectedInteractive(),1,Standard_False); Ctx->UpdateCurrentViewer(); } } @@ -1433,18 +1427,11 @@ void VT_ProcessKeyPress (const char* buf_ret) std::cout << "reset display mode to defaults" << std::endl; Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); - if(Ctx->NbCurrents()==0 || - Ctx->NbSelected()==0) + if(Ctx->NbSelected()==0) Ctx->SetDisplayMode(AIS_WireFrame); else{ - if(Ctx->HasOpenedContext()){ - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - Ctx->UnsetDisplayMode(Ctx->Interactive(),Standard_False); - } - else{ - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - Ctx->UnsetDisplayMode(Ctx->Current(),Standard_False); - } + for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) + Ctx->UnsetDisplayMode(Ctx->SelectedInteractive(),Standard_False); Ctx->UpdateCurrentViewer(); } @@ -1473,18 +1460,11 @@ void VT_ProcessKeyPress (const char* buf_ret) { std::cout << "setup WireFrame display mode" << std::endl; Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); - if(Ctx->NbCurrents()==0 || - Ctx->NbSelected()==0) + if(Ctx->NbSelected()==0) Ctx->SetDisplayMode(AIS_WireFrame); else{ - if(Ctx->HasOpenedContext()){ - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - Ctx->SetDisplayMode(Ctx->Interactive(),0,Standard_False); - } - else{ - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - Ctx->SetDisplayMode(Ctx->Current(),0,Standard_False); - } + for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) + Ctx->SetDisplayMode(Ctx->SelectedInteractive(),0,Standard_False); Ctx->UpdateCurrentViewer(); } } @@ -1518,7 +1498,6 @@ void VT_ProcessKeyPress (const char* buf_ret) { Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); if (!aCtx.IsNull() - && aCtx->NbCurrents() > 0 && aCtx->NbSelected() > 0) { Draw_Interprete ("verase"); @@ -3260,11 +3239,11 @@ static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** arg { if (aFileName.Value (aLen - 2) == '.') { - aFormatStr = aFileName.SubString (aLen - 1, aLen); + aFormatStr = aFileName.ToCString() + aLen - 2; } else if (aFileName.Value (aLen - 3) == '.') { - aFormatStr = aFileName.SubString (aLen - 2, aLen); + aFormatStr = aFileName.ToCString() + aLen - 3; } else { @@ -6075,14 +6054,7 @@ static Standard_Integer VChangeSelected (Draw_Interpretor& di, return 1; } - if(aContext->HasOpenedContext()) - { - aContext->AddOrRemoveSelected(anAISObject); - } - else - { - aContext->AddOrRemoveCurrentObject(anAISObject); - } + aContext->AddOrRemoveSelected(anAISObject); } return 0; } diff --git a/src/Visual3d/Visual3d_View.cdl b/src/Visual3d/Visual3d_View.cdl index 72adce2d76..4b819dd350 100644 --- a/src/Visual3d/Visual3d_View.cdl +++ b/src/Visual3d/Visual3d_View.cdl @@ -680,6 +680,14 @@ is ---Level: Advanced ---Purpose: Returns the view manager handle which manage this view + IsComputed (me; + theStructId : Integer from Standard; + theComputedStruct : out Structure from Graphic3d) + returns Boolean from Standard + is static; + ---Purpose: Returns Standard_True in case if the structure with the given is + -- in list of structures to be computed and stores computed struct to . + ---------------------------- -- Category: Private methods ---------------------------- @@ -782,30 +790,6 @@ is ---Purpose: Display the structure to the view . ---Category: Private methods - DisplayImmediate ( me : mutable; - theStructure : Structure from Graphic3d; - theIsSingleView : Boolean from Standard = Standard_True) - returns Boolean from Standard - is static; - ---Level: Internal - ---Purpose: Add structure to the list of immediate presentations. - -- @return true if structure has not been registered in this view - - EraseImmediate ( me : mutable; - theStructure : Structure from Graphic3d ) - returns Boolean from Standard - is static; - ---Level: Internal - ---Purpose: Removes the structure from the list of immediate presentations. - -- @return true if structure has been registered in view - - ClearImmediate ( me : mutable ) - returns Boolean from Standard - is static; - ---Level: Internal - ---Purpose: Clears list of immediate presentations. - -- @return true if list was not empty - Erase ( me : mutable; AStructure : Structure from Graphic3d ) is static private; @@ -1125,7 +1109,6 @@ fields -- the displayed structures in the view myStructsDisplayed : MapOfStructure from Graphic3d; - myImmediateStructures : MapOfStructure from Graphic3d; myGTrihedron : GraduatedTrihedron from Graphic3d; diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index 049436ba04..4ab343a791 100644 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -973,7 +973,6 @@ void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer, if (myGraphicDriver->IsDeviceLost()) { myViewManager->RecomputeStructures(); - myViewManager->RecomputeStructures (myImmediateStructures); myGraphicDriver->ResetDeviceLostFlag(); } @@ -1256,69 +1255,6 @@ void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& theMother, } } -// ======================================================================== -// function : DisplayImmediate -// purpose : -// ======================================================================== -Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure, - const Standard_Boolean theIsSingleView) -{ - if (!myImmediateStructures.Add (theStructure)) - { - return Standard_False; - } - - if (theIsSingleView) - { - const Visual3d_SequenceOfView& aViews = myViewManager->DefinedViews(); - for (Standard_Integer aViewIter = 1; aViewIter <= aViews.Length(); ++aViewIter) - { - const Handle(Visual3d_View)& aView = aViews.Value (aViewIter); - if (aView.Access() != this) - { - aView->EraseImmediate (theStructure); - } - } - } - - myGraphicDriver->DisplayImmediateStructure (MyCView, theStructure); - return Standard_True; -} - -// ======================================================================== -// function : EraseImmediate -// purpose : -// ======================================================================== -Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure) -{ - const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure); - if (isErased) - { - myGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure()); - } - - return isErased; -} - -// ======================================================================== -// function : ClearImmediate -// purpose : -// ======================================================================== -Standard_Boolean Visual3d_View::ClearImmediate() -{ - if (myImmediateStructures.IsEmpty()) - { - return Standard_False; - } - - for (Graphic3d_MapOfStructure::Iterator aStructIter (myImmediateStructures); aStructIter.More(); aStructIter.Next()) - { - myGraphicDriver->EraseImmediateStructure (MyCView, *aStructIter.Key()->CStructure()); - } - myImmediateStructures.Clear(); - return Standard_True; -} - // ======================================================================== // function : Display // purpose : @@ -1534,7 +1470,6 @@ void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct, const Aspect_TypeOfUpdate theUpdateMode) { if ( IsDeleted() - || EraseImmediate (theStruct) || !IsDisplayed (theStruct)) { return; @@ -1574,11 +1509,34 @@ void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& theStruct, const Standard_Integer anIndex = IsComputed (theStruct); if (anIndex != 0) { - const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex); + const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex); aCompStruct->Highlight (theMethod, theStruct->HighlightColor(), Standard_False); } } +// ======================================================================== +// function : IsComputed +// purpose : +// ======================================================================== +Standard_Boolean Visual3d_View::IsComputed (const Standard_Integer theStructId, + Handle(Graphic3d_Structure)& theComputedStruct) const +{ + theComputedStruct.Nullify(); + if (!ComputedMode()) + return Standard_False; + + const Standard_Integer aNbStructs = myStructsToCompute.Length(); + for (Standard_Integer aStructIter = 1; aStructIter <= aNbStructs; ++aStructIter) + { + if (myStructsToCompute.Value (aStructIter)->Identification() == theStructId) + { + theComputedStruct = myStructsComputed (aStructIter); + return Standard_True; + } + } + return Standard_False; +} + // ======================================================================== // function : SetTransform // purpose : @@ -1745,8 +1703,6 @@ inline void addStructureBndBox (const Handle(Graphic3d_Structure)& theStruct, Bnd_Box Visual3d_View::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const { Bnd_Box aResult = MinMaxValues (myStructsDisplayed, theToIgnoreInfiniteFlag); - Bnd_Box anImmediate = MinMaxValues (myImmediateStructures, theToIgnoreInfiniteFlag); - aResult.Add (anImmediate); return aResult; } diff --git a/tests/bugs/vis/bug1629 b/tests/bugs/vis/bug1629 index 34e85fd695..95520b7df8 100755 --- a/tests/bugs/vis/bug1629 +++ b/tests/bugs/vis/bug1629 @@ -1,5 +1,3 @@ -puts "TODO OCC11111 ALL: Error : Colors are not equal in default coordinate and in the near coordinates too" - puts "================" puts "OCC1629" puts "OCC2707" @@ -37,7 +35,7 @@ set Selection_G 0.8 set Selection_B 0.8 #QASetChoiceMode EDGE ON -vselmode 2 1 +vselmode 2 1 -local set BeforeNbSelected [vnbselected] @@ -84,11 +82,11 @@ puts "" set CloseNbSelected [vnbselected] -checkcolor ${x1} ${y1} ${Selection_R} ${Selection_G} ${Selection_B} -checkcolor ${x2} ${y2} ${Selection_R} ${Selection_G} ${Selection_B} -checkcolor ${x3} ${y3} ${Selection_R} ${Selection_G} ${Selection_B} -checkcolor ${x4} ${y4} ${Selection_R} ${Selection_G} ${Selection_B} -checkcolor ${x5} ${y5} ${Selection_R} ${Selection_G} ${Selection_B} +checkcolor ${x1} ${y1} 1 1 0 +checkcolor ${x2} ${y2} 1 1 0 +checkcolor ${x3} ${y3} 1 1 0 +checkcolor ${x4} ${y4} 1 1 0 +checkcolor ${x5} ${y5} 1 1 0 if {${CloseNbSelected} == 0} { puts "OCC1629: OK (case 13: after close local context)" diff --git a/tests/bugs/vis/bug24966 b/tests/bugs/vis/bug24966 index ead507db0d..786db06438 100644 --- a/tests/bugs/vis/bug24966 +++ b/tests/bugs/vis/bug24966 @@ -18,8 +18,8 @@ vertex p2 150 300 0 edge e1 p1 p2 vdisplay e1 -vselmode e1 2 1 -vselmode e1 1 1 +vselmode e1 2 1 -local +vselmode e1 1 1 -local vselect 0 0 2500 2500 verase -local diff --git a/tests/bugs/vis/bug25528 b/tests/bugs/vis/bug25528 index d02560bb71..e27e07f820 100644 --- a/tests/bugs/vis/bug25528 +++ b/tests/bugs/vis/bug25528 @@ -15,7 +15,7 @@ vdisplay b vfit # opening a local context for local selection -vselmode b 4 1 +vselmode b 4 1 -local # Select a face just to simulate the scenario used in a real application vselect 200 200 # This line should not lead to exception