Repository navigation
Land #2825, #2347, #2350, #2103, #3164: PER, TAN and Center from anywhere on the object, Tab through every snap, CIRCLE tangents, viewport-frozen layers #3351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 26 commits
90a239b
97fbaf7
98401d6
f4f0702
4a0063f
64cb95d
55ec024
4ce72c6
8acdcee
595ccf2
c40ff96
a3560a1
28ed9c5
1998da2
29bf02b
1b577e9
c00bc59
b1dcb46
c2af11d
a2f7321
080c96a
5bfba91
6971715
0ca0af9
9746b69
fe3b20a
ded4122
ca90388
472d366
71f4879
0314c8b
c647cb4
0b2cfae
f8769d9
3944964
334bcc3
7aaee29
d049a1c
adca169
17e0c81
7afe6b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,18 +127,31 @@ pub fn snap_name(m: u32) -> &'static str { | |
| } | ||
|
|
||
| /// The candidate snaps near `cursor` for Tab cycling: the snap [`crate::snap::osnap`] picks | ||
| /// first, then the closest snap of each other mode in `osmode`, nearest first, without repeats. | ||
| /// first, then every other snap of the modes in `osmode` under the aperture (each endpoint of | ||
| /// each object, each intersection …; [`crate::snap::osnap_all`]), best first, without repeats. | ||
| pub fn snap_candidates(d: &Drawing, space: &Space, cursor: Vec2, aperture: f64, osmode: u32, base: Option<Vec2>, deferred: bool) -> Vec<SnapHit> { | ||
| if osmode & !mode::HATCH == 0 || osmode & mode::OFF != 0 { | ||
| snap_candidates_with_frozen(d, space, cursor, aperture, osmode, base, deferred, &[]) | ||
| } | ||
|
|
||
| /// [`snap_candidates`] skipping entities (and block leaves) on `frozen` layers in `space`. | ||
| #[allow(clippy::too_many_arguments)] | ||
| pub fn snap_candidates_with_frozen( | ||
| d: &Drawing, | ||
| space: &Space, | ||
| cursor: Vec2, | ||
| aperture: f64, | ||
| osmode: u32, | ||
| base: Option<Vec2>, | ||
| deferred: bool, | ||
| frozen: &[String], | ||
| ) -> Vec<SnapHit> { | ||
| // A base that is not a number would give meaningless perpendiculars and tangents. | ||
| if osmode & !mode::HATCH == 0 || osmode & mode::OFF != 0 || base.is_some_and(|b| !b.is_finite()) { | ||
| return Vec::new(); | ||
| } | ||
| let osnap = |m: u32| crate::snap::osnap(d, space, cursor, aperture, m, base, deferred); | ||
| let extra = osmode & mode::HATCH; | ||
| let mut per_mode: Vec<SnapHit> = mode::ALL.iter().filter(|(b, _)| osmode & b != 0).filter_map(|(b, _)| osnap(*b | extra)).collect(); | ||
| per_mode.sort_by(|a, b| a.point.dist(cursor).total_cmp(&b.point.dist(cursor))); | ||
| let mut out: Vec<SnapHit> = osnap(osmode).into_iter().collect(); | ||
| for h in per_mode { | ||
| if !out.iter().any(|o| o.mode == h.mode && o.point.near(h.point, aperture * 1e-6)) { | ||
| let mut out: Vec<SnapHit> = crate::snap::osnap_with_frozen(d, space, cursor, aperture, osmode, base, deferred, frozen).into_iter().collect(); | ||
| for h in crate::snap::osnap_all_with_frozen(d, space, cursor, aperture, osmode, base, deferred, frozen) { | ||
| if !out.iter().any(|o| o.same(&h, aperture)) { | ||
| out.push(h); | ||
| } | ||
| } | ||
|
|
@@ -352,12 +365,15 @@ impl Session { | |
| Frame::Snap { mode } => { | ||
| // Snap the point with this mode alone, within the aperture. | ||
| let prompt = self.current_prompt(); | ||
| let space = self.space(); | ||
| let (doc, space, frozen) = { | ||
| let st = self.state()?; | ||
| (st.doc.clone(), st.edit_space(), st.viewport_frozen().to_vec()) | ||
| }; | ||
| let aperture = self.pixel_size() * self.settings.aperture.max(1.0); | ||
| let hatch = if self.settings.osnaphatch { mode::HATCH } else { 0 }; | ||
| let base = prompt.as_ref().and_then(|q| q.base); | ||
| let deferred = prompt.as_ref().is_some_and(|q| q.deferred); | ||
| let hit = crate::snap::osnap(self.doc()?, &space, p, aperture, mode | hatch, base, deferred); | ||
| let hit = crate::snap::osnap_with_frozen(&doc, &space, p, aperture, mode | hatch, base, deferred, &frozen); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the Tab-selected hit when an END override consumes a point. When an END override is pending, Consume the override with the hit the canvas already selected. Keep the re-query only for typed coordinates, which carry no
|
||
| match hit { | ||
| Some(h) if self.point_mods.is_empty() => return self.input_snapped(h), | ||
| Some(h) => p = h.point, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.