Core: move getPlacementProperty to be more accessible (#26088)
* Core: move getPlacementProperty to be more accessible * Update DocumentObject.h * Update DocumentObject.cpp * Update ViewProviderDragger.h * Update ViewProviderDragger.cpp * Update DocumentObject.h * Update DocumentObject.cpp * Update ViewProviderLink.cpp * Update DocumentObject.h * Update DocumentObject.cpp * Update DocumentObject.h
This commit is contained in:
@@ -1644,3 +1644,26 @@ Base::Placement DocumentObject::getPlacementOf(const std::string& sub, DocumentO
|
||||
return plc * subObj->getPlacementOf(newSub, targetObj);
|
||||
}
|
||||
|
||||
Base::Placement DocumentObject::getPlacement() const
|
||||
{
|
||||
Base::Placement plc;
|
||||
if (auto* prop = getPlacementProperty()) {
|
||||
plc = prop->getValue();
|
||||
}
|
||||
return plc;
|
||||
}
|
||||
|
||||
App::PropertyPlacement* DocumentObject::getPlacementProperty() const
|
||||
{
|
||||
if (auto linkExtension = getExtensionByType<App::LinkBaseExtension>(true)) {
|
||||
if (auto linkPlacementProp = linkExtension->getLinkPlacementProperty()) {
|
||||
return linkPlacementProp;
|
||||
}
|
||||
|
||||
return linkExtension->getPlacementProperty();
|
||||
}
|
||||
|
||||
return getPropertyByName<App::PropertyPlacement>("Placement");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <App/TransactionalObject.h>
|
||||
#include <App/PropertyExpressionEngine.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Base/SmartPtrPy.h>
|
||||
@@ -714,6 +715,12 @@ public:
|
||||
*/
|
||||
virtual Base::Placement getPlacementOf(const std::string& sub, DocumentObject* targetObj = nullptr);
|
||||
|
||||
/* Returns the Placement property value if any.*/
|
||||
virtual Base::Placement getPlacement() const;
|
||||
|
||||
/* Returns the Placement property to use if any*/
|
||||
virtual App::PropertyPlacement* getPlacementProperty() const;
|
||||
|
||||
protected:
|
||||
/// recompute only this object
|
||||
virtual App::DocumentObjectExecReturn* recompute();
|
||||
|
||||
@@ -187,21 +187,6 @@ bool ViewProviderDragger::forwardToLink()
|
||||
return forwardedViewProvider != nullptr;
|
||||
}
|
||||
|
||||
App::PropertyPlacement* ViewProviderDragger::getPlacementProperty() const
|
||||
{
|
||||
auto object = getObject();
|
||||
|
||||
if (auto linkExtension = object->getExtensionByType<App::LinkBaseExtension>(true)) {
|
||||
if (auto linkPlacementProp = linkExtension->getLinkPlacementProperty()) {
|
||||
return linkPlacementProp;
|
||||
}
|
||||
|
||||
return linkExtension->getPlacementProperty();
|
||||
}
|
||||
|
||||
return getObject()->getPropertyByName<App::PropertyPlacement>("Placement");
|
||||
}
|
||||
|
||||
bool ViewProviderDragger::setEdit(int ModNum)
|
||||
{
|
||||
Q_UNUSED(ModNum);
|
||||
@@ -298,7 +283,7 @@ void ViewProviderDragger::dragMotionCallback(void* data, [[maybe_unused]] SoDrag
|
||||
|
||||
void ViewProviderDragger::updatePlacementFromDragger(DraggerComponents components)
|
||||
{
|
||||
const auto placement = getPlacementProperty();
|
||||
const auto placement = getObject()->getPlacementProperty();
|
||||
|
||||
if (!placement) {
|
||||
return;
|
||||
@@ -429,7 +414,7 @@ void ViewProviderDragger::updateTransformFromDragger()
|
||||
|
||||
Base::Placement ViewProviderDragger::getObjectPlacement() const
|
||||
{
|
||||
if (auto placement = getPlacementProperty()) {
|
||||
if (auto placement = getObject()->getPlacementProperty()) {
|
||||
return placement->getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -128,9 +128,6 @@ protected:
|
||||
|
||||
bool forwardToLink();
|
||||
|
||||
/// Gets placement property of the object
|
||||
App::PropertyPlacement* getPlacementProperty() const;
|
||||
|
||||
/**
|
||||
* Returns a newly create dialog for the part to be placed in the task view
|
||||
* Must be reimplemented in subclasses.
|
||||
|
||||
@@ -3271,7 +3271,7 @@ bool ViewProviderLink::initDraggingPlacement()
|
||||
dragCtx = std::make_unique<DraggerContext>();
|
||||
|
||||
dragCtx->preTransform = doc->getEditingTransform();
|
||||
const auto& pla = getPlacementProperty()->getValue();
|
||||
const auto& pla = getObject()->getPlacementProperty()->getValue();
|
||||
|
||||
// Cancel out our own transformation from the editing transform, because
|
||||
// the dragger is meant to change our transformation.
|
||||
|
||||
Reference in New Issue
Block a user