From 85585cf49ecf118560375a6f0558ceb62530dffc Mon Sep 17 00:00:00 2001 From: logari81 Date: Sun, 9 Dec 2012 12:04:10 +0100 Subject: [PATCH] PartDesign: Enable manual alignment tool for PartDesign features --- src/App/GeoFeature.cpp | 7 +++++++ src/App/GeoFeature.h | 2 ++ src/Gui/ManualAlignment.cpp | 4 +--- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 13 +++++++++++++ src/Mod/PartDesign/App/FeatureSketchBased.h | 4 ++++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/App/GeoFeature.cpp b/src/App/GeoFeature.cpp index a0e38878f..5226b9e78 100644 --- a/src/App/GeoFeature.cpp +++ b/src/App/GeoFeature.cpp @@ -47,3 +47,10 @@ GeoFeature::GeoFeature(void) GeoFeature::~GeoFeature(void) { } + +void GeoFeature::transformPlacement(const Base::Placement &transform) +{ + Base::Placement plm = this->Placement.getValue(); + plm = transform * plm; + this->Placement.setValue(plm); +} diff --git a/src/App/GeoFeature.h b/src/App/GeoFeature.h index bf2b23cda..c709e2c88 100644 --- a/src/App/GeoFeature.h +++ b/src/App/GeoFeature.h @@ -46,6 +46,8 @@ public: /// Constructor GeoFeature(void); virtual ~GeoFeature(); + + virtual void transformPlacement(const Base::Placement &transform); }; } //namespace App diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 0256a0279..1fabb9f27 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -1016,9 +1016,7 @@ void ManualAlignment::alignObject(App::DocumentObject *obj) { if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { App::GeoFeature* geom = static_cast(obj); - Base::Placement plm = geom->Placement.getValue(); - plm = this->myTransform * plm; - geom->Placement.setValue(plm); + geom->transformPlacement(this->myTransform); } } diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 7ee871768..4ccd562d9 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -116,6 +116,19 @@ void SketchBased::positionBySketch(void) } } +void SketchBased::transformPlacement(const Base::Placement &transform) +{ + Part::Part2DObject *sketch = static_cast(Sketch.getValue()); + if (sketch && sketch->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + Part::Feature *part = static_cast(sketch->Support.getValue()); + if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + part->transformPlacement(transform); + else + sketch->transformPlacement(transform); + positionBySketch(); + } +} + Part::Part2DObject* SketchBased::getVerifiedSketch() const { App::DocumentObject* result = Sketch.getValue(); if (!result) diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index 995a2e112..ad45c76f0 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -57,6 +57,10 @@ public: * or its support if it has one */ void positionBySketch(void); + /** applies a transform on the Placement of the Sketch or its + * support if it has one + */ + virtual void transformPlacement(const Base::Placement &transform); /// Verifies the linked Sketch object Part::Part2DObject* getVerifiedSketch() const;