Skip to content

text rotation in VTK different from vcs way #503

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

Closed
doutriaux1 opened this issue Jul 19, 2014 · 43 comments · Fixed by #1013
Closed

text rotation in VTK different from vcs way #503

doutriaux1 opened this issue Jul 19, 2014 · 43 comments · Fixed by #1013
Assignees
Milestone

Comments

@doutriaux1
Copy link
Contributor

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

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

Ok pdf (converted to png) gives:
pdf

@doutriaux1
Copy link
Contributor Author

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

@alliepiper
Copy link
Contributor

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

What test produces that image for testing?

@doutriaux1
Copy link
Contributor Author

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

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

and here is now
texts

@doutriaux1
Copy link
Contributor Author

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

and just for fun, 45 degrees angle old way
texts_old

@doutriaux1
Copy link
Contributor Author

and 45 degree new way
texts

@durack1
Copy link
Member

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 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 commented Oct 2, 2014

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

@doutriaux1
Copy link
Contributor Author

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

@alliepiper
Copy link
Contributor

Taking a look now...

alliepiper 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.
@alliepiper
Copy link
Contributor

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
@alliepiper
Copy link
Contributor

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

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.

@alliepiper
Copy link
Contributor

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

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 commented Jan 7, 2015

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

@aashish24
Copy link
Contributor

@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 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

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

@durack1
Copy link
Member

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

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

@durack1
Copy link
Member

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

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 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 modified the milestones: 2.1, 2.2 Feb 2, 2015
@aashish24
Copy link
Contributor

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

@durack1 I will start a build on crunchy.

@doutriaux1
Copy link
Contributor Author

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

@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

overall we're getting closer

@doutriaux1
Copy link
Contributor Author

oh also just checked svg
top alignment is wrong

@doutriaux1
Copy link
Contributor Author

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

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...

@alliepiper
Copy link
Contributor

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

thanks @dlonie pdf is used a lot!

@alliepiper
Copy link
Contributor

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
Development

Successfully merging a pull request may close this issue.

4 participants