Re: IDL 6.2 and ITools view_title keyword [message #45317] |
Tue, 30 August 2005 10:26 |
David Alexander
Messages: 26 Registered: August 2005
|
Junior Member |
|
|
Tony,
There's no simple way to do this (like another keyword, for example).
When you use the VIEW_TITLE keyword it will always add a new text
annotation to the current view, even if the view already has a title.
So, the best thing is probably to re-use or delete the existing view
title text annotations, and to do this you have to do some extra work
(like you had to do to add a view title programatically before the
VIEW_TITLE keyword in 6.2). You don't want to delete the annotation
layer.
Here's an example. Note that I'm using the VIEW_NUMBER keyword rather
than VIEW_NEXT because I need to get the identifier of the view title
text object before updating the title, and this depends on the view I
want to change.
This isn't pretty, but I don't think there's an easier way.
This example updates the existing view titles:
pro update_view_titles
iplot,findgen(10),view_grid=[2,2],VIEW_TITLE='Original Title'
for i=2,4 do $
iplot,findgen(10),VIEW_NUMBER=i,VIEW_TITLE='Original Title'
void=itGetCurrent(TOOL=oTool)
for i=1,4 do begin
searchString='*view_'+STRTRIM(i,2)+'*text'
titleID=oTool->FindIdentifiers(searchString,/ANNOTATION_LAYER)
oText=oTool->GetByIdentifier(titleID)
iplot,10-findgen(10),VIEW_NUMBER=i
oText->SetProperty,_STRING='New Title'
oTool->RefreshCurrentWindow
endfor
end
The above example uses the undocumented _STRING property of the text
visualization object, so another way to do this would be to delete the
existing view title and just use the VIEW_TITLE keyword again, like
this:
pro update_view_titles2
iplot,findgen(10),view_grid=[2,2],VIEW_TITLE='Original Title'
for i=2,4 do $
iplot,findgen(10),VIEW_NUMBER=i,VIEW_TITLE='Original Title'
void=itGetCurrent(TOOL=oTool)
deleteID=oTool->FindIdentifiers('*Edit/Delete',/OPERATIONS)
for i=1,4 do begin
searchString='*view_'+STRTRIM(i,2)+'*text'
titleID=oTool->FindIdentifiers(searchString,/ANNOTATION_LAYER)
oText=oTool->GetByIdentifier(titleID)
oText->Select
result=oTool->DoAction(deleteID)
iplot,10-findgen(10),VIEW_NUMBER=i,VIEW_TITLE='New Title'
endfor
end
Note that in both these examples I'm assuming the view title will have
an identifier that ends with 'text', which it will if the view title
was the first text annotation created in each view.
David
|
|
|