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

Home » Public Forums » archive » Re: Text size weirdness
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Text size weirdness [message #44306] Tue, 07 June 2005 09:09 Go to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> Well, try to get the location for axis text and add to it sizes. This
> works for me.


Well, it looks like I totally misunderstood the documentation. I had
thought that if you called GetTextDimensions with an axis, the little
buffer area between the axis and text would be included. However, I now
see that the the dimensions are only that of the text. *sigh* Well, at
least now I know.

-Mike
Re: Text size weirdness [message #44309 is a reply to message #44306] Tue, 07 June 2005 00:24 Go to previous messageGo to next message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Michael Wallace wrote:
> 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

Ok, this is the goog message :) My last canceled messge (visible at
google groups was I bit stuppid XD )

Well, try to get the location for axis text and add to it sizes. This
works for me.

; 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
xtt->GetProperty, LOCATIONS=lx
ytt->GetProperty, LOCATIONS=ly

xdims[1] += ABS(lx[1,0])
ydims[0] += ABS(ly[0,0])

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




--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
Re: Text size weirdness [message #44310 is a reply to message #44309] Tue, 07 June 2005 00:10 Go to previous messageGo to next message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Michael Wallace wrote:
> 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

Hi, I'm testing your code and something is wrong. Try to create your
axis with NOTEXT keyword set and show it dimensions. Are the same ??


--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
Re: Text size weirdness [message #44395 is a reply to message #44306] Wed, 08 June 2005 00:39 Go to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Michael Wallace wrote:
>> Well, try to get the location for axis text and add to it sizes. This
>> works for me.
>
>
>
> Well, it looks like I totally misunderstood the documentation. I had
> thought that if you called GetTextDimensions with an axis, the little
> buffer area between the axis and text would be included. However, I now
> see that the the dimensions are only that of the text. *sigh* Well, at
> least now I know.
>
> -Mike

Well, I learned the same lesson as you thanks to this post ;)

--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: MacTel
Next Topic: None

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

Current Time: Wed Oct 08 17:11:34 PDT 2025

Total time taken to generate the page: 0.19280 seconds