forked from 1b-agent/opencadstudio-upstream
fix(mesh): complete polygon mesh support
This commit is contained in:
commit
e8cb752fab
48 files changed
+5962
-1701
No files matched your search
@@ -2053,6 +2053,7 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
| "text_style_handle"
|
||||
| "arrowhead_handle"
|
||||
| "line_type_handle"
|
||||
| "block_content_handle"
|
||||
) {
|
||||
// Resolve a picked name back to the handle the MLEADER
|
||||
// stores. The style/text-style rows keep their existing
|
||||
@@ -2098,6 +2099,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
.map(|l| l.handle)
|
||||
}
|
||||
}
|
||||
"block_content_handle" => doc
|
||||
.block_records
|
||||
.iter()
|
||||
.find(|block| block.name == value)
|
||||
.map(|block| block.handle),
|
||||
_ => None,
|
||||
};
|
||||
for &handle in &handles {
|
||||
@@ -2121,10 +2127,52 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
"text_style_handle" => {
|
||||
if let Some(h) = resolved {
|
||||
ml.text_style_handle = Some(h);
|
||||
ml.context.text_style_handle = Some(h);
|
||||
ml.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::TEXT_STYLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
"arrowhead_handle" => {
|
||||
ml.arrowhead_handle = resolved;
|
||||
for root in &mut ml.context.leader_roots {
|
||||
for line in &mut root.lines {
|
||||
line.arrowhead_handle = resolved;
|
||||
line.override_flags.insert(
|
||||
acadrust::entities::LeaderLinePropertyOverrideFlags::ARROWHEAD,
|
||||
);
|
||||
}
|
||||
}
|
||||
ml.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::ARROWHEAD,
|
||||
);
|
||||
}
|
||||
"line_type_handle" => {
|
||||
ml.line_type_handle = resolved;
|
||||
for root in &mut ml.context.leader_roots {
|
||||
for line in &mut root.lines {
|
||||
line.line_type_handle = resolved;
|
||||
line.override_flags.insert(
|
||||
acadrust::entities::LeaderLinePropertyOverrideFlags::LINE_TYPE,
|
||||
);
|
||||
}
|
||||
}
|
||||
ml.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::LEADER_LINE_TYPE,
|
||||
);
|
||||
}
|
||||
"block_content_handle" => {
|
||||
if let Some(block_handle) = resolved {
|
||||
ml.block_content_handle = Some(block_handle);
|
||||
ml.context.block_content_handle = Some(block_handle);
|
||||
ml.context.has_block_contents = true;
|
||||
ml.context.block_content_location =
|
||||
ml.context.content_base_point;
|
||||
ml.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::BLOCK_CONTENT,
|
||||
);
|
||||
}
|
||||
}
|
||||
"arrowhead_handle" => ml.arrowhead_handle = resolved,
|
||||
"line_type_handle" => ml.line_type_handle = resolved,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,6 +382,8 @@ impl OpenCADStudio {
|
||||
self.snapper.snap_enabled,
|
||||
),
|
||||
texteditmode: self.texteditmode,
|
||||
quick_dimension_snap_priority: self.quick_dimension_snap_priority,
|
||||
dimension_continue_mode: self.dimension_continue_mode,
|
||||
textfill: crate::scene::text::sdf_atlas::textfill(),
|
||||
backup_on_save: self.backup_on_save,
|
||||
file_assoc_enabled: self.file_assoc_enabled,
|
||||
@@ -440,6 +442,8 @@ impl OpenCADStudio {
|
||||
self.snapper.enabled = modes.into_iter().collect();
|
||||
self.snapper.snap_enabled = snap_enabled;
|
||||
self.texteditmode = s.texteditmode;
|
||||
self.quick_dimension_snap_priority = s.quick_dimension_snap_priority.min(1);
|
||||
self.dimension_continue_mode = s.dimension_continue_mode.clamp(0, 1);
|
||||
crate::scene::text::sdf_atlas::set_textfill(s.textfill);
|
||||
self.backup_on_save = s.backup_on_save;
|
||||
self.file_assoc_enabled = s.file_assoc_enabled;
|
||||
|
||||
+81
-1
@@ -4657,6 +4657,32 @@ impl OpenCADStudio {
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::PropFieldLwChanged { field, value } => {
|
||||
let i = self.active_tab;
|
||||
let handles = self.property_target_handles(i);
|
||||
self.apply_property_op(i, "CHPROP", &handles, |app, handle| {
|
||||
if let Some(acadrust::EntityType::MultiLeader(leader)) =
|
||||
app.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
if field == "line_weight" {
|
||||
leader.line_weight = value;
|
||||
leader.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::LEADER_LINE_WEIGHT,
|
||||
);
|
||||
for root in &mut leader.context.leader_roots {
|
||||
for line in &mut root.lines {
|
||||
line.line_weight = value;
|
||||
line.override_flags.insert(
|
||||
acadrust::entities::LeaderLinePropertyOverrideFlags::LINE_WEIGHT,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::PropLinetypeChanged(lt) => {
|
||||
let i = self.active_tab;
|
||||
let handles = self.property_target_handles(i);
|
||||
@@ -4896,12 +4922,18 @@ impl OpenCADStudio {
|
||||
Message::PropVertexStep(delta) => {
|
||||
let i = self.active_tab;
|
||||
let handles = self.property_target_handles(i);
|
||||
// Vertex navigation applies to a single selected polyline.
|
||||
// Navigate the active vertex or table cell.
|
||||
let n = if handles.len() == 1 {
|
||||
match self.tabs[i].scene.document.get_entity(handles[0]) {
|
||||
Some(acadrust::EntityType::LwPolyline(p)) => p.vertices.len(),
|
||||
Some(acadrust::EntityType::Polyline2D(p)) => p.vertices.len(),
|
||||
Some(acadrust::EntityType::PolygonMesh(p)) => p.vertices.len(),
|
||||
Some(acadrust::EntityType::Face3D(face)) => {
|
||||
if face.is_triangle() { 3 } else { 4 }
|
||||
}
|
||||
Some(acadrust::EntityType::Polyline3D(p)) => {
|
||||
crate::entities::polyline::polyline3d_control_vertex_count(p)
|
||||
}
|
||||
Some(acadrust::EntityType::Table(table)) => {
|
||||
table.row_count().saturating_mul(table.column_count())
|
||||
}
|
||||
@@ -5115,6 +5147,54 @@ impl OpenCADStudio {
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
if matches!(
|
||||
field.as_str(),
|
||||
"line_color" | "text_color" | "block_content_color"
|
||||
| "background_fill_color"
|
||||
) {
|
||||
self.apply_property_op(i, "CHPROP", &handles, |app, handle| {
|
||||
if let Some(acadrust::EntityType::MultiLeader(leader)) =
|
||||
app.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
match field.as_str() {
|
||||
"line_color" => {
|
||||
leader.line_color = color;
|
||||
leader.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::LINE_COLOR,
|
||||
);
|
||||
for root in &mut leader.context.leader_roots {
|
||||
for line in &mut root.lines {
|
||||
line.line_color = color;
|
||||
line.override_flags.insert(
|
||||
acadrust::entities::LeaderLinePropertyOverrideFlags::LINE_COLOR,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
"text_color" => {
|
||||
leader.text_color = color;
|
||||
leader.context.text_color = color;
|
||||
leader.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::TEXT_COLOR,
|
||||
);
|
||||
}
|
||||
"block_content_color" => {
|
||||
leader.block_content_color = color;
|
||||
leader.context.block_content_color = color;
|
||||
leader.property_override_flags.insert(
|
||||
acadrust::entities::MultiLeaderPropertyOverrideFlags::BLOCK_CONTENT_COLOR,
|
||||
);
|
||||
}
|
||||
"background_fill_color" => {
|
||||
leader.context.background_fill_color = color;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
});
|
||||
self.tabs[i].properties.open_color_field = None;
|
||||
return Task::none();
|
||||
}
|
||||
if matches!(
|
||||
field.as_str(),
|
||||
"tbl_cell_content_color" | "tbl_cell_background_color"
|
||||
|
||||
Reference in new issue
Block a user