PartDesign: Fix use of App::Planes to create sketches (#20453)
This commit is contained in:
@@ -39,7 +39,7 @@ PROPERTY_SOURCE(App::DatumElement, App::GeoFeature)
|
||||
PROPERTY_SOURCE(App::Plane, App::DatumElement)
|
||||
PROPERTY_SOURCE(App::Line, App::DatumElement)
|
||||
PROPERTY_SOURCE(App::Point, App::DatumElement)
|
||||
PROPERTY_SOURCE(App::LocalCoordinateSystem, App::GeoFeature)
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(App::LocalCoordinateSystem, App::GeoFeature)
|
||||
|
||||
DatumElement::DatumElement(bool hideRole)
|
||||
: baseDir{0.0, 0.0, 1.0}
|
||||
@@ -125,7 +125,6 @@ Point::Point()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
LocalCoordinateSystem::LocalCoordinateSystem()
|
||||
: extension(this)
|
||||
{
|
||||
ADD_PROPERTY_TYPE(OriginFeatures,
|
||||
(nullptr),
|
||||
@@ -133,8 +132,11 @@ LocalCoordinateSystem::LocalCoordinateSystem()
|
||||
App::Prop_Hidden,
|
||||
"Axis and baseplanes controlled by the LCS");
|
||||
|
||||
Group.setStatus(Property::Transient, true);
|
||||
|
||||
setStatus(App::NoAutoExpand, true);
|
||||
extension.initExtension(this);
|
||||
|
||||
GroupExtension::initExtension(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,12 +203,6 @@ App::Point* LocalCoordinateSystem::getPoint(const char* role) const
|
||||
throw Base::RuntimeError(err.str().c_str());
|
||||
}
|
||||
|
||||
bool LocalCoordinateSystem::hasObject(const DocumentObject* obj) const
|
||||
{
|
||||
const auto& features = OriginFeatures.getValues();
|
||||
return std::ranges::find(features, obj) != features.end();
|
||||
}
|
||||
|
||||
short LocalCoordinateSystem::mustExecute() const
|
||||
{
|
||||
if (OriginFeatures.isTouched()) {
|
||||
@@ -340,18 +336,7 @@ void LocalCoordinateSystem::migrateOriginPoint()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
LocalCoordinateSystem::LCSExtension::LCSExtension(LocalCoordinateSystem* obj)
|
||||
: obj(obj)
|
||||
{
|
||||
Group.setStatus(Property::Transient, true);
|
||||
}
|
||||
|
||||
void LocalCoordinateSystem::LCSExtension::initExtension(ExtensionContainer* obj)
|
||||
{
|
||||
App::GroupExtension::initExtension(obj);
|
||||
}
|
||||
|
||||
bool LocalCoordinateSystem::LCSExtension::extensionGetSubObject(DocumentObject*& ret,
|
||||
bool LocalCoordinateSystem::extensionGetSubObject(DocumentObject*& ret,
|
||||
const char* subname,
|
||||
PyObject** pyobj,
|
||||
Base::Matrix4D* mat,
|
||||
@@ -380,7 +365,7 @@ bool LocalCoordinateSystem::LCSExtension::extensionGetSubObject(DocumentObject*&
|
||||
}
|
||||
|
||||
try {
|
||||
ret = obj->getDatumElement(name.c_str());
|
||||
ret = getDatumElement(name.c_str());
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
@@ -399,3 +384,9 @@ bool LocalCoordinateSystem::LCSExtension::extensionGetSubObject(DocumentObject*&
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalCoordinateSystem::hasObject(const DocumentObject* obj, [[maybe_unused]] bool recursive) const
|
||||
{
|
||||
const auto& features = OriginFeatures.getValues();
|
||||
return std::ranges::find(features, obj) != features.end();
|
||||
}
|
||||
|
||||
@@ -102,10 +102,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class AppExport LocalCoordinateSystem: public App::GeoFeature
|
||||
class AppExport LocalCoordinateSystem: public App::GeoFeature, public App::GeoFeatureGroupExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(App::LocalCoordinateSystem);
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(App::LocalCoordinateSystem);
|
||||
Q_DECLARE_TR_FUNCTIONS(App::LocalCoordinateSystem)
|
||||
|
||||
public:
|
||||
@@ -195,9 +194,6 @@ public:
|
||||
App::Point* getPoint(const char* role) const;
|
||||
///@}
|
||||
|
||||
/// Returns true if the given object is part of the origin
|
||||
bool hasObject(const DocumentObject* obj) const;
|
||||
|
||||
/// Returns true on changing DatumElement set
|
||||
short mustExecute() const override;
|
||||
|
||||
@@ -216,6 +212,17 @@ public:
|
||||
// Axis links
|
||||
PropertyLinkList OriginFeatures;
|
||||
|
||||
// GeoFeatureGroupExtension overrides:
|
||||
bool extensionGetSubObject(DocumentObject*& ret,
|
||||
const char* subname,
|
||||
PyObject**,
|
||||
Base::Matrix4D*,
|
||||
bool,
|
||||
int) const override;
|
||||
|
||||
// Reimplement the hasObject because LCS doesn't use Group but stores objects in OriginFeatures for whatever reason.
|
||||
bool hasObject(const DocumentObject* obj, bool recursive = false) const override;
|
||||
|
||||
protected:
|
||||
/// Checks integrity of the LCS
|
||||
App::DocumentObjectExecReturn* execute() override;
|
||||
@@ -229,22 +236,6 @@ private:
|
||||
struct SetupData;
|
||||
void setupDatumElement(App::PropertyLink& featProp, const SetupData& data);
|
||||
|
||||
class LCSExtension: public GeoFeatureGroupExtension
|
||||
{
|
||||
LocalCoordinateSystem* obj;
|
||||
|
||||
public:
|
||||
explicit LCSExtension(LocalCoordinateSystem* obj);
|
||||
void initExtension(ExtensionContainer* obj) override;
|
||||
bool extensionGetSubObject(DocumentObject*& ret,
|
||||
const char* subname,
|
||||
PyObject**,
|
||||
Base::Matrix4D*,
|
||||
bool,
|
||||
int) const override;
|
||||
};
|
||||
LCSExtension extension;
|
||||
|
||||
struct SetupData
|
||||
{
|
||||
Base::Type type;
|
||||
|
||||
@@ -4154,7 +4154,6 @@ const std::vector<DocumentObject*>& Document::getObjects() const
|
||||
return d->objectArray;
|
||||
}
|
||||
|
||||
|
||||
std::vector<DocumentObject*> Document::getObjectsOfType(const Base::Type& typeId) const
|
||||
{
|
||||
std::vector<DocumentObject*> Objects;
|
||||
@@ -4166,6 +4165,20 @@ std::vector<DocumentObject*> Document::getObjectsOfType(const Base::Type& typeId
|
||||
return Objects;
|
||||
}
|
||||
|
||||
std::vector<DocumentObject*> Document::getObjectsOfType(const std::vector<Base::Type>& types) const
|
||||
{
|
||||
std::vector<DocumentObject*> Objects;
|
||||
for (auto it : d->objectArray) {
|
||||
for (auto& typeId : types) {
|
||||
if (it->isDerivedFrom(typeId)) {
|
||||
Objects.push_back(it);
|
||||
break; // Prevent adding several times the same object.
|
||||
}
|
||||
}
|
||||
}
|
||||
return Objects;
|
||||
}
|
||||
|
||||
std::vector<DocumentObject*> Document::getObjectsWithExtension(const Base::Type& typeId,
|
||||
bool derived) const
|
||||
{
|
||||
|
||||
@@ -357,6 +357,7 @@ public:
|
||||
/// Returns a list of all Objects
|
||||
const std::vector<DocumentObject*>& getObjects() const;
|
||||
std::vector<DocumentObject*> getObjectsOfType(const Base::Type& typeId) const;
|
||||
std::vector<DocumentObject*> getObjectsOfType(const std::vector<Base::Type>& types) const;
|
||||
/// Returns all object with given extensions. If derived=true also all objects with extensions
|
||||
/// derived from the given one
|
||||
std::vector<DocumentObject*> getObjectsWithExtension(const Base::Type& typeId,
|
||||
|
||||
Reference in New Issue
Block a user