Skip to content
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

Negative distance #413

Merged
merged 4 commits into from
Mar 23, 2022
Merged

Negative distance #413

merged 4 commits into from
Mar 23, 2022

Conversation

amolenaar
Copy link
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

If an element is overlayed by another element, it can not be selected.

Issue Number: gaphor/gaphor#1368

What is the new behavior?

Elements are selected based on the distance to it's boundary.

  • negative distance is calculated as the distance within an element to it's closed boundary
  • negative distance (inside) is always preferred over a positive distance (outside of the element)
  • to find the right element, find the item with the highest negative distance (e.i. closest to 0)

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Use negative numbers to denote distance to the border from inside the
rectangle.
amolenaar and others added 2 commits March 18, 2022 21:38
Covered by another item. Instead look at the distance to a border of an
element, so underlaying elements can be selected.

Elements can play with this. Negative values closest to 0 (the highest
values) take precedence.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 19, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.01%.

Quality metrics Before After Change
Complexity 1.96 ⭐ 1.97 ⭐ 0.01 👎
Method Length 37.10 ⭐ 37.78 ⭐ 0.68 👎
Working memory 7.00 🙂 6.95 🙂 -0.05 👍
Quality 79.13% 79.14% 0.01% 👍
Other metrics Before After Change
Lines 1230 1291 61
Changed files Quality Before Quality After Quality Change
gaphas/geometry.py 68.05% 🙂 67.97% 🙂 -0.08% 👎
gaphas/handlemove.py 78.38% ⭐ 78.36% ⭐ -0.02% 👎
gaphas/item.py 83.27% ⭐ 83.15% ⭐ -0.12% 👎
tests/test_element.py 82.87% ⭐ 82.87% ⭐ 0.00%
tests/test_geometry.py 88.28% ⭐ 88.52% ⭐ 0.24% 👍
tests/test_tool_item.py 90.21% ⭐ 88.75% ⭐ -1.46% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gaphas/geometry.py intersect_line_line 7 ⭐ 203 😞 15 😞 43.41% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/geometry.py point_on_rectangle 17 🙂 136 😞 10 😞 48.80% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/item.py Element.__init__ 0 ⭐ 200 😞 13 😞 53.21% 🙂 Try splitting into smaller methods. Extract out complex expressions
gaphas/geometry.py distance_line_point 4 ⭐ 176 😞 8 🙂 60.67% 🙂 Try splitting into smaller methods
gaphas/geometry.py Rectangle.__iadd__ 3 ⭐ 101 🙂 13 😞 60.67% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@amolenaar amolenaar changed the base branch from master to main March 23, 2022 19:35
@amolenaar amolenaar merged commit a20f60f into main Mar 23, 2022
@amolenaar amolenaar deleted the negative-distance branch March 23, 2022 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant