1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

1
src/TPrsStd/FILES Executable file
View File

@@ -0,0 +1 @@
GUID.txt

27
src/TPrsStd/GUID.txt Executable file
View File

@@ -0,0 +1,27 @@
00000000-0000-0000-0000-000000000000 Reserved
ffffffff-ffff-ffff-ffff-ffffffffffff Reserved
04fb4d00-5690-11d1-8940-080009dc3333 TPrsStd_AISPresentation
04fb4d01-5690-11d1-8940-080009dc3333 TPrsStd_ColorAttribute
04fb4d02-5690-11d1-8940-080009dc3333 TPrsStd_TransparencyAttribute
04fb4d04-5690-11d1-8940-080009dc3333 TPrsStd_GraphicAttribute
04fb4d05-5690-11d1-8940-080009dc3333 TPrsStd_AISViewer
04fb4d06-5690-11d1-8940-080009dc3333 Free
04fb4d07-5690-11d1-8940-080009dc3333 Free
04fb4d08-5690-11d1-8940-080009dc3333 Free
04fb4d09-5690-11d1-8940-080009dc3333 Free
04fb4d0a-5690-11d1-8940-080009dc3333 Free
04fb4d0b-5690-11d1-8940-080009dc3333 Free
04fb4d0c-5690-11d1-8940-080009dc3333 Free
04fb4d0d-5690-11d1-8940-080009dc3333 Free
04fb4d0e-5690-11d1-8940-080009dc3333 Free
04fb4d0f-5690-11d1-8940-080009dc3333 Free
04fb4d10-5690-11d1-8940-080009dc3333 Free
04fb4d11-5690-11d1-8940-080009dc3333 Free
04fb4d12-5690-11d1-8940-080009dc3333 Free
04fb4d13-5690-11d1-8940-080009dc3333 Free
04fb4d14-5690-11d1-8940-080009dc3333 Free
04fb4d15-5690-11d1-8940-080009dc3333 Free
04fb4d16-5690-11d1-8940-080009dc3333 Free
...
04fb4dff-5690-11d1-8940-080009dc3333 Free

67
src/TPrsStd/TPrsStd.cdl Executable file
View File

@@ -0,0 +1,67 @@
-- File: TPrsStd.cdl
-- Created: 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
package TPrsStd
---Purpose: The visualization attribute implements the
-- Application Interactive Services in the context
-- of Open CASCADE Application Framework.
---Category: GUID
-- 04fb4d05-5690-11d1-8940-080009dc3333 TPrsStd_AISViewer
-- 04fb4d00-5690-11d1-8940-080009dc3333 TPrsStd_AISPresentation
uses
Standard,
TCollection,
TColStd,
MMgt,
Quantity,
Graphic3d,
AIS,
V3d,
TDF,
TDataXtd,
Geom,
TopoDS,
gp
is
---Category: Attributes
-- ==========
class AISViewer;
class AISPresentation;
---Category : Drivers to build and/or update AIS objects
-- ==========================================
deferred class Driver;
class PointDriver ; -- to display Point
class AxisDriver ; -- to display Axis
class PlaneDriver ; -- to display Plane
class GeometryDriver; -- to display Geometry
class ConstraintDriver; -- to display Constraint
class NamedShapeDriver; -- to display NamedShape
class DriverTable ;
---Category: Tools
-- =====
class ConstraintTools;
class DataMapOfGUIDDriver
instantiates DataMap from TCollection(GUID from Standard,
Driver from TPrsStd,
GUID from Standard);
end TPrsStd;

View File

@@ -0,0 +1,225 @@
-- File: TPrsStd_AISPresentation.cdl
-- Created: Wed Sep 30 08:38:35 1998
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
-- Lastly modified by :
-- +---------------------------------------------------------------------------+
-- ! ivan ! SetMode ! 5-04-2001! 3.0-00-1!
-- +---------------------------------------------------------------------------+
class AISPresentation from TPrsStd inherits Attribute from TDF
---Purpose: An attribute to associate an
-- AIS_InteractiveObject to a label in an AIS viewer.
-- This attribute works in collaboration with TPrsStd_AISViewer.
-- Note that all the Set... and Unset... attribute
-- methods as well as the query methods for
-- visualization attributes and the HasOwn... test
-- methods are shortcuts to the respective
-- AIS_InteractiveObject settings.
uses GUID from Standard,
AttributeIndexedMap from TDF,
DataSet from TDF,
AttributeDelta from TDF,
Label from TDF,
RelocationTable from TDF,
InteractiveObject from AIS,
Length from Quantity,
NameOfColor from Quantity,
PlaneAngle from Quantity,
NameOfMaterial from Graphic3d,
Drawer from AIS
is
GetID (myclass) returns GUID from Standard;
---Purpose: Returns the GUID for TPrsStd_AISPresentation attributes.
---C++: return const &
Set (myclass; L : Label from TDF; driver : GUID from Standard)
---Purpose: Creates or retrieves the presentation attribute on
-- the label L, and sets the GUID driver.
returns AISPresentation from TPrsStd;
Unset (myclass; L : Label from TDF);
---Purpose: Delete (if exist) the presentation attribute associated to the label <L>.
Set (myclass; master : Attribute from TDF)
---Purpose: Creates or retrieves the AISPresentation
-- attribute attached to master.
-- The GUID of the driver will be the GUID of master.
-- master is the attribute you want to display.
returns AISPresentation from TPrsStd;
---Category: Presentation attribute implementation
-- ======================================
Create returns mutable AISPresentation from TPrsStd;
SetDisplayed(me : mutable; B : Boolean from Standard);
Display (me : mutable; update : Boolean from Standard = Standard_False);
---Purpose: Display presentation of object in AIS viewer.
-- If <update> = True then AISObject is recomputed and all
-- the visualization settings are applied
Erase (me : mutable; remove : Boolean from Standard = Standard_False);
---Purpose: Removes the presentation of this AIS
-- presentation attribute from the TPrsStd_AISViewer.
-- If remove is true, this AIS presentation attribute
-- is removed from the interactive context.
Update (me : mutable);
---Purpose: Recompute presentation of object and apply the visualization settings
GetDriverGUID (me) returns GUID from Standard;
SetDriverGUID (me: mutable ; guid : GUID from Standard);
IsDisplayed (me)
returns Boolean from Standard;
---Purpose:
-- Returns true if this AIS presentation attribute is displayed.
GetAIS (me) returns InteractiveObject from AIS;
---Purpose: Returns AIS_InteractiveObject stored in the presentation attribute
AISUpdate (me : mutable)
---Purpose: Updates AIS_InteractiveObject stored in the attribute
-- and applies the visualization settings
is private;
AISDisplay (me : mutable)
---Purpose: Displays AIS_InteractiveObject stored in the attribute
is private;
AISErase (me : mutable; remove : Boolean from Standard = Standard_False)
---Purpose: Erases AIS_InteractiveObject stored in the attribute in
-- the viewer; If <remove> = True then AISObject is removed
-- from AIS_InteractiveContext instead of simple erasing in the viewer
is private;
---Category: Visualization settings of AIS_InteractiveObject
-- ================================================
Material(me) returns NameOfMaterial from Graphic3d;
---Purpose:
-- Returns the material setting for this presentation attribute.
SetMaterial(me : mutable; aName : NameOfMaterial from Graphic3d);
---Purpose: Sets the material aName for this presentation attribute.
HasOwnMaterial(me) returns Boolean from Standard;
---Purpose: Returns true if this presentation attribute already has a material setting.
UnsetMaterial(me : mutable);
---Purpose: Removes the material setting from this presentation attribute.
SetTransparency(me : mutable; aValue : Real from Standard=0.6);
--- Purpose:
-- Sets the transparency value aValue for this
-- presentation attribute.
-- This value is 0.6 by default.
Transparency(me) returns Real from Standard;
HasOwnTransparency(me) returns Boolean from Standard;
---Purpose: Returns true if this presentation attribute already has a transparency setting.
UnsetTransparency(me : mutable);
---Purpose: Removes the transparency setting from this presentation attribute.
Color(me) returns NameOfColor from Quantity;
SetColor(me: mutable; aColor : NameOfColor from Quantity);
---Purpose: Sets the color aColor for this presentation attribute.
HasOwnColor(me) returns Boolean from Standard;
---Purpose: Returns true if this presentation attribute already has a color setting.
UnsetColor(me : mutable);
---Purpose: Removes the color setting from this presentation attribute.
Width(me) returns Real from Standard ;
SetWidth(me: mutable; aWidth : Real from Standard);
---Purpose: Sets the width aWidth for this presentation attribute.
HasOwnWidth(me) returns Boolean from Standard;
---Purpose: Returns true if this presentation attribute already has a width setting.
UnsetWidth(me : mutable);
---Purpose: Removes the width setting from this presentation attribute.
Mode(me) returns Integer from Standard;
SetMode(me: mutable; theMode : Integer from Standard);
HasOwnMode(me) returns Boolean from Standard;
UnsetMode(me : mutable);
SelectionMode(me) returns Integer from Standard;
SetSelectionMode(me: mutable; theSelectionMode : Integer from Standard);
HasOwnSelectionMode(me) returns Boolean from Standard;
UnsetSelectionMode(me : mutable);
---Category: Methods of TDF_Attribute
-- ========================
ID(me)returns GUID from Standard;
---C++: return const &
NewEmpty(me)
returns mutable Attribute from TDF;
Restore(me: mutable; with : Attribute from TDF);
Paste (me; into : mutable Attribute from TDF;
RT : mutable RelocationTable from TDF);
BackupCopy(me) returns mutable Attribute from TDF is redefined;
---Category: Callbacks for viewer updating
-- =============================
AfterAddition (me: mutable)
is redefined;
BeforeRemoval (me: mutable)
is redefined;
BeforeForget(me: mutable)
is redefined;
AfterResume(me: mutable)
is redefined;
BeforeUndo (me: mutable; anAttDelta : AttributeDelta from TDF;
forceIt : Boolean from Standard = Standard_False)
returns Boolean from Standard
is redefined;
AfterUndo (me: mutable; anAttDelta : AttributeDelta from TDF;
forceIt : Boolean from Standard = Standard_False)
---Purpose: update AIS viewer according to delta
returns Boolean from Standard
is redefined;
fields
myDriverGUID : GUID from Standard;
myTransparency : Real from Standard;
myColor : NameOfColor from Quantity;
myMaterial : NameOfMaterial from Graphic3d;
myWidth : Real from Standard;
myMode : Integer from Standard;
mySelectionMode : Integer from Standard;
isDisplayed : Boolean from Standard;
hasOwnColor : Boolean from Standard;
hasOwnMaterial : Boolean from Standard;
hasOwnTransparency : Boolean from Standard;
hasOwnWidth : Boolean from Standard;
hasOwnMode : Boolean from Standard;
hasOwnSelectionMode: Boolean from Standard;
myAIS : InteractiveObject from AIS;
end AISPresentation;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
-- File: TPrsStd_AISViewer.cdl
-- Created: Wed Sep 30 08:32:32 1998
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class AISViewer from TPrsStd inherits Attribute from TDF
---Purpose: The groundwork to define an interactive viewer attribute.
-- This attribute stores an interactive context at the root label.
-- You can only have one instance of this class per data framework.
uses Attribute from TDF,
Label from TDF,
GUID from Standard,
DataSet from TDF,
RelocationTable from TDF,
InteractiveContext from AIS,
Viewer from V3d,
ExtendedString from TCollection
is
---Purpose: class methods
-- =============
GetID (myclass)
---C++: return const &
returns GUID from Standard;
Has (myclass; acces : Label from TDF)
---Purpose: returns True if there is an AISViewer attribute in
-- <acces> Data Framework.
returns Boolean from Standard;
New (myclass; access : Label from TDF; selector : InteractiveContext from AIS)
---Purpose: create and set an AISViewer at. Raise an exception if
-- Has.
returns AISViewer from TPrsStd;
New (myclass; acces : Label from TDF; viewer : Viewer from V3d)
---Purpose: create and set an AISAttribute at root label. The
-- interactive context is build. Raise an exception if
-- Has.
returns AISViewer from TPrsStd;
Find (myclass; acces : Label from TDF; A : in out AISViewer from TPrsStd)
returns Boolean from Standard;
---Purpose:
-- Finds the viewer attribute at the label access, the
-- root of the data framework. Calling this function can be used to initialize an AIS viewer
Find (myclass; acces : Label from TDF; IC : in out InteractiveContext from AIS)
returns Boolean from Standard;
Find (myclass; acces : Label from TDF; V : in out Viewer from V3d)
returns Boolean from Standard;
Update (myclass; acces : Label from TDF);
---Purpose: AISViewer methods
-- =================
Create
returns mutable AISViewer from TPrsStd;
Update (me);
---Purpose: Updates the viewer at the label access.
-- access is the root of the data framework.
SetInteractiveContext (me : mutable; ctx : InteractiveContext from AIS);
---Purpose: Sets the interactive context ctx for this attribute.
GetInteractiveContext (me)
returns InteractiveContext from AIS;
---Purpose: Returns the interactive context in this attribute.
---Category: TDF_Attribute methods
-- =====================
ID (me)
---C++: return const &
returns GUID from Standard;
Restore(me: mutable; with : Attribute from TDF);
NewEmpty(me)
returns mutable Attribute from TDF;
Paste (me; into : mutable Attribute from TDF;
RT : mutable RelocationTable from TDF);
fields
myInteractiveContext : InteractiveContext from AIS;
end AISViewer;

193
src/TPrsStd/TPrsStd_AISViewer.cxx Executable file
View File

@@ -0,0 +1,193 @@
// File: TPrsStd_AISViewer.cxx
// Created: Wed Sep 30 09:30:28 1998
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <TPrsStd_AISViewer.ixx>
#include <TDF_Label.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TPrsStd_AISViewer::GetID ()
{
static Standard_GUID TPrsStd_AISViewerID("04fb4d05-5690-11d1-8940-080009dc3333");
return TPrsStd_AISViewerID;
}
//=======================================================================
//function : New
//purpose :
//=======================================================================
Handle(TPrsStd_AISViewer) TPrsStd_AISViewer::New (const TDF_Label& acces,
const Handle(V3d_Viewer)& viewer)
{
Handle(TPrsStd_AISViewer) V;
if (acces.Root().FindAttribute(TPrsStd_AISViewer::GetID(),V)) {
Standard_DomainError::Raise("already done");
}
V = new TPrsStd_AISViewer();
V->SetInteractiveContext (new AIS_InteractiveContext(viewer));
acces.Root().AddAttribute(V);
return V;
}
//=======================================================================
//function : New
//purpose :
//=======================================================================
Handle(TPrsStd_AISViewer) TPrsStd_AISViewer::New (const TDF_Label& acces,
const Handle(AIS_InteractiveContext)& IC)
{
Handle(TPrsStd_AISViewer) V;
if (acces.Root().FindAttribute(TPrsStd_AISViewer::GetID(),V)) {
Standard_DomainError::Raise("already done");
}
V = new TPrsStd_AISViewer();
V->SetInteractiveContext (IC);
acces.Root().AddAttribute(V);
return V;
}
//=======================================================================
//function : Find
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_AISViewer::Find (const TDF_Label& acces,
Handle(TPrsStd_AISViewer)& V)
{
return (acces.Root().FindAttribute(TPrsStd_AISViewer::GetID(),V));
}
//=======================================================================
//function : Find
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_AISViewer::Find (const TDF_Label& acces,
Handle(AIS_InteractiveContext)& IC)
{
Handle(TPrsStd_AISViewer) V;
if (acces.Root().FindAttribute(TPrsStd_AISViewer::GetID(),V)) {
IC = V->GetInteractiveContext();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Find
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_AISViewer::Find (const TDF_Label& acces,
Handle(V3d_Viewer)& VIEW)
{
Handle(TPrsStd_AISViewer) V;
if (acces.Root().FindAttribute(TPrsStd_AISViewer::GetID(),V)) {
VIEW = V->GetInteractiveContext()->CurrentViewer();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Has
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_AISViewer::Has (const TDF_Label& acces)
{
return (acces.Root().IsAttribute(TPrsStd_AISViewer::GetID()));
}
//=======================================================================
//function : Update
//purpose :
//=======================================================================
void TPrsStd_AISViewer::Update (const TDF_Label& acces)
{
Handle(TPrsStd_AISViewer) viewer;
if (Find (acces,viewer)) viewer->Update();
}
//=======================================================================
//function : TPrsStd_AISViewer
//purpose :
//=======================================================================
TPrsStd_AISViewer::TPrsStd_AISViewer()
{
}
//=======================================================================
//function : Update
//purpose :
//=======================================================================
void TPrsStd_AISViewer::Update () const
{
myInteractiveContext->UpdateCurrentViewer();
}
//=======================================================================
//function : SetInteractiveContext
//purpose :
//=======================================================================
void TPrsStd_AISViewer::SetInteractiveContext(const Handle(AIS_InteractiveContext)& ctx)
{
myInteractiveContext = ctx;
}
//=======================================================================
//function : GetInteractiveContext
//purpose :
//=======================================================================
Handle(AIS_InteractiveContext) TPrsStd_AISViewer::GetInteractiveContext() const
{
return myInteractiveContext;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TPrsStd_AISViewer::ID() const { return GetID(); }
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TPrsStd_AISViewer::Restore(const Handle(TDF_Attribute)& with)
{
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TPrsStd_AISViewer::NewEmpty() const
{
return new TPrsStd_AISViewer();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TPrsStd_AISViewer::Paste (const Handle(TDF_Attribute)& into,
const Handle(TDF_RelocationTable)& RT) const
{
}

View File

@@ -0,0 +1,31 @@
-- File: TPrsStd_AxisDriver.cdl
-- Created: Fri Aug 1 11:21:30 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
class AxisDriver from TPrsStd inherits Driver from TPrsStd
---Purpose: An implementation of TPrsStd_Driver for axes.
uses
GUID from Standard,
Label from TDF,
InteractiveObject from AIS
is
Create
returns mutable AxisDriver from TPrsStd;
---Purpose: Constructs an empty axis driver.
Update (me : mutable ;
aLabel : Label from TDF;
anAISObject : in out InteractiveObject from AIS)
returns Boolean from Standard
is redefined virtual;
--- Purpose: Build the AISObject (if null) or update it.
-- No compute is done.
-- Returns <True> if informations was found
-- and AISObject updated.
end AxisDriver;

View File

@@ -0,0 +1,70 @@
#include <TPrsStd_AxisDriver.ixx>
#include <TDF_Label.hxx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Geometry.hxx>
#include <AIS_Axis.hxx>
#include <AIS_Drawer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Geom_Line.hxx>
#include <gp_Lin.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_NamedShape.hxx>
#include <TopoDS_Shape.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_AxisDriver::TPrsStd_AxisDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_AxisDriver::Update (const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& anAISObject)
{
Handle(TDataXtd_Axis) apAxis;
if ( !aLabel.FindAttribute(TDataXtd_Axis::GetID(), apAxis) ) {
return Standard_False;
}
gp_Lin lin;
Handle(TNaming_NamedShape) NS;
if(aLabel.FindAttribute(TNaming_NamedShape::GetID(),NS)){
if(TNaming_Tool::GetShape(NS).IsNull()){
return Standard_False;
}
}
Handle(AIS_Axis) aistrihed;
if (TDataXtd_Geometry::Line(aLabel,lin)) {
Handle(Geom_Line) apt = new Geom_Line (lin);
// Update de l'AIS
if (anAISObject.IsNull())
aistrihed = new AIS_Axis(apt);
else {
aistrihed = Handle(AIS_Axis)::DownCast(anAISObject);
if (aistrihed.IsNull())
aistrihed = new AIS_Axis(apt);
else {
aistrihed->SetComponent(apt);
aistrihed->ResetLocation();
aistrihed->SetToUpdate();
aistrihed->UpdateSelection();
}
}
anAISObject = aistrihed;
return Standard_True;
}
return Standard_False;
}

View File

@@ -0,0 +1,30 @@
-- File: TPrsStd_ConstraintDriver.cdl
-- Created: Fri Aug 1 11:21:30 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
class ConstraintDriver from TPrsStd inherits Driver from TPrsStd
---Purpose: An implementation of TPrsStd_Driver for constraints.
uses
GUID from Standard,
InteractiveObject from AIS,
Label from TDF
is
Create
returns mutable ConstraintDriver from TPrsStd;
---Purpose: Constructs an empty constraint driver.
Update (me : mutable ;
aLabel : Label from TDF;
anAISObject : in out InteractiveObject from AIS)
returns Boolean from Standard
is redefined virtual;
--- Purpose: Build the AISObject (if null) or update it.
-- No compute is done.
-- Returns <True> if informations was found
-- and AISObject updated.
end ConstraintDriver;

View File

@@ -0,0 +1,190 @@
#include <TPrsStd_ConstraintDriver.ixx>
#include <TDF_Label.hxx>
#include <TDataXtd_Constraint.hxx>
#include <TPrsStd_ConstraintTools.hxx>
#include <Standard_ProgramError.hxx>
#include <Standard_GUID.hxx>
#include <TDataStd_Real.hxx>
#include <TDataXtd_Position.hxx>
#include <AIS_Drawer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Relation.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_ConstraintDriver::TPrsStd_ConstraintDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_ConstraintDriver::Update (const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& anAISObject)
{
Handle(TDataXtd_Constraint) apConstraint;
if( !aLabel.FindAttribute(TDataXtd_Constraint::GetID(), apConstraint) ) {
return Standard_False;
}
if (!anAISObject.IsNull() && anAISObject->HasInteractiveContext()) {
if (!apConstraint->Verified()) {
TPrsStd_ConstraintTools::UpdateOnlyValue(apConstraint,anAISObject);
if (anAISObject->Color() != Quantity_NOC_RED) anAISObject->SetColor(Quantity_NOC_RED);
return Standard_True;
}
}
Handle(AIS_InteractiveObject) anAIS = anAISObject;
// recuperation
TDataXtd_ConstraintEnum thetype = apConstraint->GetType();
switch (thetype) {
case TDataXtd_DISTANCE:
{
TPrsStd_ConstraintTools::ComputeDistance(apConstraint,anAIS);
break;
}
case TDataXtd_PARALLEL:
{
TPrsStd_ConstraintTools::ComputeParallel(apConstraint,anAIS);
break;
}
case TDataXtd_PERPENDICULAR:
{
TPrsStd_ConstraintTools::ComputePerpendicular(apConstraint,anAIS);
break;
}
case TDataXtd_CONCENTRIC:
{
TPrsStd_ConstraintTools::ComputeConcentric(apConstraint,anAIS);
break;
}
case TDataXtd_SYMMETRY:
{
TPrsStd_ConstraintTools::ComputeSymmetry(apConstraint,anAIS);
break;
}
case TDataXtd_MIDPOINT:
{
TPrsStd_ConstraintTools::ComputeMidPoint(apConstraint,anAIS);
break;
}
case TDataXtd_TANGENT:
{
TPrsStd_ConstraintTools::ComputeTangent(apConstraint,anAIS);
break;
}
case TDataXtd_ANGLE:
{
TPrsStd_ConstraintTools::ComputeAngle(apConstraint,anAIS);
break;
}
case TDataXtd_RADIUS:
{
TPrsStd_ConstraintTools::ComputeRadius(apConstraint,anAIS);
break;
}
case TDataXtd_MINOR_RADIUS:
{
TPrsStd_ConstraintTools::ComputeMinRadius(apConstraint,anAIS);
break;
}
case TDataXtd_MAJOR_RADIUS:
{
TPrsStd_ConstraintTools::ComputeMaxRadius(apConstraint,anAIS);
break;
}
case TDataXtd_DIAMETER:
{
TPrsStd_ConstraintTools::ComputeDiameter(apConstraint,anAIS);
break;
}
case TDataXtd_FIX:
{
TPrsStd_ConstraintTools::ComputeFix(apConstraint,anAIS);
break;
}
case TDataXtd_OFFSET:
{
TPrsStd_ConstraintTools::ComputeOffset(apConstraint,anAIS);
break;
}
case TDataXtd_COINCIDENT:
{
TPrsStd_ConstraintTools::ComputeCoincident(apConstraint,anAIS);
break;
}
case TDataXtd_ROUND:
{
TPrsStd_ConstraintTools::ComputeRound(apConstraint,anAIS);
break;
}
case TDataXtd_MATE:
case TDataXtd_ALIGN_FACES:
case TDataXtd_ALIGN_AXES:
case TDataXtd_AXES_ANGLE:
{
TPrsStd_ConstraintTools::ComputePlacement(apConstraint,anAIS);
break;
}
case TDataXtd_EQUAL_DISTANCE :
{
TPrsStd_ConstraintTools::ComputeEqualDistance(apConstraint,anAIS);
break;
}
case TDataXtd_EQUAL_RADIUS:
{
TPrsStd_ConstraintTools::ComputeEqualRadius(apConstraint,anAIS);
break;
}
default:
{
TPrsStd_ConstraintTools::ComputeOthers(apConstraint,anAIS);
break;
}
}
if (anAIS.IsNull()) return Standard_False;
anAIS->ResetLocation();
anAIS->SetToUpdate();
anAIS->UpdateSelection();
anAISObject = anAIS;
Handle(TDataXtd_Position) Position;
if (aLabel.FindAttribute(TDataXtd_Position::GetID(),Position)) {
Handle(AIS_Relation)::DownCast(anAISObject)->SetPosition(Position->GetPosition());
}
if (anAISObject->HasInteractiveContext()) {
Quantity_NameOfColor originColor = anAISObject->Color();
if (!apConstraint->Verified()) {
if (originColor != Quantity_NOC_RED)
anAISObject->SetColor(Quantity_NOC_RED);
}
else if (apConstraint->IsDimension() && apConstraint->GetValue()->IsCaptured()) {
if (originColor != Quantity_NOC_PURPLE)
anAISObject->SetColor(Quantity_NOC_PURPLE);
}
else if (!apConstraint->IsPlanar() && (originColor != Quantity_NOC_YELLOW))
anAISObject->SetColor(Quantity_NOC_YELLOW);
}
else {
if (!apConstraint->Verified()) {
anAISObject->SetColor(Quantity_NOC_RED);
}
else if (apConstraint->IsDimension() && apConstraint->GetValue()->IsCaptured()) {
anAISObject->SetColor(Quantity_NOC_PURPLE);
}
else if (!apConstraint->IsPlanar()) anAISObject->SetColor(Quantity_NOC_YELLOW);
}
return Standard_True;
}

View File

@@ -0,0 +1,132 @@
-- File: TPrsStd_ConstraintTools.cdl
-- Created: Wed Aug 20 11:02:45 1997
-- Author: Guest Design
-- <g_design@hankox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ConstraintTools from TPrsStd
uses
Constraint from TDataXtd,
InteractiveObject from AIS,
ExtendedString from TCollection,
Shape from TopoDS,
Geometry from Geom
is
UpdateOnlyValue (myclass; aConst : Constraint from TDataXtd;
anAIS : InteractiveObject from AIS);
ComputeDistance (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeParallel (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeTangent (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputePerpendicular (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeConcentric (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeSymmetry (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeMidPoint (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeAngle (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeRadius (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
--ota:
ComputeMinRadius (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeMaxRadius (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeEqualDistance (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
--end
ComputeEqualRadius (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeFix (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeDiameter (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeOffset (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputePlacement(myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeCoincident(myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeRound(myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeOthers (myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS);
ComputeTextAndValue(myclass; aConst : Constraint from TDataXtd;
aValue : in out Real from Standard;
aText : in out ExtendedString from TCollection;
anIsAngle : Boolean from Standard);
-- addition for one conical face angle
ComputeAngleForOneFace(myclass; aConst : Constraint from TDataXtd;
anAIS : in out InteractiveObject from AIS );
GetOneShape(myclass; aConst : Constraint from TDataXtd;
aShape : in out Shape from TopoDS)
is private;
GetGeom (myclass; aConst : Constraint from TDataXtd;
aGeom : in out Geometry from Geom)
is private;
GetTwoShapes(myclass; aConst : Constraint from TDataXtd;
aShape1 : in out Shape from TopoDS;
aShape2 : in out Shape from TopoDS)
is private;
GetShapesAndGeom(myclass; aConst : Constraint from TDataXtd;
aShape1 : in out Shape from TopoDS;
aShape2 : in out Shape from TopoDS;
aGeom : in out Geometry from Geom)
is private;
GetShapesAndGeom(myclass; aConst : Constraint from TDataXtd;
aShape1 : in out Shape from TopoDS;
aShape2 : in out Shape from TopoDS;
aShape3 : in out Shape from TopoDS;
aGeom : in out Geometry from Geom)
is private;
--ota --
GetShapesAndGeom(myclass; aConst : Constraint from TDataXtd;
aShape1 : in out Shape from TopoDS;
aShape2 : in out Shape from TopoDS;
aShape3 : in out Shape from TopoDS;
aShape4 : in out Shape from TopoDS;
aGeom : in out Geometry from Geom)
is private;
----
end ConstraintTools;

File diff suppressed because it is too large Load Diff

54
src/TPrsStd/TPrsStd_Driver.cdl Executable file
View File

@@ -0,0 +1,54 @@
-- File: TPrsStd_Driver.cdl
-- Created: Fri Aug 1 10:44:29 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
deferred class Driver from TPrsStd inherits TShared from MMgt
--- Purpose: Driver for AIS
-- ==============
-- An abstract class, which - in classes inheriting
-- from it - allows you to update an
-- AIS_InteractiveObject or create one if one does
-- not already exist.
-- For both creation and update, the interactive
-- object is filled with information contained in
-- attributes. These attributes are those found on
-- the label given as an argument in the method Update.
-- true is returned if the interactive object was modified by the update.
-- This class provide an algorithm to Build with its default
-- values (if Null) or Update (if !Null) an AIS_InteractiveObject
-- . Resources are found in attributes associated to a given
-- label.
-- The algorithm Returns <True> if the minimum resources are
-- found. The returned AIS may be null if algorithm failed
-- (values of resources attributes are not acceptable).
-- This algorithm may be called, even if an AISPresentation
-- attribute is not setted at the label (for simulation need by
-- example).
-- It belongs to the application to test the returned AIS object,
-- to set it in the AISPresentation attribute and to set the
-- owner of the AIS. See Tool class for default implementation of
-- those methods.
uses Label from TDF,
InteractiveObject from AIS
is
Initialize;
Update (me : mutable ; L : Label from TDF;
ais : in out InteractiveObject from AIS)
---Purpose:
-- Updates the interactive object ais with
-- information found on the attributes associated with the label L.
returns Boolean from Standard
is deferred;
end Driver;

7
src/TPrsStd/TPrsStd_Driver.cxx Executable file
View File

@@ -0,0 +1,7 @@
#include <TPrsStd_Driver.ixx>
TPrsStd_Driver::TPrsStd_Driver()
{}

View File

@@ -0,0 +1,63 @@
-- File: TPrsStd_DriverTable.cdl
-- Created: Wed Aug 4 14:02:36 1999
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class DriverTable from TPrsStd inherits TShared from MMgt
---Purpose: This class is a container to record (AddDriver)
-- binding between GUID and TPrsStd_Driver.
-- You create a new instance of TPrsStd_Driver
-- and use the method AddDriver to load it into the driver table. the method
uses Boolean from Standard,
Attribute from TDF,
Label from TDF,
GUID from Standard,
IDList from TDF,
Driver from TPrsStd,
DataMapOfGUIDDriver from TPrsStd
is
Get (myclass) returns mutable DriverTable from TPrsStd;
---Purpose: Returns the static table.
-- If it does not exist, creates it and fills it with standard drivers.
Create returns mutable DriverTable from TPrsStd;
---Purpose: Default constructor
InitStandardDrivers (me : mutable);
---Purpose: Fills the table with standard drivers
AddDriver (me : mutable; guid : GUID from Standard;
driver : Driver from TPrsStd)
---Purpose: Returns true if the driver has been added successfully to the driver table.
returns Boolean from Standard;
FindDriver (me; guid : GUID from Standard;
driver : out Driver from TPrsStd)
---Purpose: Returns true if the driver was found.
returns Boolean from Standard;
RemoveDriver (me : mutable; guid : GUID from Standard)
---Purpose:
-- Removes a driver with the given GUID.
-- Returns true if the driver has been removed successfully.
returns Boolean from Standard;
Clear (me : mutable);
---Purpose: Removes all drivers. Returns
-- true if the driver has been removed successfully.
-- If this method is used, the InitStandardDrivers method should be
-- called to fill the table with standard drivers.
fields
myDrivers : DataMapOfGUIDDriver from TPrsStd;
end DriverTable;

View File

@@ -0,0 +1,125 @@
// File: TPrsStd_DriverTable.cxx
// Created: Fri Jun 11 17:58:49 1999
// Author: Sergey RUIN
// <srn@popox.nnov.matra-dtv.fr>
#include <TPrsStd_DriverTable.ixx>
#include <TPrsStd_DataMapOfGUIDDriver.hxx>
#include <TPrsStd_Driver.hxx>
#include <TPrsStd_AxisDriver.hxx>
#include <TPrsStd_ConstraintDriver.hxx>
#include <TPrsStd_GeometryDriver.hxx>
#include <TPrsStd_NamedShapeDriver.hxx>
#include <TPrsStd_PlaneDriver.hxx>
#include <TPrsStd_PointDriver.hxx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Constraint.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Point.hxx>
static Handle(TPrsStd_DriverTable) drivertable;
//=======================================================================
//function : Get
//purpose :
//=======================================================================
Handle(TPrsStd_DriverTable) TPrsStd_DriverTable::Get()
{
if ( drivertable.IsNull() )
{
drivertable = new TPrsStd_DriverTable;
#ifdef DEB
cout << "The new TPrsStd_DriverTable was created" << endl;
#endif
}
return drivertable;
}
//=======================================================================
//function : TPrsStd_DriverTable
//purpose :
//=======================================================================
TPrsStd_DriverTable::TPrsStd_DriverTable()
{
InitStandardDrivers();
}
//=======================================================================
//function : InitStandardDrivers
//purpose : Adds standard drivers to the DriverTable
//=======================================================================
void TPrsStd_DriverTable::InitStandardDrivers()
{
if (myDrivers.Extent() > 0) return;
Handle(TPrsStd_AxisDriver) axisdrv = new TPrsStd_AxisDriver;
Handle(TPrsStd_ConstraintDriver) cnstrdrv = new TPrsStd_ConstraintDriver;
Handle(TPrsStd_GeometryDriver) geomdrv = new TPrsStd_GeometryDriver ;
Handle(TPrsStd_NamedShapeDriver) nshapedrv = new TPrsStd_NamedShapeDriver;
Handle(TPrsStd_PlaneDriver) planedrv = new TPrsStd_PlaneDriver;
Handle(TPrsStd_PointDriver) pointdrv = new TPrsStd_PointDriver;
myDrivers.Bind(TDataXtd_Axis::GetID(), axisdrv);
myDrivers.Bind(TDataXtd_Constraint::GetID(), cnstrdrv);
myDrivers.Bind(TDataXtd_Geometry::GetID(), geomdrv);
myDrivers.Bind(TNaming_NamedShape::GetID(), nshapedrv);
myDrivers.Bind(TDataXtd_Plane::GetID(), planedrv);
myDrivers.Bind(TDataXtd_Point::GetID(), pointdrv);
}
//=======================================================================
//function : AddDriver
//purpose : Adds a driver to the DriverTable
//=======================================================================
Standard_Boolean TPrsStd_DriverTable::AddDriver(const Standard_GUID& guid,
const Handle(TPrsStd_Driver)& driver)
{
return myDrivers.Bind(guid,driver);
}
//=======================================================================
//function : FindDriver
//purpose : Returns the driver if find
//=======================================================================
Standard_Boolean TPrsStd_DriverTable::FindDriver(const Standard_GUID& guid,
Handle(TPrsStd_Driver)& driver) const
{
if (myDrivers.IsBound(guid))
{
driver = myDrivers.Find(guid);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : RemoveDriver
//purpose : Removes a driver from the DriverTable
//=======================================================================
Standard_Boolean TPrsStd_DriverTable::RemoveDriver(const Standard_GUID& guid)
{
return myDrivers.UnBind(guid);
}
//=======================================================================
//function : Clear
//purpose : Removes all drivers
//=======================================================================
void TPrsStd_DriverTable::Clear()
{
myDrivers.Clear();
}

View File

@@ -0,0 +1,31 @@
-- File: TPrsStd_GeometryDriver.cdl
-- Created: Fri Aug 1 11:21:30 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
class GeometryDriver from TPrsStd inherits Driver from TPrsStd
---Purpose:
-- This method is an implementation of TPrsStd_Driver for geometries.
uses
GUID from Standard,
Label from TDF,
InteractiveObject from AIS
is
Create
returns mutable GeometryDriver from TPrsStd;
---Purpose: Constructs an empty geometry driver.
Update (me : mutable ;
aLabel : Label from TDF;
anAISObject : in out InteractiveObject from AIS)
returns Boolean from Standard
is redefined virtual;
--- Purpose: Build the AISObject (if null) or update it.
-- No compute is done.
-- Returns <True> if informations was found
-- and AISObject updated.
end GeometryDriver;

View File

@@ -0,0 +1,161 @@
// Created: Wed Sep 30 08:50:34 1999
// Author: Sergey RUIN
// <srn@popox.nnov.matra-dtv.fr>
// Copyright: Matra Datavision 1999
#include <TPrsStd_GeometryDriver.ixx>
#include <TDataXtd.hxx>
#include <TDF_Label.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TDataXtd_Geometry.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <AIS_Line.hxx>
#include <AIS_Point.hxx>
#include <AIS_Circle.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Drawer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_GeometryDriver::TPrsStd_GeometryDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& anAISObject)
{
Handle(TDataXtd_Geometry) aGeom;
Handle(TNaming_NamedShape) NS;
TDataXtd_GeometryEnum GeomType;
if (!aLabel.FindAttribute(TDataXtd_Geometry::GetID(), aGeom)) {
if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
GeomType = TDataXtd_Geometry::Type(aLabel);
}
else {
return Standard_False;
}
}
else {
GeomType = aGeom->GetType();
}
switch (GeomType) {
case TDataXtd_POINT :
{
gp_Pnt pt;
if (!TDataXtd_Geometry::Point(aLabel,pt)) return Standard_False;
Handle(Geom_Point) apt = new Geom_CartesianPoint(pt);
Handle(AIS_Point) ais1;
if( anAISObject.IsNull() ) ais1 = new AIS_Point(apt);
else {
ais1 = Handle(AIS_Point)::DownCast(anAISObject);
if (ais1.IsNull())
ais1 = new AIS_Point(apt);
else {
ais1->SetComponent(apt);
ais1->ResetLocation();
ais1->SetToUpdate();
ais1->UpdateSelection();
}
}
anAISObject = ais1;
anAISObject->SetColor(Quantity_NOC_RED);
}
break;
case TDataXtd_LINE :
{
gp_Lin ln;
if (!TDataXtd_Geometry::Line(aLabel,ln)) return Standard_False;
Handle(Geom_Line) aln = new Geom_Line(ln);
Handle(AIS_Line) ais2;
if( anAISObject.IsNull() ) ais2 = new AIS_Line(aln);
else {
ais2 = Handle(AIS_Line)::DownCast(anAISObject);
if (ais2.IsNull())
ais2 = new AIS_Line(aln);
else {
ais2->SetLine(aln);
ais2->ResetLocation();
ais2->SetToUpdate();
ais2->UpdateSelection();
}
}
anAISObject = ais2;
anAISObject->SetColor(Quantity_NOC_RED);
anAISObject->SetInfiniteState(Standard_True);
break;
}
case TDataXtd_CIRCLE :
{
Handle(AIS_Line) ais2;
gp_Circ cir;
if (!TDataXtd_Geometry::Circle(aLabel,cir)) return Standard_False;
Handle(Geom_Circle) acir = new Geom_Circle(cir);
Handle(AIS_Circle) ais3;
if (anAISObject.IsNull()) ais3 = new AIS_Circle(acir);
else {
ais3 = Handle(AIS_Circle)::DownCast(anAISObject);
if (ais3.IsNull())
ais3 = new AIS_Circle(acir);
else {
ais3->SetCircle(acir);
ais3->ResetLocation();
ais3->SetToUpdate();
ais3->UpdateSelection();
}
}
anAISObject = ais3;
anAISObject->SetColor(Quantity_NOC_RED);
break;
}
case TDataXtd_ELLIPSE :
{
gp_Elips elp;
if (!TDataXtd_Geometry::Ellipse(aLabel, elp)) return Standard_False;
BRepBuilderAPI_MakeEdge mkEdge(elp);
if( !mkEdge.IsDone() ) return Standard_False;
Handle(AIS_Shape) ais;
if (anAISObject.IsNull()) ais = new AIS_Shape(mkEdge);
else {
ais = Handle(AIS_Shape)::DownCast(anAISObject);
if (ais.IsNull())
ais = new AIS_Shape(mkEdge);
else {
ais->ResetLocation();
ais->Set(mkEdge);
ais->SetToUpdate();
ais->UpdateSelection();
}
}
anAISObject = ais;
anAISObject->SetColor(Quantity_NOC_RED);
break;
}
default:
return Standard_False;
}
return Standard_True;
}

View File

@@ -0,0 +1,31 @@
-- File: TPrsStd_NamedShapeDriver.cdl
-- Created: Fri Aug 1 11:21:30 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
class NamedShapeDriver from TPrsStd inherits Driver from TPrsStd
---Purpose: An implementation of TPrsStd_Driver for named shapes.
uses
GUID from Standard,
Label from TDF,
InteractiveObject from AIS
is
Create
returns mutable NamedShapeDriver from TPrsStd;
---Purpose: Constructs an empty named shape driver.
Update (me : mutable ;
aLabel : Label from TDF;
anAISObject : in out InteractiveObject from AIS)
returns Boolean from Standard
is redefined virtual;
--- Purpose: Build the AISObject (if null) or update it.
-- No compute is done.
-- Returns <True> if informations was found
-- and AISObject updated.
end NamedShapeDriver;

View File

@@ -0,0 +1,99 @@
// last modified by SRN 01/08/2000
#include <TPrsStd_NamedShapeDriver.ixx>
#include <TDF_Label.hxx>
#include <TNaming_NamedShape.hxx>
#include <AIS_Shape.hxx>
#include <AIS_InteractiveContext.hxx>
#include <TDataStd.hxx>
#include <Standard_GUID.hxx>
#include <TPrsStd_DriverTable.hxx>
#include <TNaming_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <PrsMgr_Presentation.hxx>
#include <Prs3d_Presentation.hxx>
#include <PrsMgr_Presentation3d.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Geom_Transformation.hxx>
#undef OPTIM_UPDATE // If this variable is defined there will be done
// more otimized update of AIS_Shape. If an object was
// erased in the viewer and it's location was changed
// but topological data wasn't then when displayed only
// the object's presentation will be moved to new location
// without recompute. The shape in AIS_Shape will
// be the previous one with the old location.
// NOTE! After selection of sub shapes of the object
// they will have THE OLD LOCATION and it has to be
// compared with location of AIS_Shape that will contain
// the right location of shape.
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_NamedShapeDriver::TPrsStd_NamedShapeDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& AIS)
{
Handle(TNaming_NamedShape) NS;
if( !aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
return Standard_False;
}
//TopoDS_Shape S = TNaming_Tool::CurrentShape (NS);
TopoDS_Shape S = TNaming_Tool::GetShape (NS);
if(S.IsNull()){
return Standard_False;
}
TopLoc_Location L = S.Location();
Handle(AIS_Shape) AISShape;
if (AIS.IsNull()) AISShape = new AIS_Shape(S);
else {
AISShape = Handle(AIS_Shape)::DownCast(AIS);
if (AISShape.IsNull()) {
AISShape = new AIS_Shape(S);
}
else {
TopoDS_Shape oldShape = AISShape->Shape();
if(oldShape != S) {
AISShape->ResetLocation();
#ifdef OPTIM_UPDATE
Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();
if(S.IsPartner(oldShape) && (!ctx.IsNull() && !ctx->IsDisplayed(AISShape))) {
if(L != oldShape.Location()) ctx->SetLocation(AISShape, L);
}
else {
AISShape->Set(S);
AISShape->UpdateSelection();
AISShape->SetToUpdate();
}
#else
AISShape->Set(S);
AISShape->UpdateSelection();
AISShape->SetToUpdate();
#endif
}
}
AISShape->SetInfiniteState(S.Infinite());
}
AIS = AISShape;
return Standard_True;
}

View File

@@ -0,0 +1,31 @@
-- File: TPrsStd_PlaneDriver.cdl
-- Created: Fri Aug 1 11:21:30 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
class PlaneDriver from TPrsStd inherits Driver from TPrsStd
---Purpose: An implementation of TPrsStd_Driver for planes.
uses
GUID from Standard,
Label from TDF,
InteractiveObject from AIS
is
Create
returns mutable PlaneDriver from TPrsStd;
---Purpose: Constructs an empty plane driver.
Update (me : mutable ;
aLabel : Label from TDF;
anAISObject : in out InteractiveObject from AIS)
returns Boolean from Standard
is redefined virtual;
--- Purpose: Build the AISObject (if null) or update it.
-- No compute is done.
-- Returns <True> if informations was found
-- and AISObject updated.
end PlaneDriver;

View File

@@ -0,0 +1,61 @@
#include <TPrsStd_PlaneDriver.ixx>
#include <TDF_Label.hxx>
#include <TDataXtd_Plane.hxx>
//#include <TDataStd_Datum.hxx>
#include <TDataXtd_Geometry.hxx>
#include <AIS_Plane.hxx>
#include <AIS_Drawer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_PlaneDriver::TPrsStd_PlaneDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_PlaneDriver::Update (const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& anAISObject)
{
Handle(TDataXtd_Plane) apPlane;
if ( !aLabel.FindAttribute(TDataXtd_Plane::GetID(), apPlane) ) {
return Standard_False;
}
gp_Pln pln;
if (!TDataXtd_Geometry::Plane(aLabel,pln)) {
return Standard_False;
}
Handle(Geom_Plane) apt = new Geom_Plane(pln);
// Update AIS
Handle(AIS_Plane) aisplane;
if (anAISObject.IsNull())
aisplane = new AIS_Plane(apt,pln.Location());
else {
aisplane = Handle(AIS_Plane)::DownCast(anAISObject);
if (aisplane.IsNull())
aisplane = new AIS_Plane(apt,pln.Location());
else {
aisplane->SetComponent(apt);
aisplane->SetCenter(pln.Location());
aisplane->ResetLocation();
aisplane->SetToUpdate();
aisplane->UpdateSelection();
}
}
anAISObject = aisplane;
return Standard_True;
}

View File

@@ -0,0 +1,32 @@
-- File: TPrsStd_PointDriver.cdl
-- Created: Fri Aug 1 11:21:30 1997
-- Author: SMO
---Copyright: Matra Datavision 1997
class PointDriver from TPrsStd inherits Driver from TPrsStd
---Purpose: An implementation of TPrsStd_Driver for points.
uses
GUID from Standard,
Label from TDF,
InteractiveObject from AIS
is
Create
returns mutable PointDriver from TPrsStd;
---Purpose: Constructs an empty point driver.
Update (me : mutable ;
aLabel : Label from TDF;
anAISObject : in out InteractiveObject from AIS)
returns Boolean from Standard
is redefined virtual;
--- Purpose: Build the AISObject (if null) or update it.
-- No compute is done.
-- Returns <True> if informations was found
-- and AISObject updated.
end PointDriver;

View File

@@ -0,0 +1,61 @@
#include <TPrsStd_PointDriver.ixx>
#include <TDF_Label.hxx>
#include <TDataXtd_Point.hxx>
#include <TDataXtd_Geometry.hxx>
//#include <TDataStd_Datum.hxx>
#include <AIS_Point.hxx>
#include <AIS_Drawer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Geom_Point.hxx>
#include <Geom_CartesianPoint.hxx>
#include <gp_Pnt.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_PointDriver::TPrsStd_PointDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_PointDriver::Update (const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& anAISObject)
{
Handle(TDataXtd_Point) appoint;
if ( !aLabel.FindAttribute(TDataXtd_Point::GetID(), appoint) ) {
return Standard_False;
}
gp_Pnt pnt;
if (!TDataXtd_Geometry::Point(aLabel,pnt)) {
return Standard_False;
}
Handle(Geom_CartesianPoint) apt = new Geom_CartesianPoint(pnt);
// Update de l'AIS
Handle(AIS_Point) aistrihed;
if (anAISObject.IsNull())
aistrihed = new AIS_Point(apt);
else {
aistrihed = Handle(AIS_Point)::DownCast(anAISObject);
if (aistrihed.IsNull())
aistrihed = new AIS_Point(apt);
else {
aistrihed->SetComponent(apt);
aistrihed->ResetLocation();
aistrihed->SetToUpdate();
aistrihed->UpdateSelection();
}
}
anAISObject = aistrihed;
return Standard_True;
}