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

Home » Public Forums » archive » Re: character size in normal coordinates
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: character size in normal coordinates [message #13610] Tue, 24 November 1998 00:00
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
David Fanning wrote:
>
> David Foster (foster@bial1.ucsd.edu) writes:
>
>> Since !D.[X|Y]_CH_SIZE give the width and height of the rectangle
>> that encloses the "average" character in the current font, in
>> device units (usually pixels) [from the Online help on !D]:
>>
>> x_ch_norm = !D.X_CH_SIZE / !D.X_SIZE
>> y_ch_norm = !D.Y_CH_SIZE / !D.Y_SIZE
>>
>> would be my guess. If your window is 100 pixels wide, and your
>> object is 50 pixels wide, then in normalized coordinates that
>> would be .5 . Or am I having a bad hair day?
>
> I would say your hair will be turning prematurely gray
> unless you cast one of those values on the right-hand
> side of the equation to FLOAT. :-)
>
> Cheers,
>
> David

Doh!

God I hate this pitfall!

Dave

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
Re: character size in normal coordinates [message #13616 is a reply to message #13610] Mon, 23 November 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
David Foster (foster@bial1.ucsd.edu) writes:

> Since !D.[X|Y]_CH_SIZE give the width and height of the rectangle
> that encloses the "average" character in the current font, in
> device units (usually pixels) [from the Online help on !D]:
>
> x_ch_norm = !D.X_CH_SIZE / !D.X_SIZE
> y_ch_norm = !D.Y_CH_SIZE / !D.Y_SIZE
>
> would be my guess. If your window is 100 pixels wide, and your
> object is 50 pixels wide, then in normalized coordinates that
> would be .5 . Or am I having a bad hair day?

I would say your hair will be turning prematurely gray
unless you cast one of those values on the right-hand
side of the equation to FLOAT. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Progamming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: character size in normal coordinates [message #13617 is a reply to message #13616] Mon, 23 November 1998 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Axel Schweiger wrote:
>
> How does one convert the character size into normal coordinates.
> --
> #----------------------------------------------------------- ------------------
> # Axel Schweiger

Since !D.[X|Y]_CH_SIZE give the width and height of the rectangle
that encloses the "average" character in the current font, in
device units (usually pixels) [from the Online help on !D]:

x_ch_norm = !D.X_CH_SIZE / !D.X_SIZE
y_ch_norm = !D.Y_CH_SIZE / !D.Y_SIZE

would be my guess. If your window is 100 pixels wide, and your
object is 50 pixels wide, then in normalized coordinates that
would be .5 . Or am I having a bad hair day?

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
Re: character size in normal coordinates [message #13619 is a reply to message #13616] Mon, 23 November 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:

> Martin Schultz (mgs@io.harvard.edu) writes:
>
>> My guess would be :
>>
>> pixsize = !d.y_ch_size * !p.charsize ; or your own charsize --> gives
>> size in pixels
>> normsize = convert_coord(pixsize,/device,/to_normal)
>> UGLY! That doesn't work! Well, then
>> normsize = pixsize/!d.y_size
>
> Careful here. The expression:
>
> normsize = pixsize / !D.Y_Size
>
> is going to evaluation to 0, almost always. :-)
>
> Try:
>
> normsize = pixsize / Float(!D.Y_Size)
>
> This one has bit me enough that I almost always
> remember it. :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Progamming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155

Ouch !! But ... if you use !p.charsize you already have a float variable.
IDL> help,!p,/stru
[...]
CHARSIZE FLOAT 1.40000
[...]

Martin

--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
Re: character size in normal coordinates [message #13625 is a reply to message #13616] Sun, 22 November 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Martin Schultz (mgs@io.harvard.edu) writes:

> My guess would be :
>
> pixsize = !d.y_ch_size * !p.charsize ; or your own charsize --> gives
> size in pixels
> normsize = convert_coord(pixsize,/device,/to_normal)
> UGLY! That doesn't work! Well, then
> normsize = pixsize/!d.y_size

Careful here. The expression:

normsize = pixsize / !D.Y_Size

is going to evaluation to 0, almost always. :-)

Try:

normsize = pixsize / Float(!D.Y_Size)

This one has bit me enough that I almost always
remember it. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Progamming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: character size in normal coordinates [message #13629 is a reply to message #13625] Sun, 22 November 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Axel Schweiger wrote:

> How does one convert the character size into normal coordinates.
> --
> # Axel Schweiger
>

My guess would be :

pixsize = !d.y_ch_size * !p.charsize ; or your own charsize --> gives
size in pixels
normsize = convert_coord(pixsize,/device,/to_normal)
UGLY! That doesn't work! Well, then
normsize = pixsize/!d.y_size

[or maybe you'll have to use !d.x_ch_size and !d.x_size for better results ...]

Hope this gives you an idea at least,
Martin.


--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: max value of function
Next Topic: Re: 5.2 looks nice

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

Current Time: Wed Oct 08 09:12:05 PDT 2025

Total time taken to generate the page: 0.00656 seconds