Fanning Software Consulting

Opening Multiple Coyote Graphics Windows

Facebook RSS Google+

QUESTION: I love the fact that I can display graphics commands in a resizeable graphics window with your Coyote Graphics routines. But, all the graphics commands go into the same window! For example, if I display an image, like this.

   cgImage, cgDemoData(7), /Window

And then, I display a line plot, like this.

   cgPlot, cgDemoData(1), /Window

The line plot goes into the same window that had the image in it. Isn't it possible to make it go into it's own window?

ANSWER: Sure, it is possible. The Coyote Graphics routines are meant, as must as possible, to mimic the way normal everyday IDL graphics commands work. So, for example, if you first display an image in a window, and then issue the Plot command to display a line plot, it will go into the same window that contains the image. No one seems to be surprised by that.

If you wanted to put the line plot in a different window, you would simply open a new window with a different window index number, and add the line plot to that window.

   TV, image
   Window, 1
   Plot, Findgen(11)

You do exactly the same thing with Coyote Graphics.

  cgImage, cgDemoData(7), /Window
  cgPlot, cgDemoData(1), /Window

As with normal IDL graphics, the last cgWindow you create is the "current" cgWindow, and new graphics commands will go into that window. If you want to make another window the "current" graphics window, you simply select it, as you do in normal graphics with WSet, although for Coyote Graphics windows you use cgSet. With WSet, you must use the window index number of the window you wish to be current. With cgSet, you have many more choices. You can use the window's window index number, it's title, it widget identifier, or it's object reference to select it. If you don't know this information (the window index number is generally shown on the title bar of the graphics window, as it is with the Window command), you can learn it by using cgQuery, which will give you all of this information for any cgWindow on the display.

You can see from the figure below that the commands above produced two windows, with window index numbers of 32 and 33. These are the numbers you can use with cgSet to select which window you want your next Coyote Graphics command to go into.

Multiple Coyote Graphics windows are created
with the cgWindow command.
Multiple Coyote Graphics windows are created with the cgWindow command.

Version of IDL used to prepare this article: IDL 8.2.

Written: 13 January 2013