mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
77
src/DDataStd/DDataStd.cdl
Executable file
77
src/DDataStd/DDataStd.cdl
Executable file
@@ -0,0 +1,77 @@
|
||||
-- File: DDataStd.cdl
|
||||
-- Created: Thu Mar 27 09:19:52 1997
|
||||
-- Author: Denis PASCAL
|
||||
-- <dp@dingox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
package DDataStd
|
||||
|
||||
---Purpose: commands for Standard Attributes.
|
||||
-- =================================
|
||||
|
||||
|
||||
uses Draw,
|
||||
TDF,
|
||||
TDataStd,
|
||||
TDataXtd,
|
||||
TopoDS,
|
||||
MMgt,
|
||||
Standard,
|
||||
TNaming,
|
||||
TCollection
|
||||
|
||||
is
|
||||
|
||||
---Purpose: attribute display presentation
|
||||
-- ==============================
|
||||
|
||||
class DrawPresentation;
|
||||
|
||||
class DrawDriver;
|
||||
---Purpose: root class of drivers to build draw variables from TDF_Label.
|
||||
|
||||
---Purpose: attribute tree presentation
|
||||
-- ===========================
|
||||
|
||||
class TreeBrowser;
|
||||
---Purpose: Used to browse tree nodes.
|
||||
|
||||
---Purpose: commands
|
||||
-- ========
|
||||
|
||||
AllCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: command to set and get modeling attributes
|
||||
|
||||
NamedShapeCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: to set and get NamedShape
|
||||
|
||||
BasicCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: to set and get Integer, Real, Reference, Geometry
|
||||
|
||||
DatumCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: to set and get Datum attributes
|
||||
|
||||
ConstraintCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: to set and get Constraint and Constraint attributes
|
||||
|
||||
ObjectCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: to set and get Objects attributes
|
||||
|
||||
DrawDisplayCommands (I : in out Interpretor from Draw);
|
||||
---Purpose: to display standard attributes
|
||||
|
||||
NameCommands (I: in out Interpretor from Draw);
|
||||
---Purpose: to set and get Name attribute
|
||||
|
||||
TreeCommands (I: in out Interpretor from Draw);
|
||||
---Purpose: to build, edit and browse an explicit tree of labels
|
||||
|
||||
---Purpose: package methods
|
||||
-- ===============
|
||||
|
||||
DumpConstraint (C : Constraint from TDataXtd; S : in out OStream);
|
||||
|
||||
|
||||
end DDataStd;
|
||||
|
68
src/DDataStd/DDataStd.cxx
Executable file
68
src/DDataStd/DDataStd.cxx
Executable file
@@ -0,0 +1,68 @@
|
||||
// File: DDataStd.cxx
|
||||
// Created: Thu Mar 27 09:24:53 1997
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DDataStd.ixx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDataStd.hxx>
|
||||
#include <TDataXtd.hxx>
|
||||
#include <TDataStd_RealEnum.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : AllCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::AllCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
NamedShapeCommands (theCommands);
|
||||
BasicCommands (theCommands);
|
||||
DatumCommands (theCommands);
|
||||
ConstraintCommands (theCommands);
|
||||
ObjectCommands (theCommands);
|
||||
DrawDisplayCommands (theCommands);
|
||||
NameCommands(theCommands);
|
||||
TreeCommands(theCommands);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpConstraint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::DumpConstraint (const Handle(TDataXtd_Constraint)& CTR, Standard_OStream& anOS)
|
||||
{
|
||||
TCollection_AsciiString S;
|
||||
TDF_Tool::Entry(CTR->Label(),S);
|
||||
anOS << S << " ";
|
||||
TDataXtd::Print(CTR->GetType(),anOS);
|
||||
for (Standard_Integer i = 1; i <= CTR->NbGeometries(); i++) {
|
||||
anOS << " G_" << i << " (";
|
||||
TDF_Tool::Entry(CTR->GetGeometry(i)->Label(),S);
|
||||
anOS << S << ") ";
|
||||
}
|
||||
if (CTR->IsPlanar()) {
|
||||
anOS << " P (";
|
||||
TDF_Tool::Entry(CTR->GetPlane()->Label(),S);
|
||||
anOS << S << ") ";
|
||||
}
|
||||
if (CTR->IsDimension()) {
|
||||
anOS << " V (";
|
||||
TDF_Tool::Entry(CTR->GetValue()->Label(),S);
|
||||
anOS << S << ") ";
|
||||
TDataStd_RealEnum t = CTR->GetValue()->GetDimension();
|
||||
TDataStd::Print(t,anOS);
|
||||
Standard_Real val = CTR->GetValue()->Get();
|
||||
if (t == TDataStd_ANGULAR) val = (180.*val)/PI;
|
||||
anOS << " ";
|
||||
anOS << val;
|
||||
}
|
||||
if (!CTR->Verified()) anOS << " NotVerifed";
|
||||
}
|
2609
src/DDataStd/DDataStd_BasicCommands.cxx
Executable file
2609
src/DDataStd/DDataStd_BasicCommands.cxx
Executable file
File diff suppressed because it is too large
Load Diff
474
src/DDataStd/DDataStd_ConstraintCommands.cxx
Executable file
474
src/DDataStd/DDataStd_ConstraintCommands.cxx
Executable file
@@ -0,0 +1,474 @@
|
||||
// File: DDataStd_ConstraintCommands.cxx
|
||||
// Created: Wed Jul 30 16:14:44 1997
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
#include <DDataStd.hxx>
|
||||
|
||||
#include <DDF.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
|
||||
#include <TDataXtd.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDataXtd_Constraint.hxx>
|
||||
#include <TDataXtd_PatternStd.hxx>
|
||||
#include <TDataXtd_Position.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetConstraint
|
||||
//purpose : SetConstraint (DF,entry,keyword,geometrie/value[,geometrie])",
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_SetConstraint (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 5)
|
||||
{
|
||||
di << "usage: SetConstraint DF entry keyword geometrie [geometrie ...]" << "\n";
|
||||
di << "or SetConstraint DF entry \"plane\" geometrie - to set plane for existing constraint" << "\n";
|
||||
di << "or SetConstraint DF entry \"value\" value - to set value for existing constraint" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
|
||||
TDataXtd_ConstraintEnum aCT;
|
||||
const char* aT = arg[3];
|
||||
|
||||
if (strcmp(aT,"plane") == 0)
|
||||
{
|
||||
Handle(TDataXtd_Constraint) C;
|
||||
if (!L.FindAttribute(TDataXtd_Constraint::GetID(), C)) return 1;
|
||||
|
||||
TDF_Label aLab;
|
||||
if (!DDF::FindLabel(DF, arg[4], aLab)) return 1;
|
||||
Handle(TNaming_NamedShape) aSh;
|
||||
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSh))
|
||||
{
|
||||
C->SetPlane(aSh);
|
||||
}
|
||||
}
|
||||
else if (strcmp(aT,"value") == 0)
|
||||
{
|
||||
Handle(TDataXtd_Constraint) C;
|
||||
if (!L.FindAttribute(TDataXtd_Constraint::GetID(), C)) return 1;
|
||||
|
||||
TDF_Label aLab;
|
||||
if (!DDF::FindLabel(DF, arg[4], aLab)) return 1;
|
||||
Handle(TDataStd_Real) aR;
|
||||
if (aLab.FindAttribute(TDataStd_Real::GetID(), aR))
|
||||
{
|
||||
C->SetValue(aR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(TDataXtd_Constraint) C = TDataXtd_Constraint::Set(L);
|
||||
|
||||
// planar constraints
|
||||
if (strcmp(aT,"rad") == 0) aCT = TDataXtd_RADIUS;
|
||||
else if (strcmp(aT,"dia") == 0) aCT = TDataXtd_DIAMETER;
|
||||
else if (strcmp(aT,"minr") == 0) aCT = TDataXtd_MINOR_RADIUS;
|
||||
else if (strcmp(aT,"majr") == 0) aCT = TDataXtd_MAJOR_RADIUS;
|
||||
else if (strcmp(aT,"tan") == 0) aCT = TDataXtd_TANGENT;
|
||||
else if (strcmp(aT,"par") == 0) aCT = TDataXtd_PARALLEL;
|
||||
else if (strcmp(aT,"perp") == 0) aCT = TDataXtd_PERPENDICULAR;
|
||||
else if (strcmp(aT,"concentric") == 0) aCT = TDataXtd_CONCENTRIC;
|
||||
else if (strcmp(aT,"equal") == 0) aCT = TDataXtd_COINCIDENT;
|
||||
else if (strcmp(aT,"dist") == 0) aCT = TDataXtd_DISTANCE;
|
||||
else if (strcmp(aT,"angle") == 0) aCT = TDataXtd_ANGLE;
|
||||
else if (strcmp(aT,"eqrad") == 0) aCT = TDataXtd_EQUAL_RADIUS;
|
||||
else if (strcmp(aT,"symm") == 0) aCT = TDataXtd_SYMMETRY;
|
||||
else if (strcmp(aT,"midp") == 0) aCT = TDataXtd_MIDPOINT;
|
||||
else if (strcmp(aT,"eqdist") == 0) aCT = TDataXtd_EQUAL_DISTANCE;
|
||||
else if (strcmp(aT,"fix") == 0) aCT = TDataXtd_FIX;
|
||||
else if (strcmp(aT,"rigid") == 0) aCT = TDataXtd_RIGID;
|
||||
// placement constraints
|
||||
else if (strcmp(aT,"from") == 0) aCT = TDataXtd_FROM;
|
||||
else if (strcmp(aT,"axis") == 0) aCT = TDataXtd_AXIS;
|
||||
else if (strcmp(aT,"mate") == 0) aCT = TDataXtd_MATE;
|
||||
else if (strcmp(aT,"alignf") == 0) aCT = TDataXtd_ALIGN_FACES;
|
||||
else if (strcmp(aT,"aligna") == 0) aCT = TDataXtd_ALIGN_AXES;
|
||||
else if (strcmp(aT,"axesa") == 0) aCT = TDataXtd_AXES_ANGLE;
|
||||
else if (strcmp(aT,"facesa") == 0) aCT = TDataXtd_FACES_ANGLE;
|
||||
else if (strcmp(aT,"round") == 0) aCT = TDataXtd_ROUND;
|
||||
else if (strcmp(aT,"offset") == 0) aCT = TDataXtd_OFFSET;
|
||||
else
|
||||
{
|
||||
di << "DDataStd_SetConstraint : unknown type, must be one of:" << "\n";
|
||||
di << "rad/dia/minr/majr/tan/par/perp/concentric/equal/dist/angle/eqrad/symm/midp/" << "\n";
|
||||
di << "eqdist/fix/rigid or from/axis/mate/alignf/aligna/axesa/facesa/round/offset" << "\n";
|
||||
di << "or plane/value" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set type
|
||||
C->SetType(aCT);
|
||||
|
||||
// retrieve and set geometries
|
||||
Standard_Integer i = 1, nbSh = nb - 4;
|
||||
Handle(TNaming_NamedShape) aSh;
|
||||
TDF_Label aLab;
|
||||
|
||||
for (i = 1; i <= nbSh; i++)
|
||||
{
|
||||
if (!DDF::FindLabel(DF, arg[i+3], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSh))
|
||||
{
|
||||
C->SetGeometry(i, aSh);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetConstraint
|
||||
//purpose : GetConstraints (document, label)
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_GetConstraint (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
Handle(TDataXtd_Constraint) CTR;
|
||||
if (nb == 3)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
TDF_Label L;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
if (L.FindAttribute(TDataXtd_Constraint::GetID(),CTR))
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
DDataStd::DumpConstraint (CTR,aStream);
|
||||
di << aStream;
|
||||
}
|
||||
else
|
||||
{
|
||||
TDF_ChildIterator it (L,Standard_True);
|
||||
for (;it.More();it.Next())
|
||||
{
|
||||
const TDF_Label& current = it.Value();
|
||||
if (current.FindAttribute(TDataXtd_Constraint::GetID(),CTR))
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
DDataStd::DumpConstraint (CTR,aStream);
|
||||
di << aStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_GetConstraint : Error : not done" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetPattern
|
||||
//purpose : SetPattern (DF,entry,signature,NSentry[realEntry,intEntry[,NSentry,realEntry,intEntry]])
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_SetPattern (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 5)
|
||||
{
|
||||
di << "usage: SetPattern (DF,entry,signature,NSentry[realEntry,intEntry[,NSentry,realEntry,intEntry]])" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
|
||||
Handle(TDataXtd_PatternStd) aP = TDataXtd_PatternStd::Set(L);
|
||||
|
||||
// set signature
|
||||
Standard_Integer signature = atoi(arg[3]);
|
||||
aP->Signature(signature);
|
||||
|
||||
TDF_Label aLab;
|
||||
Handle(TNaming_NamedShape) TNS;
|
||||
Handle(TDataStd_Real) TReal;
|
||||
Handle(TDataStd_Integer) TInt;
|
||||
|
||||
// set other parameters
|
||||
if (signature < 5)
|
||||
{
|
||||
if (nb < 7)
|
||||
{
|
||||
di<<"usage:"<<"\n";
|
||||
di<<"SetPattern (DF,entry,signature<=2,NSentry,realEntry,intEntry)"<<"\n";
|
||||
di<<"SetPattern (DF,entry,2<signature<5,NSentry,realEntry,intEntry,NSentry,realEntry,intEntry)"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NSentry
|
||||
if (!DDF::FindLabel(DF, arg[4], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), TNS))
|
||||
{
|
||||
aP->Axis1(TNS);
|
||||
}
|
||||
|
||||
// realEntry
|
||||
if (!DDF::FindLabel(DF, arg[5], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TDataStd_Real::GetID(), TReal))
|
||||
{
|
||||
aP->Value1(TReal);
|
||||
}
|
||||
|
||||
// intEntry
|
||||
if (!DDF::FindLabel(DF, arg[6], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TDataStd_Integer::GetID(), TInt))
|
||||
{
|
||||
aP->NbInstances1(TInt);
|
||||
}
|
||||
|
||||
if (signature > 2)
|
||||
{
|
||||
if (nb < 10)
|
||||
{
|
||||
di<<"usage:"<<"\n";
|
||||
di<<"SetPattern (DF,entry,2<signature<5,NSentry,realEntry,intEntry,NSentry,realEntry,intEntry)"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NSentry
|
||||
if (!DDF::FindLabel(DF, arg[7], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), TNS))
|
||||
{
|
||||
aP->Axis2(TNS);
|
||||
}
|
||||
|
||||
// realEntry
|
||||
if (!DDF::FindLabel(DF, arg[8], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TDataStd_Real::GetID(), TReal))
|
||||
{
|
||||
aP->Value2(TReal);
|
||||
}
|
||||
|
||||
// intEntry
|
||||
if (!DDF::FindLabel(DF, arg[9], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TDataStd_Integer::GetID(), TInt))
|
||||
{
|
||||
aP->NbInstances2(TInt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nb > 5)
|
||||
{
|
||||
di<<"usage: SetPattern (DF,entry,signature>=5,NSentry)"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!DDF::FindLabel(DF, arg[4], aLab)) return 1;
|
||||
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), TNS))
|
||||
{
|
||||
aP->Mirror(TNS);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DumpPattern
|
||||
//purpose : DumpPattern (DF, entry)
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_DumpPattern (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
Handle(TDataXtd_PatternStd) CTR;
|
||||
if (nb == 3)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
TDF_Label L;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
if (L.FindAttribute(TDataXtd_PatternStd::GetID(),CTR))
|
||||
{
|
||||
// Standard_SStream aStream;
|
||||
// CTR->Dump(aStream);
|
||||
// aStream << ends;
|
||||
// di << aStream.rdbuf()->str();
|
||||
|
||||
TCollection_AsciiString S;
|
||||
TDF_Tool::Entry(CTR->Label(),S);
|
||||
di << S.ToCString() << " signature = " << CTR->Signature();
|
||||
|
||||
if (!CTR->Axis1().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->Axis1()->Label(),S);
|
||||
di << " Axis1 (" << S.ToCString() << ")";
|
||||
}
|
||||
|
||||
if (!CTR->Value1().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->Value1()->Label(),S);
|
||||
di << " Val1 (" << S.ToCString() << ")";
|
||||
}
|
||||
|
||||
if (!CTR->NbInstances1().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->NbInstances1()->Label(),S);
|
||||
di << " NbIns1 (" << S.ToCString() << ")";
|
||||
}
|
||||
|
||||
if (!CTR->Axis2().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->Axis2()->Label(),S);
|
||||
di << " Axis2 (" << S.ToCString() << ")";
|
||||
}
|
||||
|
||||
if (!CTR->Value2().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->Value2()->Label(),S);
|
||||
di << " Val2 (" << S.ToCString() << ")";
|
||||
}
|
||||
|
||||
if (!CTR->NbInstances2().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->NbInstances2()->Label(),S);
|
||||
di << " NbIns2 (" << S.ToCString() << ")";
|
||||
}
|
||||
|
||||
if (!CTR->Mirror().IsNull())
|
||||
{
|
||||
TDF_Tool::Entry(CTR->Mirror()->Label(),S);
|
||||
di << " Mirror (" << S.ToCString() << ")";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TDF_ChildIterator it (L,Standard_True);
|
||||
for (;it.More();it.Next())
|
||||
{
|
||||
const TDF_Label& current = it.Value();
|
||||
if (current.FindAttribute(TDataXtd_PatternStd::GetID(),CTR))
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
// DDataStd::DumpPattern (CTR,aStream);
|
||||
CTR->Dump(aStream);
|
||||
di << aStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_DumpPattern : Error : not done" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetPosition
|
||||
//purpose : SetPosition (DF, entry, X, Y, Z)
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_SetPosition (Draw_Interpretor& di,
|
||||
Standard_Integer nb, const char** arg)
|
||||
{
|
||||
if (nb == 6)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
|
||||
Standard_Real X = atof(arg[3]), Y = atof(arg[4]), Z = atof(arg[5]);
|
||||
gp_Pnt aPos (X, Y, Z);
|
||||
|
||||
TDataXtd_Position::Set(L,aPos);
|
||||
return 0;
|
||||
}
|
||||
di << "Usage: SetPosition (DF, entry, X, Y, Z)" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetPosition
|
||||
//purpose : GetPosition (DF, entry, X(out), Y(out), Z(out))
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_GetPosition (Draw_Interpretor& di,
|
||||
Standard_Integer nb, const char** arg)
|
||||
{
|
||||
if (nb == 6)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
|
||||
gp_Pnt aPos;
|
||||
if (!TDataXtd_Position::Get(L, aPos))
|
||||
{
|
||||
di << "There is no TDataStd_Position attribute on this label" << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
Draw::Set(arg[3],TCollection_AsciiString(aPos.X()).ToCString());
|
||||
Draw::Set(arg[4],TCollection_AsciiString(aPos.Y()).ToCString());
|
||||
Draw::Set(arg[5],TCollection_AsciiString(aPos.Z()).ToCString());
|
||||
return 0;
|
||||
}
|
||||
di << "Usage: GetPosition (DF, entry, X(out), Y(out), Z(out))" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ConstraintCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void DDataStd::ConstraintCommands (Draw_Interpretor& theCommands)
|
||||
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "DData : Standard Attribute Commands";
|
||||
|
||||
theCommands.Add ("SetConstraint",
|
||||
"SetConstraint (DF,entry,keyword,geometrie/value[,geometrie])",
|
||||
__FILE__, DDataStd_SetConstraint, g);
|
||||
|
||||
theCommands.Add ("GetConstraint",
|
||||
"GetConstraint (DF, entry)",
|
||||
__FILE__, DDataStd_GetConstraint, g);
|
||||
|
||||
theCommands.Add ("SetPattern",
|
||||
"SetPattern (DF,entry,signature,NSentry[realEntry,intEntry[,NSentry,realEntry,intEntry]])",
|
||||
__FILE__, DDataStd_SetPattern, g);
|
||||
|
||||
theCommands.Add ("DumpPattern",
|
||||
"DumpPattern (DF, entry)",
|
||||
__FILE__, DDataStd_DumpPattern, g);
|
||||
|
||||
|
||||
theCommands.Add ("SetPosition",
|
||||
"SetPosition (DF, entry, X, Y, Z)",
|
||||
__FILE__, DDataStd_SetPosition, g);
|
||||
|
||||
theCommands.Add ("GetPosition",
|
||||
"GetPosition (DF, entry, X(out), Y(out), Z(out))",
|
||||
__FILE__, DDataStd_GetPosition, g);
|
||||
}
|
429
src/DDataStd/DDataStd_DatumCommands.cxx
Executable file
429
src/DDataStd/DDataStd_DatumCommands.cxx
Executable file
@@ -0,0 +1,429 @@
|
||||
// File: DDataStd_DatumCommands.cxx
|
||||
// Created: Wed Jul 30 16:14:31 1997
|
||||
// Author: Denis PASCAL
|
||||
|
||||
#include <DDataStd.hxx>
|
||||
#include <DDF.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
#include <DBRep.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
|
||||
#include <TopAbs.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shell.hxx>
|
||||
#include <TopoDS_Solid.hxx>
|
||||
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
|
||||
#include <TDataXtd_Geometry.hxx>
|
||||
#include <TDataXtd_Point.hxx>
|
||||
#include <TDataXtd_Axis.hxx>
|
||||
#include <TDataXtd_Plane.hxx>
|
||||
|
||||
#include <TNaming_Builder.hxx>
|
||||
|
||||
#include <DDataStd_DrawPresentation.hxx>
|
||||
|
||||
// Unused :
|
||||
#ifdef BLABLA_DEB
|
||||
static void Location (Standard_Integer nb, const char** arg, gp_Ax2& Loc) {
|
||||
|
||||
if (nb == 9) {
|
||||
Standard_Real X = atof(arg[3]);
|
||||
Standard_Real Y = atof(arg[4]);
|
||||
Standard_Real Z = atof(arg[5]);
|
||||
Standard_Real DX = atof(arg[6]);
|
||||
Standard_Real DY = atof(arg[7]);
|
||||
Standard_Real DZ = atof(arg[8]);
|
||||
Loc = gp_Ax2 (gp_Pnt(X,Y,Z), gp_Dir(DX,DY,DZ));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetPoint
|
||||
//purpose : SetPoint (DF, entry, [drawpoint])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetPoint (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
TDF_Label L;
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
DDF::AddLabel (DF, arg[2], L);
|
||||
if (nb == 3) {
|
||||
TDataXtd_Point::Set (L);
|
||||
}
|
||||
else if (nb == 4) {
|
||||
gp_Pnt p;
|
||||
if (DrawTrSurf::GetPoint (arg[3],p)) {
|
||||
TDataXtd_Point::Set (L,p);
|
||||
}
|
||||
else {
|
||||
di << "DDataStd_SetPoint : not a point" << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
DDataStd_DrawPresentation::Display (L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetAxis
|
||||
//purpose : SetAxis (DF, entry, drawline])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetAxis (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
TDF_Label L;
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
DDF::AddLabel (DF, arg[2], L);
|
||||
if (nb == 3) {
|
||||
TDataXtd_Axis::Set (L);
|
||||
}
|
||||
else if (nb == 4) {
|
||||
Handle(Geom_Line) LINE = Handle(Geom_Line)::DownCast(DrawTrSurf::Get (arg[3]));
|
||||
if (LINE.IsNull()) {
|
||||
di << "DDataStd_SetAxis : not a line" << "\n";
|
||||
return 1;
|
||||
}
|
||||
TDataXtd_Axis::Set (L,LINE->Lin());
|
||||
}
|
||||
DDataStd_DrawPresentation::Display (L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetPlane
|
||||
//purpose : SetPlane (DF, entry, [drawplane])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetPlane (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
TDF_Label L;
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
DDF::AddLabel (DF, arg[2], L);
|
||||
if (nb == 3) {
|
||||
TDataXtd_Plane::Set(L);
|
||||
}
|
||||
else if (nb == 4) {
|
||||
Handle(Geom_Plane) PLANE = Handle(Geom_Plane)::DownCast(DrawTrSurf::Get (arg[3]));
|
||||
if (PLANE.IsNull()) {
|
||||
di << "DDataStd_SetPlane : not a plane" << "\n";
|
||||
return 1;
|
||||
}
|
||||
TDataXtd_Plane::Set (L,PLANE->Pln());
|
||||
}
|
||||
DDataStd_DrawPresentation::Display (L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetMove
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
// static Standard_Integer DDataStd_SetMove (Draw_Interpretor&,
|
||||
// Standard_Integer nb,
|
||||
// const char** arg)
|
||||
// {
|
||||
// if (nb < 3) return 1;
|
||||
// TDF_Label L;
|
||||
// Handle(TDF_Data) DF;
|
||||
// if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
// if (!DDF::FindLabel(DF, arg[2], L)) return 1;
|
||||
|
||||
// TopLoc_Location Loc;
|
||||
// if (nb == 4) {
|
||||
// TopoDS_Shape S = DBRep::Get(arg[3]);
|
||||
// if (S.IsNull()) return 1;
|
||||
// Loc = S.Location();
|
||||
// }
|
||||
|
||||
// else {
|
||||
// if (nb < 6) return 1;
|
||||
|
||||
// gp_Trsf T;
|
||||
// Standard_Real x = atof(arg[3]);
|
||||
// Standard_Real y = atof(arg[4]);
|
||||
// Standard_Real z = atof(arg[5]);
|
||||
|
||||
// if (nb == 6) {
|
||||
// T.SetTranslation(gp_Vec(x,y,z));
|
||||
// }
|
||||
// else if (nb < 10)
|
||||
// return 1;
|
||||
// else {
|
||||
// Standard_Real dx = atof(arg[6]);
|
||||
// Standard_Real dy = atof(arg[7]);
|
||||
// Standard_Real dz = atof(arg[8]);
|
||||
// Standard_Real ang = atof(arg[9]);
|
||||
// T.SetRotation(gp_Ax1(gp_Pnt(x,y,z),
|
||||
// gp_Vec(dx,dy,dz)),
|
||||
// ang * PI180);
|
||||
// }
|
||||
// Loc = T;
|
||||
// }
|
||||
// TDataStd_CoordSys::Move(L,Loc);
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetPoint
|
||||
//purpose : GetPoint (DF, entry, [drawname])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetPoint (Draw_Interpretor&,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
Handle(TDataXtd_Point) A;
|
||||
gp_Pnt P;
|
||||
if (!DDF::Find (DF, arg[2], TDataXtd_Point::GetID(), A)) return 1;
|
||||
if (TDataXtd_Geometry::Point(A->Label(), P)) {
|
||||
if (nb == 4) DrawTrSurf::Set(arg[3], P);
|
||||
else DrawTrSurf::Set(arg[2], P);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetAxis
|
||||
//purpose : GetAxis (DF, entry, [drawname])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetAxis (Draw_Interpretor&,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
Handle(TDataXtd_Axis) A;
|
||||
if (!DDF::Find (DF, arg[2], TDataXtd_Axis::GetID(), A)) return 1;
|
||||
gp_Lin l;
|
||||
if (TDataXtd_Geometry::Line(A->Label(),l)) {
|
||||
Handle(Geom_Line) L = new Geom_Line (l);
|
||||
if (nb == 4) DrawTrSurf::Set (arg[3], L);
|
||||
else DrawTrSurf::Set (arg[2], L);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetPlane
|
||||
//purpose : GetPlane (DF, entry, [drawname])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetPlane (Draw_Interpretor&,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
Handle(TDataXtd_Plane) A;
|
||||
if (!DDF::Find (DF, arg[2], TDataXtd_Plane::GetID(), A)) return 1;
|
||||
gp_Pln p;
|
||||
if (TDataXtd_Geometry::Plane(A->Label(),p)) {
|
||||
Handle(Geom_Plane) P = new Geom_Plane (p);
|
||||
if (nb == 4) DrawTrSurf::Set (arg[3], P);
|
||||
else DrawTrSurf::Set (arg[2], P);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetGeometry
|
||||
//purpose : SetGeometry (DF, entry, [type], [shape])
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_SetGeometry (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb < 3) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF, arg[2], L)) DDF::AddLabel(DF, arg[2], L);
|
||||
|
||||
if (nb == 5)
|
||||
{
|
||||
// set NS attribute
|
||||
TopoDS_Shape s = DBRep::Get(arg[4]);
|
||||
if (s.IsNull()) { di <<"shape not found"<< "\n"; return 1;}
|
||||
TNaming_Builder SI (L);
|
||||
SI.Generated(s);
|
||||
}
|
||||
|
||||
// set geometry attribute
|
||||
Handle(TDataXtd_Geometry) aGA = TDataXtd_Geometry::Set(L);
|
||||
|
||||
// set type
|
||||
TDataXtd_GeometryEnum aType;
|
||||
if (nb > 3)
|
||||
{
|
||||
const char* aT = arg[3];
|
||||
if (strcmp(aT,"any") == 0) aType = TDataXtd_ANY_GEOM;
|
||||
else if (strcmp(aT,"pnt") == 0) aType = TDataXtd_POINT;
|
||||
else if (strcmp(aT,"lin") == 0) aType = TDataXtd_LINE;
|
||||
else if (strcmp(aT,"cir") == 0) aType = TDataXtd_CIRCLE;
|
||||
else if (strcmp(aT,"ell") == 0) aType = TDataXtd_ELLIPSE;
|
||||
else if (strcmp(aT,"spl") == 0) aType = TDataXtd_SPLINE;
|
||||
else if (strcmp(aT,"pln") == 0) aType = TDataXtd_PLANE;
|
||||
else if (strcmp(aT,"cyl") == 0) aType = TDataXtd_CYLINDER;
|
||||
else
|
||||
{
|
||||
di << "DDataStd_SetGeometry : unknown type, must be one of:" << "\n";
|
||||
di << "any/pnt/lin/cir/ell/spl/pln/cyl" << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aType = TDataXtd_Geometry::Type(L);
|
||||
}
|
||||
aGA->SetType(aType);
|
||||
|
||||
// DDataStd_DrawPresentation::Display (L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetGeometryType
|
||||
//purpose : GetGeometryType (DF, entry)
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_GetGeometryType (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb != 3) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF, arg[2], L)) DDF::AddLabel(DF, arg[2], L);
|
||||
|
||||
// get geometry attribute
|
||||
Handle(TDataXtd_Geometry) aGA;
|
||||
if (!L.FindAttribute(TDataXtd_Geometry::GetID(),aGA))
|
||||
{
|
||||
di << "TDataStd_Geometry : attribute not found" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get type
|
||||
TDataXtd_GeometryEnum aType = aGA->GetType();
|
||||
switch (aType)
|
||||
{
|
||||
case TDataXtd_ANY_GEOM: di << "any"; break;
|
||||
case TDataXtd_POINT: di << "pnt"; break;
|
||||
case TDataXtd_LINE: di << "lin"; break;
|
||||
case TDataXtd_CIRCLE: di << "cir"; break;
|
||||
case TDataXtd_ELLIPSE: di << "ell"; break;
|
||||
case TDataXtd_SPLINE: di << "spl"; break;
|
||||
case TDataXtd_PLANE: di << "pln"; break;
|
||||
case TDataXtd_CYLINDER: di <<"cyl"; break;
|
||||
default:
|
||||
{
|
||||
di << "DDataStd_GetGeometry : unknown type" << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DatumCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::DatumCommands (Draw_Interpretor& theCommands)
|
||||
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "DData : Standard Attribute Commands";
|
||||
|
||||
theCommands.Add ("SetPoint",
|
||||
"SetPoint (DF, entry, [drawpoint])",
|
||||
__FILE__, DDataStd_SetPoint, g);
|
||||
|
||||
theCommands.Add ("SetAxis",
|
||||
"SetAxis (DF, entry, [drawline])",
|
||||
__FILE__, DDataStd_SetAxis, g);
|
||||
|
||||
theCommands.Add ("SetPlane",
|
||||
"SetPlane (DF, entry, [drawplane])",
|
||||
__FILE__, DDataStd_SetPlane, g);
|
||||
|
||||
// theCommands.Add ("SetMove",
|
||||
// "SetMove (DF, entry, Shape | [x, y, z, [dx, dy, dz, angle]])",
|
||||
// __FILE__, DDataStd_SetMove, g);
|
||||
|
||||
theCommands.Add ("GetPoint",
|
||||
"GetPoint (DF, entry, [drawname])",
|
||||
__FILE__, DDataStd_GetPoint, g);
|
||||
|
||||
theCommands.Add ("GetAxis",
|
||||
"GetAxis (DF, entry, [drawname])",
|
||||
__FILE__, DDataStd_GetAxis, g);
|
||||
|
||||
theCommands.Add ("GetPlane",
|
||||
"GetPlane (DF, entry, [drawname])",
|
||||
__FILE__, DDataStd_GetPlane, g);
|
||||
|
||||
theCommands.Add ("SetGeometry",
|
||||
"SetGeometry (DF, entry, [type], [shape])",
|
||||
__FILE__, DDataStd_SetGeometry, g);
|
||||
|
||||
theCommands.Add ("GetGeometryType",
|
||||
"GetGeometryType (DF, entry)",
|
||||
__FILE__, DDataStd_GetGeometryType, g);
|
||||
}
|
303
src/DDataStd/DDataStd_DrawDisplayCommands.cxx
Executable file
303
src/DDataStd/DDataStd_DrawDisplayCommands.cxx
Executable file
@@ -0,0 +1,303 @@
|
||||
// File: DDataStd_DrawDisplayCommands.cxx
|
||||
// Created: Thu Feb 12 12:22:37 1998
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
#include <DDataStd.hxx>
|
||||
#include <DDF.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Viewer.hxx>
|
||||
#include <Draw_ColorKind.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
//
|
||||
#include <TDF_AttributeList.hxx>
|
||||
#include <TDF_ListIteratorOfAttributeList.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_LabelList.hxx>
|
||||
#include <TDF_ListIteratorOfLabelList.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TDataXtd_Point.hxx>
|
||||
#include <TDataXtd_Axis.hxx>
|
||||
#include <TDataXtd_Geometry.hxx>
|
||||
#include <TDataXtd_Constraint.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
|
||||
#include <DDataStd_DrawPresentation.hxx>
|
||||
#include <DDataStd_DrawDriver.hxx>
|
||||
|
||||
#ifndef WNT
|
||||
extern Draw_Viewer dout;
|
||||
#else
|
||||
Standard_IMPORT Draw_Viewer dout;
|
||||
#endif
|
||||
//=======================================================================
|
||||
//function : DDataStd_PNT
|
||||
//purpose : SetPoint (DF, entry, x, y, z)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_PNT (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 6) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (arg[1], DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel (DF, arg[2], L);
|
||||
Standard_Real x = atof(arg[3]);
|
||||
Standard_Real y = atof(arg[4]);
|
||||
Standard_Real z = atof(arg[5]);
|
||||
TDataXtd_Point::Set (L,gp_Pnt(x,y,z));
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_PNT : Error : not done" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawStdDriver
|
||||
//purpose : DrawStdDriver
|
||||
//=======================================================================
|
||||
// Unused :
|
||||
#ifdef DEB
|
||||
static Standard_Integer DDataStd_DrawStdDriver (Draw_Interpretor& /*di*/,
|
||||
Standard_Integer /*nb*/,
|
||||
const char** /*arg*/)
|
||||
{
|
||||
DDataStd_DrawDriver::Set(new DDataStd_DrawDriver());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_Rmdraw
|
||||
//purpose : Rmdraw (name)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 2) {
|
||||
Handle(Draw_Drawable3D) D3D;
|
||||
D3D = Draw::Get(arg[1],Standard_True);
|
||||
if (!D3D.IsNull()) dout.RemoveDrawable(D3D);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_Rmdraw : Error : not done" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawOwner
|
||||
//purpose : DrawOwner (drawable)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_DrawOwner (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 2) {
|
||||
Handle(Draw_Drawable3D) D = Draw::Get(arg[1]);
|
||||
if (!D.IsNull()) {
|
||||
TCollection_AsciiString entry;
|
||||
TCollection_AsciiString name (D->Name());
|
||||
Standard_Integer index = name.Search("_0:");
|
||||
if (index > 0) {
|
||||
entry = name.Split(index);
|
||||
name.Remove(index);
|
||||
di << entry.ToCString();
|
||||
}
|
||||
else di << name.ToCString();
|
||||
}
|
||||
else di << 0;
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_DrawOwner : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawDisplay
|
||||
//purpose : DDisplay (DOC,entry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_DrawDisplay (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
DDataStd_DrawPresentation::Display(L);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_DrawDisplay : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// //=======================================================================
|
||||
// //function : DDataStd_DrawRedisplay
|
||||
// //purpose : DrawRedisplay (DOC,entry)
|
||||
// //=======================================================================
|
||||
|
||||
// static Standard_Integer DDataStd_DrawRedisplay (Draw_Interpretor&,
|
||||
// Standard_Integer nb,
|
||||
// const char** arg)
|
||||
// {
|
||||
// if (nb == 3) {
|
||||
// Handle(TDF_Data) DF;
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// TDF_Label L;
|
||||
// if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
// DDataStd_DrawPresentation::Display(L,Standard_True);
|
||||
// return 0;
|
||||
// }
|
||||
// cout << "DDataStd_DrawRedisplay : Error" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawErase
|
||||
//purpose : DrawErase (DOC,entry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_DrawErase (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
DDataStd_DrawPresentation::Erase(L);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_DrawErase : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawUpdate
|
||||
//purpose : DrawUpdate (DOC,entry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_DrawUpdate (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,arg[2],L)) return 1;
|
||||
DDataStd_DrawPresentation::Update(L);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_DrawUpdate : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawRepaint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_DrawRepaint (Draw_Interpretor& /*di*/,
|
||||
Standard_Integer /*nb*/,
|
||||
const char** /*arg*/)
|
||||
{
|
||||
dout.Repaint3D();
|
||||
dout.Flush();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawDisplayCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
void DDataStd::DrawDisplayCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "SKETCH commands" ;
|
||||
|
||||
|
||||
theCommands.Add ("PNT",
|
||||
"PNT (DF, entry, x, y, z)",
|
||||
__FILE__, DDataStd_PNT, g);
|
||||
|
||||
|
||||
// remove drawable
|
||||
|
||||
|
||||
theCommands.Add ("rmdraw",
|
||||
"rmdraw(name)",
|
||||
__FILE__, DDataStd_Rmdraw, g);
|
||||
|
||||
|
||||
// rtetrieve a label from a drawable
|
||||
|
||||
|
||||
theCommands.Add ("DrawOwner",
|
||||
"DrawOwner (drawable)",
|
||||
__FILE__, DDataStd_DrawOwner, g);
|
||||
|
||||
// draw display
|
||||
|
||||
|
||||
theCommands.Add ("DrawDisplay",
|
||||
"DrawDisplay (DF, entry)",
|
||||
__FILE__, DDataStd_DrawDisplay, g);
|
||||
|
||||
theCommands.Add ("DrawErase",
|
||||
"DrawErase (DF, entry)",
|
||||
__FILE__, DDataStd_DrawErase, g);
|
||||
|
||||
theCommands.Add ("DrawUpdate",
|
||||
"DrawUpdate (DF, entry)",
|
||||
__FILE__, DDataStd_DrawUpdate, g);
|
||||
|
||||
theCommands.Add ("DrawRepaint",
|
||||
"update the draw viewer",
|
||||
__FILE__, DDataStd_DrawRepaint, g);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
81
src/DDataStd/DDataStd_DrawDriver.cdl
Executable file
81
src/DDataStd/DDataStd_DrawDriver.cdl
Executable file
@@ -0,0 +1,81 @@
|
||||
-- File: DDataStd_DrawDisplay.cdl
|
||||
-- Created: Mon Sep 7 10:35:02 1998
|
||||
-- Author: Denis PASCAL
|
||||
-- <dp@dingox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class DrawDriver from DDataStd inherits TShared from MMgt
|
||||
|
||||
---Purpose: priority rule to display standard attributes is :
|
||||
-- * 1 Constraint
|
||||
-- * 2 Object
|
||||
-- * 3 Datum (Point,Axis,Plane)
|
||||
-- * 4 Geometry
|
||||
-- * 5 NamedShape
|
||||
|
||||
|
||||
|
||||
uses ColorKind from Draw,
|
||||
Drawable3D from Draw,
|
||||
Label from TDF,
|
||||
Attribute from TDF,
|
||||
Integer from TDataStd,
|
||||
Real from TDataStd,
|
||||
Point from TDataXtd,
|
||||
Axis from TDataXtd,
|
||||
Plane from TDataXtd,
|
||||
Geometry from TDataXtd,
|
||||
Constraint from TDataXtd,
|
||||
NamedShape from TNaming,
|
||||
Shape from TopoDS
|
||||
|
||||
is
|
||||
|
||||
---Purpose: access to the current DrawDriver
|
||||
-- ================================
|
||||
|
||||
|
||||
Set (myclass; DD : DrawDriver from DDataStd);
|
||||
|
||||
Get (myclass)
|
||||
returns DrawDriver from DDataStd;
|
||||
|
||||
|
||||
Create
|
||||
returns DrawDriver from DDataStd;
|
||||
|
||||
|
||||
---Purpose: next method is called by DrawPresentation (may be redefined)
|
||||
-- ============================================================
|
||||
|
||||
Drawable (me; L : Label from TDF)
|
||||
returns Drawable3D from Draw
|
||||
is virtual;
|
||||
|
||||
|
||||
---Purpose: reusable methods (may used when redefined <Drawable>)
|
||||
-- =====================================================
|
||||
|
||||
DrawableConstraint (me; C : Constraint from TDataXtd)
|
||||
returns Drawable3D from Draw;
|
||||
|
||||
DrawableShape (me; L : Label from TDF;
|
||||
color : ColorKind from Draw;
|
||||
current : Boolean from Standard = Standard_True)
|
||||
returns Drawable3D from Draw;
|
||||
|
||||
DrawableShape (myclass; s : Shape from TopoDS;
|
||||
color : ColorKind from Draw)
|
||||
---Purpose: May be used for temporary display of a shape
|
||||
returns Drawable3D from Draw;
|
||||
|
||||
end DrawDriver;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
399
src/DDataStd/DDataStd_DrawDriver.cxx
Executable file
399
src/DDataStd/DDataStd_DrawDriver.cxx
Executable file
@@ -0,0 +1,399 @@
|
||||
// File: DDataStd_DrawDriver.cxx
|
||||
// Created: Mon Sep 7 11:32:44 1998
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DDataStd_DrawDriver.ixx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <DDataStd.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Marker3D.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDataStd.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
//
|
||||
// attribut affichable
|
||||
//
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TDataStd.hxx>
|
||||
#include <TDataXtd_GeometryEnum.hxx>
|
||||
#include <TDataXtd_Point.hxx>
|
||||
#include <TDataXtd_Axis.hxx>
|
||||
#include <TDataXtd_Plane.hxx>
|
||||
#include <TDataXtd_Geometry.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_LabelList.hxx>
|
||||
#include <TDF_ListIteratorOfLabelList.hxx>
|
||||
//
|
||||
// drawable object
|
||||
//
|
||||
#include <DrawTrSurf_Surface.hxx>
|
||||
#include <Draw_Axis3D.hxx>
|
||||
#include <DrawDim_Distance.hxx>
|
||||
#include <DrawDim_Radius.hxx>
|
||||
#include <DrawDim_Angle.hxx>
|
||||
#include <DrawDim_PlanarDistance.hxx>
|
||||
#include <DrawDim_PlanarRadius.hxx>
|
||||
#include <DrawDim_PlanarAngle.hxx>
|
||||
#include <DrawDim_PlanarDiameter.hxx>
|
||||
#include <DBRep_DrawableShape.hxx>
|
||||
|
||||
static Standard_Integer DISCRET = 100;
|
||||
static Standard_Integer NBISOS = 10;
|
||||
static Standard_Real THESIZE = 1000.;
|
||||
|
||||
// Unused
|
||||
#ifdef DEB
|
||||
static Standard_Real PLANETHESIZE = 100.;
|
||||
static Standard_Real DEFLECTION = 0.0;
|
||||
#endif
|
||||
|
||||
static Handle(DDataStd_DrawDriver) DrawDriver;
|
||||
|
||||
|
||||
Handle(DDataStd_DrawDriver) DDataStd_DrawDriver::Get () {return DrawDriver; }
|
||||
void DDataStd_DrawDriver::Set (const Handle(DDataStd_DrawDriver)& DD) {DrawDriver = DD; }
|
||||
|
||||
//=======================================================================
|
||||
//function : Displayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDataStd_DrawDriver::DDataStd_DrawDriver () {}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Geometry
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static TopoDS_Shape Geometry (const Handle(TDataXtd_Constraint)& A,
|
||||
const Standard_Integer i, TopAbs_ShapeEnum T)
|
||||
{
|
||||
TopoDS_Shape S = TNaming_Tool::GetShape(A->GetGeometry(i));
|
||||
if (!S.IsNull()) {
|
||||
if (T != TopAbs_SHAPE && T != S.ShapeType())
|
||||
S.Nullify();
|
||||
}
|
||||
return S;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Drawable
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDataStd_DrawDriver::Drawable (const TDF_Label& L) const
|
||||
{
|
||||
// CONSTRAINT
|
||||
|
||||
Handle(TDataXtd_Constraint) CTR;
|
||||
if (L.FindAttribute(TDataXtd_Constraint::GetID(),CTR)) {
|
||||
return DrawableConstraint(CTR);
|
||||
}
|
||||
|
||||
// OBJECT
|
||||
|
||||
TopoDS_Shape s;
|
||||
|
||||
//Handle(TDataStd_Object) OBJ;
|
||||
//if (L.FindAttribute(TDataStd_Object::GetID(),OBJ)) {
|
||||
// return DrawableShape (L,Draw_vert);
|
||||
//}
|
||||
|
||||
// DATUM
|
||||
|
||||
|
||||
Handle(TDataXtd_Point) POINT;
|
||||
if (L.FindAttribute(TDataXtd_Point::GetID(),POINT)) {
|
||||
return DrawableShape (L,Draw_magenta,Standard_False);
|
||||
}
|
||||
|
||||
Handle(TDataXtd_Axis) AXIS;
|
||||
if (L.FindAttribute(TDataXtd_Axis::GetID(),AXIS)) {
|
||||
return DrawableShape (L,Draw_magenta,Standard_False);
|
||||
}
|
||||
|
||||
Handle(TDataXtd_Plane) PLANE;
|
||||
if (L.FindAttribute(TDataXtd_Plane::GetID(),PLANE)) {
|
||||
return DrawableShape(L,Draw_magenta,Standard_False);
|
||||
}
|
||||
|
||||
// Standard GEOMETRY
|
||||
|
||||
|
||||
Handle(TDataXtd_Geometry) STD_GEOM;
|
||||
if (L.FindAttribute(TDataXtd_Geometry::GetID(),STD_GEOM)) {
|
||||
switch (STD_GEOM->GetType()) {
|
||||
case TDataXtd_POINT :
|
||||
{
|
||||
return DrawableShape(L,Draw_jaune,Standard_False);
|
||||
break;
|
||||
}
|
||||
case TDataXtd_LINE :
|
||||
case TDataXtd_CIRCLE :
|
||||
case TDataXtd_ELLIPSE :
|
||||
case TDataXtd_SPLINE :
|
||||
{
|
||||
return DrawableShape(L,Draw_cyan,Standard_False);
|
||||
break;
|
||||
}
|
||||
case TDataXtd_ANY_GEOM :
|
||||
{
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PURE SHAPE
|
||||
|
||||
Handle(TNaming_NamedShape) NS;
|
||||
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
|
||||
return DrawableShape (NS->Label(),Draw_jaune);
|
||||
}
|
||||
|
||||
Handle(Draw_Drawable3D) D3D;
|
||||
return D3D;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawableConstraint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDataStd_DrawDriver::DrawableConstraint (const Handle(TDataXtd_Constraint)& A) const
|
||||
{
|
||||
Handle(DrawDim_Dimension) D;
|
||||
|
||||
switch (A->GetType()) {
|
||||
|
||||
case TDataXtd_RADIUS:
|
||||
{
|
||||
if (A->IsPlanar()) {
|
||||
D = new DrawDim_PlanarRadius (TNaming_Tool::GetShape(A->GetGeometry(1)));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape aLocalShape = Geometry(A,1,TopAbs_FACE);
|
||||
TopoDS_Face F1 = TopoDS::Face(aLocalShape);
|
||||
// TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE));
|
||||
if (!F1.IsNull()) D = new DrawDim_Radius(F1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TDataXtd_DIAMETER:
|
||||
if (A->IsPlanar()) {
|
||||
D = new DrawDim_PlanarDiameter (TNaming_Tool::GetShape(A->GetGeometry(1)));
|
||||
}
|
||||
break;
|
||||
|
||||
case TDataXtd_MINOR_RADIUS:
|
||||
break;
|
||||
|
||||
case TDataXtd_MAJOR_RADIUS:
|
||||
break;
|
||||
|
||||
case TDataXtd_TANGENT:
|
||||
break;
|
||||
|
||||
case TDataXtd_PARALLEL:
|
||||
break;
|
||||
|
||||
case TDataXtd_PERPENDICULAR:
|
||||
break;
|
||||
|
||||
case TDataXtd_CONCENTRIC:
|
||||
break;
|
||||
|
||||
case TDataXtd_COINCIDENT:
|
||||
break;
|
||||
|
||||
case TDataXtd_DISTANCE:
|
||||
{
|
||||
if (A->IsPlanar()) {
|
||||
D = new DrawDim_PlanarDistance (TNaming_Tool::GetShape(A->GetGeometry(1)),
|
||||
TNaming_Tool::GetShape(A->GetGeometry(2)));
|
||||
}
|
||||
else {
|
||||
break;
|
||||
TopoDS_Shape aLocalShape = (Geometry (A, 1, TopAbs_FACE));
|
||||
TopoDS_Face F1 = TopoDS::Face (aLocalShape);
|
||||
// TopoDS_Face F1 = TopoDS::Face (Geometry (A, 1, TopAbs_FACE));
|
||||
if (A->NbGeometries() == 1) D = new DrawDim_Distance (F1);
|
||||
else {
|
||||
TopoDS_Shape aLocalShape = Geometry(A,2,TopAbs_FACE);
|
||||
TopoDS_Face F2 = TopoDS::Face(aLocalShape);
|
||||
// TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE));
|
||||
D = new DrawDim_Distance(F1,F2);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TDataXtd_ANGLE:
|
||||
{
|
||||
if (A->IsPlanar()) {
|
||||
Handle(DrawDim_PlanarAngle) DAng = new
|
||||
DrawDim_PlanarAngle (TNaming_Tool::GetShape(A->GetGeometry(1)),
|
||||
TNaming_Tool::GetShape(A->GetGeometry(2)));
|
||||
DAng->Sector(A->Reversed(),A->Inverted());
|
||||
TopoDS_Shape aLocalShape = TNaming_Tool::GetShape(A->GetPlane());
|
||||
DAng->SetPlane(TopoDS::Face(aLocalShape));
|
||||
// DAng->SetPlane(TopoDS::Face(TNaming_Tool::GetShape(A->GetPlane())));
|
||||
D = DAng;
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape aLocalShape = Geometry(A,1,TopAbs_FACE);
|
||||
TopoDS_Face F1 = TopoDS::Face(aLocalShape);
|
||||
aLocalShape = Geometry(A,2,TopAbs_FACE);
|
||||
TopoDS_Face F2 = TopoDS::Face(aLocalShape);
|
||||
// TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE));
|
||||
// TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE));
|
||||
if (!F1.IsNull() && !F2.IsNull()) D = new DrawDim_Angle(F1,F2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TDataXtd_EQUAL_RADIUS:
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TDataXtd_SYMMETRY:
|
||||
break;
|
||||
|
||||
case TDataXtd_MIDPOINT:
|
||||
break;
|
||||
|
||||
case TDataXtd_EQUAL_DISTANCE:
|
||||
break;
|
||||
|
||||
case TDataXtd_FIX:
|
||||
break;
|
||||
|
||||
case TDataXtd_RIGID:
|
||||
break;
|
||||
|
||||
case TDataXtd_FROM:
|
||||
break;
|
||||
|
||||
case TDataXtd_AXIS:
|
||||
break;
|
||||
|
||||
case TDataXtd_MATE:
|
||||
{
|
||||
TopoDS_Shape aLocalShape = Geometry(A,1,TopAbs_FACE);
|
||||
TopoDS_Face F1 = TopoDS::Face(aLocalShape);
|
||||
aLocalShape = Geometry(A,2,TopAbs_FACE);
|
||||
TopoDS_Face F2 = TopoDS::Face(aLocalShape);
|
||||
// TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE));
|
||||
// TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE));
|
||||
if (!F1.IsNull() && !F2.IsNull())
|
||||
D = new DrawDim_Distance(F1,F2);
|
||||
}
|
||||
break;
|
||||
|
||||
case TDataXtd_ALIGN_FACES:
|
||||
{
|
||||
TopoDS_Shape aLocalShape = Geometry(A,1,TopAbs_FACE) ;
|
||||
TopoDS_Face F1 = TopoDS::Face(aLocalShape);
|
||||
aLocalShape = Geometry(A,2,TopAbs_FACE) ;
|
||||
TopoDS_Face F2 = TopoDS::Face(aLocalShape);
|
||||
// TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE));
|
||||
// TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE));
|
||||
if (!F1.IsNull() && !F2.IsNull())
|
||||
D = new DrawDim_Distance(F1,F2);
|
||||
}
|
||||
break;
|
||||
|
||||
case TDataXtd_ALIGN_AXES:
|
||||
break;
|
||||
|
||||
case TDataXtd_AXES_ANGLE:
|
||||
break;
|
||||
|
||||
case TDataXtd_FACES_ANGLE:
|
||||
break;
|
||||
|
||||
case TDataXtd_ROUND:
|
||||
break;
|
||||
|
||||
case TDataXtd_OFFSET :
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (!D.IsNull()) {
|
||||
if (!A->GetValue().IsNull()) {
|
||||
Standard_Real val = A->GetValue()->Get();
|
||||
if (A->GetValue()->GetDimension() == TDataStd_ANGULAR) val = (180.*val)/PI;
|
||||
D->SetValue(val);
|
||||
}
|
||||
// unverified constraints are red (default is white)
|
||||
if (!A->Verified()) D->TextColor(Draw_rouge);
|
||||
}
|
||||
return D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawableShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDataStd_DrawDriver::DrawableShape (const TDF_Label& L,
|
||||
const Draw_ColorKind color,
|
||||
const Standard_Boolean current) const
|
||||
{
|
||||
Handle(Draw_Drawable3D) DS;
|
||||
Handle(TNaming_NamedShape) NS;
|
||||
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
|
||||
TopoDS_Shape S;
|
||||
if (current) S = TNaming_Tool::CurrentShape (NS);
|
||||
else S = TNaming_Tool::GetShape (NS);
|
||||
DS = DrawableShape (S,color);
|
||||
}
|
||||
return DS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawableShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDataStd_DrawDriver::DrawableShape (const TopoDS_Shape& s,
|
||||
const Draw_ColorKind color)
|
||||
{
|
||||
Handle(DBRep_DrawableShape) DS;
|
||||
DS = new DBRep_DrawableShape (s,color,color,color,Draw_bleu,THESIZE,NBISOS,DISCRET);
|
||||
return DS;
|
||||
}
|
||||
|
118
src/DDataStd/DDataStd_DrawPresentation.cdl
Executable file
118
src/DDataStd/DDataStd_DrawPresentation.cdl
Executable file
@@ -0,0 +1,118 @@
|
||||
-- File: DDataStd_Presentation.cdl
|
||||
-- Created: Wed Sep 23 08:15:56 1998
|
||||
-- Author: Denis PASCAL
|
||||
-- <dp@dingox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
|
||||
class DrawPresentation from DDataStd inherits Attribute from TDF
|
||||
|
||||
---Purpose: draw presentaion of a label of a document
|
||||
|
||||
|
||||
uses GUID from Standard,
|
||||
AttributeIndexedMap from TDF,
|
||||
DataSet from TDF,
|
||||
AttributeDelta from TDF,
|
||||
Label from TDF,
|
||||
RelocationTable from TDF,
|
||||
Drawable3D from Draw
|
||||
|
||||
is
|
||||
|
||||
|
||||
---Purpose: api methods on draw presentation
|
||||
-- ================================
|
||||
|
||||
HasPresentation (myclass; L : Label from TDF)
|
||||
returns Boolean from Standard;
|
||||
|
||||
IsDisplayed (myclass; L : Label from TDF)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Display (myclass; L : Label from TDF);
|
||||
-- display <L> presentation in draw viewer.
|
||||
|
||||
Erase (myclass; L : Label from TDF);
|
||||
-- erase <L> in draw viewer
|
||||
|
||||
Update (myclass; L : Label from TDF);
|
||||
-- recompute and display L in draw viewer
|
||||
|
||||
---Purpose: attribute implementation
|
||||
-- ========================
|
||||
|
||||
GetID(myclass) returns GUID from Standard;
|
||||
---C++: return const &
|
||||
|
||||
Create returns mutable DrawPresentation from DDataStd;
|
||||
|
||||
SetDisplayed (me : mutable; status : Boolean from Standard);
|
||||
|
||||
IsDisplayed (me)
|
||||
returns Boolean from Standard;
|
||||
|
||||
SetDrawable (me : mutable; D : Drawable3D from Draw);
|
||||
|
||||
GetDrawable (me)
|
||||
returns Drawable3D from Draw;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
---Purpose: call backs 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 draw viewer according to delta
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
---Purpose: private methods
|
||||
-- ===============
|
||||
|
||||
DrawBuild (me : mutable)
|
||||
is private;
|
||||
|
||||
DrawDisplay (myclass; L : Label from TDF; P : DrawPresentation from DDataStd)
|
||||
is private;
|
||||
|
||||
DrawErase (myclass; L : Label from TDF; P : DrawPresentation from DDataStd)
|
||||
is private;
|
||||
|
||||
fields
|
||||
|
||||
isDisplayed : Boolean from Standard;
|
||||
myDrawable : Drawable3D from Draw;
|
||||
|
||||
end DrawPresentation;
|
392
src/DDataStd/DDataStd_DrawPresentation.cxx
Executable file
392
src/DDataStd/DDataStd_DrawPresentation.cxx
Executable file
@@ -0,0 +1,392 @@
|
||||
// File: DDataStd_DrawPresentation.cxx
|
||||
// Created: Wed Sep 23 08:28:26 1998
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DDataStd_DrawPresentation.ixx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Viewer.hxx>
|
||||
#include <TDF_DefaultDeltaOnModification.hxx>
|
||||
#include <TDF_DefaultDeltaOnRemoval.hxx>
|
||||
#include <TDF_DeltaOnAddition.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <DDataStd_DrawDriver.hxx>
|
||||
|
||||
#ifndef WNT
|
||||
extern Draw_Viewer dout;
|
||||
#else
|
||||
Standard_IMPORT Draw_Viewer dout;
|
||||
#endif
|
||||
//=======================================================================
|
||||
//function : IsDisplayed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDataStd_DrawPresentation::IsDisplayed (const TDF_Label& L)
|
||||
{
|
||||
Handle(DDataStd_DrawPresentation) P;
|
||||
if (L.FindAttribute(DDataStd_DrawPresentation::GetID(),P)) {
|
||||
return P->IsDisplayed();
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDataStd_DrawPresentation::HasPresentation (const TDF_Label& L)
|
||||
{
|
||||
return (L.IsAttribute(DDataStd_DrawPresentation::GetID()));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Display
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::Display (const TDF_Label& L)
|
||||
{
|
||||
Handle(DDataStd_DrawPresentation) P;
|
||||
// set
|
||||
if (!L.FindAttribute(DDataStd_DrawPresentation::GetID(),P)) {
|
||||
P = new DDataStd_DrawPresentation ();
|
||||
L.AddAttribute(P);
|
||||
}
|
||||
// display
|
||||
if (P->IsDisplayed()) return;
|
||||
if (P->GetDrawable().IsNull()) P->DrawBuild();
|
||||
DrawDisplay (P->Label(),P);
|
||||
P->SetDisplayed(Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Erase
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::Erase(const TDF_Label& L)
|
||||
{
|
||||
Handle(DDataStd_DrawPresentation) P;
|
||||
if (L.FindAttribute(DDataStd_DrawPresentation::GetID(),P)) {
|
||||
if (P->IsDisplayed()) {
|
||||
DrawErase (P->Label(),P);
|
||||
P->SetDisplayed(Standard_False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Update
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::Update (const TDF_Label& L)
|
||||
{
|
||||
Handle(DDataStd_DrawPresentation) P;
|
||||
if (L.FindAttribute(DDataStd_DrawPresentation::GetID(),P)) {
|
||||
DrawErase(P->Label(),P);
|
||||
P->Backup();
|
||||
P->DrawBuild();
|
||||
DrawDisplay (P->Label(),P);
|
||||
P->SetDisplayed(Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose : idem GUID DDataStd Display
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& DDataStd_DrawPresentation::GetID()
|
||||
{
|
||||
static Standard_GUID DDataStd_DrawPresentationID("1c0296d4-6dbc-22d4-b9c8-0070b0ee301b");
|
||||
return DDataStd_DrawPresentationID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_DrawPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDataStd_DrawPresentation::DDataStd_DrawPresentation () : isDisplayed(Standard_False) {}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDisplayed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::SetDisplayed (const Standard_Boolean status)
|
||||
{
|
||||
isDisplayed = status;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDisplayed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDataStd_DrawPresentation::IsDisplayed () const
|
||||
{
|
||||
return isDisplayed;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDrawable
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::SetDrawable (const Handle(Draw_Drawable3D)& D)
|
||||
{
|
||||
myDrawable = D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDrawable
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDataStd_DrawPresentation::GetDrawable () const
|
||||
{
|
||||
return myDrawable;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& DDataStd_DrawPresentation::ID() const { return GetID(); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) DDataStd_DrawPresentation::NewEmpty() const
|
||||
{
|
||||
return new DDataStd_DrawPresentation ();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::Restore (const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::Restore" << endl;
|
||||
isDisplayed = Handle(DDataStd_DrawPresentation)::DownCast (With)->IsDisplayed();
|
||||
myDrawable = Handle(DDataStd_DrawPresentation)::DownCast (With)->GetDrawable();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::Paste (const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& RT) const
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::Paste" << endl;
|
||||
Handle(DDataStd_DrawPresentation)::DownCast(Into)->SetDisplayed(isDisplayed);
|
||||
Handle(DDataStd_DrawPresentation)::DownCast(Into)->SetDrawable(myDrawable);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AfterAddition
|
||||
//purpose : erase if displayed
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::AfterAddition()
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::AfterAddition" << endl;
|
||||
//if (isDisplayed) DrawDisplay ();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BeforeRemoval
|
||||
//purpose : erase if displayed
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::BeforeRemoval()
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeRemoval" << endl;
|
||||
//if (isDisplayed) DrawErase ();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BeforeForget
|
||||
//purpose : erase if displayed
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::BeforeForget()
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeForget" << endl;
|
||||
if (isDisplayed) DrawErase (Label(),this);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AfterResume
|
||||
//purpose : display if displayed
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::AfterResume()
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::AfterResume"<< endl;
|
||||
if (isDisplayed) DrawDisplay (Label(),this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BeforeUndo
|
||||
//purpose : le NamedShape associe doit etre present
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDataStd_DrawPresentation::BeforeUndo (const Handle(TDF_AttributeDelta)& AD,
|
||||
const Standard_Boolean forceIt)
|
||||
{
|
||||
Handle(DDataStd_DrawPresentation) Pme = this;
|
||||
Handle(DDataStd_DrawPresentation) Pdt = Handle(DDataStd_DrawPresentation)::DownCast(AD->Attribute());
|
||||
Handle(DDataStd_DrawPresentation) Pfw;
|
||||
if (AD->Label().FindAttribute(GetID(),Pfw)) {
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeUndo : attribute in framework" << endl;
|
||||
}
|
||||
else {
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeUndo : attribute not in framework" << endl;
|
||||
}
|
||||
//
|
||||
if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeUndo : delta on addition" << endl;
|
||||
if (Pfw->IsDisplayed()) DrawErase(AD->Label(),Pfw);
|
||||
//TDF appelle BeforeRemoval effacer
|
||||
}
|
||||
else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeUndo : delta on removal" << endl;
|
||||
}
|
||||
else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeUndo : delta on modification" << endl;
|
||||
if (Pfw->IsDisplayed()) DrawErase(AD->Label(),Pfw);
|
||||
}
|
||||
else {
|
||||
//cout<< "DDataStd_DrawPresentation::BeforeUndo : unknown delta" << endl;
|
||||
}
|
||||
//if (Label().IsNull()) cout<< "DDataStd_DrawPresentation::BeforeUndo : null label" << endl;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AfterUndo
|
||||
//purpose : le NamedShape associe doit etre present
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDataStd_DrawPresentation::AfterUndo (const Handle(TDF_AttributeDelta)& AD,
|
||||
const Standard_Boolean forceIt)
|
||||
{
|
||||
Handle(DDataStd_DrawPresentation) Pme = this;
|
||||
Handle(DDataStd_DrawPresentation) Pdt = Handle(DDataStd_DrawPresentation)::DownCast(AD->Attribute());
|
||||
Handle(DDataStd_DrawPresentation) Pfw;
|
||||
if (AD->Label().FindAttribute(GetID(),Pfw)) {
|
||||
//cout<< "DDataStd_DrawPresentation::AfterUndo : attribute in framework" << endl;
|
||||
}
|
||||
else {
|
||||
//cout<< "DDataStd_DrawPresentation::AfterUndo : attribute not in framework" << endl;
|
||||
}
|
||||
|
||||
//
|
||||
if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
|
||||
//cout<< "DDataStd_DrawPresentation::AfterUndo : delta on addition" << endl;
|
||||
}
|
||||
else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) {
|
||||
//cout<< "DDataStd_DrawPresentation::AfterUndo : delta on removal" << endl;
|
||||
if (Pdt->IsDisplayed()) DrawDisplay(AD->Label(),Pdt);
|
||||
}
|
||||
else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) {
|
||||
//cout<< "DDataStd_DrawPresentation::AfterUndo : delta on modification" << endl;
|
||||
if (Pdt->IsDisplayed()) DrawDisplay(AD->Label(),Pdt);
|
||||
}
|
||||
else {
|
||||
//cout<< "DDataStd_DrawPresentation::AfterUndo : unknown delta" << endl;
|
||||
}
|
||||
//if (Label().IsNull()) cout<< "DDataStd_DrawPresentation::AfterUndo : null label" << endl;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawBuild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::DrawBuild ()
|
||||
{
|
||||
//cout<< "DDataStd_DrawPresentation::DrawBuild" << endl;
|
||||
Handle(DDataStd_DrawDriver) DD = DDataStd_DrawDriver::Get();
|
||||
if (DD.IsNull()) {
|
||||
DD = new DDataStd_DrawDriver ();
|
||||
DDataStd_DrawDriver::Set(DD);
|
||||
}
|
||||
Handle(Draw_Drawable3D) D3D = DD->Drawable(Label());
|
||||
if (D3D.IsNull()) cout<< "DDataStd_DrawPresentation::DrawBuild : null drawable" << endl;
|
||||
myDrawable = D3D;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawDisplay
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::DrawDisplay (const TDF_Label& L,
|
||||
const Handle(DDataStd_DrawPresentation)& P)
|
||||
{
|
||||
if (!L.IsNull()) {
|
||||
if (!P->GetDrawable().IsNull()) {
|
||||
TCollection_AsciiString S;
|
||||
TDF_Tool::Entry(L,S);
|
||||
Standard_CString name = S.ToCString();
|
||||
Draw::Set(name,P->GetDrawable());
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//cout<< "DDataStd_DrawPresentation::DrawDisplay : null Drawable" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout<< "DDataStd_DrawPresentation::DrawDisplay : null Label" << endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawErase
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_DrawPresentation::DrawErase (const TDF_Label& L,
|
||||
const Handle(DDataStd_DrawPresentation)& P)
|
||||
{
|
||||
if (!L.IsNull()) {
|
||||
if (!P->GetDrawable().IsNull()) {
|
||||
dout.RemoveDrawable(P->GetDrawable());
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//cout<< "DDataStd_DrawPresentation::DrawErase : null Drawable" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout<< "DDataStd_DrawPresentation::DrawErase : null Label" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
203
src/DDataStd/DDataStd_NameCommands.cxx
Executable file
203
src/DDataStd/DDataStd_NameCommands.cxx
Executable file
@@ -0,0 +1,203 @@
|
||||
// File: DDataStd_NameCommands.cxx
|
||||
// Created: Thu Aug 19 12:19:35 1999
|
||||
// Author: Sergey RUIN
|
||||
// <s-ruin@nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DDataStd.hxx>
|
||||
#include <DDF.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_AttributeSequence.hxx>
|
||||
#include <TDF_AttributeList.hxx>
|
||||
#include <TDF_ListIteratorOfAttributeList.hxx>
|
||||
|
||||
// ATTRIBUTES
|
||||
|
||||
#include <TDataStd.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDataStd_ListOfExtendedString.hxx>
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetName
|
||||
//purpose : SetName (DF, entry, name)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetName (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
// if (nb == 3) {
|
||||
// Handle(TDF_Data) DF;
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// TDF_Label L;
|
||||
// DDF::FindLabel(DF, arg[2], L);
|
||||
// if(L.IsNull()) cout << "Label is not found" << endl;
|
||||
// Handle(TDataStd_Name) N = TDataStd_Name::Set(L);
|
||||
// return 0;
|
||||
// }
|
||||
// else if (nb == 4) {
|
||||
if (nb == 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::FindLabel(DF, arg[2], L);
|
||||
if(L.IsNull()) di << "Label is not found" << "\n";
|
||||
Handle(TDataStd_Name) N;
|
||||
//if( !L.FindAttribute(TDataStd_Name::GetID(), N) ) N = TDataStd_Name::Set(L);
|
||||
//N->Set(arg[3]);
|
||||
N = TDataStd_Name::Set(L,arg[3]);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetName : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetName
|
||||
//purpose : GetName (DF, entry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetName (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::FindLabel(DF, arg[2], L);
|
||||
if(L.IsNull()) di << "Label is not found" << "\n";
|
||||
Handle(TDataStd_Name) N;
|
||||
if( !L.FindAttribute(TDataStd_Name::GetID(), N) ) return 1;
|
||||
TCollection_AsciiString s(N->Get(),'?');
|
||||
di << s.ToCString();
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetName : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LabelName (DF, [entry], path)
|
||||
//=======================================================================
|
||||
// static Standard_Integer DDataStd_LabelName (Draw_Interpretor& di,
|
||||
// Standard_Integer nb,
|
||||
// const char** arg)
|
||||
// {
|
||||
// Handle(TDF_Data) DF;
|
||||
// TDF_Label label;
|
||||
// Handle(TDataStd_Name) result;
|
||||
// TDataStd_ListOfExtendedString myList;
|
||||
// Standard_Integer i = 2;
|
||||
// Standard_Boolean Found = Standard_False;
|
||||
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// if( nb == 4 ) {
|
||||
// if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
// cout << "No label for entry" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
// i = 3;
|
||||
// }
|
||||
|
||||
// if( !TDataStd_Name::MakePath(arg[i], myList) ) return 1;
|
||||
|
||||
// if( nb == 4 ) {
|
||||
// Handle(TDataStd_Name) current;
|
||||
// if (TDataStd_Name::Find(label,current)) {
|
||||
// if (current->Find(myList ,result)) Found = Standard_True;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if(TDataStd_Name::Find(DF, myList ,result)) Found = Standard_True;
|
||||
// }
|
||||
|
||||
// if(Found) {
|
||||
// DDF::ReturnLabel(di, result->Label());
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// cout << "Label wasn't found" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
||||
// //=======================================================================
|
||||
// //function : FullPath (DF, entry)
|
||||
// //=======================================================================
|
||||
// static Standard_Integer DDataStd_FullPath (Draw_Interpretor& di,
|
||||
// Standard_Integer nb,
|
||||
// const char** arg)
|
||||
// {
|
||||
// Handle(TDF_Data) DF;
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// TDF_Label label;
|
||||
// if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
// cout << "No label for entry" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
// Handle(TDataStd_Name) current;
|
||||
// if (TDataStd_Name::Find(label,current)) {
|
||||
// TDF_AttributeList myList;
|
||||
// if (!current->FullPath(myList)) return 1;
|
||||
// TDF_ListIteratorOfAttributeList itr(myList);
|
||||
// TCollection_AsciiString str;
|
||||
// for(;itr.More(); itr.Next() ) {
|
||||
// str+=Handle(TDataStd_Name)::DownCast(itr.Value())->Get();
|
||||
// str+=":";
|
||||
// }
|
||||
// str.Remove(str.Length()); //remove last ":"
|
||||
// di << str.ToCString();
|
||||
// }
|
||||
// #ifndef DEB
|
||||
// return 0 ;
|
||||
// #endif
|
||||
// }
|
||||
//=======================================================================
|
||||
//function : SetCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::NameCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "DDataStd : Name attribute commands";
|
||||
|
||||
theCommands.Add ("SetName",
|
||||
"SetName (DF, entry, name)",
|
||||
__FILE__, DDataStd_SetName, g);
|
||||
|
||||
theCommands.Add ("GetName",
|
||||
"GetNmae (DF, entry)",
|
||||
__FILE__, DDataStd_GetName, g);
|
||||
|
||||
// theCommands.Add ("LabelName",
|
||||
// "GetLabel (DF, [entry], path(name1:name2:...nameN)",
|
||||
// __FILE__, DDataStd_LabelName, g);
|
||||
|
||||
// theCommands.Add ("FullPath",
|
||||
// "FullPath (DF, entry)",
|
||||
// __FILE__, DDataStd_FullPath, g);
|
||||
|
||||
}
|
||||
|
70
src/DDataStd/DDataStd_NamedShapeCommands.cxx
Executable file
70
src/DDataStd/DDataStd_NamedShapeCommands.cxx
Executable file
@@ -0,0 +1,70 @@
|
||||
// File: DDataStd_NamedShapeCommands.cxx
|
||||
// Created: Wed Jul 30 16:47:00 1997
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
#include <DDataStd.hxx>
|
||||
#include <DDataStd_DrawPresentation.hxx>
|
||||
#include <DDF.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
#include <DBRep.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
|
||||
// LES ATTRIBUTES
|
||||
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetShape
|
||||
//purpose : SetShape (DF, entry, drawshape)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetShape (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TopoDS_Shape s = DBRep::Get(arg[3]);
|
||||
if (s.IsNull()) { di <<"shape not found"<< "\n"; return 1;}
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
TNaming_Builder SI (L);
|
||||
SI.Generated(s);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetShape : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NamedShapeCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::NamedShapeCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "DData : Standard Attribute Commands";
|
||||
|
||||
|
||||
theCommands.Add ("SetShape",
|
||||
"SetShape (DF, entry, drawname)",
|
||||
__FILE__, DDataStd_SetShape, g);
|
||||
|
||||
}
|
224
src/DDataStd/DDataStd_ObjectCommands.cxx
Executable file
224
src/DDataStd/DDataStd_ObjectCommands.cxx
Executable file
@@ -0,0 +1,224 @@
|
||||
// File: DDataStd_ObjectCommands.cxx
|
||||
// Created: Thu Jul 15 10:19:40 1999
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
#include <DDataStd.hxx>
|
||||
#include <DDataStd_DrawPresentation.hxx>
|
||||
#include <DDF.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <TDataStd_Directory.hxx>
|
||||
#include <TDataXtd_Shape.hxx>
|
||||
|
||||
|
||||
// LES ATTRIBUTES
|
||||
|
||||
#include <TDataStd_NoteBook.hxx>
|
||||
#include <TDataXtd_Shape.hxx>
|
||||
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <DBRep.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewDirectory (DF, entry )
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_NewDirectory (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if( nb != 3 ) {
|
||||
di << "Too few arguments" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
DDF::AddLabel(DF, arg[2], label);
|
||||
TDataStd_Directory::New(label );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddDirectory (DF, entry )
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_AddDirectory (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if( nb != 3 ) {
|
||||
di << "Too few arguments" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
di << "No label for entry" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDataStd_Directory) A;
|
||||
if (TDataStd_Directory::Find(label, A)) {
|
||||
Handle(TDataStd_Directory) Dir = TDataStd_Directory::AddDirectory (A);
|
||||
TCollection_AsciiString entry;
|
||||
TDF_Tool::Entry(Dir->Label(), entry);
|
||||
di << entry.ToCString()<<" "; //return a label to draw
|
||||
return 0;
|
||||
}
|
||||
di << "No Object Attribute on label" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeObjectLabel (DF, entry )
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_MakeObjectLabel (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if( nb != 3 ) {
|
||||
di << "Too few arguments" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
di << "No label for entry" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDataStd_Directory) A;
|
||||
if(TDataStd_Directory::Find(label,A)) {
|
||||
TCollection_AsciiString entry;
|
||||
TDF_Tool::Entry(TDataStd_Directory::MakeObjectLabel(A), entry);
|
||||
di << entry.ToCString()<<" "; //return a label to draw
|
||||
return 0;
|
||||
}
|
||||
di << "No Object Attribute on label" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_NewNoteBook
|
||||
//purpose : NewNoteBook (DF, entry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_NewNoteBook (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
TDataStd_NoteBook::New(L);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_NewNoteBook : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewShape (DF, entry, [in_shape] )
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_NewShape (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
//di << "nb = " <<nb << "\n";
|
||||
if( nb < 3 ) {
|
||||
di << "Too few arguments" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
DDF::AddLabel(DF, arg[2], label);
|
||||
if( nb == 4 ) {
|
||||
TopoDS_Shape shape = DBRep::Get( arg[3] );
|
||||
if( shape.IsNull() ) {
|
||||
di << "Shape argument is invalid" << "\n";
|
||||
return 1;
|
||||
}
|
||||
TDataXtd_Shape::Set(label, shape );
|
||||
}
|
||||
else TDataXtd_Shape::New(label);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShape2 (DF, entry, out_shape )
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_GetShape2 (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if( nb < 4 ) {
|
||||
di << "Too few arguments" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
di << "No label for entry" << "\n";
|
||||
return 1;
|
||||
}
|
||||
DBRep::Set(arg[3], TDataXtd_Shape::Get(label));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ObjectComands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::ObjectCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "DData : Standard Attribute Commands";
|
||||
|
||||
theCommands.Add ("NewNoteBook",
|
||||
"NewNoteBook (DF, entry)",
|
||||
__FILE__, DDataStd_NewNoteBook, g);
|
||||
|
||||
theCommands.Add ("NewShape",
|
||||
"NewShape (DF, entry, [in_shape] )",
|
||||
__FILE__, DDataStd_NewShape, g);
|
||||
|
||||
theCommands.Add ("GetShape2",
|
||||
"GetShape2 (DF, entry, out_shape )",
|
||||
__FILE__, DDataStd_GetShape2, g);
|
||||
|
||||
theCommands.Add ("NewDirectory",
|
||||
"NewDirectory (DF, entry)",
|
||||
__FILE__, DDataStd_NewDirectory, g);
|
||||
|
||||
theCommands.Add ("AddDirectory",
|
||||
"AddDirectory (DF, entry)",
|
||||
__FILE__, DDataStd_AddDirectory, g);
|
||||
|
||||
theCommands.Add ("MakeObjectLabel",
|
||||
"MakeObjectLabel (DF, entry)",
|
||||
__FILE__, DDataStd_MakeObjectLabel, g);
|
||||
|
||||
}
|
||||
|
422
src/DDataStd/DDataStd_Sample.cxx
Executable file
422
src/DDataStd/DDataStd_Sample.cxx
Executable file
@@ -0,0 +1,422 @@
|
||||
// File: DDataStd_Sample.cxx
|
||||
// Created: Tue Dec 28 09:46:59 1999
|
||||
// Author: Sergey RUIN
|
||||
// <srn@popox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDataXtd_Axis.hxx>
|
||||
#include <TDataStd_Current.hxx>
|
||||
#include <TDataStd_Comment.hxx>
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDataStd_IntegerArray.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_RealArray.hxx>
|
||||
#include <TDF_Reference.hxx>
|
||||
#include <TDataStd_UAttribute.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataXtd_Constraint.hxx>
|
||||
#include <TDataXtd_Shape.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDataStd_Directory.hxx>
|
||||
#include <TDataXtd_Point.hxx>
|
||||
#include <TDataXtd_Plane.hxx>
|
||||
#include <TDataXtd_Geometry.hxx>
|
||||
#include <TDataXtd_GeometryEnum.hxx>
|
||||
#include <TDataXtd_ConstraintEnum.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Cylinder.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TDF_AttributeList.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TDataStd_ListOfExtendedString.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
|
||||
#ifdef DEB
|
||||
|
||||
static void Sample()
|
||||
{
|
||||
// Starting with data framework
|
||||
Handle(TDF_Data) DF = new TDF_Data();
|
||||
TDF_Label aLabel = DF->Root();
|
||||
|
||||
//------------------------- TDataStd_Integer (Real) ---------------------------------
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
// Setting TDataStd_Integer attribute to a label (work with TDataStd_Real is the same)
|
||||
|
||||
Standard_Integer i = 10;
|
||||
|
||||
Handle(TDataStd_Integer) I = TDataStd_Integer::Set(aLabel, i);
|
||||
|
||||
// Getting the value stored in TDataStd_Integer attribute
|
||||
|
||||
Standard_Integer aValue;
|
||||
|
||||
aValue = I->Get();
|
||||
|
||||
// Setting the new value in the attribute
|
||||
|
||||
I->Set( 25 );
|
||||
|
||||
//------------------------- TDataStd_RealArray (IntegerArray is analogical) --------------
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
||||
// Setting TDataStd_RealArray attribute to a label
|
||||
|
||||
Standard_Integer lower = 1, upper = 20;
|
||||
|
||||
Handle(TDataStd_RealArray) realarray = TDataStd_RealArray::Set(aLabel, lower, upper);
|
||||
|
||||
// Filling array
|
||||
|
||||
for(Standard_Integer j = realarray->Lower(); j<= realarray->Upper(); j++) {
|
||||
realarray->SetValue(j, Standard_PI*j);
|
||||
}
|
||||
|
||||
// Getting length of array
|
||||
|
||||
Standard_Integer length = realarray->Length();
|
||||
|
||||
// Retrieving value by index
|
||||
|
||||
Standard_Real value = realarray->Value(3);
|
||||
|
||||
// Getting handle to an underlying array TColStd_HArray1OfReal
|
||||
|
||||
Handle(TColStd_HArray1OfReal) array = realarray->Array();
|
||||
|
||||
//------------------------- TDataStd_Comment --------------
|
||||
//---------------------------------------------------------
|
||||
|
||||
// Setting TDataStd_Comment attribute to a label
|
||||
|
||||
Handle(TDataStd_Comment) comment = TDataStd_Comment::Set(aLabel);
|
||||
|
||||
// Setting comment string in to the attribute
|
||||
|
||||
TCollection_ExtendedString message = "This is a remark";
|
||||
|
||||
comment->Set(message);
|
||||
|
||||
// Getting comment string stored in the attribute
|
||||
|
||||
TCollection_ExtendedString string = comment->Get();
|
||||
|
||||
//------------------------- TDataStd_Name -----------------
|
||||
//---------------------------------------------------------
|
||||
|
||||
// Setting TDataStd_Name attribute to a label
|
||||
|
||||
// Handle(TDataStd_Name) name = TDataStd_Name::Set(aLabel);
|
||||
|
||||
|
||||
// Checking if the label has a name (TDataStd_Name attribute with not empty name field)
|
||||
|
||||
// Standard_Boolean isempty = name->IsEmpty();
|
||||
|
||||
// Getting the name of the label
|
||||
|
||||
//if( !isempty ) TCollection_ExtendedString thename = name->Get();
|
||||
|
||||
// Erasing the name of the label in TDataStd_Name attribute
|
||||
|
||||
// name->SetEmpty();
|
||||
|
||||
// Setting a new name string in the attribute
|
||||
|
||||
TCollection_ExtendedString aname = "Name of the label";
|
||||
Handle(TDataStd_Name) name = TDataStd_Name::Set(aLabel,aname);
|
||||
|
||||
name->Set(aname);
|
||||
|
||||
// Getting comment string stored in the attribute
|
||||
|
||||
TCollection_ExtendedString namestring = name->Get();
|
||||
|
||||
// Getting the first father label which has TDataStd_Name attribute
|
||||
|
||||
//Handle(TDataStd_Name) father;
|
||||
|
||||
//Standard_Boolean hasfather = name->Father(father);
|
||||
|
||||
// Find if there exists label with full path "Assembly1:Part3:Prism7"
|
||||
|
||||
// Converting string to list of names
|
||||
|
||||
//TCollection_ExtendedString fullpath = "Assembly_1:Part_3:Prism_7";
|
||||
//TDataStd_ListOfExtendedString listofstring;
|
||||
|
||||
//TDataStd_Name::MakePath(fullpath, listofstring);
|
||||
|
||||
//Handle(TDataStd_Name) nameattribute;
|
||||
|
||||
//Standard_Boolean found = TDataStd_Name::Find(DF, listofstring, nameattribute);
|
||||
|
||||
//if( found ) {
|
||||
// Getting the fullpath of the nameattribute (fullpath consists of list of TDataStd_Name attributes situated on
|
||||
// father labels from label where nameattribute is situated to root label
|
||||
//TDF_AttributeList list;
|
||||
|
||||
//nameattribute->FullPath(list);
|
||||
//}
|
||||
|
||||
//TDF_Label currentLabel;
|
||||
|
||||
// ... Finding currentLabel...
|
||||
|
||||
// Search under <currentLabel> a label which fits with the given name
|
||||
|
||||
//Handle(TDataStd_Name) givenname;
|
||||
|
||||
//found = TDataStd_Name::Find(currentLabel, "Sketch_11", givenname);
|
||||
|
||||
//if( found ) {
|
||||
|
||||
// Getting all named child labels of the label where givenname attribute situated
|
||||
//TDF_AttributeList listOfChildren;name to the
|
||||
//Standard_Boolean isAtLeastOneFound = givenname->ChildNames(listOfChildren);
|
||||
//}
|
||||
|
||||
|
||||
//------------------------- TDataStd_UAttribute -----------
|
||||
//---------------------------------------------------------
|
||||
|
||||
// Setting TDataStd_UAttribute to a label
|
||||
|
||||
Standard_GUID guid("01010101-0101-0101-1010-010101010101");
|
||||
|
||||
Handle(TDataStd_UAttribute) uattribute = TDataStd_UAttribute::Set(aLabel, guid);
|
||||
|
||||
// Finding a TDataStd_UAttribute on the label using standard mechanism
|
||||
|
||||
Handle(TDataStd_UAttribute) theUA;
|
||||
if (aLabel.FindAttribute(guid,theUA)) {
|
||||
// do something
|
||||
}
|
||||
|
||||
// Checking that a TDataStd_UAttribute exist on a given label using standard mechanism
|
||||
|
||||
if (aLabel.IsAttribute(guid)) {
|
||||
// do something
|
||||
}
|
||||
|
||||
//------------------------- TDF_Reference -----------
|
||||
//---------------------------------------------------------
|
||||
|
||||
TDF_Label referencedlabel;
|
||||
|
||||
// ... Finding referencedlabel ...
|
||||
|
||||
|
||||
// Setting TDF_Reference attribute to a label
|
||||
|
||||
Handle(TDF_Reference) reference = TDF_Reference::Set(aLabel, referencedlabel);
|
||||
|
||||
// Getting a label to TDF_Reference attribute refers to
|
||||
|
||||
TDF_Label refLabel = reference->Get();
|
||||
|
||||
|
||||
//------------------------- TDataXtd_Point ----------------
|
||||
//---------------------------------------------------------
|
||||
gp_Pnt Pnt;
|
||||
|
||||
// ... Defining point <Pnt> ...
|
||||
|
||||
// Setting TDataXtd_Point attribute to a label
|
||||
|
||||
Handle(TDataXtd_Point) P = TDataXtd_Point::Set(aLabel, Pnt);
|
||||
|
||||
//Retrieve gp_Pnt associated with attribute
|
||||
|
||||
gp_Pnt aPnt;
|
||||
TDataXtd_Geometry::Point(aLabel, aPnt);
|
||||
|
||||
//------------------------- TDataXtd_Plane ----------------
|
||||
//---------------------------------------------------------
|
||||
gp_Pln Plane;
|
||||
|
||||
// ... Defining plane <Plane> ...
|
||||
|
||||
// Setting TDataXtd_Plane attribute to a label
|
||||
|
||||
Handle(TDataXtd_Plane) Pl = TDataXtd_Plane::Set(aLabel, Plane);
|
||||
|
||||
//Retrieve gp_Plane associated with attribute
|
||||
|
||||
gp_Pln aPlane;
|
||||
TDataXtd_Geometry::Plane(aLabel, aPlane);
|
||||
|
||||
//------------------------- TDataXtd_Axis ----------------
|
||||
//---------------------------------------------------------
|
||||
|
||||
gp_Lin Axis;
|
||||
|
||||
// ... Defining axis <Axis> ...
|
||||
|
||||
// Setting TDataXtd_Axis attribute to a label
|
||||
|
||||
Handle(TDataXtd_Axis) axis = TDataXtd_Axis::Set(aLabel, Axis);
|
||||
|
||||
//Retrieve gp_Ax1 associated with attribute
|
||||
|
||||
gp_Ax1 anAxis;
|
||||
TDataXtd_Geometry::Axis(aLabel, anAxis);
|
||||
|
||||
|
||||
//------------------------- TDataXtd_Geometry ----------------
|
||||
//---------------------------------------------------------
|
||||
|
||||
Handle(TNaming_NamedShape) NS;
|
||||
|
||||
// ... Constructing NS which contains cylinder...
|
||||
|
||||
// Setting TDataXtd_Geometry attribute to the label where <NS> is situated
|
||||
|
||||
TDF_Label NSLabel = NS->Label();
|
||||
|
||||
Handle(TDataXtd_Geometry) geom = TDataXtd_Geometry::Set(NSLabel);
|
||||
|
||||
// Setting a type of geometry
|
||||
|
||||
geom->SetType(TDataXtd_CYLINDER);
|
||||
|
||||
// Retrieving gp_Cylinder stored in associated NamedShape
|
||||
|
||||
// Checking the type of geometry
|
||||
|
||||
if( geom->GetType() == TDataXtd_CYLINDER ) {
|
||||
|
||||
gp_Cylinder Cylinder;
|
||||
|
||||
TDataXtd_Geometry::Cylinder(geom->Label(), Cylinder);
|
||||
|
||||
}
|
||||
|
||||
//------------------------- TDataXtd_Constraint -------------
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// Setting TDataXtd_Constraint to a label
|
||||
|
||||
Handle(TDataXtd_Constraint) constraint = TDataXtd_Constraint::Set(aLabel);
|
||||
|
||||
Handle(TNaming_NamedShape) NS1, NS2;
|
||||
Handle(TDataStd_Real) aDistance;
|
||||
|
||||
// ... Constructing NS1 and NS2 which contain lines and calculating the distance between them ...
|
||||
|
||||
// Setting DISTANCE Dimension between NS1 and NS2
|
||||
|
||||
constraint->Set(TDataXtd_DISTANCE, NS1, NS2);
|
||||
|
||||
constraint->SetValue(aDistance); // <aDistance> should contain the calucalated distance
|
||||
|
||||
// Checking if <constraint> is a Dimension rather than a Constraint
|
||||
|
||||
Standard_Boolean isdimension = constraint->IsDimension();
|
||||
|
||||
if(isdimension) {
|
||||
|
||||
// Getting the distance between NS1 and NS2
|
||||
|
||||
Handle(TDataStd_Real) valOfdistance = constraint->GetValue();
|
||||
|
||||
Standard_Real distance = valOfdistance->Get();
|
||||
}
|
||||
|
||||
// Setting PARALLEL constraint between NS1 and NS2
|
||||
|
||||
constraint->Set(TDataXtd_PARALLEL, NS1, NS2);
|
||||
|
||||
// Getting number of geometries which define a constarint
|
||||
|
||||
Standard_Integer number = constraint->NbGeometries();
|
||||
|
||||
// Checking if a constraint is verified
|
||||
|
||||
Standard_Boolean isverified = constraint->Verified();
|
||||
if( !isverified ) {
|
||||
cout << "Constraint is not valid" << endl;
|
||||
}
|
||||
|
||||
|
||||
//------------------------- TDataStd_Directory --------------
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// Setting TDataStd_Directory to a label
|
||||
|
||||
Handle(TDataStd_Directory) directory = TDataStd_Directory::New(aLabel);
|
||||
|
||||
// Creating a new sub directory of the given directory
|
||||
|
||||
Handle(TDataStd_Directory) newdirectory = TDataStd_Directory::AddDirectory(directory);
|
||||
|
||||
// Creating a new label in directory
|
||||
|
||||
TDF_Label newlabel = TDataStd_Directory::MakeObjectLabel(newdirectory);
|
||||
|
||||
|
||||
//------------------------- TDataStd_TreeNode ---------------
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// Let's create a tree:
|
||||
|
||||
// Root
|
||||
// |
|
||||
// --- FirstChild
|
||||
// |
|
||||
// --- SecondChild
|
||||
// |
|
||||
// --- FirstChildOfSecondChild
|
||||
|
||||
|
||||
|
||||
// Setting a TDataStd_TreeNode attribute to a label.
|
||||
// It becomes a root because it hasn't a father:
|
||||
|
||||
Handle(TDataStd_TreeNode) Root = TDataStd_TreeNode::Set(aLabel);
|
||||
|
||||
// Create a child TreeNode:
|
||||
|
||||
Handle(TDataStd_TreeNode) FirstChild = TDataStd_TreeNode::Set(aLabel.FindChild(1));
|
||||
Root->Append(FirstChild);
|
||||
|
||||
// Let's add a second child node to the Root:
|
||||
|
||||
Handle(TDataStd_TreeNode) SecondChild = TDataStd_TreeNode::Set(aLabel.FindChild(2));
|
||||
Root->Append(SecondChild);
|
||||
|
||||
// Now, it's time to create the a child for the SecondChild node - FirstChildOfSecondChild:
|
||||
|
||||
Handle(TDataStd_TreeNode) FirstChildOfSecondChild = TDataStd_TreeNode::Set(aLabel.FindChild(3));
|
||||
SecondChild->Append(FirstChildOfSecondChild);
|
||||
|
||||
// Let's redesign the tree:
|
||||
|
||||
// Root
|
||||
// |
|
||||
// --- SecondChild
|
||||
// |
|
||||
// --- FirstChild
|
||||
// |
|
||||
// --- FirstChildOfSecondChild
|
||||
|
||||
// Removing of the FirstChild from our tree:
|
||||
|
||||
FirstChild->Remove();
|
||||
|
||||
// Setting the FirstChild node as a first child of the SecondChild node:
|
||||
|
||||
SecondChild->Prepend(FirstChild);
|
||||
}
|
||||
|
||||
#endif
|
69
src/DDataStd/DDataStd_TreeBrowser.cdl
Executable file
69
src/DDataStd/DDataStd_TreeBrowser.cdl
Executable file
@@ -0,0 +1,69 @@
|
||||
-- File: DDataStd_TreeBrowser.cdl
|
||||
-- --------------------
|
||||
-- Author: DAUTRY Philippe
|
||||
-- <fid@fox.paris1.matra-dtv.fr>
|
||||
---Copyright: MATRA DATAVISION 1997
|
||||
|
||||
---Version: 0.0
|
||||
---History: Version Date Purpose
|
||||
-- 0.0 Nov 27 1997 Creation
|
||||
|
||||
class TreeBrowser from DDataStd inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: Browses a TreeNode from TDataStd.
|
||||
-- =================================
|
||||
|
||||
uses
|
||||
|
||||
Label from TDF,
|
||||
TreeNode from TDataStd,
|
||||
Interpretor from Draw,
|
||||
Display from Draw,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Create (root : Label from TDF)
|
||||
returns mutable TreeBrowser from DDataStd;
|
||||
|
||||
DrawOn (me; dis : in out Display);
|
||||
|
||||
Copy (me)
|
||||
returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
|
||||
Dump (me; S : in out OStream)
|
||||
is redefined;
|
||||
|
||||
Whatis (me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
|
||||
---Purpose: Specific methods
|
||||
-- ================
|
||||
|
||||
Label (me : mutable; root : Label from TDF);
|
||||
|
||||
Label (me)
|
||||
returns Label from TDF;
|
||||
|
||||
OpenRoot (me)
|
||||
---Purpose: Returns a string composed with the TreeNode of
|
||||
-- <myLabel>.
|
||||
returns AsciiString from TCollection;
|
||||
|
||||
OpenNode (me; L : Label from TDF)
|
||||
---Purpose: Returns a string composed with the sub-TreeNodes of
|
||||
-- <L>
|
||||
returns AsciiString from TCollection;
|
||||
|
||||
OpenNode (me; aTreeNode : TreeNode from TDataStd;
|
||||
aList : in out AsciiString from TCollection)
|
||||
---Purpose: Returns a string composed with the sub-TreeNodes
|
||||
-- of <aTreeNode>. Used to implement other methods.
|
||||
is private;
|
||||
|
||||
fields
|
||||
|
||||
myRoot : Label from TDF;
|
||||
|
||||
end TreeBrowser;
|
213
src/DDataStd/DDataStd_TreeBrowser.cxx
Executable file
213
src/DDataStd/DDataStd_TreeBrowser.cxx
Executable file
@@ -0,0 +1,213 @@
|
||||
// File: DDesign_TreeNodeBrowser.cxx
|
||||
// --------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Nov 27 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDataStd_TreeBrowser.ixx>
|
||||
#include <DDataStd.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TDF.hxx>
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Communication convention with tcl:
|
||||
// tcl waits for a string of characters, being an information list.
|
||||
// In this list, each item is separated from another by a separator: '\'.
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
#define TDF_BrowserSeparator1 '\\'
|
||||
#define TDF_BrowserSeparator2 ' '
|
||||
#define TDF_BrowserSeparator3 '#'
|
||||
#define TDF_BrowserSeparator4 ','
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDesign_TreeNodeBrowser
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDataStd_TreeBrowser::DDataStd_TreeBrowser(const TDF_Label& aLabel)
|
||||
: myRoot(aLabel)
|
||||
{}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_TreeBrowser::DrawOn(Draw_Display& dis) const
|
||||
{ cout<<"DDataStd_TreeBrowser"<<endl; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDataStd_TreeBrowser::Copy() const
|
||||
{ return new DDataStd_TreeBrowser(myRoot); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_TreeBrowser::Dump(Standard_OStream& S) const
|
||||
{
|
||||
S<<"DDataStd_TreeBrowser on a label: "<<endl;
|
||||
S<<myRoot;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_TreeBrowser::Whatis(Draw_Interpretor& I) const
|
||||
{ I<<"function browser"; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Label
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_TreeBrowser::Label(const TDF_Label& aLabel)
|
||||
{ myRoot = aLabel; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Label
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label DDataStd_TreeBrowser::Label() const
|
||||
{ return myRoot; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenRoot
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDataStd_TreeBrowser::OpenRoot() const
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
Handle(TDataStd_TreeNode) TN;
|
||||
if (myRoot.FindAttribute (TDataStd_TreeNode::GetDefaultTreeID(),TN)) {
|
||||
OpenNode(TN,list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenNode
|
||||
//purpose :
|
||||
// the items are separated by "\\".
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDataStd_TreeBrowser::OpenNode(const TDF_Label& aLabel) const
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
Handle(TDataStd_TreeNode) nodeToOpen;
|
||||
if (aLabel.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), nodeToOpen)) {
|
||||
Standard_Boolean split = Standard_False;
|
||||
Handle(TDataStd_TreeNode) current = nodeToOpen->First();
|
||||
while (!current.IsNull()) {
|
||||
if (split) list.AssignCat(TDF_BrowserSeparator1);
|
||||
OpenNode(current,list);
|
||||
split = Standard_True;
|
||||
current = current->Next();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenNode
|
||||
//purpose :
|
||||
// An item is composed as follows:
|
||||
// "LabelEntry "Name" DynamicType Executable|Forgotten Failed|Success First|Null [ LabelFather]"
|
||||
// First/Null : has/has not child
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd_TreeBrowser::OpenNode (const Handle(TDataStd_TreeNode)& aTreeNode,
|
||||
TCollection_AsciiString& aList) const
|
||||
{
|
||||
// Label entry. -0
|
||||
TCollection_AsciiString tmp;
|
||||
TDF_Tool::Entry(aTreeNode->Label(),tmp);
|
||||
aList.AssignCat(tmp);
|
||||
// Name -1
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
Handle(TDataStd_Name) name;
|
||||
aList.AssignCat("\"");
|
||||
if (aTreeNode->Label().FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
TCollection_AsciiString tmpStr(name->Get(),'?');
|
||||
tmpStr.ChangeAll(' ','_');
|
||||
aList.AssignCat(tmpStr);
|
||||
}
|
||||
aList.AssignCat("\"");
|
||||
// Dynamic type. -2
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
TCollection_ExtendedString ext;
|
||||
if (TDF::ProgIDFromGUID(aTreeNode->ID(), ext))
|
||||
aList.AssignCat(TCollection_AsciiString(ext,'?'));
|
||||
else aList.AssignCat(aTreeNode->DynamicType()->Name());
|
||||
// Executable or Forgotten? -3
|
||||
// aList.AssignCat(TDF_BrowserSeparator2);
|
||||
// if (aTreeNode->IsExecutable()) aList.AssignCat("Executable");
|
||||
// else aList.AssignCat("Forgotten");
|
||||
// Failed or Success? -4
|
||||
// aList.AssignCat(TDF_BrowserSeparator2);
|
||||
// if (aTreeNode->Failed()) aList.AssignCat("Failed");
|
||||
// else aList.AssignCat("Success");
|
||||
//Children? -3
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
if (aTreeNode->First().IsNull()) aList.AssignCat("Null");
|
||||
else aList.AssignCat("First");
|
||||
// Father? -4
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!aTreeNode->HasFather()) aList.AssignCat("Null");
|
||||
else {
|
||||
TDF_Tool::Entry(aTreeNode->Father()->Label(),tmp);
|
||||
aList.AssignCat(tmp);
|
||||
}
|
||||
// First? -5
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!aTreeNode->HasFirst()) aList.AssignCat("Null");
|
||||
else {
|
||||
TDF_Tool::Entry(aTreeNode->First()->Label(),tmp);
|
||||
aList.AssignCat(tmp);
|
||||
}
|
||||
// Next? -6
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!aTreeNode->HasNext()) aList.AssignCat("Null");
|
||||
else {
|
||||
TDF_Tool::Entry(aTreeNode->Next()->Label(),tmp);
|
||||
aList.AssignCat(tmp);
|
||||
}
|
||||
// Previous? -7
|
||||
aList.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!aTreeNode->HasPrevious()) aList.AssignCat("Null");
|
||||
else {
|
||||
TDF_Tool::Entry(aTreeNode->Previous()->Label(),tmp);
|
||||
aList.AssignCat(tmp);
|
||||
}
|
||||
}
|
413
src/DDataStd/DDataStd_TreeBrowser.tcl
Executable file
413
src/DDataStd/DDataStd_TreeBrowser.tcl
Executable file
@@ -0,0 +1,413 @@
|
||||
###########################
|
||||
# #
|
||||
# Version 1.0 #
|
||||
# by FID #
|
||||
# #
|
||||
###########################
|
||||
#
|
||||
# Open : double-clic or +
|
||||
# Close : double-clic or -
|
||||
# Refresh tree : close top level and re-open
|
||||
#
|
||||
# Attributes:
|
||||
# white : interoperable
|
||||
# white + c : non interoperable
|
||||
# X : X Reference
|
||||
# Red : not yet commited in transaction #0
|
||||
#
|
||||
#
|
||||
|
||||
proc __update { args } {
|
||||
}
|
||||
|
||||
global TreeBrowser
|
||||
|
||||
proc treebrowser { TreeBrowser } {
|
||||
|
||||
global TREE_WINDOWS
|
||||
global TREE_LabelStyle
|
||||
global TREE_LabelStyle1
|
||||
global TREE_AttributeStyle
|
||||
global TREE_AttributeStyle1
|
||||
global TREE_AttributeStyle2
|
||||
|
||||
global $TreeBrowser
|
||||
|
||||
package require Tix
|
||||
tixPref:InitFontSet:14Point
|
||||
|
||||
set TREE_LabelStyle [tixDisplayStyle imagetext \
|
||||
-font 9x15bold \
|
||||
-background Bisque3 \
|
||||
]
|
||||
|
||||
set TREE_LabelStyle1 [tixDisplayStyle imagetext \
|
||||
-font 9x15bold \
|
||||
-background Bisque3 \
|
||||
-foreground SeaGreen2 \
|
||||
]
|
||||
|
||||
set TREE_AttributeStyle [tixDisplayStyle imagetext \
|
||||
-font 9x15 \
|
||||
-background Bisque3 \
|
||||
]
|
||||
|
||||
set TREE_AttributeStyle1 [tixDisplayStyle imagetext \
|
||||
-font 9x15 \
|
||||
-background Bisque3 \
|
||||
-foreground Green \
|
||||
]
|
||||
|
||||
set TREE_AttributeStyle2 [tixDisplayStyle imagetext \
|
||||
-font 9x15 \
|
||||
-background Bisque3 \
|
||||
-foreground Red \
|
||||
]
|
||||
|
||||
set w .$TreeBrowser
|
||||
toplevel $w
|
||||
|
||||
set top [frame $w.thu -bd 1 -relief raised -background Bisque3]
|
||||
|
||||
################
|
||||
# Paned Window #
|
||||
################
|
||||
set p [tixPanedWindow $top.p -orient horizontal -height 400 -width 700]
|
||||
pack $p -expand yes -fill both -padx 4 -pady 4
|
||||
|
||||
TREE:Tree:InitTreePanel $TreeBrowser $w $p
|
||||
#TREE:Tree:InitTextPanel $TreeBrowser $w $p
|
||||
|
||||
tixForm $top -left 2 -top 2 -right %99 -bottom %99
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:InitTreePanel { TreeBrowser w p } {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
|
||||
########
|
||||
# Tree #
|
||||
########
|
||||
|
||||
set p1 [$p add pane1 -expand 1 -size 700] ; $p1 config -relief flat
|
||||
set tree [tixTree $p1.tree \
|
||||
-opencmd [list TREE:Tree:Open $TreeBrowser $w] \
|
||||
-options { \
|
||||
hlist.separator "^" \
|
||||
hlist.font 9x15bold \
|
||||
hlist.background Bisque3 \
|
||||
hlist.foreground Black \
|
||||
} ]
|
||||
pack $p1.tree -expand yes -fill both -padx 4 -pady 4
|
||||
|
||||
# -browsecmd TREE:Tree:BrowseCmd
|
||||
# Cette option peut etre ajoutee a la commande tixTree,
|
||||
# mais elle declanche l'appel a la procedure a chaque clic ,
|
||||
# double-clic, voire a chaque appui puis relachement de souris!!!
|
||||
|
||||
# to see different fonts: /usr/openwin/lib/X11/fonts/misc or xlsfonts?
|
||||
# 8x13 8x13bold 9x15 9x15bold
|
||||
# hlist.font 8x13bold
|
||||
# hlist.gap "15"
|
||||
# hlist.indent "30"
|
||||
|
||||
set TREE_WINDOWS($w,NAV,tree) $tree
|
||||
set TREE_WINDOWS($w,NAV,hlist) [$tree subwidget hlist]
|
||||
$TREE_WINDOWS($w,NAV,hlist) add ^ \
|
||||
-text $TreeBrowser \
|
||||
-data [list $TreeBrowser Root]
|
||||
$TREE_WINDOWS($w,NAV,tree) setmode ^ open
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:InitTextPanel { TreeBrowser w p } {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
|
||||
########
|
||||
# Text #
|
||||
########
|
||||
set p2 [$p add pane2 -expand 4 -size 400] ; $p2 config -relief flat
|
||||
tixScrolledText $p2.st
|
||||
pack $p2.st -expand yes -fill both -padx 4 -pady 4
|
||||
|
||||
set TREE_WINDOWS($w,NAV,text) [$p2.st subwidget text]
|
||||
|
||||
|
||||
|
||||
$TREE_WINDOWS($w,NAV,text) insert end " Welcome to the QDF browser (Rev #.#)\n"
|
||||
$TREE_WINDOWS($w,NAV,text) insert end "--------------------------------------\n\n"
|
||||
$TREE_WINDOWS($w,NAV,text) insert end "This browser is an easy to use prototype made with Tix technology. We hope it will be usefull for understanding and debugging QDF.\n"
|
||||
$TREE_WINDOWS($w,NAV,text) insert end "\t\t\t\tFID & YAN"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:BrowseCmd { dir } {
|
||||
puts "Hello $dir !"
|
||||
}
|
||||
###############################################################################
|
||||
# Se positionne sur l'entry pere et update les fenetres.
|
||||
#
|
||||
proc FCTREE:Tree:Up { w } {
|
||||
global TREE_WINDOWS
|
||||
global TREE_GLOBALS
|
||||
#puts "TREE:Tree:Up"
|
||||
|
||||
if { [set here [$TREE_WINDOWS($w,NAV,hlist) info anchor]] != {} } {
|
||||
if { [set up [$TREE_WINDOWS($w,NAV,hlist) info parent $here]] != {} } {
|
||||
TREE:Tree:ShowUp $w $up
|
||||
set TREE_GLOBALS(CWD) [lindex [$TREE_WINDOWS($w,NAV,hlist) info data $up] 0]
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
# Se positionne sur l'entry up sans update (History)
|
||||
#
|
||||
proc TREE:Tree:ShowUp { w dir } {
|
||||
global TREE_WINDOWS
|
||||
#puts "TREE:Tree:ShowUp"
|
||||
|
||||
$TREE_WINDOWS($w,NAV,hlist) anchor clear
|
||||
$TREE_WINDOWS($w,NAV,hlist) anchor set $dir
|
||||
$TREE_WINDOWS($w,NAV,hlist) selection clear
|
||||
$TREE_WINDOWS($w,NAV,hlist) selection set $dir
|
||||
$TREE_WINDOWS($w,NAV,hlist) see $dir
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:Open { TreeBrowser w dir} {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
#puts "TREE:Tree:Open"
|
||||
|
||||
if {$dir == "^"} {
|
||||
# This is root
|
||||
if {[$TREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} {
|
||||
# The root branch already exists in hlist.
|
||||
# Clear all its children to force the tree to be updated.
|
||||
foreach kid [$TREE_WINDOWS($w,NAV,hlist) info children $dir] {
|
||||
$TREE_WINDOWS($w,NAV,hlist) delete entry $kid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if {[$TREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} {
|
||||
# The branch exists in hlist.
|
||||
foreach kid [$TREE_WINDOWS($w,NAV,hlist) info children $dir] {
|
||||
$TREE_WINDOWS($w,NAV,hlist) show entry $kid
|
||||
}
|
||||
set data [$TREE_WINDOWS($w,NAV,hlist) info data $dir]
|
||||
#set loc [lindex $data 0]
|
||||
} else {
|
||||
# The branch is unknown.
|
||||
tixBusy $w on
|
||||
update
|
||||
TREE:Tree:Fill $TreeBrowser $w $dir
|
||||
tixBusy $w off
|
||||
}
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:Fill { TreeBrowser w dir } {
|
||||
global TREE_WINDOWS
|
||||
global TREE_GLOBALS
|
||||
global $TreeBrowser
|
||||
#puts "TREE:Tree:Fill"
|
||||
|
||||
set data [$TREE_WINDOWS($w,NAV,hlist) info data $dir]
|
||||
#set loc [lindex $data 0]
|
||||
set type [lindex $data 1]
|
||||
|
||||
#puts "====================="
|
||||
#puts "Type $type"
|
||||
#puts "Window $w"
|
||||
#puts "Loc $loc"
|
||||
#puts "Dir $dir"
|
||||
#puts "====================="
|
||||
|
||||
switch -glob $type {
|
||||
|
||||
Root {
|
||||
TREE:Tree:UpdateRoot $TreeBrowser $w $dir
|
||||
}
|
||||
|
||||
Node {
|
||||
set lab [lindex $data 0]
|
||||
TREE:Tree:UpdateNode $TreeBrowser $w $dir $lab
|
||||
}
|
||||
|
||||
terminal {
|
||||
TREE:Tree:terminal $TreeBrowser $w $dir
|
||||
}
|
||||
|
||||
default {
|
||||
puts "type non reconnu"
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
# ici dir = ^
|
||||
#
|
||||
proc TREE:Tree:UpdateRoot { TreeBrowser w dir } {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
global TREE_AttributeStyle
|
||||
global TREE_AttributeStyle1
|
||||
#puts "TREE:Tree:UpdateRoot"
|
||||
|
||||
foreach nodeItem [split [OpenNode $TreeBrowser ""] "\\" ] {
|
||||
|
||||
TREE:Tree:DecodeNodeItem $TreeBrowser $w $dir $nodeItem
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:UpdateNode { TreeBrowser w dir lab} {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
global TREE_AttributeStyle
|
||||
global TREE_AttributeStyle1
|
||||
#puts "TREE:Tree:UpdateNode"
|
||||
|
||||
foreach nodeItem [split [OpenNode $TreeBrowser $lab ] "\\" ] {
|
||||
|
||||
TREE:Tree:DecodeNodeItem $TreeBrowser $w $dir $nodeItem
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
# item:
|
||||
# "LabelEntry "Name" DynamicType Executable|Forgotten Failed|Success First|Null [ LabelFather]"
|
||||
proc TREE:Tree:DecodeNodeItem { TreeBrowser w dir nodeItem} {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
global TREE_AttributeStyle
|
||||
global TREE_AttributeStyle1
|
||||
global TREE_AttributeStyle2
|
||||
#puts "TREE:Tree:DecodeNodeItem"
|
||||
|
||||
set litm {}
|
||||
set standardimage [tix getimage file]
|
||||
set forgottenimage [tix getimage maximize]
|
||||
set image $standardimage
|
||||
|
||||
# Information first split
|
||||
set tmplist [split $nodeItem " "]
|
||||
set labentry [lindex $tmplist 0]
|
||||
set name [lindex $tmplist 1]
|
||||
set type [lindex $tmplist 2]
|
||||
#set exec [lindex $tmplist 3]
|
||||
#set state [lindex $tmplist 4]
|
||||
set children [lindex $tmplist 3]
|
||||
set father [lindex $tmplist 4]
|
||||
set first [lindex $tmplist 5]
|
||||
set next [lindex $tmplist 6]
|
||||
set previous [lindex $tmplist 7]
|
||||
|
||||
#puts "labentry : $labentry"
|
||||
#puts "name : $name"
|
||||
#puts "type : $type"
|
||||
#puts "state : $state"
|
||||
#puts "exec : $exec"
|
||||
#puts "children : $children"
|
||||
#puts "father : $father"
|
||||
#puts "first : $first"
|
||||
#puts "next : $next"
|
||||
#puts "previous : $previous"
|
||||
|
||||
# Label entry , name & Dynamic type.
|
||||
set ll [expr [string length $name] -2]
|
||||
if {$ll > 0} {
|
||||
set textname "$labentry [string range $name 1 $ll] $type"
|
||||
} else {
|
||||
set textname "$labentry $type"
|
||||
}
|
||||
|
||||
set locstyle $TREE_AttributeStyle
|
||||
|
||||
# Executable/Forgotten?
|
||||
#if {$exec == "Forgotten"} {
|
||||
#set textname "$textname $exec"
|
||||
#set locstyle $TREE_AttributeStyle1
|
||||
#set image $forgottenimage
|
||||
#}
|
||||
|
||||
# Failed/Success analysis.
|
||||
#if {$state == "Failed"} {
|
||||
#set textname "$textname $state"
|
||||
#set locstyle $TREE_AttributeStyle2
|
||||
#}
|
||||
|
||||
# Father?
|
||||
if {$father != "Null"} {set textname "$textname Father=$father"}
|
||||
# First?
|
||||
if {$first != "Null"} {set textname "$textname First=$first"}
|
||||
# Next?
|
||||
if {$next != "Null"} {set textname "$textname Next=$next"}
|
||||
# Previous?
|
||||
if {$previous != "Null"} {set textname "$textname Previous=$previous"}
|
||||
|
||||
$TREE_WINDOWS($w,NAV,hlist) add ${dir}^${labentry} \
|
||||
-itemtype imagetext \
|
||||
-text $textname \
|
||||
-image $image \
|
||||
-style $locstyle \
|
||||
-data [list ${labentry} Node]
|
||||
if {$children == "First"} {
|
||||
$TREE_WINDOWS($w,NAV,tree) setmode ${dir}^${labentry} open
|
||||
}
|
||||
lappend litm [list $labentry $image]
|
||||
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:terminal { TreeBrowser w dir } {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
proc TREE:Tree:DisplayAttribute { TreeBrowser w dir } {
|
||||
global TREE_WINDOWS
|
||||
global $TreeBrowser
|
||||
|
||||
return
|
||||
}
|
||||
###############################################################################
|
||||
# imprime tout ce qu'il y a dans hli ( Hlist )
|
||||
#
|
||||
proc wokDBG { {root {}} } {
|
||||
global TREE_GLOBALS
|
||||
global TREE_WINDOWS
|
||||
set w $TREE_GLOBALS(toplevel)
|
||||
set hli $TREE_WINDOWS($w,NAV,hlist)
|
||||
foreach c [$hli info children $root] {
|
||||
puts "$c : data <[$hli info data $c]>"
|
||||
wokDBG $c
|
||||
}
|
||||
return
|
||||
}
|
591
src/DDataStd/DDataStd_TreeCommands.cxx
Executable file
591
src/DDataStd/DDataStd_TreeCommands.cxx
Executable file
@@ -0,0 +1,591 @@
|
||||
// File: DDataStd_TreeCommands.cxx
|
||||
// Created: Fri Nov 5 11:32:51 1999
|
||||
// Author: Denis PASCAL
|
||||
// <dp@dingox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DDataStd.ixx>
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
#include <DDataStd_TreeBrowser.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataStd_ChildNodeIterator.hxx>
|
||||
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : SetNode
|
||||
//purpose : SetNode (DOC Entry [ID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetNode (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
Handle(TDataStd_TreeNode) TN;
|
||||
DDF::AddLabel(DF,a[2],L);
|
||||
if (n == 3) {
|
||||
TN = TDataStd_TreeNode::Set(L);
|
||||
DDF::ReturnLabel(di,TN->Label());
|
||||
return 0;
|
||||
} else if (n == 4) {
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[3])) {
|
||||
di<<"DDataStd_SetNode: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID ID(a[3]);
|
||||
TN = TDataStd_TreeNode::Set(L, ID);
|
||||
DDF::ReturnLabel(di,TN->Label());
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetNode : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : AppendNode
|
||||
//purpose : AppendNode (DOC FatherEntry childEntry [fatherID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_AppendNode (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF))return 1;
|
||||
Handle(TDataStd_TreeNode) father, child;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==4)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[4])) {
|
||||
di<<"DDataStd_AppendNode: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[4]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,a[2],ID,father)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF,a[3],L);
|
||||
if ( (L.FindAttribute(ID,child))
|
||||
&&(!child->IsRoot()) ){
|
||||
di << "DDataStd_AppendNode : Error : childTreeNode don't detach" << "\n";
|
||||
return 1;
|
||||
}
|
||||
child = TDataStd_TreeNode::Set(L,ID);
|
||||
if (!father->Append(child)) return 1;
|
||||
#ifdef DEB
|
||||
di<<"AppendNode: OK"<<"\n";
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_AppendNode : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : PrependNode
|
||||
//purpose : PrependNode (DOC FatherEntry childEntry [fatherID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_PrependNode (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF))return 1;
|
||||
Handle(TDataStd_TreeNode) father, child;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==4)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[4])) {
|
||||
di<<"DDataStd_PrependNode: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[4]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,a[2],ID,father)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF,a[3],L);
|
||||
if ( (L.FindAttribute(ID,child))
|
||||
&&(!child->IsRoot()) ){
|
||||
di << "DDataStd_PrependNode : Error : childTreeNode don't detach" << "\n";
|
||||
return 1;
|
||||
}
|
||||
child = TDataStd_TreeNode::Set(L,ID);
|
||||
if (!father->Prepend(child)) return 1;
|
||||
#ifdef DEB
|
||||
di<<"PrependNode: OK"<<"\n";
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_PrependNode : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : RootNode
|
||||
//purpose : RootNode (DOC TreeNodeEntry [ID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_RootNode (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
Handle(TDataStd_TreeNode) TN;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==3)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[3])) {
|
||||
di<<"DDataStd_RootNode: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[3]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,a[2],ID,TN)) return 1;
|
||||
DDF::ReturnLabel(di,TN->Root()->Label());
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_RootNode : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : InsertNodeBefore
|
||||
//purpose : InsertNodeBefore (DOC TreeNodeEntry TreeNodeWhichHasToBeBefore [ID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_InsertNodeBefore(Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
Handle(TDataStd_TreeNode) current, TN;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==4)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[4])) {
|
||||
di<<"DDataStd_InsertNodeBefore: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[4]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,a[2],ID,current)) return 1;
|
||||
// if (!DDF::Find(DF,a[3],ID,TN)) return 1;
|
||||
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,a[3],L)) return 1;
|
||||
TN = TDataStd_TreeNode::Set(L,ID);
|
||||
if (!current->InsertBefore(TN)) return 1;
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_InsertBefore : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : InsertNodeAfter
|
||||
//purpose : InsertNodeAfter (DOC TreeNodeEntry TreeNodeWhichHasToBeAfter [ID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_InsertNodeAfter(Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
Handle(TDataStd_TreeNode) current, TN;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==4)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[4])) {
|
||||
di<<"DDataStd_InsertNodeAfter: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[4]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,a[2],ID,current)) return 1;
|
||||
//if (!DDF::Find(DF,a[3],TDataStd_TreeNode::GetDefaultTreeID(),TN)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,a[3],L)) return 1;
|
||||
TN = TDataStd_TreeNode::Set(L);
|
||||
if (!current->InsertAfter(TN)) return 1;
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_InsertNodeAfter : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : DetachNode
|
||||
//purpose : DetachNode (DOC TreeNodeEntry [ID])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_DetachNode (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n >= 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
Handle(TDataStd_TreeNode) TN;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==3)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[3])) {
|
||||
di<<"DDataStd_DetachNode: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[3]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,a[2],ID,TN)) return 1;
|
||||
if (!TN->Remove())
|
||||
di << "Can't Detach the TreeNode" << "\n";
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_DetachNode : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TreeBrowse
|
||||
//purpose :
|
||||
// arg 1 : DF name
|
||||
// arg 2 : Entry
|
||||
// [arg 3] : Browser name
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_TreeBrowse (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n<3) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (a[1], DF)) return 1;
|
||||
|
||||
TDF_Label lab;
|
||||
TDF_Tool::Label(DF,a[2],lab);
|
||||
|
||||
Handle(DDataStd_TreeBrowser) NewTreeNode = new DDataStd_TreeBrowser (lab);
|
||||
char *name = new char[50];
|
||||
if (n == 4) sprintf(name,"treebrowser_%s",a[3]);
|
||||
else sprintf(name,"treebrowser_%s",a[1]);
|
||||
|
||||
Draw::Set(name, NewTreeNode);
|
||||
TCollection_AsciiString inst1("treebrowser ");
|
||||
inst1.AssignCat(name);
|
||||
di.Eval(inst1.ToCString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenNode
|
||||
//purpose :
|
||||
// arg 1 : Browser name
|
||||
// [arg 2] : Label entry
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_OpenNode (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(DDataStd_TreeBrowser) browser =
|
||||
Handle(DDataStd_TreeBrowser)::DownCast (Draw::Get(a[1], Standard_True));
|
||||
|
||||
TDF_Label lab;
|
||||
if (n == 3) TDF_Tool::Label(browser->Label().Data(),a[2],lab);
|
||||
|
||||
if (n == 2 || lab.IsNull()) {
|
||||
TCollection_AsciiString list = browser->OpenRoot();
|
||||
di<<list.ToCString();
|
||||
}
|
||||
else {
|
||||
TCollection_AsciiString list = browser->OpenNode(lab);
|
||||
di<<list.ToCString();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : ChildNodeIterate
|
||||
//purpose : ChildNodeIterate Doc TreeNode AllLevels [ID]
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_ChildNodeIterate (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
const Standard_Boolean AllLevels(atoi(a[3]));
|
||||
Handle(TDataStd_TreeNode) TN, Value;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==4)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[4])) {
|
||||
di<<"DDataStd_ChildNodeIterate: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[4]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF, a[2], ID, TN)) return 1;
|
||||
//di<<"TDataStd_ChildNodeIterator: "<<"\n";
|
||||
TDataStd_ChildNodeIterator itr(TN, AllLevels);
|
||||
for (; itr.More(); itr.Next()) {
|
||||
Value = itr.Value();
|
||||
TCollection_AsciiString entry;
|
||||
TDF_Tool::Entry(Value->Label(), entry);
|
||||
di<<entry<<"\n";
|
||||
//di<<entry;
|
||||
//if(itr.More()==Standard_True)
|
||||
//di<<" ";
|
||||
}
|
||||
di<<"\n";
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_ChildNodeIterate : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
static TDataStd_ChildNodeIterator cni;
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : InitChildNodeIterator
|
||||
//purpose : InitChildNodeIterator Doc TreeNode AllLevels [ID]
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_InitChildNodeIterator (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(a[1],DF)) return 1;
|
||||
Handle(TDataStd_TreeNode) TN, Value;
|
||||
|
||||
Standard_GUID ID;
|
||||
if (n==4)
|
||||
ID=Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID());
|
||||
else{
|
||||
if (!Standard_GUID::CheckGUIDFormat(a[4])) {
|
||||
di<<"DDataStd_ChildNodeIterator: The format of GUID is invalid"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_GUID varID(a[4]);
|
||||
ID=varID;
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF, a[2], ID, TN)) return 1;
|
||||
const Standard_Boolean AllLevels(atoi(a[3]));
|
||||
cni.Initialize(TN, AllLevels);
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_InitChildNodeIterator : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : ChildNodeMore
|
||||
//purpose : ChildNodeMore
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_ChildNodeMore (Draw_Interpretor& di,
|
||||
Standard_Integer /*n*/,
|
||||
const char** /*a*/)
|
||||
{
|
||||
if (cni.More()) {
|
||||
//cout<<"TRUE"<<endl;
|
||||
di<<"TRUE"<<"\n";
|
||||
}
|
||||
else {
|
||||
//cout<<"FALSE"<<endl;
|
||||
di<<"FALSE"<<"\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : ChildNodeNext
|
||||
//purpose : ChildNodeNext
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_ChildNodeNext (Draw_Interpretor& /*di*/,
|
||||
Standard_Integer /*n*/,
|
||||
const char** /*a*/)
|
||||
{
|
||||
cni.Next();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : ChildNodeNextBrother
|
||||
//purpose : ChildNodeNext Brother
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_ChildNodeNextBrother (Draw_Interpretor& /*di*/,
|
||||
Standard_Integer /*n*/,
|
||||
const char** /*a*/)
|
||||
{
|
||||
cni.NextBrother();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : ChildNodeValue
|
||||
//purpose : ChildNodeValue
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_ChildNodeValue (Draw_Interpretor& di,
|
||||
Standard_Integer /*n*/,
|
||||
const char** /*a*/)
|
||||
{
|
||||
TCollection_AsciiString entry;
|
||||
TDF_Tool::Entry(cni.Value()->Label(), entry);
|
||||
//cout<<entry<<endl;
|
||||
di <<entry<<"\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//TreeNode : TreeCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDataStd::TreeCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "DData : Standard Attribute Commands";
|
||||
|
||||
// SET
|
||||
|
||||
theCommands.Add ("SetNode",
|
||||
"SetNode (DOC Entry [GUID])",
|
||||
__FILE__, DDataStd_SetNode, g);
|
||||
|
||||
// EDIT
|
||||
|
||||
theCommands.Add ("AppendNode",
|
||||
"AppendNode (DOC FatherEntry childEntry [fatherGUID])",
|
||||
__FILE__, DDataStd_AppendNode, g);
|
||||
|
||||
theCommands.Add ("PrependNode",
|
||||
"PrependNode (DOC FatherEntry childEntry [fatherGUID])",
|
||||
__FILE__, DDataStd_PrependNode, g);
|
||||
|
||||
theCommands.Add ("InsertNodeBefore",
|
||||
"InsertNodeBefore (DOC TreeNodeEntry TreeNodeWhichHasToBeBefore [GUID])",
|
||||
__FILE__, DDataStd_InsertNodeBefore, g);
|
||||
|
||||
theCommands.Add ("InsertNodeAfter",
|
||||
"InsertNodeAfter (DOC TreeNodeEntry TreeNodeWhichHasToBeAfter [GUID])",
|
||||
__FILE__, DDataStd_InsertNodeAfter, g);
|
||||
|
||||
theCommands.Add ("DetachNode",
|
||||
"DetachNode (DOC TreeNodeEntry [GUID])",
|
||||
__FILE__, DDataStd_DetachNode, g);
|
||||
|
||||
theCommands.Add ("RootNode",
|
||||
"RootNode (DOC TreeNodeEntry [GUID])",
|
||||
__FILE__, DDataStd_RootNode, g);
|
||||
|
||||
|
||||
// TREE BROWSER
|
||||
|
||||
theCommands.Add ("TreeBrowse",
|
||||
"TreeBrowse dfname entry [browsername]",
|
||||
__FILE__, DDataStd_TreeBrowse, g);
|
||||
|
||||
theCommands.Add ("OpenNode",
|
||||
"PRIVATE COMMAND FOR TREE BROWSER!\nReturns the list of sub-TreeNodes : OpenTreeNode browsername [entry]",
|
||||
__FILE__, DDataStd_OpenNode, g);
|
||||
|
||||
|
||||
|
||||
// TREE ITERATOR
|
||||
|
||||
theCommands.Add ("ChildNodeIterate",
|
||||
"ChildNodeIterate Doc TreeNode AllLevels [GUID]",
|
||||
__FILE__, DDataStd_ChildNodeIterate, g);
|
||||
|
||||
theCommands.Add ("InitChildNodeIterator",
|
||||
"InitChildNodeIterator Doc TreeNode AllLevels [GUID]",
|
||||
__FILE__, DDataStd_InitChildNodeIterator, g);
|
||||
|
||||
theCommands.Add ("ChildNodeMore",
|
||||
"ChildNodeMore",
|
||||
__FILE__, DDataStd_ChildNodeMore, g);
|
||||
|
||||
theCommands.Add ("ChildNodeNext",
|
||||
"ChildNodeNext",
|
||||
__FILE__, DDataStd_ChildNodeNext, g);
|
||||
|
||||
theCommands.Add ("ChildNodeNextBrother",
|
||||
"ChildNodeNextBrother",
|
||||
__FILE__, DDataStd_ChildNodeNextBrother, g);
|
||||
|
||||
theCommands.Add ("ChildNodeValue",
|
||||
"ChildNodeValue",
|
||||
__FILE__, DDataStd_ChildNodeValue, g);
|
||||
|
||||
}
|
1
src/DDataStd/EXTERNLIB
Executable file
1
src/DDataStd/EXTERNLIB
Executable file
@@ -0,0 +1 @@
|
||||
TKDraw
|
11
src/DDataStd/FILES
Executable file
11
src/DDataStd/FILES
Executable file
@@ -0,0 +1,11 @@
|
||||
EXTERNLIB
|
||||
DDataStd_TreeBrowser.tcl
|
||||
DDataStd_TreeCommands.cxx
|
||||
DDataStd_NamedShapeCommands.cxx
|
||||
DDataStd_BasicCommands.cxx
|
||||
DDataStd_DatumCommands.cxx
|
||||
DDataStd_ConstraintCommands.cxx
|
||||
DDataStd_DrawDisplayCommands.cxx
|
||||
DDataStd_ObjectCommands.cxx
|
||||
DDataStd_NameCommands.cxx
|
||||
DDataStd_Sample.cxx
|
Reference in New Issue
Block a user