Feat: Phase 1.5 — viewport count in status bar + REVCLOUD command

Status bar: shows "N VP" pill (with tooltip) when in a paper layout that has
user viewports (id > 1). New Scene::viewport_count() method.

REVCLOUD: closed LwPolyline with arc bumps (bulge = 0.5) along each edge.
Click polygon corners, Enter to close into a revision cloud shape.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-04-02 23:52:35 +03:00
commit 1572d0c38f
3 changed files with 34 additions and 1 deletions

View file

@ -166,6 +166,7 @@ impl H7CAD {
tab.scene.current_layout.clone(),
self.layout_rename_state.as_ref(),
tab.scene.first_viewport_scale(),
tab.scene.viewport_count(),
)
]
.width(Fill)

View file

@ -228,6 +228,24 @@ impl Scene {
})
}
/// Count of user viewports (id > 1) in the current layout.
pub fn viewport_count(&self) -> usize {
if self.current_layout == "Model" {
return 0;
}
let layout_block = self.current_layout_block_handle();
if layout_block.is_null() {
return 0;
}
self.document.entities().filter(|e| {
if let EntityType::Viewport(vp) = e {
vp.id > 1 && vp.common.owner_handle == layout_block
} else {
false
}
}).count()
}
/// Sorted list of layout names: "Model" first, then paper layouts by tab order.
pub fn layout_names(&self) -> Vec<String> {
let mut names = vec!["Model".to_string()];

View file

@ -33,6 +33,8 @@ impl StatusBar {
rename_state: Option<&'a (String, String)>,
// Scale of the first user viewport in the active paper layout.
viewport_scale: Option<f64>,
// Number of user viewports in the current paper layout (0 = model space).
viewport_count: usize,
) -> Element<'a, Message> {
let menu_btn = button(text("").size(14).color(ICON_COLOR))
.on_press(Message::Command("MENU".into()))
@ -60,7 +62,12 @@ impl StatusBar {
"LAYOUT"
};
let scale_label = format_scale(viewport_scale);
let right_status = row![
let vp_label = if viewport_count > 0 {
format!("{} VP", viewport_count)
} else {
String::new()
};
let mut right_status = row![
tip(
toggle_pill("SNAP", snap_grid_on, Message::ToggleGridSnap),
"Snap to Grid\nF9"
@ -82,6 +89,13 @@ impl StatusBar {
status_pill(scale_label),
]
.spacing(2);
if !vp_label.is_empty() {
right_status = right_status.push(tip(
status_pill(vp_label).into(),
"Viewport count in active layout",
));
}
let right_status = right_status;
let mut bar = Row::new().align_y(iced::Center).spacing(0);
bar = bar.push(menu_btn);