Re: Object boundaries [message #40205] |
Tue, 27 July 2004 16:08  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Michael Wallace wrote:
> Is it possible to determine the boundaries of an object in an object
> graphics view? For example, say that I wanted the coordinates of an
> IDLgrAxis with it's annotations included. I'd like to get the
> coordinates which describe the bounding box of the axis and everything
> else associated with it (title, tick labels, tick marks, etc).
>
> I have some other annotations in this view, and I want to make sure that
> there is sufficient spacing between these annotations and the
> annotations automatically created for the axis. I am currently
> positioning the other annotations at exact locations and most of the
> time they're fine, but if my axis gets some long tick labels which
> causes the axis title to get pushed out, the title can collide with the
> other annotations. I'm just searching for a way to position my other
> stuff relative to boundary of the axis annotation to ensure that there
> won't be any overlap. Ideas?
>
> -Mike
Graphics objects normally have XRANGE, YRANGE and ZRANGE properties that
tell you the coordinates of the object's bounding rectangle.
Unfortunately, for an IDLgrAxis this does not include the tick text and
title, but you can get those separately. Consider the following code...
oaxis = obj_new('idlgraxis')
xobjview, oaxis
oaxis->GetProperty, XRANGE=xr, YRANgE=yr, ZRANgE=zr
print, xr, yr, zr
; 0.00000000 1.0000000
; 0.00000000 0.20000000
; 0.00000000 0.00000000
oaxis->GetProperty, TICKTEXT=ott
ott->GetProperty, XRANGE=xr_tt, YRANGE=yr_tt, ZRANGE=zr_tt
print, xr_tt, yr_tt, zr_tt
; -0.047485654 1.0474857
; -0.081563380 -0.020111518
; 0.00000000 0.00000000
;; Ditto for the TITLE object, but you'll have to check if it is
;; valid first.
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|
Re: Object boundaries [message #40206 is a reply to message #40205] |
Tue, 27 July 2004 15:41   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
Michael Wallace wrote:
> Is it possible to determine the boundaries of an object in an object
> graphics view? For example, say that I wanted the coordinates of an
> IDLgrAxis with it's annotations included. I'd like to get the
> coordinates which describe the bounding box of the axis and everything
> else associated with it (title, tick labels, tick marks, etc).
>
There are a couple of ways.
You can use my bounding box object available here:
http://www.acoustics.washington.edu/~towler/RHTgrAABBRef.htm l
It is a child of IDLgrModel which can return the bounds of all of the
objects contained within it in position/extents form:
IDL> orb=obj_new('orb', radius=3.5, pos=[5,10,12])
% Compiled module: ORB__DEFINE.
IDL> bbox=obj_new('RHTgrAABB')
% Compiled module: RHTGRAABB__DEFINE.
IDL> bbox->add, orb
% Loaded DLM: RHTGRAABB.
IDL> bbox->getaabb, position=p, extents=e
IDL> print, p
5.00000 10.0000 12.0000
IDL> print, e
3.49021 3.49021 3.50000
It does require a DLM which I have compiled for Solaris and Windows.
Or you could use the RSI supplied get_obj_range.pro which might be a
better fit since it seems to deal with text in a special way. Don't
know for sure since I haven't played with it. You can find it in
$IDL_DIR/lib/utilities
-Rick
> I have some other annotations in this view, and I want to make sure that
> there is sufficient spacing between these annotations and the
> annotations automatically created for the axis. I am currently
> positioning the other annotations at exact locations and most of the
> time they're fine, but if my axis gets some long tick labels which
> causes the axis title to get pushed out, the title can collide with the
> other annotations. I'm just searching for a way to position my other
> stuff relative to boundary of the axis annotation to ensure that there
> won't be any overlap. Ideas?
>
> -Mike
|
|
|
Re: Object boundaries [message #40343 is a reply to message #40205] |
Mon, 02 August 2004 09:18  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
> Graphics objects normally have XRANGE, YRANGE and ZRANGE properties that
> tell you the coordinates of the object's bounding rectangle.
> Unfortunately, for an IDLgrAxis this does not include the tick text and
> title, but you can get those separately. Consider the following code...
>
> oaxis = obj_new('idlgraxis')
> xobjview, oaxis
> oaxis->GetProperty, XRANGE=xr, YRANgE=yr, ZRANgE=zr
> print, xr, yr, zr
> ; 0.00000000 1.0000000
> ; 0.00000000 0.20000000
> ; 0.00000000 0.00000000
> oaxis->GetProperty, TICKTEXT=ott
> ott->GetProperty, XRANGE=xr_tt, YRANGE=yr_tt, ZRANGE=zr_tt
> print, xr_tt, yr_tt, zr_tt
> ; -0.047485654 1.0474857
> ; -0.081563380 -0.020111518
> ; 0.00000000 0.00000000
> ;; Ditto for the TITLE object, but you'll have to check if it is
> ;; valid first.
While this works, is there any way to remove the call to xobjview? When
I remove that call and try the code, I get back 0.0 for all of the tick
text ranges. Is this because IDL doesn't know where it is before it's
drawn? If so, can I just create a temporary IDLgrBuffer or something,
and draw to it and grab the numbers from that? If this is the solution,
that seems pretty ugly to have to create a random IDLgrBuffer in the
middle of my code, but that's the way RSI works, I suppose. ;-)
-Mike
|
|
|