CAD: right-click in a sketch offers verbs for what is selected, instead of for nothing

Select a line in a sketch, right-click, and every sketch verb was greyed: Trim,
Extend, Fillet, Chamfer, Offset, Mirror, the arrays, Constrain. The menu was
right and the selection was gone — two independent faults, each of which hid
the other.

FIRST, the Select-mode RightDown branch called clear_selection() before handing
the click back. Handing it back is correct: the m_right_consumed flag means "the
tool USED this right-click", and a plain right-click is not a gesture
terminator, so the offer should open. Clearing first is not: the offer describes
WHAT IS SELECTED, so wiping the selection guaranteed it could only ever describe
nothing. Deselection keeps its own gesture — left-click on empty space, a few
lines above in the same handler.

SECOND, offer_selection_kind() returned SkNone for every sketch state. The offer
table has always carried verbs for a selected line, arc, point or pair, but
nothing ever RETURNED those kinds, so fourteen rows were gated on selection bits
no code path could set. Classify the selection instead: SkLine / SkArc / SkPoint
/ Sk2Ent, via a first_selected_type() accessor on the tool and two forwarders on
the canvas.

Either fix alone measures as a failure — the classification is handed an empty
selection, or the preserved selection has no kind to match — which is why both
land together.

This is the second half of the report behind 3eb6e5d608: a user comparing the
Design tab with Onshape said "adding constraints seems to be missing"
(OrcaSlicer PR #15238). Constrain was one of the fourteen dead rows, and the
gesture that would have shown it threw the selection away first.

Verified at the machine on behemoth by Tommaso: select a line of a rectangle,
right-click, and the sketch verbs are live.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tommaso Bianchi
2026-08-14 17:37:37 +02:00
co-authored by Claude Opus 5
parent eb52972a8e
commit 614824ce89
5 changed files with 56 additions and 6 deletions
+22 -1
View File
@@ -5534,8 +5534,29 @@ bool DesignPanel::sketch_map_applies() const
// sketch_plane_from_selection, which deliberately uses m_pick_face. snaporca-3a2.)
int DesignPanel::offer_selection_kind() const
{
if (sketch_map_applies())
if (sketch_map_applies()) {
// Classify WHAT is selected in the sketch, rather than collapsing every sketch state to
// SkNone. The offer table has always described verbs for a selected line, arc, point or
// pair — Trim, Extend, Fillet, Chamfer, Offset, Mirror, the arrays, Move/Rotate/Scale,
// Constrain, Delete — but nothing ever RETURNED those kinds, so all thirteen were
// unreachable from the menu and the sketch-editing vocabulary did not exist in the one
// place this app tells users to look. A user comparing against Onshape reported exactly
// that about constraints (OrcaSlicer PR #15238).
const int n = m_viewport ? m_viewport->sketch_selection_count() : 0;
if (n >= 2) return int(OfferSel::Sk2Ent);
if (n == 1) {
SketchEntity::Type t = SketchEntity::Type::Line;
if (m_viewport && m_viewport->sketch_first_selected_type(t)) {
switch (t) {
case SketchEntity::Type::Line: return int(OfferSel::SkLine);
case SketchEntity::Type::Point: return int(OfferSel::SkPoint);
// Arc, Circle, Ellipse, EllipseArc, BSpline all take the curve vocabulary.
default: return int(OfferSel::SkArc);
}
}
}
return int(OfferSel::SkNone);
}
const int nb = int(m_doc.bodies.size());
if (m_sel_solid_vertex && m_sel_solid_body >= 0 && m_sel_solid_body < nb)