From 0717ddc13291e099f92171b66858fb6718bb2ca8 Mon Sep 17 00:00:00 2001 From: duv Date: Thu, 28 Aug 2014 16:38:28 +0400 Subject: [PATCH] 0024837: Visualization - revise design and implementation of connected Interactive Objects 0023422: Selection problems when using SetLocation. 0024756: AIS_ConnectedInteractive does not support nested AIS_ConnectedInteractive 0025103: Visualization - Regression in interactive detection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Each PrsMgr_PresentableObject has list of PrsMgr _PresentableObject called myChildren. Transformation PrsMgr_PresentableObject applied to its children every time when its own transformation affected. This hierarchy does not propagate to Graphic3d level and below. PrsMgr_PresentableObject send its combined (according to hierarchy) transform down to Graphic3d_Structure. AIS_ConnectedInteractive and AIS_MultiplyConnectedInteractive are reused but behavior has been changed. AIS_ConnectedInteractive now is an instance of object. It reuses geometry of connected object but have own transformation, material, visibility flag etc. This connection propagated down to OpenGl level to OpenGl_Structure. For this task old “connected” mechanism has been reused. AIS_MultiplyConnectedInteractive represents assembly which doesn’t have its own presentation. Assemblies are able to participate is scene hierarchy and intended to handle a grouped set of instanced objects. It behaves as single object in terms of selection. It applies high level transform to all sub-elements since it located above in the hierarchy. All AIS_MultiplyConnectedInteractive are able to have child assemblies. Deep copy of object instances performed when one assembly attached to another. Correction test cases for CR24837 Test cases for issue CR23422 Test cases for issue CR24756 Test cases for issue CR25103 Viewer3d sample fixed. --- .../04_Viewer3d/src/ModelClippingDlg.cpp | 4 +- src/AIS/AIS.cdl | 3 - src/AIS/AIS_ConnectedInteractive.cdl | 85 +-- src/AIS/AIS_ConnectedInteractive.cxx | 340 ++++++++--- src/AIS/AIS_ConnectedShape.cdl | 139 ----- src/AIS/AIS_ConnectedShape.cxx | 335 ----------- src/AIS/AIS_InteractiveContext.cdl | 1 - src/AIS/AIS_InteractiveContext.cxx | 26 +- src/AIS/AIS_InteractiveContext_1.cxx | 18 +- src/AIS/AIS_InteractiveObject.cdl | 32 -- src/AIS/AIS_InteractiveObject.cxx | 76 +-- src/AIS/AIS_LocalContext.cdl | 1 - src/AIS/AIS_LocalContext_1.cxx | 5 +- src/AIS/AIS_MultipleConnectedInteractive.cdl | 47 +- src/AIS/AIS_MultipleConnectedInteractive.cxx | 358 +++++++++--- src/AIS/AIS_MultipleConnectedInteractive.lxx | 11 - src/AIS/AIS_MultipleConnectedShape.cdl | 107 ---- src/AIS/AIS_MultipleConnectedShape.cxx | 231 -------- src/AIS/AIS_Shape.cxx | 4 +- src/AIS/AIS_Trihedron.cdl | 5 +- src/AIS/AIS_Trihedron.cxx | 6 +- src/Graphic3d/Graphic3d_Structure.cdl | 7 + src/Graphic3d/Graphic3d_Structure.cxx | 51 +- src/OpenGl/OpenGl_Structure.cxx | 16 +- src/OpenGl/OpenGl_Structure.hxx | 8 +- src/OpenGl/OpenGl_Workspace.hxx | 8 +- src/OpenGl/OpenGl_Workspace_Raytrace.cxx | 84 ++- src/PrsMgr/FILES | 1 + src/PrsMgr/PrsMgr.cdl | 1 + .../PrsMgr_ListOfPresentableObjects.hxx} | 25 +- src/PrsMgr/PrsMgr_PresentableObject.cdl | 93 ++- src/PrsMgr/PrsMgr_PresentableObject.cxx | 124 ++-- src/PrsMgr/PrsMgr_PresentableObject.lxx | 26 +- src/PrsMgr/PrsMgr_PresentationManager.cdl | 30 - src/PrsMgr/PrsMgr_PresentationManager.cxx | 182 ++++-- src/QABugs/QABugs_11.cxx | 2 +- src/Select3D/Select3D_SensitiveEntity.cdl | 2 +- src/Select3D/Select3D_SensitiveEntity.cxx | 4 +- src/SelectBasics/SelectBasics_EntityOwner.cdl | 1 - src/SelectMgr/SelectMgr_EntityOwner.cdl | 11 +- src/SelectMgr/SelectMgr_EntityOwner.cxx | 17 +- src/SelectMgr/SelectMgr_SelectableObject.cdl | 8 +- src/SelectMgr/SelectMgr_SelectableObject.cxx | 29 +- src/SelectMgr/SelectMgr_SelectionManager.cxx | 35 +- src/TPrsStd/TPrsStd_AxisDriver.cxx | 2 +- src/TPrsStd/TPrsStd_ConstraintDriver.cxx | 2 +- src/TPrsStd/TPrsStd_GeometryDriver.cxx | 8 +- src/TPrsStd/TPrsStd_NamedShapeDriver.cxx | 2 +- src/TPrsStd/TPrsStd_PlaneDriver.cxx | 2 +- src/TPrsStd/TPrsStd_PointDriver.cxx | 2 +- src/ViewerTest/ViewerTest.cxx | 8 +- src/ViewerTest/ViewerTest_ObjectCommands.cxx | 540 ++++++++++-------- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 52 ++ tests/bugs/vis/bug12121 | 12 +- tests/bugs/vis/bug23422 | 20 + tests/bugs/vis/bug24358 | 2 +- tests/bugs/vis/bug24756 | 18 + tests/bugs/vis/bug24837_1 | 41 ++ tests/bugs/vis/bug24837_2 | 38 ++ tests/bugs/vis/bug25103 | 48 ++ tests/v3d/raytrace/connected | 6 +- 61 files changed, 1702 insertions(+), 1700 deletions(-) delete mode 100644 src/AIS/AIS_ConnectedShape.cdl delete mode 100644 src/AIS/AIS_ConnectedShape.cxx delete mode 100644 src/AIS/AIS_MultipleConnectedShape.cdl delete mode 100644 src/AIS/AIS_MultipleConnectedShape.cxx mode change 100755 => 100644 src/OpenGl/OpenGl_Workspace_Raytrace.cxx rename src/{AIS/AIS_MultipleConnectedShape.lxx => PrsMgr/PrsMgr_ListOfPresentableObjects.hxx} (53%) create mode 100644 tests/bugs/vis/bug23422 create mode 100644 tests/bugs/vis/bug24756 create mode 100644 tests/bugs/vis/bug24837_1 create mode 100644 tests/bugs/vis/bug24837_2 create mode 100644 tests/bugs/vis/bug25103 diff --git a/samples/mfc/standard/04_Viewer3d/src/ModelClippingDlg.cpp b/samples/mfc/standard/04_Viewer3d/src/ModelClippingDlg.cpp index 9023600534..86fd233f07 100755 --- a/samples/mfc/standard/04_Viewer3d/src/ModelClippingDlg.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/ModelClippingDlg.cpp @@ -86,7 +86,7 @@ void CModelClippingDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBa } else { - myShape->SetLocation (TopLoc_Location (myTrsf)); + myShape->SetLocalTransformation (myTrsf); } TCollection_AsciiString aMessage ( @@ -174,7 +174,7 @@ void CModelClippingDlg::OnChangeEditModelclippingZ() } else { - myShape->SetLocation (TopLoc_Location (myTrsf)); + myShape->SetLocalTransformation (myTrsf); } myModelClipping_Z = m_ModelClipping_Z; diff --git a/src/AIS/AIS.cdl b/src/AIS/AIS.cdl index 1340559f41..3abdfc8c15 100644 --- a/src/AIS/AIS.cdl +++ b/src/AIS/AIS.cdl @@ -360,9 +360,6 @@ is ---Category: Object of type Shape class Shape; --signature 0 - class ConnectedShape; --signature 1 - class MultipleConnectedShape; --signature 2 - ---Category: General Objects diff --git a/src/AIS/AIS_ConnectedInteractive.cdl b/src/AIS/AIS_ConnectedInteractive.cdl index 595878d7f1..e4b8a41d93 100644 --- a/src/AIS/AIS_ConnectedInteractive.cdl +++ b/src/AIS/AIS_ConnectedInteractive.cdl @@ -16,38 +16,30 @@ class ConnectedInteractive from AIS inherits InteractiveObject from AIS - ---Purpose: Defines an Interactive Object through a connection to - -- another Interactive Object, which serves as a - -- reference, and which is located elsewhere in the viewer. + ---Purpose: Creates an arbitrary located instance of another Interactive Object, + -- which serves as a reference. -- This allows you to use the Connected Interactive -- Object without having to recalculate presentation, -- selection or graphic structure. These are deduced -- from your reference object. -- The relation between the connected interactive object -- and its source is generally one of geometric transformation. - -- AIS_ConnectedInteractive class doesn't support selection - -- modes different from 0. Descendants should redefine ComputeSelection() - -- method in order to handle other selection modes and generate connected - -- sensitive entities properly. Refer to AIS_ConnectedShape class - -- for exisiting implementation of a connected interactive object - -- for AIS_Shape that supports all standard sub-shape selection modes. - -- Warning - -- An Interactive entity which is view (or projector) - -- dependent requires recalculation of views in hidden - -- parts mode depending on the position of the - -- projector in each view. You should derive the entity's - -- inheritance from ConnectedInteractive and redefine - -- its compute method to enable this type of calculation. + -- AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and + -- all standard modes if its reference based on AIS_Shape. + -- Descendants may redefine ComputeSelection() though. + -- Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape. uses Location from TopLoc, + Shape from TopoDS, Transformation from Geom, PresentationManager3d from PrsMgr, Presentation from Prs3d, TypeOfPresentation3d from PrsMgr, Selection from SelectMgr, Projector from Prs3d, - KindOfInteractive from AIS + KindOfInteractive from AIS, + Trsf from gp raises NotImplemented from Standard @@ -73,16 +65,15 @@ is Connect(me : mutable; anotherIObj : InteractiveObject from AIS) is virtual; ---Purpose: Establishes the connection between the Connected - -- Interactive Object, anotherIobj, and its reference - -- entity. If a previous connection with an Interactive - -- Object already exists, it is removed by Disconnect. - -- The second syntax also initiates the location of the - -- Connected Interactive Object. + -- Interactive Object, anotherIobj, and its reference. + Connect(me:mutable; anotherIobj: InteractiveObject from AIS; - aLocation : Location from TopLoc) is virtual; - ---Purpose: + aLocation : Trsf from gp) is virtual; + ---Purpose: Establishes the connection between the Connected + -- Interactive Object, anotherIobj, and its reference. + -- Locates instance in aLocation. HasConnection(me) returns Boolean from Standard; @@ -123,7 +114,7 @@ is aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; aPresentation : Presentation from Prs3d) - is redefined; + is redefined virtual private; ---Purpose: Computes the presentation according to a point of view -- given by . -- To be Used when the associated degenerated Presentations @@ -136,34 +127,46 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: Presentation from Prs3d) - is redefined; + is redefined virtual private; + ---Purpose: Computes the presentation according to a point of view + -- given by . - ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; - aMode : Integer) is redefined virtual private; + ComputeSelection(me:mutable; theSelection : Selection from SelectMgr; + theMode : Integer) is redefined virtual private; ---Level: Public ---Purpose: Generates sensitive entities by copying -- them from myReference selection, creates and sets an entity - -- owner for this entities and adds them to aSelection + -- owner for this entities and adds them to theSelection + + computeSubShapeSelection (me:mutable; theSelection : Selection from SelectMgr; + theMode : Integer) is private; + ---Level: Public + ---Purpose: Generates sensitive entities by copying + -- them from myReference sub shapes selection, creates and sets an entity + -- owner for this entities and adds them to theSelection AcceptShapeDecomposition(me) returns Boolean from Standard is redefined virtual; - ---C++: inline - - - UpdateLocation(me:mutable) is redefined virtual; + ---C++: inline + ---Purpose: Informs the graphic context that the interactive Object + -- may be decomposed into sub-shapes for dynamic selection. - UpdateLocation(me:mutable;aSel:Selection from SelectMgr) is redefined virtual; - ---Purpose: For this class, the location effect is treated in the - -- compute & computeSelection methods. So the - -- UpdateLocation Methods are redefined to do nothing else --- UpdateLocation(me:mutable;P : Presentation from Prs3d) is redefined virtual; + updateShape(me:mutable;WithLocation:Boolean from Standard = Standard_True) + is static private; + + Compute(me:mutable; + aProjector : Projector from Prs3d; + aPresentation: Presentation from Prs3d; + aShape : Shape from TopoDS) + is private; + ---Purpose: Computes the presentation according to a point of view + -- given by . fields - myReference : InteractiveObject from AIS is protected; - ---Purpose: To have the time to Disconnect below, the old is kept for a while. - myOldReference : InteractiveObject from AIS is protected; + myReference : InteractiveObject from AIS is protected; -- reference object + myShape : Shape from TopoDS; -- used for HLR end ConnectedInteractive; diff --git a/src/AIS/AIS_ConnectedInteractive.cxx b/src/AIS/AIS_ConnectedInteractive.cxx index a6a81ae4a5..31e3c51f62 100644 --- a/src/AIS/AIS_ConnectedInteractive.cxx +++ b/src/AIS/AIS_ConnectedInteractive.cxx @@ -23,7 +23,25 @@ #include #include -#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include //======================================================================= @@ -32,7 +50,7 @@ //======================================================================= AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): AIS_InteractiveObject(aTypeOfPresentation3d) -{ +{ SetHilightMode(0); } @@ -41,44 +59,52 @@ AIS_InteractiveObject(aTypeOfPresentation3d) //purpose : //======================================================================= AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const -{return AIS_KOI_Object;} +{ + return AIS_KOI_Object; +} Standard_Integer AIS_ConnectedInteractive::Signature() const -{return 0; } - - +{ + return 0; +} //======================================================================= //function : Connect //purpose : //======================================================================= -void AIS_ConnectedInteractive:: -Connect(const Handle(AIS_InteractiveObject)& anotherIObj) +void AIS_ConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { - // To have the time to Disconnect below, - // the old is kept for a while. - if(myReference==anotherIObj) return; - myOldReference = myReference; -//Disconnect(); - myReference = anotherIObj ; + if (myReference == theAnotherObj) return; + + Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj); + if (!aConnected.IsNull()) + { + myReference = aConnected->myReference; + } + else if (theAnotherObj->HasOwnPresentations()) + { + myReference = theAnotherObj; + } + + if (!myReference.IsNull()) + { + myTypeOfPresentation3d = myReference->TypeOfPresentation3d(); + } + + theAnotherObj->AddChild (this); } //======================================================================= //function : Connect //purpose : //======================================================================= -void AIS_ConnectedInteractive:: -Connect(const Handle(AIS_InteractiveObject)& anotherIobj, - const TopLoc_Location& aLocation) +void AIS_ConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, + const gp_Trsf& theLocation) { - if(myLocation!=aLocation) - myLocation = aLocation; - if(myReference!=anotherIobj) { - myOldReference = myReference; // necessary to disconnect below.. -// Disconnect(); - myReference = anotherIobj;} - + Connect (theAnotherObj); + + SetLocalTransformation (theLocation); } @@ -106,11 +132,6 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3 const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) { - if (!(HasLocation() || HasConnection())) - { - return; - } - if (HasConnection()) { thePrs->Clear (Standard_False); @@ -127,77 +148,246 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3 } } - if (HasLocation()) + if (!thePrs.IsNull()) { - Handle(Geom_Transformation) aPrsTrans = new Geom_Transformation (myLocation.Transformation()); - thePrsMgr->Transform (this, aPrsTrans, theMode); + thePrs->ReCompute(); } - thePrs->ReCompute(); } -void AIS_ConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation) +//======================================================================= +//function : Compute +//purpose : +//======================================================================= +void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjector, + const Handle(Geom_Transformation)& theTransformation, + const Handle(Prs3d_Presentation)& thePresentation) { -// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; + updateShape (Standard_False); + if (myShape.IsNull()) + { + return; + } + const TopLoc_Location& aLocation = myShape.Location(); + TopoDS_Shape aShape = myShape.Located (TopLoc_Location (theTransformation->Trsf()) * aLocation); + Compute (theProjector, thePresentation, aShape); } +//======================================================================= +//function : Compute +//purpose : +//======================================================================= void AIS_ConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) { -// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; + updateShape (Standard_True); + Compute (aProjector, aPresentation, myShape); } //======================================================================= -//function : ComputeSelection -//purpose : +//function : Compute +//purpose : //======================================================================= - -void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, - const Standard_Integer aMode) +void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjector, + const Handle(Prs3d_Presentation)& thePresentation, + const TopoDS_Shape& theShape) { - if(!(HasLocation() ||HasConnection())) return; - - aSel->Clear(); - if(!myReference->HasSelection(aMode)) - myReference->UpdateSelection(aMode); + if (myShape.IsNull()) + { + return; + } - const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode); - Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this); - Handle(Select3D_SensitiveEntity) SE3D, SNew; - - if(TheRefSel->IsEmpty()) - myReference->UpdateSelection(aMode); - for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()) + switch (theShape.ShapeType()) { - SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive()); - if(!SE3D.IsNull()) + case TopAbs_VERTEX: + case TopAbs_EDGE: + case TopAbs_WIRE: { - // Get the copy of SE3D - SNew = SE3D->GetConnected(myLocation); - if(aMode==0) + thePresentation->SetDisplayPriority (4); + StdPrs_WFDeflectionShape::Add (thePresentation, theShape, myDrawer); + break; + } + default: + { + Handle(Prs3d_Drawer) aDefaultDrawer = GetContext()->DefaultDrawer(); + if (aDefaultDrawer->DrawHiddenLine()) + { + myDrawer->EnableDrawHiddenLine(); + } + else + { + myDrawer->DisableDrawHiddenLine(); + } + + Aspect_TypeOfDeflection aPrevDeflection = aDefaultDrawer->TypeOfDeflection(); + aDefaultDrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); + + // process HLRAngle and HLRDeviationCoefficient() + Standard_Real aPrevAngle = myDrawer->HLRAngle(); + Standard_Real aNewAngle = aDefaultDrawer->HLRAngle(); + if (Abs (aNewAngle - aPrevAngle) > Precision::Angular()) { - SNew->Set(OWN); - // In case if SE3D caches some location-dependent data - // that must be updated after setting OWN - SNew->SetLocation(myLocation); + BRepTools::Clean (theShape); } - aSel->Add(SNew); + + myDrawer->SetHLRAngle (aNewAngle); + myDrawer->SetHLRDeviationCoefficient (aDefaultDrawer->HLRDeviationCoefficient()); + StdPrs_HLRPolyShape::Add (thePresentation, theShape, myDrawer, theProjector); + aDefaultDrawer->SetTypeOfDeflection (aPrevDeflection); } } } -void AIS_ConnectedInteractive::UpdateLocation() +//======================================================================= +//function : updateShape +//purpose : +//======================================================================= +void AIS_ConnectedInteractive::updateShape (const Standard_Boolean isWithLocation) { -// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()"); - SelectMgr_SelectableObject::UpdateLocation() ; + Handle(AIS_Shape) anAisShape = Handle(AIS_Shape)::DownCast (myReference); + if (anAisShape.IsNull()) + { + return; + } + + TopoDS_Shape aShape = anAisShape->Shape(); + if (aShape.IsNull()) + { + return; + } + + if(!isWithLocation) + { + myShape = aShape; + } + else + { + myShape = aShape.Moved (TopLoc_Location (Transformation())); + } } -void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel) + +//======================================================================= +//function : ComputeSelection +//purpose : +//======================================================================= +void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) { -// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)"); - SelectMgr_SelectableObject::UpdateLocation(Sel) ; + if (!HasConnection()) + { + return; + } + + if (theMode != 0 && myReference->AcceptShapeDecomposition()) + { + computeSubShapeSelection (theSelection, theMode); + return; + } + + if (!myReference->HasSelection (theMode)) + { + myReference->UpdateSelection (theMode); + } + + const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection (theMode); + Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this); + Handle(Select3D_SensitiveEntity) aSensitive, aNewSensitive; + + if (TheRefSel->IsEmpty()) + { + myReference->UpdateSelection (theMode); + } + + for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next()) + { + aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive()); + if (!aSensitive.IsNull()) + { + TopLoc_Location aLocation (Transformation()); + // Get the copy of SE3D + aNewSensitive = aSensitive->GetConnected (aLocation); + + aNewSensitive->Set(anOwner); + // In case if SE3D caches some location-dependent data + // that must be updated after setting OWN + aNewSensitive->SetLocation (aLocation); + + theSelection->Add (aNewSensitive); + } + } } -/*void AIS_ConnectedInteractive::UpdateLocation(const Handle(Prs3d_Presentation)& aPresentation) + +//======================================================================= +//function : ComputeSubShapeSelection +//purpose : +//======================================================================= +void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) { -// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(Prs3d_Presentation)&)"); - SelectMgr_SelectableObject::UpdateLocation(aPresentation) ; -}*/ + typedef NCollection_List SensitiveList; + typedef NCollection_DataMap + Shapes2EntitiesMap; + + if (!myReference->HasSelection (theMode)) + myReference->UpdateSelection (theMode); + + const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode); + + if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full) + { + myReference->UpdateSelection (theMode); + } + + Handle(StdSelect_BRepOwner) anOwner; + TopLoc_Location aDummyLoc; + + Handle(Select3D_SensitiveEntity) aSE, aNewSE; + Shapes2EntitiesMap aShapes2EntitiesMap; + + SensitiveList aSEList; + TopoDS_Shape aSubShape; + + // Fill in the map of subshapes and corresponding + // sensitive entities associated with aMode + for (aRefSel->Init(); aRefSel->More(); aRefSel->Next()) + { + aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive()); + if(!aSE.IsNull()) + { + anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId()); + if(!anOwner.IsNull()) + { + aSubShape = anOwner->Shape(); + if(!aShapes2EntitiesMap.IsBound (aSubShape)) + { + aShapes2EntitiesMap.Bind (aSubShape, aSEList); + } + aShapes2EntitiesMap (aSubShape).Append (aSE); + } + } + } + + // Fill in selection from aShapes2EntitiesMap + for (Shapes2EntitiesMap::Iterator aMapIt (aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next()) + { + aSEList = aMapIt.Value(); + anOwner = new StdSelect_BRepOwner (aMapIt.Key(), + this, + aSEList.First()->OwnerId()->Priority(), + Standard_True); + + for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next()) + { + aSE = aListIt.Value(); + + TopLoc_Location aLocation (Transformation()); + aNewSE = aSE->GetConnected (aDummyLoc); + aNewSE->Set (anOwner); + // In case if aSE caches some location-dependent data + // that must be updated after setting anOwner + aNewSE->SetLocation (aLocation); + + theSelection->Add (aNewSE); + } + } + + StdSelect::SetDrawerForBRepOwner (theSelection, myDrawer); +} diff --git a/src/AIS/AIS_ConnectedShape.cdl b/src/AIS/AIS_ConnectedShape.cdl deleted file mode 100644 index ee75a3350d..0000000000 --- a/src/AIS/AIS_ConnectedShape.cdl +++ /dev/null @@ -1,139 +0,0 @@ --- Created on: 1997-01-08 --- Created by: Robert COUBLANC --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - ---Modified by rob on Jul-28-97 - - -class ConnectedShape from AIS inherits ConnectedInteractive from AIS - - ---Purpose: Constructs a Connected Interactive Object with an - -- AIS_Shape presentation as its reference Interactive Object. - -- In topological decomposition of the shape, this class - -- assigns the same owners to the sensitive primitives - -- as those in AIS_Shape. Like AIS_Shape, it allows a - -- presentation of hidden parts. These are calculated - -- automatically from the shape of its reference entity. - - - -uses - - Shape from TopoDS, - Projector from Prs3d, - Presentation from Prs3d, - Selection from SelectMgr, - Integer from Standard, - Shape from AIS, - TypeOfPresentation3d from PrsMgr, - PresentationManager3d from PrsMgr, - InteractiveObject from AIS, - KindOfInteractive from AIS, - Location from TopLoc, - Transformation from Geom -raises - NotImplemented from Standard - -is - - Create (aTypeOfPresentation : TypeOfPresentation3d from PrsMgr - =PrsMgr_TOP_ProjectorDependant) - returns ConnectedShape from AIS; - ---Purpose: Initializes the type of 3d presentation aTypeOfPresentation - - Create (aInteractiveShape : Shape from AIS; - aTypeOfPresentation : TypeOfPresentation3d from PrsMgr - =PrsMgr_TOP_ProjectorDependant) - returns ConnectedShape from AIS; - ---Purpose: Initializes the entity aInteractiveShape and the type of 3d presentation aTypeOfPresentation. - - Create(aConnectedShape : ConnectedShape from AIS; - aTypeOfPresentation : TypeOfPresentation3d from PrsMgr - =PrsMgr_TOP_ProjectorDependant) - returns ConnectedShape from AIS; - ---Purpose: Initializes the entity aConnectedShape and the type of 3d presentation aTypeOfPresentation. - - ---Category: Redefined methods... - - Type(me) returns KindOfInteractive from AIS - is redefined virtual; - - Signature(me) returns Integer from Standard - is redefined virtual; - - AcceptShapeDecomposition(me) - returns Boolean from Standard is redefined; - - - - - Connect(me : mutable; - anotherIObj : InteractiveObject from AIS) is redefined ; - ---Purpose: Establishes the connection between the Connected - -- Interactive Object, anotherIobj, and its reference - -- entity. If there is already a previous connection with - -- an Interactive Object, this connection is removed. - - Connect(me:mutable; - anotherIobj: InteractiveObject from AIS; - aLocation : Location from TopLoc) is redefined; - ---Purpose: Establishes the connection between the Connected - -- Interactive Object, anotherIobj, and its reference - -- entity. If there is already a previous connection with - -- an Interactive Object, this connection is removed. - -- This syntax also initiates the location of the Connected Interactive Object. - - - Compute(me:mutable; - aProjector : Projector from Prs3d; - aPresentation: Presentation from Prs3d) - is redefined virtual private; - - Compute(me : mutable; - aProjector : Projector from Prs3d; - aTrsf : Transformation from Geom; - aPresentation : Presentation from Prs3d) - is redefined virtual private; - - ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; - aMode : Integer from Standard) - is redefined virtual private; - ---Purpose: Generates sensitive entities by copying - -- them from myReferense selection specified by aMode, - -- creates and sets an entity owner for this entities and adds - -- them to aSelection. - - Shape(me:mutable) returns Shape from TopoDS; - ---C++: return const& - ---Purpose: Returns the topological shape which is the reference - -- for the connected shape. Sets hilight mode to index - -- 0. This returns a wireframe presentation. - - - UpdateShape(me:mutable;WithLocation:Boolean from Standard = Standard_True) - is static private; - - Compute(me:mutable; - aProjector : Projector from Prs3d; - aPresentation: Presentation from Prs3d; - aShape : Shape from TopoDS) - is private; - - -fields - - myOwnSh : Shape from TopoDS; -- used for HLR and selection... - -end ConnectedShape; diff --git a/src/AIS/AIS_ConnectedShape.cxx b/src/AIS/AIS_ConnectedShape.cxx deleted file mode 100644 index 1d46b87a33..0000000000 --- a/src/AIS/AIS_ConnectedShape.cxx +++ /dev/null @@ -1,335 +0,0 @@ -// Created on: 1996-04-10 -// Created by: Guest Design -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// - - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : AIS_ConnectedShape -//purpose : -//======================================================================= - -AIS_ConnectedShape::AIS_ConnectedShape (const Handle(AIS_Shape)& TheAISShape, - const PrsMgr_TypeOfPresentation3d TheType): -AIS_ConnectedInteractive(TheType) -{ - myReference = TheAISShape; -} - -AIS_ConnectedShape::AIS_ConnectedShape (const Handle(AIS_ConnectedShape)& TheConnectedShape, - const PrsMgr_TypeOfPresentation3d TheType): -AIS_ConnectedInteractive(TheType) -{ - myReference = TheConnectedShape; -} - - -//======================================================================= -//function : Type -//purpose : -//======================================================================= - -AIS_KindOfInteractive AIS_ConnectedShape::Type() const -{return AIS_KOI_Shape;} - -//======================================================================= -//function : Signature -//purpose : -//======================================================================= -Standard_Integer AIS_ConnectedShape::Signature() const -{return 1;} - -//======================================================================= -//function : AcceptShapeDecomposition -//purpose : -//======================================================================= -Standard_Boolean AIS_ConnectedShape::AcceptShapeDecomposition() const -{return Standard_True;} - -//======================================================================= -//function : Compute Hidden Lines -//purpose : -//======================================================================= - -void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) -{ - UpdateShape(Standard_True); - Compute(aProjector,aPresentation,myOwnSh); -} - - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= -void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Geom_Transformation)& TheTrsf, - const Handle(Prs3d_Presentation)& aPresentation) -{ - UpdateShape(Standard_False); - const TopLoc_Location& loc = myOwnSh.Location(); - TopoDS_Shape shbis = myOwnSh.Located(TopLoc_Location(TheTrsf->Trsf())*loc); - Compute(aProjector,aPresentation,shbis); -} - - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation, - const TopoDS_Shape& SH) -{ -// Standard_Boolean recompute = Standard_False; -// Standard_Boolean myFirstCompute = Standard_True; - switch (SH.ShapeType()){ - case TopAbs_VERTEX: - case TopAbs_EDGE: - case TopAbs_WIRE: - { - aPresentation->SetDisplayPriority(4); - StdPrs_WFDeflectionShape::Add(aPresentation,SH,myDrawer); - break; - } - default: - { - Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer(); - if (defdrawer->DrawHiddenLine()) - {myDrawer->EnableDrawHiddenLine();} - else {myDrawer->DisableDrawHiddenLine();} - - Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection(); - defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); - - // process HLRAngle and HLRDeviationCoefficient() - Standard_Real prevangl = myDrawer->HLRAngle(); - Standard_Real newangl = defdrawer->HLRAngle(); - if (Abs(newangl- prevangl) > Precision::Angular()) { -#ifdef DEB - cout << "AIS_MultipleConnectedShape : compute"<SetHLRAngle(newangl); - myDrawer->SetHLRDeviationCoefficient(defdrawer->HLRDeviationCoefficient()); - StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector); - defdrawer->SetTypeOfDeflection (prevdef); - } - } -} - -//======================================================================= -//function : ComputeSelection -//purpose : Attention fragile... -//======================================================================= - -void AIS_ConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) -{ - typedef NCollection_List SensitiveList; - typedef NCollection_DataMap - Shapes2EntitiesMap; - - UpdateShape(); - aSelection->Clear(); - // It is checked if there is nothing to do with the reference - // of type update... - - if(!myReference->HasSelection(aMode)) - myReference->UpdateSelection(aMode); - const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection(aMode); - if(aRefSel->IsEmpty()) - myReference->UpdateSelection(aMode); - - if(aRefSel->UpdateStatus()==SelectMgr_TOU_Full) - myReference->UpdateSelection(aMode); - - Handle(StdSelect_BRepOwner) anOwner; - TopLoc_Location aBidLoc; - Handle(Select3D_SensitiveEntity) aSE, aNewSE; - Shapes2EntitiesMap aShapes2EntitiesMap; - SensitiveList aSEList; - TopoDS_Shape aSubShape; - - // Fill in the map of subshapes and corresponding - // sensitive entities associated with aMode - for(aRefSel->Init(); aRefSel->More(); aRefSel->Next()) - { - aSE = Handle(Select3D_SensitiveEntity)::DownCast(aRefSel->Sensitive()); - if(!aSE.IsNull()) - { - anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSE->OwnerId()); - if(!anOwner.IsNull()) - { - aSubShape = anOwner->Shape(); - if(!aShapes2EntitiesMap.IsBound(aSubShape)) - { - aShapes2EntitiesMap.Bind(aSubShape, aSEList); - } - aShapes2EntitiesMap(aSubShape).Append(aSE); - } - } - } - - // Fill in selection from aShapes2EntitiesMap - Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap); - for(; aMapIt.More(); aMapIt.Next()) - { - aSEList = aMapIt.Value(); - anOwner = new StdSelect_BRepOwner(aMapIt.Key(), - this, - aSEList.First()->OwnerId()->Priority(), - Standard_True); - - SensitiveList::Iterator aListIt(aSEList); - for(; aListIt.More(); aListIt.Next()) - { - aSE = aListIt.Value(); - if(myLocation.IsIdentity()) - { - aNewSE = aSE->GetConnected(aBidLoc); - aNewSE->Set(anOwner); - // In case if aSE caches some location-dependent data - // that must be updated after setting anOwner - aNewSE->SetLocation(aBidLoc); - } - else - { - aNewSE = aSE->GetConnected(myLocation); - aNewSE->Set(anOwner); - // In case if aSE caches some location-dependent data - // that must be updated after setting anOwner - aNewSE->SetLocation(myLocation); - } - aSelection->Add(aNewSE); - } - } - - StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer); -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - -const TopoDS_Shape& AIS_ConnectedShape::Shape() -{ - UpdateShape(); - return myOwnSh; -} -AIS_ConnectedShape::AIS_ConnectedShape(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): -AIS_ConnectedInteractive(aTypeOfPresentation3d) -{ - SetHilightMode(0); -} - -//======================================================================= -//function : UpdateShape -//purpose : if computes only the deducted shape -// from reference; does not put "myLocation" -//======================================================================= -void AIS_ConnectedShape::UpdateShape(const Standard_Boolean WithTheLocation) -{ - if(myReference.IsNull()) return; - - // attention great line... - if(myReference->Type()!=AIS_KOI_Shape) return; - - Standard_Integer Sig = myReference->Signature(); - - TopoDS_Shape S ; - switch(Sig){ - case 0: - S = (*((Handle(AIS_Shape)*) &myReference))->Shape(); - break; - case 1: - S = (*((Handle(AIS_ConnectedShape)*) &myReference))->Shape(); - break; - case 2: - S=(*((Handle(AIS_MultipleConnectedShape)*) &myReference))->Shape(); - break; - default: - S = myOwnSh; - } - if(S.IsNull()) return; - if(myLocation.IsIdentity() || !WithTheLocation) - myOwnSh = S; - else - myOwnSh = S.Moved(myLocation); -} - - -//======================================================================= -//function : Connect -//purpose : -//======================================================================= -void AIS_ConnectedShape:: -Connect(const Handle(AIS_InteractiveObject)& anotherIObj) -{ - if(anotherIObj->Type()== AIS_KOI_Shape){ - Standard_Integer Sig = anotherIObj->Signature(); - if(Sig <=2) - AIS_ConnectedInteractive::Connect(anotherIObj); - } -} - -//======================================================================= -//function : Connect -//purpose : -//======================================================================= -void AIS_ConnectedShape:: -Connect(const Handle(AIS_InteractiveObject)& anotherIObj, - const TopLoc_Location& aLocation) -{ - if(anotherIObj->Type()== AIS_KOI_Shape){ - Standard_Integer Sig = anotherIObj->Signature(); - if(Sig <=2) - AIS_ConnectedInteractive::Connect(anotherIObj,aLocation); - } -} - diff --git a/src/AIS/AIS_InteractiveContext.cdl b/src/AIS/AIS_InteractiveContext.cdl index f9bf5b1690..5ea726746e 100644 --- a/src/AIS/AIS_InteractiveContext.cdl +++ b/src/AIS/AIS_InteractiveContext.cdl @@ -526,7 +526,6 @@ is returns Location from TopLoc; ---Purpose: -- Returns the location of the entity aniobj. - ---C++: return const& diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 46a326202a..8dc78cea55 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -47,8 +47,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -1319,19 +1319,19 @@ void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& an if(anIObj.IsNull()) return; - if(anIObj->HasLocation() && aLoc.IsIdentity()){ - anIObj->ResetLocation(); + if(anIObj->HasTransformation() && aLoc.IsIdentity()){ + anIObj->ResetTransformation(); mgrSelector->Update(anIObj,Standard_False); return; } if(aLoc.IsIdentity()) return ; // first reset the previous location to properly clean everything... - if(anIObj->HasLocation()) - anIObj->ResetLocation(); + if(anIObj->HasTransformation()) + anIObj->ResetTransformation(); - anIObj->SetLocation(aLoc); + anIObj->SetLocalTransformation (aLoc.Transformation()); if(!HasOpenedContext()) mgrSelector->Update(anIObj,Standard_False); @@ -1352,7 +1352,7 @@ void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& { if(anIObj.IsNull()) return; - anIObj->ResetLocation(); + anIObj->ResetTransformation(); mgrSelector->Update(anIObj,Standard_False); } @@ -1366,13 +1366,13 @@ HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const { if(anIObj.IsNull()) return Standard_False; - return anIObj->HasLocation(); + return anIObj->HasTransformation(); } -const TopLoc_Location& AIS_InteractiveContext:: +TopLoc_Location AIS_InteractiveContext:: Location(const Handle(AIS_InteractiveObject)& anIObj) const { - return anIObj->Location(); + return anIObj->Transformation(); } //======================================================================= @@ -1489,8 +1489,8 @@ void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode, Handle(AIS_InteractiveObject) anObj = It.Key(); // ENDCLE Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) || - anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) || - anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) ); + anObj->IsKind(STANDARD_TYPE(AIS_ConnectedInteractive)) || + anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedInteractive)) ); if ((!anObj->HasDisplayMode()) && Processed) { diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 73cebca4fa..9d041b0297 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -1120,17 +1120,17 @@ Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const TopoDS_Shape AIS_InteractiveContext::SelectedShape() const { - - if(!HasOpenedContext()){ + if (!HasOpenedContext()) + { TopoDS_Shape sh; -#ifdef IMP280200 - Handle(AIS_Shape) shape = - Handle(AIS_Shape)::DownCast(SelectedInteractive()); - if( !shape.IsNull() ) sh = shape->Shape(); -#endif + Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(SelectedInteractive()); + if (!shape.IsNull()) sh = shape->Shape().Located (SelectedInteractive()->Transformation()); return sh; - } else - return myLocalContexts(myCurLocalIndex)->SelectedShape(); + } + else + { + return myLocalContexts (myCurLocalIndex)->SelectedShape(); + } } //======================================================================= diff --git a/src/AIS/AIS_InteractiveObject.cdl b/src/AIS/AIS_InteractiveObject.cdl index cf6cea7afa..8b4f4480a6 100644 --- a/src/AIS/AIS_InteractiveObject.cdl +++ b/src/AIS/AIS_InteractiveObject.cdl @@ -521,37 +521,6 @@ is State(me) returns Integer from Standard ; ---C++: inline - SetTransformation ( me : mutable; - aTranformation: Transformation from Geom; - postConcatenate: Boolean from Standard = Standard_False; - updateSelection: Boolean from Standard = Standard_True) - is static; - ---Level: Public - ---Purpose: Transforms all presentations of the object - -- and replace the actual transformation matrix if is FALSE. - -- Note that the selection must be updated only at the end of - -- object animation when is TRUE - ---Category: Transformation method - - UnsetTransformation ( me : mutable ) - is static; - ---Level: Public - ---Purpose: Deactivate the current transformation - ---Category: Transformation method - - Transformation ( me : mutable ) returns Transformation from Geom - is static; - ---Level: Public - ---Purpose: Returns the current transformation associated - -- to the first available presentation of this object. - ---Category: Inquire transformation method - - HasTransformation ( me ) returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns TRUE when this object is transformed - ---Category: Inquire transformation method - HasPresentation ( me ) returns Boolean from Standard is static; ---Level: Public @@ -657,7 +626,6 @@ fields myToRecomputeModes : ListOfInteger from TColStd is protected; mystate : Integer from Standard; - myHasTransformation : Boolean from Standard; friends diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index c568148927..3e97b9c3ae 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -72,8 +72,7 @@ myCTXPtr(NULL), mySelPriority(-1), myDisplayMode (-1), mySelectionMode(0), -mystate(0), -myHasTransformation(Standard_False) +mystate(0) { Handle (AIS_InteractiveContext) Bid; myCTXPtr = Bid.operator->(); @@ -545,79 +544,6 @@ void AIS_InteractiveObject::SetInfiniteState(const Standard_Boolean aFlag) } } -//======================================================================= -//function : SetTransformation -//purpose : -//======================================================================= -void AIS_InteractiveObject::SetTransformation (const Handle(Geom_Transformation)& theTrsf, - const Standard_Boolean theToPostConcatenate, - const Standard_Boolean theToUpdateSelection) -{ - if (GetContext().IsNull()) - { - return; - } - - const PrsMgr_Presentations& aPrsList = Presentations(); - myHasTransformation = Standard_True; - for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) - { - const Standard_Integer aMode = aPrsList (aPrsIter).Mode(); - Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, aMode)->Presentation(); - theToPostConcatenate ? aPrs->Multiply (theTrsf) - : aPrs->Transform (theTrsf); - if (theToUpdateSelection) - { - myCTXPtr->ClearSelected (Standard_True); - myCTXPtr->RecomputeSelectionOnly (this); - } - } -} - -//======================================================================= -//function : SetTransformation -//purpose : -//======================================================================= -void AIS_InteractiveObject::UnsetTransformation() { -#ifdef OCC708 - static Handle(Geom_Transformation) trsf = new Geom_Transformation( gp_Trsf() ); -#else -Handle(Geom_Transformation) trsf; -#endif - - SetTransformation(trsf); // Set identity transformation - myHasTransformation = Standard_False; -} - -//======================================================================= -//function : Transformation -//purpose : -//======================================================================= -Handle(Geom_Transformation) AIS_InteractiveObject::Transformation() -{ - if (GetContext().IsNull()) - { - return Handle(Geom_Transformation)(); - } - - const PrsMgr_Presentations& aPrsList = Presentations(); - if (aPrsList.Length() > 0) - { - Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, 1)->Presentation(); - return aPrs->Transformation(); - } - return Handle(Geom_Transformation)(); -} - -//======================================================================= -//function : HasTransformation -//purpose : -//======================================================================= -Standard_Boolean AIS_InteractiveObject::HasTransformation() const { - - return myHasTransformation; -} - //======================================================================= //function : HasPresentation //purpose : diff --git a/src/AIS/AIS_LocalContext.cdl b/src/AIS/AIS_LocalContext.cdl index 1cca3f4768..5dc1160934 100644 --- a/src/AIS/AIS_LocalContext.cdl +++ b/src/AIS/AIS_LocalContext.cdl @@ -379,7 +379,6 @@ is ---Purpose: returns TRUE if the detected entity is a shape -- coming from a Decomposition of an element. SelectedShape(me) returns Shape from TopoDS; - ---C++: return const & SelectedOwner(me) returns EntityOwner from SelectMgr; IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard; diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 30f05e2ee8..7ce7815cf0 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -774,8 +774,7 @@ HasShape() const // Function: // Purpose : //================================================== -const TopoDS_Shape& AIS_LocalContext:: -SelectedShape() const +TopoDS_Shape AIS_LocalContext::SelectedShape() const { static TopoDS_Shape aSh; Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value(); @@ -785,7 +784,7 @@ SelectedShape() const { return aSh; } - return BRO->Shape(); + return BRO->Shape().Located (BRO->Location()); } //================================================== diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cdl b/src/AIS/AIS_MultipleConnectedInteractive.cdl index 5ce6b7b167..5815d3fc20 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cdl +++ b/src/AIS/AIS_MultipleConnectedInteractive.cdl @@ -37,22 +37,27 @@ uses Projector from Prs3d, Transformation from Geom, Integer from Standard, - Selection from SelectMgr + Selection from SelectMgr, + Trsf from gp is - Create (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView) + Create returns MultipleConnectedInteractive from AIS; ---Purpose: Initializes the Interactive Object with multiple - -- presentation connections. If aTypeOfPresentation3d - -- does not have the affectation PrsMgr_TOP_AllView, - -- it is projector dependent. + -- connections to AIS_Interactive objects. - Connect(me : mutable; - anotherIObj : InteractiveObject from AIS); - ---Purpose: Add anotherIObj in the presentation of me + Connect(me : mutable; + theInteractive : InteractiveObject from AIS); + ---Purpose: Adds instance of theInteractive to child list. + Connect(me:mutable; + anotherIobj: InteractiveObject from AIS; + aLocation : Trsf from gp) is virtual; + ---Purpose: Establishes the connection between the Connected + -- Interactive Object, anotherIobj, and its reference. + -- Locates instance in aLocation. Type(me) returns KindOfInteractive from AIS is redefined virtual; @@ -63,16 +68,9 @@ is HasConnection(me) returns Boolean from Standard; ---Purpose: Returns true if the object is connected to others. - ConnectedTo(me) returns SequenceOfInteractive from AIS; - ---Purpose: - -- Returns the connection references of the previous - -- Interactive Objects in view. - ---C++: inline - ---C++: return const& - - Disconnect(me:mutable; - anotherIObj : InteractiveObject from AIS); - ---Purpose: Removes the connection anotherIObj to an entity. + Disconnect(me : mutable; + theInteractive : InteractiveObject from AIS); + ---Purpose: Removes the connection with theInteractive. DisconnectAll(me:mutable); ---Purpose: Clears all the connections to objects. @@ -106,17 +104,20 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: Presentation from Prs3d) - is redefined ; + is redefined ; + + AcceptShapeDecomposition(me) returns Boolean from Standard is redefined virtual; + ---C++: inline + ---Purpose: Informs the graphic context that the interactive Object + -- may be decomposed into sub-shapes for dynamic selection. + ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; aMode : Integer from Standard) is redefined virtual private; + ---Purpose: Computes the selection for whole subtree in scene hierarchy. -fields - - myReferences : SequenceOfInteractive from AIS; - myPreviousReferences : SequenceOfInteractive from AIS; end MultipleConnectedInteractive; diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 10ba1c1e38..91c37f53bc 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -14,34 +14,139 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// - - #include #include +#include +#include #include #include +#include +#include +#include +#include + +namespace +{ + //! SelectMgr_AssemblyEntityOwner replaces original owners in sensitive entities + //! copied from reference objects to AIS_MultipleConnectedInteractive in order to + //! redirect all selection queries to multiply connected (assembly). + class SelectMgr_AssemblyEntityOwner : public SelectMgr_EntityOwner + { + + public: + + // Copies another SelectMgr_EntityOwner. + SelectMgr_AssemblyEntityOwner (const Handle(SelectMgr_EntityOwner) theOwner, + SelectMgr_SelectableObject* theAssembly); + + void SetAssembly (SelectMgr_SelectableObject* theAssembly) + { + myAssembly = theAssembly; + } + + //! Selectable() method modified to return myAssembly. + virtual Handle_SelectMgr_SelectableObject Selectable() const; + + Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode) const; + + void Hilight (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode); + + void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, + const Quantity_NameOfColor aColor, + const Standard_Integer aMode); + + void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer aMode); + + private: + + SelectMgr_SelectableObject* myAssembly; + }; + +} + +//======================================================================= +//function : SelectMgr_AssemblyEntityOwner +//purpose : +//======================================================================= +SelectMgr_AssemblyEntityOwner::SelectMgr_AssemblyEntityOwner (const Handle(SelectMgr_EntityOwner) theOwner, + SelectMgr_SelectableObject* theAssembly) +: + SelectMgr_EntityOwner (theOwner), + myAssembly (theAssembly) +{ +} + +//======================================================================= +//function : Selectable +//purpose : +//======================================================================= +Handle(SelectMgr_SelectableObject) SelectMgr_AssemblyEntityOwner::Selectable() const +{ + return myAssembly; +} -static Standard_Boolean IsInSeq (const AIS_SequenceOfInteractive& theSeq, - const Handle(AIS_InteractiveObject)& theItem) +//======================================================================= +//function : IsHilighted +//purpose : +//======================================================================= +Standard_Boolean SelectMgr_AssemblyEntityOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& PM, + const Standard_Integer aMode) const { - Standard_Integer I = theSeq.Length(); - while ( I>0 && theSeq.Value(I) != theItem) { - I--; + if (HasSelectable()) + { + return PM->IsHighlighted (myAssembly, aMode); } - return (I>0); + + return Standard_False; } -static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq , - const Handle(AIS_InteractiveObject)& theItem) +//======================================================================= +//function : Hilight +//purpose : +//======================================================================= +void SelectMgr_AssemblyEntityOwner::Hilight (const Handle(PrsMgr_PresentationManager)& PM, + const Standard_Integer aMode) { - Standard_Integer I = theSeq.Length(); - while ( I>0 && theSeq.Value(I) != theItem) { - I--; + if (HasSelectable()) + { + PM->Highlight (myAssembly, aMode); + } +} + +//======================================================================= +//function : HilightWithColor +//purpose : +//======================================================================= +void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, + const Quantity_NameOfColor aColor, + const Standard_Integer aMode) +{ + if (HasSelectable()) + { + if (IsAutoHilight()) + { + PM->Color (myAssembly, aColor, aMode); + } + else + { + myAssembly->HilightOwnerWithColor (PM, aColor, this); + } + } +} + +//======================================================================= +//function : Unhilight +//purpose : +//======================================================================= +void SelectMgr_AssemblyEntityOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& PM, + const Standard_Integer aMode) +{ + if (HasSelectable()) + { + PM->Unhighlight (myAssembly, aMode); } - return I; } @@ -50,11 +155,11 @@ static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq , //purpose : //======================================================================= -AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive -(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): -AIS_InteractiveObject(aTypeOfPresentation3d) -{ - SetHilightMode(0); +AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive() + : AIS_InteractiveObject (PrsMgr_TOP_AllView) +{ + myHasOwnPresentations = Standard_False; + SetHilightMode (0); } //======================================================================= @@ -62,25 +167,68 @@ AIS_InteractiveObject(aTypeOfPresentation3d) //purpose : //======================================================================= AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const -{return AIS_KOI_Object;} +{ + return AIS_KOI_Object; +} //======================================================================= //function : Signature //purpose : //======================================================================= Standard_Integer AIS_MultipleConnectedInteractive::Signature() const -{return 1;} +{ + return 1; +} //======================================================================= //function : Connect //purpose : //======================================================================= -void AIS_MultipleConnectedInteractive::Connect(const Handle(AIS_InteractiveObject)& anotherIObj) +void AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, + const gp_Trsf& theTransformation) { + Handle(AIS_InteractiveObject) anObjectToAdd; + + Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj); + if (!aMultiConnected.IsNull()) + { + Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive(); + aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformation()); + + // Perform deep copy of instance tree + for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next()) + { + Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + if (anInteractive.IsNull()) + { + continue; + } + + aNewMultiConnected->Connect (anInteractive); + } - if (!IsInSeq (myReferences, anotherIObj)) { - myReferences.Append(anotherIObj); + anObjectToAdd = aNewMultiConnected; } + else + { + Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive(); + aNewConnected->Connect (theAnotherObj); + aNewConnected->SetLocalTransformation (theAnotherObj->LocalTransformation()); + + anObjectToAdd = aNewConnected; + } + + anObjectToAdd->SetLocalTransformation (theTransformation); + AddChild (anObjectToAdd); +} + +//======================================================================= +//function : Connect +//purpose : +//======================================================================= +void AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) +{ + Connect (theAnotherObj, theAnotherObj->LocalTransformation()); } //======================================================================= @@ -89,7 +237,7 @@ void AIS_MultipleConnectedInteractive::Connect(const Handle(AIS_InteractiveObjec //======================================================================= Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const { - return (myReferences.Length() != 0); + return (Children().Size() != 0); } //======================================================================= @@ -99,11 +247,7 @@ Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj) { - Standard_Integer I = RangeInSeq (myReferences, anotherIObj); - if (I != 0) { - myReferences.Remove(I); - - } + RemoveChild (anotherIObj); } //======================================================================= @@ -111,49 +255,36 @@ void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveOb //purpose : //======================================================================= -void AIS_MultipleConnectedInteractive::DisconnectAll () +void AIS_MultipleConnectedInteractive::DisconnectAll() { -/* for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) - { - const Handle(PrsMgr_Presentation)& aPrs = myPresentations (aPrsIter).Presentation(); - if (!aPrs.IsNull()) - { - aPrs->Presentation()->DisconnectAll (Graphic3d_TOC_DESCENDANT); - } - }*/ - myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!! - myReferences.Clear(); + Standard_Integer aNbItemsToRemove = Children().Size(); + for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter) + { + RemoveChild (Children().First()); + } } //======================================================================= //function : Compute //purpose : //======================================================================= -void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, - const Handle(Prs3d_Presentation)& thePrs, - const Standard_Integer theMode) +void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/, + const Handle(Prs3d_Presentation)& /*thePrs*/, + const Standard_Integer /*theMode*/) { - thePrs->Clear (Standard_False); - thePrs->RemoveAll(); - if (HasConnection()) + for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) { - for (Standard_Integer aRefIter = 1; aRefIter <= myReferences.Length(); ++aRefIter) + Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + if (aChild.IsNull()) { - const Handle (AIS_InteractiveObject)& aRef = myReferences.Value (aRefIter); - if (!aRef->HasInteractiveContext()) - { - aRef->SetContext (GetContext()); - } + continue; + } - thePrsMgr->Connect (this, aRef, theMode, theMode); - if (thePrsMgr->Presentation (aRef, theMode)->MustBeUpdated()) - { - thePrsMgr->Update (aRef, theMode); - } + if (!aChild->HasInteractiveContext()) + { + aChild->SetContext (GetContext()); } } - - thePrs->ReCompute(); } //======================================================================= @@ -164,8 +295,7 @@ void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_Presentation void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) { -// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; + PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } //======================================================================= @@ -177,15 +307,109 @@ void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aP const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation) { -// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; + PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; +} + +//======================================================================= +//function : AcceptShapeDecomposition +//purpose : +//======================================================================= +Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const +{ + for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) + { + Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + if (aChild.IsNull()) + { + continue; + } + + if (aChild->AcceptShapeDecomposition()) + { + return Standard_True; + } + } + return Standard_False; } //======================================================================= //function : ComputeSelection //purpose : //======================================================================= -void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/, - const Standard_Integer /*aMode*/) +void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) { + if (theMode != 0) + { + for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) + { + Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + if (aChild.IsNull()) + { + continue; + } + + if (!aChild->HasSelection(theMode)) + { + aChild->UpdateSelection(theMode); + } + + aChild->ComputeSelection (theSelection, theMode); + } + + return; + } + + for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) + { + Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + if (aChild.IsNull()) + { + continue; + } + + if (!aChild->HasSelection (theMode)) + { + aChild->UpdateSelection (theMode); + } + + const Handle(SelectMgr_Selection)& TheRefSel = aChild->Selection (theMode); + + // To redirect selection we must replace owners in sensitives, but we don't want new owner for each SE. + // Only for each existing owner. + NCollection_DataMap anOwnerMap; + + Handle(Select3D_SensitiveEntity) aSensitive, aNewSensitive; + + if (TheRefSel->IsEmpty()) + { + aChild->UpdateSelection(theMode); + } + + for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next()) + { + aSensitive = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive()); + + if (!aSensitive.IsNull()) + { + TopLoc_Location aLocation (Transformation()); + // Get the copy of aSensitive + aNewSensitive = aSensitive->GetConnected (aLocation); + Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aNewSensitive->OwnerId()); + + if (!anOwnerMap.IsBound (anOwner)) + { + Handle(SelectMgr_EntityOwner) aNewOwner = new SelectMgr_AssemblyEntityOwner (anOwner, this); + anOwnerMap.Bind (anOwner, aNewOwner); + } + + aNewSensitive->Set (anOwnerMap.Find (anOwner)); + // In case if aSensitive caches some location-dependent data + // that must be updated after setting OWN + aNewSensitive->SetLocation (aLocation); + + theSelection->Add (aNewSensitive); + } + } + } } diff --git a/src/AIS/AIS_MultipleConnectedInteractive.lxx b/src/AIS/AIS_MultipleConnectedInteractive.lxx index 9790839249..9c37240705 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.lxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.lxx @@ -13,14 +13,3 @@ // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -// -//======================================================================= -//function : ConnectedTo -//purpose : -//======================================================================= - -inline const AIS_SequenceOfInteractive& AIS_MultipleConnectedInteractive::ConnectedTo() const -{ - return myReferences; -} diff --git a/src/AIS/AIS_MultipleConnectedShape.cdl b/src/AIS/AIS_MultipleConnectedShape.cdl deleted file mode 100644 index c58a5b17c0..0000000000 --- a/src/AIS/AIS_MultipleConnectedShape.cdl +++ /dev/null @@ -1,107 +0,0 @@ --- Created on: 1997-04-22 --- Created by: Guest Design --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class MultipleConnectedShape from AIS inherits MultipleConnectedInteractive from AIS - - - ---Purpose: Constructs an Interactive Object connected to a list of - -- Interactive Objects having a Shape. These include - -- AIS_Shape, and AIS_ConnectedShape. - -- Presentation of Hidden parts is calculated automatically. - -- You define the Interactive Object by gathering - -- together several other object presentations as in - -- AIS_MultipleConnectedInteractive. - -uses - - PresentationManager3d from PrsMgr, - Shape from TopoDS, - Projector from Prs3d, - Presentation from Prs3d, - Selection from SelectMgr, - Integer from Standard, - Transformation from Geom, - KindOfInteractive from AIS - -raises - NotImplemented from Standard - -is - - Create (aShape : Shape from TopoDS) - returns MultipleConnectedShape from AIS; - ---Purpose: Initializes the shape aShape, a multiple connected - -- Interactive Object grouping different - -- projector-dependent representations of an entity. - Type(me) returns KindOfInteractive from AIS - is redefined virtual; - - Signature(me) returns Integer from Standard - is redefined virtual; - - AcceptShapeDecomposition(me) - returns Boolean from Standard is redefined virtual; - ---Purpose: Returns true is shape decomposition is accepted. - - Set(me:mutable;ashap : Shape from TopoDS) is static; - ---Purpose: Constructs the reference shape ashap. - ---C++: inline - - Shape(me) returns Shape from TopoDS ; - ---Purpose: Returns the shape which is constructed in Set. - ---C++: inline - ---C++: return const& - - - Compute(me:mutable; - aProjector : Projector from Prs3d; - aPresentation: Presentation from Prs3d) - is redefined virtual protected; - - Compute(me:mutable; - aProjector : Projector from Prs3d; - aTrsf : Transformation from Geom; - aPresentation: Presentation from Prs3d) - is redefined virtual protected; - - ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; - aMode : Integer from Standard) - is redefined virtual protected; - - - - Compute(me:mutable; - aProjector : Projector from Prs3d; - aPresentation: Presentation from Prs3d; - aShape : Shape from TopoDS) - is private; - - Compute(me:mutable; - aPresentationManager : PresentationManager3d from PrsMgr; - aPresentation : Presentation from Prs3d; - aMode : Integer from Standard = 0) - ---Level: Internal - ---Purpose: this method is redefined virtual; - -- when the instance is connected to another - -- InteractiveObject,this method doesn't - -- compute anything, but just uses the - -- presentation of this last object, with - -- a transformation if there's one stored. - is redefined virtual private; - -fields - myShape : Shape from TopoDS; -- celle qui sert au compute Hidden lines et selection -end MultipleConnectedShape; diff --git a/src/AIS/AIS_MultipleConnectedShape.cxx b/src/AIS/AIS_MultipleConnectedShape.cxx deleted file mode 100644 index 4fef33c0e2..0000000000 --- a/src/AIS/AIS_MultipleConnectedShape.cxx +++ /dev/null @@ -1,231 +0,0 @@ -// Created on: 1997-04-22 -// Created by: Guest Design -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// - - -#include - -#include - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : AIS_ConnectedShape -//purpose : -//======================================================================= - -AIS_MultipleConnectedShape::AIS_MultipleConnectedShape (const TopoDS_Shape& aShape): -AIS_MultipleConnectedInteractive(PrsMgr_TOP_ProjectorDependant), -myShape(aShape) -{ -} - -//======================================================================= -//function : Type -//purpose : -//======================================================================= -AIS_KindOfInteractive AIS_MultipleConnectedShape::Type() const -{return AIS_KOI_Shape;} - - -//======================================================================= -//function : Signature -//purpose : -//======================================================================= -Standard_Integer AIS_MultipleConnectedShape::Signature() const -{return 2;} - - -//======================================================================= -//function : AcceptShapeDecomposition -//purpose : -//======================================================================= - -Standard_Boolean AIS_MultipleConnectedShape::AcceptShapeDecomposition() const -{return Standard_True;} - - - - -//======================================================================= -//function : Compute Hidden Lines -//purpose : -//======================================================================= - -void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) -{ - Compute(aProjector,aPresentation,myShape); - -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Geom_Transformation)& aTrsf, - const Handle(Prs3d_Presentation)& aPresentation) -{ - aPresentation->Clear(); - - const TopLoc_Location& loc = myShape.Location(); - TopoDS_Shape shbis = myShape.Located(TopLoc_Location(aTrsf->Trsf())*loc); - Compute(aProjector,aPresentation,shbis); -} - - - - -void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation, - const TopoDS_Shape& SH) -{ - //Standard_Boolean recompute = Standard_False; - //Standard_Boolean myFirstCompute = Standard_True; - switch (SH.ShapeType()){ - case TopAbs_VERTEX: - case TopAbs_EDGE: - case TopAbs_WIRE: - { - aPresentation->SetDisplayPriority(4); - StdPrs_WFDeflectionShape::Add(aPresentation,SH,myDrawer); - break; - } - default: - { - - Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer(); - if (defdrawer->DrawHiddenLine()) - {myDrawer->EnableDrawHiddenLine();} - else {myDrawer->DisableDrawHiddenLine();} - - Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection(); - defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); - - // traitement HLRAngle et HLRDeviationCoefficient() - Standard_Real prevangl = myDrawer->HLRAngle(); - Standard_Real newangl = defdrawer->HLRAngle(); - if (Abs(newangl- prevangl) > Precision::Angular()) { -#ifdef DEB - cout << "AIS_MultipleConnectedShape : compute"<SetHLRAngle(newangl); - myDrawer->SetHLRDeviationCoefficient(defdrawer->HLRDeviationCoefficient()); - - StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector); - - - defdrawer->SetTypeOfDeflection (prevdef); - - } - } -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_MultipleConnectedShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager3d, - const Handle(Prs3d_Presentation)& aPresentation, - const int anint) -{ - AIS_MultipleConnectedInteractive::Compute( aPresentationManager3d , aPresentation , anint ) ; -} - -//======================================================================= -//function : ComputeSelection -//purpose : -//======================================================================= - -void AIS_MultipleConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) -{ - //cout<<"AIS_MultipleConnectedShape::ComputeSelection"<DeviationAngle(); - Standard_Real aDeflection = myDrawer->MaximalChordialDeviation(); - if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) - { - // On calcule la fleche en fonction des min max globaux de la piece: - Bnd_Box aBndBox; //= BoundingBox(); ? - BRepBndLib::Add (myShape, aBndBox); - if (!aBndBox.IsVoid()) - { - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient(); - } - } - - switch(aMode){ - case 1: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_VERTEX, aDeflection, aDeviationAngle); - break; - case 2: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_EDGE, aDeflection, aDeviationAngle); - break; - case 3: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_WIRE, aDeflection, aDeviationAngle); - break; - case 4: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_FACE, aDeflection, aDeviationAngle); - break; - case 5: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHELL, aDeflection, aDeviationAngle); - break; - case 6: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SOLID, aDeflection, aDeviationAngle); - break; - case 7: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPOUND, aDeflection, aDeviationAngle); - break; - case 8: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPSOLID, aDeflection, aDeviationAngle); - break; - default: - StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHAPE, aDeflection, aDeviationAngle); - break; - } - // insert the drawer in the BrepOwners for hilight... - StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer); - -} - - - - diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 51aa9ab578..416f39274c 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -411,8 +411,8 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, TypOfSel = AIS_Shape::SelectionType(aMode); TopoDS_Shape shape = myshape; if( HasTransformation() ) { - Handle(Geom_Transformation) trsf = Transformation(); - shape = shape.Located(TopLoc_Location(trsf->Trsf())*shape.Location()); + gp_Trsf trsf = Transformation(); + shape = shape.Located(TopLoc_Location(trsf)*shape.Location()); } // POP protection against crash in low layers diff --git a/src/AIS/AIS_Trihedron.cdl b/src/AIS/AIS_Trihedron.cdl index 660f5505dd..544e5b04a2 100644 --- a/src/AIS/AIS_Trihedron.cdl +++ b/src/AIS/AIS_Trihedron.cdl @@ -47,6 +47,7 @@ class Trihedron from AIS inherits InteractiveObject from AIS uses Axis2Placement from Geom, + Trsf from gp, Presentation from Prs3d, PresentationManager3d from PrsMgr, NameOfColor from Quantity, @@ -152,9 +153,7 @@ is -- Methods from PresentableObject - SetLocation(me : mutable; - aLoc : Location from TopLoc) - is redefined static; + SetLocalTransformation(me:mutable; theTransformation:Trsf from gp) is redefined static; -- Methods from SelectableObject diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index 1cc77c89c9..a53df314f6 100644 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -107,14 +107,14 @@ void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& aComponent) //purpose : //======================================================================= -void AIS_Trihedron::SetLocation(const TopLoc_Location& aLoc) +void AIS_Trihedron::SetLocalTransformation (const gp_Trsf& theTransformation) { // Update location to the subshapes Standard_Integer anIdx; for (anIdx = 0; anIdx < 7; anIdx++) - myShapes[anIdx]->SetLocation (aLoc); + myShapes[anIdx]->SetLocalTransformation (theTransformation); - AIS_InteractiveObject::SetLocation (aLoc); + AIS_InteractiveObject::SetLocalTransformation (theTransformation); } //======================================================================= diff --git a/src/Graphic3d/Graphic3d_Structure.cdl b/src/Graphic3d/Graphic3d_Structure.cdl index f0231affd9..7c5d470b49 100644 --- a/src/Graphic3d/Graphic3d_Structure.cdl +++ b/src/Graphic3d/Graphic3d_Structure.cdl @@ -911,10 +911,17 @@ is is static private; ---Purpose: Returns the extreme coordinates found in the structure without transformation applied. + getBox (me; + theBox : out BndBox4d from Graphic3d; + theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False) + is static private; + ---Purpose: Gets untransformed bounding box from structure. + addTransformed (me; theBox : out BndBox4d from Graphic3d; theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False) is static private; + ---Purpose: Adds transformed (with myCStructure->Transformation) bounding box of structure to theBox. PrintNetwork ( myclass; AStructure : Structure from Graphic3d; diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 884967a9af..e66e2ec58d 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -1838,29 +1838,28 @@ Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord (const Standard_Boolean theT //function : addTransformed //purpose : //============================================================================= -void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox, - const Standard_Boolean theToIgnoreInfiniteFlag) const +void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox, + const Standard_Boolean theToIgnoreInfiniteFlag) const { - Graphic3d_BndBox4d aBox; Graphic3d_BndBox4f aBoxF = minMaxCoord (theToIgnoreInfiniteFlag); if (aBoxF.IsValid()) { - aBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(), - (Standard_Real )aBoxF.CornerMin().y(), - (Standard_Real )aBoxF.CornerMin().z(), - (Standard_Real )aBoxF.CornerMin().w()), - Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMax().x(), - (Standard_Real )aBoxF.CornerMax().y(), - (Standard_Real )aBoxF.CornerMax().z(), - (Standard_Real )aBoxF.CornerMax().w())); + theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(), + (Standard_Real )aBoxF.CornerMin().y(), + (Standard_Real )aBoxF.CornerMin().z(), + (Standard_Real )aBoxF.CornerMin().w()), + Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMax().x(), + (Standard_Real )aBoxF.CornerMax().y(), + (Standard_Real )aBoxF.CornerMax().z(), + (Standard_Real )aBoxF.CornerMax().w())); if (IsInfinite() && !theToIgnoreInfiniteFlag) { - const Graphic3d_Vec4d aDiagVec = aBox.CornerMax() - aBox.CornerMin(); + const Graphic3d_Vec4d aDiagVec = theBox.CornerMax() - theBox.CornerMin(); if (aDiagVec.xyz().SquareModulus() >= 500000.0 * 500000.0) { // bounding borders of infinite line has been calculated as own point in center of this line - aBox = Graphic3d_BndBox4d ((aBox.CornerMin() + aBox.CornerMax()) * 0.5); + theBox = Graphic3d_BndBox4d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5); } else { @@ -1870,20 +1869,42 @@ void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox, } } } +} + +//============================================================================= +//function : addTransformed +//purpose : +//============================================================================= +void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox, + const Standard_Boolean theToIgnoreInfiniteFlag) const +{ + Graphic3d_BndBox4d aCombinedBox, aBox; + getBox (aCombinedBox, theToIgnoreInfiniteFlag); for (Standard_Integer aStructIt = 1; aStructIt <= myDescendants.Length(); ++aStructIt) { const Graphic3d_Structure* aStruct = (const Graphic3d_Structure* )myDescendants.Value (aStructIt); - aStruct->addTransformed (aBox, theToIgnoreInfiniteFlag); + aStruct->getBox (aBox, theToIgnoreInfiniteFlag); + aCombinedBox.Combine (aBox); } + aBox = aCombinedBox; if (aBox.IsValid()) { TColStd_Array2OfReal aTrsf (0, 3, 0, 3); Transform (aTrsf); TransformBoundaries (aTrsf, aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(), aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z()); - theBox.Combine (aBox); + + // if box is still valid after transformation + if (aBox.IsValid()) + { + theBox.Combine (aBox); + } + else // it was infinite, return untransformed + { + theBox.Combine (aCombinedBox); + } } } diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index ec54411052..d9c27b1c7b 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -606,6 +606,20 @@ void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx) IsForHighlight = Standard_False; } +// ======================================================================= +// function : RenderGeometry +// purpose : +// ======================================================================= +void OpenGl_Structure::RenderGeometry (const Handle(OpenGl_Workspace) &AWorkspace) const +{ + // Render groups + const Graphic3d_SequenceOfGroup& aGroups = DrawGroups(); + for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next()) + { + aGroupIter.Value()->Render (AWorkspace); + } +} + // ======================================================================= // function : Render // purpose : @@ -693,7 +707,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const OpenGl_ListOfStructure::Iterator its(myConnected); while (its.More()) { - its.Value()->Render(AWorkspace); + its.Value()->RenderGeometry (AWorkspace); its.Next(); } diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 48569aefa0..d603cea93d 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -139,8 +139,14 @@ public: //! Get z layer ID Standard_EXPORT Standard_Integer GetZLayer() const; + //! Renders groups of structure without applying any attributes (i.e. transform, material etc). + virtual void RenderGeometry (const Handle(OpenGl_Workspace)& theWorkspace) const; + + //! Renders the structure. virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; - virtual void Release (const Handle(OpenGl_Context)& theGlCtx); + + //! Releases structure resources. + virtual void Release (const Handle(OpenGl_Context)& theGlCtx); //! Marks structure as not overlapping view volume (as it is by default). void ResetCullingStatus() const diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index d122e43e34..fa4a05f2bc 100755 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -448,8 +448,12 @@ protected: //! @name methods related to ray-tracing Standard_Boolean UpdateRaytraceEnvironmentMap(); //! Adds OpenGL structure to ray-traced scene geometry. - Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure, - const Standard_ShortReal* theTransform, std::set& theElements); + Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure, std::set& theElements); + + //! Adds OpenGL groups to ray-traced scene geometry. + Standard_Boolean AddRaytraceGroups (const OpenGl_Structure* theStructure, + const Standard_Integer theStructMatId, + const Standard_ShortReal* theTransform); //! Adds OpenGL primitive array to ray-traced scene geometry. OpenGl_TriangleSet* AddRaytracePrimitiveArray ( diff --git a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx old mode 100755 new mode 100644 index f336ac9ed7..3c408cebbe --- a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx +++ b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx @@ -105,8 +105,6 @@ Standard_Boolean OpenGl_Workspace::UpdateRaytraceGeometry (GeomUpdateMode theMod for (aStructIt.Init (aStructArray (anIndex)); aStructIt.More(); aStructIt.Next()) { - Standard_ShortReal* aTransform (NULL); - const OpenGl_Structure* aStructure = aStructIt.Value(); if (theMode == OpenGl_GUM_CHECK) @@ -142,22 +140,8 @@ Standard_Boolean OpenGl_Workspace::UpdateRaytraceGeometry (GeomUpdateMode theMod if (!aStructure->IsRaytracable()) continue; - if (aStructure->Transformation()->mat != NULL) - { - if (aTransform == NULL) - aTransform = new Standard_ShortReal[16]; - - for (Standard_Integer i = 0; i < 4; ++i) - for (Standard_Integer j = 0; j < 4; ++j) - { - aTransform[j * 4 + i] = aStructure->Transformation()->mat[i][j]; - } - } - - AddRaytraceStructure (aStructure, aTransform, anElements); + AddRaytraceStructure (aStructure, anElements); } - - delete [] aTransform; } } } @@ -311,8 +295,7 @@ void CreateMaterial (const OPENGL_SURF_PROP& theProp, OpenGl_RaytraceMaterial& t // function : AddRaytraceStructure // purpose : Adds OpenGL structure to ray-traced scene geometry // ======================================================================= -Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* theStructure, - const Standard_ShortReal* theTransform, std::set& theElements) +Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* theStructure, std::set& theElements) { theElements.insert (theStructure); @@ -335,6 +318,41 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* myRaytraceGeometry.Materials.push_back (aStructMaterial); } + Standard_ShortReal aStructTransformArr[16]; + Standard_ShortReal* aStructTransform = NULL; + if (theStructure->Transformation()->mat != NULL) + { + aStructTransform = aStructTransformArr; + for (Standard_Integer i = 0; i < 4; ++i) + { + for (Standard_Integer j = 0; j < 4; ++j) + { + aStructTransform[j * 4 + i] = theStructure->Transformation()->mat[i][j]; + } + } + } + + AddRaytraceGroups (theStructure, aStructMatID, aStructTransform); + + // Process all connected OpenGL structures + for (OpenGl_ListOfStructure::Iterator anIts (theStructure->ConnectedStructures()); anIts.More(); anIts.Next()) + { + if (anIts.Value()->IsRaytracable()) + AddRaytraceGroups (anIts.Value(), aStructMatID, aStructTransform); + } + + myStructureStates[theStructure] = theStructure->ModificationState(); + return Standard_True; +} + +// ======================================================================= +// function : AddRaytraceGroups +// purpose : Adds OpenGL groups to ray-traced scene geometry +// ======================================================================= +Standard_Boolean OpenGl_Workspace::AddRaytraceGroups (const OpenGl_Structure* theStructure, + const Standard_Integer theStructMatId, + const Standard_ShortReal* theTransform) +{ for (OpenGl_Structure::GroupIterator aGroupIter (theStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next()) { // Get group material @@ -349,7 +367,7 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* myRaytraceGeometry.Materials.push_back (aGroupMaterial); } - Standard_Integer aMatID = aGroupMatID < 0 ? aStructMatID : aGroupMatID; + Standard_Integer aMatID = aGroupMatID < 0 ? theStructMatId : aGroupMatID; if (aMatID < 0) { @@ -421,32 +439,6 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* } } - Standard_ShortReal* aTransform = NULL; - - // Process all connected OpenGL structures - for (OpenGl_ListOfStructure::Iterator anIts (theStructure->ConnectedStructures()); anIts.More(); anIts.Next()) - { - if (anIts.Value()->Transformation()->mat != NULL) - { - if (aTransform == NULL) - aTransform = new Standard_ShortReal[16]; - - for (Standard_Integer i = 0; i < 4; ++i) - for (Standard_Integer j = 0; j < 4; ++j) - { - aTransform[j * 4 + i] = - anIts.Value()->Transformation()->mat[i][j]; - } - } - - if (anIts.Value()->IsRaytracable()) - AddRaytraceStructure (anIts.Value(), aTransform != NULL ? aTransform : theTransform, theElements); - } - - delete[] aTransform; - - myStructureStates[theStructure] = theStructure->ModificationState(); - return Standard_True; } diff --git a/src/PrsMgr/FILES b/src/PrsMgr/FILES index bc7af4c88d..6c58657be7 100644 --- a/src/PrsMgr/FILES +++ b/src/PrsMgr/FILES @@ -1 +1,2 @@ PrsMgr_ListOfPresentations.hxx +PrsMgr_ListOfPresentableObjects.hxx diff --git a/src/PrsMgr/PrsMgr.cdl b/src/PrsMgr/PrsMgr.cdl index e6f817ec66..990c74914d 100644 --- a/src/PrsMgr/PrsMgr.cdl +++ b/src/PrsMgr/PrsMgr.cdl @@ -57,6 +57,7 @@ is deferred class PresentableObject; imported ListOfPresentations; + imported ListOfPresentableObjects; class Prs; diff --git a/src/AIS/AIS_MultipleConnectedShape.lxx b/src/PrsMgr/PrsMgr_ListOfPresentableObjects.hxx similarity index 53% rename from src/AIS/AIS_MultipleConnectedShape.lxx rename to src/PrsMgr/PrsMgr_ListOfPresentableObjects.hxx index 91cf03309a..873aec42e2 100644 --- a/src/AIS/AIS_MultipleConnectedShape.lxx +++ b/src/PrsMgr/PrsMgr_ListOfPresentableObjects.hxx @@ -1,7 +1,6 @@ -// Created on: 1997-04-22 -// Created by: Guest Design -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Created on: 2014-08-11 +// Created by: duv +// Copyright (c) 2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -14,16 +13,14 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// +#ifndef _PrsMgr_ListOfPresentableObjects_HeaderFile +#define _PrsMgr_ListOfPresentableObjects_HeaderFile -inline void AIS_MultipleConnectedShape::Set(const TopoDS_Shape& ashap) -{ - myShape = ashap; -} +#include +#include -inline const TopoDS_Shape& -AIS_MultipleConnectedShape::Shape() const -{ - return myShape; -} +typedef NCollection_List PrsMgr_ListOfPresentableObjects; +typedef NCollection_List::Iterator PrsMgr_ListOfPresentableObjectsIter; + +#endif // _PrsMgr_ListOfPresentableObjects_HeaderFile diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cdl b/src/PrsMgr/PrsMgr_PresentableObject.cdl index 9b88fe54ff..c4a26f70de 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cdl +++ b/src/PrsMgr/PrsMgr_PresentableObject.cdl @@ -48,23 +48,26 @@ deferred class PresentableObject from PrsMgr inherits TShared from MMgt -- creation of new interactive objects. uses - Presentation from PrsMgr, - Presentation from Prs3d, - Presentations from PrsMgr, - PresentationManager from PrsMgr, - PresentationManager3d from PrsMgr, - TypeOfPresentation3d from PrsMgr, - DataStructureManager from Graphic3d, - Projector from Prs3d, - Transformation from Geom, - ListOfInteger from TColStd, - Location from TopLoc, - ClipPlane_Handle from Graphic3d, - SequenceOfHClipPlane from Graphic3d, + Presentation from PrsMgr, + Presentation from Prs3d, + Presentations from PrsMgr, + PresentationManager from PrsMgr, + PresentationManager3d from PrsMgr, + TypeOfPresentation3d from PrsMgr, + ListOfPresentableObjects from PrsMgr, + PresentableObjectPointer from PrsMgr, + DataStructureManager from Graphic3d, + Projector from Prs3d, + Transformation from Geom, + ListOfInteger from TColStd, + Location from TopLoc, + ClipPlane_Handle from Graphic3d, + SequenceOfHClipPlane from Graphic3d, -- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) - TransModeFlags from Graphic3d, - Pnt from gp, - CTransPersStruct from Graphic3d + TransModeFlags from Graphic3d, + Pnt from gp, + Trsf from gp, + CTransPersStruct from Graphic3d -- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) raises @@ -73,6 +76,7 @@ is Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView); + ---C++: alias "Standard_EXPORT virtual ~PrsMgr_PresentableObject();" ---Category: deferred methods. -- @@ -149,7 +153,7 @@ is -- is static private; Presentations(me : mutable) returns Presentations from PrsMgr - is static protected; + is static; ---C++: return & TypeOfPresentation3d(me) returns TypeOfPresentation3d from PrsMgr @@ -218,19 +222,30 @@ is ToBeUpdated(me;ListOfMode : out ListOfInteger from TColStd); ---Purpose: gives the list of modes which are flagged "to be updated". - SetLocation(me:mutable;aLoc:Location from TopLoc) is virtual; + SetLocalTransformation(me:mutable; theTransformation:Trsf from gp) is virtual; + ---Purpose: Sets local transformation to theTransformation. + + SetCombinedParentTransform(me:mutable; theTransformation:Trsf from gp) is virtual protected; + ---Purpose: Sets myCombinedParentTransform to theTransformation. Thus object receives transformation + -- from parent node and able to derive its own. - HasLocation(me) returns Boolean from Standard; + HasTransformation(me) returns Boolean from Standard; + ---Purpose: Returns true if object has a transformation that is different from the identity. - Location(me) returns any Location from TopLoc; + LocalTransformation(me) returns any Trsf from gp; + ---C++: inline + ---C++: return const& + + Transformation(me) returns any Trsf from gp; ---C++: inline ---C++: return const& - ResetLocation(me:mutable) is virtual; + ResetTransformation(me:mutable) is virtual; + ---Purpose: resets local transformation to identity. - UpdateLocation(me:mutable) is virtual; + UpdateTransformation(me:mutable) is virtual; - UpdateLocation(me:mutable;P : Presentation from Prs3d) is virtual; + UpdateTransformation(me:mutable;P : Presentation from Prs3d) is virtual; SetZLayer ( me : mutable; thePrsMgr : PresentationManager from PrsMgr; @@ -287,6 +302,26 @@ is ---Purpose: Returns true if object has mutable nature (content or location are be changed regularly). -- Mutable object will be managed in different way than static onces (another optimizations). + AddChild ( me : mutable; + theObject : PresentableObject from PrsMgr ) is virtual; + --- Purpose: Makes theObject child of current object in scene hierarchy. + + RemoveChild ( me : mutable; + theObject : PresentableObject from PrsMgr ) is virtual; + --- Purpose: Removes theObject from children of current object in scene hierarchy. + + Children (me) returns ListOfPresentableObjects from PrsMgr is static; + ---C++: return const& + --- Purpose: Returns children of the current object. + + HasOwnPresentations (me) returns Boolean from Standard is static; + ---C++: return const + --- Purpose: Returns true if object should have own presentations. + + Parent (me) returns PresentableObjectPointer from PrsMgr is static; + ---C++: return const + --- Purpose: Returns parent of current object in scene hierarchy. + UpdateClipping (me : mutable) is virtual protected; ---Purpose: General virtual method for internal update of presentation state -- when some modifications on list of clip planes occurs. Base @@ -295,11 +330,21 @@ is fields myPresentations: Presentations from PrsMgr is protected; myTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr is protected; - myLocation : Location from TopLoc is protected; myClipPlanes : SequenceOfHClipPlane from Graphic3d is protected; myTransformPersistence : CTransPersStruct from Graphic3d; myIsMutable : Boolean from Standard is protected; + + myHasOwnPresentations : Boolean from Standard is protected; -- shows if object should have own presentations. + + myParent : PresentableObjectPointer from PrsMgr; -- Reference to parent object in scene hierarchy. + + myLocalTransformation : Trsf from gp; -- Own transformation of presentable object. + myTransformation : Trsf from gp; -- Combined transformation of presentable object. + myCombinedParentTransform : Trsf from gp; -- Combined transformation of presentable object excepting local transformation. + + myChildren : ListOfPresentableObjects from PrsMgr; -- Child objects in scene hierarchy. + friends class Presentation from PrsMgr, class PresentationManager from PrsMgr, diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index b1535eb5ef..84c928485e 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -29,7 +29,9 @@ //======================================================================= PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType) : myTypeOfPresentation3d (theType), - myIsMutable (Standard_False) + myIsMutable (Standard_False), + myHasOwnPresentations (Standard_True), + myParent (NULL) { myTransformPersistence.Flag = 0; myTransformPersistence.Point.x = 0.0; @@ -37,6 +39,20 @@ PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentat myTransformPersistence.Point.z = 0.0; } +//======================================================================= +//function : ~PrsMgr_PresentableObject +//purpose : destructor +//======================================================================= +PrsMgr_PresentableObject::~PrsMgr_PresentableObject() +{ + gp_Trsf anIdentity; + for (PrsMgr_ListOfPresentableObjectsIter anIter (myChildren); anIter.More(); anIter.Next()) + { + anIter.Value()->SetCombinedParentTransform (anIdentity); + anIter.Value()->myParent = NULL; + } +} + //======================================================================= //function : Fill //purpose : @@ -47,7 +63,7 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t { Handle(Prs3d_Presentation) aStruct3d = thePrs->Presentation(); Compute (thePrsMgr, aStruct3d, theMode); - UpdateLocation (aStruct3d); + UpdateTransformation (aStruct3d); aStruct3d->SetClipPlanes (myClipPlanes); aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint()); } @@ -148,12 +164,12 @@ PrsMgr_Presentations& PrsMgr_PresentableObject::Presentations() { } //======================================================================= -//function : HasLocation +//function : HasTransformation //purpose : //======================================================================= -Standard_Boolean PrsMgr_PresentableObject::HasLocation() const +Standard_Boolean PrsMgr_PresentableObject::HasTransformation() const { - return !Location().IsIdentity(); + return myTransformation.Form() != gp_Identity; } //======================================================================= @@ -217,64 +233,64 @@ void PrsMgr_PresentableObject::SetTypeOfPresentation (const PrsMgr_TypeOfPresent } //======================================================================= -//function : SetLocation +//function : SetLocalTransformation //purpose : WARNING : use with only 3D objects... //======================================================================= -void PrsMgr_PresentableObject::SetLocation(const TopLoc_Location& aLoc) +void PrsMgr_PresentableObject::SetLocalTransformation (const gp_Trsf& theTransformation) { - if(aLoc.IsIdentity()) return; - myLocation = aLoc; - UpdateLocation(); + myLocalTransformation = theTransformation; + UpdateTransformation(); } //======================================================================= -//function : ReSetLocation +//function : ResetTransformation //purpose : //======================================================================= -void PrsMgr_PresentableObject::ResetLocation() +void PrsMgr_PresentableObject::ResetTransformation() { - TopLoc_Location aLoc; - Handle(Geom_Transformation) aTrsf = new Geom_Transformation (aLoc.Transformation()); - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) - { - myPresentations (aPrsIter).Presentation()->Transform (aTrsf); - } - myLocation = aLoc; + SetLocalTransformation (gp_Trsf()); } //======================================================================= -//function : UpdateLocation +//function : SetCombinedParentTransform +//purpose : +//======================================================================= +void PrsMgr_PresentableObject::SetCombinedParentTransform (const gp_Trsf& theTransformation) +{ + myCombinedParentTransform = theTransformation; + UpdateTransformation(); +} + +//======================================================================= +//function : UpdateTransformation //purpose : //======================================================================= -void PrsMgr_PresentableObject::UpdateLocation() +void PrsMgr_PresentableObject::UpdateTransformation() { - if (!HasLocation()) - { - return; - } + myTransformation = myCombinedParentTransform * myLocalTransformation; + Handle(Geom_Transformation) aTrsf = new Geom_Transformation (myTransformation); - Handle(Geom_Transformation) aTrsf = new Geom_Transformation (Location().Transformation()); - if (aTrsf->Trsf().Form() == gp_Identity) + for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) { - return; + myPresentations (aPrsIter).Presentation()->Transform (aTrsf); } + + PrsMgr_ListOfPresentableObjectsIter anIter (myChildren); - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (; anIter.More(); anIter.Next()) { - myPresentations (aPrsIter).Presentation()->Transform (aTrsf); + anIter.Value()->SetCombinedParentTransform (myTransformation); } } //======================================================================= -//function : UpdateLocation +//function : UpdateTransformation //purpose : //======================================================================= -void PrsMgr_PresentableObject::UpdateLocation(const Handle(Prs3d_Presentation)& P) +void PrsMgr_PresentableObject::UpdateTransformation(const Handle(Prs3d_Presentation)& P) { - if(myLocation.IsIdentity()) return; - Handle(Geom_Transformation) G = new Geom_Transformation(Location().Transformation()); - P->Transform(G); - + Handle(Geom_Transformation) aTrsf = new Geom_Transformation (myTransformation); + P->Transform (aTrsf); } //======================================================================= @@ -328,6 +344,42 @@ gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const return gp_Pnt( myTransformPersistence.Point.x, myTransformPersistence.Point.y, myTransformPersistence.Point.z ); } +//======================================================================= +//function : AddChild +//purpose : +//======================================================================= +void PrsMgr_PresentableObject::AddChild (const Handle(PrsMgr_PresentableObject)& theObject) +{ + Handle(PrsMgr_PresentableObject) aHandleGuard = theObject; + if (theObject->myParent != NULL) + { + theObject->myParent->RemoveChild (aHandleGuard); + } + + myChildren.Append (theObject); + theObject->myParent = this; + theObject->SetCombinedParentTransform (myTransformation); +} + +//======================================================================= +//function : RemoveChild +//purpose : +//======================================================================= +void PrsMgr_PresentableObject::RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject) +{ + PrsMgr_ListOfPresentableObjectsIter anIter (myChildren); + for (; anIter.More(); anIter.Next()) + { + if (anIter.Value() == theObject) + { + theObject->myParent = NULL; + theObject->SetCombinedParentTransform (gp_Trsf()); + myChildren.Remove (anIter); + break; + } + } +} + //======================================================================= //function : SetZLayer //purpose : diff --git a/src/PrsMgr/PrsMgr_PresentableObject.lxx b/src/PrsMgr/PrsMgr_PresentableObject.lxx index 4a27926598..86f34921ae 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.lxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.lxx @@ -18,8 +18,30 @@ inline PrsMgr_TypeOfPresentation3d PrsMgr_PresentableObject::TypeOfPresentation3 {return myTypeOfPresentation3d;} -inline const TopLoc_Location& PrsMgr_PresentableObject::Location() const -{return myLocation;} +inline const gp_Trsf& PrsMgr_PresentableObject::LocalTransformation() const +{ + return myLocalTransformation; +} + +inline const gp_Trsf& PrsMgr_PresentableObject::Transformation() const +{ + return myTransformation; +} + +inline const PrsMgr_ListOfPresentableObjects& PrsMgr_PresentableObject::Children() const +{ + return myChildren; +} + +inline const Standard_Boolean PrsMgr_PresentableObject::HasOwnPresentations() const +{ + return myHasOwnPresentations; +} + +inline const PrsMgr_PresentableObjectPointer PrsMgr_PresentableObject::Parent() const +{ + return myParent; +} inline const Graphic3d_SequenceOfHClipPlane& PrsMgr_PresentableObject::GetClipPlanes() const { diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cdl b/src/PrsMgr/PrsMgr_PresentationManager.cdl index 8bda94e299..970982d2b2 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cdl +++ b/src/PrsMgr/PrsMgr_PresentationManager.cdl @@ -199,36 +199,6 @@ is -- thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode. is static; - Place (me : mutable; - thePrsObject : PresentableObject from PrsMgr; - X, Y, Z : Length from Quantity; - theMode : Integer from Standard = 0) - ---Purpose: - -- Sets a position to move the presentable object - -- aPresentableObject to. This position is defined by the - -- lengths along the x, y and z axes: X, Y and Z respectively. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe display mode. - is static; - - Multiply (me : mutable; - thePrsObject : PresentableObject from PrsMgr; - theTransformation : Transformation from Geom; - theMode : Integer from Standard = 0) - ---Purpose: - -- Defines the transformation theTransformation for the presentable object thePrsObject. - -- thePrsObject has the display mode aMode; this has the default value of 0, that is, the wireframe display mode. - is static; - - Move (me : mutable; - thePrsObject : PresentableObject from PrsMgr; - X, Y, Z : Length from Quantity; - theMode : Integer from Standard = 0) - ---Purpose: - -- Sets a position to move the presentable object thePrsObject to. This position is defined by the lengths along the x, y and z axes: X, Y and Z respectively. - -- thePrsObject has the display mode aMode; this has the default value of 0, that is, the wireframe display mode. - is static; - StructureManager (me) returns StructureManager from Graphic3d is static; ---C++: inline diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 72028a7cce..a834ed4d03 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -43,24 +43,39 @@ PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_S void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) { - if (!HasPresentation (thePrsObj, theMode)) + if (thePrsObj->HasOwnPresentations()) { - AddPresentation (thePrsObj, theMode); - } + if (!HasPresentation (thePrsObj, theMode)) + { + AddPresentation (thePrsObj, theMode); + } - Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); - if (aPrs->MustBeUpdated()) - { - Update (thePrsObj, theMode); - } + Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); - if (myImmediateModeOn > 0) - { - AddToImmediateList (aPrs->Presentation()); + if (aPrs.IsNull()) return; + + if (aPrs->MustBeUpdated()) + { + Update (thePrsObj, theMode); + } + + if (myImmediateModeOn > 0) + { + AddToImmediateList (aPrs->Presentation()); + } + else + { + aPrs->Display(); + } } else { - aPrs->Display(); + thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode); + } + + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Display (anIter.Value(), theMode); } } @@ -71,6 +86,11 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject) void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Erase (anIter.Value(), theMode); + } + if (HasPresentation (thePrsObj, theMode)) { Presentation (thePrsObj, theMode)->Erase(); @@ -85,6 +105,11 @@ void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Clear (anIter.Value(), theMode); + } + if (HasPresentation (thePrsObj, theMode)) { Presentation (thePrsObj, theMode)->Clear(); @@ -95,11 +120,20 @@ void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& // function : SetVisibility // purpose : // ======================================================================= -void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePresentableObject, +void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode, const Standard_Boolean theValue) { - Presentation(thePresentableObject, theMode)->SetVisible (theValue); + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + SetVisibility (anIter.Value(), theMode, theValue); + } + if (!thePrsObj->HasOwnPresentations()) + { + return; + } + + Presentation (thePrsObj, theMode)->SetVisible (theValue); } // ======================================================================= @@ -109,11 +143,22 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Highlight (anIter.Value(), theMode); + } + if (!thePrsObj->HasOwnPresentations()) + { + return; + } + if (!HasPresentation (thePrsObj, theMode)) { AddPresentation (thePrsObj, theMode); } + if (!HasPresentation (thePrsObj, theMode)) return; + Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); if (aPrs->MustBeUpdated()) { @@ -139,6 +184,11 @@ void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObjec void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Unhighlight (anIter.Value(), theMode); + } + if (HasPresentation (thePrsObj, theMode)) { Presentation (thePrsObj, theMode)->Unhighlight(); @@ -153,6 +203,11 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present const Standard_Integer theMode, const Standard_Integer theNewPrior) const { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + SetDisplayPriority (anIter.Value(), theMode, theNewPrior); + } + if (HasPresentation (thePrsObj, theMode)) { Presentation (thePrsObj, theMode)->SetDisplayPriority (theNewPrior); @@ -166,6 +221,15 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) const { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Standard_Integer aPriority = DisplayPriority (anIter.Value(), theMode); + if (aPriority != 0) + { + return aPriority; + } + } + return HasPresentation (thePrsObj, theMode) ? Presentation (thePrsObj, theMode)->DisplayPriority() : 0; @@ -178,6 +242,14 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) const { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + if (IsDisplayed (anIter.Value(), theMode)) + { + return Standard_True; + } + } + return HasPresentation (thePrsObj, theMode) && Presentation (thePrsObj, theMode)->IsDisplayed(); } @@ -189,6 +261,14 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) const { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + if (IsHighlighted (anIter.Value(), theMode)) + { + return Standard_True; + } + } + return HasPresentation (thePrsObj, theMode) && Presentation (thePrsObj, theMode)->IsHighlighted(); } @@ -200,6 +280,10 @@ Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_ void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) const { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Update (anIter.Value(), theMode); + } if (!HasPresentation(thePrsObj, theMode)) { return; @@ -299,6 +383,9 @@ void PrsMgr_PresentationManager::AddToImmediateList (const Handle(Prs3d_Presenta Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode) const { + if (!thePrsObj->HasOwnPresentations()) + return Standard_False; + const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) { @@ -388,6 +475,14 @@ void PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_Present void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theLayerId) { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + SetZLayer (anIter.Value(), theLayerId); + } + if (!thePrsObj->HasOwnPresentations()) + { + return; + } PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) { @@ -405,6 +500,18 @@ void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObjec // ======================================================================= Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Standard_Integer aLayer = GetZLayer (anIter.Value()); + if (aLayer != -1) + { + return aLayer; + } + } + if (!thePrsObj->HasOwnPresentations()) + { + return -1; + } const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) { @@ -448,42 +555,6 @@ void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObjec Presentation (thePrsObj, theMode)->Transform (theTransformation); } -// ======================================================================= -// function : Place -// purpose : -// ======================================================================= -void PrsMgr_PresentationManager::Place (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Quantity_Length theX, - const Quantity_Length theY, - const Quantity_Length theZ, - const Standard_Integer theMode) -{ - Presentation (thePrsObj, theMode)->Place (theX, theY, theZ); -} - -// ======================================================================= -// function : Multiply -// purpose : -// ======================================================================= -void PrsMgr_PresentationManager::Multiply (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Handle(Geom_Transformation)& theTransformation, - const Standard_Integer theMode) -{ - Presentation (thePrsObj, theMode)->Multiply (theTransformation); -} - -// ======================================================================= -// function : Move -// purpose : -// ======================================================================= -void PrsMgr_PresentationManager::Move (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Quantity_Length theX, - const Quantity_Length theY, - const Quantity_Length theZ, - const Standard_Integer theMode) -{ - Presentation (thePrsObj, theMode)->Move (theX, theY, theZ); -} // ======================================================================= // function : Color @@ -493,11 +564,22 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& const Quantity_NameOfColor theColor, const Standard_Integer theMode) { + for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) + { + Color (anIter.Value(), theColor, theMode); + } + if (!thePrsObj->HasOwnPresentations()) + { + return; + } + if (!HasPresentation (thePrsObj, theMode)) { AddPresentation (thePrsObj, theMode); } + if (!HasPresentation (thePrsObj, theMode)) return; + Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); if (aPrs->MustBeUpdated()) { diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index b6785d51ab..a7099d5681 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -1675,7 +1675,7 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con di << argv[1] << " : No interactive object" << "\n"; return 1; } - AISObj->UnsetTransformation(); + AISObj->ResetTransformation(); if (!aContext->HasOpenedContext()) { aContext->OpenLocalContext(); } diff --git a/src/Select3D/Select3D_SensitiveEntity.cdl b/src/Select3D/Select3D_SensitiveEntity.cdl index c46a03d66b..866954303e 100644 --- a/src/Select3D/Select3D_SensitiveEntity.cdl +++ b/src/Select3D/Select3D_SensitiveEntity.cdl @@ -110,7 +110,7 @@ is ---Purpose: Returns true if this framework has a location defined. Location(me) returns Location from TopLoc is virtual; - ---C++: return const& + ---C++: return const ResetLocation(me:mutable) is virtual; ---Purpose: sets the location to Identity diff --git a/src/Select3D/Select3D_SensitiveEntity.cxx b/src/Select3D/Select3D_SensitiveEntity.cxx index e8d08bd9bb..913e715e98 100644 --- a/src/Select3D/Select3D_SensitiveEntity.cxx +++ b/src/Select3D/Select3D_SensitiveEntity.cxx @@ -120,9 +120,9 @@ void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc) //purpose : //======================================================================= -const TopLoc_Location& Select3D_SensitiveEntity::Location() const +const TopLoc_Location Select3D_SensitiveEntity::Location() const { - static TopLoc_Location anIdentity; + TopLoc_Location anIdentity; Handle(SelectBasics_EntityOwner) anOwner = OwnerId(); return anOwner.IsNull() ? anIdentity : anOwner->Location(); } diff --git a/src/SelectBasics/SelectBasics_EntityOwner.cdl b/src/SelectBasics/SelectBasics_EntityOwner.cdl index 576e4f353f..8f8039da18 100644 --- a/src/SelectBasics/SelectBasics_EntityOwner.cdl +++ b/src/SelectBasics/SelectBasics_EntityOwner.cdl @@ -60,7 +60,6 @@ is ResetLocation(me:mutable) is deferred; Location(me) returns Location from TopLoc is deferred; - ---C++: return const& diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cdl b/src/SelectMgr/SelectMgr_EntityOwner.cdl index d08eeadf11..38a5ca2398 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cdl +++ b/src/SelectMgr/SelectMgr_EntityOwner.cdl @@ -49,6 +49,12 @@ is returns EntityOwner from SelectMgr; ---Purpose: Constructs a framework with the selectable object -- anSO being attributed the selection priority aPriority. + + Create (theOwner : EntityOwner from SelectMgr; + aPriority : Integer=0) + returns EntityOwner from SelectMgr; + ---Purpose: Constructs a framework from existing one + -- anSO being attributed the selection priority aPriority. HasSelectable(me) returns Boolean from Standard; ---Purpose: Returns true if there is a selectable object to serve as an owner. @@ -56,7 +62,7 @@ is Selectable(me) returns any SelectableObject from SelectMgr ---Purpose: Returns a selectable object detected in the working context. raises NoSuchObject from Standard - is static; + is virtual; Set(me:mutable; aSO : SelectableObject) is static; ---Purpose: Sets the selectable object anSO to be used by the @@ -124,9 +130,6 @@ is SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined; ResetLocation(me:mutable) is redefined; Location(me) returns Location from TopLoc is redefined; - ---C++: return const& - - --very Internal method (to be used in selection process only...) diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index cc670f6246..692713c76d 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -37,6 +37,13 @@ myIsSelected (Standard_False) mySelectable = aSO.operator->(); } +SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority) +: + SelectBasics_EntityOwner(aPriority), + mySelectable (theOwner->mySelectable) +{ +} + //======================================================================= //function : About Selectable... @@ -106,25 +113,23 @@ void SelectMgr_EntityOwner:: Hilight(){} - //======================================================================= -//function : about Location +//function : about Transformation //purpose : //======================================================================= Standard_Boolean SelectMgr_EntityOwner::HasLocation() const { - return (HasSelectable() && mySelectable->HasLocation()); + return (HasSelectable() && mySelectable->HasTransformation()); } void SelectMgr_EntityOwner::SetLocation(const TopLoc_Location&) { } -const TopLoc_Location& SelectMgr_EntityOwner::Location() const +TopLoc_Location SelectMgr_EntityOwner::Location() const { - static TopLoc_Location anIdentity; - return HasSelectable() ? mySelectable->Location() : anIdentity; + return !HasSelectable() ? TopLoc_Location() : TopLoc_Location(mySelectable->Transformation()); } void SelectMgr_EntityOwner::ResetLocation() diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cdl b/src/SelectMgr/SelectMgr_SelectableObject.cdl index f1beb54812..5fe6db9b32 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cdl +++ b/src/SelectMgr/SelectMgr_SelectableObject.cdl @@ -53,7 +53,7 @@ is Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView); ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; - aMode : Integer) is deferred private; + aMode : Integer) is deferred; ---Purpose: Recovers and calculates any sensitive primitive, -- aSelection, available in Shape mode, specified by -- aMode. As a rule, these are sensitive faces. @@ -133,12 +133,12 @@ is ---C++: inline - ResetLocation(me:mutable) is redefined static; + ResetTransformation(me:mutable) is redefined static; - UpdateLocation(me:mutable) is redefined virtual; + UpdateTransformation(me:mutable) is redefined virtual; ---Purpose: Recomputes the location of the selection aSelection. - UpdateLocation(me:mutable;aSelection: Selection from SelectMgr) is virtual protected; + UpdateTransformation(me:mutable;aSelection: Selection from SelectMgr) is virtual protected; ---Level: Internal ---Purpose: Updates locations in all sensitive entities from -- and in corresponding entity owners. diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index 856ee5b170..bf2ce86f21 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -24,6 +24,7 @@ #include #include +#include #include static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq, @@ -160,13 +161,14 @@ void SelectMgr_SelectableObject //======================================================================= -//function : ReSetLocation +//function : ReSetTransformation //purpose : //======================================================================= -void SelectMgr_SelectableObject::ResetLocation() +void SelectMgr_SelectableObject::ResetTransformation() { TopLoc_Location aLoc; + TopLoc_Location aSelfLocation (Transformation()); // les selections Handle(Select3D_SensitiveEntity) SE; @@ -176,13 +178,13 @@ void SelectMgr_SelectableObject::ResetLocation() SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive())); if(!SE.IsNull()){ if(SE->HasLocation()) { - if( SE->Location()==myLocation){ + if( SE->Location()==aSelfLocation){ SE->ResetLocation(); const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId(); (*((Handle(SelectMgr_EntityOwner)*)&EO))->ResetLocation();} else{ const TopLoc_Location& iniloc =SE->Location(); - SE->SetLocation(iniloc*myLocation.Inverted()); + SE->SetLocation(iniloc*aSelfLocation.Inverted()); const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId(); (*((Handle(SelectMgr_EntityOwner)*)&EO))->SetLocation(SE->Location());} } @@ -191,15 +193,15 @@ void SelectMgr_SelectableObject::ResetLocation() Sel->UpdateStatus(SelectMgr_TOU_None); } - PrsMgr_PresentableObject::ResetLocation(); + PrsMgr_PresentableObject::ResetTransformation(); } //======================================================================= -//function : UpdateLocation +//function : UpdateTransformation //purpose : //======================================================================= -void SelectMgr_SelectableObject::UpdateLocation() +void SelectMgr_SelectableObject::UpdateTransformation() { Handle(Select3D_SensitiveEntity) SE; @@ -207,28 +209,29 @@ void SelectMgr_SelectableObject::UpdateLocation() const Handle(SelectMgr_Selection) & Sel = CurrentSelection(); Sel->UpdateStatus(SelectMgr_TOU_Partial); } - PrsMgr_PresentableObject::UpdateLocation(); + PrsMgr_PresentableObject::UpdateTransformation(); } //======================================================================= -//function : UpdateLocation +//function : UpdateTransformation //purpose : //======================================================================= -void SelectMgr_SelectableObject::UpdateLocation(const Handle(SelectMgr_Selection)& Sel) +void SelectMgr_SelectableObject::UpdateTransformation(const Handle(SelectMgr_Selection)& Sel) { + TopLoc_Location aSelfLocation (Transformation()); Handle(Select3D_SensitiveEntity) SE; - if(myLocation.IsIdentity()) return; + if(aSelfLocation.IsIdentity()) return; for(Sel->Init();Sel->More();Sel->Next()){ SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive())); if(!SE.IsNull()){ - SE->UpdateLocation(myLocation); + SE->UpdateLocation(aSelfLocation); const Handle(SelectBasics_EntityOwner)& aEOwner = SE->OwnerId(); Handle(SelectMgr_EntityOwner) aMgrEO = Handle(SelectMgr_EntityOwner)::DownCast (aEOwner); if (!aMgrEO.IsNull()) - aMgrEO->SetLocation (myLocation); + aMgrEO->SetLocation (aSelfLocation); } } } diff --git a/src/SelectMgr/SelectMgr_SelectionManager.cxx b/src/SelectMgr/SelectMgr_SelectionManager.cxx index 96465d811b..f0935758ac 100644 --- a/src/SelectMgr/SelectMgr_SelectionManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectionManager.cxx @@ -263,8 +263,8 @@ Activate(const Handle(SelectMgr_SelectableObject)& anObject, anObject->UpdateSelection(aMode); // pas de break expres... case SelectMgr_TOU_Partial: { - if(anObject->HasLocation()) - anObject->UpdateLocation(Sel); + if(anObject->HasTransformation()) + anObject->UpdateTransformation(Sel); Sel->UpdateStatus(SelectMgr_TOU_None); break; } @@ -302,8 +302,8 @@ Activate(const Handle(SelectMgr_SelectableObject)& anObject, anObject->UpdateSelection(aMode); case SelectMgr_TOU_Partial: { - if(anObject->HasLocation()) - anObject->UpdateLocation(Sel); + if(anObject->HasTransformation()) + anObject->UpdateTransformation(Sel); break; } default: @@ -580,11 +580,11 @@ RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject, if( SelectDebugModeOnSM() ) cout<<"\t Global Recalculation of selections"<UpdateSelection(); - anObject->UpdateLocation(); + anObject->UpdateTransformation(); } else if(anObject->HasSelection(aMode)){ anObject->UpdateSelection(aMode); - anObject->UpdateLocation(); + anObject->UpdateTransformation(); } return; } @@ -628,7 +628,7 @@ RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject, case SelectMgr_TOU_Full: anObject->UpdateSelection(curmode); // no break on purpose... case SelectMgr_TOU_Partial: - anObject->UpdateLocation(Sel); + anObject->UpdateTransformation(Sel); break; default: break; @@ -653,6 +653,17 @@ RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject, void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)& anObject, const Standard_Boolean ForceUpdate) { + PrsMgr_ListOfPresentableObjectsIter anIter (anObject->Children()); + for (; anIter.More(); anIter.Next()) + { + const Handle(SelectMgr_SelectableObject) aSelectable = Handle(SelectMgr_SelectableObject)::DownCast (anIter.Value()); + + if (!aSelectable.IsNull()) + { + Update (aSelectable, ForceUpdate); + } + } + Standard_Boolean wasrecomputed; for(anObject->Init();anObject->More();anObject->Next()){ @@ -663,7 +674,7 @@ void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject) case SelectMgr_TOU_Full: anObject->UpdateSelection(Sel->Mode()); // no break on purpose... case SelectMgr_TOU_Partial: - anObject->UpdateLocation(Sel); + anObject->UpdateTransformation(Sel); wasrecomputed = Standard_True; break; default: @@ -683,7 +694,7 @@ void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject) case SelectMgr_TOU_Full: anObject->UpdateSelection(Sel->Mode()); // no break on purpose... case SelectMgr_TOU_Partial: - anObject->UpdateLocation(Sel); + anObject->UpdateTransformation(Sel); wasrecomputed = Standard_True; break; default: @@ -725,7 +736,7 @@ Update(const Handle(SelectMgr_SelectableObject)& anObject, case SelectMgr_TOU_Full: anObject->UpdateSelection(Sel->Mode()); // no break on purpose... case SelectMgr_TOU_Partial: - anObject->UpdateLocation(Sel); + anObject->UpdateTransformation(Sel); wasrecomputed = Standard_True; break; default: @@ -739,8 +750,8 @@ Update(const Handle(SelectMgr_SelectableObject)& anObject, case SelectMgr_TOU_Full: anObject->UpdateSelection(Sel->Mode()); case SelectMgr_TOU_Partial: - if(anObject->HasLocation()) - anObject->UpdateLocation(Sel); + if(anObject->HasTransformation()) + anObject->UpdateTransformation(Sel); wasrecomputed = Standard_True; break; default: diff --git a/src/TPrsStd/TPrsStd_AxisDriver.cxx b/src/TPrsStd/TPrsStd_AxisDriver.cxx index 5cefbe7c61..03fdd3b1ec 100644 --- a/src/TPrsStd/TPrsStd_AxisDriver.cxx +++ b/src/TPrsStd/TPrsStd_AxisDriver.cxx @@ -70,7 +70,7 @@ Standard_Boolean TPrsStd_AxisDriver::Update (const TDF_Label& aLabel, aistrihed = new AIS_Axis(apt); else { aistrihed->SetComponent(apt); - aistrihed->ResetLocation(); + aistrihed->ResetTransformation(); aistrihed->SetToUpdate(); aistrihed->UpdateSelection(); } diff --git a/src/TPrsStd/TPrsStd_ConstraintDriver.cxx b/src/TPrsStd/TPrsStd_ConstraintDriver.cxx index 06b49866af..1898ad049a 100644 --- a/src/TPrsStd/TPrsStd_ConstraintDriver.cxx +++ b/src/TPrsStd/TPrsStd_ConstraintDriver.cxx @@ -165,7 +165,7 @@ Standard_Boolean TPrsStd_ConstraintDriver::Update (const TDF_Label& aLabel, } if (anAIS.IsNull()) return Standard_False; - anAIS->ResetLocation(); + anAIS->ResetTransformation(); anAIS->SetToUpdate(); anAIS->UpdateSelection(); diff --git a/src/TPrsStd/TPrsStd_GeometryDriver.cxx b/src/TPrsStd/TPrsStd_GeometryDriver.cxx index a120661a7c..369361f4f5 100644 --- a/src/TPrsStd/TPrsStd_GeometryDriver.cxx +++ b/src/TPrsStd/TPrsStd_GeometryDriver.cxx @@ -84,7 +84,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, ais1 = new AIS_Point(apt); else { ais1->SetComponent(apt); - ais1->ResetLocation(); + ais1->ResetTransformation(); ais1->SetToUpdate(); ais1->UpdateSelection(); } @@ -107,7 +107,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, ais2 = new AIS_Line(aln); else { ais2->SetLine(aln); - ais2->ResetLocation(); + ais2->ResetTransformation(); ais2->SetToUpdate(); ais2->UpdateSelection(); } @@ -131,7 +131,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, ais3 = new AIS_Circle(acir); else { ais3->SetCircle(acir); - ais3->ResetLocation(); + ais3->ResetTransformation(); ais3->SetToUpdate(); ais3->UpdateSelection(); } @@ -153,7 +153,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, if (ais.IsNull()) ais = new AIS_Shape(mkEdge); else { - ais->ResetLocation(); + ais->ResetTransformation(); ais->Set(mkEdge); ais->SetToUpdate(); ais->UpdateSelection(); diff --git a/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx b/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx index d99ca67d46..745c1f29e0 100644 --- a/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx +++ b/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx @@ -82,7 +82,7 @@ Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel, else { TopoDS_Shape oldShape = AISShape->Shape(); if(oldShape != S) { - AISShape->ResetLocation(); + AISShape->ResetTransformation(); #ifdef OPTIM_UPDATE Handle(AIS_InteractiveContext) ctx = AISShape->GetContext(); diff --git a/src/TPrsStd/TPrsStd_PlaneDriver.cxx b/src/TPrsStd/TPrsStd_PlaneDriver.cxx index c0302b860f..6c30f3dc42 100644 --- a/src/TPrsStd/TPrsStd_PlaneDriver.cxx +++ b/src/TPrsStd/TPrsStd_PlaneDriver.cxx @@ -63,7 +63,7 @@ Standard_Boolean TPrsStd_PlaneDriver::Update (const TDF_Label& aLabel, else { aisplane->SetComponent(apt); aisplane->SetCenter(pln.Location()); - aisplane->ResetLocation(); + aisplane->ResetTransformation(); aisplane->SetToUpdate(); aisplane->UpdateSelection(); } diff --git a/src/TPrsStd/TPrsStd_PointDriver.cxx b/src/TPrsStd/TPrsStd_PointDriver.cxx index c90a5b7ee9..2b2115ea87 100644 --- a/src/TPrsStd/TPrsStd_PointDriver.cxx +++ b/src/TPrsStd/TPrsStd_PointDriver.cxx @@ -63,7 +63,7 @@ Standard_Boolean TPrsStd_PointDriver::Update (const TDF_Label& aLabel, aistrihed = new AIS_Point(apt); else { aistrihed->SetComponent(apt); - aistrihed->ResetLocation(); + aistrihed->ResetTransformation(); aistrihed->SetToUpdate(); aistrihed->UpdateSelection(); } diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 7698ebd1ff..326c6814fb 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -3154,11 +3154,11 @@ static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** TheAISContext()->UpdateCurrentViewer(); } - TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Location() ); - TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Location() ); + TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() ); + TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() ); - myAisCrankArm ->ResetLocation(); - myAisPropeller->ResetLocation(); + myAisCrankArm ->ResetTransformation(); + myAisPropeller->ResetTransformation(); myAisCrankArm -> Set(myNewCrankArm ); myAisPropeller -> Set(myNewPropeller); diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 8e05ff422d..140462570d 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -117,9 +117,8 @@ #include #include -#include #include -#include +#include #include #include #include @@ -3498,13 +3497,13 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di, Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) { - di << argv[0] << "ERROR : use 'vinit' command before " << "\n"; + std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n"; return 1; } if (argc != 5) { - di << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n"; + std::cout << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n"; return 1; } @@ -3518,7 +3517,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di, Handle(AIS_InteractiveObject) anIObj; if (!aMap.IsBound2 (aName)) { - di << "Use 'vdisplay' before" << "\n"; + std::cout << "Use 'vdisplay' before" << "\n"; return 1; } else @@ -3528,7 +3527,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di, // not an AIS_InteractiveObject if (anIObj.IsNull()) { - di << argv[1] << " : Not an AIS interactive object" << "\n"; + std::cout << argv[1] << " : Not an AIS interactive object" << "\n"; return 1; } @@ -3545,12 +3544,12 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di, //=============================================================================================== //function : VConnect //purpose : Creates and displays AIS_ConnectedInteractive object from input object and location -//Draw arg : vconnect name Xo Yo Zo Xu Xv Xw Zu Zv Zw object1 object2 ... [color=NAME] +//Draw arg : vconnect name Xo Yo Zo object1 object2 ... [color=NAME] //=============================================================================================== -static Standard_Integer VConnect(Draw_Interpretor& /*di*/, - Standard_Integer argc, - const char ** argv) +static Standard_Integer VConnect (Draw_Interpretor& /*di*/, + Standard_Integer argc, + const char ** argv) { // Check the viewer Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); @@ -3560,16 +3559,16 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/, return 1; // TCL_ERROR } // Check argumnets - if (argc < 12) + if (argc < 6) { - std::cout << "vconnect error: expect at least 11 arguments\n"; + std::cout << "vconnect error: expect at least 5 arguments\n"; return 1; // TCL_ERROR } // Get values Standard_Integer anArgIter = 1; TCollection_AsciiString aName (argv[anArgIter++]); - Handle(AIS_InteractiveObject) anOriginObject; + Handle(AIS_MultipleConnectedInteractive) anOriginObject; TCollection_AsciiString aColorString (argv[argc-1]); Standard_CString aColorName = ""; Standard_Boolean hasColor = Standard_False; @@ -3581,23 +3580,24 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/, } Handle(AIS_InteractiveObject) anObject; - // AIS_ConnectedInteractive - if (argc == 12 || (argc == 13 && hasColor)) + // AIS_MultipleConnectedInteractive + const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc; + for (Standard_Integer i = 5; i < aNbShapes; ++i) { - TCollection_AsciiString anOriginObjectName(argv[11]); + TCollection_AsciiString anOriginObjectName (argv[i]); if (aName.IsEqual (anOriginObjectName)) { - std::cout << "vconnect error: equal names for connected objects\n"; - return 1; // TCL_ERROR + std::cout << "vconnect error: equal names for connected objects\n"; + continue; } if (GetMapOfAIS().IsBound2 (anOriginObjectName)) { Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName); - anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj); - if (anOriginObject.IsNull()) + anObject = Handle(AIS_InteractiveObject)::DownCast(anObj); + if (anObject.IsNull()) { std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n"; - return 1; // TCL_ERROR + continue; } } else @@ -3607,101 +3607,38 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/, if (aTDShape.IsNull()) { std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n"; - return 1; // TCL_ERROR - } - anOriginObject = new AIS_Shape (aTDShape); - if (hasColor) - { - anOriginObject->SetColor (ViewerTest::GetColorFromName (aColorName)); - } - } - } - // AIS_MultipleConnectedInteractive - else - { - const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc; - for (Standard_Integer i = 11; i < aNbShapes; ++i) - { - TCollection_AsciiString anOriginObjectName (argv[i]); - if (aName.IsEqual (anOriginObjectName)) - { - std::cout << "vconnect error: equal names for connected objects\n"; continue; } - if (GetMapOfAIS().IsBound2 (anOriginObjectName)) - { - Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName); - anObject = Handle(AIS_InteractiveObject)::DownCast(anObj); - if (anObject.IsNull()) - { - std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n"; - continue; - } - } - else - { - Standard_CString aName = anOriginObjectName.ToCString(); - TopoDS_Shape aTDShape = DBRep::Get (aName); - if (aTDShape.IsNull()) - { - std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n"; - continue; - } - anObject = new AIS_Shape (aTDShape); - anObject->SetColor (ViewerTest::GetColorFromName (aColorName)); - } - if (anOriginObject.IsNull()) - { - anOriginObject = new AIS_MultipleConnectedInteractive(); - Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject)->Connect (anObject); - } - else - { - Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject)->Connect (anObject); - } + anObject = new AIS_Shape (aTDShape); + anObject->SetColor (ViewerTest::GetColorFromName (aColorName)); } + if (anOriginObject.IsNull()) { - std::cout << "vconect error : can't connect input objects\n"; - return 1; // TCL_ERROR + anOriginObject = new AIS_MultipleConnectedInteractive(); } + + anOriginObject->Connect (anObject); + } + if (anOriginObject.IsNull()) + { + std::cout << "vconect error : can't connect input objects\n"; + return 1; // TCL_ERROR } // Get location data Standard_Real aXo = Draw::Atof (argv[anArgIter++]); Standard_Real aYo = Draw::Atof (argv[anArgIter++]); Standard_Real aZo = Draw::Atof (argv[anArgIter++]); - Standard_Real aXu = Draw::Atof (argv[anArgIter++]); - Standard_Real aXv = Draw::Atof (argv[anArgIter++]); - Standard_Real aXw = Draw::Atof (argv[anArgIter++]); - Standard_Real aZu = Draw::Atof (argv[anArgIter++]); - Standard_Real aZv = Draw::Atof (argv[anArgIter++]); - Standard_Real aZw = Draw::Atof (argv[anArgIter++]); // Create transformation - gp_Pnt aPoint(aXo, aYo, aZo); - gp_Dir anXDir(aXu, aXv, aXw), aZDir(aZu, aZv, aZw); - if(!anXDir.IsNormal(aZDir, Precision::Angular())) - { - std::cout << "vconnect error : XDir expects to be normal to ZDir\n"; - return 1; // TCL_ERROR - } - gp_Ax3 anAx3(aPoint, aZDir, anXDir); + gp_Vec aTranslation (aXo, aYo, aZo); + gp_Trsf aTrsf; - aTrsf.SetTransformation(anAx3); - TopLoc_Location aLocation(aTrsf); + aTrsf.SetTranslationPart (aTranslation); + TopLoc_Location aLocation (aTrsf); - // Create connected object - Handle(AIS_ConnectedInteractive) aConnected = new AIS_ConnectedInteractive(); - Handle(AIS_MultipleConnectedInteractive) anOrigin = Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject); - if (anOrigin.IsNull()) - { - aConnected->Connect (anOriginObject, aLocation); - } - else - { - aConnected->Connect (anOrigin, aLocation); - } + anOriginObject->SetLocalTransformation (aTrsf); // Check if there is another object with given name // and remove it from context @@ -3714,179 +3651,87 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/, } // Bind connected object to its name - GetMapOfAIS().Bind (aConnected, aName); + GetMapOfAIS().Bind (anOriginObject, aName); // Display connected object - TheAISContext()->Display (aConnected); + TheAISContext()->Display (anOriginObject); return 0; } //=============================================================================================== -//function : VConnectShape -//purpose : Creates and displays AIS_ConnectedShape from input shape and location -//Draw arg : vconnectsh name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME] +//function : VConnectTo +//purpose : Creates and displays AIS_ConnectedInteractive object from input object and location +//Draw arg : vconnectto name Xo Yo Zo object //=============================================================================================== -static Standard_Integer VConnectShape(Draw_Interpretor& /*di*/, - Standard_Integer argc, - const char ** argv) +static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/, + Standard_Integer argc, + const char ** argv) { // Check the viewer Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) { - std::cout << "vconnectsh error : call vinit before\n"; + std::cout << "vconnect error : call vinit before\n"; return 1; // TCL_ERROR } - // Check argumnets - if (argc < 12) + // Check argumnets + if (argc != 6) { - std::cout << "vconnectsh error: expect at least 11 arguments\n"; + std::cout << "vconnect error: expect at least 5 arguments\n"; return 1; // TCL_ERROR } // Get values Standard_Integer anArgIter = 1; TCollection_AsciiString aName (argv[anArgIter++]); - Handle(AIS_InteractiveObject) anOriginShape; - TCollection_AsciiString aColorString(argv[argc-1]); - Standard_CString aColorName = ""; - Standard_Boolean hasColor = Standard_False; - if (aColorString.Search ("color=") != -1) + Handle(AIS_InteractiveObject) anOriginObject; + + TCollection_AsciiString anOriginObjectName(argv[5]); + if (aName.IsEqual (anOriginObjectName)) { - hasColor = Standard_True; - aColorString.Remove (1, 6); - aColorName = aColorString.ToCString(); + std::cout << "vconnect error: equal names for connected objects\n"; + return 1; // TCL_ERROR } - Handle(AIS_Shape) aShape; - - // AIS_ConnectedShape - if (argc == 12 || (argc == 13 && hasColor)) + if (GetMapOfAIS().IsBound2 (anOriginObjectName)) { - TCollection_AsciiString anOriginShapeName (argv[11]); - if (aName.IsEqual (anOriginShapeName)) + Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName); + anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj); + if (anOriginObject.IsNull()) { - std::cout << "vconnectsh error: equal names for connected shapes\n"; + std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n"; return 1; // TCL_ERROR } - if (GetMapOfAIS().IsBound2 (anOriginShapeName)) - { - Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginShapeName); - anOriginShape = Handle(AIS_Shape)::DownCast(anObj); - if (anOriginShape.IsNull()) - { - std::cout << "Shape " << anOriginShapeName << " is used for non AIS viewer\n!"; - return 1; // TCL_ERROR - } - } - else - { - Standard_CString aName = anOriginShapeName.ToCString(); - TopoDS_Shape aTDShape = DBRep::Get (aName); - if (aTDShape.IsNull()) - { - std::cout << "vconnectsh error: object " << anOriginShapeName << " doesn't exist\n"; - return 1; // TCL_ERROR - } - anOriginShape = new AIS_Shape (aTDShape); - if (hasColor) - { - anOriginShape->SetColor (ViewerTest::GetColorFromName (aColorName)); - } - } } - // AIS_MultipleConnectedShape else { - const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc; - for (Standard_Integer i = 11; i < aNbShapes; ++i) + Standard_CString aName = anOriginObjectName.ToCString(); + TopoDS_Shape aTDShape = DBRep::Get (aName); + if (aTDShape.IsNull()) { - TCollection_AsciiString anOriginShapeName (argv[i]); - if (aName.IsEqual (anOriginShapeName)) - { - std::cout << "vconnectsh error: equal names for connected shapes\n"; - continue; - } - if (GetMapOfAIS().IsBound2 (anOriginShapeName)) - { - Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginShapeName); - aShape = Handle(AIS_Shape)::DownCast(anObj); - if (aShape.IsNull()) - { - std::cout << "Shape " << anOriginShapeName << " is used for non AIS viewer\n"; - continue; - } - } - else - { - Standard_CString aName = anOriginShapeName.ToCString(); - TopoDS_Shape aTDShape = DBRep::Get (aName); - if (aTDShape.IsNull()) - { - std::cout << "vconnectsh error: object " << anOriginShapeName << " doesn't exist\n"; - continue; - } - aShape = new AIS_Shape (aTDShape); - if (hasColor) - { - aShape->SetColor (ViewerTest::GetColorFromName (aColorName)); - } - } - if (anOriginShape.IsNull()) - { - anOriginShape = new AIS_MultipleConnectedShape (aShape->Shape()); - Handle(AIS_MultipleConnectedShape)::DownCast(anOriginShape)->Connect (aShape); - } - else - { - Handle(AIS_MultipleConnectedShape)::DownCast(anOriginShape)->Connect (aShape); - } - } - if (anOriginShape.IsNull()) - { - std::cout << "vconectsh error : can't connect input objects\n"; + std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n"; return 1; // TCL_ERROR } + anOriginObject = new AIS_Shape (aTDShape); } - - // Get location data + + // Get location data Standard_Real aXo = Draw::Atof (argv[anArgIter++]); Standard_Real aYo = Draw::Atof (argv[anArgIter++]); Standard_Real aZo = Draw::Atof (argv[anArgIter++]); - Standard_Real aXu = Draw::Atof (argv[anArgIter++]); - Standard_Real aXv = Draw::Atof (argv[anArgIter++]); - Standard_Real aXw = Draw::Atof (argv[anArgIter++]); - Standard_Real aZu = Draw::Atof (argv[anArgIter++]); - Standard_Real aZv = Draw::Atof (argv[anArgIter++]); - Standard_Real aZw = Draw::Atof (argv[anArgIter++]); // Create transformation - gp_Pnt aPoint(aXo, aYo, aZo); - gp_Dir anXDir(aXu, aXv, aXw), aZDir(aZu, aZv, aZw); - if(!anXDir.IsNormal(aZDir, Precision::Angular())) - { - std::cout << "vconnectsh error : XDir expects to be normal to ZDir\n"; - return 1; // TCL_ERROR - } - gp_Ax3 anAx3(aPoint, aZDir, anXDir); - gp_Trsf aTrsf; - aTrsf.SetTransformation(anAx3); - TopLoc_Location aLocation(aTrsf); + gp_Vec aTranslation (aXo, aYo, aZo); - // Create connected shape + gp_Trsf aTrsf; + aTrsf.SetTranslationPart (aTranslation); + Handle(AIS_ConnectedInteractive) aConnected; - Handle(AIS_Shape) anOrigin = Handle(AIS_Shape)::DownCast(anOriginShape); - if (!anOrigin.IsNull()) - { - aConnected = new AIS_ConnectedShape (anOrigin); - aConnected->Connect (anOrigin, aLocation); - } - else - { - aConnected = new AIS_ConnectedInteractive(); - aConnected->Connect (anOriginShape, aLocation); - } + + aConnected = new AIS_ConnectedInteractive(); + + aConnected->Connect (anOriginObject, aTrsf); // Check if there is another object with given name // and remove it from context @@ -3898,15 +3743,220 @@ static Standard_Integer VConnectShape(Draw_Interpretor& /*di*/, GetMapOfAIS().UnBind2(aName); } - // Bind connected shape to its name + // Bind connected object to its name GetMapOfAIS().Bind (aConnected, aName); - // Display connected shape + // Display connected object TheAISContext()->Display (aConnected); return 0; } +//======================================================================= +//function : VDisconnect +//purpose : +//======================================================================= +static Standard_Integer VDisconnect (Draw_Interpretor& di, + Standard_Integer argc, + const char ** argv) +{ + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n"; + return 1; + } + + if (argc != 3) + { + std::cout << "ERROR : Usage : " << argv[0] << " name object" << "\n"; + return 1; + } + + TCollection_AsciiString aName (argv[1]); + TCollection_AsciiString anObject (argv[2]); + Standard_Integer anObjectNumber = Draw::Atoi (argv[2]); + + // find objects + ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); + Handle(AIS_MultipleConnectedInteractive) anAssembly; + if (!aMap.IsBound2 (aName) ) + { + std::cout << "Use 'vdisplay' before" << "\n"; + return 1; + } + + anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName)); + if (anAssembly.IsNull()) + { + di << "Not an assembly" << "\n"; + return 1; + } + + Handle(AIS_InteractiveObject) anIObj; + if (!aMap.IsBound2 (anObject)) + { + // try to interpret second argument as child number + if (anObjectNumber > 0 && anObjectNumber <= anAssembly->Children().Size()) + { + Standard_Integer aCounter = 1; + for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next()) + { + if (aCounter == anObjectNumber) + { + anIObj = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + break; + } + ++aCounter; + } + } + else + { + std::cout << "Use 'vdisplay' before" << "\n"; + return 1; + } + } + + // if object was found by name + if (anIObj.IsNull()) + { + anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject)); + } + + anAssembly->Disconnect (anIObj); + aContext->UpdateCurrentViewer(); + + return 0; +} + +//======================================================================= +//function : VAddConnected +//purpose : +//======================================================================= +static Standard_Integer VAddConnected (Draw_Interpretor& di, + Standard_Integer argc, + const char ** argv) +{ + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + std::cout << argv[0] << "error : use 'vinit' command before " << "\n"; + return 1; + } + + if (argc != 6) + { + std::cout << argv[0] << " error: expect 5 arguments\n"; + return 1; + } + + TCollection_AsciiString aName (argv[1]); + TCollection_AsciiString anObject (argv[5]); + Standard_Real aX = Draw::Atof (argv[2]); + Standard_Real aY = Draw::Atof (argv[3]); + Standard_Real aZ = Draw::Atof (argv[4]); + + // find object + ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); + Handle(AIS_MultipleConnectedInteractive) anAssembly; + if (!aMap.IsBound2 (aName) ) + { + std::cout << "Use 'vdisplay' before" << "\n"; + return 1; + } + + anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName)); + if (anAssembly.IsNull()) + { + di << "Not an assembly" << "\n"; + return 1; + } + + Handle(AIS_InteractiveObject) anIObj; + if (!aMap.IsBound2 (anObject)) + { + std::cout << "Use 'vdisplay' before" << "\n"; + return 1; + } + + anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject)); + + gp_Trsf aTrsf; + aTrsf.SetTranslation (gp_Vec (aX, aY, aZ)); + + anAssembly->Connect (anIObj, aTrsf); + TheAISContext()->Display (anAssembly); + TheAISContext()->RecomputeSelectionOnly (anAssembly); + aContext->UpdateCurrentViewer(); + + return 0; +} + +//======================================================================= +//function : VListConnected +//purpose : +//======================================================================= +static Standard_Integer VListConnected (Draw_Interpretor& di, + Standard_Integer argc, + const char ** argv) +{ + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n"; + return 1; + } + + if (argc != 2) + { + std::cout << "ERROR : Usage : " << argv[0] << " name" << "\n"; + return 1; + } + + TCollection_AsciiString aName (argv[1]); + + // find object + ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); + Handle(AIS_MultipleConnectedInteractive) anAssembly; + if (!aMap.IsBound2 (aName) ) + { + std::cout << "Use 'vdisplay' before" << "\n"; + return 1; + } + + anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName)); + if (anAssembly.IsNull()) + { + std::cout << "Not an assembly" << "\n"; + return 1; + } + + std::cout << "Children of " << aName << ":\n"; + + Standard_Integer aCounter = 1; + for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next()) + { + if (GetMapOfAIS().IsBound1 (anIter.Value())) + { + TCollection_AsciiString aName = GetMapOfAIS().Find1 (anIter.Value()); + std::cout << aCounter << ") " << aName << " (" << anIter.Value()->DynamicType()->Name() << ")"; + } + + std::cout << aCounter << ") " << anIter.Value()->DynamicType()->Name(); + + Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (anIter.Value()); + if (!aConnected.IsNull() && !aConnected->ConnectedTo().IsNull() && aMap.IsBound1 (aConnected->ConnectedTo())) + { + std::cout << " connected to " << aMap.Find1 (aConnected->ConnectedTo()); + } + std::cout << std::endl; + + ++aCounter; + } + + return 0; +} + namespace { //! Checks if theMode is already turned on for theObj. @@ -5402,12 +5452,30 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands) __FILE__,VDrawPArray,group); theCommands.Add("vconnect", - "vconnect : name Xo Yo Zo Xu Xv Xw Zu Zv Zw object1 object2 ... [color=NAME]", + "vconnect : assembly_name Xo Yo Zo object1 object2 ..." + " Makes an assembly of object instances located in point (Xo Yo Zo).", __FILE__, VConnect, group); - theCommands.Add("vconnectsh", - "vconnectsh : name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME]", - __FILE__, VConnectShape, group); + theCommands.Add("vconnectto", + "vconnectto : instance_name Xo Yo Zo object" + " Makes an instance 'instance_name' of 'object' with position (Xo Yo Zo).", + __FILE__, VConnectTo,group); + + theCommands.Add("vdisconnect", + "vdisconnect assembly_name (object_name | object_number | 'all')" + " Disconnects all objects from assembly or disconnects object by name or number (use vlistconnected to enumerate assembly children).", + __FILE__,VDisconnect,group); + + theCommands.Add("vaddconnected", + "vaddconnected assembly_name object_name" + "Adds object to assembly.", + __FILE__,VAddConnected,group); + + theCommands.Add("vlistconnected", + "vlistconnected assembly_name" + "Lists objects in assembly.", + __FILE__,VListConnected,group); + theCommands.Add("vselmode", "vselmode : [object] mode_number is_turned_on=(1|0)\n" diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 345a2441e3..5d5e016582 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -6713,6 +6713,53 @@ static int VHighlightSelected (Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : VXRotate +//purpose : +//======================================================================= +static Standard_Integer VXRotate (Draw_Interpretor& di, + Standard_Integer argc, + const char ** argv) +{ + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + di << argv[0] << "ERROR : use 'vinit' command before " << "\n"; + return 1; + } + + if (argc != 3) + { + di << "ERROR : Usage : " << argv[0] << " name angle" << "\n"; + return 1; + } + + TCollection_AsciiString aName (argv[1]); + Standard_Real anAngle = Draw::Atof (argv[2]); + + // find object + ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); + Handle(AIS_InteractiveObject) anIObj; + if (!aMap.IsBound2 (aName) ) + { + di << "Use 'vdisplay' before" << "\n"; + return 1; + } + else + { + anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName)); + + gp_Trsf aTransform; + aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle); + aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart()); + + aContext->SetLocation (anIObj, aTransform); + aContext->UpdateCurrentViewer(); + } + + return 0; +} + //======================================================================= //function : ViewerCommands //purpose : @@ -7086,4 +7133,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) "Without arguments it shows if highlighting of selected objects is enabled now.", __FILE__,VHighlightSelected,group); + + theCommands.Add("vxrotate", + "vxrotate", + __FILE__,VXRotate,group); + } diff --git a/tests/bugs/vis/bug12121 b/tests/bugs/vis/bug12121 index 9c6af2fbef..dda4aca389 100755 --- a/tests/bugs/vis/bug12121 +++ b/tests/bugs/vis/bug12121 @@ -58,7 +58,7 @@ set y_refresh 10 restore [locate_data_file OCC12121-CrankArm.brep] obj vinit vdisplay obj -vconnectsh new 50 50 50 1 0 0 0 0 1 obj +vconnect new 50 50 50 obj vfit vmoveto $x1 $y1 set ColorObj1 [QAGetPixelColor ${x2} ${y2}] @@ -68,12 +68,12 @@ vselect $x1 $y1 set ColorObj2 [QAGetPixelColor ${x2} ${y2}] set ColorNew2 [QAGetPixelColor ${x3} ${y3}] -puts "Check vconnectsh command" -set status_vconnectsh 0 +puts "Check vconnect command" +set status_vconnect 0 if { ${ColorObj1} == ${ColorNew1} && ${ColorObj2} == ${ColorNew2} } { - set status_vconnectsh 0 + set status_vconnect 0 } else { - set status_vconnectsh 1 + set status_vconnect 1 } vselect ${x_refresh} ${y_refresh} @@ -124,7 +124,7 @@ vselect ${x_refresh} ${y_refresh} ##Resume puts "" -if { ${status_vconnectsh} == 0 } { +if { ${status_vconnect} == 1 } { puts "OK ${BugNumber}" } else { puts "Faulty ${BugNumber}" diff --git a/tests/bugs/vis/bug23422 b/tests/bugs/vis/bug23422 new file mode 100644 index 0000000000..477fb0b630 --- /dev/null +++ b/tests/bugs/vis/bug23422 @@ -0,0 +1,20 @@ +puts "============" +puts "CR23422" +puts "============" +puts "" +####################################################################### +# Selection problems when using SetLocation. +####################################################################### + +box b 50 50 50 +vinit +vsetdispmode 1 +vdisplay b +vtrihedron t + +vsetlocation b 30 30 130 + +vmoveto 240 150 + +set anImage ${imagedir}/${casename}.png +vdump ${anImage} diff --git a/tests/bugs/vis/bug24358 b/tests/bugs/vis/bug24358 index e6fb3cc8b7..d13af6161f 100644 --- a/tests/bugs/vis/bug24358 +++ b/tests/bugs/vis/bug24358 @@ -17,7 +17,7 @@ vinit View1 vclear vaxo vsetdispmode 1 -vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 +vconnect b1c -3 0 0 b1 b2 vfit vdump $Image1 diff --git a/tests/bugs/vis/bug24756 b/tests/bugs/vis/bug24756 new file mode 100644 index 0000000000..9b46631c53 --- /dev/null +++ b/tests/bugs/vis/bug24756 @@ -0,0 +1,18 @@ +puts "============" +puts "CR24756" +puts "============" +puts "" +####################################################################### +# AIS_ConnectedInteractive does not support nested AIS_ConnectedInteractive +####################################################################### + +vinit +box b 1 1 1 +vdisplay b +vconnectto b1 2 0 0 b +vconnectto b2 2 0 0 b1 +vsetlocation b1 2 1 0 +vfit + +set anImage ${imagedir}/${casename}.png +vdump ${anImage} diff --git a/tests/bugs/vis/bug24837_1 b/tests/bugs/vis/bug24837_1 new file mode 100644 index 0000000000..cffd324ab4 --- /dev/null +++ b/tests/bugs/vis/bug24837_1 @@ -0,0 +1,41 @@ +puts "============" +puts "CR24837_1" +puts "============" +puts "" +####################################################################### +# Visualization - revise design and implementation of connected Interactive Objects +####################################################################### + +pload MODELING VISUALIZATION +vinit +box b 1 1 1 +psphere s 0.5 +vdisplay b s +vsetlocation s 0 2.5 0 +box d 0.5 0.5 3 +box d2 0.5 3 0.5 +vdisplay d d2 +vconnectto b1 -2 0 0 b +vconnect z 2 0 0 b s +vconnect z2 4 0 0 d d2 +vconnect z3 6 0 0 z z2 +vconnect z4 10 0 0 z3 z2 +vfit +set anImage ${imagedir}/${casename}_1_1.png +vdump ${anImage} + +vaddconnected z4 0 4 0 s +vdisconnect z4 1 +vfit +set anImage ${imagedir}/${casename}_1_2.png +vdump ${anImage} + +vhlr on +set anImage ${imagedir}/${casename}_1_3.png +vdump ${anImage} + +vhlr off +vsetdispmode 1 +vmoveto 320 330 +set anImage ${imagedir}/${casename}_1_4.png +vdump ${anImage} diff --git a/tests/bugs/vis/bug24837_2 b/tests/bugs/vis/bug24837_2 new file mode 100644 index 0000000000..d3b99f8e96 --- /dev/null +++ b/tests/bugs/vis/bug24837_2 @@ -0,0 +1,38 @@ +puts "============" +puts "CR24837_2" +puts "============" +puts "" +####################################################################### +# Visualization - revise design and implementation of connected Interactive Objects +####################################################################### + +pload MODELING VISUALIZATION +box o1 -10 -10 -5 1 1 10 +box o2 10 10 -5 1 1 10 +box b1 0 0 0 1 2 3 +box b2 3 0 0 3 2 1 +vinit View1 +vclear +vtop +vsetdispmode 0 +vdisplay o1 o2 +vdisplay b1 b2 +vfit +vdrawtext "b1" 0 -3 3 255 25 25 2 0 000 0 14 1 Arial +vdrawtext "b2" 3 0 3 25 255 25 2 0 000 0 14 1 Arial +vdrawtext "bc_1" 0 -9 3 255 225 225 2 0 000 0 14 1 Arial +vdrawtext "bc_2" 3 -6 3 255 225 225 2 0 000 0 14 1 Arial +vsetdispmode 1 +set anImage ${imagedir}/${casename}_2_1.png +vdump ${anImage} + +vsetmaterial b1 b2 plastic +vsetcolor b1 RED +vsetcolor b2 GREEN +set anImage ${imagedir}/${casename}_2_2.png +vdump ${anImage} + +vsetlocation b1 0 -3 0 +vconnect bc 0 -6 0 b1 b2 +set anImage ${imagedir}/${casename}_2_3.png +vdump ${anImage} diff --git a/tests/bugs/vis/bug25103 b/tests/bugs/vis/bug25103 new file mode 100644 index 0000000000..edbfd9eabc --- /dev/null +++ b/tests/bugs/vis/bug25103 @@ -0,0 +1,48 @@ +puts "============" +puts "CR25103" +puts "============" +puts "" +####################################################################### +# Visualization - Regression in interactive detection +####################################################################### + +vinit +vsetdispmode 1 + +box wall1 1 8 8 +box wall2 1 8 8 +box wall3 16 8 1 + +vdisplay wall1 +vdisplay wall2 +vdisplay wall3 + +vsetlocation wall1 -10 0 0 +vsetlocation wall2 5 0 0 +vsetlocation wall3 -10 0 -1 + +vsetmaterial wall1 stone +vsetmaterial wall2 stone +vsetmaterial wall3 pewter + +vsetcolor wall1 red +vsetcolor wall2 green + +vright +vturnview 0 -0.3 0 +vfit + +set anImage ${imagedir}/${casename}_1.png +vdump ${anImage} + +# The next line should highlight the green box (wall2) but it does not +vmoveto 394 205 + +set anImage ${imagedir}/${casename}_2.png +vdump ${anImage} + +# The next line should not hit any object but it highlights the green box +vmoveto 264 205 + +set anImage ${imagedir}/${casename}_3.png +vdump ${anImage} diff --git a/tests/v3d/raytrace/connected b/tests/v3d/raytrace/connected index b53631d530..aac69bef39 100644 --- a/tests/v3d/raytrace/connected +++ b/tests/v3d/raytrace/connected @@ -12,12 +12,12 @@ vclear vrenderparams -rasterization vsetdispmode 1 vaxo -vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 +vconnect b1c -3 0 0 b1 b2 vfit vrotate 0.2 0.0 0.0 vfit vclear -vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 +vconnect b1c -3 0 0 b1 b2 # take snapshot with fixed pipeline vdump $::imagedir/${::casename}_OFF.png @@ -27,4 +27,4 @@ vrenderparams -raytrace vdump $::imagedir/${::casename}_rt1.png vclear -vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 +vconnect b1c -3 0 0 b1 b2 -- 2.20.1