Sketcher: VP - Fix error messages while deleting geometry

==========================================================

When selecting a list of geometry, where at least one element has internal geometry, together with the internal geometry
produced an error in the report view.

Solution:
Use newly exposed deleteGeometries to delete all geometries at once.

Note:
The list is not reverse sorted (as opposed as with the deleteGeometry method), as the list will be sorted
by SketchObject in the normal order. Reverse sorting would lead to the worst case for that normal order sort.
This commit is contained in:
Abdullah Tahiri
2021-01-04 11:17:21 +01:00
committed by abdullahtahiriyo
parent cf7422af4f
commit 07f449e81f

View File

@@ -6887,8 +6887,9 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
for (std::vector<std::string>::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) {
if (it->size() > 4 && it->substr(0,4) == "Edge") {
int GeoId = std::atoi(it->substr(4,4000).c_str()) - 1;
if( GeoId >= 0 )
if( GeoId >= 0 ) {
delInternalGeometries.insert(GeoId);
}
else
delExternalGeometries.insert(Sketcher::GeoEnum::RefExt - GeoId);
} else if (it->size() > 12 && it->substr(0,12) == "ExternalEdge") {
@@ -6957,13 +6958,26 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
}
}
for (rit = delInternalGeometries.rbegin(); rit != delInternalGeometries.rend(); ++rit) {
if(!delInternalGeometries.empty()) {
std::stringstream stream;
// NOTE: SketchObject delGeometries will sort the array, so filling it here with a reverse iterator would
// lead to the worst case scenario for sorting.
auto endit = std::prev(delInternalGeometries.end());
for (auto it = delInternalGeometries.begin(); it != endit; ++it) {
stream << *it << ",";
}
stream << *endit;
try {
Gui::cmdAppObjectArgs(getObject(), "delGeometry(%i)", *rit);
Gui::cmdAppObjectArgs(getObject(), "delGeometries([%s])", stream.str().c_str());
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
stream.str(std::string());
}
for (rit = delExternalGeometries.rbegin(); rit != delExternalGeometries.rend(); ++rit) {