Sketcher: Fix box selection regressions. And make addSelections Print to python (#26869)
This commit is contained in:
@@ -1151,13 +1151,7 @@ void SelectionSingleton::_SelObj::log(bool remove, bool clearPreselect)
|
||||
ss << "Gui.Selection." << (remove ? "removeSelection" : "addSelection") << "('" << DocName
|
||||
<< "','" << FeatName << "'";
|
||||
if (!SubName.empty()) {
|
||||
if (!elementName.oldName.empty() && !elementName.newName.empty()) {
|
||||
ss << ",'" << SubName.substr(0, SubName.size() - elementName.newName.size())
|
||||
<< elementName.oldName << "'";
|
||||
}
|
||||
else {
|
||||
ss << ",'" << SubName << "'";
|
||||
}
|
||||
ss << "," << getSubString();
|
||||
}
|
||||
if (!remove && (x || y || z || !clearPreselect)) {
|
||||
if (SubName.empty()) {
|
||||
@@ -1172,6 +1166,18 @@ void SelectionSingleton::_SelObj::log(bool remove, bool clearPreselect)
|
||||
Application::Instance->macroManager()->addLine(MacroManager::Cmt, ss.str().c_str());
|
||||
}
|
||||
|
||||
std::string SelectionSingleton::_SelObj::getSubString() const
|
||||
{
|
||||
if (!SubName.empty()) {
|
||||
if (!elementName.oldName.empty() && !elementName.newName.empty()) {
|
||||
return "'" + SubName.substr(0, SubName.size() - elementName.newName.size())
|
||||
+ elementName.oldName + "'";
|
||||
}
|
||||
return "'" + SubName + "'";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool SelectionSingleton::addSelection(
|
||||
const char* pDocName,
|
||||
const char* pObjectName,
|
||||
@@ -1440,6 +1446,14 @@ bool SelectionSingleton::addSelections(
|
||||
notify(SelectionChanges(SelectionChanges::PickedListChanged));
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
bool anyLogged = false;
|
||||
|
||||
if (!logDisabled) {
|
||||
ss << "Gui.Selection.addSelection(App.getDocument('" << pDocName << "').getObject('"
|
||||
<< pObjectName << "'),[";
|
||||
}
|
||||
|
||||
bool update = false;
|
||||
for (const auto& pSubName : pSubNames) {
|
||||
_SelObj temp;
|
||||
@@ -1452,6 +1466,16 @@ bool SelectionSingleton::addSelections(
|
||||
temp.y = 0;
|
||||
temp.z = 0;
|
||||
|
||||
if (!logDisabled && !temp.SubName.empty()) {
|
||||
temp.logged = true;
|
||||
if (anyLogged) {
|
||||
ss << ",";
|
||||
}
|
||||
anyLogged = true;
|
||||
|
||||
ss << temp.getSubString();
|
||||
}
|
||||
|
||||
_SelList.push_back(temp);
|
||||
_SelStackForward.clear();
|
||||
|
||||
@@ -1469,6 +1493,11 @@ bool SelectionSingleton::addSelections(
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (!logDisabled && anyLogged) {
|
||||
ss << "])";
|
||||
Application::Instance->macroManager()->addLine(MacroManager::Cmt, ss.str().c_str());
|
||||
}
|
||||
|
||||
if (update) {
|
||||
getMainWindow()->updateActions();
|
||||
}
|
||||
|
||||
@@ -791,6 +791,7 @@ protected:
|
||||
App::DocumentObject* pResolvedObject = nullptr;
|
||||
|
||||
void log(bool remove = false, bool clearPreselect = true);
|
||||
std::string getSubString() const;
|
||||
};
|
||||
mutable std::list<_SelObj> _SelList;
|
||||
|
||||
|
||||
@@ -2774,8 +2774,8 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s&
|
||||
|
||||
if (!batchSelection.empty()) {
|
||||
Gui::Selection().addSelections(
|
||||
getSketchObject()->getDocument()->getName(),
|
||||
getSketchObject()->getNameInDocument(),
|
||||
editDocName.c_str(),
|
||||
editObjName.c_str(),
|
||||
batchSelection
|
||||
);
|
||||
}
|
||||
@@ -2929,8 +2929,8 @@ bool ViewProviderSketch::selectAll()
|
||||
|
||||
if (!batchSelection.empty()) {
|
||||
Gui::Selection().addSelections(
|
||||
getSketchObject()->getDocument()->getName(),
|
||||
getSketchObject()->getNameInDocument(),
|
||||
editDocName.c_str(),
|
||||
editObjName.c_str(),
|
||||
batchSelection
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user