1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0024837: Visualization - revise design and implementation of connected Interactive Objects

0023422: Selection problems when using SetLocation.
0024756: AIS_ConnectedInteractive does not support nested AIS_ConnectedInteractive
0025103: Visualization - Regression in interactive detection

Each PrsMgr_PresentableObject has list of PrsMgr _PresentableObject called myChildren.
Transformation PrsMgr_PresentableObject applied to its children every time when its own transformation affected. This hierarchy does not propagate to Graphic3d level and below.

PrsMgr_PresentableObject send its combined (according to hierarchy) transform down to Graphic3d_Structure.

AIS_ConnectedInteractive and AIS_MultiplyConnectedInteractive are reused but behavior has been changed.

AIS_ConnectedInteractive now is an instance of object. It reuses geometry of connected object but have own transformation, material, visibility flag etc. This connection propagated down to OpenGl level to OpenGl_Structure. For this task old “connected” mechanism has been reused.

AIS_MultiplyConnectedInteractive represents assembly which doesn’t have its own presentation. Assemblies are able to participate is scene hierarchy and intended to handle a grouped set of instanced objects. It behaves as single object in terms of selection. It applies high level transform to all sub-elements since it located above in the hierarchy.

All AIS_MultiplyConnectedInteractive are able to have child assemblies. Deep copy of object instances performed when one assembly attached to another.

Correction test cases for CR24837

Test cases for issue CR23422

Test cases for issue CR24756

Test cases for issue CR25103

Viewer3d sample fixed.
This commit is contained in:
duv 2014-08-28 16:38:28 +04:00 committed by bugmaster
parent e3e895af61
commit 0717ddc132
61 changed files with 1729 additions and 1727 deletions

View File

@ -86,7 +86,7 @@ void CModelClippingDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBa
} }
else else
{ {
myShape->SetLocation (TopLoc_Location (myTrsf)); myShape->SetLocalTransformation (myTrsf);
} }
TCollection_AsciiString aMessage ( TCollection_AsciiString aMessage (
@ -174,7 +174,7 @@ void CModelClippingDlg::OnChangeEditModelclippingZ()
} }
else else
{ {
myShape->SetLocation (TopLoc_Location (myTrsf)); myShape->SetLocalTransformation (myTrsf);
} }
myModelClipping_Z = m_ModelClipping_Z; myModelClipping_Z = m_ModelClipping_Z;

View File

@ -360,9 +360,6 @@ is
---Category: Object of type Shape ---Category: Object of type Shape
class Shape; --signature 0 class Shape; --signature 0
class ConnectedShape; --signature 1
class MultipleConnectedShape; --signature 2
---Category: General Objects ---Category: General Objects

View File

@ -16,38 +16,30 @@
class ConnectedInteractive from AIS inherits InteractiveObject from AIS class ConnectedInteractive from AIS inherits InteractiveObject from AIS
---Purpose: Defines an Interactive Object through a connection to ---Purpose: Creates an arbitrary located instance of another Interactive Object,
-- another Interactive Object, which serves as a -- which serves as a reference.
-- reference, and which is located elsewhere in the viewer.
-- This allows you to use the Connected Interactive -- This allows you to use the Connected Interactive
-- Object without having to recalculate presentation, -- Object without having to recalculate presentation,
-- selection or graphic structure. These are deduced -- selection or graphic structure. These are deduced
-- from your reference object. -- from your reference object.
-- The relation between the connected interactive object -- The relation between the connected interactive object
-- and its source is generally one of geometric transformation. -- and its source is generally one of geometric transformation.
-- AIS_ConnectedInteractive class doesn't support selection -- AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and
-- modes different from 0. Descendants should redefine ComputeSelection() -- all standard modes if its reference based on AIS_Shape.
-- method in order to handle other selection modes and generate connected -- Descendants may redefine ComputeSelection() though.
-- sensitive entities properly. Refer to AIS_ConnectedShape class -- Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape.
-- 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.
uses uses
Location from TopLoc, Location from TopLoc,
Shape from TopoDS,
Transformation from Geom, Transformation from Geom,
PresentationManager3d from PrsMgr, PresentationManager3d from PrsMgr,
Presentation from Prs3d, Presentation from Prs3d,
TypeOfPresentation3d from PrsMgr, TypeOfPresentation3d from PrsMgr,
Selection from SelectMgr, Selection from SelectMgr,
Projector from Prs3d, Projector from Prs3d,
KindOfInteractive from AIS KindOfInteractive from AIS,
Trsf from gp
raises raises
NotImplemented from Standard NotImplemented from Standard
@ -73,16 +65,15 @@ is
Connect(me : mutable; Connect(me : mutable;
anotherIObj : InteractiveObject from AIS) is virtual; anotherIObj : InteractiveObject from AIS) is virtual;
---Purpose: Establishes the connection between the Connected ---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference -- 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.
Connect(me:mutable; Connect(me:mutable;
anotherIobj: InteractiveObject from AIS; anotherIobj: InteractiveObject from AIS;
aLocation : Location from TopLoc) is virtual; aLocation : Trsf from gp) is virtual;
---Purpose: ---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference.
-- Locates instance in aLocation.
HasConnection(me) returns Boolean from Standard; HasConnection(me) returns Boolean from Standard;
@ -123,7 +114,7 @@ is
aProjector : Projector from Prs3d; aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom; aTrsf : Transformation from Geom;
aPresentation : Presentation from Prs3d) aPresentation : Presentation from Prs3d)
is redefined; is redefined virtual private;
---Purpose: Computes the presentation according to a point of view ---Purpose: Computes the presentation according to a point of view
-- given by <aProjector>. -- given by <aProjector>.
-- To be Used when the associated degenerated Presentations -- To be Used when the associated degenerated Presentations
@ -136,34 +127,46 @@ is
Compute(me:mutable; Compute(me:mutable;
aProjector: Projector from Prs3d; aProjector: Projector from Prs3d;
aPresentation: Presentation 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; ComputeSelection(me:mutable; theSelection : Selection from SelectMgr;
aMode : Integer) is redefined virtual private; theMode : Integer) is redefined virtual private;
---Level: Public ---Level: Public
---Purpose: Generates sensitive entities by copying ---Purpose: Generates sensitive entities by copying
-- them from myReference selection, creates and sets an entity -- 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 AcceptShapeDecomposition(me) returns Boolean from Standard is
redefined virtual; redefined virtual;
---C++: inline ---C++: inline
---Purpose: Informs the graphic context that the interactive Object
-- may be decomposed into sub-shapes for dynamic selection.
UpdateLocation(me:mutable) is redefined virtual; updateShape(me:mutable;WithLocation:Boolean from Standard = Standard_True)
is static private;
UpdateLocation(me:mutable;aSel:Selection from SelectMgr) is redefined virtual;
---Purpose: For this class, the location effect is treated in the Compute(me:mutable;
-- compute & computeSelection methods. So the aProjector : Projector from Prs3d;
-- UpdateLocation Methods are redefined to do nothing else aPresentation: Presentation from Prs3d;
aShape : Shape from TopoDS)
-- UpdateLocation(me:mutable;P : Presentation from Prs3d) is redefined virtual; is private;
---Purpose: Computes the presentation according to a point of view
-- given by <aProjector>.
fields fields
myReference : InteractiveObject from AIS is protected; myReference : InteractiveObject from AIS is protected; -- reference object
---Purpose: To have the time to Disconnect below, the old is kept for a while. myShape : Shape from TopoDS; -- used for HLR
myOldReference : InteractiveObject from AIS is protected;
end ConnectedInteractive; end ConnectedInteractive;

View File

@ -23,7 +23,25 @@
#include <PrsMgr_ModedPresentation.hxx> #include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_Presentation.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>
//======================================================================= //=======================================================================
@ -32,7 +50,7 @@
//======================================================================= //=======================================================================
AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
AIS_InteractiveObject(aTypeOfPresentation3d) AIS_InteractiveObject(aTypeOfPresentation3d)
{ {
SetHilightMode(0); SetHilightMode(0);
} }
@ -41,44 +59,52 @@ AIS_InteractiveObject(aTypeOfPresentation3d)
//purpose : //purpose :
//======================================================================= //=======================================================================
AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
{return AIS_KOI_Object;} {
return AIS_KOI_Object;
}
Standard_Integer AIS_ConnectedInteractive::Signature() const Standard_Integer AIS_ConnectedInteractive::Signature() const
{return 0; } {
return 0;
}
//======================================================================= //=======================================================================
//function : Connect //function : Connect
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_ConnectedInteractive:: void AIS_ConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
{ {
// To have the time to Disconnect below, if (myReference == theAnotherObj) return;
// the old is kept for a while.
if(myReference==anotherIObj) return; Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj);
myOldReference = myReference; if (!aConnected.IsNull())
//Disconnect(); {
myReference = anotherIObj ; myReference = aConnected->myReference;
}
else if (theAnotherObj->HasOwnPresentations())
{
myReference = theAnotherObj;
}
if (!myReference.IsNull())
{
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
}
theAnotherObj->AddChild (this);
} }
//======================================================================= //=======================================================================
//function : Connect //function : Connect
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_ConnectedInteractive:: void AIS_ConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
Connect(const Handle(AIS_InteractiveObject)& anotherIobj, const gp_Trsf& theLocation)
const TopLoc_Location& aLocation)
{ {
if(myLocation!=aLocation) Connect (theAnotherObj);
myLocation = aLocation;
if(myReference!=anotherIobj) { SetLocalTransformation (theLocation);
myOldReference = myReference; // necessary to disconnect below..
// Disconnect();
myReference = anotherIobj;}
} }
@ -106,11 +132,6 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
if (!(HasLocation() || HasConnection()))
{
return;
}
if (HasConnection()) if (HasConnection())
{ {
thePrs->Clear (Standard_False); thePrs->Clear (Standard_False);
@ -127,77 +148,246 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3
} }
} }
if (HasLocation()) if (!thePrs.IsNull())
{ {
Handle(Geom_Transformation) aPrsTrans = new Geom_Transformation (myLocation.Transformation()); thePrs->ReCompute();
thePrsMgr->Transform (this, aPrsTrans, theMode);
} }
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)&)"); updateShape (Standard_False);
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; 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) 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)&)"); updateShape (Standard_True);
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; Compute (aProjector, aPresentation, myShape);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theShape)
{
if (myShape.IsNull())
{
return;
}
switch (theShape.ShapeType())
{
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
{
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())
{
BRepTools::Clean (theShape);
}
myDrawer->SetHLRAngle (aNewAngle);
myDrawer->SetHLRDeviationCoefficient (aDefaultDrawer->HLRDeviationCoefficient());
StdPrs_HLRPolyShape::Add (thePresentation, theShape, myDrawer, theProjector);
aDefaultDrawer->SetTypeOfDeflection (aPrevDeflection);
}
}
}
//=======================================================================
//function : updateShape
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::updateShape (const Standard_Boolean isWithLocation)
{
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()));
}
} }
//======================================================================= //=======================================================================
//function : ComputeSelection //function : ComputeSelection
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, const Standard_Integer theMode)
const Standard_Integer aMode)
{ {
if(!(HasLocation() ||HasConnection())) return; if (!HasConnection())
aSel->Clear();
if(!myReference->HasSelection(aMode))
myReference->UpdateSelection(aMode);
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())
{ {
SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive()); return;
if(!SE3D.IsNull()) }
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 // Get the copy of SE3D
SNew = SE3D->GetConnected(myLocation); aNewSensitive = aSensitive->GetConnected (aLocation);
if(aMode==0)
{ aNewSensitive->Set(anOwner);
SNew->Set(OWN); // In case if SE3D caches some location-dependent data
// In case if SE3D caches some location-dependent data // that must be updated after setting OWN
// that must be updated after setting OWN aNewSensitive->SetLocation (aLocation);
SNew->SetLocation(myLocation);
} theSelection->Add (aNewSensitive);
aSel->Add(SNew);
} }
} }
} }
void AIS_ConnectedInteractive::UpdateLocation() //=======================================================================
//function : ComputeSubShapeSelection
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{ {
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()"); typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
SelectMgr_SelectableObject::UpdateLocation() ; 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);
} }
void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)");
SelectMgr_SelectableObject::UpdateLocation(Sel) ;
}
/*void AIS_ConnectedInteractive::UpdateLocation(const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(Prs3d_Presentation)&)");
SelectMgr_SelectableObject::UpdateLocation(aPresentation) ;
}*/

View File

@ -1,139 +0,0 @@
-- Created on: 1997-01-08
-- Created by: Robert COUBLANC
-- Copyright (c) 1997-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
--Modified by rob on Jul-28-97
class ConnectedShape from AIS inherits ConnectedInteractive from AIS
---Purpose: Constructs a Connected Interactive Object with an
-- AIS_Shape presentation as its reference Interactive Object.
-- In topological decomposition of the shape, this class
-- assigns the same owners to the sensitive primitives
-- as those in AIS_Shape. Like AIS_Shape, it allows a
-- presentation of hidden parts. These are calculated
-- automatically from the shape of its reference entity.
uses
Shape from TopoDS,
Projector from Prs3d,
Presentation from Prs3d,
Selection from SelectMgr,
Integer from Standard,
Shape from AIS,
TypeOfPresentation3d from PrsMgr,
PresentationManager3d from PrsMgr,
InteractiveObject from AIS,
KindOfInteractive from AIS,
Location from TopLoc,
Transformation from Geom
raises
NotImplemented from Standard
is
Create (aTypeOfPresentation : TypeOfPresentation3d from PrsMgr
=PrsMgr_TOP_ProjectorDependant)
returns ConnectedShape from AIS;
---Purpose: Initializes the type of 3d presentation aTypeOfPresentation
Create (aInteractiveShape : Shape from AIS;
aTypeOfPresentation : TypeOfPresentation3d from PrsMgr
=PrsMgr_TOP_ProjectorDependant)
returns ConnectedShape from AIS;
---Purpose: Initializes the entity aInteractiveShape and the type of 3d presentation aTypeOfPresentation.
Create(aConnectedShape : ConnectedShape from AIS;
aTypeOfPresentation : TypeOfPresentation3d from PrsMgr
=PrsMgr_TOP_ProjectorDependant)
returns ConnectedShape from AIS;
---Purpose: Initializes the entity aConnectedShape and the type of 3d presentation aTypeOfPresentation.
---Category: Redefined methods...
Type(me) returns KindOfInteractive from AIS
is redefined virtual;
Signature(me) returns Integer from Standard
is redefined virtual;
AcceptShapeDecomposition(me)
returns Boolean from Standard is redefined;
Connect(me : mutable;
anotherIObj : InteractiveObject from AIS) is redefined ;
---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference
-- entity. If there is already a previous connection with
-- an Interactive Object, this connection is removed.
Connect(me:mutable;
anotherIobj: InteractiveObject from AIS;
aLocation : Location from TopLoc) is redefined;
---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference
-- entity. If there is already a previous connection with
-- an Interactive Object, this connection is removed.
-- This syntax also initiates the location of the Connected Interactive Object.
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: Presentation from Prs3d)
is redefined virtual private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : Presentation from Prs3d)
is redefined virtual private;
ComputeSelection(me:mutable; aSelection : Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual private;
---Purpose: Generates sensitive entities by copying
-- them from myReferense selection specified by aMode,
-- creates and sets an entity owner for this entities and adds
-- them to aSelection.
Shape(me:mutable) returns Shape from TopoDS;
---C++: return const&
---Purpose: Returns the topological shape which is the reference
-- for the connected shape. Sets hilight mode to index
-- 0. This returns a wireframe presentation.
UpdateShape(me:mutable;WithLocation:Boolean from Standard = Standard_True)
is static private;
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: Presentation from Prs3d;
aShape : Shape from TopoDS)
is private;
fields
myOwnSh : Shape from TopoDS; -- used for HLR and selection...
end ConnectedShape;

View File

@ -1,335 +0,0 @@
// Created on: 1996-04-10
// Created by: Guest Design
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// <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);
}
}

View File

@ -526,7 +526,6 @@ is
returns Location from TopLoc; returns Location from TopLoc;
---Purpose: ---Purpose:
-- Returns the location of the entity aniobj. -- Returns the location of the entity aniobj.
---C++: return const&

View File

@ -47,8 +47,8 @@
#include <Precision.hxx> #include <Precision.hxx>
#include <AIS_Selection.hxx> #include <AIS_Selection.hxx>
#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
#include <AIS_ConnectedShape.hxx> #include <AIS_ConnectedInteractive.hxx>
#include <AIS_MultipleConnectedShape.hxx> #include <AIS_MultipleConnectedInteractive.hxx>
#include <AIS_DataMapIteratorOfDataMapOfILC.hxx> #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
#include <AIS_GlobalStatus.hxx> #include <AIS_GlobalStatus.hxx>
#include <AIS_MapIteratorOfMapOfInteractive.hxx> #include <AIS_MapIteratorOfMapOfInteractive.hxx>
@ -1319,19 +1319,19 @@ void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& an
if(anIObj.IsNull()) return; if(anIObj.IsNull()) return;
if(anIObj->HasLocation() && aLoc.IsIdentity()){ if(anIObj->HasTransformation() && aLoc.IsIdentity()){
anIObj->ResetLocation(); anIObj->ResetTransformation();
mgrSelector->Update(anIObj,Standard_False); mgrSelector->Update(anIObj,Standard_False);
return; return;
} }
if(aLoc.IsIdentity()) return ; if(aLoc.IsIdentity()) return ;
// first reset the previous location to properly clean everything... // first reset the previous location to properly clean everything...
if(anIObj->HasLocation()) if(anIObj->HasTransformation())
anIObj->ResetLocation(); anIObj->ResetTransformation();
anIObj->SetLocation(aLoc); anIObj->SetLocalTransformation (aLoc.Transformation());
if(!HasOpenedContext()) if(!HasOpenedContext())
mgrSelector->Update(anIObj,Standard_False); mgrSelector->Update(anIObj,Standard_False);
@ -1352,7 +1352,7 @@ void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)&
{ {
if(anIObj.IsNull()) return; if(anIObj.IsNull()) return;
anIObj->ResetLocation(); anIObj->ResetTransformation();
mgrSelector->Update(anIObj,Standard_False); mgrSelector->Update(anIObj,Standard_False);
} }
@ -1366,13 +1366,13 @@ HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const
{ {
if(anIObj.IsNull()) return 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 Location(const Handle(AIS_InteractiveObject)& anIObj) const
{ {
return anIObj->Location(); return anIObj->Transformation();
} }
//======================================================================= //=======================================================================
@ -1489,8 +1489,8 @@ void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
Handle(AIS_InteractiveObject) anObj = It.Key(); Handle(AIS_InteractiveObject) anObj = It.Key();
// ENDCLE // ENDCLE
Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) || Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) ||
anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) || anObj->IsKind(STANDARD_TYPE(AIS_ConnectedInteractive)) ||
anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) ); anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedInteractive)) );
if ((!anObj->HasDisplayMode()) && Processed) if ((!anObj->HasDisplayMode()) && Processed)
{ {

View File

@ -1120,17 +1120,17 @@ Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
TopoDS_Shape AIS_InteractiveContext::SelectedShape() const TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
{ {
if (!HasOpenedContext())
if(!HasOpenedContext()){ {
TopoDS_Shape sh; TopoDS_Shape sh;
#ifdef IMP280200 Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(SelectedInteractive());
Handle(AIS_Shape) shape = if (!shape.IsNull()) sh = shape->Shape().Located (SelectedInteractive()->Transformation());
Handle(AIS_Shape)::DownCast(SelectedInteractive());
if( !shape.IsNull() ) sh = shape->Shape();
#endif
return sh; return sh;
} else }
return myLocalContexts(myCurLocalIndex)->SelectedShape(); else
{
return myLocalContexts (myCurLocalIndex)->SelectedShape();
}
} }
//======================================================================= //=======================================================================

View File

@ -521,37 +521,6 @@ is
State(me) returns Integer from Standard ; State(me) returns Integer from Standard ;
---C++: inline ---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 HasPresentation ( me ) returns Boolean from Standard
is static; is static;
---Level: Public ---Level: Public
@ -657,7 +626,6 @@ fields
myToRecomputeModes : ListOfInteger from TColStd is protected; myToRecomputeModes : ListOfInteger from TColStd is protected;
mystate : Integer from Standard; mystate : Integer from Standard;
myHasTransformation : Boolean from Standard;
friends friends

View File

@ -72,8 +72,7 @@ myCTXPtr(NULL),
mySelPriority(-1), mySelPriority(-1),
myDisplayMode (-1), myDisplayMode (-1),
mySelectionMode(0), mySelectionMode(0),
mystate(0), mystate(0)
myHasTransformation(Standard_False)
{ {
Handle (AIS_InteractiveContext) Bid; Handle (AIS_InteractiveContext) Bid;
myCTXPtr = Bid.operator->(); myCTXPtr = Bid.operator->();
@ -545,79 +544,6 @@ void AIS_InteractiveObject::SetInfiniteState(const Standard_Boolean aFlag)
} }
} }
//=======================================================================
//function : SetTransformation
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetTransformation (const Handle(Geom_Transformation)& theTrsf,
const Standard_Boolean theToPostConcatenate,
const Standard_Boolean theToUpdateSelection)
{
if (GetContext().IsNull())
{
return;
}
const PrsMgr_Presentations& aPrsList = Presentations();
myHasTransformation = Standard_True;
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{
const Standard_Integer aMode = aPrsList (aPrsIter).Mode();
Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, aMode)->Presentation();
theToPostConcatenate ? aPrs->Multiply (theTrsf)
: aPrs->Transform (theTrsf);
if (theToUpdateSelection)
{
myCTXPtr->ClearSelected (Standard_True);
myCTXPtr->RecomputeSelectionOnly (this);
}
}
}
//=======================================================================
//function : SetTransformation
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetTransformation() {
#ifdef OCC708
static Handle(Geom_Transformation) trsf = new Geom_Transformation( gp_Trsf() );
#else
Handle(Geom_Transformation) trsf;
#endif
SetTransformation(trsf); // Set identity transformation
myHasTransformation = Standard_False;
}
//=======================================================================
//function : Transformation
//purpose :
//=======================================================================
Handle(Geom_Transformation) AIS_InteractiveObject::Transformation()
{
if (GetContext().IsNull())
{
return Handle(Geom_Transformation)();
}
const PrsMgr_Presentations& aPrsList = Presentations();
if (aPrsList.Length() > 0)
{
Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, 1)->Presentation();
return aPrs->Transformation();
}
return Handle(Geom_Transformation)();
}
//=======================================================================
//function : HasTransformation
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasTransformation() const {
return myHasTransformation;
}
//======================================================================= //=======================================================================
//function : HasPresentation //function : HasPresentation
//purpose : //purpose :

View File

@ -379,7 +379,6 @@ is
---Purpose: returns TRUE if the detected entity is a shape ---Purpose: returns TRUE if the detected entity is a shape
-- coming from a Decomposition of an element. -- coming from a Decomposition of an element.
SelectedShape(me) returns Shape from TopoDS; SelectedShape(me) returns Shape from TopoDS;
---C++: return const &
SelectedOwner(me) returns EntityOwner from SelectMgr; SelectedOwner(me) returns EntityOwner from SelectMgr;
IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard; IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard;

View File

@ -774,8 +774,7 @@ HasShape() const
// Function: // Function:
// Purpose : // Purpose :
//================================================== //==================================================
const TopoDS_Shape& AIS_LocalContext:: TopoDS_Shape AIS_LocalContext::SelectedShape() const
SelectedShape() const
{ {
static TopoDS_Shape aSh; static TopoDS_Shape aSh;
Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value(); Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
@ -785,7 +784,7 @@ SelectedShape() const
{ {
return aSh; return aSh;
} }
return BRO->Shape(); return BRO->Shape().Located (BRO->Location());
} }
//================================================== //==================================================

View File

@ -37,22 +37,27 @@ uses
Projector from Prs3d, Projector from Prs3d,
Transformation from Geom, Transformation from Geom,
Integer from Standard, Integer from Standard,
Selection from SelectMgr Selection from SelectMgr,
Trsf from gp
is is
Create (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView) Create
returns MultipleConnectedInteractive from AIS; returns MultipleConnectedInteractive from AIS;
---Purpose: Initializes the Interactive Object with multiple ---Purpose: Initializes the Interactive Object with multiple
-- presentation connections. If aTypeOfPresentation3d -- connections to AIS_Interactive objects.
-- does not have the affectation PrsMgr_TOP_AllView,
-- it is projector dependent.
Connect(me : mutable; Connect(me : mutable;
anotherIObj : InteractiveObject from AIS); theInteractive : InteractiveObject from AIS);
---Purpose: Add anotherIObj in the presentation of me ---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 Type(me) returns KindOfInteractive from AIS
is redefined virtual; is redefined virtual;
@ -63,16 +68,9 @@ is
HasConnection(me) returns Boolean from Standard; HasConnection(me) returns Boolean from Standard;
---Purpose: Returns true if the object is connected to others. ---Purpose: Returns true if the object is connected to others.
ConnectedTo(me) returns SequenceOfInteractive from AIS; Disconnect(me : mutable;
---Purpose: theInteractive : InteractiveObject from AIS);
-- Returns the connection references of the previous ---Purpose: Removes the connection with theInteractive.
-- Interactive Objects in view.
---C++: inline
---C++: return const&
Disconnect(me:mutable;
anotherIObj : InteractiveObject from AIS);
---Purpose: Removes the connection anotherIObj to an entity.
DisconnectAll(me:mutable); DisconnectAll(me:mutable);
---Purpose: Clears all the connections to objects. ---Purpose: Clears all the connections to objects.
@ -106,17 +104,20 @@ is
Compute(me:mutable; Compute(me:mutable;
aProjector: Projector from Prs3d; aProjector: Projector from Prs3d;
aPresentation: Presentation 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; ComputeSelection(me:mutable; aSelection : Selection from SelectMgr;
aMode : Integer from Standard) aMode : Integer from Standard)
is redefined virtual private; 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; end MultipleConnectedInteractive;

View File

@ -14,34 +14,139 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
// <g_design>
#include <Standard_NotImplemented.hxx> #include <Standard_NotImplemented.hxx>
#include <AIS_MultipleConnectedInteractive.ixx> #include <AIS_MultipleConnectedInteractive.ixx>
#include <AIS_ConnectedInteractive.hxx>
#include <AIS_InteractiveContext.hxx>
#include <PrsMgr_ModedPresentation.hxx> #include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_Presentation.hxx> #include <PrsMgr_Presentation.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <TopLoc_Location.hxx>
#include <NCollection_DataMap.hxx>
static Standard_Boolean IsInSeq (const AIS_SequenceOfInteractive& theSeq, namespace
const Handle(AIS_InteractiveObject)& theItem)
{ {
Standard_Integer I = theSeq.Length(); //! SelectMgr_AssemblyEntityOwner replaces original owners in sensitive entities
while ( I>0 && theSeq.Value(I) != theItem) { //! copied from reference objects to AIS_MultipleConnectedInteractive in order to
I--; //! redirect all selection queries to multiply connected (assembly).
} class SelectMgr_AssemblyEntityOwner : public SelectMgr_EntityOwner
return (I>0); {
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;
};
} }
static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq , //=======================================================================
const Handle(AIS_InteractiveObject)& theItem) //function : SelectMgr_AssemblyEntityOwner
//purpose :
//=======================================================================
SelectMgr_AssemblyEntityOwner::SelectMgr_AssemblyEntityOwner (const Handle(SelectMgr_EntityOwner) theOwner,
SelectMgr_SelectableObject* theAssembly)
:
SelectMgr_EntityOwner (theOwner),
myAssembly (theAssembly)
{ {
Standard_Integer I = theSeq.Length(); }
while ( I>0 && theSeq.Value(I) != theItem) {
I--; //=======================================================================
//function : Selectable
//purpose :
//=======================================================================
Handle(SelectMgr_SelectableObject) SelectMgr_AssemblyEntityOwner::Selectable() const
{
return myAssembly;
}
//=======================================================================
//function : IsHilighted
//purpose :
//=======================================================================
Standard_Boolean SelectMgr_AssemblyEntityOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode) const
{
if (HasSelectable())
{
return PM->IsHighlighted (myAssembly, aMode);
}
return Standard_False;
}
//=======================================================================
//function : Hilight
//purpose :
//=======================================================================
void SelectMgr_AssemblyEntityOwner::Hilight (const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode)
{
if (HasSelectable())
{
PM->Highlight (myAssembly, aMode);
}
}
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM,
const Quantity_NameOfColor aColor,
const Standard_Integer aMode)
{
if (HasSelectable())
{
if (IsAutoHilight())
{
PM->Color (myAssembly, aColor, aMode);
}
else
{
myAssembly->HilightOwnerWithColor (PM, aColor, this);
}
}
}
//=======================================================================
//function : Unhilight
//purpose :
//=======================================================================
void SelectMgr_AssemblyEntityOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode)
{
if (HasSelectable())
{
PM->Unhighlight (myAssembly, aMode);
} }
return I;
} }
@ -50,11 +155,11 @@ static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq ,
//purpose : //purpose :
//======================================================================= //=======================================================================
AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): : AIS_InteractiveObject (PrsMgr_TOP_AllView)
AIS_InteractiveObject(aTypeOfPresentation3d) {
{ myHasOwnPresentations = Standard_False;
SetHilightMode(0); SetHilightMode (0);
} }
//======================================================================= //=======================================================================
@ -62,25 +167,68 @@ AIS_InteractiveObject(aTypeOfPresentation3d)
//purpose : //purpose :
//======================================================================= //=======================================================================
AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
{return AIS_KOI_Object;} {
return AIS_KOI_Object;
}
//======================================================================= //=======================================================================
//function : Signature //function : Signature
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer AIS_MultipleConnectedInteractive::Signature() const Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
{return 1;} {
return 1;
}
//======================================================================= //=======================================================================
//function : Connect //function : Connect
//purpose : //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;
if (!IsInSeq (myReferences, anotherIObj)) { Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
myReferences.Append(anotherIObj); 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);
}
anObjectToAdd = aNewMultiConnected;
} }
else
{
Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
aNewConnected->Connect (theAnotherObj);
aNewConnected->SetLocalTransformation (theAnotherObj->LocalTransformation());
anObjectToAdd = aNewConnected;
}
anObjectToAdd->SetLocalTransformation (theTransformation);
AddChild (anObjectToAdd);
}
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
{
Connect (theAnotherObj, theAnotherObj->LocalTransformation());
} }
//======================================================================= //=======================================================================
@ -89,7 +237,7 @@ void AIS_MultipleConnectedInteractive::Connect(const Handle(AIS_InteractiveObjec
//======================================================================= //=======================================================================
Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
{ {
return (myReferences.Length() != 0); return (Children().Size() != 0);
} }
//======================================================================= //=======================================================================
@ -99,11 +247,7 @@ Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj) void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
{ {
Standard_Integer I = RangeInSeq (myReferences, anotherIObj); RemoveChild (anotherIObj);
if (I != 0) {
myReferences.Remove(I);
}
} }
//======================================================================= //=======================================================================
@ -111,49 +255,36 @@ void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveOb
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_MultipleConnectedInteractive::DisconnectAll () void AIS_MultipleConnectedInteractive::DisconnectAll()
{ {
/* for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) Standard_Integer aNbItemsToRemove = Children().Size();
{ for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter)
const Handle(PrsMgr_Presentation)& aPrs = myPresentations (aPrsIter).Presentation(); {
if (!aPrs.IsNull()) RemoveChild (Children().First());
{ }
aPrs->Presentation()->DisconnectAll (Graphic3d_TOC_DESCENDANT);
}
}*/
myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!!
myReferences.Clear();
} }
//======================================================================= //=======================================================================
//function : Compute //function : Compute
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& /*thePrs*/,
const Standard_Integer theMode) const Standard_Integer /*theMode*/)
{ {
thePrs->Clear (Standard_False); for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
thePrs->RemoveAll();
if (HasConnection())
{ {
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); continue;
if (!aRef->HasInteractiveContext()) }
{
aRef->SetContext (GetContext());
}
thePrsMgr->Connect (this, aRef, theMode, theMode); if (!aChild->HasInteractiveContext())
if (thePrsMgr->Presentation (aRef, theMode)->MustBeUpdated()) {
{ aChild->SetContext (GetContext());
thePrsMgr->Update (aRef, theMode);
}
} }
} }
thePrs->ReCompute();
} }
//======================================================================= //=======================================================================
@ -164,8 +295,7 @@ void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_Presentation
void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation) const Handle(Prs3d_Presentation)& aPresentation)
{ {
// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Prs3d_Presentation)&)"); PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
} }
//======================================================================= //=======================================================================
@ -177,15 +307,109 @@ void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aP
const Handle(Geom_Transformation)& aTransformation, const Handle(Geom_Transformation)& aTransformation,
const Handle(Prs3d_Presentation)& aPresentation) 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 //function : ComputeSelection
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/, void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer /*aMode*/) 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);
}
}
}
} }

View File

@ -13,14 +13,3 @@
// //
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
// <g_design>
//=======================================================================
//function : ConnectedTo
//purpose :
//=======================================================================
inline const AIS_SequenceOfInteractive& AIS_MultipleConnectedInteractive::ConnectedTo() const
{
return myReferences;
}

View File

@ -1,107 +0,0 @@
-- Created on: 1997-04-22
-- Created by: Guest Design
-- Copyright (c) 1997-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class MultipleConnectedShape from AIS inherits MultipleConnectedInteractive from AIS
---Purpose: Constructs an Interactive Object connected to a list of
-- Interactive Objects having a Shape. These include
-- AIS_Shape, and AIS_ConnectedShape.
-- Presentation of Hidden parts is calculated automatically.
-- You define the Interactive Object by gathering
-- together several other object presentations as in
-- AIS_MultipleConnectedInteractive.
uses
PresentationManager3d from PrsMgr,
Shape from TopoDS,
Projector from Prs3d,
Presentation from Prs3d,
Selection from SelectMgr,
Integer from Standard,
Transformation from Geom,
KindOfInteractive from AIS
raises
NotImplemented from Standard
is
Create (aShape : Shape from TopoDS)
returns MultipleConnectedShape from AIS;
---Purpose: Initializes the shape aShape, a multiple connected
-- Interactive Object grouping different
-- projector-dependent representations of an entity.
Type(me) returns KindOfInteractive from AIS
is redefined virtual;
Signature(me) returns Integer from Standard
is redefined virtual;
AcceptShapeDecomposition(me)
returns Boolean from Standard is redefined virtual;
---Purpose: Returns true is shape decomposition is accepted.
Set(me:mutable;ashap : Shape from TopoDS) is static;
---Purpose: Constructs the reference shape ashap.
---C++: inline
Shape(me) returns Shape from TopoDS ;
---Purpose: Returns the shape which is constructed in Set.
---C++: inline
---C++: return const&
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: Presentation from Prs3d)
is redefined virtual protected;
Compute(me:mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation: Presentation from Prs3d)
is redefined virtual protected;
ComputeSelection(me:mutable; aSelection : Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual protected;
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: Presentation from Prs3d;
aShape : Shape from TopoDS)
is private;
Compute(me:mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : Presentation from Prs3d;
aMode : Integer from Standard = 0)
---Level: Internal
---Purpose: this method is redefined virtual;
-- when the instance is connected to another
-- InteractiveObject,this method doesn't
-- compute anything, but just uses the
-- presentation of this last object, with
-- a transformation if there's one stored.
is redefined virtual private;
fields
myShape : Shape from TopoDS; -- celle qui sert au compute Hidden lines et selection
end MultipleConnectedShape;

View File

@ -1,231 +0,0 @@
// Created on: 1997-04-22
// Created by: Guest Design
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// <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);
}

View File

@ -411,8 +411,8 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
TypOfSel = AIS_Shape::SelectionType(aMode); TypOfSel = AIS_Shape::SelectionType(aMode);
TopoDS_Shape shape = myshape; TopoDS_Shape shape = myshape;
if( HasTransformation() ) { if( HasTransformation() ) {
Handle(Geom_Transformation) trsf = Transformation(); gp_Trsf trsf = Transformation();
shape = shape.Located(TopLoc_Location(trsf->Trsf())*shape.Location()); shape = shape.Located(TopLoc_Location(trsf)*shape.Location());
} }
// POP protection against crash in low layers // POP protection against crash in low layers

View File

@ -47,6 +47,7 @@ class Trihedron from AIS inherits InteractiveObject from AIS
uses uses
Axis2Placement from Geom, Axis2Placement from Geom,
Trsf from gp,
Presentation from Prs3d, Presentation from Prs3d,
PresentationManager3d from PrsMgr, PresentationManager3d from PrsMgr,
NameOfColor from Quantity, NameOfColor from Quantity,
@ -152,9 +153,7 @@ is
-- Methods from PresentableObject -- Methods from PresentableObject
SetLocation(me : mutable; SetLocalTransformation(me:mutable; theTransformation:Trsf from gp) is redefined static;
aLoc : Location from TopLoc)
is redefined static;
-- Methods from SelectableObject -- Methods from SelectableObject

View File

@ -107,14 +107,14 @@ void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& aComponent)
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_Trihedron::SetLocation(const TopLoc_Location& aLoc) void AIS_Trihedron::SetLocalTransformation (const gp_Trsf& theTransformation)
{ {
// Update location to the subshapes // Update location to the subshapes
Standard_Integer anIdx; Standard_Integer anIdx;
for (anIdx = 0; anIdx < 7; anIdx++) for (anIdx = 0; anIdx < 7; anIdx++)
myShapes[anIdx]->SetLocation (aLoc); myShapes[anIdx]->SetLocalTransformation (theTransformation);
AIS_InteractiveObject::SetLocation (aLoc); AIS_InteractiveObject::SetLocalTransformation (theTransformation);
} }
//======================================================================= //=======================================================================

View File

@ -911,10 +911,17 @@ is
is static private; is static private;
---Purpose: Returns the extreme coordinates found in the structure <me> without transformation applied. ---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; addTransformed (me;
theBox : out BndBox4d from Graphic3d; theBox : out BndBox4d from Graphic3d;
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False) theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
is static private; is static private;
---Purpose: Adds transformed (with myCStructure->Transformation) bounding box of structure to theBox.
PrintNetwork ( myclass; PrintNetwork ( myclass;
AStructure : Structure from Graphic3d; AStructure : Structure from Graphic3d;

View File

@ -1838,29 +1838,28 @@ Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord (const Standard_Boolean theT
//function : addTransformed //function : addTransformed
//purpose : //purpose :
//============================================================================= //=============================================================================
void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox, void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox,
const Standard_Boolean theToIgnoreInfiniteFlag) const const Standard_Boolean theToIgnoreInfiniteFlag) const
{ {
Graphic3d_BndBox4d aBox;
Graphic3d_BndBox4f aBoxF = minMaxCoord (theToIgnoreInfiniteFlag); Graphic3d_BndBox4f aBoxF = minMaxCoord (theToIgnoreInfiniteFlag);
if (aBoxF.IsValid()) if (aBoxF.IsValid())
{ {
aBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(), theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(),
(Standard_Real )aBoxF.CornerMin().y(), (Standard_Real )aBoxF.CornerMin().y(),
(Standard_Real )aBoxF.CornerMin().z(), (Standard_Real )aBoxF.CornerMin().z(),
(Standard_Real )aBoxF.CornerMin().w()), (Standard_Real )aBoxF.CornerMin().w()),
Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMax().x(), Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMax().x(),
(Standard_Real )aBoxF.CornerMax().y(), (Standard_Real )aBoxF.CornerMax().y(),
(Standard_Real )aBoxF.CornerMax().z(), (Standard_Real )aBoxF.CornerMax().z(),
(Standard_Real )aBoxF.CornerMax().w())); (Standard_Real )aBoxF.CornerMax().w()));
if (IsInfinite() if (IsInfinite()
&& !theToIgnoreInfiniteFlag) && !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) if (aDiagVec.xyz().SquareModulus() >= 500000.0 * 500000.0)
{ {
// bounding borders of infinite line has been calculated as own point in center of this line // 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 else
{ {
@ -1870,20 +1869,42 @@ void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox,
} }
} }
} }
}
//=============================================================================
//function : addTransformed
//purpose :
//=============================================================================
void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox,
const Standard_Boolean theToIgnoreInfiniteFlag) const
{
Graphic3d_BndBox4d aCombinedBox, aBox;
getBox (aCombinedBox, theToIgnoreInfiniteFlag);
for (Standard_Integer aStructIt = 1; aStructIt <= myDescendants.Length(); ++aStructIt) for (Standard_Integer aStructIt = 1; aStructIt <= myDescendants.Length(); ++aStructIt)
{ {
const Graphic3d_Structure* aStruct = (const Graphic3d_Structure* )myDescendants.Value (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()) if (aBox.IsValid())
{ {
TColStd_Array2OfReal aTrsf (0, 3, 0, 3); TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
Transform (aTrsf); Transform (aTrsf);
TransformBoundaries (aTrsf, aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(), TransformBoundaries (aTrsf, aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().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);
}
} }
} }

View File

@ -606,6 +606,20 @@ void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx)
IsForHighlight = Standard_False; 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 // function : Render
// purpose : // purpose :
@ -693,7 +707,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
OpenGl_ListOfStructure::Iterator its(myConnected); OpenGl_ListOfStructure::Iterator its(myConnected);
while (its.More()) while (its.More())
{ {
its.Value()->Render(AWorkspace); its.Value()->RenderGeometry (AWorkspace);
its.Next(); its.Next();
} }

View File

@ -139,8 +139,14 @@ public:
//! Get z layer ID //! Get z layer ID
Standard_EXPORT Standard_Integer GetZLayer() const; 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 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). //! Marks structure as not overlapping view volume (as it is by default).
void ResetCullingStatus() const void ResetCullingStatus() const

View File

@ -448,8 +448,12 @@ protected: //! @name methods related to ray-tracing
Standard_Boolean UpdateRaytraceEnvironmentMap(); Standard_Boolean UpdateRaytraceEnvironmentMap();
//! Adds OpenGL structure to ray-traced scene geometry. //! Adds OpenGL structure to ray-traced scene geometry.
Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure, Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure, std::set<const OpenGl_Structure*>& theElements);
const Standard_ShortReal* theTransform, 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. //! Adds OpenGL primitive array to ray-traced scene geometry.
OpenGl_TriangleSet* AddRaytracePrimitiveArray ( OpenGl_TriangleSet* AddRaytracePrimitiveArray (

84
src/OpenGl/OpenGl_Workspace_Raytrace.cxx Executable file → Normal file
View File

@ -105,8 +105,6 @@ Standard_Boolean OpenGl_Workspace::UpdateRaytraceGeometry (GeomUpdateMode theMod
for (aStructIt.Init (aStructArray (anIndex)); aStructIt.More(); aStructIt.Next()) for (aStructIt.Init (aStructArray (anIndex)); aStructIt.More(); aStructIt.Next())
{ {
Standard_ShortReal* aTransform (NULL);
const OpenGl_Structure* aStructure = aStructIt.Value(); const OpenGl_Structure* aStructure = aStructIt.Value();
if (theMode == OpenGl_GUM_CHECK) if (theMode == OpenGl_GUM_CHECK)
@ -142,22 +140,8 @@ Standard_Boolean OpenGl_Workspace::UpdateRaytraceGeometry (GeomUpdateMode theMod
if (!aStructure->IsRaytracable()) if (!aStructure->IsRaytracable())
continue; continue;
if (aStructure->Transformation()->mat != NULL) AddRaytraceStructure (aStructure, anElements);
{
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);
} }
delete [] aTransform;
} }
} }
} }
@ -311,8 +295,7 @@ void CreateMaterial (const OPENGL_SURF_PROP& theProp, OpenGl_RaytraceMaterial& t
// function : AddRaytraceStructure // function : AddRaytraceStructure
// purpose : Adds OpenGL structure to ray-traced scene geometry // purpose : Adds OpenGL structure to ray-traced scene geometry
// ======================================================================= // =======================================================================
Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* theStructure, Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* theStructure, std::set<const OpenGl_Structure*>& theElements)
const Standard_ShortReal* theTransform, std::set<const OpenGl_Structure*>& theElements)
{ {
theElements.insert (theStructure); theElements.insert (theStructure);
@ -335,6 +318,41 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
myRaytraceGeometry.Materials.push_back (aStructMaterial); 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()) for (OpenGl_Structure::GroupIterator aGroupIter (theStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next())
{ {
// Get group material // Get group material
@ -349,7 +367,7 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
myRaytraceGeometry.Materials.push_back (aGroupMaterial); myRaytraceGeometry.Materials.push_back (aGroupMaterial);
} }
Standard_Integer aMatID = aGroupMatID < 0 ? aStructMatID : aGroupMatID; Standard_Integer aMatID = aGroupMatID < 0 ? theStructMatId : aGroupMatID;
if (aMatID < 0) if (aMatID < 0)
{ {
@ -421,32 +439,6 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
} }
} }
Standard_ShortReal* aTransform = NULL;
// Process all connected OpenGL structures
for (OpenGl_ListOfStructure::Iterator anIts (theStructure->ConnectedStructures()); anIts.More(); anIts.Next())
{
if (anIts.Value()->Transformation()->mat != NULL)
{
if (aTransform == NULL)
aTransform = new Standard_ShortReal[16];
for (Standard_Integer i = 0; i < 4; ++i)
for (Standard_Integer j = 0; j < 4; ++j)
{
aTransform[j * 4 + i] =
anIts.Value()->Transformation()->mat[i][j];
}
}
if (anIts.Value()->IsRaytracable())
AddRaytraceStructure (anIts.Value(), aTransform != NULL ? aTransform : theTransform, theElements);
}
delete[] aTransform;
myStructureStates[theStructure] = theStructure->ModificationState();
return Standard_True; return Standard_True;
} }

View File

@ -1 +1,2 @@
PrsMgr_ListOfPresentations.hxx PrsMgr_ListOfPresentations.hxx
PrsMgr_ListOfPresentableObjects.hxx

View File

@ -57,6 +57,7 @@ is
deferred class PresentableObject; deferred class PresentableObject;
imported ListOfPresentations; imported ListOfPresentations;
imported ListOfPresentableObjects;
class Prs; class Prs;

View File

@ -1,7 +1,6 @@
// Created on: 1997-04-22 // Created on: 2014-08-11
// Created by: Guest Design // Created by: duv
// Copyright (c) 1997-1999 Matra Datavision // Copyright (c) 2014 OPEN CASCADE SAS
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
@ -14,16 +13,14 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
// <g_design> #ifndef _PrsMgr_ListOfPresentableObjects_HeaderFile
#define _PrsMgr_ListOfPresentableObjects_HeaderFile
inline void AIS_MultipleConnectedShape::Set(const TopoDS_Shape& ashap) #include <PrsMgr_PresentableObject.hxx>
{ #include <NCollection_List.hxx>
myShape = ashap;
}
inline const TopoDS_Shape& typedef NCollection_List<Handle(PrsMgr_PresentableObject)> PrsMgr_ListOfPresentableObjects;
AIS_MultipleConnectedShape::Shape() const typedef NCollection_List<Handle(PrsMgr_PresentableObject)>::Iterator PrsMgr_ListOfPresentableObjectsIter;
{
return myShape;
}
#endif // _PrsMgr_ListOfPresentableObjects_HeaderFile

View File

@ -48,23 +48,26 @@ deferred class PresentableObject from PrsMgr inherits TShared from MMgt
-- creation of new interactive objects. -- creation of new interactive objects.
uses uses
Presentation from PrsMgr, Presentation from PrsMgr,
Presentation from Prs3d, Presentation from Prs3d,
Presentations from PrsMgr, Presentations from PrsMgr,
PresentationManager from PrsMgr, PresentationManager from PrsMgr,
PresentationManager3d from PrsMgr, PresentationManager3d from PrsMgr,
TypeOfPresentation3d from PrsMgr, TypeOfPresentation3d from PrsMgr,
DataStructureManager from Graphic3d, ListOfPresentableObjects from PrsMgr,
Projector from Prs3d, PresentableObjectPointer from PrsMgr,
Transformation from Geom, DataStructureManager from Graphic3d,
ListOfInteger from TColStd, Projector from Prs3d,
Location from TopLoc, Transformation from Geom,
ClipPlane_Handle from Graphic3d, ListOfInteger from TColStd,
SequenceOfHClipPlane from Graphic3d, Location from TopLoc,
ClipPlane_Handle from Graphic3d,
SequenceOfHClipPlane from Graphic3d,
-- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) -- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate )
TransModeFlags from Graphic3d, TransModeFlags from Graphic3d,
Pnt from gp, Pnt from gp,
CTransPersStruct from Graphic3d Trsf from gp,
CTransPersStruct from Graphic3d
-- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) -- ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate )
raises raises
@ -73,6 +76,7 @@ is
Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView); Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView);
---C++: alias "Standard_EXPORT virtual ~PrsMgr_PresentableObject();"
---Category: deferred methods. ---Category: deferred methods.
-- --
@ -149,7 +153,7 @@ is
-- is static private; -- is static private;
Presentations(me : mutable) returns Presentations from PrsMgr Presentations(me : mutable) returns Presentations from PrsMgr
is static protected; is static;
---C++: return & ---C++: return &
TypeOfPresentation3d(me) returns TypeOfPresentation3d from PrsMgr TypeOfPresentation3d(me) returns TypeOfPresentation3d from PrsMgr
@ -218,19 +222,30 @@ is
ToBeUpdated(me;ListOfMode : out ListOfInteger from TColStd); ToBeUpdated(me;ListOfMode : out ListOfInteger from TColStd);
---Purpose: gives the list of modes which are flagged "to be updated". ---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++: inline
---C++: return const& ---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; SetZLayer ( me : mutable;
thePrsMgr : PresentationManager from PrsMgr; thePrsMgr : PresentationManager from PrsMgr;
@ -287,6 +302,26 @@ is
---Purpose: Returns true if object has mutable nature (content or location are be changed regularly). ---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). -- 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; UpdateClipping (me : mutable) is virtual protected;
---Purpose: General virtual method for internal update of presentation state ---Purpose: General virtual method for internal update of presentation state
-- when some modifications on list of clip planes occurs. Base -- when some modifications on list of clip planes occurs. Base
@ -295,11 +330,21 @@ is
fields fields
myPresentations: Presentations from PrsMgr is protected; myPresentations: Presentations from PrsMgr is protected;
myTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr is protected; myTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr is protected;
myLocation : Location from TopLoc is protected;
myClipPlanes : SequenceOfHClipPlane from Graphic3d is protected; myClipPlanes : SequenceOfHClipPlane from Graphic3d is protected;
myTransformPersistence : CTransPersStruct from Graphic3d; myTransformPersistence : CTransPersStruct from Graphic3d;
myIsMutable : Boolean from Standard is protected; 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 friends
class Presentation from PrsMgr, class Presentation from PrsMgr,
class PresentationManager from PrsMgr, class PresentationManager from PrsMgr,

View File

@ -29,7 +29,9 @@
//======================================================================= //=======================================================================
PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType) PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType)
: myTypeOfPresentation3d (theType), : myTypeOfPresentation3d (theType),
myIsMutable (Standard_False) myIsMutable (Standard_False),
myHasOwnPresentations (Standard_True),
myParent (NULL)
{ {
myTransformPersistence.Flag = 0; myTransformPersistence.Flag = 0;
myTransformPersistence.Point.x = 0.0; myTransformPersistence.Point.x = 0.0;
@ -37,6 +39,20 @@ PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentat
myTransformPersistence.Point.z = 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 //function : Fill
//purpose : //purpose :
@ -47,7 +63,7 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t
{ {
Handle(Prs3d_Presentation) aStruct3d = thePrs->Presentation(); Handle(Prs3d_Presentation) aStruct3d = thePrs->Presentation();
Compute (thePrsMgr, aStruct3d, theMode); Compute (thePrsMgr, aStruct3d, theMode);
UpdateLocation (aStruct3d); UpdateTransformation (aStruct3d);
aStruct3d->SetClipPlanes (myClipPlanes); aStruct3d->SetClipPlanes (myClipPlanes);
aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint()); aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint());
} }
@ -148,12 +164,12 @@ PrsMgr_Presentations& PrsMgr_PresentableObject::Presentations() {
} }
//======================================================================= //=======================================================================
//function : HasLocation //function : HasTransformation
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean PrsMgr_PresentableObject::HasLocation() const Standard_Boolean PrsMgr_PresentableObject::HasTransformation() const
{ {
return !Location().IsIdentity(); return myTransformation.Form() != gp_Identity;
} }
//======================================================================= //=======================================================================
@ -217,64 +233,64 @@ void PrsMgr_PresentableObject::SetTypeOfPresentation (const PrsMgr_TypeOfPresent
} }
//======================================================================= //=======================================================================
//function : SetLocation //function : SetLocalTransformation
//purpose : WARNING : use with only 3D objects... //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; myLocalTransformation = theTransformation;
myLocation = aLoc; UpdateTransformation();
UpdateLocation();
} }
//======================================================================= //=======================================================================
//function : ReSetLocation //function : ResetTransformation
//purpose : //purpose :
//======================================================================= //=======================================================================
void PrsMgr_PresentableObject::ResetLocation() void PrsMgr_PresentableObject::ResetTransformation()
{ {
TopLoc_Location aLoc; SetLocalTransformation (gp_Trsf());
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;
} }
//======================================================================= //=======================================================================
//function : UpdateLocation //function : SetCombinedParentTransform
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetCombinedParentTransform (const gp_Trsf& theTransformation)
{
myCombinedParentTransform = theTransformation;
UpdateTransformation();
}
//=======================================================================
//function : UpdateTransformation
//purpose : //purpose :
//======================================================================= //=======================================================================
void PrsMgr_PresentableObject::UpdateLocation() void PrsMgr_PresentableObject::UpdateTransformation()
{ {
if (!HasLocation()) myTransformation = myCombinedParentTransform * myLocalTransformation;
{ Handle(Geom_Transformation) aTrsf = new Geom_Transformation (myTransformation);
return;
}
Handle(Geom_Transformation) aTrsf = new Geom_Transformation (Location().Transformation());
if (aTrsf->Trsf().Form() == gp_Identity)
{
return;
}
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{ {
myPresentations (aPrsIter).Presentation()->Transform (aTrsf); myPresentations (aPrsIter).Presentation()->Transform (aTrsf);
} }
PrsMgr_ListOfPresentableObjectsIter anIter (myChildren);
for (; anIter.More(); anIter.Next())
{
anIter.Value()->SetCombinedParentTransform (myTransformation);
}
} }
//======================================================================= //=======================================================================
//function : UpdateLocation //function : UpdateTransformation
//purpose : //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) aTrsf = new Geom_Transformation (myTransformation);
Handle(Geom_Transformation) G = new Geom_Transformation(Location().Transformation()); P->Transform (aTrsf);
P->Transform(G);
} }
//======================================================================= //=======================================================================
@ -328,6 +344,42 @@ gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const
return gp_Pnt( myTransformPersistence.Point.x, myTransformPersistence.Point.y, myTransformPersistence.Point.z ); 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 //function : SetZLayer
//purpose : //purpose :

View File

@ -18,8 +18,30 @@ inline PrsMgr_TypeOfPresentation3d PrsMgr_PresentableObject::TypeOfPresentation3
{return myTypeOfPresentation3d;} {return myTypeOfPresentation3d;}
inline const TopLoc_Location& PrsMgr_PresentableObject::Location() const inline const gp_Trsf& PrsMgr_PresentableObject::LocalTransformation() const
{return myLocation;} {
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 inline const Graphic3d_SequenceOfHClipPlane& PrsMgr_PresentableObject::GetClipPlanes() const
{ {

View File

@ -199,36 +199,6 @@ is
-- thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode. -- thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode.
is static; 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 StructureManager (me) returns StructureManager from Graphic3d
is static; is static;
---C++: inline ---C++: inline

View File

@ -43,24 +43,39 @@ PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_S
void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) 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); Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (aPrs->MustBeUpdated())
{
Update (thePrsObj, theMode);
}
if (myImmediateModeOn > 0) if (aPrs.IsNull()) return;
{
AddToImmediateList (aPrs->Presentation()); if (aPrs->MustBeUpdated())
{
Update (thePrsObj, theMode);
}
if (myImmediateModeOn > 0)
{
AddToImmediateList (aPrs->Presentation());
}
else
{
aPrs->Display();
}
} }
else else
{ {
aPrs->Display(); thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode);
}
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
Display (anIter.Value(), theMode);
} }
} }
@ -71,6 +86,11 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
Erase (anIter.Value(), theMode);
}
if (HasPresentation (thePrsObj, theMode)) if (HasPresentation (thePrsObj, theMode))
{ {
Presentation (thePrsObj, theMode)->Erase(); Presentation (thePrsObj, theMode)->Erase();
@ -85,6 +105,11 @@ void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)&
void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
Clear (anIter.Value(), theMode);
}
if (HasPresentation (thePrsObj, theMode)) if (HasPresentation (thePrsObj, theMode))
{ {
Presentation (thePrsObj, theMode)->Clear(); Presentation (thePrsObj, theMode)->Clear();
@ -95,11 +120,20 @@ void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)&
// function : SetVisibility // function : SetVisibility
// purpose : // 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_Integer theMode,
const Standard_Boolean theValue) const Standard_Boolean theValue)
{ {
Presentation(thePresentableObject, theMode)->SetVisible (theValue); for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetVisibility (anIter.Value(), theMode, theValue);
}
if (!thePrsObj->HasOwnPresentations())
{
return;
}
Presentation (thePrsObj, theMode)->SetVisible (theValue);
} }
// ======================================================================= // =======================================================================
@ -109,11 +143,22 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) 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)) if (!HasPresentation (thePrsObj, theMode))
{ {
AddPresentation (thePrsObj, theMode); AddPresentation (thePrsObj, theMode);
} }
if (!HasPresentation (thePrsObj, theMode)) return;
Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (aPrs->MustBeUpdated()) if (aPrs->MustBeUpdated())
{ {
@ -139,6 +184,11 @@ void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObjec
void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
Unhighlight (anIter.Value(), theMode);
}
if (HasPresentation (thePrsObj, theMode)) if (HasPresentation (thePrsObj, theMode))
{ {
Presentation (thePrsObj, theMode)->Unhighlight(); Presentation (thePrsObj, theMode)->Unhighlight();
@ -153,6 +203,11 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
const Standard_Integer theMode, const Standard_Integer theMode,
const Standard_Integer theNewPrior) const const Standard_Integer theNewPrior) const
{ {
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetDisplayPriority (anIter.Value(), theMode, theNewPrior);
}
if (HasPresentation (thePrsObj, theMode)) if (HasPresentation (thePrsObj, theMode))
{ {
Presentation (thePrsObj, theMode)->SetDisplayPriority (theNewPrior); Presentation (thePrsObj, theMode)->SetDisplayPriority (theNewPrior);
@ -166,6 +221,15 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const 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) return HasPresentation (thePrsObj, theMode)
? Presentation (thePrsObj, theMode)->DisplayPriority() ? Presentation (thePrsObj, theMode)->DisplayPriority()
: 0; : 0;
@ -178,6 +242,14 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg
Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj, Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const 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) return HasPresentation (thePrsObj, theMode)
&& Presentation (thePrsObj, theMode)->IsDisplayed(); && Presentation (thePrsObj, theMode)->IsDisplayed();
} }
@ -189,6 +261,14 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr
Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj, Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const 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) return HasPresentation (thePrsObj, theMode)
&& Presentation (thePrsObj, theMode)->IsHighlighted(); && Presentation (thePrsObj, theMode)->IsHighlighted();
} }
@ -200,6 +280,10 @@ Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_
void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const const Standard_Integer theMode) const
{ {
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
Update (anIter.Value(), theMode);
}
if (!HasPresentation(thePrsObj, theMode)) if (!HasPresentation(thePrsObj, theMode))
{ {
return; return;
@ -299,6 +383,9 @@ void PrsMgr_PresentationManager::AddToImmediateList (const Handle(Prs3d_Presenta
Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const const Standard_Integer theMode) const
{ {
if (!thePrsObj->HasOwnPresentations())
return Standard_False;
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{ {
@ -388,6 +475,14 @@ void PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_Present
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj, void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theLayerId) 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(); PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{ {
@ -405,6 +500,18 @@ void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObjec
// ======================================================================= // =======================================================================
Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const 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(); const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{ {
@ -448,42 +555,6 @@ void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObjec
Presentation (thePrsObj, theMode)->Transform (theTransformation); 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 // function : Color
@ -493,11 +564,22 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)&
const Quantity_NameOfColor theColor, const Quantity_NameOfColor theColor,
const Standard_Integer theMode) 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)) if (!HasPresentation (thePrsObj, theMode))
{ {
AddPresentation (thePrsObj, theMode); AddPresentation (thePrsObj, theMode);
} }
if (!HasPresentation (thePrsObj, theMode)) return;
Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (aPrs->MustBeUpdated()) if (aPrs->MustBeUpdated())
{ {

View File

@ -1675,7 +1675,7 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con
di << argv[1] << " : No interactive object" << "\n"; di << argv[1] << " : No interactive object" << "\n";
return 1; return 1;
} }
AISObj->UnsetTransformation(); AISObj->ResetTransformation();
if (!aContext->HasOpenedContext()) { if (!aContext->HasOpenedContext()) {
aContext->OpenLocalContext(); aContext->OpenLocalContext();
} }

View File

@ -110,7 +110,7 @@ is
---Purpose: Returns true if this framework has a location defined. ---Purpose: Returns true if this framework has a location defined.
Location(me) returns Location from TopLoc is virtual; Location(me) returns Location from TopLoc is virtual;
---C++: return const& ---C++: return const
ResetLocation(me:mutable) is virtual; ResetLocation(me:mutable) is virtual;
---Purpose: sets the location to Identity ---Purpose: sets the location to Identity

View File

@ -120,9 +120,9 @@ void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc)
//purpose : //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(); Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
return anOwner.IsNull() ? anIdentity : anOwner->Location(); return anOwner.IsNull() ? anIdentity : anOwner->Location();
} }

View File

@ -60,7 +60,6 @@ is
ResetLocation(me:mutable) is deferred; ResetLocation(me:mutable) is deferred;
Location(me) returns Location from TopLoc is deferred; Location(me) returns Location from TopLoc is deferred;
---C++: return const&

View File

@ -49,6 +49,12 @@ is
returns EntityOwner from SelectMgr; returns EntityOwner from SelectMgr;
---Purpose: Constructs a framework with the selectable object ---Purpose: Constructs a framework with the selectable object
-- anSO being attributed the selection priority aPriority. -- 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; HasSelectable(me) returns Boolean from Standard;
---Purpose: Returns true if there is a selectable object to serve as an owner. ---Purpose: Returns true if there is a selectable object to serve as an owner.
@ -56,7 +62,7 @@ is
Selectable(me) returns any SelectableObject from SelectMgr Selectable(me) returns any SelectableObject from SelectMgr
---Purpose: Returns a selectable object detected in the working context. ---Purpose: Returns a selectable object detected in the working context.
raises NoSuchObject from Standard raises NoSuchObject from Standard
is static; is virtual;
Set(me:mutable; aSO : SelectableObject) is static; Set(me:mutable; aSO : SelectableObject) is static;
---Purpose: Sets the selectable object anSO to be used by the ---Purpose: Sets the selectable object anSO to be used by the
@ -124,9 +130,6 @@ is
SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined; SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined;
ResetLocation(me:mutable) is redefined; ResetLocation(me:mutable) is redefined;
Location(me) returns Location from TopLoc is redefined; Location(me) returns Location from TopLoc is redefined;
---C++: return const&
--very Internal method (to be used in selection process only...) --very Internal method (to be used in selection process only...)

View File

@ -37,6 +37,13 @@ myIsSelected (Standard_False)
mySelectable = aSO.operator->(); 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... //function : About Selectable...
@ -106,25 +113,23 @@ void SelectMgr_EntityOwner::
Hilight(){} Hilight(){}
//======================================================================= //=======================================================================
//function : about Location //function : about Transformation
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean SelectMgr_EntityOwner::HasLocation() const Standard_Boolean SelectMgr_EntityOwner::HasLocation() const
{ {
return (HasSelectable() && mySelectable->HasLocation()); return (HasSelectable() && mySelectable->HasTransformation());
} }
void SelectMgr_EntityOwner::SetLocation(const TopLoc_Location&) 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() ? TopLoc_Location() : TopLoc_Location(mySelectable->Transformation());
return HasSelectable() ? mySelectable->Location() : anIdentity;
} }
void SelectMgr_EntityOwner::ResetLocation() void SelectMgr_EntityOwner::ResetLocation()

View File

@ -53,7 +53,7 @@ is
Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView); Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView);
ComputeSelection(me:mutable; aSelection : Selection from SelectMgr; ComputeSelection(me:mutable; aSelection : Selection from SelectMgr;
aMode : Integer) is deferred private; aMode : Integer) is deferred;
---Purpose: Recovers and calculates any sensitive primitive, ---Purpose: Recovers and calculates any sensitive primitive,
-- aSelection, available in Shape mode, specified by -- aSelection, available in Shape mode, specified by
-- aMode. As a rule, these are sensitive faces. -- aMode. As a rule, these are sensitive faces.
@ -133,12 +133,12 @@ is
---C++: inline ---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. ---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 ---Level: Internal
---Purpose: Updates locations in all sensitive entities from <aSelection> ---Purpose: Updates locations in all sensitive entities from <aSelection>
-- and in corresponding entity owners. -- and in corresponding entity owners.

View File

@ -24,6 +24,7 @@
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager3d.hxx>
#include <TopLoc_Location.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq, static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq,
@ -160,13 +161,14 @@ void SelectMgr_SelectableObject
//======================================================================= //=======================================================================
//function : ReSetLocation //function : ReSetTransformation
//purpose : //purpose :
//======================================================================= //=======================================================================
void SelectMgr_SelectableObject::ResetLocation() void SelectMgr_SelectableObject::ResetTransformation()
{ {
TopLoc_Location aLoc; TopLoc_Location aLoc;
TopLoc_Location aSelfLocation (Transformation());
// les selections // les selections
Handle(Select3D_SensitiveEntity) SE; Handle(Select3D_SensitiveEntity) SE;
@ -176,13 +178,13 @@ void SelectMgr_SelectableObject::ResetLocation()
SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive())); SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive()));
if(!SE.IsNull()){ if(!SE.IsNull()){
if(SE->HasLocation()) { if(SE->HasLocation()) {
if( SE->Location()==myLocation){ if( SE->Location()==aSelfLocation){
SE->ResetLocation(); SE->ResetLocation();
const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId(); const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId();
(*((Handle(SelectMgr_EntityOwner)*)&EO))->ResetLocation();} (*((Handle(SelectMgr_EntityOwner)*)&EO))->ResetLocation();}
else{ else{
const TopLoc_Location& iniloc =SE->Location(); const TopLoc_Location& iniloc =SE->Location();
SE->SetLocation(iniloc*myLocation.Inverted()); SE->SetLocation(iniloc*aSelfLocation.Inverted());
const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId(); const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId();
(*((Handle(SelectMgr_EntityOwner)*)&EO))->SetLocation(SE->Location());} (*((Handle(SelectMgr_EntityOwner)*)&EO))->SetLocation(SE->Location());}
} }
@ -191,15 +193,15 @@ void SelectMgr_SelectableObject::ResetLocation()
Sel->UpdateStatus(SelectMgr_TOU_None); Sel->UpdateStatus(SelectMgr_TOU_None);
} }
PrsMgr_PresentableObject::ResetLocation(); PrsMgr_PresentableObject::ResetTransformation();
} }
//======================================================================= //=======================================================================
//function : UpdateLocation //function : UpdateTransformation
//purpose : //purpose :
//======================================================================= //=======================================================================
void SelectMgr_SelectableObject::UpdateLocation() void SelectMgr_SelectableObject::UpdateTransformation()
{ {
Handle(Select3D_SensitiveEntity) SE; Handle(Select3D_SensitiveEntity) SE;
@ -207,28 +209,29 @@ void SelectMgr_SelectableObject::UpdateLocation()
const Handle(SelectMgr_Selection) & Sel = CurrentSelection(); const Handle(SelectMgr_Selection) & Sel = CurrentSelection();
Sel->UpdateStatus(SelectMgr_TOU_Partial); Sel->UpdateStatus(SelectMgr_TOU_Partial);
} }
PrsMgr_PresentableObject::UpdateLocation(); PrsMgr_PresentableObject::UpdateTransformation();
} }
//======================================================================= //=======================================================================
//function : UpdateLocation //function : UpdateTransformation
//purpose : //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; Handle(Select3D_SensitiveEntity) SE;
if(myLocation.IsIdentity()) return; if(aSelfLocation.IsIdentity()) return;
for(Sel->Init();Sel->More();Sel->Next()){ for(Sel->Init();Sel->More();Sel->Next()){
SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive())); SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive()));
if(!SE.IsNull()){ if(!SE.IsNull()){
SE->UpdateLocation(myLocation); SE->UpdateLocation(aSelfLocation);
const Handle(SelectBasics_EntityOwner)& aEOwner = SE->OwnerId(); const Handle(SelectBasics_EntityOwner)& aEOwner = SE->OwnerId();
Handle(SelectMgr_EntityOwner) aMgrEO = Handle(SelectMgr_EntityOwner) aMgrEO =
Handle(SelectMgr_EntityOwner)::DownCast (aEOwner); Handle(SelectMgr_EntityOwner)::DownCast (aEOwner);
if (!aMgrEO.IsNull()) if (!aMgrEO.IsNull())
aMgrEO->SetLocation (myLocation); aMgrEO->SetLocation (aSelfLocation);
} }
} }
} }

View File

@ -263,8 +263,8 @@ Activate(const Handle(SelectMgr_SelectableObject)& anObject,
anObject->UpdateSelection(aMode); // pas de break expres... anObject->UpdateSelection(aMode); // pas de break expres...
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
{ {
if(anObject->HasLocation()) if(anObject->HasTransformation())
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
Sel->UpdateStatus(SelectMgr_TOU_None); Sel->UpdateStatus(SelectMgr_TOU_None);
break; break;
} }
@ -302,8 +302,8 @@ Activate(const Handle(SelectMgr_SelectableObject)& anObject,
anObject->UpdateSelection(aMode); anObject->UpdateSelection(aMode);
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
{ {
if(anObject->HasLocation()) if(anObject->HasTransformation())
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
break; break;
} }
default: default:
@ -580,11 +580,11 @@ RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject,
if( SelectDebugModeOnSM() ) cout<<"\t Global Recalculation of selections"<<endl; if( SelectDebugModeOnSM() ) cout<<"\t Global Recalculation of selections"<<endl;
if(aMode==-1){ if(aMode==-1){
anObject->UpdateSelection(); anObject->UpdateSelection();
anObject->UpdateLocation(); anObject->UpdateTransformation();
} }
else if(anObject->HasSelection(aMode)){ else if(anObject->HasSelection(aMode)){
anObject->UpdateSelection(aMode); anObject->UpdateSelection(aMode);
anObject->UpdateLocation(); anObject->UpdateTransformation();
} }
return; return;
} }
@ -628,7 +628,7 @@ RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject,
case SelectMgr_TOU_Full: case SelectMgr_TOU_Full:
anObject->UpdateSelection(curmode); // no break on purpose... anObject->UpdateSelection(curmode); // no break on purpose...
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
break; break;
default: default:
break; break;
@ -653,6 +653,17 @@ RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject,
void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)& anObject, void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)& anObject,
const Standard_Boolean ForceUpdate) 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; Standard_Boolean wasrecomputed;
for(anObject->Init();anObject->More();anObject->Next()){ for(anObject->Init();anObject->More();anObject->Next()){
@ -663,7 +674,7 @@ void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)
case SelectMgr_TOU_Full: case SelectMgr_TOU_Full:
anObject->UpdateSelection(Sel->Mode()); // no break on purpose... anObject->UpdateSelection(Sel->Mode()); // no break on purpose...
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
wasrecomputed = Standard_True; wasrecomputed = Standard_True;
break; break;
default: default:
@ -683,7 +694,7 @@ void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)
case SelectMgr_TOU_Full: case SelectMgr_TOU_Full:
anObject->UpdateSelection(Sel->Mode()); // no break on purpose... anObject->UpdateSelection(Sel->Mode()); // no break on purpose...
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
wasrecomputed = Standard_True; wasrecomputed = Standard_True;
break; break;
default: default:
@ -725,7 +736,7 @@ Update(const Handle(SelectMgr_SelectableObject)& anObject,
case SelectMgr_TOU_Full: case SelectMgr_TOU_Full:
anObject->UpdateSelection(Sel->Mode()); // no break on purpose... anObject->UpdateSelection(Sel->Mode()); // no break on purpose...
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
wasrecomputed = Standard_True; wasrecomputed = Standard_True;
break; break;
default: default:
@ -739,8 +750,8 @@ Update(const Handle(SelectMgr_SelectableObject)& anObject,
case SelectMgr_TOU_Full: case SelectMgr_TOU_Full:
anObject->UpdateSelection(Sel->Mode()); anObject->UpdateSelection(Sel->Mode());
case SelectMgr_TOU_Partial: case SelectMgr_TOU_Partial:
if(anObject->HasLocation()) if(anObject->HasTransformation())
anObject->UpdateLocation(Sel); anObject->UpdateTransformation(Sel);
wasrecomputed = Standard_True; wasrecomputed = Standard_True;
break; break;
default: default:

View File

@ -70,7 +70,7 @@ Standard_Boolean TPrsStd_AxisDriver::Update (const TDF_Label& aLabel,
aistrihed = new AIS_Axis(apt); aistrihed = new AIS_Axis(apt);
else { else {
aistrihed->SetComponent(apt); aistrihed->SetComponent(apt);
aistrihed->ResetLocation(); aistrihed->ResetTransformation();
aistrihed->SetToUpdate(); aistrihed->SetToUpdate();
aistrihed->UpdateSelection(); aistrihed->UpdateSelection();
} }

View File

@ -165,7 +165,7 @@ Standard_Boolean TPrsStd_ConstraintDriver::Update (const TDF_Label& aLabel,
} }
if (anAIS.IsNull()) return Standard_False; if (anAIS.IsNull()) return Standard_False;
anAIS->ResetLocation(); anAIS->ResetTransformation();
anAIS->SetToUpdate(); anAIS->SetToUpdate();
anAIS->UpdateSelection(); anAIS->UpdateSelection();

View File

@ -84,7 +84,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
ais1 = new AIS_Point(apt); ais1 = new AIS_Point(apt);
else { else {
ais1->SetComponent(apt); ais1->SetComponent(apt);
ais1->ResetLocation(); ais1->ResetTransformation();
ais1->SetToUpdate(); ais1->SetToUpdate();
ais1->UpdateSelection(); ais1->UpdateSelection();
} }
@ -107,7 +107,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
ais2 = new AIS_Line(aln); ais2 = new AIS_Line(aln);
else { else {
ais2->SetLine(aln); ais2->SetLine(aln);
ais2->ResetLocation(); ais2->ResetTransformation();
ais2->SetToUpdate(); ais2->SetToUpdate();
ais2->UpdateSelection(); ais2->UpdateSelection();
} }
@ -131,7 +131,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
ais3 = new AIS_Circle(acir); ais3 = new AIS_Circle(acir);
else { else {
ais3->SetCircle(acir); ais3->SetCircle(acir);
ais3->ResetLocation(); ais3->ResetTransformation();
ais3->SetToUpdate(); ais3->SetToUpdate();
ais3->UpdateSelection(); ais3->UpdateSelection();
} }
@ -153,7 +153,7 @@ Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
if (ais.IsNull()) if (ais.IsNull())
ais = new AIS_Shape(mkEdge); ais = new AIS_Shape(mkEdge);
else { else {
ais->ResetLocation(); ais->ResetTransformation();
ais->Set(mkEdge); ais->Set(mkEdge);
ais->SetToUpdate(); ais->SetToUpdate();
ais->UpdateSelection(); ais->UpdateSelection();

View File

@ -82,7 +82,7 @@ Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel,
else { else {
TopoDS_Shape oldShape = AISShape->Shape(); TopoDS_Shape oldShape = AISShape->Shape();
if(oldShape != S) { if(oldShape != S) {
AISShape->ResetLocation(); AISShape->ResetTransformation();
#ifdef OPTIM_UPDATE #ifdef OPTIM_UPDATE
Handle(AIS_InteractiveContext) ctx = AISShape->GetContext(); Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();

View File

@ -63,7 +63,7 @@ Standard_Boolean TPrsStd_PlaneDriver::Update (const TDF_Label& aLabel,
else { else {
aisplane->SetComponent(apt); aisplane->SetComponent(apt);
aisplane->SetCenter(pln.Location()); aisplane->SetCenter(pln.Location());
aisplane->ResetLocation(); aisplane->ResetTransformation();
aisplane->SetToUpdate(); aisplane->SetToUpdate();
aisplane->UpdateSelection(); aisplane->UpdateSelection();
} }

View File

@ -63,7 +63,7 @@ Standard_Boolean TPrsStd_PointDriver::Update (const TDF_Label& aLabel,
aistrihed = new AIS_Point(apt); aistrihed = new AIS_Point(apt);
else { else {
aistrihed->SetComponent(apt); aistrihed->SetComponent(apt);
aistrihed->ResetLocation(); aistrihed->ResetTransformation();
aistrihed->SetToUpdate(); aistrihed->SetToUpdate();
aistrihed->UpdateSelection(); aistrihed->UpdateSelection();
} }

View File

@ -3154,11 +3154,11 @@ static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char**
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
} }
TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Location() ); TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() );
TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Location() ); TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() );
myAisCrankArm ->ResetLocation(); myAisCrankArm ->ResetTransformation();
myAisPropeller->ResetLocation(); myAisPropeller->ResetTransformation();
myAisCrankArm -> Set(myNewCrankArm ); myAisCrankArm -> Set(myNewCrankArm );
myAisPropeller -> Set(myNewPropeller); myAisPropeller -> Set(myNewPropeller);

View File

@ -117,9 +117,8 @@
#include <StdPrs_ShadedShape.hxx> #include <StdPrs_ShadedShape.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <AIS_ConnectedShape.hxx>
#include <AIS_MultipleConnectedInteractive.hxx> #include <AIS_MultipleConnectedInteractive.hxx>
#include <AIS_MultipleConnectedShape.hxx> #include <AIS_ConnectedInteractive.hxx>
#include <TopLoc_Location.hxx> #include <TopLoc_Location.hxx>
#include <TColStd_ListOfInteger.hxx> #include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx> #include <TColStd_ListIteratorOfListOfInteger.hxx>
@ -3498,13 +3497,13 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext.IsNull()) if (aContext.IsNull())
{ {
di << argv[0] << "ERROR : use 'vinit' command before " << "\n"; std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
return 1; return 1;
} }
if (argc != 5) 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; return 1;
} }
@ -3518,7 +3517,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
Handle(AIS_InteractiveObject) anIObj; Handle(AIS_InteractiveObject) anIObj;
if (!aMap.IsBound2 (aName)) if (!aMap.IsBound2 (aName))
{ {
di << "Use 'vdisplay' before" << "\n"; std::cout << "Use 'vdisplay' before" << "\n";
return 1; return 1;
} }
else else
@ -3528,7 +3527,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
// not an AIS_InteractiveObject // not an AIS_InteractiveObject
if (anIObj.IsNull()) if (anIObj.IsNull())
{ {
di << argv[1] << " : Not an AIS interactive object" << "\n"; std::cout << argv[1] << " : Not an AIS interactive object" << "\n";
return 1; return 1;
} }
@ -3545,12 +3544,12 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
//=============================================================================================== //===============================================================================================
//function : VConnect //function : VConnect
//purpose : Creates and displays AIS_ConnectedInteractive object from input object and location //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*/, static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
Standard_Integer argc, Standard_Integer argc,
const char ** argv) const char ** argv)
{ {
// Check the viewer // Check the viewer
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
@ -3560,16 +3559,16 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
return 1; // TCL_ERROR return 1; // TCL_ERROR
} }
// Check argumnets // 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 return 1; // TCL_ERROR
} }
// Get values // Get values
Standard_Integer anArgIter = 1; Standard_Integer anArgIter = 1;
TCollection_AsciiString aName (argv[anArgIter++]); TCollection_AsciiString aName (argv[anArgIter++]);
Handle(AIS_InteractiveObject) anOriginObject; Handle(AIS_MultipleConnectedInteractive) anOriginObject;
TCollection_AsciiString aColorString (argv[argc-1]); TCollection_AsciiString aColorString (argv[argc-1]);
Standard_CString aColorName = ""; Standard_CString aColorName = "";
Standard_Boolean hasColor = Standard_False; Standard_Boolean hasColor = Standard_False;
@ -3581,23 +3580,24 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
} }
Handle(AIS_InteractiveObject) anObject; Handle(AIS_InteractiveObject) anObject;
// AIS_ConnectedInteractive // AIS_MultipleConnectedInteractive
if (argc == 12 || (argc == 13 && hasColor)) 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)) if (aName.IsEqual (anOriginObjectName))
{ {
std::cout << "vconnect error: equal names for connected objects\n"; std::cout << "vconnect error: equal names for connected objects\n";
return 1; // TCL_ERROR continue;
} }
if (GetMapOfAIS().IsBound2 (anOriginObjectName)) if (GetMapOfAIS().IsBound2 (anOriginObjectName))
{ {
Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName); Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj); anObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
if (anOriginObject.IsNull()) if (anObject.IsNull())
{ {
std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n"; std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
return 1; // TCL_ERROR continue;
} }
} }
else else
@ -3607,101 +3607,131 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
if (aTDShape.IsNull()) if (aTDShape.IsNull())
{ {
std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n"; 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; continue;
} }
if (GetMapOfAIS().IsBound2 (anOriginObjectName)) anObject = new AIS_Shape (aTDShape);
{ anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
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);
}
} }
if (anOriginObject.IsNull()) if (anOriginObject.IsNull())
{ {
std::cout << "vconect error : can't connect input objects\n"; anOriginObject = new AIS_MultipleConnectedInteractive();
return 1; // TCL_ERROR
} }
anOriginObject->Connect (anObject);
}
if (anOriginObject.IsNull())
{
std::cout << "vconect error : can't connect input objects\n";
return 1; // TCL_ERROR
} }
// Get location data // Get location data
Standard_Real aXo = Draw::Atof (argv[anArgIter++]); Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
Standard_Real aYo = Draw::Atof (argv[anArgIter++]); Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
Standard_Real aZo = 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 // Create transformation
gp_Pnt aPoint(aXo, aYo, aZo); gp_Vec aTranslation (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_Trsf aTrsf;
aTrsf.SetTransformation(anAx3);
TopLoc_Location aLocation(aTrsf);
// Create connected object gp_Trsf aTrsf;
Handle(AIS_ConnectedInteractive) aConnected = new AIS_ConnectedInteractive(); aTrsf.SetTranslationPart (aTranslation);
Handle(AIS_MultipleConnectedInteractive) anOrigin = Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject); TopLoc_Location aLocation (aTrsf);
if (anOrigin.IsNull())
anOriginObject->SetLocalTransformation (aTrsf);
// Check if there is another object with given name
// and remove it from context
if(GetMapOfAIS().IsBound2(aName))
{ {
aConnected->Connect (anOriginObject, aLocation); Handle(AIS_InteractiveObject) anObj =
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
TheAISContext()->Remove(anObj, Standard_False);
GetMapOfAIS().UnBind2(aName);
}
// Bind connected object to its name
GetMapOfAIS().Bind (anOriginObject, aName);
// Display connected object
TheAISContext()->Display (anOriginObject);
return 0;
}
//===============================================================================================
//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 VConnectTo (Draw_Interpretor& /*di*/,
Standard_Integer argc,
const char ** argv)
{
// Check the viewer
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext.IsNull())
{
std::cout << "vconnect error : call vinit before\n";
return 1; // TCL_ERROR
}
// Check argumnets
if (argc != 6)
{
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;
TCollection_AsciiString anOriginObjectName(argv[5]);
if (aName.IsEqual (anOriginObjectName))
{
std::cout << "vconnect error: equal names for connected objects\n";
return 1; // TCL_ERROR
}
if (GetMapOfAIS().IsBound2 (anOriginObjectName))
{
Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
if (anOriginObject.IsNull())
{
std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
return 1; // TCL_ERROR
}
} }
else else
{ {
aConnected->Connect (anOrigin, aLocation); Standard_CString aName = anOriginObjectName.ToCString();
TopoDS_Shape aTDShape = DBRep::Get (aName);
if (aTDShape.IsNull())
{
std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
return 1; // TCL_ERROR
}
anOriginObject = new AIS_Shape (aTDShape);
} }
// Get location data
Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
// Create transformation
gp_Vec aTranslation (aXo, aYo, aZo);
gp_Trsf aTrsf;
aTrsf.SetTranslationPart (aTranslation);
Handle(AIS_ConnectedInteractive) aConnected;
aConnected = new AIS_ConnectedInteractive();
aConnected->Connect (anOriginObject, aTrsf);
// Check if there is another object with given name // Check if there is another object with given name
// and remove it from context // and remove it from context
@ -3722,188 +3752,208 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
return 0; return 0;
} }
//=============================================================================================== //=======================================================================
//function : VConnectShape //function : VDisconnect
//purpose : Creates and displays AIS_ConnectedShape from input shape and location //purpose :
//Draw arg : vconnectsh name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME] //=======================================================================
//=============================================================================================== static Standard_Integer VDisconnect (Draw_Interpretor& di,
Standard_Integer argc,
static Standard_Integer VConnectShape(Draw_Interpretor& /*di*/, const char ** argv)
Standard_Integer argc,
const char ** argv)
{ {
// Check the viewer
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext.IsNull()) if (aContext.IsNull())
{ {
std::cout << "vconnectsh error : call vinit before\n"; std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
return 1; // TCL_ERROR return 1;
} }
// Check argumnets
if (argc < 12) if (argc != 3)
{ {
std::cout << "vconnectsh error: expect at least 11 arguments\n"; std::cout << "ERROR : Usage : " << argv[0] << " name object" << "\n";
return 1; // TCL_ERROR return 1;
} }
// Get values TCollection_AsciiString aName (argv[1]);
Standard_Integer anArgIter = 1; TCollection_AsciiString anObject (argv[2]);
TCollection_AsciiString aName (argv[anArgIter++]); Standard_Integer anObjectNumber = Draw::Atoi (argv[2]);
Handle(AIS_InteractiveObject) anOriginShape;
TCollection_AsciiString aColorString(argv[argc-1]);
Standard_CString aColorName = "";
Standard_Boolean hasColor = Standard_False;
if (aColorString.Search ("color=") != -1)
{
hasColor = Standard_True;
aColorString.Remove (1, 6);
aColorName = aColorString.ToCString();
}
Handle(AIS_Shape) aShape;
// AIS_ConnectedShape // find objects
if (argc == 12 || (argc == 13 && hasColor)) ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
Handle(AIS_MultipleConnectedInteractive) anAssembly;
if (!aMap.IsBound2 (aName) )
{ {
TCollection_AsciiString anOriginShapeName (argv[11]); std::cout << "Use 'vdisplay' before" << "\n";
if (aName.IsEqual (anOriginShapeName)) 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())
{ {
std::cout << "vconnectsh error: equal names for connected shapes\n"; Standard_Integer aCounter = 1;
return 1; // TCL_ERROR for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
}
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!"; if (aCounter == anObjectNumber)
return 1; // TCL_ERROR {
anIObj = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
break;
}
++aCounter;
} }
} }
else else
{ {
Standard_CString aName = anOriginShapeName.ToCString(); std::cout << "Use 'vdisplay' before" << "\n";
TopoDS_Shape aTDShape = DBRep::Get (aName); return 1;
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 // if object was found by name
if (anIObj.IsNull())
{ {
const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc; anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
for (Standard_Integer i = 11; i < aNbShapes; ++i) }
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 anOriginShapeName (argv[i]); TCollection_AsciiString aName = GetMapOfAIS().Find1 (anIter.Value());
if (aName.IsEqual (anOriginShapeName)) std::cout << aCounter << ") " << aName << " (" << anIter.Value()->DynamicType()->Name() << ")";
{
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 << 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 << "vconectsh error : can't connect input objects\n"; std::cout << " connected to " << aMap.Find1 (aConnected->ConnectedTo());
return 1; // TCL_ERROR
} }
std::cout << std::endl;
++aCounter;
} }
// 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);
// Create connected shape
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);
}
// Check if there is another object with given name
// and remove it from context
if(GetMapOfAIS().IsBound2(aName))
{
Handle(AIS_InteractiveObject) anObj =
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
TheAISContext()->Remove(anObj, Standard_False);
GetMapOfAIS().UnBind2(aName);
}
// Bind connected shape to its name
GetMapOfAIS().Bind (aConnected, aName);
// Display connected shape
TheAISContext()->Display (aConnected);
return 0; return 0;
} }
@ -5402,12 +5452,30 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
__FILE__,VDrawPArray,group); __FILE__,VDrawPArray,group);
theCommands.Add("vconnect", 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); __FILE__, VConnect, group);
theCommands.Add("vconnectsh", theCommands.Add("vconnectto",
"vconnectsh : name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME]", "vconnectto : instance_name Xo Yo Zo object"
__FILE__, VConnectShape, group); " 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", theCommands.Add("vselmode",
"vselmode : [object] mode_number is_turned_on=(1|0)\n" "vselmode : [object] mode_number is_turned_on=(1|0)\n"

View File

@ -6713,6 +6713,53 @@ static int VHighlightSelected (Draw_Interpretor& theDI,
return 0; 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 //function : ViewerCommands
//purpose : //purpose :
@ -7086,4 +7133,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"Without arguments it shows if highlighting of selected objects is enabled now.", "Without arguments it shows if highlighting of selected objects is enabled now.",
__FILE__,VHighlightSelected,group); __FILE__,VHighlightSelected,group);
theCommands.Add("vxrotate",
"vxrotate",
__FILE__,VXRotate,group);
} }

View File

@ -58,7 +58,7 @@ set y_refresh 10
restore [locate_data_file OCC12121-CrankArm.brep] obj restore [locate_data_file OCC12121-CrankArm.brep] obj
vinit vinit
vdisplay obj vdisplay obj
vconnectsh new 50 50 50 1 0 0 0 0 1 obj vconnect new 50 50 50 obj
vfit vfit
vmoveto $x1 $y1 vmoveto $x1 $y1
set ColorObj1 [QAGetPixelColor ${x2} ${y2}] set ColorObj1 [QAGetPixelColor ${x2} ${y2}]
@ -68,12 +68,12 @@ vselect $x1 $y1
set ColorObj2 [QAGetPixelColor ${x2} ${y2}] set ColorObj2 [QAGetPixelColor ${x2} ${y2}]
set ColorNew2 [QAGetPixelColor ${x3} ${y3}] set ColorNew2 [QAGetPixelColor ${x3} ${y3}]
puts "Check vconnectsh command" puts "Check vconnect command"
set status_vconnectsh 0 set status_vconnect 0
if { ${ColorObj1} == ${ColorNew1} && ${ColorObj2} == ${ColorNew2} } { if { ${ColorObj1} == ${ColorNew1} && ${ColorObj2} == ${ColorNew2} } {
set status_vconnectsh 0 set status_vconnect 0
} else { } else {
set status_vconnectsh 1 set status_vconnect 1
} }
vselect ${x_refresh} ${y_refresh} vselect ${x_refresh} ${y_refresh}
@ -124,7 +124,7 @@ vselect ${x_refresh} ${y_refresh}
##Resume ##Resume
puts "" puts ""
if { ${status_vconnectsh} == 0 } { if { ${status_vconnect} == 1 } {
puts "OK ${BugNumber}" puts "OK ${BugNumber}"
} else { } else {
puts "Faulty ${BugNumber}" puts "Faulty ${BugNumber}"

20
tests/bugs/vis/bug23422 Normal file
View File

@ -0,0 +1,20 @@
puts "============"
puts "CR23422"
puts "============"
puts ""
#######################################################################
# Selection problems when using SetLocation.
#######################################################################
box b 50 50 50
vinit
vsetdispmode 1
vdisplay b
vtrihedron t
vsetlocation b 30 30 130
vmoveto 240 150
set anImage ${imagedir}/${casename}.png
vdump ${anImage}

View File

@ -17,7 +17,7 @@ vinit View1
vclear vclear
vaxo vaxo
vsetdispmode 1 vsetdispmode 1
vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 vconnect b1c -3 0 0 b1 b2
vfit vfit
vdump $Image1 vdump $Image1

18
tests/bugs/vis/bug24756 Normal file
View File

@ -0,0 +1,18 @@
puts "============"
puts "CR24756"
puts "============"
puts ""
#######################################################################
# AIS_ConnectedInteractive does not support nested AIS_ConnectedInteractive
#######################################################################
vinit
box b 1 1 1
vdisplay b
vconnectto b1 2 0 0 b
vconnectto b2 2 0 0 b1
vsetlocation b1 2 1 0
vfit
set anImage ${imagedir}/${casename}.png
vdump ${anImage}

41
tests/bugs/vis/bug24837_1 Normal file
View File

@ -0,0 +1,41 @@
puts "============"
puts "CR24837_1"
puts "============"
puts ""
#######################################################################
# Visualization - revise design and implementation of connected Interactive Objects
#######################################################################
pload MODELING VISUALIZATION
vinit
box b 1 1 1
psphere s 0.5
vdisplay b s
vsetlocation s 0 2.5 0
box d 0.5 0.5 3
box d2 0.5 3 0.5
vdisplay d d2
vconnectto b1 -2 0 0 b
vconnect z 2 0 0 b s
vconnect z2 4 0 0 d d2
vconnect z3 6 0 0 z z2
vconnect z4 10 0 0 z3 z2
vfit
set anImage ${imagedir}/${casename}_1_1.png
vdump ${anImage}
vaddconnected z4 0 4 0 s
vdisconnect z4 1
vfit
set anImage ${imagedir}/${casename}_1_2.png
vdump ${anImage}
vhlr on
set anImage ${imagedir}/${casename}_1_3.png
vdump ${anImage}
vhlr off
vsetdispmode 1
vmoveto 320 330
set anImage ${imagedir}/${casename}_1_4.png
vdump ${anImage}

38
tests/bugs/vis/bug24837_2 Normal file
View File

@ -0,0 +1,38 @@
puts "============"
puts "CR24837_2"
puts "============"
puts ""
#######################################################################
# Visualization - revise design and implementation of connected Interactive Objects
#######################################################################
pload MODELING VISUALIZATION
box o1 -10 -10 -5 1 1 10
box o2 10 10 -5 1 1 10
box b1 0 0 0 1 2 3
box b2 3 0 0 3 2 1
vinit View1
vclear
vtop
vsetdispmode 0
vdisplay o1 o2
vdisplay b1 b2
vfit
vdrawtext "b1" 0 -3 3 255 25 25 2 0 000 0 14 1 Arial
vdrawtext "b2" 3 0 3 25 255 25 2 0 000 0 14 1 Arial
vdrawtext "bc_1" 0 -9 3 255 225 225 2 0 000 0 14 1 Arial
vdrawtext "bc_2" 3 -6 3 255 225 225 2 0 000 0 14 1 Arial
vsetdispmode 1
set anImage ${imagedir}/${casename}_2_1.png
vdump ${anImage}
vsetmaterial b1 b2 plastic
vsetcolor b1 RED
vsetcolor b2 GREEN
set anImage ${imagedir}/${casename}_2_2.png
vdump ${anImage}
vsetlocation b1 0 -3 0
vconnect bc 0 -6 0 b1 b2
set anImage ${imagedir}/${casename}_2_3.png
vdump ${anImage}

48
tests/bugs/vis/bug25103 Normal file
View File

@ -0,0 +1,48 @@
puts "============"
puts "CR25103"
puts "============"
puts ""
#######################################################################
# Visualization - Regression in interactive detection
#######################################################################
vinit
vsetdispmode 1
box wall1 1 8 8
box wall2 1 8 8
box wall3 16 8 1
vdisplay wall1
vdisplay wall2
vdisplay wall3
vsetlocation wall1 -10 0 0
vsetlocation wall2 5 0 0
vsetlocation wall3 -10 0 -1
vsetmaterial wall1 stone
vsetmaterial wall2 stone
vsetmaterial wall3 pewter
vsetcolor wall1 red
vsetcolor wall2 green
vright
vturnview 0 -0.3 0
vfit
set anImage ${imagedir}/${casename}_1.png
vdump ${anImage}
# The next line should highlight the green box (wall2) but it does not
vmoveto 394 205
set anImage ${imagedir}/${casename}_2.png
vdump ${anImage}
# The next line should not hit any object but it highlights the green box
vmoveto 264 205
set anImage ${imagedir}/${casename}_3.png
vdump ${anImage}

View File

@ -12,12 +12,12 @@ vclear
vrenderparams -rasterization vrenderparams -rasterization
vsetdispmode 1 vsetdispmode 1
vaxo vaxo
vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 vconnect b1c -3 0 0 b1 b2
vfit vfit
vrotate 0.2 0.0 0.0 vrotate 0.2 0.0 0.0
vfit vfit
vclear 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 # take snapshot with fixed pipeline
vdump $::imagedir/${::casename}_OFF.png vdump $::imagedir/${::casename}_OFF.png
@ -27,4 +27,4 @@ vrenderparams -raytrace
vdump $::imagedir/${::casename}_rt1.png vdump $::imagedir/${::casename}_rt1.png
vclear vclear
vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 vconnect b1c -3 0 0 b1 b2