comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Text size weirdness
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Text size weirdness [message #44312] Mon, 06 June 2005 21:33
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
I have encountered a strange problem and I am at a loss to explain it.
I am using IDLgrWindow::GetTextDimensions with an IDLgrAxis and am
getting results that I don't expect. I have a plot with axes and other
annotations and I'd like to calculate the "bounding box" around all the
objects. The left bound of the box is determined by the Y axis and the
bottom bound of the box is determined by the X axis. I'd prefer that
this value be calculated rather than hard-coded.

Anyway, I am consistently calculating bounds that are too small. I can
always see part of the axis text, but never all of it. I've put
together an example that shows what I'm trying to explain. In my
example, I use a 1 x 1 viewplane and [0, 1] axis data ranges so there
aren't any coordinate transformations to gum up the works. I also have
both axes pass through the origin.

I had thought that if I got the X dimension of the Y axis text and
subtracted that from 0, I would get the left bound on the Y axis text.
The same goes for the X axis. If I got the Y dimension of X axis text
and subtracted that from 0, I would get the bottom bound on the X axis.
But, this doesn't work! I'm able to see part of the text, but never
all of it. Despite the various approaches I've tried so far, it remains
very consistent -- the "clipping line" seems to be in the same relative
position. It always shows just a little over half of the text.


; Setup objects and note the 1 x 1 viewplane
window = obj_new('idlgrwindow')
view = obj_new('idlgrview', VIEWPLANE_RECT = [0, 0, 1, 1])
model = obj_new('idlgrmodel')
xaxis = obj_new('idlgraxis', 0)
yaxis = obj_new('idlgraxis', 1)

model -> add, xaxis
model -> add, yaxis
view -> add, model
window -> SetProperty, GRAPHICS_TREE = view

; Set the tick text to recompute dimensions automatically
xaxis -> GetProperty, TICKTEXT = xtt
yaxis -> GetProperty, TICKTEXT = ytt
xtt -> SetProperty, RECOMPUTE_DIMENSIONS = 2
ytt -> SetProperty, RECOMPUTE_DIMENSIONS = 2

; Get the dimensions of the axes
xdims = window -> GetTextDimensions(xaxis)
ydims = window -> GetTextDimensions(yaxis)

; On my system I see the following values:
; print, xdims, ydims
; 1.0357957 0.032621843 0.0000000
; 0.037679673 1.0326218 0.0000000

; Reset the viewplane to show all of the axis text
view -> SetProperty, VIEWPLANE_RECT = [-ydims[0], -xdims[1], 1, 1]

; When drawn, part of the labels are clipped off! What's going on?
; I thought I had positioned the viewplane at the edge according to
; to the text dimensions!

window -> draw


By the way, I reset the viewplane only because that was the easiest way
for me to demonstrate the problem. The viewplane size didn't change and
the data ranges were always [0, 1], so I can't figure out why
GetTextDimensions gives me numbers that are too small. When I add
titles to the axes, the same thing happens, except it's the titles
rather than the axis labels that get sliced off.

Have I made a wrong assumption about how GetTextDimensions works? Or
how IDLgrAxes work? Or how IDL works? Any idea of why this happens and
how to fix it? I just want to know where the axis text is. Is that too
much to ask? Why can't the answer just be 42?

-Mike
[Message index]
 
Read Message
Previous Topic: Re: Adding an annotation to an iTool programmatically
Next Topic: Re: Help with XML and DTD/Shema !!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 21:01:42 PDT 2025

Total time taken to generate the page: 2.23618 seconds