1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Semantic name Get/Set functions added to XCAFDimTolObjects_*Object classes. Added XGetGDTSemanticName/XSetGDTSemanticName draw commands.

This commit is contained in:
snn
2018-02-26 15:16:18 +03:00
parent a7f965ccb8
commit 93cfd787c4
11 changed files with 265 additions and 19 deletions

View File

@@ -2720,21 +2720,27 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
{
return aGDTL;
}
Handle(TCollection_HAsciiString) aSemanticName;
// protection against invalid input
if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
Handle(StepDimTol_GeometricTolerance) aGeomTol = Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
if (aGeomTol->TolerancedShapeAspect().IsNull())
return aGDTL;
aSemanticName = aGeomTol->Name();
}
if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
Handle(StepShape_DimensionalSize) aDim = Handle(StepShape_DimensionalSize)::DownCast(theEnt);
if (aDim->AppliesTo().IsNull())
return aGDTL;
aSemanticName = aDim->Name();
}
if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
Handle(StepShape_DimensionalLocation) aDim = Handle(StepShape_DimensionalLocation)::DownCast(theEnt);
if (aDim->RelatedShapeAspect().IsNull() || aDim->RelatingShapeAspect().IsNull())
return aGDTL;
aSemanticName = aDim->Name();
}
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
@@ -3139,6 +3145,13 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Over);
aGTol->SetObject(anObj);
}
if (aSemanticName)
{
TCollection_ExtendedString str(aSemanticName->String());
TDataStd_Name::Set(aGDTL, str);
}
readDatumsAP242(theEnt, aGDTL, theDoc, theWS);
}
return aGDTL;

View File

@@ -52,6 +52,27 @@ XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject(const Handle(XCAFDi
myHasPlane = theObj->myHasPlane;
myHasPnt = theObj->myHasPnt;
myHasPntText = theObj->myHasPntText;
mySemanticName = theObj->mySemanticName;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) XCAFDimTolObjects_DatumObject::GetSemanticName() const
{
return mySemanticName;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_DatumObject::SetSemanticName(const Handle(TCollection_HAsciiString)& theName)
{
mySemanticName = theName;
}
//=======================================================================

View File

@@ -44,7 +44,13 @@ public:
Standard_EXPORT XCAFDimTolObjects_DatumObject();
Standard_EXPORT XCAFDimTolObjects_DatumObject(const Handle(XCAFDimTolObjects_DatumObject)& theObj);
//! Returns semantic name
Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
//! Sets semantic name
Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
Standard_EXPORT Handle(TCollection_HAsciiString) GetName() const;
Standard_EXPORT void SetName (const Handle(TCollection_HAsciiString)& theTag);
@@ -181,7 +187,8 @@ private:
Standard_Boolean myHasPnt;
Standard_Boolean myHasPntText;
TopoDS_Shape myPresentation;
Handle(TCollection_HAsciiString) myPresentationName;
Handle(TCollection_HAsciiString) mySemanticName;
Handle(TCollection_HAsciiString) myPresentationName;
};
#endif // _XCAFDimTolObjects_DatumObject_HeaderFile

View File

@@ -57,6 +57,27 @@ XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject(const Handl
myHasPlane = theObj->myHasPlane;
myPlane = theObj->myPlane;
myHasPntText = theObj->myHasPntText;
mySemanticName = theObj->mySemanticName;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) XCAFDimTolObjects_DimensionObject::GetSemanticName() const
{
return mySemanticName;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_DimensionObject::SetSemanticName(const Handle(TCollection_HAsciiString)& theName)
{
mySemanticName = theName;
}
//=======================================================================

View File

@@ -54,6 +54,12 @@ public:
Standard_EXPORT XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj);
//! Returns semantic name
Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
//! Sets semantic name
Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
Standard_EXPORT void SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier);
Standard_EXPORT XCAFDimTolObjects_DimensionQualifier GetQualifier() const;
@@ -186,7 +192,7 @@ public:
return myPresentation;
}
//! Returns graphical presentation of the object
//! Returns graphical presentation of the object
Standard_EXPORT Handle(TCollection_HAsciiString) GetPresentationName() const
{
return myPresentationName;
@@ -252,6 +258,7 @@ private:
Standard_Boolean myHasPntText;
gp_Pnt myPntText;
TopoDS_Shape myPresentation;
Handle(TCollection_HAsciiString) mySemanticName;
Handle(TCollection_HAsciiString) myPresentationName;
NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptions;
NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptionNames;

View File

@@ -51,6 +51,27 @@ XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject(con
myHasPlane = theObj->myHasPlane;
myHasPnt = theObj->myHasPnt;
myHasPntText = theObj->myHasPntText;
mySemanticName = theObj->mySemanticName;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) XCAFDimTolObjects_GeomToleranceObject::GetSemanticName() const
{
return mySemanticName;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XCAFDimTolObjects_GeomToleranceObject::SetSemanticName(const Handle(TCollection_HAsciiString)& theName)
{
mySemanticName = theName;
}
//=======================================================================

View File

@@ -46,6 +46,12 @@ public:
Standard_EXPORT XCAFDimTolObjects_GeomToleranceObject(const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObj);
//! Returns semantic name
Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
//! Sets semantic name
Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
Standard_EXPORT void SetType (const XCAFDimTolObjects_GeomToleranceType theType);
Standard_EXPORT XCAFDimTolObjects_GeomToleranceType GetType() const;
@@ -163,14 +169,8 @@ private:
Standard_Boolean myHasPnt;
Standard_Boolean myHasPntText;
TopoDS_Shape myPresentation;
Handle(TCollection_HAsciiString) mySemanticName;
Handle(TCollection_HAsciiString) myPresentationName;
};
#endif // _XCAFDimTolObjects_GeomToleranceObject_HeaderFile

View File

@@ -172,6 +172,13 @@ Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetIdentification() const
void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theObject)
{
Backup();
if (theObject->GetSemanticName())
{
TCollection_ExtendedString str(theObject->GetSemanticName()->String());
TDataStd_Name::Set(Label(), str);
}
TDF_ChildIterator anIter(Label());
for(;anIter.More(); anIter.Next())
{
@@ -342,6 +349,16 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
{
Handle(XCAFDimTolObjects_DatumObject) anObj = new XCAFDimTolObjects_DatumObject();
Handle(TDataStd_Name) aSemanticNameAttr;
Handle(TCollection_HAsciiString) aSemanticName;
if (Label().FindAttribute(TDataStd_Name::GetID(), aSemanticNameAttr))
{
const TCollection_ExtendedString& aName = aSemanticNameAttr->Get();
if (!aName.IsEmpty())
aSemanticName = new TCollection_HAsciiString(aName);
}
anObj->SetSemanticName(aSemanticName);
Handle(TDataStd_AsciiString) anAttName;
if(Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
{

View File

@@ -100,7 +100,12 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
{
Backup();
//Label().ForForgetAllAttributes();
if (theObject->GetSemanticName())
{
TCollection_ExtendedString str(theObject->GetSemanticName()->String());
TDataStd_Name::Set(Label(), str);
}
TDF_ChildIterator anIter(Label());
for(;anIter.More(); anIter.Next())
{
@@ -282,6 +287,16 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject() const
{
Handle(XCAFDimTolObjects_DimensionObject) anObj = new XCAFDimTolObjects_DimensionObject();
Handle(TDataStd_Name) aSemanticNameAttr;
Handle(TCollection_HAsciiString) aSemanticName;
if (Label().FindAttribute(TDataStd_Name::GetID(), aSemanticNameAttr))
{
const TCollection_ExtendedString& aName = aSemanticNameAttr->Get();
if (!aName.IsEmpty())
aSemanticName = new TCollection_HAsciiString(aName);
}
anObj->SetSemanticName(aSemanticName);
Handle(TDataStd_Integer) aType;
if(Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
{
@@ -332,7 +347,6 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject() const
anObj->SetPath(TopoDS::Edge(aShape->Get()));
}
Handle(TDataStd_RealArray) aDir;
if(Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir)
&& !aDir->Array().IsNull() && aDir->Array()->Length() > 0)
@@ -378,21 +392,17 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject() const
TDF_Label aLPres = Label().FindChild( ChildLab_Presentation);
if ( aLPres.FindAttribute(TNaming_NamedShape::GetID(), aNS) )
{
TopoDS_Shape aPresentation = TNaming_Tool::GetShape(aNS);
if( !aPresentation.IsNull())
{
Handle(TDataStd_Name) aNameAtrr;
Handle(TCollection_HAsciiString) aPresentName;
if (aLPres.FindAttribute(TDataStd_Name::GetID(),aNameAtrr))
{
const TCollection_ExtendedString& aName = aNameAtrr->Get();
if( !aName.IsEmpty())
aPresentName = new TCollection_HAsciiString(aName);
}
anObj->SetPresentation(aPresentation, aPresentName);
}
}

View File

@@ -97,7 +97,12 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
{
Backup();
//Label().ForForgetAllAttributes();
if (theObject->GetSemanticName())
{
TCollection_ExtendedString str(theObject->GetSemanticName()->String());
TDataStd_Name::Set(Label(), str);
}
TDF_ChildIterator anIter(Label());
for(;anIter.More(); anIter.Next())
{
@@ -244,6 +249,16 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
{
Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = new XCAFDimTolObjects_GeomToleranceObject();
Handle(TDataStd_Name) aSemanticNameAttr;
Handle(TCollection_HAsciiString) aSemanticName;
if (Label().FindAttribute(TDataStd_Name::GetID(), aSemanticNameAttr))
{
const TCollection_ExtendedString& aName = aSemanticNameAttr->Get();
if (!aName.IsEmpty())
aSemanticName = new TCollection_HAsciiString(aName);
}
anObj->SetSemanticName(aSemanticName);
Handle(TDataStd_Integer) aType;
if(Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
{

View File

@@ -137,6 +137,10 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
if (argc > 3)
{
di <<" (";
if (aDimTolObj->GetSemanticName())
{
di << " N \"" << aDimTolObj->GetSemanticName()->String() << "\"";
}
di << " T " << aDimTolObj->GetType();
if(aDimTolObj->IsDimWithRange())
{
@@ -207,6 +211,10 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
if (argc > 3)
{
di <<" (";
if (aDimTolObj->GetSemanticName())
{
di << " N \"" << aDimTolObj->GetSemanticName()->String() << "\"";
}
di << " T " << aDimTolObj->GetType();
di << " TV " << aDimTolObj->GetTypeOfValue();
di << ", V " << aDimTolObj->GetValue();
@@ -244,7 +252,6 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
di << " ZMV " <<aDimTolObj->GetValueOfZoneModifier();
}
}
di << " )";
}
Handle(XCAFDoc_GraphNode) aNode;
@@ -262,7 +269,11 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
di << " Datum."<< i << "."<< j << "."<< k;
if (argc > 3)
{
di <<" (";
di << " (";
if (aDimTolObj->GetSemanticName())
{
di << " N \"" << aDimTolObj->GetSemanticName()->String() << "\"";
}
XCAFDimTolObjects_DatumModifiersSequence aModif =
aDatumObj->GetModifiers();
if (!aModif.IsEmpty())
@@ -313,6 +324,10 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
if (argc > 3)
{
di <<" (";
if (aDatumObj->GetSemanticName())
{
di << " N \"" << aDatumObj->GetSemanticName()->String() << "\"";
}
di << " T " << aDatumObj->GetDatumTargetType();
if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Area)
{
@@ -2506,6 +2521,97 @@ static Standard_Integer getGDTPresentation (Draw_Interpretor& di, Standard_Integ
return 0;
}
static Standard_Integer getGDTSemanticName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) {
di << "Use: XGetGDTSemanticName Doc GDT_Label\n";
return 1;
}
Handle(TDocStd_Document) Doc;
DDocStd::GetDocument(argv[1], Doc);
if (Doc.IsNull()) { di << argv[1] << " is not a document\n"; return 1; }
TDF_Label aLabel;
TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
if (aLabel.IsNull())
{
di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
return 1;
}
Handle(TCollection_HAsciiString) aSemanticName;
// Dimension
Handle(XCAFDoc_Dimension) aDimension;
if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
{
Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
aSemanticName = anObj->GetSemanticName();
}
// Geometric Tolerance
Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
{
Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
aSemanticName = anObj->GetSemanticName();
}
// Datum
Handle(XCAFDoc_Datum) aDatum;
if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
{
Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
aSemanticName = anObj->GetSemanticName();
}
if (aSemanticName)
{
di << aSemanticName->String();
}
return 0;
}
static Standard_Integer setGDTSemanticName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) {
di << "Use: XSetGDTSemanticName Doc GDT_Label Name\n";
return 1;
}
Handle(TDocStd_Document) Doc;
DDocStd::GetDocument(argv[1], Doc);
if (Doc.IsNull()) { di << argv[1] << " is not a document\n"; return 1; }
TDF_Label aLabel;
TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
if (aLabel.IsNull())
{
di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
return 1;
}
Handle(TCollection_HAsciiString) aSemanticName = new TCollection_HAsciiString(argv[3]);
// Dimension
Handle(XCAFDoc_Dimension) aDimension;
if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
{
Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
anObj->SetSemanticName(aSemanticName);
aDimension->SetObject(anObj);
}
// Geometric Tolerance
Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
{
Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
anObj->SetSemanticName(aSemanticName);
aGeomTolerance->SetObject(anObj);
}
// Datum
Handle(XCAFDoc_Datum) aDatum;
if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
{
Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
anObj->SetSemanticName(aSemanticName);
aDatum->SetObject(anObj);
}
return 0;
}
//=======================================================================
//function : InitCommands
//purpose :
@@ -2874,4 +2980,12 @@ void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
di.Add ("XGetGDTPresentation","XGetGDTPresentation Doc GDT_Label Shape"
"Returns Presentation into Shape",
__FILE__, getGDTPresentation, g);
di.Add("XGetGDTSemanticName", "XGetGDTSemanticName Doc GDT_Label"
"Returns semantic name",
__FILE__, getGDTSemanticName, g);
di.Add("XSetGDTSemanticName", "XGetGDTSemanticName Doc GDT_Label Name"
"Set semantic name",
__FILE__, setGDTSemanticName, g);
}