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

Svg update #1350

Merged
merged 7 commits into from
Jul 4, 2023
Merged

Svg update #1350

merged 7 commits into from
Jul 4, 2023

Conversation

jmwright
Copy link
Member

PRs #1277 and #1325 are both open with SVG export changes, but neither one fixed this issue for me. There was an extra bottom-right margin that I could not remove in the resulting SVG, and I wanted my SVGs to fill the image edge to edge for my use case while still respecting the top/left margins. These changes accomplish that.

Below are before and after examples.

Before:
Screenshot from 2023-06-14 21-38-18

After:
Screenshot from 2023-06-14 21-36-17

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Merging #1350 (53eead1) into master (7143ead) will decrease coverage by 0.14%.
The diff coverage is 93.33%.

❗ Current head 53eead1 differs from pull request most recent head 2a8b413. Consider uploading reports for the commit 2a8b413 to get more accurate results

@@            Coverage Diff             @@
##           master    #1350      +/-   ##
==========================================
- Coverage   94.30%   94.17%   -0.14%     
==========================================
  Files          26       26              
  Lines        5584     5594      +10     
  Branches      954      958       +4     
==========================================
+ Hits         5266     5268       +2     
- Misses        187      194       +7     
- Partials      131      132       +1     
Impacted Files Coverage Δ
cadquery/__init__.py 87.50% <0.00%> (ø)
cadquery/assembly.py 96.61% <ø> (ø)
cadquery/cq.py 92.23% <ø> (ø)
cadquery/occ_impl/exporters/svg.py 96.92% <100.00%> (+0.25%) ⬆️
cadquery/occ_impl/sketch_solver.py 91.19% <100.00%> (ø)

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@adam-urbanczyk adam-urbanczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. I assume that the black border in the "after" picture is some artifact not coming from CQ.

@jmwright
Copy link
Member Author

I assume that the black border in the "after" picture is some artifact not coming from CQ.

Correct. I must have gotten part of the frame of the app when I did the screenshot.

Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to propose the following changes:

  1. Explicitly choose to recompute width or height.

    • With the current PR the user does not know ahead of time which dimension will be recomputed.

      I get surprised to find either one of width/height changed.

    • It is more straightforward to specify a fixed width or height. The user will likely have one in mind and does not need to specify both since the other is recomputed.

      I can then say I want a width of 200 pixels and the height fits automatically.

  2. The current PR handling of margin is inconsistent with fitView=False. I suggest to respect the width or height value given - do not change it according to margin (margin padded to inside of width and height).

Please see these changes here:
lorenzncode@6aab3be

The fitView option was removed. Instead, you can fit by specifying -1 for one of the dimensions.

This results in a width of 200, height is computed:

width = 200
height = -1 

This results in a height of 100, width is computed:

width = -1 
height = 100 

@jmwright
Copy link
Member Author

jmwright commented Jul 3, 2023

@lorenzncode I've made those changes (except for the test changes), but I'm not convinced that using -1 for autofit is the best way. Maybe we should allow the user to leave out the other dimension from opts or set it to None.

@adam-urbanczyk
Copy link
Member

None sounds more pythonic

Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @jmwright!

@jmwright jmwright merged commit 63afebe into master Jul 4, 2023
@jmwright jmwright deleted the svg_update branch July 4, 2023 12:18
@jmwright
Copy link
Member Author

jmwright commented Jul 4, 2023

@adam-urbanczyk It looks like AppVeyor is grabbing the OCP 7.7.1 pre-release and it might be breaking the builds.

TypeError: GetColor(): incompatible function arguments. The following argument types are supported:

@adam-urbanczyk
Copy link
Member

Should be solved, I moved 7.7.1 to dev

@adam-urbanczyk
Copy link
Member

Hm, not quite. Seems that 7.7.1 is available from the conda-forge channel even though the PR is not merged.

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.

3 participants