Re: writing to 2 "windows" in idl? [message #5628] |
Fri, 19 January 1996 00:00 |
Mirko Vukovic
Messages: 124 Registered: January 1996
|
Senior Member |
|
|
cas@revelle.cdc.noaa.gov (Cathy Smith) wrote:
>
> Hi- I'd like to write out character strings to a gif imagee and determine
> their lengths (in pixels). I can do this using xyouts and this works for
> most of what I want to do. However, now I would like to find the length
> of a character string BEFORE I write it out. I tried writing out
> in the same color as my image to get the returned length and then writing
> it out again in the color I want. This works except that I cover up some
> lines on my original plot that I don't want covered. Is there a way to
> write to a "fake" device instead?
The trick I heard from a former colleague of mine (PHP) is to write using
xyouts, way out in the left field, meaning way outside the plot, and still
use xyouts to return the string length. So if your plot window covers
coordinates (0,0) to (10,10), then xyout,-100,-100, blah...
--
Mirko Vukovic, Ph.D. mirko.vukovic@grc.varian.com
Varian Research Center Phone: (415) 424-4969
3075 Hansen Way, M/S K-109 Fax: (415) 424-6988
Palo Alto, CA 94304-1025
|
|
|
Re: writing to 2 "windows" in idl? [message #5633 is a reply to message #5628] |
Thu, 18 January 1996 00:00  |
jlaw
Messages: 11 Registered: November 1995
|
Junior Member |
|
|
In article 96Jan17130850@revelle.cdc.noaa.gov, cas@revelle.cdc.noaa.gov (Cathy Smith) writes:
>
> Hi- I'd like to write out character strings to a gif imagee and determine
> their lengths (in pixels).
> <snip>
> This works except that I cover up some
> lines on my original plot that I don't want covered. Is there a way to
> write to a "fake" device instead?
>
Does this help?
IDL> plot,cos(indgen(100)/7)
IDL> device,get_write_Mask=smask
IDL> print,smask
255
IDL> device,set_write_mask=0 ; DO NOT WRITE TO ANY GRAPHICS PLANES
IDL> xyouts,50,0,'My string of text',wid=wid
IDL> print,wid
0.131250
IDL> device,set_write_mask=smask ; WRITE TO ALL GRAPHICS PLANES AGAIN..
IDL> xyouts,50,0,'My string of text',wid=wid
You could probably also do this with
device,set_graphics_function=something. Table 3.4 in my online help...
best of luck
f.
|
|
|
Re: writing to 2 "windows" in idl? [message #5634 is a reply to message #5633] |
Thu, 18 January 1996 00:00  |
hahn
Messages: 108 Registered: November 1993
|
Senior Member |
|
|
cas@revelle.cdc.noaa.gov (Cathy Smith) wrote:
> Hi- I'd like to write out character strings to a gif imagee and determine
> their lengths (in pixels). I can do this using xyouts and this works for
> most of what I want to do. However, now I would like to find the length
> of a character string BEFORE I write it out.
XYOutS has two keyword parameters that may help:
width=lg puts the length of the text into the variable lg.
Units is normalized coordinate units.
Charsize=-1 suppresses any graphical output.
> I tried writing out
> in the same color as my image to get the returned length and then writing
> it out again in the color I want. This works except that I cover up some
> lines on my original plot that I don't want covered. Is there a way to
> write to a "fake" device instead?
The above keywords should work with any device, no need to use a fake.
[remainder deleted]
Hope this helps
Norbert Hahn
|
|
|
Re: writing to 2 "windows" in idl? [message #5637 is a reply to message #5633] |
Thu, 18 January 1996 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
In article <CAS.96Jan17130850@revelle.cdc.noaa.gov>, cas@revelle.cdc.noaa.gov (Cathy Smith) writes:
|>
|> Hi- I'd like to write out character strings to a gif imagee and determine
|> their lengths (in pixels). I can do this using xyouts and this works for
|> most of what I want to do. However, now I would like to find the length
|> of a character string BEFORE I write it out. I tried writing out
|> in the same color as my image to get the returned length and then writing
|> it out again in the color I want. This works except that I cover up some
|> lines on my original plot that I don't want covered. Is there a way to
|> write to a "fake" device instead?
|>
You could use e.g.,
GXnoop = 5 ; This graphics function does no operation on the screen
device,get_graphics_function=oldgraphics ; Store
device,set_graphics_function=GXnoop ; Plot with the color that's there
device,font='-adobe-helvetica-bold-r-normal--10-100-75-75-p- 60-iso8859-1'
xyouts, x+4, y, string, /device,width=namew ,charsize=1.2,color=44
mmwidth=namew*n1
device,set_graphics_function=oldgraphics ; Put it back
xyouts, x-mmwidth-4, y, string, /device, width=namew ,charsize=1.2,color=222
Stein Vidar
|
|
|
Re: writing to 2 "windows" in idl? [message #5644 is a reply to message #5633] |
Thu, 18 January 1996 00:00  |
Eric Deutsch
Messages: 11 Registered: May 1995
|
Junior Member |
|
|
Cathy Smith wrote:
>
> Hi- I'd like to write out character strings to a gif imagee and determine
> their lengths (in pixels). I can do this using xyouts and this works for
> most of what I want to do. However, now I would like to find the length
> of a character string BEFORE I write it out. I tried writing out
> in the same color as my image to get the returned length and then writing
> it out again in the color I want. This works except that I cover up some
> lines on my original plot that I don't want covered. Is there a way to
> write to a "fake" device instead?
yes, there is a "Z-buffer" device which is a virtual device that lets you do these
sorts of things, but...
> The relevant parts of my code are:
>
> tvlct,/GET,r,g,b
> window, colors=223,xsize=n1,ysize=n2
> etc......
>
> device,font='-adobe-helvetica-bold-r-normal--10-100-75-75-p- 60-iso8859-1'
you are using an X hardware font here, and it is very unfortunate (but not
surprising, I guess) that you cannot use X hardware fonts when using the Z
device... As far as I know, the best you can do is use the Hershey fonts
(or a bitmapped font solution). Anyone know otherwise??
> xyouts, x+4, y, string, /device,width=namew ,charsize=1.2,color=44
> mmwidth=namew*n1
> xyouts, x-mmwidth-4, y, string, /device, width=namew ,charsize=1.2,color=222
However, if I understand your coding here, it looks to me like you're trying to
right-justify some text. IDL provides a nice facility for this with the xyouts
,ALIGN=1 keyword; and you can use ,ALIGN=0.5 to center text about the specified
X,Y coordinates.
Hope this helps..
Eric
--
------------------------------------------------------------ ----------------
Eric Deutsch email: deutsch@astro.washington.edu
Department of Astronomy Voice: (206) 616-2788
University of Washington FAX: (206) 685-0403
Box 351580 WWW: http://www.astro.washington.edu/deutsch
Seattle, WA 98195-1580 Physics/Astronomy Bldg., Room B356F
|
|
|