diff --git a/assets/icons/ui/design/palette.toml b/assets/icons/ui/design/palette.toml index c23f252be..770c9b445 100644 --- a/assets/icons/ui/design/palette.toml +++ b/assets/icons/ui/design/palette.toml @@ -204,7 +204,10 @@ constraint = [ "c_polygon", "c_smooth", "c_symmetry", "c_tangent", ] construction = [ - "centerline", "construction", "infinite", + "centerline", "construction", "construction_line", "construction_line_angle", + "construction_line_bisector", "construction_line_horizontal", "construction_line_parallel", + "construction_line_perpendicular", "construction_line_tangent_at", "construction_line_tangent_external", + "construction_line_tangent_two", "construction_line_vertical", "infinite", ] mesh = [ "mesh_body", diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt index 038e79783..fe784a97f 100644 --- a/assets/icons/ui/design/requested_icons.txt +++ b/assets/icons/ui/design/requested_icons.txt @@ -70,6 +70,16 @@ configuration_table false conic false constrainer false construction false +construction_line false +construction_line_angle false +construction_line_bisector false +construction_line_horizontal false +construction_line_parallel false +construction_line_perpendicular false +construction_line_tangent_at false +construction_line_tangent_external false +construction_line_tangent_two false +construction_line_vertical false contact_all false contact_new false contact_off false diff --git a/assets/icons/ui/design/svg/model/construction_line.svg b/assets/icons/ui/design/svg/model/construction_line.svg new file mode 100644 index 000000000..6f511bed9 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line.svg @@ -0,0 +1,8 @@ + + Construction line through two points + + + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_angle.svg b/assets/icons/ui/design/svg/model/construction_line_angle.svg new file mode 100644 index 000000000..449243213 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_angle.svg @@ -0,0 +1,8 @@ + + Construction line at an angle + + + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_bisector.svg b/assets/icons/ui/design/svg/model/construction_line_bisector.svg new file mode 100644 index 000000000..a6d119808 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_bisector.svg @@ -0,0 +1,6 @@ + + Angle bisector + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_horizontal.svg b/assets/icons/ui/design/svg/model/construction_line_horizontal.svg new file mode 100644 index 000000000..9db9affb3 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_horizontal.svg @@ -0,0 +1,6 @@ + + Horizontal construction line + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_parallel.svg b/assets/icons/ui/design/svg/model/construction_line_parallel.svg new file mode 100644 index 000000000..aa8ff96d0 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_parallel.svg @@ -0,0 +1,5 @@ + + Parallel construction line + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_perpendicular.svg b/assets/icons/ui/design/svg/model/construction_line_perpendicular.svg new file mode 100644 index 000000000..93f6d4b93 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_perpendicular.svg @@ -0,0 +1,6 @@ + + Perpendicular construction line + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_tangent_at.svg b/assets/icons/ui/design/svg/model/construction_line_tangent_at.svg new file mode 100644 index 000000000..b8ee5abc9 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_tangent_at.svg @@ -0,0 +1,7 @@ + + Tangent at a curve point + + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_tangent_external.svg b/assets/icons/ui/design/svg/model/construction_line_tangent_external.svg new file mode 100644 index 000000000..7c584cef8 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_tangent_external.svg @@ -0,0 +1,7 @@ + + Tangent through an external point + + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_tangent_two.svg b/assets/icons/ui/design/svg/model/construction_line_tangent_two.svg new file mode 100644 index 000000000..cd6b84547 --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_tangent_two.svg @@ -0,0 +1,6 @@ + + Common tangent to two curves + + + + diff --git a/assets/icons/ui/design/svg/model/construction_line_vertical.svg b/assets/icons/ui/design/svg/model/construction_line_vertical.svg new file mode 100644 index 000000000..67001285e --- /dev/null +++ b/assets/icons/ui/design/svg/model/construction_line_vertical.svg @@ -0,0 +1,6 @@ + + Vertical construction line + + + + diff --git a/assets/locales/pending/construction-lines.json b/assets/locales/pending/construction-lines.json new file mode 100644 index 000000000..b8cc7c78d --- /dev/null +++ b/assets/locales/pending/construction-lines.json @@ -0,0 +1,567 @@ +{ + "en": { + "cmd.sketch.construction_line": "Construction Line", + "cmd.sketch.construction_line.horizontal": "Horizontal Construction Line", + "cmd.sketch.construction_line.vertical": "Vertical Construction Line", + "cmd.sketch.construction_line.angle": "Construction Line at Angle", + "cmd.sketch.construction_line.parallel": "Parallel Construction Line", + "cmd.sketch.construction_line.perpendicular": "Perpendicular Construction Line", + "cmd.sketch.construction_line.tangent_external": "Tangent through External Point", + "cmd.sketch.construction_line.tangent_at": "Tangent at Curve Point", + "cmd.sketch.construction_line.tangent_two": "Common Tangent", + "cmd.sketch.construction_line.bisector": "Angle Bisector", + "help.sketch.construction_line": "Create an infinite construction line through two points. Use it to lay out a sketch without splitting profiles.", + "help.sketch.construction_line.horizontal": "Create an infinite horizontal construction line through a point. Its horizontal constraint follows later edits.", + "help.sketch.construction_line.vertical": "Create an infinite vertical construction line through a point. Its vertical constraint follows later edits.", + "help.sketch.construction_line.angle": "Create an infinite construction line at an angle from sketch X. Pick the point and type the angle, or pick its direction.", + "help.sketch.construction_line.parallel": "Pick a straight sketch line, then place a parallel infinite construction line. Right-click to choose another reference.", + "help.sketch.construction_line.perpendicular": "Pick a straight sketch line, then place a perpendicular infinite construction line. Right-click to choose another reference.", + "help.sketch.construction_line.tangent_external": "Pick a circle or circular arc, then an external point and a tangent solution. The previews show only contacts on the drawn arc.", + "help.sketch.construction_line.tangent_at": "Create a tangent at a point on a circle or circular arc, or an endpoint of an open spline or conic. Pick the curve, then its contact point.", + "help.sketch.construction_line.tangent_two": "Pick two circles or circular arcs, then choose a common tangent in the preview. Contacts must lie on the drawn curves.", + "help.sketch.construction_line.bisector": "Pick two intersecting straight sketch lines, then choose either angle bisector. The result follows its source lines.", + "ui.construction.free_hint": "Construction line: click two points; right-click to restart", + "ui.construction.point_hint": "Construction line: click the point to pass through", + "ui.construction.angle_hint": "Construction line: click a point, then type an angle or pick a direction", + "ui.construction.reference_hint": "Construction line: pick a straight line, then a point; right-click to change the reference", + "ui.construction.external_hint": "Tangent: pick a circle or arc, an external point, then the desired solution", + "ui.construction.contact_hint": "Tangent: pick a circle/arc or open spline/conic, then the contact point (free-form curves: endpoints)", + "ui.construction.common_hint": "Common tangent: pick two circles/arcs, then the desired solution", + "ui.construction.bisector_hint": "Bisector: pick two intersecting straight lines, then the desired solution", + "prefs.sketch_construction_lines": "Extended construction line tools", + "ui.construction.ribbon_label": "X-Lines" + }, + "ar": { + "cmd.sketch.construction_line": "خط إنشائي", + "cmd.sketch.construction_line.horizontal": "خط إنشائي أفقي", + "cmd.sketch.construction_line.vertical": "خط إنشائي رأسي", + "cmd.sketch.construction_line.angle": "خط إنشائي بزاوية", + "cmd.sketch.construction_line.parallel": "خط إنشائي موازٍ", + "cmd.sketch.construction_line.perpendicular": "خط إنشائي عمودي", + "cmd.sketch.construction_line.tangent_external": "مماس يمر بنقطة خارجية", + "cmd.sketch.construction_line.tangent_at": "مماس عند نقطة على المنحنى", + "cmd.sketch.construction_line.tangent_two": "مماس مشترك", + "cmd.sketch.construction_line.bisector": "منصف الزاوية", + "prefs.sketch_construction_lines": "أدوات الخطوط الإنشائية الموسعة", + "help.sketch.construction_line": "أنشئ خطًا إنشائيًا لا نهائيًا يمر بنقطتين، للمساعدة في رسم الاسكتش دون تقسيم مقاطعه.", + "help.sketch.construction_line.horizontal": "أنشئ خطًا إنشائيًا أفقيًا لا نهائيًا يمر بنقطة. يحافظ القيد الأفقي على الاتجاه بعد التعديلات.", + "help.sketch.construction_line.vertical": "أنشئ خطًا إنشائيًا رأسيًا لا نهائيًا يمر بنقطة. يحافظ القيد الرأسي على الاتجاه بعد التعديلات.", + "help.sketch.construction_line.angle": "أنشئ خطًا إنشائيًا لا نهائيًا بزاوية من محور X للاسكتش. اختر النقطة ثم أدخل الزاوية أو اختر الاتجاه.", + "help.sketch.construction_line.parallel": "اختر خطًا مستقيمًا في الاسكتش ثم ضع خطًا إنشائيًا لا نهائيًا موازيًا له. انقر بزر الفأرة الأيمن لتغيير المرجع.", + "help.sketch.construction_line.perpendicular": "اختر خطًا مستقيمًا في الاسكتش ثم ضع خطًا إنشائيًا لا نهائيًا عموديًا عليه. انقر بزر الفأرة الأيمن لتغيير المرجع.", + "help.sketch.construction_line.tangent_external": "اختر دائرة أو قوسًا دائريًا، ثم نقطة خارجية وحل المماس. تعرض المعاينة نقاط التماس الواقعة على القوس المرسوم فقط.", + "help.sketch.construction_line.tangent_at": "أنشئ مماسًا عند نقطة على دائرة أو قوس دائري، أو عند نهاية منحنى سبلاين مفتوح أو قطع مخروطي مفتوح. اختر المنحنى ثم نقطة التماس.", + "help.sketch.construction_line.tangent_two": "اختر دائرتين أو قوسين دائريين ثم اختر مماسًا مشتركًا من المعاينة. يجب أن تقع نقطتا التماس على المنحنيين المرسومين.", + "help.sketch.construction_line.bisector": "اختر خطين مستقيمين متقاطعين في الاسكتش ثم اختر أحد منصفي الزاوية. يتبع الناتج تعديلات الخطين الأصليين.", + "ui.construction.free_hint": "خط إنشائي: انقر نقطتين؛ انقر بزر الفأرة الأيمن للبدء من جديد", + "ui.construction.point_hint": "خط إنشائي: انقر نقطة المرور", + "ui.construction.angle_hint": "خط إنشائي: انقر نقطة ثم أدخل زاوية أو اختر اتجاهًا", + "ui.construction.reference_hint": "خط إنشائي: اختر خطًا مستقيمًا ثم نقطة؛ انقر بزر الفأرة الأيمن لتغيير المرجع", + "ui.construction.external_hint": "مماس: اختر دائرة أو قوسًا ثم نقطة خارجية ثم الحل المطلوب", + "ui.construction.contact_hint": "مماس: اختر دائرة/قوسًا أو سبلاين/قطعًا مخروطيًا مفتوحًا ثم نقطة التماس (للمنحنيات الحرة: النهايات فقط)", + "ui.construction.common_hint": "مماس مشترك: اختر دائرتين/قوسين ثم الحل المطلوب", + "ui.construction.bisector_hint": "منصف زاوية: اختر خطين مستقيمين متقاطعين ثم الحل المطلوب", + "ui.construction.ribbon_label": "خطوط مساعدة" + }, + "bs": { + "cmd.sketch.construction_line": "Pomoćna prava", + "cmd.sketch.construction_line.horizontal": "Horizontalna pomoćna prava", + "cmd.sketch.construction_line.vertical": "Vertikalna pomoćna prava", + "cmd.sketch.construction_line.angle": "Pomoćna prava pod uglom", + "cmd.sketch.construction_line.parallel": "Paralelna pomoćna prava", + "cmd.sketch.construction_line.perpendicular": "Okomita pomoćna prava", + "cmd.sketch.construction_line.tangent_external": "Tangenta kroz vanjsku tačku", + "cmd.sketch.construction_line.tangent_at": "Tangenta u tački krive", + "cmd.sketch.construction_line.tangent_two": "Zajednička tangenta", + "cmd.sketch.construction_line.bisector": "Simetrala ugla", + "ui.construction.ribbon_label": "Pomoćne" + }, + "cs": { + "cmd.sketch.construction_line": "Konstrukční přímka", + "cmd.sketch.construction_line.horizontal": "Vodorovná konstrukční přímka", + "cmd.sketch.construction_line.vertical": "Svislá konstrukční přímka", + "cmd.sketch.construction_line.angle": "Konstrukční přímka pod úhlem", + "cmd.sketch.construction_line.parallel": "Rovnoběžná konstrukční přímka", + "cmd.sketch.construction_line.perpendicular": "Kolmá konstrukční přímka", + "cmd.sketch.construction_line.tangent_external": "Tečna vedená vnějším bodem", + "cmd.sketch.construction_line.tangent_at": "Tečna v bodě křivky", + "cmd.sketch.construction_line.tangent_two": "Společná tečna", + "cmd.sketch.construction_line.bisector": "Osa úhlu", + "ui.construction.ribbon_label": "Pom. přímky" + }, + "da": { + "cmd.sketch.construction_line": "Hjælpelinje", + "cmd.sketch.construction_line.horizontal": "Vandret hjælpelinje", + "cmd.sketch.construction_line.vertical": "Lodret hjælpelinje", + "cmd.sketch.construction_line.angle": "Hjælpelinje med vinkel", + "cmd.sketch.construction_line.parallel": "Parallel hjælpelinje", + "cmd.sketch.construction_line.perpendicular": "Vinkelret hjælpelinje", + "cmd.sketch.construction_line.tangent_external": "Tangent gennem eksternt punkt", + "cmd.sketch.construction_line.tangent_at": "Tangent i kurvepunkt", + "cmd.sketch.construction_line.tangent_two": "Fælles tangent", + "cmd.sketch.construction_line.bisector": "Vinkelhalveringslinje", + "ui.construction.ribbon_label": "Hjælpelinjer" + }, + "de": { + "cmd.sketch.construction_line": "Konstruktionslinie", + "cmd.sketch.construction_line.horizontal": "Horizontale Konstruktionslinie", + "cmd.sketch.construction_line.vertical": "Vertikale Konstruktionslinie", + "cmd.sketch.construction_line.angle": "Konstruktionslinie unter Winkel", + "cmd.sketch.construction_line.parallel": "Parallele Konstruktionslinie", + "cmd.sketch.construction_line.perpendicular": "Senkrechte Konstruktionslinie", + "cmd.sketch.construction_line.tangent_external": "Tangente durch äußeren Punkt", + "cmd.sketch.construction_line.tangent_at": "Tangente an Kurvenpunkt", + "cmd.sketch.construction_line.tangent_two": "Gemeinsame Tangente", + "cmd.sketch.construction_line.bisector": "Winkelhalbierende", + "prefs.sketch_construction_lines": "Erweiterte Konstruktionslinien-Werkzeuge", + "help.sketch.construction_line": "Erstellt eine unendliche Konstruktionslinie durch zwei Punkte, ohne Skizzenprofile zu teilen.", + "help.sketch.construction_line.horizontal": "Erstellt eine unendliche horizontale Konstruktionslinie durch einen Punkt. Die Horizontalbedingung bleibt bei späteren Änderungen erhalten.", + "help.sketch.construction_line.vertical": "Erstellt eine unendliche vertikale Konstruktionslinie durch einen Punkt. Die Vertikalbedingung bleibt bei späteren Änderungen erhalten.", + "help.sketch.construction_line.angle": "Erstellt eine unendliche Konstruktionslinie in einem Winkel zur Skizzen-X-Achse. Punkt wählen und Winkel eingeben oder Richtung wählen.", + "help.sketch.construction_line.parallel": "Gerade Skizzenlinie wählen, dann eine parallele unendliche Konstruktionslinie platzieren. Rechtsklick wählt eine andere Referenz.", + "help.sketch.construction_line.perpendicular": "Gerade Skizzenlinie wählen, dann eine senkrechte unendliche Konstruktionslinie platzieren. Rechtsklick wählt eine andere Referenz.", + "help.sketch.construction_line.tangent_external": "Kreis oder Kreisbogen wählen, dann einen äußeren Punkt und eine Tangentenlösung. Die Vorschau zeigt nur Berührpunkte auf dem gezeichneten Bogen.", + "help.sketch.construction_line.tangent_at": "Erstellt eine Tangente an einem Punkt eines Kreises oder Kreisbogens oder an einem Endpunkt eines offenen Splines oder Kegelschnitts. Kurve wählen, dann Berührpunkt.", + "help.sketch.construction_line.tangent_two": "Zwei Kreise oder Kreisbögen wählen, dann eine gemeinsame Tangente in der Vorschau. Die Berührpunkte müssen auf den gezeichneten Kurven liegen.", + "help.sketch.construction_line.bisector": "Zwei sich schneidende gerade Skizzenlinien wählen, dann eine der beiden Winkelhalbierenden. Das Ergebnis folgt den Ausgangslinien.", + "ui.construction.free_hint": "Konstruktionslinie: zwei Punkte anklicken; Rechtsklick beginnt neu", + "ui.construction.point_hint": "Konstruktionslinie: Durchgangspunkt anklicken", + "ui.construction.angle_hint": "Konstruktionslinie: Punkt anklicken, dann Winkel eingeben oder Richtung wählen", + "ui.construction.reference_hint": "Konstruktionslinie: Gerade wählen, dann Punkt; Rechtsklick wechselt die Referenz", + "ui.construction.external_hint": "Tangente: Kreis oder Bogen, äußeren Punkt, dann gewünschte Lösung wählen", + "ui.construction.contact_hint": "Tangente: Kreis/Bogen oder offenen Spline/Kegelschnitt wählen, dann Berührpunkt (Freiformkurven: Endpunkte)", + "ui.construction.common_hint": "Gemeinsame Tangente: zwei Kreise/Bögen wählen, dann gewünschte Lösung", + "ui.construction.bisector_hint": "Winkelhalbierende: zwei sich schneidende Geraden wählen, dann gewünschte Lösung", + "ui.construction.ribbon_label": "Hilfslinien" + }, + "es": { + "cmd.sketch.construction_line": "Recta de construcción", + "cmd.sketch.construction_line.horizontal": "Recta de construcción horizontal", + "cmd.sketch.construction_line.vertical": "Recta de construcción vertical", + "cmd.sketch.construction_line.angle": "Recta de construcción con ángulo", + "cmd.sketch.construction_line.parallel": "Recta de construcción paralela", + "cmd.sketch.construction_line.perpendicular": "Recta de construcción perpendicular", + "cmd.sketch.construction_line.tangent_external": "Tangente por un punto exterior", + "cmd.sketch.construction_line.tangent_at": "Tangente en un punto de la curva", + "cmd.sketch.construction_line.tangent_two": "Tangente común", + "cmd.sketch.construction_line.bisector": "Bisectriz", + "ui.construction.ribbon_label": "Líneas aux." + }, + "fr": { + "cmd.sketch.construction_line": "Droite de construction", + "cmd.sketch.construction_line.horizontal": "Droite de construction horizontale", + "cmd.sketch.construction_line.vertical": "Droite de construction verticale", + "cmd.sketch.construction_line.angle": "Droite de construction inclinée", + "cmd.sketch.construction_line.parallel": "Droite de construction parallèle", + "cmd.sketch.construction_line.perpendicular": "Droite de construction perpendiculaire", + "cmd.sketch.construction_line.tangent_external": "Tangente passant par un point extérieur", + "cmd.sketch.construction_line.tangent_at": "Tangente en un point de la courbe", + "cmd.sketch.construction_line.tangent_two": "Tangente commune", + "cmd.sketch.construction_line.bisector": "Bissectrice", + "ui.construction.ribbon_label": "Lignes aux." + }, + "gl": { + "cmd.sketch.construction_line": "Recta de construción", + "cmd.sketch.construction_line.horizontal": "Recta de construción horizontal", + "cmd.sketch.construction_line.vertical": "Recta de construción vertical", + "cmd.sketch.construction_line.angle": "Recta de construción con ángulo", + "cmd.sketch.construction_line.parallel": "Recta de construción paralela", + "cmd.sketch.construction_line.perpendicular": "Recta de construción perpendicular", + "cmd.sketch.construction_line.tangent_external": "Tanxente por un punto exterior", + "cmd.sketch.construction_line.tangent_at": "Tanxente nun punto da curva", + "cmd.sketch.construction_line.tangent_two": "Tanxente común", + "cmd.sketch.construction_line.bisector": "Bisectriz", + "ui.construction.ribbon_label": "Liñas aux." + }, + "he": { + "cmd.sketch.construction_line": "ישר עזר", + "cmd.sketch.construction_line.horizontal": "ישר עזר אופקי", + "cmd.sketch.construction_line.vertical": "ישר עזר אנכי", + "cmd.sketch.construction_line.angle": "ישר עזר בזווית", + "cmd.sketch.construction_line.parallel": "ישר עזר מקביל", + "cmd.sketch.construction_line.perpendicular": "ישר עזר ניצב", + "cmd.sketch.construction_line.tangent_external": "משיק דרך נקודה חיצונית", + "cmd.sketch.construction_line.tangent_at": "משיק בנקודה על העקומה", + "cmd.sketch.construction_line.tangent_two": "משיק משותף", + "cmd.sketch.construction_line.bisector": "חוצה זווית", + "prefs.sketch_construction_lines": "כלי ישרי עזר מורחבים", + "help.sketch.construction_line": "יצירת ישר עזר אינסופי דרך שתי נקודות, לתכנון הסקיצה בלי לפצל את הפרופילים.", + "help.sketch.construction_line.horizontal": "יצירת ישר עזר אופקי אינסופי דרך נקודה. האילוץ האופקי נשמר בעריכות מאוחרות יותר.", + "help.sketch.construction_line.vertical": "יצירת ישר עזר אנכי אינסופי דרך נקודה. האילוץ האנכי נשמר בעריכות מאוחרות יותר.", + "help.sketch.construction_line.angle": "יצירת ישר עזר אינסופי בזווית מציר X של הסקיצה. יש לבחור נקודה ולהקליד זווית או לבחור כיוון.", + "help.sketch.construction_line.parallel": "יש לבחור ישר בסקיצה ואז למקם ישר עזר אינסופי מקביל. לחיצה ימנית מאפשרת לבחור ייחוס אחר.", + "help.sketch.construction_line.perpendicular": "יש לבחור ישר בסקיצה ואז למקם ישר עזר אינסופי ניצב. לחיצה ימנית מאפשרת לבחור ייחוס אחר.", + "help.sketch.construction_line.tangent_external": "יש לבחור מעגל או קשת מעגלית, נקודה חיצונית ואז פתרון למשיק. התצוגה המקדימה מציגה רק נקודות השקה על הקשת המצוירת.", + "help.sketch.construction_line.tangent_at": "יצירת משיק בנקודה על מעגל או קשת מעגלית, או בנקודת קצה של ספליין פתוח או חתך חרוט פתוח. יש לבחור את העקומה ואז את נקודת ההשקה.", + "help.sketch.construction_line.tangent_two": "יש לבחור שני מעגלים או קשתות מעגליות ואז משיק משותף בתצוגה המקדימה. נקודות ההשקה חייבות להיות על העקומות המצוירות.", + "help.sketch.construction_line.bisector": "יש לבחור שני ישרים נחתכים בסקיצה ואז אחד משני חוצי הזווית. התוצאה עוקבת אחר עריכת ישרי המקור.", + "ui.construction.free_hint": "ישר עזר: לחיצה על שתי נקודות; לחיצה ימנית להתחלה מחדש", + "ui.construction.point_hint": "ישר עזר: לחיצה על נקודת המעבר", + "ui.construction.angle_hint": "ישר עזר: בחירת נקודה ואז הקלדת זווית או בחירת כיוון", + "ui.construction.reference_hint": "ישר עזר: בחירת ישר ואז נקודה; לחיצה ימנית להחלפת הייחוס", + "ui.construction.external_hint": "משיק: בחירת מעגל או קשת, נקודה חיצונית ואז הפתרון הרצוי", + "ui.construction.contact_hint": "משיק: בחירת מעגל/קשת או ספליין/חתך חרוט פתוח ואז נקודת השקה (לעקומות חופשיות: קצוות בלבד)", + "ui.construction.common_hint": "משיק משותף: בחירת שני מעגלים/קשתות ואז הפתרון הרצוי", + "ui.construction.bisector_hint": "חוצה זווית: בחירת שני ישרים נחתכים ואז הפתרון הרצוי", + "ui.construction.ribbon_label": "קווי עזר" + }, + "hr": { + "cmd.sketch.construction_line": "Pomoćni pravac", + "cmd.sketch.construction_line.horizontal": "Vodoravni pomoćni pravac", + "cmd.sketch.construction_line.vertical": "Okomiti pomoćni pravac", + "cmd.sketch.construction_line.angle": "Pomoćni pravac pod kutom", + "cmd.sketch.construction_line.parallel": "Paralelni pomoćni pravac", + "cmd.sketch.construction_line.perpendicular": "Pomoćni pravac okomit na pravac", + "cmd.sketch.construction_line.tangent_external": "Tangenta kroz vanjsku točku", + "cmd.sketch.construction_line.tangent_at": "Tangenta u točki krivulje", + "cmd.sketch.construction_line.tangent_two": "Zajednička tangenta", + "cmd.sketch.construction_line.bisector": "Simetrala kuta", + "ui.construction.ribbon_label": "Pomoćne" + }, + "hu": { + "cmd.sketch.construction_line": "Szerkesztőegyenes", + "cmd.sketch.construction_line.horizontal": "Vízszintes szerkesztőegyenes", + "cmd.sketch.construction_line.vertical": "Függőleges szerkesztőegyenes", + "cmd.sketch.construction_line.angle": "Adott szögű szerkesztőegyenes", + "cmd.sketch.construction_line.parallel": "Párhuzamos szerkesztőegyenes", + "cmd.sketch.construction_line.perpendicular": "Merőleges szerkesztőegyenes", + "cmd.sketch.construction_line.tangent_external": "Érintő külső pontból", + "cmd.sketch.construction_line.tangent_at": "Érintő a görbe pontjában", + "cmd.sketch.construction_line.tangent_two": "Közös érintő", + "cmd.sketch.construction_line.bisector": "Szögfelező", + "ui.construction.ribbon_label": "Segédvonalak" + }, + "id": { + "cmd.sketch.construction_line": "Garis bantu", + "cmd.sketch.construction_line.horizontal": "Garis bantu horizontal", + "cmd.sketch.construction_line.vertical": "Garis bantu vertikal", + "cmd.sketch.construction_line.angle": "Garis bantu bersudut", + "cmd.sketch.construction_line.parallel": "Garis bantu sejajar", + "cmd.sketch.construction_line.perpendicular": "Garis bantu tegak lurus", + "cmd.sketch.construction_line.tangent_external": "Garis singgung melalui titik luar", + "cmd.sketch.construction_line.tangent_at": "Garis singgung pada titik kurva", + "cmd.sketch.construction_line.tangent_two": "Garis singgung persekutuan", + "cmd.sketch.construction_line.bisector": "Garis bagi sudut", + "ui.construction.ribbon_label": "Garis bantu" + }, + "it": { + "cmd.sketch.construction_line": "Retta di costruzione", + "cmd.sketch.construction_line.horizontal": "Retta di costruzione orizzontale", + "cmd.sketch.construction_line.vertical": "Retta di costruzione verticale", + "cmd.sketch.construction_line.angle": "Retta di costruzione inclinata", + "cmd.sketch.construction_line.parallel": "Retta di costruzione parallela", + "cmd.sketch.construction_line.perpendicular": "Retta di costruzione perpendicolare", + "cmd.sketch.construction_line.tangent_external": "Tangente per un punto esterno", + "cmd.sketch.construction_line.tangent_at": "Tangente in un punto della curva", + "cmd.sketch.construction_line.tangent_two": "Tangente comune", + "cmd.sketch.construction_line.bisector": "Bisettrice", + "ui.construction.ribbon_label": "Linee aus." + }, + "ja": { + "cmd.sketch.construction_line": "補助直線", + "cmd.sketch.construction_line.horizontal": "水平補助直線", + "cmd.sketch.construction_line.vertical": "垂直補助直線", + "cmd.sketch.construction_line.angle": "角度指定の補助直線", + "cmd.sketch.construction_line.parallel": "平行補助直線", + "cmd.sketch.construction_line.perpendicular": "直交補助直線", + "cmd.sketch.construction_line.tangent_external": "外部点を通る接線", + "cmd.sketch.construction_line.tangent_at": "曲線上の点での接線", + "cmd.sketch.construction_line.tangent_two": "共通接線", + "cmd.sketch.construction_line.bisector": "角の二等分線", + "prefs.sketch_construction_lines": "拡張補助直線ツール", + "help.sketch.construction_line": "2点を通る無限の補助直線を作成します。スケッチの輪郭を分割せずに作図できます。", + "help.sketch.construction_line.horizontal": "指定点を通る無限の水平補助直線を作成します。後で編集しても水平拘束が維持されます。", + "help.sketch.construction_line.vertical": "指定点を通る無限の垂直補助直線を作成します。後で編集しても垂直拘束が維持されます。", + "help.sketch.construction_line.angle": "スケッチのX軸に対して角度を指定し、無限の補助直線を作成します。点を選び、角度を入力するか方向を選びます。", + "help.sketch.construction_line.parallel": "スケッチの直線を選び、平行な無限の補助直線を配置します。右クリックで参照を選び直します。", + "help.sketch.construction_line.perpendicular": "スケッチの直線を選び、直交する無限の補助直線を配置します。右クリックで参照を選び直します。", + "help.sketch.construction_line.tangent_external": "円または円弧、外部点、接線の解を順に選びます。プレビューには描かれた円弧上の接点のみが表示されます。", + "help.sketch.construction_line.tangent_at": "円や円弧上の点、または開いたスプラインや円錐曲線の端点に接線を作成します。曲線を選び、接点を選びます。", + "help.sketch.construction_line.tangent_two": "2つの円または円弧を選び、プレビューから共通接線を選びます。接点は描かれた曲線上にある必要があります。", + "help.sketch.construction_line.bisector": "交差する2本のスケッチ直線を選び、2つの角の二等分線から選びます。結果は元の直線の編集に追従します。", + "ui.construction.free_hint": "補助直線: 2点をクリック。右クリックで最初から", + "ui.construction.point_hint": "補助直線: 通過点をクリック", + "ui.construction.angle_hint": "補助直線: 点をクリックし、角度を入力するか方向を選択", + "ui.construction.reference_hint": "補助直線: 直線、点の順に選択。右クリックで参照を変更", + "ui.construction.external_hint": "接線: 円または円弧、外部点、必要な解の順に選択", + "ui.construction.contact_hint": "接線: 円/円弧または開いたスプライン/円錐曲線を選び、接点を選択 (自由曲線は端点のみ)", + "ui.construction.common_hint": "共通接線: 2つの円/円弧を選び、必要な解を選択", + "ui.construction.bisector_hint": "二等分線: 交差する2直線を選び、必要な解を選択", + "ui.construction.ribbon_label": "補助線" + }, + "ko": { + "cmd.sketch.construction_line": "보조 직선", + "cmd.sketch.construction_line.horizontal": "수평 보조 직선", + "cmd.sketch.construction_line.vertical": "수직 보조 직선", + "cmd.sketch.construction_line.angle": "각도 지정 보조 직선", + "cmd.sketch.construction_line.parallel": "평행 보조 직선", + "cmd.sketch.construction_line.perpendicular": "직교 보조 직선", + "cmd.sketch.construction_line.tangent_external": "외부 점을 지나는 접선", + "cmd.sketch.construction_line.tangent_at": "곡선 위 점에서의 접선", + "cmd.sketch.construction_line.tangent_two": "공통 접선", + "cmd.sketch.construction_line.bisector": "각의 이등분선", + "prefs.sketch_construction_lines": "확장 보조 직선 도구", + "help.sketch.construction_line": "두 점을 지나는 무한 보조 직선을 만듭니다. 스케치 프로파일을 나누지 않고 작도할 수 있습니다.", + "help.sketch.construction_line.horizontal": "한 점을 지나는 무한 수평 보조 직선을 만듭니다. 나중에 편집해도 수평 구속이 유지됩니다.", + "help.sketch.construction_line.vertical": "한 점을 지나는 무한 수직 보조 직선을 만듭니다. 나중에 편집해도 수직 구속이 유지됩니다.", + "help.sketch.construction_line.angle": "스케치 X축을 기준으로 지정한 각도의 무한 보조 직선을 만듭니다. 점을 선택한 뒤 각도를 입력하거나 방향을 선택합니다.", + "help.sketch.construction_line.parallel": "스케치 직선을 선택한 뒤 평행한 무한 보조 직선을 배치합니다. 다른 참조를 선택하려면 마우스 오른쪽 버튼을 클릭합니다.", + "help.sketch.construction_line.perpendicular": "스케치 직선을 선택한 뒤 직교하는 무한 보조 직선을 배치합니다. 다른 참조를 선택하려면 마우스 오른쪽 버튼을 클릭합니다.", + "help.sketch.construction_line.tangent_external": "원 또는 원호, 외부 점, 접선 해를 차례로 선택합니다. 미리보기에는 그려진 원호 위의 접점만 표시됩니다.", + "help.sketch.construction_line.tangent_at": "원이나 원호 위의 점, 또는 열린 스플라인이나 원뿔 곡선의 끝점에 접선을 만듭니다. 곡선을 선택한 뒤 접점을 선택합니다.", + "help.sketch.construction_line.tangent_two": "두 원 또는 원호를 선택한 뒤 미리보기에서 공통 접선을 선택합니다. 접점은 그려진 곡선 위에 있어야 합니다.", + "help.sketch.construction_line.bisector": "교차하는 두 스케치 직선을 선택한 뒤 두 각의 이등분선 중 하나를 선택합니다. 결과는 원본 직선의 편집을 따릅니다.", + "ui.construction.free_hint": "보조 직선: 두 점 클릭; 마우스 오른쪽 버튼으로 다시 시작", + "ui.construction.point_hint": "보조 직선: 통과할 점 클릭", + "ui.construction.angle_hint": "보조 직선: 점 클릭 후 각도 입력 또는 방향 선택", + "ui.construction.reference_hint": "보조 직선: 직선 선택 후 점 선택; 마우스 오른쪽 버튼으로 참조 변경", + "ui.construction.external_hint": "접선: 원 또는 원호, 외부 점, 원하는 해를 차례로 선택", + "ui.construction.contact_hint": "접선: 원/원호 또는 열린 스플라인/원뿔 곡선 선택 후 접점 선택 (자유 곡선은 끝점만)", + "ui.construction.common_hint": "공통 접선: 두 원/원호 선택 후 원하는 해 선택", + "ui.construction.bisector_hint": "이등분선: 교차하는 두 직선 선택 후 원하는 해 선택", + "ui.construction.ribbon_label": "보조선" + }, + "ms": { + "cmd.sketch.construction_line": "Garis binaan", + "cmd.sketch.construction_line.horizontal": "Garis binaan mendatar", + "cmd.sketch.construction_line.vertical": "Garis binaan menegak", + "cmd.sketch.construction_line.angle": "Garis binaan bersudut", + "cmd.sketch.construction_line.parallel": "Garis binaan selari", + "cmd.sketch.construction_line.perpendicular": "Garis binaan serenjang", + "cmd.sketch.construction_line.tangent_external": "Tangen melalui titik luar", + "cmd.sketch.construction_line.tangent_at": "Tangen pada titik lengkung", + "cmd.sketch.construction_line.tangent_two": "Tangen sepunya", + "cmd.sketch.construction_line.bisector": "Pembahagi dua sudut", + "ui.construction.ribbon_label": "Garis bantu" + }, + "nb": { + "cmd.sketch.construction_line": "Hjelpelinje", + "cmd.sketch.construction_line.horizontal": "Vannrett hjelpelinje", + "cmd.sketch.construction_line.vertical": "Loddrett hjelpelinje", + "cmd.sketch.construction_line.angle": "Hjelpelinje med vinkel", + "cmd.sketch.construction_line.parallel": "Parallell hjelpelinje", + "cmd.sketch.construction_line.perpendicular": "Vinkelrett hjelpelinje", + "cmd.sketch.construction_line.tangent_external": "Tangent gjennom eksternt punkt", + "cmd.sketch.construction_line.tangent_at": "Tangent i kurvepunkt", + "cmd.sketch.construction_line.tangent_two": "Felles tangent", + "cmd.sketch.construction_line.bisector": "Vinkelhalveringslinje", + "ui.construction.ribbon_label": "Hjelpelinjer" + }, + "nl": { + "cmd.sketch.construction_line": "Constructielijn", + "cmd.sketch.construction_line.horizontal": "Horizontale constructielijn", + "cmd.sketch.construction_line.vertical": "Verticale constructielijn", + "cmd.sketch.construction_line.angle": "Constructielijn onder hoek", + "cmd.sketch.construction_line.parallel": "Parallelle constructielijn", + "cmd.sketch.construction_line.perpendicular": "Loodrechte constructielijn", + "cmd.sketch.construction_line.tangent_external": "Raaklijn door extern punt", + "cmd.sketch.construction_line.tangent_at": "Raaklijn in punt op kromme", + "cmd.sketch.construction_line.tangent_two": "Gemeenschappelijke raaklijn", + "cmd.sketch.construction_line.bisector": "Bissectrice", + "ui.construction.ribbon_label": "Hulplijnen" + }, + "pl": { + "cmd.sketch.construction_line": "Prosta konstrukcyjna", + "cmd.sketch.construction_line.horizontal": "Pozioma prosta konstrukcyjna", + "cmd.sketch.construction_line.vertical": "Pionowa prosta konstrukcyjna", + "cmd.sketch.construction_line.angle": "Prosta konstrukcyjna pod kątem", + "cmd.sketch.construction_line.parallel": "Równoległa prosta konstrukcyjna", + "cmd.sketch.construction_line.perpendicular": "Prostopadła prosta konstrukcyjna", + "cmd.sketch.construction_line.tangent_external": "Styczna przez punkt zewnętrzny", + "cmd.sketch.construction_line.tangent_at": "Styczna w punkcie krzywej", + "cmd.sketch.construction_line.tangent_two": "Wspólna styczna", + "cmd.sketch.construction_line.bisector": "Dwusieczna kąta", + "ui.construction.ribbon_label": "Linie pom." + }, + "pt-BR": { + "cmd.sketch.construction_line": "Reta de construção", + "cmd.sketch.construction_line.horizontal": "Reta de construção horizontal", + "cmd.sketch.construction_line.vertical": "Reta de construção vertical", + "cmd.sketch.construction_line.angle": "Reta de construção em ângulo", + "cmd.sketch.construction_line.parallel": "Reta de construção paralela", + "cmd.sketch.construction_line.perpendicular": "Reta de construção perpendicular", + "cmd.sketch.construction_line.tangent_external": "Tangente por um ponto externo", + "cmd.sketch.construction_line.tangent_at": "Tangente em um ponto da curva", + "cmd.sketch.construction_line.tangent_two": "Tangente comum", + "cmd.sketch.construction_line.bisector": "Bissetriz", + "ui.construction.ribbon_label": "Linhas aux." + }, + "ro": { + "cmd.sketch.construction_line": "Dreaptă de construcție", + "cmd.sketch.construction_line.horizontal": "Dreaptă de construcție orizontală", + "cmd.sketch.construction_line.vertical": "Dreaptă de construcție verticală", + "cmd.sketch.construction_line.angle": "Dreaptă de construcție la un unghi", + "cmd.sketch.construction_line.parallel": "Dreaptă de construcție paralelă", + "cmd.sketch.construction_line.perpendicular": "Dreaptă de construcție perpendiculară", + "cmd.sketch.construction_line.tangent_external": "Tangentă printr-un punct exterior", + "cmd.sketch.construction_line.tangent_at": "Tangentă într-un punct al curbei", + "cmd.sketch.construction_line.tangent_two": "Tangentă comună", + "cmd.sketch.construction_line.bisector": "Bisectoare", + "ui.construction.ribbon_label": "Linii aux." + }, + "ru": { + "cmd.sketch.construction_line": "Вспомогательная прямая", + "cmd.sketch.construction_line.horizontal": "Горизонтальная вспомогательная прямая", + "cmd.sketch.construction_line.vertical": "Вертикальная вспомогательная прямая", + "cmd.sketch.construction_line.angle": "Вспомогательная прямая под углом", + "cmd.sketch.construction_line.parallel": "Параллельная вспомогательная прямая", + "cmd.sketch.construction_line.perpendicular": "Перпендикулярная вспомогательная прямая", + "cmd.sketch.construction_line.tangent_external": "Касательная через внешнюю точку", + "cmd.sketch.construction_line.tangent_at": "Касательная в точке кривой", + "cmd.sketch.construction_line.tangent_two": "Общая касательная", + "cmd.sketch.construction_line.bisector": "Биссектриса", + "ui.construction.free_hint": "Вспомогательная прямая: укажите две точки; правая кнопка — начать заново", + "ui.construction.point_hint": "Вспомогательная прямая: укажите точку прохождения", + "ui.construction.angle_hint": "Вспомогательная прямая: укажите точку, затем введите угол или задайте направление", + "ui.construction.reference_hint": "Выберите прямую, затем точку; правая кнопка — сменить исходную прямую", + "ui.construction.external_hint": "Касательная: выберите окружность или дугу, внешнюю точку, затем нужное решение", + "ui.construction.contact_hint": "Касательная: выберите окружность/дугу или открытый сплайн/конику, затем точку касания (для сплайна/коники — конец)", + "ui.construction.common_hint": "Общая касательная: выберите две окружности/дуги, затем нужное решение", + "ui.construction.bisector_hint": "Биссектриса: выберите две пересекающиеся прямые, затем нужное решение", + "prefs.sketch_construction_lines": "Расширенные инструменты вспомогательных прямых", + "ui.construction.ribbon_label": "Всп. линии" + }, + "sr": { + "cmd.sketch.construction_line": "Помоћна права", + "cmd.sketch.construction_line.horizontal": "Хоризонтална помоћна права", + "cmd.sketch.construction_line.vertical": "Вертикална помоћна права", + "cmd.sketch.construction_line.angle": "Помоћна права под углом", + "cmd.sketch.construction_line.parallel": "Паралелна помоћна права", + "cmd.sketch.construction_line.perpendicular": "Нормална помоћна права", + "cmd.sketch.construction_line.tangent_external": "Тангента кроз спољашњу тачку", + "cmd.sketch.construction_line.tangent_at": "Тангента у тачки криве", + "cmd.sketch.construction_line.tangent_two": "Заједничка тангента", + "cmd.sketch.construction_line.bisector": "Симетрала угла", + "ui.construction.ribbon_label": "Пом. праве" + }, + "sv": { + "cmd.sketch.construction_line": "Konstruktionslinje", + "cmd.sketch.construction_line.horizontal": "Horisontell konstruktionslinje", + "cmd.sketch.construction_line.vertical": "Vertikal konstruktionslinje", + "cmd.sketch.construction_line.angle": "Konstruktionslinje med vinkel", + "cmd.sketch.construction_line.parallel": "Parallell konstruktionslinje", + "cmd.sketch.construction_line.perpendicular": "Vinkelrät konstruktionslinje", + "cmd.sketch.construction_line.tangent_external": "Tangent genom yttre punkt", + "cmd.sketch.construction_line.tangent_at": "Tangent i kurvpunkt", + "cmd.sketch.construction_line.tangent_two": "Gemensam tangent", + "cmd.sketch.construction_line.bisector": "Vinkelbisektris", + "ui.construction.ribbon_label": "Hjälplinjer" + }, + "tr": { + "cmd.sketch.construction_line": "Yardımcı doğru", + "cmd.sketch.construction_line.horizontal": "Yatay yardımcı doğru", + "cmd.sketch.construction_line.vertical": "Dikey yardımcı doğru", + "cmd.sketch.construction_line.angle": "Açılı yardımcı doğru", + "cmd.sketch.construction_line.parallel": "Paralel yardımcı doğru", + "cmd.sketch.construction_line.perpendicular": "Dik yardımcı doğru", + "cmd.sketch.construction_line.tangent_external": "Dış noktadan geçen teğet", + "cmd.sketch.construction_line.tangent_at": "Eğri noktasındaki teğet", + "cmd.sketch.construction_line.tangent_two": "Ortak teğet", + "cmd.sketch.construction_line.bisector": "Açıortay", + "ui.construction.ribbon_label": "Yardımcılar" + }, + "uk": { + "cmd.sketch.construction_line": "Допоміжна пряма", + "cmd.sketch.construction_line.horizontal": "Горизонтальна допоміжна пряма", + "cmd.sketch.construction_line.vertical": "Вертикальна допоміжна пряма", + "cmd.sketch.construction_line.angle": "Допоміжна пряма під кутом", + "cmd.sketch.construction_line.parallel": "Паралельна допоміжна пряма", + "cmd.sketch.construction_line.perpendicular": "Перпендикулярна допоміжна пряма", + "cmd.sketch.construction_line.tangent_external": "Дотична через зовнішню точку", + "cmd.sketch.construction_line.tangent_at": "Дотична в точці кривої", + "cmd.sketch.construction_line.tangent_two": "Спільна дотична", + "cmd.sketch.construction_line.bisector": "Бісектриса", + "ui.construction.ribbon_label": "Доп. лінії" + }, + "vi": { + "cmd.sketch.construction_line": "Đường thẳng dựng hình", + "cmd.sketch.construction_line.horizontal": "Đường dựng hình nằm ngang", + "cmd.sketch.construction_line.vertical": "Đường dựng hình thẳng đứng", + "cmd.sketch.construction_line.angle": "Đường dựng hình theo góc", + "cmd.sketch.construction_line.parallel": "Đường dựng hình song song", + "cmd.sketch.construction_line.perpendicular": "Đường dựng hình vuông góc", + "cmd.sketch.construction_line.tangent_external": "Tiếp tuyến qua điểm ngoài", + "cmd.sketch.construction_line.tangent_at": "Tiếp tuyến tại điểm trên đường cong", + "cmd.sketch.construction_line.tangent_two": "Tiếp tuyến chung", + "cmd.sketch.construction_line.bisector": "Đường phân giác", + "prefs.sketch_construction_lines": "Công cụ đường dựng hình mở rộng", + "help.sketch.construction_line": "Tạo đường thẳng dựng hình vô hạn qua hai điểm để bố trí phác thảo mà không chia tách biên dạng.", + "help.sketch.construction_line.horizontal": "Tạo đường dựng hình nằm ngang vô hạn qua một điểm. Ràng buộc ngang được giữ khi chỉnh sửa sau này.", + "help.sketch.construction_line.vertical": "Tạo đường dựng hình thẳng đứng vô hạn qua một điểm. Ràng buộc đứng được giữ khi chỉnh sửa sau này.", + "help.sketch.construction_line.angle": "Tạo đường dựng hình vô hạn theo góc so với trục X của phác thảo. Chọn điểm rồi nhập góc hoặc chọn hướng.", + "help.sketch.construction_line.parallel": "Chọn đường thẳng trong phác thảo rồi đặt đường dựng hình vô hạn song song. Nhấp chuột phải để đổi tham chiếu.", + "help.sketch.construction_line.perpendicular": "Chọn đường thẳng trong phác thảo rồi đặt đường dựng hình vô hạn vuông góc. Nhấp chuột phải để đổi tham chiếu.", + "help.sketch.construction_line.tangent_external": "Chọn đường tròn hoặc cung tròn, một điểm ngoài rồi chọn nghiệm tiếp tuyến. Bản xem trước chỉ hiển thị tiếp điểm trên cung đã vẽ.", + "help.sketch.construction_line.tangent_at": "Tạo tiếp tuyến tại một điểm trên đường tròn hoặc cung tròn, hoặc tại đầu mút của spline hay đường conic hở. Chọn đường cong rồi chọn tiếp điểm.", + "help.sketch.construction_line.tangent_two": "Chọn hai đường tròn hoặc cung tròn rồi chọn tiếp tuyến chung trong bản xem trước. Tiếp điểm phải nằm trên các đường cong đã vẽ.", + "help.sketch.construction_line.bisector": "Chọn hai đường thẳng giao nhau trong phác thảo rồi chọn một trong hai đường phân giác. Kết quả thay đổi theo các đường gốc.", + "ui.construction.free_hint": "Đường dựng hình: nhấp hai điểm; nhấp chuột phải để bắt đầu lại", + "ui.construction.point_hint": "Đường dựng hình: nhấp điểm đi qua", + "ui.construction.angle_hint": "Đường dựng hình: nhấp một điểm rồi nhập góc hoặc chọn hướng", + "ui.construction.reference_hint": "Đường dựng hình: chọn đường thẳng rồi chọn điểm; nhấp chuột phải để đổi tham chiếu", + "ui.construction.external_hint": "Tiếp tuyến: chọn đường tròn hoặc cung, điểm ngoài rồi chọn nghiệm mong muốn", + "ui.construction.contact_hint": "Tiếp tuyến: chọn đường tròn/cung hoặc spline/conic hở rồi chọn tiếp điểm (đường cong tự do: chỉ đầu mút)", + "ui.construction.common_hint": "Tiếp tuyến chung: chọn hai đường tròn/cung rồi chọn nghiệm mong muốn", + "ui.construction.bisector_hint": "Phân giác: chọn hai đường thẳng giao nhau rồi chọn nghiệm mong muốn", + "ui.construction.ribbon_label": "Đường phụ" + }, + "zh": { + "cmd.sketch.construction_line": "构造直线", + "cmd.sketch.construction_line.horizontal": "水平构造直线", + "cmd.sketch.construction_line.vertical": "竖直构造直线", + "cmd.sketch.construction_line.angle": "指定角度构造直线", + "cmd.sketch.construction_line.parallel": "平行构造直线", + "cmd.sketch.construction_line.perpendicular": "垂直构造直线", + "cmd.sketch.construction_line.tangent_external": "过外部点的切线", + "cmd.sketch.construction_line.tangent_at": "曲线上点处的切线", + "cmd.sketch.construction_line.tangent_two": "公切线", + "cmd.sketch.construction_line.bisector": "角平分线", + "prefs.sketch_construction_lines": "扩展构造直线工具", + "help.sketch.construction_line": "创建经过两点的无限构造直线,用于辅助绘制草图而不分割轮廓。", + "help.sketch.construction_line.horizontal": "创建经过指定点的无限水平构造直线。后续编辑时保持水平约束。", + "help.sketch.construction_line.vertical": "创建经过指定点的无限竖直构造直线。后续编辑时保持竖直约束。", + "help.sketch.construction_line.angle": "创建与草图X轴成指定角度的无限构造直线。选择一点后输入角度或选择方向。", + "help.sketch.construction_line.parallel": "选择草图直线,然后放置与其平行的无限构造直线。右键单击可更换参照。", + "help.sketch.construction_line.perpendicular": "选择草图直线,然后放置与其垂直的无限构造直线。右键单击可更换参照。", + "help.sketch.construction_line.tangent_external": "依次选择圆或圆弧、外部点和所需切线。预览仅显示接点位于已绘圆弧上的解。", + "help.sketch.construction_line.tangent_at": "在圆或圆弧上的点处,或开放样条曲线、圆锥曲线的端点处创建切线。先选曲线,再选接点。", + "help.sketch.construction_line.tangent_two": "选择两个圆或圆弧,再从预览中选择公切线。接点必须位于已绘曲线上。", + "help.sketch.construction_line.bisector": "选择两条相交的草图直线,再选择所需的角平分线。结果随原直线的编辑而变化。", + "ui.construction.free_hint": "构造直线:单击两点;右键单击重新开始", + "ui.construction.point_hint": "构造直线:单击要经过的点", + "ui.construction.angle_hint": "构造直线:单击一点,然后输入角度或选择方向", + "ui.construction.reference_hint": "构造直线:先选直线,再选一点;右键单击更换参照", + "ui.construction.external_hint": "切线:依次选择圆或圆弧、外部点和所需解", + "ui.construction.contact_hint": "切线:先选圆/圆弧或开放样条曲线/圆锥曲线,再选接点(自由曲线仅支持端点)", + "ui.construction.common_hint": "公切线:选择两个圆/圆弧,再选择所需解", + "ui.construction.bisector_hint": "角平分线:选择两条相交直线,再选择所需解", + "ui.construction.ribbon_label": "辅助线" + }, + "zh-TW": { + "cmd.sketch.construction_line": "建構直線", + "cmd.sketch.construction_line.horizontal": "水平建構直線", + "cmd.sketch.construction_line.vertical": "鉛直建構直線", + "cmd.sketch.construction_line.angle": "指定角度建構直線", + "cmd.sketch.construction_line.parallel": "平行建構直線", + "cmd.sketch.construction_line.perpendicular": "垂直建構直線", + "cmd.sketch.construction_line.tangent_external": "通過外部點的切線", + "cmd.sketch.construction_line.tangent_at": "曲線上點的切線", + "cmd.sketch.construction_line.tangent_two": "公切線", + "cmd.sketch.construction_line.bisector": "角平分線", + "ui.construction.ribbon_label": "輔助線" + }, + "en-GB": { + "cmd.sketch.construction_line": "Construction Line", + "cmd.sketch.construction_line.horizontal": "Horizontal Construction Line", + "cmd.sketch.construction_line.vertical": "Vertical Construction Line", + "cmd.sketch.construction_line.angle": "Construction Line at Angle", + "cmd.sketch.construction_line.parallel": "Parallel Construction Line", + "cmd.sketch.construction_line.perpendicular": "Perpendicular Construction Line", + "cmd.sketch.construction_line.tangent_external": "Tangent through External Point", + "cmd.sketch.construction_line.tangent_at": "Tangent at Curve Point", + "cmd.sketch.construction_line.tangent_two": "Common Tangent", + "cmd.sketch.construction_line.bisector": "Angle Bisector", + "prefs.sketch_construction_lines": "Extended construction line tools", + "ui.construction.ribbon_label": "X-Lines" + } +} diff --git a/attribution/pending/construction-lines.md b/attribution/pending/construction-lines.md new file mode 100644 index 000000000..bcbc280b3 --- /dev/null +++ b/attribution/pending/construction-lines.md @@ -0,0 +1,10 @@ +| assets/icons/ui/design/svg/model/construction_line.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_horizontal.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_vertical.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_angle.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_parallel.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_perpendicular.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_tangent_external.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_tangent_at.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_tangent_two.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/construction_line_bisector.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | diff --git a/crates/engine/src/cmd/mod.rs b/crates/engine/src/cmd/mod.rs index 747073d5a..6e9f0689b 100644 --- a/crates/engine/src/cmd/mod.rs +++ b/crates/engine/src/cmd/mod.rs @@ -42,6 +42,7 @@ pub(crate) use features::{EdgeRefForm, axis_dir_form, edge_ref_form, sketch_key} pub use features::{auto_operation, extrude_reach, shown_scope}; pub use join_pieces::{Addition, addition}; pub use sketch::dimension_roles; +pub use sketch_construction::{ConstructionLine, construction_line_choice, construction_line_mode, construction_line_solutions}; pub use sketch_import::drawing_import_command; pub use sketch_modify::{extend_arc_preview, extend_preview, trim_piece}; pub use view_dxf::sketch::exportable as view_dxf_exportable; @@ -93,6 +94,7 @@ mod sketch_3d; mod sketch_canvas; pub mod sketch_clipboard; mod sketch_constraints; +mod sketch_construction; mod sketch_create; mod sketch_ends; mod sketch_equation; @@ -288,6 +290,7 @@ pub fn command_specs() -> Vec<&'static CommandSpec> { let mut v: Vec<&'static CommandSpec> = Vec::new(); v.extend(sketch::COMMANDS.iter()); v.extend(sketch_create::COMMANDS.iter()); + v.extend(sketch_construction::COMMANDS.iter()); v.extend(sketch_equation::COMMANDS.iter()); v.extend(sketch_constraints::COMMANDS.iter()); v.extend(sketch_import::COMMANDS.iter()); diff --git a/crates/engine/src/cmd/sketch_construction.rs b/crates/engine/src/cmd/sketch_construction.rs new file mode 100644 index 000000000..bac231724 --- /dev/null +++ b/crates/engine/src/cmd/sketch_construction.rs @@ -0,0 +1,349 @@ +//! Fast infinite reference lines. Preview and creation use the same analytic solutions. + +use serde_json::{Value, json}; +use solidcraft_geom::{Seg2, Vec2}; +use solidcraft_sketch::{ConstraintKind, CurveKind, Sketch}; + +use super::sketch::{add_c, curve_ref, edit, ids_of, line_or_axis_ref, line_pts, req_parg, result}; +use super::{CommandSpec, in_sketch}; +use crate::params::{bad, expr, num, str_, vec2}; +use crate::schema::sketch_create::{ConstructionLineParams, ConstructionLineResult}; +use crate::schema::{TypedContract, output_schema_for}; +use crate::{Result, Session}; + +const CONTRACT: TypedContract = TypedContract::new(); +const CMD: &str = "sketch.construction_line"; + +macro_rules! variant { + ($id:literal, $label:literal, $mode:literal) => { + CommandSpec::new($id, $label, |s, p| { + crate::schema::run_checked_as(s, p, $id, |s, p| run(s, p, $mode)) + }) + .at("SKETCH", "CREATE") + .enabled(in_sketch) + .contract(&CONTRACT) + .output(output_schema_for::) + .params(concat!("Infinite construction line, ", $mode, ". at: point; through?: second point; curve?, curve2?: sketch references; angle?: degrees from sketch X; near?: solution selector; solution?: zero-based solution index. Tangents take circles/arcs, or an open spline/conic endpoint for tangent_at.", created_doc!())) + }; +} + +pub static COMMANDS: &[CommandSpec] = &[ + variant!("sketch.construction_line", "Construction Line", "free").icon("construction_line"), + variant!("sketch.construction_line.horizontal", "Horizontal Construction Line", "horizontal").icon("construction_line_horizontal"), + variant!("sketch.construction_line.vertical", "Vertical Construction Line", "vertical").icon("construction_line_vertical"), + variant!("sketch.construction_line.angle", "Construction Line at Angle", "angle").icon("construction_line_angle"), + variant!("sketch.construction_line.parallel", "Parallel Construction Line", "parallel").icon("construction_line_parallel"), + variant!("sketch.construction_line.perpendicular", "Perpendicular Construction Line", "perpendicular").icon("construction_line_perpendicular"), + variant!("sketch.construction_line.tangent_external", "Tangent through External Point", "tangent_external") + .icon("construction_line_tangent_external"), + variant!("sketch.construction_line.tangent_at", "Tangent at Curve Point", "tangent_at").icon("construction_line_tangent_at"), + variant!("sketch.construction_line.tangent_two", "Common Tangent", "tangent_two").icon("construction_line_tangent_two"), + variant!("sketch.construction_line.bisector", "Angle Bisector", "bisector").icon("construction_line_bisector"), +]; + +/// One mathematical solution, before adding any sketch entities. +#[derive(Clone, Copy, Debug)] +pub struct ConstructionLine { + pub start: Vec2, + pub direction: Vec2, +} + +impl ConstructionLine { + fn distance(self, p: Vec2) -> f64 { + (p - self.start).cross(self.direction).abs() + } +} + +/// The method belonging to an interactive command. The generic command defaults to two points. +pub fn construction_line_mode(id: &str) -> Option<&str> { + if id == CMD { Some("free") } else { id.strip_prefix("sketch.construction_line.") } +} + +fn point(sk: &Sketch, v: Option<&Value>, key: &str) -> Result { + v.and_then(|v| vec2(v).or_else(|| v.as_str().and_then(|id| sk.resolve_point(id)).and_then(|i| sk.point(i)))) + .ok_or_else(|| bad(CMD, format!("`{key}` must be a finite point or sketch point reference"))) +} + +fn reference(sk: &Sketch, p: &Value, key: &str) -> Result { + curve_ref(sk, p.get(key), CMD, key) +} + +fn line(sk: &Sketch, p: &Value, key: &str) -> Result<(Vec2, Vec2)> { + match str_(p, key) { + Some("x") if sk.curve_index("x").is_none() => Ok((Vec2::ZERO, Vec2::X)), + Some("y") if sk.curve_index("y").is_none() => Ok((Vec2::ZERO, Vec2::Y)), + _ => line_pts(sk, reference(sk, p, key)?).ok_or_else(|| bad(CMD, "the reference must be a straight line")), + } +} + +fn round(sk: &Sketch, i: usize) -> Result<(Vec2, f64)> { + let c = sk.center(i).ok_or_else(|| bad(CMD, "the reference must be a circle or circular arc"))?; + let r = sk + .radius(i) + .filter(|r| r.is_finite() && *r > 1e-9) + .ok_or_else(|| bad(CMD, "the reference must be a non-degenerate circle or circular arc"))?; + Ok((c, r)) +} + +/// A circular arc accepts tangency on its drawn sweep, including either end. +fn on_sweep(sk: &Sketch, i: usize, q: Vec2) -> bool { + if matches!(sk.curves.get(i).map(|c| &c.kind), Some(CurveKind::Circle { .. })) { + return true; + } + sk.segs(i).iter().any(|s| match s { + Seg2::Arc { center, start, sweep, .. } => { + let theta = (q - *center).angle(); + let span = if *sweep >= 0.0 { theta - start } else { start - theta }; + span.rem_euclid(std::f64::consts::TAU) <= sweep.abs() + 1e-8 || span.rem_euclid(std::f64::consts::TAU) > std::f64::consts::TAU - 1e-8 + } + _ => false, + }) +} + +fn endpoint_tangent(sk: &Sketch, i: usize, at: Vec2) -> Option<(usize, Vec2)> { + let ends = sk.curves.get(i)?.kind.ends()?; + [ends.0, ends.1].into_iter().find_map(|pi| { + let q = sk.point(pi)?; + (q.dist(at) <= 1e-6).then(|| super::sketch_create::leaving_dir(sk, i, pi).map(|d| (pi, d))).flatten() + }) +} + +/// All valid solutions in deterministic order. This reads the sketch and never changes it. +pub fn construction_line_solutions(sk: &Sketch, p: &Value, mode: &str) -> Result> { + let at = point(sk, p.get("at"), "at")?; + let mut out = Vec::new(); + let mut push = |start: Vec2, d: Vec2| { + if let Some(direction) = d.normalized() + && start.is_finite() + && direction.is_finite() + { + out.push(ConstructionLine { start, direction }); + } + }; + match mode { + "free" => push(at, point(sk, p.get("through"), "through")? - at), + "horizontal" => push(at, Vec2::X), + "vertical" => push(at, Vec2::Y), + "angle" => { + let a = num(p, "angle").ok_or_else(|| bad(CMD, "`angle` must be finite degrees"))?; + push(at, Vec2::from_angle(a.rem_euclid(360.0).to_radians())); + } + "parallel" | "perpendicular" => { + let (a, b) = line(sk, p, "curve")?; + push(at, if mode == "parallel" { b - a } else { (b - a).perp() }); + } + "bisector" => { + let (a, b) = line(sk, p, "curve")?; + let (c, d) = line(sk, p, "curve2")?; + let u = (b - a).normalized().ok_or_else(|| bad(CMD, "the reference has no direction"))?; + let v = (d - c).normalized().ok_or_else(|| bad(CMD, "the reference has no direction"))?; + let cross = u.cross(v); + if cross.abs() < 1e-9 { + return Err(bad(CMD, "the two lines must intersect")); + } + let origin = a + u * ((c - a).cross(v) / cross); + push(origin, u + v); + push(origin, u - v); + } + "tangent_at" => { + let i = reference(sk, p, "curve")?; + if let Ok((c, r)) = round(sk, i) { + let radial = (at - c).normalized().ok_or_else(|| bad(CMD, "the point must differ from the centre"))?; + let q = c + radial * r; + if on_sweep(sk, i, q) { + push(q, radial.perp()); + } + } else if let Some((pi, d)) = endpoint_tangent(sk, i, at) { + push(sk.point(pi).unwrap_or(at), d); + } else { + return Err(bad(CMD, "pick a point on a circle/arc, or an endpoint of an open spline or conic")); + } + } + "tangent_external" => { + let i = reference(sk, p, "curve")?; + let (c, r) = round(sk, i)?; + let delta = at - c; + let distance = delta.len(); + if distance <= r + 1e-9 { + return Err(bad(CMD, "the point must be outside the circle or arc")); + } + let u = delta / distance; + let ratio = r / distance; + for side in [1.0, -1.0] { + let contact = c + (u * ratio + u.perp() * (side * (1.0 - ratio * ratio).max(0.0).sqrt())) * r; + if on_sweep(sk, i, contact) { + push(at, contact - at); + } + } + } + "tangent_two" => { + let a = reference(sk, p, "curve")?; + let b = reference(sk, p, "curve2")?; + if a == b { + return Err(bad(CMD, "choose two different curves")); + } + let (c1, r1) = round(sk, a)?; + let (c2, r2) = round(sk, b)?; + let delta = c2 - c1; + let distance = delta.len(); + let u = delta.normalized().ok_or_else(|| bad(CMD, "concentric curves have no unique common tangent"))?; + for sign in [1.0, -1.0] { + let along = (r1 - sign * r2) / distance; + if along.abs() > 1.0 + 1e-12 { + continue; + } + let along = along.clamp(-1.0, 1.0); + for side in [1.0, -1.0] { + let n = u * along + u.perp() * (side * (1.0 - along * along).max(0.0).sqrt()); + let q1 = c1 + n * r1; + let q2 = c2 + n * (sign * r2); + if on_sweep(sk, a, q1) && on_sweep(sk, b, q2) { + push(q1, n.perp()); + } + } + } + } + _ => return Err(bad(CMD, "unknown construction method")), + } + out.dedup_by(|a, b| a.direction.cross(b.direction).abs() < 1e-9 && a.distance(b.start) < 1e-8); + if out.is_empty() { + return Err(bad(CMD, "no construction line satisfies these inputs")); + } + if out.iter().any(|l| l.start.x.abs() >= 1e9 || l.start.y.abs() >= 1e9) { + return Err(bad(CMD, "the construction is outside the supported coordinate range")); + } + Ok(out) +} + +/// Which preview solution a click selects. Equal distances keep the deterministic first one. +pub fn construction_line_choice(lines: &[ConstructionLine], p: &Value) -> Result { + if let Some(v) = p.get("solution") { + let i = v.as_u64().and_then(|i| usize::try_from(i).ok()).filter(|i| *i < lines.len()); + return i.ok_or_else(|| bad(CMD, "`solution` is outside the available solutions")); + } + if let Some(near) = p.get("near") { + let near = vec2(near).ok_or_else(|| bad(CMD, "`near` must be a finite point"))?; + return lines + .iter() + .enumerate() + .min_by(|(_, a), (_, b)| a.distance(near).total_cmp(&b.distance(near))) + .map(|(i, _)| i) + .ok_or_else(|| bad(CMD, "there are no solutions")); + } + if p.get("alternate").is_some_and(|v| !v.is_boolean()) { + return Err(bad(CMD, "`alternate` must be a boolean")); + } + Ok(usize::from(p.get("alternate").and_then(Value::as_bool).unwrap_or(false)).min(lines.len().saturating_sub(1))) +} + +fn run(s: &mut Session, p: &Value, default_mode: &str) -> Result { + let mode = str_(p, "mode").unwrap_or(default_mode); + if default_mode != "free" && mode != default_mode { + return Err(bad(CMD, "`mode` does not match this construction command")); + } + let p = super::sketch_project::snap_points(s, p, CMD)?; + let (out, info) = edit(s, &p, CMD, true, |sk, doc| { + let first_new = sk.points.len(); + let at = req_parg(sk, doc, &p, "at", CMD)?; + let through = if mode == "free" { Some(req_parg(sk, doc, &p, "through", CMD)?) } else { None }; + let mut params = p.clone(); + params["at"] = json!([at.pos().x, at.pos().y]); + let angle_expression = if mode == "angle" { + let e = expr(&p, "angle").ok_or_else(|| bad(CMD, "`angle` must be an angle or expression"))?; + let e = doc.with_design_unit(e.as_str(), solidcraft_doc::expr::Kind::Angle); + let radians = doc.eval(&e, solidcraft_doc::expr::Kind::Angle).map_err(|e| bad(CMD, format!("angle: {e}")))?; + if !radians.is_finite() || radians.abs() > 1e9 { + return Err(bad(CMD, "angle is outside the supported range")); + } + params["angle"] = json!(radians.to_degrees()); + Some(e) + } else { + None + }; + if let Some(q) = &through { + params["through"] = json!([q.pos().x, q.pos().y]); + } + let reference = if matches!(mode, "parallel" | "perpendicular" | "bisector") { + Some(line_or_axis_ref(sk, p.get("curve"), CMD, "curve")?) + } else if mode.starts_with("tangent_") { + Some(curve_ref(sk, p.get("curve"), CMD, "curve")?) + } else { + None + }; + let second = if mode == "bisector" { + Some(line_or_axis_ref(sk, p.get("curve2"), CMD, "curve2")?) + } else if mode == "tangent_two" { + Some(curve_ref(sk, p.get("curve2"), CMD, "curve2")?) + } else { + None + }; + let solutions = construction_line_solutions(sk, ¶ms, mode)?; + let choice = construction_line_choice(&solutions, ¶ms)?; + let chosen = solutions.get(choice).ok_or_else(|| bad(CMD, "no solution"))?; + let start_ref = if mode == "tangent_at" { + if let Some(i) = at.idx() { + if at.pos().dist(chosen.start) > 1e-6 { + return Err(bad(CMD, "the referenced point must lie on the curve")); + } + Some(i) + } else { + reference.and_then(|i| endpoint_tangent(sk, i, chosen.start).map(|(pi, _)| pi)) + } + } else if matches!(mode, "tangent_two" | "bisector") { + None + } else { + at.idx() + }; + let end = through.as_ref().map_or(chosen.start + chosen.direction * 10.0, |q| q.pos()); + let l = sk.add_line(chosen.start, end, start_ref, through.as_ref().and_then(|q| q.idx()), None)?; + if let Some(c) = sk.curves.get_mut(l) { + c.infinite = true; + c.construction = true; + } + let mut cons = Vec::new(); + let kind = match (mode, reference) { + ("horizontal", _) => Some(ConstraintKind::Horizontal { l }), + ("vertical", _) => Some(ConstraintKind::Vertical { l }), + ("angle", _) => Some(ConstraintKind::LineAngle { l, value: chosen.direction.angle() }), + ("parallel", Some(b)) => Some(ConstraintKind::Parallel { a: l, b }), + ("perpendicular", Some(b)) => Some(ConstraintKind::Perpendicular { a: l, b }), + ("tangent_at" | "tangent_external" | "tangent_two", Some(b)) => Some(ConstraintKind::Tangent { a: l, b }), + _ => None, + }; + if let Some(k) = kind { + let parameter = angle_expression.map(|e| doc.new_model_param(&e, "deg")); + cons.push(sk.add_constraint(k, parameter)?); + } + if let ("tangent_two", Some(b)) = (mode, second) { + cons.push(add_c(sk, ConstraintKind::Tangent { a: l, b })?); + } + let start = sk.curves.get(l).and_then(|c| c.kind.ends()).map(|(a, _)| a).ok_or_else(|| bad(CMD, "no line start"))?; + if let ("tangent_at", Some(c)) = (mode, reference) { + let already_on = + sk.constraints.iter().any(|k| matches!(k.kind, ConstraintKind::PointOnCurve { p, c: curve } if p == start && curve == c)); + let own_end = sk.curves.get(c).and_then(|c| c.kind.ends()).is_some_and(|(a, b)| a == start || b == start); + if sk.radius(c).is_some() && !already_on && !own_end { + cons.push(add_c(sk, ConstraintKind::PointOnCurve { p: start, c })?); + } + } + if let ("bisector", Some(a), Some(b)) = (mode, reference, second) { + let (a0, a1) = sk.curves.get(a).and_then(|c| c.kind.ends()).ok_or_else(|| bad(CMD, "the reference must be a line"))?; + let pa = if sk.point(a1).is_some_and(|q| q.dist(chosen.start) > 1e-6) { a1 } else { a0 }; + let source = sk.point(pa).ok_or_else(|| bad(CMD, "missing reference point"))?; + let relative = source - chosen.start; + let mirror = chosen.start + chosen.direction * (2.0 * relative.dot(chosen.direction)) - relative; + let pb = sk.add_point(mirror, None)?; + for k in [ + ConstraintKind::PointOnCurve { p: start, c: a }, + ConstraintKind::PointOnCurve { p: start, c: b }, + ConstraintKind::PointOnCurve { p: pb, c: b }, + ConstraintKind::Symmetric { p: pa, q: pb, l }, + ] { + cons.push(add_c(sk, k)?); + } + } + super::sketch_create::solve_new_only(sk, first_new); + Ok((ids_of(sk, &[l]), cons)) + })?; + Ok(result(out, info)) +} diff --git a/crates/engine/src/cmd/sketch_create.rs b/crates/engine/src/cmd/sketch_create.rs index 75597ae86..38d8e5387 100644 --- a/crates/engine/src/cmd/sketch_create.rs +++ b/crates/engine/src/cmd/sketch_create.rs @@ -772,7 +772,7 @@ fn midpoint_line(s: &mut Session, p: &Value) -> Result { } /// Direction leaving curve `ci` at its end point `pi` (continuing the curve past that end). -fn leaving_dir(sk: &Sketch, ci: usize, pi: usize) -> Option { +pub(super) fn leaving_dir(sk: &Sketch, ci: usize, pi: usize) -> Option { match sk.curves.get(ci)?.kind { CurveKind::Line { a, b } => { let (pa, pb) = (sk.point(a)?, sk.point(b)?); diff --git a/crates/engine/src/cmd/sketch_infinite_tests.rs b/crates/engine/src/cmd/sketch_infinite_tests.rs index eae8092ad..85f30fb00 100644 --- a/crates/engine/src/cmd/sketch_infinite_tests.rs +++ b/crates/engine/src/cmd/sketch_infinite_tests.rs @@ -33,6 +33,201 @@ fn profiles(s: &Session) -> usize { s.model.state().sketch(s.active_sketch.unwrap()).unwrap().profiles.len() } +#[test] +fn construction_line_methods_make_infinite_lines_with_direction_constraints() { + let mut s = new_sketch(); + run(&mut s, "sketch.line", json!({"points": [[0, 0], [3, 4]], "ids": ["reference"], "infer": false})); + for (mode, expected) in [ + ("horizontal", Vec2::new(1.0, 0.0)), + ("vertical", Vec2::new(0.0, 1.0)), + ("angle", Vec2::new(0.5, 3.0_f64.sqrt() / 2.0)), + ("parallel", Vec2::new(0.6, 0.8)), + ("perpendicular", Vec2::new(-0.8, 0.6)), + ] { + let out = run(&mut s, "sketch.construction_line", json!({"mode": mode, "at": [10, 10], "curve": "reference", "angle": 60})); + let sk = sketch(&s); + let id = out["curves"][0].as_str().unwrap(); + let c = curve(&sk, id); + assert!(c.infinite && c.construction); + let CurveKind::Line { a, b } = c.kind else { panic!("expected a line") }; + let direction = (sk.point(b).unwrap() - sk.point(a).unwrap()).normalized().unwrap(); + assert!(direction.cross(expected).abs() < 1e-6, "{mode}: {direction:?}"); + assert_eq!(out["constraints"].as_array().unwrap().len(), 1); + } + assert!(s.execute("sketch.construction_line", &json!({"mode": "parallel", "at": [0, 0], "curve": "missing"})).is_err()); +} + +#[test] +fn construction_angle_keeps_its_parameter_expression() { + let mut s = new_sketch(); + run(&mut s, "parameters.add", json!({"name":"inclination","expression":"30 deg"})); + let r = run(&mut s, "sketch.construction_line.angle", json!({"at":[5,5],"angle":"inclination"})); + let id = r["curves"][0].as_str().unwrap(); + let angle = |s: &Session| { + let sk = sketch(s); + let CurveKind::Line { a, b } = curve(&sk, id).kind else { panic!("line") }; + (sk.point(b).unwrap() - sk.point(a).unwrap()).angle().to_degrees() + }; + assert!((angle(&s) - 30.0).abs() < 1e-6); + run(&mut s, "parameters.change", json!({"name":"inclination","expression":"60 deg"})); + assert!((angle(&s) - 60.0).abs() < 1e-6); +} + +#[test] +fn construction_common_tangent_exposes_all_four_solutions() { + let mut s = new_sketch(); + run(&mut s, "sketch.circle.center", json!({"center":[0,0],"radius":5,"id":"a"})); + run(&mut s, "sketch.circle.center", json!({"center":[20,0],"radius":3,"id":"b"})); + let p = json!({"at":[10,10],"curve":"a","curve2":"b"}); + let lines = super::super::sketch_construction::construction_line_solutions(&sketch(&s), &p, "tangent_two").unwrap(); + assert_eq!(lines.len(), 4); + for (i, expected) in lines.iter().enumerate() { + let mut p = p.clone(); + p["solution"] = json!(i); + let r = run(&mut s, "sketch.construction_line.tangent_two", p); + let sk = sketch(&s); + let CurveKind::Line { a, b } = curve(&sk, r["curves"][0].as_str().unwrap()).kind else { panic!("line") }; + let start = sk.point(a).unwrap(); + let direction = (sk.point(b).unwrap() - start).normalized().unwrap(); + assert!(direction.cross(expected.direction).abs() < 1e-6); + assert!((start - expected.start).cross(direction).abs() < 1e-6); + for id in ["a", "b"] { + let c = sk.curve_index(id).unwrap(); + assert!(((sk.center(c).unwrap() - start).cross(direction).abs() - sk.radius(c).unwrap()).abs() < 1e-6); + } + } +} + +#[test] +fn construction_tangent_at_an_open_curve_endpoint_reuses_the_point() { + for (command, params, expected) in [ + ("sketch.spline.control_point", json!({"points":[[0,0],[0,10],[20,10],[20,0]]}), Vec2::Y), + ("sketch.conic", json!({"start":[0,0],"end":[20,0],"apex":[10,20],"rho":0.5}), Vec2::new(1.0, 2.0)), + ] { + let mut s = new_sketch(); + let source = run(&mut s, command, params)["curves"][0].as_str().unwrap().to_string(); + let start = format!("{source}.start"); + let r = run(&mut s, "sketch.construction_line.tangent_at", json!({"curve":source,"at":start})); + let sk = sketch(&s); + let CurveKind::Line { a, b } = curve(&sk, r["curves"][0].as_str().unwrap()).kind else { panic!("line") }; + assert_eq!(a, sk.resolve_point(&start).unwrap()); + assert!(sk.point(a).unwrap().dist(Vec2::ZERO) < 1e-7); + let direction = (sk.point(b).unwrap() - sk.point(a).unwrap()).normalized().unwrap(); + assert!(direction.cross(expected.normalized().unwrap()).abs() < 1e-7, "{command}: {direction:?}"); + assert_eq!(r["constraints"].as_array().unwrap().len(), 1); + } +} + +#[test] +fn construction_line_tangents_touch_the_circle() { + let mut s = new_sketch(); + run(&mut s, "sketch.circle.center", json!({"center": [0, 0], "radius": 5, "id": "circle"})); + for (mode, at, alternate) in [("tangent_external", [13, 0], false), ("tangent_external", [13, 0], true), ("tangent_at", [5, 0], false)] { + let out = run(&mut s, "sketch.construction_line", json!({"mode": mode, "at": at, "curve": "circle", "alternate": alternate})); + let sk = sketch(&s); + let id = out["curves"][0].as_str().unwrap(); + let CurveKind::Line { a, b } = curve(&sk, id).kind else { panic!("expected a line") }; + let p = sk.point(a).unwrap(); + let d = (sk.point(b).unwrap() - p).normalized().unwrap(); + let ci = sk.curve_index("circle").unwrap(); + let center = sk.center(ci).unwrap(); + let radius = sk.radius(ci).unwrap(); + assert!(((center - p).cross(d).abs() - radius).abs() < 1e-5); + } + assert!(s.execute("sketch.construction_line", &json!({"mode":"tangent_external", "at":[0,0], "curve":"circle"})).is_err()); +} + +#[test] +fn construction_common_tangent_and_bisector() { + let mut s = new_sketch(); + run(&mut s, "sketch.circle.center", json!({"center": [0, 0], "radius": 5, "id": "c1"})); + run(&mut s, "sketch.circle.center", json!({"center": [20, 0], "radius": 3, "id": "c2"})); + let out = run(&mut s, "sketch.construction_line", json!({"mode":"tangent_two", "curve":"c1", "curve2":"c2", "at":[10, 8]})); + let sk = sketch(&s); + let CurveKind::Line { a, b } = curve(&sk, out["curves"][0].as_str().unwrap()).kind else { panic!("expected a line") }; + let start = sk.point(a).unwrap(); + let direction = (sk.point(b).unwrap() - start).normalized().unwrap(); + for id in ["c1", "c2"] { + let c = sk.curve_index(id).unwrap(); + assert!(((sk.center(c).unwrap() - start).cross(direction).abs() - sk.radius(c).unwrap()).abs() < 1e-5); + } + let mut s = new_sketch(); + run(&mut s, "sketch.line", json!({"points":[[0,0],[10,0]],"ids":["a"],"infer":false})); + run(&mut s, "sketch.line", json!({"points":[[0,0],[0,10]],"ids":["b"],"infer":false,"connect":false})); + let out = run(&mut s, "sketch.construction_line", json!({"mode":"bisector", "curve":"a", "curve2":"b", "at":[5,5]})); + let sk = sketch(&s); + let CurveKind::Line { a, b } = curve(&sk, out["curves"][0].as_str().unwrap()).kind else { panic!("expected a line") }; + let direction = (sk.point(b).unwrap() - sk.point(a).unwrap()).normalized().unwrap(); + assert!((direction.x.abs() - direction.y.abs()).abs() < 1e-5); +} + +#[test] +fn construction_tools_keep_profiles_and_undo_and_save_as_one_edit() { + let mut s = new_sketch(); + run(&mut s, "sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[20,10]})); + let before = s.doc.to_json(); + let depth = s.undo.len(); + let r = run(&mut s, "sketch.construction_line", json!({"at":[-5,5],"through":[30,5]})); + assert_eq!(s.undo.len(), depth + 1); + assert_eq!(profiles(&s), 1); + let doc = solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap(); + let id = r["curves"][0].as_str().unwrap(); + let c = curve(doc.sketch(s.active_sketch.unwrap()).unwrap(), id); + assert!(c.construction && c.infinite); + run(&mut s, "edit.undo", json!({})); + assert_eq!(s.doc.to_json(), before); +} + +#[test] +fn construction_tangents_respect_arc_sweeps_and_invalid_inputs_are_atomic() { + let mut s = new_sketch(); + run(&mut s, "sketch.arc.center_point", json!({"center":[0,0],"start":[5,0],"end":[0,5],"id":"arc"})); + let sk = sketch(&s); + let p = json!({"at":[13,0],"curve":"arc"}); + let lines = super::super::sketch_construction::construction_line_solutions(&sk, &p, "tangent_external").unwrap(); + assert_eq!(lines.len(), 1, "the lower-circle tangent is outside the quarter arc"); + assert!(lines[0].direction.y > 0.0); + let r = run(&mut s, "sketch.construction_line.tangent_external", p); + let sk = sketch(&s); + let CurveKind::Line { a, b } = curve(&sk, r["curves"][0].as_str().unwrap()).kind else { panic!("line") }; + let actual = (sk.point(b).unwrap() - sk.point(a).unwrap()).normalized().unwrap(); + assert!(actual.cross(lines[0].direction).abs() < 1e-7); + for p in [ + json!({}), + json!({"at":[0,0],"curve":"arc","mode":"tangent_external"}), + json!({"at":[10,10],"mode":"angle","angle":"bad"}), + json!({"at":[10,10],"mode":"horizontal","solution":99}), + json!({"at":[10,10],"mode":"horizontal","alternate":"false"}), + json!({"at":[1,1],"through":[1,1]}), + ] { + let before = s.doc.to_json(); + assert!(s.execute("sketch.construction_line", &p).is_err(), "{p}"); + assert_eq!(s.doc.to_json(), before, "{p}"); + } +} + +#[test] +fn construction_relations_follow_source_edits_without_an_auxiliary_dimension() { + let mut s = new_sketch(); + run(&mut s, "sketch.line", json!({"points":[[0,0],[20,0]],"ids":["a"],"infer":false})); + run(&mut s, "sketch.line", json!({"points":[[0,0],[0,20]],"ids":["b"],"infer":false})); + let parallel = run(&mut s, "sketch.construction_line.parallel", json!({"curve":"a","at":[5,5]})); + let bisector = run(&mut s, "sketch.construction_line.bisector", json!({"curve":"a","curve2":"b","at":[10,10]})); + assert!(sketch(&s).constraints.iter().all(|c| !matches!(c.kind, solidcraft_sketch::ConstraintKind::Distance { .. }))); + run(&mut s, "sketch.drag", json!({"entity":"a.end","from":[20,0],"to":[20,10]})); + let sk = sketch(&s); + let direction = |id: &str| { + let CurveKind::Line { a, b } = curve(&sk, id).kind else { panic!("line") }; + (sk.point(b).unwrap() - sk.point(a).unwrap()).normalized().unwrap() + }; + let a = direction("a"); + let b = direction("b"); + let p = direction(parallel["curves"][0].as_str().unwrap()); + let d = direction(bisector["curves"][0].as_str().unwrap()); + assert!(a.cross(p).abs() < 1e-5); + assert!((a.dot(d).abs() - b.dot(d).abs()).abs() < 1e-5); +} + #[test] fn the_line_type_switches_on_and_off_and_stays_out_of_profiles() { let mut s = new_sketch(); diff --git a/crates/engine/src/schema/sketch_create.rs b/crates/engine/src/schema/sketch_create.rs index 4b079e9a6..143069480 100644 --- a/crates/engine/src/schema/sketch_create.rs +++ b/crates/engine/src/schema/sketch_create.rs @@ -4,7 +4,58 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::Value; -use super::types::{SketchRef, present}; +use super::types::{AngleExpr, SketchRef, present}; + +/// Create an infinite reference line in the active sketch. +#[derive(Debug, Deserialize, JsonSchema)] +#[schemars(deny_unknown_fields)] +pub struct ConstructionLineParams { + /// The construction method. + pub mode: Option, + /// Point to pass through; for tangent_at it selects a contact on the curve. + pub at: Value, + /// Second point of a two-point construction line. + pub through: Option, + /// Point used to select the closest solution when several exist. + pub near: Option<[f64; 2]>, + /// Zero-based index in the deterministic list of solutions. + pub solution: Option, + /// A reference line for parallel and perpendicular constructions. + pub curve: Option, + /// Second reference curve for a common tangent or an angle bisector. + pub curve2: Option, + /// Choose the other tangent when two solutions exist. + pub alternate: Option, + /// Direction measured counter-clockwise from sketch X, in degrees. + pub angle: Option, + /// The sketch (default: the one being edited). + pub sketch: Option, +} + +#[derive(Debug, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ConstructionMethod { + Free, + Horizontal, + Vertical, + Angle, + Parallel, + Perpendicular, + TangentExternal, + TangentAt, + TangentTwo, + Bisector, +} + +/// The curves and constraints created, together with the sketch solve. +#[derive(Debug, Serialize, JsonSchema)] +pub struct ConstructionLineResult { + pub curves: Vec, + pub constraints: Vec, + pub sketch: Value, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub param_warnings: Vec, +} /// Reverse a spline's direction: its last point becomes its first, and the curve runs the other /// way along the same path. Its points, and the constraints on them and on the curve, stay. Takes diff --git a/crates/engine/src/schema/sketch_create_tests.rs b/crates/engine/src/schema/sketch_create_tests.rs index ce79b6eab..e9c69cf50 100644 --- a/crates/engine/src/schema/sketch_create_tests.rs +++ b/crates/engine/src/schema/sketch_create_tests.rs @@ -36,3 +36,25 @@ fn spline_reverse_reply_matches_its_schema() { assert!(conforms(schema, schema, &r), "{r} doesn't match {schema}"); assert!(r["param_warnings"].as_array().is_some_and(|w| !w.is_empty()), "{r}"); } + +#[test] +fn construction_line_contracts_and_replies_match() { + use super::{ConstructionLineParams, ConstructionLineResult}; + assert_keys( + input_schema_for::(), + &["alternate", "angle", "at", "curve", "curve2", "mode", "near", "sketch", "solution", "through"], + ); + let schema = output_schema_for::(); + let schema = schema.as_value(); + let mut s = Session { param_check: ParamCheck::Strict, ..Session::default() }; + s.execute("sketch.create", &json!({"plane":"XY"})).unwrap(); + for (id, p) in [ + ("sketch.construction_line", json!({"at":[0,0],"through":[5,5]})), + ("sketch.construction_line.horizontal", json!({"at":[0,10]})), + ("sketch.construction_line.angle", json!({"at":[10,10],"angle":30})), + ] { + let r = s.execute(id, &p).unwrap(); + assert!(conforms(schema, schema, &r), "{r}"); + } + assert!(s.execute("sketch.construction_line", &json!({"at":[0,0],"mode":"unknown"})).is_err()); +} diff --git a/crates/ui-egui/src/command_help.rs b/crates/ui-egui/src/command_help.rs index d34ce0621..390966946 100644 --- a/crates/ui-egui/src/command_help.rs +++ b/crates/ui-egui/src/command_help.rs @@ -15,6 +15,16 @@ pub const DOCUMENTED: &[&str] = &[ "occurrence.move", "parameters.change", "pointcloud.insert", + "sketch.construction_line", + "sketch.construction_line.angle", + "sketch.construction_line.bisector", + "sketch.construction_line.horizontal", + "sketch.construction_line.parallel", + "sketch.construction_line.perpendicular", + "sketch.construction_line.tangent_at", + "sketch.construction_line.tangent_external", + "sketch.construction_line.tangent_two", + "sketch.construction_line.vertical", "sketch.equation_curve", "solid.align", "solid.chamfer", diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 1c7d3003a..ccb90f997 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -348,6 +348,18 @@ mod tests { } } + #[test] + fn construction_operation_names_exist_in_every_supported_catalog() { + let family = crate::sketch_families::family("sketch.construction_line").unwrap(); + for catalog in LOCALES { + assert!(catalog.messages().get("ui.construction.ribbon_label").is_some_and(|v| !v.trim().is_empty()), "{}: ribbon label", catalog.id); + for id in family.commands { + let key = format!("cmd.{id}"); + assert!(catalog.messages().get(&key).is_some_and(|v| !v.trim().is_empty()), "{}: {key}", catalog.id); + } + } + } + #[test] fn alias_resolution_regression() { static LEGACY: Catalog = Catalog::new("test-legacy", "Test", r#"{"Pitch":"legacy pitch"}"#); diff --git a/crates/ui-egui/src/icon_svg.rs b/crates/ui-egui/src/icon_svg.rs index 7a75fb332..ec1a60837 100644 --- a/crates/ui-egui/src/icon_svg.rs +++ b/crates/ui-egui/src/icon_svg.rs @@ -829,7 +829,7 @@ mod tests { Some("surface") } else if c.panel == "CONSTRAINTS" { Some("constraint") - } else if matches!(c.id, "sketch.construction" | "sketch.centerline") { + } else if matches!(c.id, "sketch.construction" | "sketch.centerline") || c.id.starts_with("sketch.construction_line") { Some("construction") } else if c.id.starts_with("sketch.") && matches!(c.panel, "CREATE" | "MODIFY" | "PATTERN" | "FINISH SKETCH") { Some("sketch") @@ -942,6 +942,7 @@ mod tests { #[test] fn sketch_construction_modes_have_distinct_icons() { let families: &[&[&str]] = &[ + crate::sketch_families::family("sketch.construction_line").unwrap().commands, &["sketch.polygon.inscribed", "sketch.polygon.circumscribed", "sketch.polygon.edge"], &["sketch.slot.center_to_center", "sketch.slot.overall", "sketch.slot.center_point"], &["sketch.slot.arc_three_point", "sketch.slot.arc_center"], diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 776ab4cb3..773f20744 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -238,6 +238,7 @@ mod sketch3d_frame_ui_tests; pub(crate) mod sketch_attachment_ui; #[cfg(test)] mod sketch_attachment_ui_tests; +mod sketch_construction; pub mod sketch_dims; pub(crate) mod sketch_display; #[cfg(test)] diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index c54a58b2e..0d29f29ec 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -1293,6 +1293,8 @@ preference_settings! { /// A sketch's icon in History and the browser takes the colour of its solve state, and its /// tooltip names the state (#7245). Off: every sketch has the same icon, as before. sketch_state_icons: bool = true, PAGE_SKETCH => check_id("prefs.sketch_state_icons"); + /// Show the construction-line family in Sketch CREATE; off restores the earlier menu. + sketch_construction_lines: bool = true, PAGE_SKETCH => check_id("prefs.sketch_construction_lines"); /// A sketch tool's shortcut pressed again before the first point steps to the tool's next /// creation mode (#2459). Off (the default): the key starts the tool again, as it always has. shortcut_cycles_modes: bool = false, PAGE_SKETCH; diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rs index ba358cb26..01b580470 100644 --- a/crates/ui-egui/src/prefs/sketch.rs +++ b/crates/ui-egui/src/prefs/sketch.rs @@ -24,6 +24,8 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { // Sketch icons in the colour of their solve state (#7245). let check = setting::sketch_state_icons(app, ui).on_hover_text(app.tr("prefs.sketch_state_icons_note")); crate::scenario::publish_target("prefs:sketch_state_icons", check.rect); + let construction = setting::sketch_construction_lines(app, ui); + crate::scenario::publish_target("prefs:sketch_construction_lines", construction.rect); let dimension = setting::sketch_auto_dimensions(app, ui); crate::scenario::publish_handle("prefs:sketch_auto_dimensions", dimension.rect.center()); ui.add_enabled_ui(app.preferences.sketch_auto_dimensions, |ui| { diff --git a/crates/ui-egui/src/sketch_construction.rs b/crates/ui-egui/src/sketch_construction.rs new file mode 100644 index 000000000..3390175c7 --- /dev/null +++ b/crates/ui-egui/src/sketch_construction.rs @@ -0,0 +1,160 @@ +//! Interactive construction-line family: reference picks, shared analytic previews and commits. + +use egui::Stroke; +use serde_json::{Value, json}; +use solidcraft_engine::cmd::{construction_line_choice, construction_line_mode, construction_line_solutions}; +use solidcraft_engine::geom::Vec2; + +use crate::SolveApp; +use crate::tools::Tool; +use crate::viewport::{Hit, Proj}; + +fn references(mode: &str) -> usize { + match mode { + "tangent_two" | "bisector" => 2, + "parallel" | "perpendicular" | "tangent_external" | "tangent_at" => 1, + _ => 0, + } +} + +pub fn hint(id: &str) -> String { + let key = match construction_line_mode(id).unwrap_or("free") { + "free" => "ui.construction.free_hint", + "horizontal" | "vertical" => "ui.construction.point_hint", + "angle" => "ui.construction.angle_hint", + "parallel" | "perpendicular" => "ui.construction.reference_hint", + "tangent_external" => "ui.construction.external_hint", + "tangent_at" => "ui.construction.contact_hint", + "tangent_two" => "ui.construction.common_hint", + "bisector" => "ui.construction.bisector_hint", + _ => "ui.construction.point_hint", + }; + crate::i18n::tr(key).to_owned() +} + +fn arg(point: &(Vec2, Option), preview: bool) -> Value { + if !preview && let Some(id) = &point.1 { + return json!(id); + } + json!([point.0.x, point.0.y]) +} + +/// Parameters for the line under the pointer, also used for the final click. +fn params(app: &SolveApp, t: &Tool, pointer: &(Vec2, Option), preview: bool) -> Option { + let mode = construction_line_mode(t.cmd)?; + let refs = references(mode); + if t.picks.len() < refs { + return None; + } + let first = t.pts.first(); + let at = match mode { + "free" | "angle" => first?, + "tangent_external" => first.unwrap_or(pointer), + _ => pointer, + }; + let mut p = json!({"mode": mode, "at": arg(at, preview), "near": [pointer.0.x, pointer.0.y]}); + if let Some(id) = t.picks.first() { + p["curve"] = json!(id); + } + if let Some(id) = t.picks.get(1) { + p["curve2"] = json!(id); + } + if mode == "free" { + p["through"] = arg(pointer, preview); + } + if mode == "angle" { + let angle = crate::sketch_dims::locked_value(app, t, "Angle").unwrap_or_else(|| (pointer.0 - at.0).angle()); + p["angle"] = json!(angle.to_degrees()); + if !preview && let Some(expression) = crate::sketch_dims::locked_expression(t, "Angle") { + p["angle"] = json!(expression); + } + } + Some(p) +} + +pub fn on_click(app: &mut SolveApp, tool: &mut Tool, hits: &[Hit], at: Option<(Vec2, Option)>) { + let Some(mode) = construction_line_mode(tool.cmd) else { return }; + let refs = references(mode); + if tool.picks.len() < refs { + let active = app.session.active_sketch; + let picked = hits.iter().find_map(|h| match h { + Hit::SketchCurve { sketch, id, .. } if Some(*sketch) == active => Some(id.clone()), + _ => None, + }); + if let Some(id) = picked { + let state = app.session.world_state(); + let valid = active.and_then(|sid| state.sketch(sid)).is_some_and(|ss| { + ss.sketch.curve_index(&id).and_then(|i| ss.sketch.curves.get(i)).is_some_and(|c| { + use solidcraft_engine::sketch::CurveKind; + match mode { + "parallel" | "perpendicular" | "bisector" => matches!(c.kind, CurveKind::Line { .. }), + "tangent_external" | "tangent_two" => matches!(c.kind, CurveKind::Circle { .. } | CurveKind::Arc { .. }), + "tangent_at" => !matches!(c.kind, CurveKind::Line { .. } | CurveKind::Ellipse { .. }), + _ => false, + } + }) + }); + if valid && !tool.picks.contains(&id) { + tool.picks.push(id); + } + } + return; + } + if let Some(at) = at { + place_point(app, tool, at); + } +} + +/// Enter in the angle box follows the same path as a click. +pub fn place_point(app: &mut SolveApp, t: &mut Tool, at: (Vec2, Option)) { + let Some(mode) = construction_line_mode(t.cmd) else { return }; + if t.picks.len() < references(mode) { + return; + } + if let Err(error) = crate::sketch_dims::validate(app, t) { + app.set_status(error, true); + return; + } + let at = crate::sketch_dims::placed(app, t, &at); + if matches!(mode, "free" | "angle" | "tangent_external") && t.pts.is_empty() { + t.pts.push(at); + return; + } + let Some(p) = params(app, t, &at, false) else { return }; + if app.run(t.cmd, p).is_ok() { + t.pts.clear(); + // Retain references for repeated parallel lines/tangents. Right-click resets the picks. + crate::sketch_dims::reset(t); + } +} + +/// Shared geometry, drawn far enough either way to cover the visible sketch plane. +pub fn preview(app: &SolveApp, t: &Tool, painter: &egui::Painter, proj: &Proj) { + let Some(pointer) = &t.hover else { return }; + let Some(mode) = construction_line_mode(t.cmd) else { return }; + let Some(p) = params(app, t, pointer, true) else { return }; + let state = app.session.world_state(); + let Some(ss) = app.session.active_sketch.and_then(|sid| state.sketch(sid)) else { return }; + let Ok(lines) = construction_line_solutions(&ss.sketch, &p, mode) else { return }; + let chosen = construction_line_choice(&lines, &p).ok(); + let tokens = crate::theme::Tokens::get(); + let center = ss.plane.to_local(app.cam.target); + let extent = app.cam.half_height().max(1.0) * 20.0; + for (i, line) in lines.iter().enumerate() { + let origin = line.start + line.direction * (center - line.start).dot(line.direction); + let points = [ss.plane.to_world(origin - line.direction * extent), ss.plane.to_world(origin + line.direction * extent)]; + let selected = chosen == Some(i); + let stroke = + Stroke::new(if selected { 2.0 } else { 1.0 }, if selected { tokens.preview_new } else { tokens.sketch_accent.gamma_multiply(0.35) }); + crate::tools::paint_sketch_path(&points, 3, painter, proj, stroke); + } + if let Some(first) = t.pts.first() + && let Some(p) = proj.to_screen(ss.plane.to_world(first.0)) + { + painter.circle_stroke(p, 4.0, Stroke::new(1.5, tokens.sketch_accent)); + } +} + +#[cfg(test)] +#[path = "sketch_construction_tests.rs"] +mod tests; diff --git a/crates/ui-egui/src/sketch_construction_tests.rs b/crates/ui-egui/src/sketch_construction_tests.rs new file mode 100644 index 000000000..3ef812fda --- /dev/null +++ b/crates/ui-egui/src/sketch_construction_tests.rs @@ -0,0 +1,106 @@ +use crate::scenario::Harness; +use serde_json::json; +use solidcraft_engine::sketch::CurveKind; + +fn sketch() -> Harness { + let mut h = Harness::new(); + h.app.home.open = false; + h.app.run("sketch.create", json!({"plane":"XY"})).unwrap(); + h.app.run("sketch.line", json!({"points":[[0,0],[20,0]],"ids":["a"],"infer":false})).unwrap(); + h.app.run("sketch.line", json!({"points":[[0,0],[0,20]],"ids":["b"],"infer":false})).unwrap(); + h.app.run("sketch.circle.center", json!({"center":[40,0],"radius":5,"id":"c"})).unwrap(); + h.app.run("sketch.circle.center", json!({"center":[60,0],"radius":5,"id":"d"})).unwrap(); + h.settle(); + h +} + +fn steps(h: &mut Harness, id: &str, clicks: &[[f64; 2]]) { + h.step(&json!({"start":id})).unwrap(); + for q in clicks { + h.step(&json!({"click":{"sketch":q}})).unwrap(); + } +} + +#[test] +fn every_construction_variant_is_interactive_and_stays_infinite() { + let cases: &[(&str, &[[f64; 2]])] = &[ + ("sketch.construction_line", &[[5., 10.], [15., 15.]]), + ("sketch.construction_line.horizontal", &[[5., 10.]]), + ("sketch.construction_line.vertical", &[[5., 10.]]), + ("sketch.construction_line.angle", &[[5., 10.], [15., 20.]]), + ("sketch.construction_line.parallel", &[[10., 0.], [5., 10.]]), + ("sketch.construction_line.perpendicular", &[[10., 0.], [5., 10.]]), + ("sketch.construction_line.tangent_external", &[[40., 5.], [50., 10.], [50., 15.]]), + ("sketch.construction_line.tangent_at", &[[40., 5.], [45., 0.]]), + ("sketch.construction_line.tangent_two", &[[40., 5.], [60., 5.], [50., 8.]]), + ("sketch.construction_line.bisector", &[[10., 0.], [0., 10.], [10., 10.]]), + ]; + for (id, clicks) in cases { + let mut h = sketch(); + crate::sketch_palette::set_mode(&mut h.app, 2); + let sid = h.app.session.active_sketch.unwrap(); + let before = h.app.session.doc.sketch(sid).unwrap().curves.len(); + steps(&mut h, id, clicks); + let sk = h.app.session.doc.sketch(sid).unwrap(); + assert_eq!(sk.curves.len(), before + 1, "{id}: {:?}", h.app.tool); + let curve = sk.curves.last().unwrap(); + assert!(curve.infinite && curve.construction && !curve.centerline, "{id}: {curve:?}"); + assert!(matches!(curve.kind, CurveKind::Line { .. })); + } +} + +#[test] +fn world_axes_are_not_mistaken_for_sketch_axes() { + // The world Y axis is sketch X on YZ. Sending its name as local "y" would + // silently create a perpendicular reference, so only sketch curves are picked. + let mut h = Harness::new(); + h.app.run("sketch.create", json!({"plane":"YZ"})).unwrap(); + for id in ["sketch.construction_line.parallel", "sketch.construction_line.perpendicular", "sketch.construction_line.bisector"] { + let mut tool = crate::sketch_tools::tool_for(id).unwrap(); + super::on_click(&mut h.app, &mut tool, &[crate::viewport::Hit::Axis { name: "Y".into() }], None); + assert!(tool.picks.is_empty(), "{id} must not reinterpret a world axis as a local axis"); + } +} + +#[test] +fn construction_angle_accepts_inline_value_and_undo_is_one_step() { + let mut h = sketch(); + steps(&mut h, "sketch.construction_line.angle", &[[5., 10.]]); + h.step(&json!({"move":{"sketch":[15,15]}})).unwrap(); + h.settle(); + let tool = h.app.tool.as_mut().unwrap(); + tool.dims = crate::sketch_dims::boxes_for(tool.cmd, 1); + let dim = tool.dims.first_mut().unwrap(); + dim.locked = true; + dim.value = "30 deg".into(); + let mut tool = h.app.tool.take().unwrap(); + super::place_point(&mut h.app, &mut tool, (solidcraft_engine::geom::Vec2::new(15., 15.), None)); + let sid = h.app.session.active_sketch.unwrap(); + let sk = h.app.session.doc.sketch(sid).unwrap(); + let curve = sk.curves.last().unwrap(); + let CurveKind::Line { a, b } = curve.kind else { panic!("line") }; + assert!(((sk.point(b).unwrap() - sk.point(a).unwrap()).angle().to_degrees() - 30.).abs() < 1e-6); + let count = sk.curves.len(); + h.app.run("edit.undo", json!({})).unwrap(); + assert_eq!(h.app.session.doc.sketch(sid).unwrap().curves.len(), count - 1); +} + +#[test] +fn construction_family_menu_and_preference() { + for enabled in [true, false] { + let mut h = sketch(); + h.app.preferences.sketch_construction_lines = enabled; + h.settle(); + h.step(&json!({"click":{"handle":"panel:SKETCH:CREATE"}})).unwrap(); + h.frames(4); + assert_eq!(crate::scenario::handle_at("create_family:Construction Line").is_some(), enabled); + if enabled { + h.step(&json!({"click":{"handle":"create_family:Construction Line"}})).unwrap(); + h.frames(4); + let family = crate::sketch_families::family("sketch.construction_line").unwrap(); + for id in family.commands { + assert!(crate::scenario::handle_at(&format!("dropdown:{id}")).is_some(), "{id}"); + } + } + } +} diff --git a/crates/ui-egui/src/sketch_dims.rs b/crates/ui-egui/src/sketch_dims.rs index 3626d50ef..df13d3f97 100644 --- a/crates/ui-egui/src/sketch_dims.rs +++ b/crates/ui-egui/src/sketch_dims.rs @@ -39,6 +39,7 @@ pub fn boxes_for(cmd: &str, n: usize) -> Vec { use ValueKind::*; let b = DimBox::new; match (cmd, n) { + ("sketch.construction_line.angle", 1) => vec![b("Angle", Angle)], ("sketch.line" | "sketch.line.midpoint", n) if n >= 1 => vec![b("Length", Length), b("Angle", Angle)], ("sketch.rectangle.two_point" | "sketch.rectangle.center", 1) => vec![b("Width", Length), b("Height", Length)], ("sketch.rectangle.rounded", 1) => vec![b("Width", Length), b("Height", Length), b("Radius", Length)], @@ -72,6 +73,9 @@ fn eval(doc: &Document, text: &str, kind: ValueKind) -> solidcraft_engine::doc:: /// Whether a box becomes one of the shape's dimensions. A rounded rectangle's radius is its own /// parameter (sent with the shape); sides and rho are counts and shape factors. fn is_dimension(t: &Tool, label: &str) -> bool { + if solidcraft_engine::cmd::construction_line_mode(t.cmd).is_some() { + return t.cmd == "sketch.construction_line.angle" && label == "Angle"; + } !matches!(label, "Sides" | "Rho") && !(t.cmd == "sketch.rectangle.rounded" && label == "Radius") } @@ -88,6 +92,7 @@ pub fn effective(app: &SolveApp, t: &Tool, h: Vec2) -> Vec2 { let Some(a) = t.pts.last().map(|p| p.0) else { return h }; let lk = |l: &str| locked(app, t, l); match (t.cmd, t.pts.len()) { + ("sketch.construction_line.angle", 1) => a + Vec2::from_angle(lk("Angle").unwrap_or_else(|| (h - a).angle())) * (h - a).len().max(1.0), ("sketch.line", _) | ("sketch.slot.center_to_center" | "sketch.slot.overall", 1) => { let v = h - a; let len = lk("Length").unwrap_or(v.len()); @@ -243,6 +248,7 @@ fn live(app: &SolveApp, t: &Tool, e: Vec2, px: f64) -> Vec<(f64, Vec2)> { let first = t.pts.first().map(|p| p.0).unwrap_or(a); let off = 20.0 * px; match (t.cmd, t.pts.len()) { + ("sketch.construction_line.angle", 1) => vec![((e - a).angle(), (a + e) * 0.5 + dir_or_x(e - a).perp() * off)], ("sketch.line", _) | ("sketch.slot.center_to_center" | "sketch.slot.overall", 1) => line_boxes(a, e, px, off), // The midpoint line runs from the end's mirror image through the midpoint to the end, // so its length is the whole line: twice the distance from the midpoint to the cursor. diff --git a/crates/ui-egui/src/sketch_families.rs b/crates/ui-egui/src/sketch_families.rs index ac3feeeef..d89fcdc13 100644 --- a/crates/ui-egui/src/sketch_families.rs +++ b/crates/ui-egui/src/sketch_families.rs @@ -10,6 +10,21 @@ pub struct Family { } pub const FAMILIES: &[Family] = &[ + Family { + label: "Construction Line", + commands: &[ + "sketch.construction_line", + "sketch.construction_line.horizontal", + "sketch.construction_line.vertical", + "sketch.construction_line.angle", + "sketch.construction_line.parallel", + "sketch.construction_line.perpendicular", + "sketch.construction_line.tangent_external", + "sketch.construction_line.tangent_at", + "sketch.construction_line.tangent_two", + "sketch.construction_line.bisector", + ], + }, Family { label: "Line", commands: &["sketch.line", "sketch.line.midpoint"] }, Family { label: "Rectangle", diff --git a/crates/ui-egui/src/sketch_palette.rs b/crates/ui-egui/src/sketch_palette.rs index f7d7babcc..2596dee07 100644 --- a/crates/ui-egui/src/sketch_palette.rs +++ b/crates/ui-egui/src/sketch_palette.rs @@ -106,6 +106,9 @@ pub fn toggle_construction(app: &mut SolveApp) { /// Curves a drawing command just made take the drawing line type. pub fn apply_mode(app: &mut SolveApp, id: &str, result: &Value) { + if solidcraft_engine::cmd::construction_line_mode(id).is_some() { + return; + } let m = mode(app); if m == 0 || !solidcraft_engine::find_command(id).is_some_and(|c| c.tab == "SKETCH" && c.panel == "CREATE") { return; diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs index fcdb97edc..cf8c4145e 100644 --- a/crates/ui-egui/src/sketch_tools.rs +++ b/crates/ui-egui/src/sketch_tools.rs @@ -37,6 +37,16 @@ const EXTEND_BINDINGS: &[Binding] = &[ /// Per-tool modifier descriptors owned by this host file. pub const MODIFIERS: &[ToolModifiers] = &[ + ToolModifiers { tool: "sketch.construction_line", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.horizontal", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.vertical", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.angle", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.parallel", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.perpendicular", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.tangent_external", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.tangent_at", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.tangent_two", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, + ToolModifiers { tool: "sketch.construction_line.bisector", scopes: DRAW_SCOPES, bindings: &[], audit: Audit::Implemented }, ToolModifiers { tool: "sketch.project", scopes: NONE, bindings: &[], audit: Audit::VerifiedNoOp }, ToolModifiers { tool: "sketch.intersect", scopes: NONE, bindings: &[], audit: Audit::VerifiedNoOp }, ToolModifiers { tool: "sketch.include_3d", scopes: NONE, bindings: &[], audit: Audit::VerifiedNoOp }, @@ -701,6 +711,7 @@ pub fn delete_glyph(app: &mut SolveApp) -> bool { /// What the extra tools do with clicks. #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum Mode { + Construction, /// Each click on model geometry runs the command with that reference. ModelRef, /// Click a curve of the active sketch where it should change. @@ -724,6 +735,9 @@ pub fn takes(id: &str, hit: &Hit) -> bool { } fn mode(id: &str) -> Option { + if solidcraft_engine::cmd::construction_line_mode(id).is_some() { + return Some(Mode::Construction); + } Some(match id { "sketch.project" | "sketch.intersect" | "sketch.include_3d" | "sketch.fit_curves_to_section" | "sketch.isoparametric_curve" => Mode::ModelRef, "inspect.curvature_comb" | "canvas.insert" | "canvas.decal" => Mode::ModelRef, @@ -772,6 +786,9 @@ pub fn image_placement_finished(tool: &Tool) -> bool { } pub fn hint(id: &str) -> Option { + if solidcraft_engine::cmd::construction_line_mode(id).is_some() { + return Some(crate::sketch_construction::hint(id)); + } Some( match id { "sketch.project" => "Project: click edges, faces, vertices, other sketches' curves, axes or planes", @@ -962,6 +979,7 @@ pub fn on_click(app: &mut SolveApp, tool: &mut Tool, proj: &Proj, pos: Pos2) { let at = sketch_point_at(app, proj, pos); let cmd = tool.cmd; match m { + Mode::Construction => crate::sketch_construction::on_click(app, tool, &hits, at), Mode::ModelRef if cmd == "inspect.curvature_comb" => { let params = hits.iter().find_map(|h| match h { Hit::SketchCurve { sketch, id, .. } => Some(json!({"sketch": sketch, "curves": [id]})), @@ -1213,6 +1231,10 @@ pub fn on_click(app: &mut SolveApp, tool: &mut Tool, proj: &Proj, pos: Pos2) { /// Typed values are checked first, so a rejected one stays in its box to be corrected rather /// than reaching the command. pub(crate) fn place_point(app: &mut SolveApp, tool: &mut Tool, p: (Vec2, Option)) { + if solidcraft_engine::cmd::construction_line_mode(tool.cmd).is_some() { + crate::sketch_construction::place_point(app, tool, p); + return; + } if tool.cmd == "sketch.circle.two_tangent" && tool.picks.len() == 2 { if let Err(error) = crate::sketch_dims::validate(app, tool) { app.set_status(error, true); @@ -1387,6 +1409,10 @@ fn extend_preview_piece(app: &SolveApp, sketch: u64, id: &str) -> Option = crate::toolbar_custom::panel_lists(&tab) .into_iter() .filter(|(panel, _, _)| editing_in_place || !(tab == "MODEL" && *panel == "FINISH EDITING")) - .map(|(panel, cmds, promote)| { + .map(|(panel, mut cmds, promote)| { + let promote = if tab == "SKETCH" && panel == "CREATE" && !app.preferences.sketch_construction_lines { + promote.saturating_sub(1) + } else { + promote + }; + if !app.preferences.sketch_construction_lines { + cmds.retain(|c| solidcraft_engine::cmd::construction_line_mode(c.id).is_none()); + } let mut shown = crate::toolbar_custom::buttons(app, &tab, panel, &cmds, promote); // Gallery cells are painted together after the large buttons, in reading order. if tab == "SKETCH" && panel == "CONSTRAIN" { @@ -1386,7 +1394,7 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) { .map(|c| { let family = crate::sketch_families::family(c.id) .filter(|f| tab == "SKETCH" && *panel == "CREATE" && f.commands.first().copied() == Some(c.id)); - let label = family.map_or_else(|| crate::workspace::ribbon_button_label(c), |f| f.label); + let label = family.map_or_else(|| crate::workspace::ribbon_button_label(c), crate::workspace::ribbon_family_label); if labels { ButtonSize { width: ribbon_button_width(&painter, app.tr_label(label)), min_width: BUTTON_MIN_WIDTH } } else { @@ -1572,7 +1580,8 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) { // The title sits on the same line as the other buttons' labels. if labels { let title_y = whole.top() + 39.0; - let galley = ribbon_button_galley(&painter, app.tr_label(f.label), ar.width() - 16.0, t.text); + let galley = + ribbon_button_galley(&painter, app.tr_label(crate::workspace::ribbon_family_label(f)), ar.width() - 16.0, t.text); painter.galley(pos2(ar.center().x - 4.0, title_y - galley.size().y / 2.0), galley, t.text); dropdown_arrow(&painter, pos2(ar.right() - 6.0, title_y + 0.5), t.text_dim); } else { diff --git a/crates/ui-egui/src/workspace.rs b/crates/ui-egui/src/workspace.rs index 139fca2d3..0834fe122 100644 --- a/crates/ui-egui/src/workspace.rs +++ b/crates/ui-egui/src/workspace.rs @@ -246,8 +246,15 @@ pub const SECTIONS: &[Section] = &[ Section { tab: "SKETCH", panel: "CREATE", - promoted: 4, - ids: &["sketch.line", "sketch.rectangle.two_point", "sketch.circle.center", "sketch.arc.three_point", "sketch.infinite"], + promoted: 5, + ids: &[ + "sketch.line", + "sketch.rectangle.two_point", + "sketch.circle.center", + "sketch.arc.three_point", + "sketch.construction_line", + "sketch.infinite", + ], }, Section { tab: "SKETCH", @@ -431,6 +438,7 @@ pub const RIBBON_LABELS: &[(&str, &str)] = &[ ("sketch.circle.center", "Circle"), ("sketch.constraint.coincident", "Coincident"), ("sketch.constraint.horizontal_vertical", "Horiz./Vert."), + ("sketch.construction_line", "X-Lines"), ("sketch.create", "New Sketch"), ("sketch.dimension", "Dimension"), ("sketch.finish", "Finish Sketch"), @@ -451,6 +459,11 @@ pub fn ribbon_button_label(command: &CommandSpec) -> &str { RIBBON_LABELS.iter().find(|(id, _)| *id == command.id).map_or(command.label, |(_, label)| *label) } +/// Families keep their full menu title while using the first command's compact ribbon name. +pub fn ribbon_family_label(family: &crate::sketch_families::Family) -> &'static str { + family.commands.first().and_then(|first| RIBBON_LABELS.iter().find(|(id, _)| id == first)).map_or(family.label, |(_, label)| *label) +} + /// Registry placement → default ribbon destination, after explicit id overrides. pub const PLACEMENTS: &[(&str, &str, &str, &str)] = &[ ("SOLID", "CREATE", "MODEL", "CREATE"), @@ -846,6 +859,9 @@ mod tests { } assert_eq!(ribbon_button_label(solidcraft_engine::find_command("sketch.create").unwrap()), "New Sketch"); assert_eq!(solidcraft_engine::find_command("sketch.create").unwrap().label, "Create Sketch"); + let construction = crate::sketch_families::family("sketch.construction_line").unwrap(); + assert_eq!(ribbon_family_label(construction), "X-Lines"); + assert_eq!(construction.label, "Construction Line"); } #[test] @@ -856,7 +872,12 @@ mod tests { assert!(lists.iter().any(|(_, (cmds, _))| cmds.iter().any(|x| x.id == c.id)), "lost toolbar command {} ({}/{})", c.id, c.tab, c.panel); } for (s, (cmds, n)) in lists { - assert!(n <= 4 || (s.tab == "SKETCH" && s.panel == "CONSTRAIN" && n == 7), "{}/{} promotes {n} commands", s.tab, s.panel); + assert!( + n <= 4 || (s.tab == "SKETCH" && ((s.panel == "CONSTRAIN" && n == 7) || (s.panel == "CREATE" && n == 5))), + "{}/{} promotes {n} commands", + s.tab, + s.panel + ); for id in s.ids { assert!(specs.iter().any(|c| c.id == *id), "unknown layout id {id}"); } diff --git a/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json b/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json index cb8307de0..6b334a0e7 100644 --- a/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json +++ b/crates/ui-egui/tests/scenarios/sketch_centerline_toolbar_icon.json @@ -10,7 +10,8 @@ {"key": "Escape"}, {"click": {"handle": "panel:SKETCH:CONSTRAIN"}}, {"expect": {"shown_handles": ["toolbar:sketch.construction"]}}, - {"click": [1000, 500]}, + {"note": "Close the menu with Escape: a fixed canvas pixel can be inside the menu after ribbon families or pins change its position."}, + {"key": "Escape"}, {"start": "sketch.rectangle.two_point"}, {"click": {"sketch": [0, 0]}}, {"click": {"sketch": [30, 20]}}, diff --git a/docs/book/src/guide/sketching.md b/docs/book/src/guide/sketching.md index 17f017690..c09bc0904 100644 --- a/docs/book/src/guide/sketching.md +++ b/docs/book/src/guide/sketching.md @@ -86,6 +86,37 @@ a line type of their own and keep showing. Projected geometry that carries the c line type, such as the trace of a plane, answers to **Projected Geometries** instead. The option changes display only. Construction curves were already outside every profile. +The **Construction Line** drop-down in Sketch **CREATE** draws infinite reference lines +directly. It contains two-point, horizontal, vertical, angle, parallel, perpendicular, tangent +through an external point, tangent at a curve point, common tangent, and angle-bisector tools. +These lines remain construction geometry regardless of the Sketch Palette's drawing line type. +Turn off **Extended construction line tools** in Preferences > Sketch to restore the earlier menu. + +For horizontal or vertical lines, click the point to pass through. For a line at an angle, +click its point, then type the angle from sketch X in the inline box and press Enter, or click +the direction. Angle expressions can refer to parameters and follow their later changes. +Parallel and perpendicular lines ask for a straight sketch line, then a point; +the reference stays picked so you can place several lines. Right-click clears the current +points and references; Escape ends the tool. + +Tangents through an external point take a circle or circular arc, the external point, and a +click choosing the desired preview. A common tangent takes two circles/arcs and a click choosing +the solution. Contacts outside an arc's drawn sweep are excluded. A tangent at a curve point +takes a circle/arc and a contact point, or an endpoint of an open spline or conic. Interior +free-form contacts and ellipse tangents are not supported by these tools yet. A bisector takes +two intersecting straight lines; click near the desired one of the two preview lines. Parallel +or coincident references have no unique angle bisector and are refused. + +Each placement is one undo step. Direction, parallel, perpendicular, tangency and bisector +relations are kept as ordinary sketch constraints; the reference geometry follows later edits +within those constraints. Programmatic callers can use `sketch.construction_line` with `mode`, +or one of its named variants. `near` chooses the closest solution; `solution` chooses its +zero-based index. For example: + +```json +{"command":"sketch.construction_line.parallel","params":{"curve":"l1","at":[20,10]}} +``` + Polygon tools show their edge outline while positioning the second point, so the orientation can be checked before placement. Inscribed and circumscribed polygons retain their support circle and update the outline when the inline **Sides** value changes. diff --git a/docs/control-protocol.md b/docs/control-protocol.md index dd579dd77..734a8a7e3 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -420,6 +420,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own - `sketch_auto_dimensions` (default false: each shape drawn in a sketch gets all its dimensions at the sizes drawn, as `sketch.draw.dimensioned` with `as_drawn`; typed values win) - `sketch_auto_locate` (default false; with `sketch_auto_dimensions`, new shapes are also placed from the sketch origin until fully constrained, as `sketch.draw.dimensioned` with `locate`) - `sketch_conflict_colour` (default true: while the open sketch's constraints conflict, the curves and points a failing constraint holds are drawn in the theme's `sketch_conflict` colour too, not only its glyph or dimension; false: only the glyphs and dimensions are red, in `error`, as before, #7244) +- `sketch_construction_lines` (default true: show the Construction Line tool family in Sketch CREATE; false restores the earlier menu) - `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned)) - `sketch_recent_snap` (default false: while drawing, the cursor snaps where the horizontal guide of one recent circle or arc centre or straight-edge midpoint meets the vertical guide of another; a free coordinate, with no constraint and no construction geometry. Off: those guides stay visual and the cursor does not move. The references come from `sketch_tracking_guides`, #8694) - `sketch_state_icons` (default true: a sketch's icon in History and the browser takes the colour of its solve state, `sketch` under constrained, `sketch_fixed` fully constrained, `error` while its constraints conflict, and its tooltip names the state; false: every sketch row's icon and tooltip as before, #7245)