Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions crates/engine/src/cmd/labels.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! View › Labeling (lock, pause, unplaced labels, convert to annotation), the Style tab's label
//! visibility range and placement, and a layer's label classes (#618).
//! The Labeling tab (#897): Map Labeling (lock, pause, unplaced labels, convert to annotation), a
//! layer's label visibility range and placement, and its label classes (#618).

use rustgis_data::{Dataset, Field, FieldType, Geometry, GeometryType, Value as Attr};
use rustgis_map::symbology::{MAX_LABEL_CLASSES, label_class_name};
Expand All @@ -12,28 +12,28 @@ use crate::{CmdResult, CommandSpec as C, Session};

pub fn commands() -> Vec<C> {
vec![
C::new("labels.lock", "Lock", "View › Labeling", |s, p| {
C::new("labels.lock", "Lock", "Labeling › Map Labeling", |s, p| {
let d = &mut s.map_mut().label_display;
d.locked = b(p, "on").unwrap_or(!d.locked);
Ok(json!({"locked": d.locked}))
})
.view()
.params(r#"{"on"?: bool}"#),
C::new("labels.pause", "Pause", "View › Labeling", |s, p| {
C::new("labels.pause", "Pause", "Labeling › Map Labeling", |s, p| {
let d = &mut s.map_mut().label_display;
d.paused = b(p, "on").unwrap_or(!d.paused);
Ok(json!({"paused": d.paused}))
})
.view()
.params(r#"{"on"?: bool}"#),
C::new("labels.viewUnplaced", "View Unplaced", "View › Labeling", |s, p| {
C::new("labels.viewUnplaced", "View Unplaced", "Labeling › Map Labeling", |s, p| {
let d = &mut s.map_mut().label_display;
d.show_unplaced = b(p, "on").unwrap_or(!d.show_unplaced);
Ok(json!({"showUnplaced": d.show_unplaced}))
})
.view()
.params(r#"{"on"?: bool}"#),
C::new("labels.fonts", "Label Fonts", "Style › Text Symbol", |_, p| {
C::new("labels.fonts", "Label Fonts", "View › Windows › Labeling", |_, p| {
// The families a font picker lists, those containing `search` (in any case) if given.
// While the app is still indexing them (commands run on its UI thread), none yet,
// and `indexing` says so: asking again later lists them.
Expand All @@ -45,16 +45,16 @@ pub fn commands() -> Vec<C> {
})
.view()
.params(r#"{"search"?: text in the family name} → {"fonts": [the installed font families, by name], "indexing"?: true (still being indexed: none listed yet)}"#),
C::new("labels.convert", "Convert To Annotation", "View › Labeling", convert)
C::new("labels.convert", "Convert To Annotation", "Labeling › Map Labeling", convert)
.when(need_feature_layer)
.params(r#"{"layer"?, "name"?: string}"#),
C::new("labels.scaleRange", "Label Visibility Range", "Style › Label Range", scale_range)
C::new("labels.scaleRange", "Label Visibility Range", "Labeling › Label Range", scale_range)
.when(need_feature_layer)
.params(r#"{"layer"?, "class"?: name (none: the Default class, by whatever name it has), "min"?: scale|null (out beyond), "max"?: scale|null (in beyond), "clear"?: bool (clears the scale and distance limits, as Clear Limits does)}"#),
C::new("labels.distanceRange", "Label Distance Range", "Style › Label Range", distance_range)
C::new("labels.distanceRange", "Label Distance Range", "Labeling › Label Range", distance_range)
.when(need_feature_layer)
.params(r#"{"layer"?, "class"?: name (none: the Default class, by whatever name it has), "closest"?: metres|null, "farthest"?: metres|null, "clear"?: bool}"#),
C::new("labels.placement", "Label Placement", "Style › Label Placement", |s, p| {
C::new("labels.placement", "Label Placement", "Labeling › Label Placement", |s, p| {
let code = ps(p, "position").ok_or("position is required")?;
let pos = LabelPlacement::from_code(code).ok_or_else(|| format!("unknown placement '{code}'"))?;
with_class(s, p, |c| c.placement = pos)
Expand Down
6 changes: 3 additions & 3 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ pub fn commands() -> Vec<C> {
}).params(r#"{"layer"?, "on"?: bool (toggles when omitted)}"#)
.view()
.when(need_layer),
C::new("labels.enable", "Label", "Style › Labels", |s, p| {
C::new("labels.enable", "Label", "Labeling › Labels", |s, p| {
let on = b(p, "on");
with(s, p, |l| l.labels.enabled = on.unwrap_or(!l.labels.enabled))
})
.when(need_feature_layer)
.params(r#"{"layer"?, "on"?: bool}"#),
C::new("labels.field", "Label Field", "Style › Label Class", |s, p| {
C::new("labels.field", "Label Field", "Labeling › Label Class", |s, p| {
let name = s_req(p, "field")?.to_string();
let id = s.layer_id(p)?;
let fname = s.map().layer(id).and_then(|l| l.dataset.field_index(&name).and_then(|i| l.dataset.fields.get(i)).map(|f| f.name.clone()));
Expand All @@ -298,7 +298,7 @@ pub fn commands() -> Vec<C> {
})
}).params(r#"{"layer"?, "class"?: name (none: the Default class, by whatever name it has), "field": name}"#)
.when(need_feature_layer),
C::new("labels.style", "Text Symbol", "Style › Text Symbol", |s, p| {
C::new("labels.style", "Text Symbol", "Labeling › Text Symbol", |s, p| {
let size = f(p, "size").map(|v| v.clamp(*LABEL_SIZE.start(), *LABEL_SIZE.end()) as f32);
let color = s.get_color(p, "color")?;
let (halo, bold, italic) = (b(p, "halo"), b(p, "bold"), b(p, "italic"));
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ fn identify_reports_every_overlapping_feature() {

#[test]
fn label_size_stays_within_what_text_symbol_shows() {
// Style › Text Symbol offers the range `labels.style` accepts (#457): 72 pt is kept, and
// Labeling › Text Symbol offers the range `labels.style` accepts (#457): 72 pt is kept, and
// anything outside is brought back to the nearest end.
let mut s = world();
let size = |s: &Session| s.map().layers.iter().find(|l| l.name == "Countries").map(|l| f64::from(l.labels.default.size));
Expand Down
2 changes: 1 addition & 1 deletion crates/map/src/symbology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ fn jenks(sorted: &[f64], k: usize) -> Vec<f64> {
breaks
}

/// The label sizes `labels.style` accepts, in points (Style › Text Symbol).
/// The label sizes `labels.style` accepts, in points (Labeling › Text Symbol).
pub const LABEL_SIZE: std::ops::RangeInclusive<f64> = 4.0..=72.0;

/// The most label classes a layer keeps besides its Default class.
Expand Down
4 changes: 2 additions & 2 deletions crates/ui-egui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! L6: the RustGIS desktop front end, built around a ribbon (Home, Data, Style, Edit, Analyze,
//! View, Publish), the Layers and Browser panes, a Tools pane, the map view, the
//! L6: the RustGIS desktop front end, built around a ribbon (Home, Data, Style, Labeling, Edit,
//! Analyze, View, Publish), the Layers and Browser panes, a Tools pane, the map view, the
//! attribute table and the status bar.
//!
//! The UI is thin: it reads [`Session`] state and runs commands by id ([`RustGisApp::run`]).
Expand Down
Loading
Loading