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

text rotation in VTK different from vcs way #503

Closed
doutriaux1 opened this issue Jul 19, 2014 · 43 comments
Closed

text rotation in VTK different from vcs way #503

doutriaux1 opened this issue Jul 19, 2014 · 43 comments
Assignees
Milestone

Comments

@doutriaux1
Copy link
Contributor

@doutriaux1 doutriaux1 commented Jul 19, 2014

If I "left justify" a text, and then rotate it, the "justify" seems to be applied to the rotated text.
Trying to show this here, I have a vertical centered and left justified text.

First putting 3 points on the same "y" location I would expect (with the letter rotated 90 degrees)

A     A
B     B
C  A  C
D  B  D

But in fact I get

A     A
B  A  B
C  B  C
D     D
@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Aug 4, 2014

Actually it seems that pdf outputs correctly but screen and png are not.
fdecomp5_linearity_pap_finalcol_rel_ensoleoftop20_pdsdet1djf1_pr_12panels_1900_1999_2000_2099

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Aug 4, 2014

Ok pdf (converted to png) gives:
pdf

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 22, 2014

@dlonie I think you're the right person to fix this, let me know if you need more details about it.

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Sep 23, 2014

@doutriaux1 Hmmm, that shouldn't be happening. I'll look into it.

What test produces that image for testing?

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 23, 2014

let me try to make a quick test for you
also it appears that png and pdf do not behave the same in that regard

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 23, 2014

here is a sample code with the "old" (1.5.1) output

import vcs

x=vcs.init()
#Plot a rectangle to show the bug issue
r=x.createfillarea()
r.x=[.25,.75,.75,.25]
r.y=[.25,.25,.75,.75]
r.color=242 # red?
x.plot(r)



# text rtated in middle/bottom
for i,valign in enumerate(["top","half","bottom"]):
  for j,halign in enumerate(["right","center","left"]):
    t=x.createtext()
    t.x=[.25*(1+i)]
    t.y=[.25*(1+j)]
    t.angle=90
    t.valign = valign
    t.halign= halign
    t.string=["%s-%s" % (valign,halign)]
    x.plot(t)

x.png("texts")
x.pdf("texts")
x.postscript("texts")

texts_old

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 23, 2014

and here is now
texts

@doutriaux1 doutriaux1 closed this Sep 23, 2014
@doutriaux1 doutriaux1 reopened this Sep 23, 2014
@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 23, 2014

for example look at top-center or top-right. Looking at it I see what VTK is doing it is using the "rotated" text to apply the alignements, whereas vcs is using the pre-rotated text. That might actually be better let me think about it some more with the scientists.
Now the one issue to fix right away is that pdfs are not consistent with pngs, here is what pdfs give us (in gimp)
texts_pdf
:

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 23, 2014

and just for fun, 45 degrees angle old way
texts_old

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Sep 23, 2014

and 45 degree new way
texts

@durack1
Copy link
Member

@durack1 durack1 commented Sep 23, 2014

Ok weird, these 45 degree plots are insightful.. It seems that the behavior is not consistent across each label, so the far left appear to be indexed to a cell lower than the far right..

I agree @doutriaux1 that this appears to show an inconsistency in the way labels are placed.. The difference between the png and pdf versions of the outputs is even more concerning - these should be identical!

@durack1
Copy link
Member

@durack1 durack1 commented Sep 24, 2014

I would vote to return the defaults back to the way the older VCS had them, so #503 (comment) in favour of #503 (comment) - in my opinion these are more consistent with a behaviour that I'd expect

@durack1
Copy link
Member

@durack1 durack1 commented Oct 2, 2014

I'm uncertain if any changes in #726 would affect how the plots above look..

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Oct 6, 2014

@dlonie if you can it would be nice to prioritize this one in your "After 2.0" list. Thanks.

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Oct 8, 2014

Taking a look now...

allisonvacanti pushed a commit that referenced this issue Oct 8, 2014
VTK has some oddball quirks for backwards compatibility -- this is one of
them. In a nutshell:

vtkTextProperty::SetOrientation: Rotates the text in the texture produced
by the text-rendering backend in VTK.

vtkTextActor::SetOrientation: Rotates the texture around the anchor point.

So previously the text was rendered at an angle to an oversized
rectangular texture, which was then aligned to the anchor-point, leading
to the unexpected results.
@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Oct 8, 2014

That branch should fix the alignment issues in the plots/pngs. The pdf/svg/ps exporter issue is a bug in VTK. That's up next....

doutriaux1 added a commit that referenced this issue Oct 8, 2014
Fix rotation/alignment issues in text. Ref #503
ok new files look good, thanks @dlonie approving merge
@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Oct 15, 2014

For reference, there is a fix pending in VTK for the exported text issue:

http://review.source.kitware.com/#/t/4851/

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Oct 15, 2014

nice! Does that fix BOTH pdf and postscript (they both produce different results than png)
Also can you put that patch in our UV-CDAT/VTK repo?
Thanks.

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Jan 7, 2015

They're in VTK's master at the moment. @aashish24, are we still planning to just bump the VTK version in uvcdat at some point? Or should these commits just be cherry-picked into the uvcdat fork of VTK?

@aashish24
Copy link
Contributor

@aashish24 aashish24 commented Jan 7, 2015

yes, I will merge release into the master today, update the SHA and the version, and then will update the VTK after I build it successfully with it. I have to sync up with @doutriaux1 but yes, we need to move forward

@durack1
Copy link
Member

@durack1 durack1 commented Jan 7, 2015

@aashish24 these changes wont make it into 2.1.0 will they?

@aashish24
Copy link
Contributor

@aashish24 aashish24 commented Jan 7, 2015

@durack1 I am sorry, they won't since it has significant changes and we already froze 2.1.0. We will do it in 2.1.1 though (or 2.2) depending on what Dean and Charles has to suggest.

@durack1
Copy link
Member

@durack1 durack1 commented Jan 7, 2015

@aashish24 ok.. It'd be great if you can tag a 2.1.1 fairly soon with this VTK change implemented.. We're trying to lock down some code against a known UV-CDAT version, and this text rotation stuff is an important tweak we'd like to include..

@aashish24
Copy link
Contributor

@aashish24 aashish24 commented Jan 7, 2015

Roger that. That is my intention as well. I will talk to @doutriaux1 about it.

@durack1
Copy link
Member

@durack1 durack1 commented Jan 7, 2015

@aashish24 it would also be good for us to test out the new code too, and make sure that it faithfully addresses the issue highlighted above (and my test case which shows differing results for outputs saved to png, ps and pdf)

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Jan 7, 2015

@aashish24 @dlonie let me know when it's in @durack1 and i will test it here.

@durack1
Copy link
Member

@durack1 durack1 commented Jan 20, 2015

@aashish24 @dlonie are these text rotation changes in master yet? @doutriaux1 and I are keen to test out the new code..

@aashish24
Copy link
Contributor

@aashish24 aashish24 commented Jan 21, 2015

I have one more branch to review and then I will bump the VTK. Sorry for some delay on this.

@durack1
Copy link
Member

@durack1 durack1 commented Jan 21, 2015

@aashish24 @dlonie no problem.. Looking forward to testing this so please do let both @doutriaux1 and I know when there's a PR or it's in master..

@doutriaux1 doutriaux1 removed this from the 2.1 milestone Feb 2, 2015
@doutriaux1 doutriaux1 added this to the 2.2 milestone Feb 2, 2015
@doutriaux1 doutriaux1 added this to the 2.2 milestone Feb 2, 2015
@doutriaux1 doutriaux1 removed this from the 2.1 milestone Feb 2, 2015
@aashish24
Copy link
Contributor

@aashish24 aashish24 commented Feb 5, 2015

VTK has been updated. @durack1 could you please verify if you are still seeing these issues. Make sure you build current master of UV-CDAT

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

@durack1 I will start a build on crunchy.

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

I ran the above test, here are the results:
Postscript:
Ok
PNG:
top alignment does seem to be a bit off
bottom right if off as well
PDF
right alignment wrong
top alignment wrong

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

@aashish24 @dlonie PS is h best one right now. We really need to make sure they ALL produce the SAME plots.

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

overall we're getting closer

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

oh also just checked svg
top alignment is wrong

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

hum.. .now looking at VTK sha we might still not be using the right VTK

2c7d13c885a67971201ab743205f988e60d6a37b

It does say it's uvcdat-master
@aashish24 are you sure you updated the sha?

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 5, 2015

looking on github this sha is 1 ahead and 4 behind kitware, so yep I'm getting the right VTK. But the output are still wrong.. Sorry...

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Feb 5, 2015

No worries, I half expected that -- text labels in PDFs don't support alignment very well using our exporter library, but I have a couple tricks up my sleeve. I'll see what I can come up with.

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Feb 6, 2015

thanks @dlonie pdf is used a lot!

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Feb 6, 2015

After #1013 and CDAT/VTK@9760973 are applied, the results are consistent across backends for me.

@doutriaux1 @durack1 can you try again?

@aashish24 I need you to review / merge http://review.source.kitware.com/#/t/5428 into VTK master, as the UVCDAT fonts uncovered a bug in our path renderer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants