Fanning Software Consulting

Adding a String to an iTool

QUESTION: I'd like to be able to add strings to an iTool graphic plot in a way that is analogous to using XYOUTS in direct graphics. Does such a thing exits in the iTool world?

ANSWER: It does now, thanks to Ken Bowman and Mike Galloy, who provided some ideas about this in a thread in the IDL newsgroup. I've written a program, named iXYOUTS, that can put a text string into an iTool in a fairly general way.

iXYOUTS can take any keyword that is accepted by the IDLgrTEXT object. Among the useful ones, probably, will be FONT_SIZE, LOCATION, COLOR, ALIGNMENT and maybe others. Be sure you read the IDL on-line documentation for ideas. When an iTool starts up, the default coordinate system looks like it ranges from -1.4 to 1.4 units in X, from -1.0 to 1.0 units in Y, and from 1.0 to -1.0 units in Z. Once the iTool is magnified or changed in other ways, this coordinate system can change. This is unlike the normalized coordinate system in direct graphics. This makes is much harder to guarantee you will successfully place the text where you want it, but there is not much I can do. We are working with object graphics after all! You can move the text in the iTool if you don't get it exactly where you want it. Just drag it to the correct position. If you don't see anything, well, goodness! Check the color, the location, the alignment, and anything else you can think of. It is there somewhere! Welcome to the world of object graphics.

I've tried to pick a few defaults that will make it likely you will see something. I've used the keywords LOCATION, FONT_SIZE, and ALIGNMENT. If you don't like my choices, use these keywords to change to something you do like. For LOCATION I use [0.0, 0.0 1.0], which should put the text in the middle of the view, close to you, and ONGLASS. I use a FONT_SIZE of 12 and an ALIGNMENT of 0.5, which will center the text on the location. The rest is up to you. Check those IDLgrTEXT keywords out.

You will have to have an iTool on the display to use iXYOUTS, otherwise it will cause an error. You will also have to download cgErrorMsg from the Coyote Library to use the program. Here is some code that you can use to try it out. Note that the first iXYOUTS call will go into the iSurface plot, since that is the current iTool. Unless you tell it otherwise, the target is always the current iTool. But, as you can see, you can also specify the identifier of another iTool where the text is suppose to go. You will need to interact with an iTool, or have saved its identifier to do this.

   iPlot, Findgen(11), IDENTIFIER=plotID
   iSurface, Dist(30)
   
   ; Put some text in the iSurface plot.
   iXYOUTS, 'Some RED text', COLOR=[255,0,0]

   ; Put some big text into the iPlot plot.
   iXYOUTS, 'Some BIG text', ID=plotID, FONT_SIZE=24, LOCATION=[0.0, 0.9, 1.0]
Adding text to iTools.
Adding text to iTools is easy with iXYOUTS.
 

Google
 
Web Coyote's Guide to IDL Programming