----- header of xplot2d.pro extracted on: Wed Mar  5 17:24:03 2008

----- Documentation for /scisoft/xop2.3/src_idl/wutil/xplot2d.pro -----
 ============================== XPLOT2D =======================================

 XPLOT2D

 A software tool for analysing scientific images.

 Functionality:
    - Load and visualize several images
    - Several file types: EDF, MAR, BINARY, XRD, etc.
    - Automatically handles gzip MAR compressed files
    - Loads multiple files
    - When an image is load, it can be added to the image stack or
      substitute the first image in the stack.
    - Visualize images in frames.
    - Apply several color tables and adjust their limits to data.
      button: "c f" color full range
      button: "c s" color stretched range
    - Define ROIS (rectangle, circle, cake, polygon)
    - Mask data to ROI or complement of ROI (1-ROI)
    - Applies mask from another image
    - Calculations:
        -azimuthal integration 
        -histograms
        -horizontal or vertical integration, etc.
        -horizontal, vertical and transversal profiles
    - Simulations: Overplot rings from external x-ray diffraction profiles,
      defined in with either "twotheta" or "d-spacing" files,
      containing columns with :
         twotheta [deg], intensity [,color index]  or
         d-spacing [A], intensity [,color indexa] , respectively.
    - Makes a generic operation with one image.
    - Define/edit image titles
    -Full calibration using circles (detector perpendicular to beam) or
     ellimses (detector oblique to the beam)
    -Allows non interactive use
    -One level undo

 To be done:
   - Zoom
   - Mask algebra
   - Printing
   - Documentation

 Authors: M. Sanchez del Rio, F. Matulic and V. Favre-Nicolin

 Version History:
   Version 1.0 Beta 1  (March 15 2004)
   Version 1.0 Beta 2  (June 11 2004)
   Version 1.0 Beta 3  (April 20 2005, UAM-I, Mexico)
   Version 1.00  (December 19 2007, srio@esrf.eu)

 Modifications history:
   - V. Favre-Nicolin, 01/2002 (skeleton)
   - M. Sanchez del Rio, 07/2002 (painted skeleton)
   - F. Matulic 24.09.02 completed development of the main prototype
   - 04-03-15 First beta version.
   - 04-05-11 2nd beta version.
   - 04-04-20 3rd beta version: Fast azimuth integral,...
   - 2007-12-19 First released version 1.00
   - 2008-02-06 srio@esrf.eu adds support for multichannel images 
         (loaded into different images).
   - 2008-02-25 srio@esrf.eu adds peak width in simul. Check for file
         existence when overplotting rings. v 1.02

===================== Non interactive use of xplot2d ==========================

 EXAMPLE OF NON-INTERACTIVE USE:

     print,'>> opening xplot2d...'
     xplot2d,parent=p
     
     print,'>> setting imageformat...'
     xplot2d_imageformat,p,interactive=0,getStr=str
     str.filter='*.stl'
     tmp = str.format
     tmp[0]='3'
     str.format=tmp
     xplot2d_imageformat,p,interactive=0,putStr=str
     
     print,'>> loading image...'
     xplot2d_loadimage,p,file='al2o3_002.stl'
     
     print,'>> loading inputs...'
     xplot2d_loadinputfile,p,file='Al2O3.xop'
     
     print,'>> azimuthal integration...'
     xplot2d_azimuth_integral,p
     
     print,'>> others: '
     xplot2d_annulus,p
     xplot2d_calibrate_onering,p
     xplot2d_calibrate_multiring,p
     xplot2d_displayct,p
     
     print,'>> saving image...'
     xplot2d_saveimage,p,format='EDF',file='tmp.edf'
     
     print,'>> quitting application...
     xplot2d_quit,p


  COPYRIGHT:
 	XPLOT2D belongs to XOP package and it is distributed within XOP.
 	PLEASE REFER TO THE XOP COPYRIGHT NOTICE
 
  REFERENCE:
 	Published calculations made with XOP should refer:
 
 	M. Sanchez del Rio and R. J. Dejus 
         "Status of XOP: an x-ray optics software toolkit"
         SPIE Proceedings Vol. 5536 (2004) pp.171-174
 
         http://dx.doi.org/10.1117/12.560903
 
  LAST MODIFICATION: srio@esrf.eu 2008-02-26
 
 

 

 PRO xplot2d_annulus,wid, roi_text=roi_text, $   ; inputs
     color=color, $                              ; inputs
     img=img, $                                  ; input/output
     center=center,axes=axes, $                  ; output
     extractRoi=extractRoi, histogram=histo , $  ; flag to analyze filling points  
     roi_indices=roi, weights=weights, x=x, y=y  ; outputawhen extractRoi=1


 
 PRO XPLOT2D_APPLY_IMAGE_TO_MASK,wXplot2D,maskarray=mask,refresh=refresh



 PRO XPLOT2D_AZIMUTH_INTEGRAL,wXplot2d,method=method, window=nwindow




 FUNCTION xplot2d_calc_cm,wId,image=img, roi=roi




 PRO xplot2d_calibrate_onering,Xplot2DId,$
    interactive=interactive, $
    annulus=annulus,     $     ;  0=use ellipse line, 1=use annular region
    GuessFlag=GuessFlag, $     ;  0=use ellipse line, 1=use current detector parameters
    dspacing=dspacing          ;  d-spacing for the selected ring




 PRO xplot2d_calibrate_multiring,Xplot2DId,interactive=interactive,  $
   action=action,v0=v0,vS=vS ; outputs




 PRO xplot2d_calibrate_scan,Xplot2DId




 PRO XPLOT2D_DISPLAYCT,wid,MINRANGE=minrange,MAXRANGE=maxrange




 PRO xplot2d_imageformat, wId, interactive=interactive, putStr=str, $
   getStr=tmp ; output




 PRO xplot2d_loadimage,wXplot2d, reload=reload, file=file, increment=increment




 PRO xplot2d_loadinputfile,wid,file=file,path=path,group=group




 PRO xplot2d_overplotrings,wid,dataSize=ssize,  $
   x0=x0,y0=y0,axis1=axis1,axis2=axis2,phi=phi,$ ; output arrays (dim=number of rings)
   dspacing=dspacing,twoTheta=twoTheta           ; output arrays (dim=number of rings)




 FUNCTION XPLOT2D_GETIMAGE,wXplot2d,index=index, pointer=ipointer




 PRO xplot2d_crop,wXplot2d, $
     outputTo=outputTo, $   ; 0=New window, 1=Substiture current image, 2=Add image
     roi=roi                ; roi=[x1,y1,x2,y2] selected rectangle




 PRO XPLOT2D_PROFILE,wXplot2d,profile=profile




 PRO XPLOT2D_QUIT,wXplot2d




PRO XPLOT2D_ROI_MOUSE,wXplot2d,iFlag=iFlag, $
   center=center,axes=axes,phi=phi, coeff=coeff ; output keywords




 PRO xplot2d_roi_plot,wXplot2d, coeffs=coeff, $
     refresh=refresh,noPlot=noPlot,noEnvelope=noEnvelope, $
     points=points,roi_text=roi_text, $ ; output
     center=center, axes=axes, phi=phi  ; output




 PRO xplot2d_saveimage,wid, $,
     format=format, $ ; Accepted values: 'EDF','XRD', 'Oth' (other).
     file=filename




 PRO xplot2d_saveinputfile,wid




 PRO xplot2d_scale,wId,scale,max=iMax




 PRO xplot2d_setcolorlimits,wid, $
   interactive=interactive,  $
   min=min1,max=max1, $
   fullrange=fullrange,refresh=refresh,  $
   stretch=stretch, changeStretch=changeStretch




 PRO XPLOT2D_SET_COMMENT,wXplot2d,comment




 PRO XPLOT2D_REFRESH,wXplot2d,print=print1, $
    imageInside=imageInside, imageArray=img, $ ; outputs
    xrange=xrange, yrange=yrange ; outputs




 PRO XPLOT2D_CHANGE_IMAGE,wXplot2d,index,min=min,max=max,log=log,linear=linear




 PRO XPLOT2D_LAST_IMAGE,wXplot2d




 PRO XPLOT2D_FIRST_IMAGE,wXplot2d




 PRO XPLOT2D_NEXT_IMAGE,wXplot2d




 PRO XPLOT2D_PREVIOUS_IMAGE,wXplot2d



 PRO XPLOT2D_ADD_IMAGE,wXplot2d, $
    indata,title=title,substitute=substitute, $
    refresh=refresh




 PRO XPLOT2D_REPLACE_IMAGE,wXplot2d,indata, refresh=refresh




 PRO XPLOT2D_SET_SCALE,wXplot2d,min=min,max=max,log=log,linear=linear




 PRO XPLOT2D_ROTATE_IMAGE,wXplot2d,direction




 PRO XPLOT2D_APPLY_SELECTION_TO_MASK,wXplot2d,Complementary=complementary
   Sets the current selection to act as a mask on the image 
   (sets its pixels to -1)




 PRO XPLOT2D,indata, parent=wXplot2d, $
     wtitle=wtitle,no_block=no_block, $
     group=group,window_size=window_size,$
     scale=scale,mincolor=mincolor,maxcolor=maxcolor,$
     imagetitle=imagetitle


