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

Home » Public Forums » archive » Resizeable Graphics window
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
Resizeable Graphics window [message #75117] Thu, 17 February 2011 11:35 Go to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I am unclear how to add graphics commands to a Coyote graphics window. If I create a simple plot in a resizeable window:

cgplot,indgen(100),/window,psym=2

and now I want to add error bars.

for i=0,89 do cgplots,[i,i],[i-1,i+1],/addcmd

I get the plot I want but only after 90 flashes of the window. (If I don't include the /addcmd keyword then the error bars go to a different window.)

Thanks, --Wayne
Re: Resizeable Graphics window [message #75186 is a reply to message #75117] Fri, 18 February 2011 06:53 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
Just updated, tested, and everything works properly (all aspect ratios are right).

-Jeremy.
Re: Resizeable Graphics window [message #75194 is a reply to message #75117] Thu, 17 February 2011 13:23 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
wlandsman writes:

> And what's even more weirder (bad grammar intentional) is that I am having the opposite problem. My postscript files have the right aspect, but the .png file created via ImageMagick has the wrong aspect. I will try to make an example code. --Wayne

OK, let's make sure we are all using the same software
here. New update a minute ago. :-)

Let's see weird. I've nothing else to do today. ;-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Resizeable Graphics window [message #75195 is a reply to message #75117] Thu, 17 February 2011 13:21 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Thursday, February 17, 2011 4:01:30 PM UTC-5, wlandsman wrote:

> Below I give a test program that displays error bars, but first converts the data to device units. It works fine in a normal window, but if I create a resizeable window (i.e. test,/window) the lines are plotted incorrectly.

I should say that the problem persists even if I compute device coordinates *after* creating the resizeable graphics window. The revised code is below.

But the problem is fixed if I take David's recent suggestion and add a

WSet, cgQuery(/Current)

after the cgplot command.



pro test,window=window
x = indgen(10)
y = indgen(10)

cgplot,indgen(10),indgen(10),window=window,psym=2

; Let's do everything in device coordinates
data_low = convert_coord(x,y-0.5,/TO_DEVICE)
data_hi = convert_coord(x,y+0.5,/TO_DEVICE)
xd = data_low[0,*]
yl = data_low[1,*]
yh = data_hi[1,*]


if keyword_Set(window) then cgcontrol,execute=0

for i=0,9 do $
cgplots,[xd[i],xd[i]],[yl[i],yh[i] ],/device, addcmd = window


if keyword_set(window) then cgcontrol,execute=1
return
end
Re: Resizeable Graphics window [message #75197 is a reply to message #75117] Thu, 17 February 2011 13:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
wlandsman writes:

> Another resizeable window question:
>
> Do device coordinates make any sense in a resizeable window (when the size of your "device" is always changing)?
>
> Below I give a test program that displays error bars, but first converts the data to device units. It works fine in a normal window, but if I create a resizeable window (i.e. test,/window) the lines are plotted incorrectly.
>
> In this case, the use of device coordinates is perverse, but they are sometimes useful for "ornamental" figures. For example, setting the size of an arrow or the "hat" on an error bar to one-fiftieth of the screen size.

The problem here is that cgWindow is "hiding" itself
from the rest of IDL. That is to say, you are going
to have to go to some trouble to write into a cgWindow
graphics window accidentally. This is probably why
you can't calculate the device coordinates correctly.
The "current" graphics window is not the cgWindow
graphics window when you are doing the calculations.
(Although it probably looks like it might be.)

To do the calculations properly, you are going to have
to make the cgWindow graphics window the "current"
graphics window, do the calculations based on that
window, add your commands, etc.

cgWindow
WSet, cgQuery(/Current)
deviceCoords = Convert_Coord(dataCoords, /To_Device)
etc.

Maybe cgWindow needs a CoordConvert method. Let me give
this some thought. This would make it possible to know
where you are in the window, so we could report it. But,
again, we are going in the direction of Coyote Graphics 2.0.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Resizeable Graphics window [message #75198 is a reply to message #75117] Thu, 17 February 2011 13:05 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Thursday, February 17, 2011 3:24:55 PM UTC-5, Jeremy Bailin wrote:

> Speaking of which, I've got another odd issue with the aspect ratio of output. If I output a postscript file, I get the wrong aspect ratio, but if I out a .png file via ImageMagick, I get the right aspect ratio. Even weirder is that if I set ps_delete=0, the intermediate postscript file has the *right* aspect ratio.

And what's even more weirder (bad grammar intentional) is that I am having the opposite problem. My postscript files have the right aspect, but the .png file created via ImageMagick has the wrong aspect. I will try to make an example code. --Wayne
Re: Resizeable Graphics window [message #75199 is a reply to message #75117] Thu, 17 February 2011 13:01 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Another resizeable window question:

Do device coordinates make any sense in a resizeable window (when the size of your "device" is always changing)?

Below I give a test program that displays error bars, but first converts the data to device units. It works fine in a normal window, but if I create a resizeable window (i.e. test,/window) the lines are plotted incorrectly.

In this case, the use of device coordinates is perverse, but they are sometimes useful for "ornamental" figures. For example, setting the size of an arrow or the "hat" on an error bar to one-fiftieth of the screen size.

Thanks, --Wayne


pro test,window=window
x = indgen(10)
y = indgen(10)

; Let's do everything in device coordinates

data_low = convert_coord(x,y-0.5,/TO_DEVICE)
data_hi = convert_coord(x,y+0.5,/TO_DEVICE)
xd = data_low[0,*]
yl = data_low[1,*]
yh = data_hi[1,*]

cgplot,indgen(10),indgen(10),window=window,psym=2
if keyword_Set(window) then cgcontrol,execute=0

for i=0,9 do $
cgplots,[xd[i],xd[i]],[yl[i],yh[i] ],/device, addcmd = window


if keyword_set(window) then cgcontrol,execute=1
return
end
Re: Resizeable Graphics window [message #75201 is a reply to message #75117] Thu, 17 February 2011 12:56 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
>> Speaking of which, I've got another odd issue with the aspect ratio of output. If I output a postscript file, I get the wrong aspect ratio, but if I out a .png file via ImageMagick, I get the right aspect ratio. Even weirder is that if I set ps_delete=0, the intermediate postscript file has the *right* aspect ratio. I've looked at the code in both sections, and I can't see any difference that could account for it... and if I try to manually run the commands that create
> the ImageMagicked .png file, I get the wrong aspect ratio!
>
> When was the last time you updated your Coyote directory?
> Do you recall if there were any other graphics windows
> open when you created the PostScript file that didn't work
> properly?

Coyote library was last updated yesterday afternoon. There is another cgWindow open, but it has the same dimensions.

-Jeremy.
Re: Resizeable Graphics window [message #75202 is a reply to message #75117] Thu, 17 February 2011 12:52 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeremy Bailin writes:

> Ah yes, that's clearly a better option. :-)= Lots of nice little tricks within CG still to learn...
>
> Speaking of which, I've got another odd issue with the aspect ratio of output. If I output a postscript file, I get the wrong aspect ratio, but if I out a .png file via ImageMagick, I get the right aspect ratio. Even weirder is that if I set ps_delete=0, the intermediate postscript file has the *right* aspect ratio. I've looked at the code in both sections, and I can't see any difference that could account for it... and if I try to manually run the commands that create
the ImageMagicked .png file, I get the wrong aspect ratio!
>
> So I'm befuddled. :-)=

My fault. I need to make the resizeable graphics window
the current graphics window before I call PS_Start,
so that PS_Start will get the proper window aspect
ratio. It was using the default window aspect ratio,
rather than the correct one.

I'll update in just a few minutes. I'm right in the
middle of writing some notes for the new Get_Keyword
functionality for cgControl.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Resizeable Graphics window [message #75203 is a reply to message #75117] Thu, 17 February 2011 12:44 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeremy Bailin writes:

> Ah yes, that's clearly a better option. :-)= Lots of nice little tricks within CG still to learn...
>
> Speaking of which, I've got another odd issue with the aspect ratio of output. If I output a postscript file, I get the wrong aspect ratio, but if I out a .png file via ImageMagick, I get the right aspect ratio. Even weirder is that if I set ps_delete=0, the intermediate postscript file has the *right* aspect ratio. I've looked at the code in both sections, and I can't see any difference that could account for it... and if I try to manually run the commands that create
the ImageMagicked .png file, I get the wrong aspect ratio!
>
> So I'm befuddled. :-)=

Welcome to my world. :-)

When was the last time you updated your Coyote directory?
Do you recall if there were any other graphics windows
open when you created the PostScript file that didn't work
properly?

I'll look into it.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Yesterday's Coyote Graphics Update
Next Topic: Re: working on multiple z buffers at once?

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

Current Time: Thu Oct 09 12:28:14 PDT 2025

Total time taken to generate the page: 1.04101 seconds