user manual

368 Chapter 15: Creating a Custom iTool Widget Interface
Example: a Custom iTool Interface iTool Developers Guide
; Call IPLOT to create a plot of random values, replacing the
; data used in the iTool's window.
IPLOT, RANDOMU(seed, points), THICK=linesize, $
COLOR=newcolor, VIEW_NUMBER=1
END
Discussion
This routine uses mostly standard widget programming techniques. Two points are
worth noting, however:
1. We must be sure that our iTool is set as the current tool. To do this, we retrieve
our iTool’s identifier using the object reference stored in the widget interface’s
state structure and the GetFullIdentifier method. Next, we use the
ITCURRENT routine with the full identifier to make sure our tool is current.
2. When we call the IPLOT routine to generate the new plot, we set the
VIEW_NUMBER keyword equal to 1 (one). This replaces the data in the first
(and in our case, only) view in the tool with the data specified.
linesize_event
The linesize_event routine is specified as the event handler for the Line Size droplist
in the custom section of the interface. The complete code for this event-handler
routine is shown below.
PRO linesize_event, event
; Retrieve a pointer to the state structure.
wChild = WIDGET_INFO(event.top, /CHILD)
WIDGET_CONTROL, wChild, GET_UVALUE = pState
; Get the iTool identifier and make sure our iTool
; is the current tool.
toolID = (*pState).oTool->GetFullIdentifier()
ITCURRENT, toolID
; Get the value of the line size droplist.
linesize = WIDGET_INFO((*pState).wLineSize, /DROPLIST_SELECT)+1
; Select the first plot line visualization in the window.
; There should be only one line, but we select the first one
; just to be sure.
plotID = (*pState).oTool->FindIdentifiers('*plot*', $
/VISUALIZATIONS)
plotObj = (*pState).oTool->GetByIdentifier(plotID[0])
plotObj->Select