From eae3ef69195f14b88b1a38a213d0c1c2ec3ed7b8 Mon Sep 17 00:00:00 2001 From: dish Date: Tue, 11 Jun 2024 14:47:58 +0000 Subject: [PATCH] TMP --- src/GeomAPI/GeomAPI_AISObject.cpp | 15 +++++++++++++++ src/GeomAPI/GeomAPI_AISObject.h | 4 ++++ src/Model/Model_Data.cpp | 23 +++++++++++++++++++++++ src/Model/Model_Data.h | 3 +++ src/Model/Model_Objects.cpp | 4 ++-- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index fba0ed2ff..c4fe22c55 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -359,6 +360,20 @@ bool GeomAPI_AISObject::setWidth(const double& theWidth) return isChanged; } +bool GeomAPI_AISObject::setWidth(const std::shared_ptr& theSubShape, const double& theWidth) +{ + Handle(AIS_InteractiveObject) anAIS = impl(); + if (anAIS.IsNull()) + return false; + + Handle(AIS_ColoredShape) aShape = Handle(AIS_ColoredShape)::DownCast(anAIS); // Why ColoredShape, instead of Shape ? + if (!aShape) + return false; + + aShape->SetCustomWidth(theSubShape->impl(), theWidth); // Why SetCustomWidth, instead of SetWidth ? + return true; // Why always true ? What if theWidth == width() ? +} + bool GeomAPI_AISObject::setColor(int theR, int theG, int theB) { Handle(AIS_InteractiveObject) anAIS = impl(); diff --git a/src/GeomAPI/GeomAPI_AISObject.h b/src/GeomAPI/GeomAPI_AISObject.h index 2812845b3..df3a17915 100644 --- a/src/GeomAPI/GeomAPI_AISObject.h +++ b/src/GeomAPI/GeomAPI_AISObject.h @@ -167,6 +167,10 @@ class GeomAPI_AISObject : public GeomAPI_Interface GEOMAPI_EXPORT bool setWidth(const double& theWidth); + GEOMAPI_EXPORT + /// @brief Assigns edge thickness to theSubShape. + bool GeomAPI_AISObject::setWidth(const std::shared_ptr& theSubShape, const double& theWidth); + /// \brief Checks if the object is empty GEOMAPI_EXPORT bool empty() const; diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 28237c24e..9feeb2239 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -121,6 +121,29 @@ std::wstring Model_Data::name() return L""; // not defined } +std::wstring Model_Data::name(std::shared_ptr theSubShape) +{ + std::wstring aShapeName = L""; + std::wstring aResultName = name(); + if (aResultName == L"") + return aShapeName; + + AttributeSelectionPtr aSelectionAttribute; + ResultBodyPtr aResBody = std::dynamic_pointer_cast(myObject); + if (aResBody.get()) + aSelectionAttribute = aResBody->selection(); + else + { + ResultPartPtr aPart = std::dynamic_pointer_cast(myObject); + aSelectionAttribute = aPart->selection(); + } + aSelectionAttribute->setValue(myObject, theSubShape); + aShapeName = aSelectionAttribute->namingName(); + aSelectionAttribute->reset(); + + return aShapeName; +} + void Model_Data::setName(const std::wstring& theName) { bool isModified = false; diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 82703d70c..241bf1d3b 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -47,6 +47,7 @@ #include #include #include +#include #include class ModelAPI_Attribute; @@ -104,6 +105,8 @@ class Model_Data : public ModelAPI_Data Model_Data(); /// Returns the name of the feature visible by the user in the object browser MODEL_EXPORT virtual std::wstring name(); + /// Returns the name of the shape + MODEL_EXPORT virtual std::wstring name(std::shared_ptr theSubShape); /// Defines the name of the feature visible by the user in the object browser MODEL_EXPORT virtual void setName(const std::wstring& theName); /// Return \c true if the object has been renamed by the user diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index bbce6b42d..48a01961f 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -797,7 +797,7 @@ void Model_Objects::setAttribute(const Handle(TDF_Attribute)& theAttribute, aResultLabel = resultLabel(theResult->data(), index(theResult)); TDF_Label anAttributeLabel = subShapeLabel(aResultLabel, index(theResult, theShape)).FindChild(TAG_FEATURE_ARGUMENTS); - if (Standard_GUID::IsEqual(theAttribute->ID(), TDataStd_IntegerArray::GetID())) + if (theAttribute->ID() == TDataStd_IntegerArray::GetID()) { Handle(TDataStd_IntegerArray) anColor; Handle(TDataStd_IntegerArray) anAttr = @@ -811,7 +811,7 @@ void Model_Objects::setAttribute(const Handle(TDF_Attribute)& theAttribute, static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent); } - else if (Standard_GUID::IsEqual(theAttribute->ID(), TDataStd_Integer::GetID())) { + else if (theAttribute->ID() == TDataStd_Integer::GetID()) { Handle(TDataStd_Integer) aThicknessAttr; Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(theAttribute); -- 2.39.2