For SVG exports, shift PlotCurveItems to be about 0,0#2728
Merged
j9ac9k merged 6 commits intopyqtgraph:masterfrom Jun 6, 2023
Merged
For SVG exports, shift PlotCurveItems to be about 0,0#2728j9ac9k merged 6 commits intopyqtgraph:masterfrom
j9ac9k merged 6 commits intopyqtgraph:masterfrom
Conversation
6b5e51e to
86a6243
Compare
j9ac9k
commented
May 22, 2023
Member
Author
|
This PR is working again, but I'm still puzzled by two things.
Ideally, I would be able to apply the QTransform that shifts the GraphicsItem to the center, if that method works we can use that same method for scatter plots and other graphics items without a bunch of if/elif statements. |
b93c03b to
98ac81c
Compare
Member
Author
|
Looks like this type of annotation needs python 3.9+ ...while I could use the 3.8 compatible variant, we should have dropped python 3.8 already per NEP-29.... will let this PR sit idle until we actually drop python 3.8. |
2a14aad to
6419c0d
Compare
Member
Author
|
...and somewhere along the way I broke the exporter, it's no longer showing the curve in the SVG 😆 Oh, exiting prematurely in the case of PlotDataItem was apparently not a good idea in hindsight (even tho it saved me from the console log/spam). |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2661
Fixes #2018
Fixes #1849
This one is a doozy...
In the SVG exporter; there is a QPainter draw operation that occurs to a QDataBuffer that is interacting w/ a QSvgGenerator. The issue is that the positional information in the view (x and y coordinates for line to, move to, etc), are relatively high (> 1E8) and small differences between values (in the case of #2661, differences in increments of 10) are lost.
The way this PR attempts to get around this is by shifting PlotCurveItem's such that they are centered about (0, 0), and compute the transform for that shift, then apply the transform to the QPainter; so the curve appears to be in the correct place on the SVG output.
There are some more todo's with this PR
setData, andUsingdataBoundsviewRect())This PR also removed an unused lengthy PlotItem method that was left over after its usages were removed in 2012. For now I am commenting out the method as it looks to do that similar kind of translation and scaling we want, so I may need to borrow some code from it.
PlotItem.writeSvgCurvesshould be removed before this PR is merged.While testing, I attempted to get scatter plots to work in a similar fashion but could not get it working; so I decided to give up on that effort since I'm not sure if anyone cares about scatter plots that are placed in positions with larger absolute values.