PartDesign: fix wrong sketch pad (#1854)
Fixes the issue where, when a sketch is cloned, and selected for padding, the clone gets padded instead of the sketch. It also allows padding of a sketch that is already used by anything else, except for PartDesign features. + the same fix for PartDesign Revolution.
This commit is contained in:
parent
e85935c4e3
commit
08f7afb0e4
|
@ -73,7 +73,7 @@ void validateSketches(std::vector<App::DocumentObject*>& sketches, const bool su
|
||||||
std::vector<App::DocumentObject*> ref = (*s)->getInList();
|
std::vector<App::DocumentObject*> ref = (*s)->getInList();
|
||||||
std::vector<App::DocumentObject*>::iterator r = ref.begin();
|
std::vector<App::DocumentObject*>::iterator r = ref.begin();
|
||||||
while (r != ref.end()) {
|
while (r != ref.end()) {
|
||||||
if ((*r)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) {
|
if (!(*r)->getTypeId().isDerivedFrom(PartDesign::SketchBased().getClassTypeId())) {
|
||||||
r = ref.erase(r);
|
r = ref.erase(r);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -186,20 +186,26 @@ CmdPartDesignPad::CmdPartDesignPad()
|
||||||
|
|
||||||
void CmdPartDesignPad::activated(int iMsg)
|
void CmdPartDesignPad::activated(int iMsg)
|
||||||
{
|
{
|
||||||
|
bool bNoSketchWasSelected = false;
|
||||||
// Get a valid sketch from the user
|
// Get a valid sketch from the user
|
||||||
// First check selections
|
// First check selections
|
||||||
std::vector<App::DocumentObject*> sketches = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
std::vector<App::DocumentObject*> sketches = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||||
Gui::validateSketches(sketches, false);
|
if (sketches.size() == 0) {//no sketches were selected. Let user pick an object from valid ones available in document
|
||||||
// Next let the user choose from a list of all eligible objects
|
|
||||||
if (sketches.size() == 0) {
|
|
||||||
sketches = getDocument()->getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
sketches = getDocument()->getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||||
Gui::validateSketches(sketches, false);
|
bNoSketchWasSelected = true;
|
||||||
if (sketches.size() == 0) {
|
}
|
||||||
|
Gui::validateSketches(sketches, false);
|
||||||
|
if (sketches.size() == 0) {
|
||||||
|
if (bNoSketchWasSelected) {
|
||||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid sketches in this document"),
|
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid sketches in this document"),
|
||||||
QObject::tr("Please create a sketch or 2D object first"));
|
QObject::tr("Please create a sketch or 2D object first"));
|
||||||
return;
|
} else {
|
||||||
|
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid sketches selected"),
|
||||||
|
QObject::tr("None of selected sketches/2D objects is valid for padding. Please select a valid sketch or 2D object that is not used by any other feature."));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is more than one selection/possibility, show dialog and let user pick sketch
|
// If there is more than one selection/possibility, show dialog and let user pick sketch
|
||||||
if (sketches.size() > 1) {
|
if (sketches.size() > 1) {
|
||||||
PartDesignGui::FeaturePickDialog Dlg(sketches);
|
PartDesignGui::FeaturePickDialog Dlg(sketches);
|
||||||
|
@ -338,20 +344,26 @@ CmdPartDesignRevolution::CmdPartDesignRevolution()
|
||||||
|
|
||||||
void CmdPartDesignRevolution::activated(int iMsg)
|
void CmdPartDesignRevolution::activated(int iMsg)
|
||||||
{
|
{
|
||||||
|
bool bNoSketchWasSelected = false;
|
||||||
// Get a valid sketch from the user
|
// Get a valid sketch from the user
|
||||||
// First check selections
|
// First check selections
|
||||||
std::vector<App::DocumentObject*> sketches = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
std::vector<App::DocumentObject*> sketches = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||||
Gui::validateSketches(sketches, false);
|
if (sketches.size() == 0) {//no sketches were selected. Let user pick an object from valid ones available in document
|
||||||
// Next let the user choose from a list of all eligible objects
|
|
||||||
if (sketches.size() == 0) {
|
|
||||||
sketches = getDocument()->getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
sketches = getDocument()->getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||||
Gui::validateSketches(sketches, false);
|
bNoSketchWasSelected = true;
|
||||||
if (sketches.size() == 0) {
|
}
|
||||||
|
Gui::validateSketches(sketches, false);
|
||||||
|
if (sketches.size() == 0) {
|
||||||
|
if (bNoSketchWasSelected) {
|
||||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid sketches in this document"),
|
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid sketches in this document"),
|
||||||
QObject::tr("Please create a sketch or 2D object first"));
|
QObject::tr("Please create a sketch or 2D object first"));
|
||||||
return;
|
} else {
|
||||||
|
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid sketches selected"),
|
||||||
|
QObject::tr("None of selected sketches/2D objects is valid for revolving. Please select a valid sketch or 2D object that is not used by any other feature."));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is more than one selection/possibility, show dialog and let user pick sketch
|
// If there is more than one selection/possibility, show dialog and let user pick sketch
|
||||||
if (sketches.size() > 1) {
|
if (sketches.size() > 1) {
|
||||||
PartDesignGui::FeaturePickDialog Dlg(sketches);
|
PartDesignGui::FeaturePickDialog Dlg(sketches);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user