PartDesign: Enable selecting a sketch as base plane of another sketch (#23428)
* PartDesign: Enable selecting a sketch as base plane of another sketch * to squash * Part: Attacher: enable attaching to empty objects such as empty Sketch or Body. * Update SketchWorkflow.cpp
This commit is contained in:
@@ -197,17 +197,18 @@ class SketchPreselection
|
||||
{
|
||||
public:
|
||||
SketchPreselection(Gui::Document* guidocument, PartDesign::Body* activeBody,
|
||||
std::tuple<Gui::SelectionFilter, Gui::SelectionFilter> filter)
|
||||
std::tuple<Gui::SelectionFilter, Gui::SelectionFilter, Gui::SelectionFilter> filter)
|
||||
: guidocument(guidocument)
|
||||
, activeBody(activeBody)
|
||||
, faceFilter(std::get<0>(filter))
|
||||
, planeFilter(std::get<1>(filter))
|
||||
, sketchFilter(std::get<2>(filter))
|
||||
{
|
||||
}
|
||||
|
||||
bool matches()
|
||||
{
|
||||
return faceFilter.match() || planeFilter.match();
|
||||
return faceFilter.match() || planeFilter.match() || sketchFilter.match();
|
||||
}
|
||||
|
||||
std::string getSupport() const
|
||||
@@ -231,11 +232,17 @@ public:
|
||||
selectedObject = validator.getObject();
|
||||
supportString = validator.getSupport();
|
||||
}
|
||||
else {
|
||||
else if (planeFilter.match()) {
|
||||
SupportPlaneValidator validator(planeFilter.Result[0][0]);
|
||||
selectedObject = validator.getObject();
|
||||
supportString = validator.getSupport();
|
||||
}
|
||||
else {
|
||||
// For a sketch, the support is the object itself with no sub-element.
|
||||
Gui::SelectionObject sketchSelObject = sketchFilter.Result[0][0];
|
||||
selectedObject = sketchSelObject.getObject();
|
||||
supportString = sketchSelObject.getAsPropertyLinkSubString();
|
||||
}
|
||||
|
||||
handleIfSupportOutOfBody(selectedObject);
|
||||
}
|
||||
@@ -250,7 +257,16 @@ public:
|
||||
FCMD_OBJ_CMD(activeBody, "newObject('Sketcher::SketchObject','" << FeatName << "')");
|
||||
auto Feat = activeBody->getDocument()->getObject(FeatName.c_str());
|
||||
FCMD_OBJ_CMD(Feat, "AttachmentSupport = " << supportString);
|
||||
FCMD_OBJ_CMD(Feat, "MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)<<"'");
|
||||
if (sketchFilter.match()) {
|
||||
FCMD_OBJ_CMD(Feat,
|
||||
"MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmObjectXY)
|
||||
<< "'");
|
||||
}
|
||||
else { // For Face or Plane
|
||||
FCMD_OBJ_CMD(Feat,
|
||||
"MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)
|
||||
<< "'");
|
||||
}
|
||||
Gui::Command::updateActive();
|
||||
PartDesignGui::setEdit(Feat, activeBody);
|
||||
}
|
||||
@@ -346,6 +362,7 @@ private:
|
||||
PartDesign::Body* activeBody;
|
||||
Gui::SelectionFilter faceFilter;
|
||||
Gui::SelectionFilter planeFilter;
|
||||
Gui::SelectionFilter sketchFilter;
|
||||
std::string supportString;
|
||||
};
|
||||
|
||||
@@ -757,8 +774,8 @@ void SketchWorkflow::tryCreateSketch()
|
||||
return;
|
||||
}
|
||||
|
||||
auto faceOrPlaneFilter = getFaceAndPlaneFilter();
|
||||
SketchPreselection sketchOnFace{ guidocument, activeBody, faceOrPlaneFilter };
|
||||
auto filters = getFilters();
|
||||
SketchPreselection sketchOnFace {guidocument, activeBody, filters};
|
||||
|
||||
if (sketchOnFace.matches()) {
|
||||
// create Sketch on Face or Plane
|
||||
@@ -804,7 +821,7 @@ bool SketchWorkflow::shouldAbort(bool shouldMakeBody) const
|
||||
return !shouldMakeBody && !activeBody;
|
||||
}
|
||||
|
||||
std::tuple<Gui::SelectionFilter, Gui::SelectionFilter> SketchWorkflow::getFaceAndPlaneFilter() const
|
||||
std::tuple<Gui::SelectionFilter, Gui::SelectionFilter, Gui::SelectionFilter> SketchWorkflow::getFilters() const
|
||||
{
|
||||
// Hint:
|
||||
// The behaviour of this command has changed with respect to a selected sketch:
|
||||
@@ -815,9 +832,11 @@ std::tuple<Gui::SelectionFilter, Gui::SelectionFilter> SketchWorkflow::getFaceAn
|
||||
Gui::SelectionFilter FaceFilter ("SELECT Part::Feature SUBELEMENT Face COUNT 1");
|
||||
Gui::SelectionFilter PlaneFilter ("SELECT App::Plane COUNT 1", activeBody);
|
||||
Gui::SelectionFilter PlaneFilter2("SELECT PartDesign::Plane COUNT 1", activeBody);
|
||||
Gui::SelectionFilter SketchFilter("SELECT Part::2DObject COUNT 1", activeBody);
|
||||
|
||||
if (PlaneFilter2.match()) {
|
||||
PlaneFilter = PlaneFilter2;
|
||||
}
|
||||
return std::make_tuple(FaceFilter, PlaneFilter);
|
||||
|
||||
return std::make_tuple(FaceFilter, PlaneFilter, SketchFilter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user