X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



4672 Rate this article:
No rating

IDL 8.2: Example of the Erase method for IDL 8 Function Graphics windows

One new addition to IDL 8.2 is the ERASE method that is now included with the Function Graphics windows. The ERASE method can be used with windows created using the WINDOW or WIDGET_WINDOW property. The erase method will clear out the contents of a window without closing it. 

An example  program that demonstrates how this method can be used is shown below. This example is a widget program that is composed of three routines. "ds_erase_example" sets up the widget. "ds_make_random_image" creates 5 images of a rose and  draws them to random locations in the window. "ds_erase_example_event" is the event handler that controls the widget, and the ERASE method is used in this routine.


;The event handler for the example widget
pro ds_erase_example_event, event
  compile_opt idl2
 
  widget_control, event.top, get_uvalue=state
  widget_control, event.id, get_value=uval

  WIDGET_CONTROL, state.win, GET_VALUE=owin ;get the window reference from the state

  case (uval) of
       'Restart': begin
          owin.select ;select the window as the current window
          owin.erase ;erase the current contents of the window
           ds_make_random_image ;draw the new images
         end
         else: begin
         end
  endcase
 
end

;Routine that will draw the different color rose pictures in different colors

pro ds_make_random_image
  compile_opt idl2
 
 
  random_picks = RANDOMU(seed,6);create random distribution
  sorted_random = sort(random_picks) ;return indexes of random_picks in order
  sorted_random += 1 ;add 1 to work with LAYOUT keyword
 
  ;create images of different colors
  rose=READ_IMAGE(FILE_WHICH('rose.jpg'))
  red_rose=rose
 
  yellow_rose=rose
  yellow_rose[2,*,*]=0
 
  red_rose=yellow_rose
  red_rose[1,*,*]=0
 
  green_rose=yellow_rose
  green_rose[0,*,*]=0
 
   
  purple_rose=rose
  purple_rose[1,*,*]=0  
 
  ;Draw the rose of different colors in random order using the result of the
  ;SORT funtion
  !NULL = image(rose, LAYOUT=[3,3, sorted_random[0]], /CURRENT, MARGIN=0)
  !NULL = image(red_rose, LAYOUT=[3,3, sorted_random[1]], /CURRENT, MARGIN=0)
  !NULL = image(yellow_rose, LAYOUT=[3,3, sorted_random[2]], /CURRENT, MARGIN=0)
  !NULL = image(green_rose, LAYOUT=[3,3, sorted_random[3]], /CURRENT, MARGIN=0)
  !NULL = image(purple_rose, LAYOUT=[3,3, sorted_random[4]], /CURRENT, MARGIN=0)
 
end


;sets up the widget

pro ds_erase_example
 
  compile_opt idl2
  on_error, 2
 

  ;create the widget base and window
  base = WIDGET_BASE(/COLUMN)
  win = WIDGET_WINDOW(base, XSIZE=600, YSIZE=400 )
  wcontrolbase=widget_base(base, /row) ;make button base
  restart_button = WIDGET_BUTTON(base, VALUE="Restart", UVALUE="restart_button")
 
 ; create the state variable
  state={win:win, restart_button:restart_button}
 
  widget_control, base, SET_UVALUE=state
  WIDGET_CONTROL, base, /REALIZE
 
  ;Draw the images of the rose in random order
  ds_make_random_image
 

  xmanager, 'ds_erase_example', base, /no_block ;starts xmanager
 
 
end
Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »