}
else
{
- myShape->SetLocation (TopLoc_Location (myTrsf));
+ myShape->SetLocalTransformation (myTrsf);
}
TCollection_AsciiString aMessage (
}
else
{
- myShape->SetLocation (TopLoc_Location (myTrsf));
+ myShape->SetLocalTransformation (myTrsf);
}
myModelClipping_Z = m_ModelClipping_Z;
---Category: Object of type Shape
class Shape; --signature 0
- class ConnectedShape; --signature 1
- class MultipleConnectedShape; --signature 2
-
---Category: General Objects
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
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;
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 <aProjector>.
-- To be Used when the associated degenerated Presentations
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 <aProjector>.
- 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 <aProjector>.
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;
#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_Presentation.hxx>
-#include <OSD_Timer.hxx>
+
+#include <StdSelect_BRepOwner.hxx>
+
+#include <StdSelect.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_OrientedShapeMapHasher.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <BRepTools.hxx>
+#include <Precision.hxx>
+#include <AIS_Drawer.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdPrs_HLRPolyShape.hxx>
+#include <Prs3d_Drawer.hxx>
+
+#include <AIS_Shape.hxx>
+
+#include <NCollection_DataMap.hxx>
//=======================================================================
//=======================================================================
AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
AIS_InteractiveObject(aTypeOfPresentation3d)
-{
+{
SetHilightMode(0);
}
//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);
}
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
- if (!(HasLocation() || HasConnection()))
- {
- return;
- }
-
if (HasConnection())
{
thePrs->Clear (Standard_False);
}
}
- 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<Handle(Select3D_SensitiveEntity)> SensitiveList;
+ typedef NCollection_DataMap<TopoDS_Shape, SensitiveList, TopTools_OrientedShapeMapHasher>
+ 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);
+}
+++ /dev/null
--- 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;
+++ /dev/null
-// 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.
-
-// <g_design>
-
-
-#include <Standard_NotImplemented.hxx>
-
-#include <AIS_ConnectedShape.ixx>
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Drawer.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_HLRPolyShape.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Aspect_TypeOfDeflection.hxx>
-#include <BRepTools.hxx>
-#include <OSD_Timer.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <StdSelect.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
-#include <TopExp.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectBasics_EntityOwner.hxx>
-#include <AIS_MultipleConnectedShape.hxx>
-#include <Precision.hxx>
-#include <NCollection_DataMap.hxx>
-#include <NCollection_List.hxx>
-
-//=======================================================================
-//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"<<endl;
- cout << "newangl : " << newangl << " # de " << "prevangl : " << prevangl << endl;
-#endif
- BRepTools::Clean(SH);
- }
- myDrawer->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<Handle(Select3D_SensitiveEntity)> SensitiveList;
- typedef NCollection_DataMap<TopoDS_Shape, SensitiveList, TopTools_OrientedShapeMapHasher>
- 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<WithLocation=False> 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);
- }
-}
-
returns Location from TopLoc;
---Purpose:
-- Returns the location of the entity aniobj.
- ---C++: return const&
#include <Precision.hxx>
#include <AIS_Selection.hxx>
#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
-#include <AIS_ConnectedShape.hxx>
-#include <AIS_MultipleConnectedShape.hxx>
+#include <AIS_ConnectedInteractive.hxx>
+#include <AIS_MultipleConnectedInteractive.hxx>
#include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
#include <AIS_GlobalStatus.hxx>
#include <AIS_MapIteratorOfMapOfInteractive.hxx>
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);
{
if(anIObj.IsNull()) return;
- anIObj->ResetLocation();
+ anIObj->ResetTransformation();
mgrSelector->Update(anIObj,Standard_False);
}
{
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();
}
//=======================================================================
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)
{
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();
+ }
}
//=======================================================================
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 <postConcatenate> is FALSE.
- -- Note that the selection must be updated only at the end of
- -- object animation when <updateSelection> 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
myToRecomputeModes : ListOfInteger from TColStd is protected;
mystate : Integer from Standard;
- myHasTransformation : Boolean from Standard;
friends
mySelPriority(-1),
myDisplayMode (-1),
mySelectionMode(0),
-mystate(0),
-myHasTransformation(Standard_False)
+mystate(0)
{
Handle (AIS_InteractiveContext) Bid;
myCTXPtr = Bid.operator->();
}
}
-//=======================================================================
-//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 :
---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;
// 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();
{
return aSh;
}
- return BRO->Shape();
+ return BRO->Shape().Located (BRO->Location());
}
//==================================================
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;
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.
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;
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-// <g_design>
-
-
#include <Standard_NotImplemented.hxx>
#include <AIS_MultipleConnectedInteractive.ixx>
+#include <AIS_ConnectedInteractive.hxx>
+#include <AIS_InteractiveContext.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_Presentation.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Select3D_SensitiveEntity.hxx>
+#include <TopLoc_Location.hxx>
+#include <NCollection_DataMap.hxx>
+
+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;
}
//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);
}
//=======================================================================
//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());
}
//=======================================================================
//=======================================================================
Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
{
- return (myReferences.Length() != 0);
+ return (Children().Size() != 0);
}
//=======================================================================
void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
{
- Standard_Integer I = RangeInSeq (myReferences, anotherIObj);
- if (I != 0) {
- myReferences.Remove(I);
-
- }
+ RemoveChild (anotherIObj);
}
//=======================================================================
//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();
}
//=======================================================================
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 ) ;
}
//=======================================================================
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 <Handle(SelectMgr_EntityOwner), Handle(SelectMgr_EntityOwner)> 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);
+ }
+ }
+ }
}
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
-// <g_design>
-//=======================================================================
-//function : ConnectedTo
-//purpose :
-//=======================================================================
-
-inline const AIS_SequenceOfInteractive& AIS_MultipleConnectedInteractive::ConnectedTo() const
-{
- return myReferences;
-}
+++ /dev/null
--- 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;
+++ /dev/null
-// 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.
-
-// <g_design>
-
-
-#include <Standard_NotImplemented.hxx>
-
-#include <AIS_MultipleConnectedShape.ixx>
-
-
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Drawer.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_HLRPolyShape.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Aspect_TypeOfDeflection.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepTools.hxx>
-#include <BRepBndLib.hxx>
-#include <OSD_Timer.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
-#include <StdSelect.hxx>
-#include <Precision.hxx>
-
-//=======================================================================
-//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"<<endl;
- cout << "newangl : " << newangl << " # de " << "prevangl : " << prevangl << endl;
-#endif
- BRepTools::Clean(SH);
- }
- myDrawer->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"<<endl;
-
- Standard_Real aDeviationAngle = myDrawer->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);
-
-}
-
-
-
-
+++ /dev/null
-// 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.
-
-// <g_design>
-
-inline void AIS_MultipleConnectedShape::Set(const TopoDS_Shape& ashap)
-{
- myShape = ashap;
-}
-
-inline const TopoDS_Shape&
-AIS_MultipleConnectedShape::Shape() const
-{
- return myShape;
-}
-
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
uses
Axis2Placement from Geom,
+ Trsf from gp,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
NameOfColor from Quantity,
-- 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
//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);
}
//=======================================================================
is static private;
---Purpose: Returns the extreme coordinates found in the structure <me> 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;
//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
{
}
}
}
+}
+
+//=============================================================================
+//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);
+ }
}
}
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 :
OpenGl_ListOfStructure::Iterator its(myConnected);
while (its.More())
{
- its.Value()->Render(AWorkspace);
+ its.Value()->RenderGeometry (AWorkspace);
its.Next();
}
//! 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
Standard_Boolean UpdateRaytraceEnvironmentMap();
//! Adds OpenGL structure to ray-traced scene geometry.
- Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure,
- const Standard_ShortReal* theTransform, std::set<const OpenGl_Structure*>& theElements);
+ Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure, std::set<const OpenGl_Structure*>& 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 (
for (aStructIt.Init (aStructArray (anIndex)); aStructIt.More(); aStructIt.Next())
{
- Standard_ShortReal* aTransform (NULL);
-
const OpenGl_Structure* aStructure = aStructIt.Value();
if (theMode == OpenGl_GUM_CHECK)
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;
}
}
}
// 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<const OpenGl_Structure*>& theElements)
+Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* theStructure, std::set<const OpenGl_Structure*>& theElements)
{
theElements.insert (theStructure);
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
myRaytraceGeometry.Materials.push_back (aGroupMaterial);
}
- Standard_Integer aMatID = aGroupMatID < 0 ? aStructMatID : aGroupMatID;
+ Standard_Integer aMatID = aGroupMatID < 0 ? theStructMatId : aGroupMatID;
if (aMatID < 0)
{
}
}
- 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;
}
PrsMgr_ListOfPresentations.hxx
+PrsMgr_ListOfPresentableObjects.hxx
deferred class PresentableObject;
imported ListOfPresentations;
+ imported ListOfPresentableObjects;
class Prs;
--- /dev/null
+// Created on: 2014-08-11
+// Created by: duv
+// Copyright (c) 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.
+
+#ifndef _PrsMgr_ListOfPresentableObjects_HeaderFile
+#define _PrsMgr_ListOfPresentableObjects_HeaderFile
+
+#include <PrsMgr_PresentableObject.hxx>
+#include <NCollection_List.hxx>
+
+typedef NCollection_List<Handle(PrsMgr_PresentableObject)> PrsMgr_ListOfPresentableObjects;
+typedef NCollection_List<Handle(PrsMgr_PresentableObject)>::Iterator PrsMgr_ListOfPresentableObjectsIter;
+
+
+#endif // _PrsMgr_ListOfPresentableObjects_HeaderFile
-- 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
Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView);
+ ---C++: alias "Standard_EXPORT virtual ~PrsMgr_PresentableObject();"
---Category: deferred methods.
--
-- is static private;
Presentations(me : mutable) returns Presentations from PrsMgr
- is static protected;
+ is static;
---C++: return &
TypeOfPresentation3d(me) returns TypeOfPresentation3d from PrsMgr
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;
---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
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,
//=======================================================================
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;
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 :
{
Handle(Prs3d_Presentation) aStruct3d = thePrs->Presentation();
Compute (thePrsMgr, aStruct3d, theMode);
- UpdateLocation (aStruct3d);
+ UpdateTransformation (aStruct3d);
aStruct3d->SetClipPlanes (myClipPlanes);
aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint());
}
}
//=======================================================================
-//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;
}
//=======================================================================
}
//=======================================================================
-//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);
}
//=======================================================================
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 :
{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
{
-- 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
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);
}
}
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();
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();
// 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);
}
// =======================================================================
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())
{
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();
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);
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;
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();
}
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();
}
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;
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)
{
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)
{
// =======================================================================
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)
{
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
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())
{
di << argv[1] << " : No interactive object" << "\n";
return 1;
}
- AISObj->UnsetTransformation();
+ AISObj->ResetTransformation();
if (!aContext->HasOpenedContext()) {
aContext->OpenLocalContext();
}
---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
//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();
}
ResetLocation(me:mutable) is deferred;
Location(me) returns Location from TopLoc is deferred;
- ---C++: return const&
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.
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
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...)
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...
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()
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.
---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 <aSelection>
-- and in corresponding entity owners.
#include <SelectMgr_EntityOwner.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
+#include <TopLoc_Location.hxx>
#include <gp_Pnt.hxx>
static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq,
//=======================================================================
-//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;
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());}
}
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;
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);
}
}
}
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;
}
anObject->UpdateSelection(aMode);
case SelectMgr_TOU_Partial:
{
- if(anObject->HasLocation())
- anObject->UpdateLocation(Sel);
+ if(anObject->HasTransformation())
+ anObject->UpdateTransformation(Sel);
break;
}
default:
if( SelectDebugModeOnSM() ) cout<<"\t Global Recalculation of selections"<<endl;
if(aMode==-1){
anObject->UpdateSelection();
- anObject->UpdateLocation();
+ anObject->UpdateTransformation();
}
else if(anObject->HasSelection(aMode)){
anObject->UpdateSelection(aMode);
- anObject->UpdateLocation();
+ anObject->UpdateTransformation();
}
return;
}
case SelectMgr_TOU_Full:
anObject->UpdateSelection(curmode); // no break on purpose...
case SelectMgr_TOU_Partial:
- anObject->UpdateLocation(Sel);
+ anObject->UpdateTransformation(Sel);
break;
default:
break;
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()){
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:
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:
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:
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:
aistrihed = new AIS_Axis(apt);
else {
aistrihed->SetComponent(apt);
- aistrihed->ResetLocation();
+ aistrihed->ResetTransformation();
aistrihed->SetToUpdate();
aistrihed->UpdateSelection();
}
}
if (anAIS.IsNull()) return Standard_False;
- anAIS->ResetLocation();
+ anAIS->ResetTransformation();
anAIS->SetToUpdate();
anAIS->UpdateSelection();
ais1 = new AIS_Point(apt);
else {
ais1->SetComponent(apt);
- ais1->ResetLocation();
+ ais1->ResetTransformation();
ais1->SetToUpdate();
ais1->UpdateSelection();
}
ais2 = new AIS_Line(aln);
else {
ais2->SetLine(aln);
- ais2->ResetLocation();
+ ais2->ResetTransformation();
ais2->SetToUpdate();
ais2->UpdateSelection();
}
ais3 = new AIS_Circle(acir);
else {
ais3->SetCircle(acir);
- ais3->ResetLocation();
+ ais3->ResetTransformation();
ais3->SetToUpdate();
ais3->UpdateSelection();
}
if (ais.IsNull())
ais = new AIS_Shape(mkEdge);
else {
- ais->ResetLocation();
+ ais->ResetTransformation();
ais->Set(mkEdge);
ais->SetToUpdate();
ais->UpdateSelection();
else {
TopoDS_Shape oldShape = AISShape->Shape();
if(oldShape != S) {
- AISShape->ResetLocation();
+ AISShape->ResetTransformation();
#ifdef OPTIM_UPDATE
Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();
else {
aisplane->SetComponent(apt);
aisplane->SetCenter(pln.Location());
- aisplane->ResetLocation();
+ aisplane->ResetTransformation();
aisplane->SetToUpdate();
aisplane->UpdateSelection();
}
aistrihed = new AIS_Point(apt);
else {
aistrihed->SetComponent(apt);
- aistrihed->ResetLocation();
+ aistrihed->ResetTransformation();
aistrihed->SetToUpdate();
aistrihed->UpdateSelection();
}
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);
#include <StdPrs_ShadedShape.hxx>
#include <TopoDS_Wire.hxx>
-#include <AIS_ConnectedShape.hxx>
#include <AIS_MultipleConnectedInteractive.hxx>
-#include <AIS_MultipleConnectedShape.hxx>
+#include <AIS_ConnectedInteractive.hxx>
#include <TopLoc_Location.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
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;
}
Handle(AIS_InteractiveObject) anIObj;
if (!aMap.IsBound2 (aName))
{
- di << "Use 'vdisplay' before" << "\n";
+ std::cout << "Use 'vdisplay' before" << "\n";
return 1;
}
else
// 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;
}
//===============================================================================================
//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();
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;
}
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
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
}
// 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
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.
__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"
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 :
"Without arguments it shows if highlighting of selected objects is enabled now.",
__FILE__,VHighlightSelected,group);
+
+ theCommands.Add("vxrotate",
+ "vxrotate",
+ __FILE__,VXRotate,group);
+
}
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}]
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}
##Resume
puts ""
-if { ${status_vconnectsh} == 0 } {
+if { ${status_vconnect} == 1 } {
puts "OK ${BugNumber}"
} else {
puts "Faulty ${BugNumber}"
--- /dev/null
+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}
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
--- /dev/null
+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}
--- /dev/null
+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}
--- /dev/null
+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}
--- /dev/null
+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}
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
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