Move parametric tools to their own ribbon tab

This commit is contained in:
Hakan Seven committed 2026-09-11 20:58:37 +03:00
1 parent d07e8cf7d4
commit cf33455e93
35 files changed
+114 -76

No files matched your search

+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = رسم
.parametric = بارامتري
.annotate = تعليقات توضيحية
.insert = إدراج
.model = النمذجة
.model = نموذج
.layout = تخطيط
.manage = إدارة
.view = عرض
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Чертане
.parametric = Параметричен
.annotate = Анотиране
.insert = Вмъкване
.model = Моделиране
.model = Модел
.layout = Оформление
.manage = Управление
.view = Изглед
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Kreslení
.parametric = Parametrické
.annotate = Poznámky
.insert = Vložit
.model = Modelování
.model = Model
.layout = Rozvržení
.manage = Správa
.view = Zobrazení
+1
View File
@@ -29,6 +29,7 @@ action =
ribbon-tab =
.draw = Zeichnen
.parametric = Parametrisch
.annotate = Beschriften
.insert = Einfügen
.model = Modell
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Σχεδίαση
.parametric = Παραμετρικό
.annotate = Επισημείωση
.insert = Εισαγωγή
.model = Μοντελοποίηση
.model = Μοντέλο
.layout = Διάταξη
.manage = Διαχείριση
.view = Προβολή
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Draw
.parametric = Parametric
.annotate = Annotate
.insert = Insert
.model = Modelling
.model = Model
.layout = Layout
.manage = Manage
.view = View
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Dibujo
.parametric = Paramétrico
.annotate = Anotar
.insert = Insertar
.model = Modelado
.model = Modelo
.layout = Presentación
.manage = Administrar
.view = Vista
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Piirrä
.parametric = Parametrinen
.annotate = Merkinnät
.insert = Lisää
.model = Mallinnus
.model = Malli
.layout = Asettelu
.manage = Hallinta
.view = Näkymä
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Dessin
.parametric = Paramétrique
.annotate = Annoter
.insert = Insérer
.model = Modélisation
.model = Modèle
.layout = Mise en page
.manage = Gérer
.view = Affichage
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = ड्रॉ
.parametric = पैरामीट्रिक
.annotate = एनोटेट
.insert = सम्मिलित करें
.model = मॉडलिंग
.model = मॉडल
.layout = लेआउट
.manage = प्रबंधित करें
.view = देखें
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Rajz
.parametric = Parametrikus
.annotate = Feliratozás
.insert = Beszúrás
.model = Modellezés
.model = Modell
.layout = Elrendezés
.manage = Kezelés
.view = Nézet
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Disegno
.parametric = Parametrico
.annotate = Annotazione
.insert = Inserisci
.model = Modellazione
.model = Modello
.layout = Disposizione
.manage = Gestisci
.view = Vista
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = 作図
.parametric = パラメトリック
.annotate = 注釈
.insert = 挿入
.model = モデリング
.model = モデル
.layout = レイアウト
.manage = 管理
.view = 表示
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = 그리기
.parametric = 파라메트릭
.annotate = 주석
.insert = 삽입
.model = 모델링
.model = 모델
.layout = 배치
.manage = 관리
.view = 보기
+1
View File
@@ -29,6 +29,7 @@ action =
ribbon-tab =
.draw = Tekenen
.parametric = Parametrisch
.annotate = Annoteren
.insert = Invoegen
.model = Model
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Rysowanie
.parametric = Parametryczne
.annotate = Opisy
.insert = Wstaw
.model = Modelowanie
.model = Model
.layout = Układ
.manage = Zarządzaj
.view = Widok
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Desenhar
.parametric = Paramétrico
.annotate = Anotar
.insert = Inserir
.model = Modelagem
.model = Modelo
.layout = Layout
.manage = Gerenciar
.view = Exibir
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Начертить
.parametric = Параметрический
.annotate = Аннотации
.insert = Вставка
.model = Моделирование
.model = Модель
.layout = Расположение
.manage = Управление
.view = Просмотр
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = Çizim
.parametric = Parametrik
.annotate = Açıklama
.insert = Ekle
.model = Modelleme
.model = Model
.layout = Yerleşim
.manage = Yönet
.view = Görünüm
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = 绘制
.parametric = 参数化
.annotate = 注释
.insert = 插入
.model = 建模
.model = 模型
.layout = 布局
.manage = 管理
.view = 视图
+2 -1
View File
@@ -29,9 +29,10 @@ action =
ribbon-tab =
.draw = 繪製
.parametric = 參數化
.annotate = 註解
.insert = 插入
.model = 建模
.model = 模型
.layout = 配置
.manage = 管理
.view = 視圖
+5 -5
View File
@@ -1006,14 +1006,14 @@ impl OpenCADStudio {
}
"CCONSTRAINT" => {
use crate::modules::draw::constrain::CoincidentConstraintCommand;
use crate::modules::parametric::CoincidentConstraintCommand;
let new_cmd = CoincidentConstraintCommand::new();
self.command_line.push_info(&new_cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
}
"EDCONSTRAINT" => {
use crate::modules::draw::constrain::EqualDistanceConstraintCommand;
use crate::modules::parametric::EqualDistanceConstraintCommand;
let new_cmd = EqualDistanceConstraintCommand::new();
self.command_line.push_info(&new_cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
@@ -1106,7 +1106,7 @@ impl OpenCADStudio {
"Select exactly one entity (the circle or line the point should attach to), then run this constraint again.",
);
} else {
use crate::modules::draw::constrain::PointOnEntityConstraintCommand;
use crate::modules::parametric::PointOnEntityConstraintCommand;
use crate::scene::sketch_constraints::ConstraintKind;
let (name, kind, label) = match cmd {
"CPCONSTRAINT" => ("CPCONSTRAINT", ConstraintKind::CenterPoint, "Center point constraint"),
@@ -1130,7 +1130,7 @@ impl OpenCADStudio {
self.command_line
.push_output("Select exactly one line or circle, then run this constraint again.");
} else {
use crate::modules::draw::constrain::DistanceConstraintCommand;
use crate::modules::parametric::DistanceConstraintCommand;
match DistanceConstraintCommand::new(&self.tabs[i].scene, handles[0]) {
Some(new_cmd) => {
self.command_line.push_info(&new_cmd.prompt());
@@ -1153,7 +1153,7 @@ impl OpenCADStudio {
"Select exactly two lines (first = reference, second = the one that rotates), then run this constraint again.",
);
} else {
use crate::modules::draw::constrain::AngleConstraintCommand;
use crate::modules::parametric::AngleConstraintCommand;
match AngleConstraintCommand::new(&self.tabs[i].scene, handles[0], handles[1]) {
Some(new_cmd) => {
self.command_line.push_info(&new_cmd.prompt());
+2 -2
View File
@@ -1446,7 +1446,7 @@ pub enum CmdResult {
label: &'static str,
},
/// Add a persistent `CenterPoint`/`Midpoint`/`PointOnCurve` constraint
/// (`crate::modules::draw::constrain::point_on_entity`) between one
/// (`crate::modules::parametric::point_on_entity`) between one
/// picked point and `target`, a whole entity selected before the tool
/// ran. Like `AddCoincidentConstraint`, the host resolves `point` via
/// `sketch_constraints::nearest_sketch_point` (a `CadCommand` has no
@@ -1462,7 +1462,7 @@ pub enum CmdResult {
label: &'static str,
},
/// Add a persistent `EqualDistance` constraint
/// (`crate::modules::draw::constrain::equal_distance`): the distance
/// (`crate::modules::parametric::equal_distance`): the distance
/// between `points[0]`/`points[1]` equals the distance between
/// `points[2]`/`points[3]`. The host resolves each point via
/// `sketch_constraints::nearest_sketch_point`, same reasoning as
+1
View File
@@ -339,6 +339,7 @@ fn format_values(template: &str, rendered: &str) -> Option<Vec<String>> {
pub fn ribbon_module_title(id: &str, fallback: &str) -> String {
match id {
"draw" => crate::tr!("ribbon-tab", "draw"),
"parametric" => crate::tr!("ribbon-tab", "parametric"),
"annotate" => crate::tr!("ribbon-tab", "annotate"),
"insert" => crate::tr!("ribbon-tab", "insert"),
"model" => crate::tr!("ribbon-tab", "model"),
-29
View File
@@ -2,7 +2,6 @@
mod changelog;
pub mod clipboard;
pub mod constrain;
pub mod defaults;
mod donate;
pub mod draw;
@@ -34,11 +33,6 @@ impl CadModule for DrawModule {
};
use crate::modules::insert::{create_block, insert_block};
use clipboard::{copy_clip, cut, paste};
use constrain::{
angle_tool, center_point_tool, coincident_tool, colinear, concentric, distance_tool, equal,
equal_distance_tool, fixed, horizontal, midpoint_tool, normal, parallel, perpendicular, point_on_curve_tool,
symmetric, tangent, vertical,
};
use draw::{arc, circle, ellipse, hatch, line, polyline, shapes};
use groups::{group, ungroup};
use layers::{
@@ -126,29 +120,6 @@ impl CadModule for DrawModule {
offset::tool().into(),
],
},
RibbonGroup {
title: "Constraints",
tools: vec![
horizontal::tool().into(),
vertical::tool().into(),
parallel::tool().into(),
perpendicular::tool().into(),
equal::tool().into(),
tangent::tool().into(),
normal::tool().into(),
coincident_tool::tool().into(),
distance_tool::tool().into(),
angle_tool::tool().into(),
concentric::tool().into(),
colinear::tool().into(),
fixed::tool().into(),
symmetric::tool().into(),
center_point_tool::tool().into(),
midpoint_tool::tool().into(),
point_on_curve_tool::tool().into(),
equal_distance_tool::tool().into(),
],
},
RibbonGroup {
title: "Annotation",
tools: vec![
+1
View File
@@ -27,6 +27,7 @@ pub use ocs_plugin_api::ribbon::{
pub mod annotate;
pub mod draw;
pub mod insert;
pub mod parametric;
pub mod model;
pub mod layout;
pub mod manage;
+1 -1
View File
@@ -47,7 +47,7 @@ impl CadModule for ModelModule {
"model"
}
fn title(&self) -> &'static str {
"Modelling"
"Model"
}
fn ribbon_groups(&self) -> &[RibbonGroup] {
@@ -24,7 +24,7 @@ pub mod coincident_tool {
id: "CCONSTRAINT",
label: "Coincident",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/coincident.svg"
"../../../assets/icons/constrain/coincident.svg"
)),
event: ModuleEvent::Command("CCONSTRAINT".to_string()),
}
@@ -17,7 +17,7 @@ pub mod equal_distance_tool {
id: "EDCONSTRAINT",
label: "Equal Distance",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/equal_distance.svg"
"../../../assets/icons/constrain/equal_distance.svg"
)),
event: ModuleEvent::Command("EDCONSTRAINT".to_string()),
}
@@ -36,3 +36,46 @@ pub use tools::{
tangent, vertical,
};
pub use value::{angle_tool, distance_tool, AngleConstraintCommand, DistanceConstraintCommand};
use crate::modules::{CadModule, RibbonGroup};
pub struct ParametricModule;
impl CadModule for ParametricModule {
fn id(&self) -> &'static str {
"parametric"
}
fn title(&self) -> &'static str {
"Parametric"
}
fn ribbon_groups(&self) -> &[RibbonGroup] {
static GROUPS: std::sync::OnceLock<Vec<RibbonGroup>> = std::sync::OnceLock::new();
GROUPS.get_or_init(|| {
vec![RibbonGroup {
title: "Constraints",
tools: vec![
horizontal::tool().into(),
vertical::tool().into(),
parallel::tool().into(),
perpendicular::tool().into(),
equal::tool().into(),
tangent::tool().into(),
normal::tool().into(),
coincident_tool::tool().into(),
distance_tool::tool().into(),
angle_tool::tool().into(),
concentric::tool().into(),
colinear::tool().into(),
fixed::tool().into(),
symmetric::tool().into(),
center_point_tool::tool().into(),
midpoint_tool::tool().into(),
point_on_curve_tool::tool().into(),
equal_distance_tool::tool().into(),
],
}]
})
}
}
@@ -25,7 +25,7 @@ pub mod center_point_tool {
id: "CPCONSTRAINT",
label: "Center Point",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/center_point.svg"
"../../../assets/icons/constrain/center_point.svg"
)),
event: ModuleEvent::Command("CPCONSTRAINT".to_string()),
}
@@ -39,7 +39,7 @@ pub mod midpoint_tool {
id: "MPCONSTRAINT",
label: "Midpoint",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/midpoint.svg"
"../../../assets/icons/constrain/midpoint.svg"
)),
event: ModuleEvent::Command("MPCONSTRAINT".to_string()),
}
@@ -53,7 +53,7 @@ pub mod point_on_curve_tool {
id: "OCCONSTRAINT",
label: "Point on Curve",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/point_on_curve.svg"
"../../../assets/icons/constrain/point_on_curve.svg"
)),
event: ModuleEvent::Command("OCCONSTRAINT".to_string()),
}
@@ -9,7 +9,7 @@ pub mod horizontal {
id: "HCONSTRAINT",
label: "Horizontal",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/horizontal.svg"
"../../../assets/icons/constrain/horizontal.svg"
)),
event: ModuleEvent::Command("HCONSTRAINT".to_string()),
}
@@ -23,7 +23,7 @@ pub mod vertical {
id: "VCONSTRAINT",
label: "Vertical",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/vertical.svg"
"../../../assets/icons/constrain/vertical.svg"
)),
event: ModuleEvent::Command("VCONSTRAINT".to_string()),
}
@@ -37,7 +37,7 @@ pub mod parallel {
id: "PCONSTRAINT",
label: "Parallel",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/parallel.svg"
"../../../assets/icons/constrain/parallel.svg"
)),
event: ModuleEvent::Command("PCONSTRAINT".to_string()),
}
@@ -51,7 +51,7 @@ pub mod perpendicular {
id: "QCONSTRAINT",
label: "Perpendicular",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/perpendicular.svg"
"../../../assets/icons/constrain/perpendicular.svg"
)),
event: ModuleEvent::Command("QCONSTRAINT".to_string()),
}
@@ -65,7 +65,7 @@ pub mod equal {
id: "ECONSTRAINT",
label: "Equal",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/equal.svg"
"../../../assets/icons/constrain/equal.svg"
)),
event: ModuleEvent::Command("ECONSTRAINT".to_string()),
}
@@ -79,7 +79,7 @@ pub mod tangent {
id: "TCONSTRAINT",
label: "Tangent",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/tangent.svg"
"../../../assets/icons/constrain/tangent.svg"
)),
event: ModuleEvent::Command("TCONSTRAINT".to_string()),
}
@@ -93,7 +93,7 @@ pub mod concentric {
id: "NCONSTRAINT",
label: "Concentric",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/concentric.svg"
"../../../assets/icons/constrain/concentric.svg"
)),
event: ModuleEvent::Command("NCONSTRAINT".to_string()),
}
@@ -114,7 +114,7 @@ pub mod normal {
id: "NRCONSTRAINT",
label: "Normal",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/normal.svg"
"../../../assets/icons/constrain/normal.svg"
)),
event: ModuleEvent::Command("NRCONSTRAINT".to_string()),
}
@@ -128,7 +128,7 @@ pub mod colinear {
id: "LCONSTRAINT",
label: "Colinear",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/colinear.svg"
"../../../assets/icons/constrain/colinear.svg"
)),
event: ModuleEvent::Command("LCONSTRAINT".to_string()),
}
@@ -142,7 +142,7 @@ pub mod fixed {
id: "FXCONSTRAINT",
label: "Fixed",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/fixed.svg"
"../../../assets/icons/constrain/fixed.svg"
)),
event: ModuleEvent::Command("FXCONSTRAINT".to_string()),
}
@@ -156,7 +156,7 @@ pub mod symmetric {
id: "SYCONSTRAINT",
label: "Symmetric",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/symmetric.svg"
"../../../assets/icons/constrain/symmetric.svg"
)),
event: ModuleEvent::Command("SYCONSTRAINT".to_string()),
}
@@ -53,7 +53,7 @@ pub mod distance_tool {
id: "DCONSTRAINT",
label: "Distance",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/distance.svg"
"../../../assets/icons/constrain/distance.svg"
)),
event: ModuleEvent::Command("DCONSTRAINT".to_string()),
}
@@ -67,7 +67,7 @@ pub mod angle_tool {
id: "ACONSTRAINT",
label: "Angle",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/constrain/angle.svg"
"../../../assets/icons/constrain/angle.svg"
)),
event: ModuleEvent::Command("ACONSTRAINT".to_string()),
}
+1
View File
@@ -14,6 +14,7 @@ use crate::modules::CadModule;
pub fn all_modules() -> Vec<Box<dyn CadModule>> {
vec![
Box::new(super::draw::DrawModule),
Box::new(super::parametric::ParametricModule),
Box::new(super::model::ModelModule),
Box::new(super::insert::InsertModule),
Box::new(super::annotate::AnnotateModule),
+2 -2
View File
@@ -57,7 +57,7 @@ impl SketchRef {
/// click" vocabulary, one layer above the `cadkernel_constraints` primitives each maps
/// onto (that mapping is `constraint_map`, a later stage; see the design
/// doc §2). Named and grouped the same way the existing one-shot ribbon
/// tools are (`crate::modules::draw::constrain::tools`), plus the
/// tools are (`crate::modules::parametric::tools`), plus the
/// endpoint-picking kinds (`Coincident`, `Radius`, `Tangent`) that one-shot
/// group never needed.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
@@ -390,7 +390,7 @@ pub(crate) fn infer_coincident_refs(
impl ConstraintKind {
/// The short symbol a constraint glyph shows — matches the existing
/// ribbon icons (`crate::modules::draw::constrain::{tools,value}`) for
/// ribbon icons (`crate::modules::parametric::{tools,value}`) for
/// the kinds that have a one-click button, so the same glyph means the
/// same thing in both places.
pub fn glyph_symbol(&self) -> &'static str {