PRO MAINWTC2_EVENT, Event ;+ ;This routine handles the events from the 2D Wavelet Transform ;Compression Widget. ;- COMMON WTC2_common, FSLID4, BUTTON6, BUTTON8, BUTTON9, $ BUTTON18, wc, wcmsort, perslider COMMON WWB_COMMON, $ TEXT_ANNOUNCE, wd, sig, len, st, noise_type, noise_lev, $ QMF, LD, shrinkage_type, WaveType, ParVal type = TAG_NAMES(event, /structure_name) WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev CASE 1 OF ( type eq 'WIDGET_BUTTON' ) and ( ev eq 'Done' ): BEGIN WIDGET_CONTROL, event.top, /destroy END ELSE: BEGIN len2 = len*len CASE ev OF 'FSLID4': BEGIN ;Print, 'Event for Percentage Reconstruction' WIDGET_CONTROL, Event.Id, get_value=perslider END 'BUTTON8': BEGIN ;Print, 'Event for Percentage/2' perslider = perslider / 2.0 IF perslider LT 0 THEN perslider = 0 END 'BUTTON9': BEGIN ;Print, 'Event for Percentage*2' perslider = perslider * 2.0 IF perslider GT 100 THEN perslider = 100 END 'Compute': BEGIN ;Print, 'Event for Compute' WIDGET_CONTROL, FSLID4, get_value=perslider val = (100.0 - perslider)/100.0 wthresh = wcmsort(FLOOR(val*(len2-1))) cw = wc * (ABS(wc) GT wthresh) ;Reconstruct the dataset WIDGET_CONTROL, TEXT_ANNOUNCE, SET_VALUE='Calculating Inverse Discrete Wavelet Transform.', /HOURGLASS recon = WIWT2PO(cw ,LD,QMF) brecon = BYTE(recon) WIDGET_CONTROL, TEXT_ANNOUNCE, SET_VALUE='Done.' rt = 'Reconstruction from Best' + STRCOMPRESS(STRING(perslider))+ ' % Coefficients' signaltitle = rt + ' for ' + st ;TVSCL, brecon WPLOTIT, signaltitle, 11, brecon END ;Compute button ENDCASE ;ev WIDGET_CONTROL, FSLID4, set_value=perslider END ;ELSE ENDCASE ;CASE 1.. Checking buttons and menu items END ;of procedure MAINWTC2_Event ;**************************************************************** PRO WTC2, GROUP=Group ;This procedure sets up the 2D Wavelet Transform Compression widget. COMMON WTC2_common, FSLID4, BUTTON6, BUTTON8, BUTTON9, $ BUTTON18, wc, wcmsort, perslider COMMON WWB_COMMON, $ TEXT_ANNOUNCE, wd, sig, len, st, noise_type, noise_lev, $ QMF, LD, shrinkage_type, WaveType, ParVal ;----------Prep work------------------ ;Do Wavelet Transform WIDGET_CONTROL, TEXT_ANNOUNCE, SET_VALUE='Calculating Forward Discrete Wavelet Transform.', /HOURGLASS WINTWAVE, sig, WaveType, ParVal, QMF, LD signaltitle = 'WT of ' + st len2 = len*len wc = WFWT2PO(sig,LD,QMF) WPLOTIT, signaltitle, 10, ABS(wc) WIDGET_CONTROL, TEXT_ANNOUNCE, SET_VALUE='Done.' ;Reconstruct from Best x% coefficients (start with 50%) perslider = 50 wcmsort = WMSORT(ABS(WCOMBINE(wc))) ;---------------------------------------- IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0 junk = { CW_PDMENU_S, flags:0, name:'' } MAINWTC2 = WIDGET_BASE(GROUP_LEADER=Group, $ ROW=3, $ MAP=1, $ TITLE='2D Wavelet Transform Compression', $ UVALUE='MAINWTC2') BASE2 = WIDGET_BASE(MAINWTC2, $ ROW=1, $ MAP=1, $ UVALUE='BASE2') FSLID4 = WIDGET_SLIDER( BASE2, $ DRAG=0, $ TITLE='Percentage Reconstruction', $ UVALUE='FSLID4', $ VALUE=perslider, $ MINIMUM=0, $ MAXIMUM=100, $ XSIZE=200) BUTTON8 = WIDGET_BUTTON( BASE2, $ UVALUE='BUTTON8', $ VALUE='Percentage/2', $ XSIZE=100, $ YSIZE=40) BUTTON9 = WIDGET_BUTTON( BASE2, $ UVALUE='BUTTON9', $ VALUE='Percentage*2', $ XSIZE=100, $ YSIZE=40) BUTTON6 = WIDGET_BUTTON( BASE2, $ UVALUE='Done', $ VALUE='Done') BASE17 = WIDGET_BASE(MAINWTC2, $ ROW=1, $ MAP=1, $ TITLE='Compute', $ UVALUE='BASE17') BUTTON18 = WIDGET_BUTTON( BASE17, $ UVALUE='Compute', $ VALUE='Compute', $ XOFFSET=50, $ XSIZE=400, $ YSIZE=20) WIDGET_CONTROL, MAINWTC2, /REALIZE XMANAGER, 'MAINWTC2', MAINWTC2 END ;of Procedure WTC2