Sketcher: Fix ctrl A (#23866)
This commit is contained in:
@@ -1458,6 +1458,11 @@ void TaskSketcherConstraints::onListWidgetConstraintsItemSelectionChanged()
|
||||
Gui::Selection().addSelections(doc_name.c_str(), obj_name.c_str(), constraintSubNames);
|
||||
|
||||
this->blockSelection(block);
|
||||
|
||||
// it seems that addSelections gives back the focus to the view, and not immediately.
|
||||
QTimer::singleShot(200, [this]() {
|
||||
ui->listWidgetConstraints->setFocus();
|
||||
});
|
||||
}
|
||||
|
||||
void TaskSketcherConstraints::change3DViewVisibilityToTrackFilter(bool filterEnabled)
|
||||
|
||||
@@ -1735,6 +1735,11 @@ void TaskSketcherElements::onListWidgetElementsItemPressed(QListWidgetItem* it)
|
||||
previouslySelectedItemIndex = focusItemIndex;
|
||||
|
||||
ui->listWidgetElements->repaint();
|
||||
|
||||
// it seems that addSelections gives back the focus to the view, and not immediately.
|
||||
QTimer::singleShot(200, [this]() {
|
||||
ui->listWidgetElements->setFocus();
|
||||
});
|
||||
}
|
||||
|
||||
bool TaskSketcherElements::hasInputWidgetFocused()
|
||||
|
||||
@@ -2729,6 +2729,20 @@ bool ViewProviderSketch::selectAll()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the focus is on the constraints or element list widget.
|
||||
QWidget* focusedWidget = QApplication::focusWidget();
|
||||
bool focusOnConstraintWidget = false;
|
||||
bool focusOnElementWidget = false;
|
||||
if (focusedWidget) {
|
||||
if (focusedWidget->objectName().toStdString() == "listWidgetConstraints") {
|
||||
focusOnConstraintWidget = true;
|
||||
}
|
||||
else if (focusedWidget->objectName().toStdString() == "listWidgetElements") {
|
||||
focusOnElementWidget = true;
|
||||
}
|
||||
}
|
||||
bool noWidgetSelected = !focusOnConstraintWidget && !focusOnElementWidget;
|
||||
|
||||
Sketcher::SketchObject* sketchObject = getSketchObject();
|
||||
if (!sketchObject) {
|
||||
return false;
|
||||
@@ -2736,70 +2750,73 @@ bool ViewProviderSketch::selectAll()
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
int intGeoCount = sketchObject->getHighestCurveIndex() + 1;
|
||||
int extGeoCount = sketchObject->getExternalGeometryCount();
|
||||
if (focusOnElementWidget || noWidgetSelected) {
|
||||
int intGeoCount = sketchObject->getHighestCurveIndex() + 1;
|
||||
int extGeoCount = sketchObject->getExternalGeometryCount();
|
||||
|
||||
const std::vector<Part::Geometry*> geomlist = sketchObject->getCompleteGeometry();
|
||||
const std::vector<Part::Geometry*> geomlist = sketchObject->getCompleteGeometry();
|
||||
|
||||
int VertexId = -1;
|
||||
int GeoId = 0;
|
||||
int VertexId = -1;
|
||||
int GeoId = 0;
|
||||
|
||||
auto selectVertex = [this](int &vertexId, int numberOfVertices) {
|
||||
for (int i = 0; i < numberOfVertices; i++) {
|
||||
vertexId++;
|
||||
addSelection2(fmt::format("Vertex{}", vertexId + 1));
|
||||
}
|
||||
};
|
||||
auto selectVertex = [this](int &vertexId, int numberOfVertices) {
|
||||
for (int i = 0; i < numberOfVertices; i++) {
|
||||
vertexId++;
|
||||
addSelection2(fmt::format("Vertex{}", vertexId + 1));
|
||||
}
|
||||
};
|
||||
|
||||
auto selectEdge = [this](int GeoId) {
|
||||
if (GeoId >= 0) {
|
||||
addSelection2(fmt::format("Edge{}", GeoId + 1));
|
||||
} else {
|
||||
addSelection2(fmt::format("ExternalEdge{}", GeoEnum::RefExt - GeoId + 1));
|
||||
}
|
||||
};
|
||||
auto selectEdge = [this](int GeoId) {
|
||||
if (GeoId >= 0) {
|
||||
addSelection2(fmt::format("Edge{}", GeoId + 1));
|
||||
} else {
|
||||
addSelection2(fmt::format("ExternalEdge{}", GeoEnum::RefExt - GeoId + 1));
|
||||
}
|
||||
};
|
||||
|
||||
bool hasUnselectedGeometry = false;
|
||||
bool hasUnselectedGeometry = false;
|
||||
|
||||
for (std::vector<Part::Geometry*>::const_iterator it = geomlist.begin();
|
||||
it != geomlist.end() - 2; // -2 to exclude H_Axis and V_Axis
|
||||
++it, ++GeoId) {
|
||||
for (std::vector<Part::Geometry*>::const_iterator it = geomlist.begin();
|
||||
it != geomlist.end() - 2; // -2 to exclude H_Axis and V_Axis
|
||||
++it, ++GeoId) {
|
||||
|
||||
if (GeoId >= intGeoCount) {
|
||||
GeoId = -extGeoCount;
|
||||
if (GeoId >= intGeoCount) {
|
||||
GeoId = -extGeoCount;
|
||||
}
|
||||
|
||||
if ((*it)->is<Part::GeomPoint>()) {
|
||||
selectVertex(VertexId, 1);
|
||||
}
|
||||
else if ((*it)->is<Part::GeomLineSegment>() || (*it)->is<Part::GeomBSplineCurve>()) {
|
||||
selectVertex(VertexId, 2); // Start + End
|
||||
selectEdge(GeoId);
|
||||
}
|
||||
else if ((*it)->isDerivedFrom<Part::GeomConic>()) {
|
||||
selectVertex(VertexId, 1); // Center
|
||||
selectEdge(GeoId);
|
||||
}
|
||||
else if ((*it)->isDerivedFrom<Part::GeomArcOfConic>()) {
|
||||
selectVertex(VertexId, 3); // Start + End + Center
|
||||
selectEdge(GeoId);
|
||||
}
|
||||
else {
|
||||
hasUnselectedGeometry = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->is<Part::GeomPoint>()) {
|
||||
selectVertex(VertexId, 1);
|
||||
}
|
||||
else if ((*it)->is<Part::GeomLineSegment>() || (*it)->is<Part::GeomBSplineCurve>()) {
|
||||
selectVertex(VertexId, 2); // Start + End
|
||||
selectEdge(GeoId);
|
||||
}
|
||||
else if ((*it)->isDerivedFrom<Part::GeomConic>()) {
|
||||
selectVertex(VertexId, 1); // Center
|
||||
selectEdge(GeoId);
|
||||
}
|
||||
else if ((*it)->isDerivedFrom<Part::GeomArcOfConic>()) {
|
||||
selectVertex(VertexId, 3); // Start + End + Center
|
||||
selectEdge(GeoId);
|
||||
}
|
||||
else {
|
||||
hasUnselectedGeometry = true;
|
||||
// get root point if they exist
|
||||
addSelection2("RootPoint");
|
||||
|
||||
if (hasUnselectedGeometry) {
|
||||
Base::Console().error("Select All: Not all geometry was selected");
|
||||
}
|
||||
}
|
||||
|
||||
// select constraints too
|
||||
const std::vector<Sketcher::Constraint*>& constraints = sketchObject->Constraints.getValues();
|
||||
for (size_t i = 0; i < constraints.size(); ++i) {
|
||||
addSelection2(fmt::format("Constraint{}", i + 1));
|
||||
}
|
||||
|
||||
// get root point if they exist
|
||||
addSelection2("RootPoint");
|
||||
|
||||
if (hasUnselectedGeometry) {
|
||||
Base::Console().error("Select All: Not all geometry was selected");
|
||||
if (focusOnConstraintWidget || noWidgetSelected) {
|
||||
const std::vector<Sketcher::Constraint*>& constraints = sketchObject->Constraints.getValues();
|
||||
for (size_t i = 0; i < constraints.size(); ++i) {
|
||||
addSelection2(fmt::format("Constraint{}", i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user