BOOL CSizeImageDlg::DoSizeControls( ITEMID id, UINT codeNotify, BOOL bResAdjust ) { BOOL bResult = TRUE; HWND hDlg = GetSafeHwnd(); BOOL Bool; long x, y; int npix, nlin; HWND hWnd, hControl; RECT rArea; LFIXED scale; LPIMAGE lpImage; FRMDATATYPE Type; lpImage = GetImage(); ImgGetInfo(lpImage, NULL, NULL, NULL, &Type); npix = CROPWIDTH(); nlin = CROPHEIGHT(); switch( id ) { case IDC_SMARTSIZE: m_SmartSize = !m_SmartSize; CheckDlgButton( IDC_SMARTSIZE, m_SmartSize ); break; case IDC_MAINTAINSIZE: m_MaintainSize = !m_MaintainSize; if (m_MaintainSize) m_Distortable = NO; ControlEnable(hDlg, IDC_DISTORT, !m_MaintainSize); ControlEnable(hDlg, IDC_SMARTSIZE, !m_MaintainSize); Bool = !m_MaintainSize || m_Units != IDC_PREF_UNITPIXELS; ControlEnable(hDlg, IDC_WIDTH, Bool); ControlEnable(hDlg, IDC_HEIGHT, Bool); ControlEnable(hDlg, IDC_SCALEX, Bool); ControlEnable(hDlg, IDC_SCALEY, Bool); if (m_MaintainSize) { m_Resolution = m_CropResolution = m_OrigResolution; m_Width = FGET( npix, m_CropResolution ); m_Height = FGET( nlin, m_CropResolution ); SetUnitResolution( m_CropResolution ); SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO ); SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES ); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); } CheckDlgButton( IDC_MAINTAINSIZE, m_MaintainSize ); CheckDlgButton( IDC_SMARTSIZE, !m_MaintainSize && m_SmartSize ); break; case IDC_PREF_UNITS: { WORD wUnits; if ( !(wUnits = HandleCombo( hDlg, id, codeNotify )) ) break; m_Units = wUnits; SetUnitInfo((UNIT_TYPE)(m_Units-IDC_PREF_UNITINCHES), m_UnitRes, m_Points); CheckComboItem(hDlg, IDC_PREF_UNITS, IDC_PREF_UNITFIRST, IDC_PREF_UNITLAST, m_Units); Bool = !m_MaintainSize || m_Units != IDC_PREF_UNITPIXELS; ControlEnable(hDlg, IDC_WIDTH, Bool); ControlEnable(hDlg, IDC_HEIGHT, Bool); ControlEnable(hDlg, IDC_SCALEX, Bool); ControlEnable(hDlg, IDC_SCALEY, Bool); if (m_MaintainSize && m_Units == IDC_PREF_UNITPIXELS) { m_CropResolution = m_Resolution; SetUnitResolution( m_CropResolution ); m_Width = FGET( npix, m_CropResolution ); m_Height = FGET( nlin, m_CropResolution ); y = FMUL( m_CropResolution, m_Height ); m_ScaleY = ((y*100L) + nlin/2) / nlin; SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO ); x = FMUL( m_CropResolution, m_Width ); m_ScaleX = ((x*100L) + npix/2) / npix; SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO ); } SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES ); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); SetUnitLabels(); } break; case IDC_DISTORT: m_Distortable = !m_Distortable; CheckDlgButton( IDC_DISTORT, m_Distortable ); if (m_Distortable) m_MaintainSize = NO; ControlEnable(hDlg, IDC_MAINTAINSIZE, !m_MaintainSize); if ( m_ScaleX != m_ScaleY ) { m_ScaleX = m_ScaleY; x = (((long)npix * m_ScaleX)+50L)/100L; m_Width = FGET( x, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES ); SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO ); } CheckDlgButton( IDC_SMARTSIZE,m_SmartSize && !m_Distortable); ControlEnable( hDlg, IDC_SMARTSIZE, !m_Distortable && CANDOTRANSPARENCY(Type)); ControlEnable(hDlg, IDC_MAINTAINSIZE, !m_Distortable && lpImage); if ( Page.PrintNumeric ) break; if ( !(hWnd = ::GetDlgItem( hDlg,IDC_PRINTVIEWPAGE)) ) break; if ( !(hControl = ::GetDlgItem( hDlg,IDC_PRINTVIEWIMAGE)) ) break; SetLongBit(hControl, GWL_STYLE, IS_RATIO_CONSTRAIN, !m_Distortable ); if (!m_Distortable) { ::GetWindowRect(hControl, &rArea); ::ScreenToClient(hWnd, (LPPOINT)&rArea.left); ::ScreenToClient(hWnd, (LPPOINT)&rArea.right); ::MoveWindow(hControl, rArea.left, rArea.top, RectWidth(&rArea)-1, RectHeight(&rArea)-1, TRUE); } break; case IDC_HEIGHT: if ( ::GetFocus() != ::GetDlgItem( hDlg,id ) ) break; if ( codeNotify != EN_CHANGE ) break; m_Height = GetDlgItemSpinFixed( hDlg, IDC_HEIGHT, &Bool, YES); if (m_MaintainSize) { scale = FGET(FUNITY, m_Height); m_Resolution = FMUL(nlin, scale); SetUnitResolution( m_Resolution ); SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO ); } // y = number of new pixels x 100 y = FMUL( m_CropResolution, m_Height ); // calculate scale factor = (new pixels * 100) / old pixels m_ScaleY = ((y * 100L) + nlin/2) / nlin; SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO ); if ( !m_Distortable ) { m_ScaleX = m_ScaleY; x = (((long)npix * (long)y) + (nlin/2))/ (long)nlin; m_Width = FGET( x, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES ); SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO ); } ImageMemory( hDlg, IDC_MEMORY, m_MaintainSize ? FGET(npix,1) : m_Width, m_MaintainSize ? FGET(nlin,1) : m_Height, m_MaintainSize ? 1 : m_Resolution, m_Depth ); break; case IDC_WIDTH: if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) ) break; if ( codeNotify != EN_CHANGE ) break; m_Width = GetDlgItemSpinFixed( hDlg, IDC_WIDTH, &Bool, YES ); if (m_MaintainSize) { scale = FGET(FUNITY, m_Width); m_Resolution = FMUL(npix, scale); SetUnitResolution( m_Resolution ); SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO ); } x = FMUL( m_CropResolution, m_Width ); m_ScaleX = ((x * 100L) + npix/2L) / (long)npix; SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO ); if ( !m_Distortable ) { m_ScaleY = m_ScaleX; y = (((long)nlin * (long)x) + (npix/2))/ (long)npix; m_Height = FGET( y, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO ); } ImageMemory( hDlg, IDC_MEMORY, m_MaintainSize ? FGET(npix,1) : m_Width, m_MaintainSize ? FGET(nlin,1) : m_Height, m_MaintainSize ? 1 : m_Resolution, m_Depth ); break; case IDC_RES: if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) ) break; if ( codeNotify != EN_CHANGE ) break; m_Resolution = GetDlgItemSpin( hDlg, IDC_RES, &Bool, NO ); if ( m_Resolution <= 0 ) m_Resolution = 2; if (m_MaintainSize) { m_Width = FGET(npix, m_Resolution); m_Height = FGET(nlin, m_Resolution); SetUnitResolution( m_Resolution ); if (m_Units != IDC_PREF_UNITPIXELS) { SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES ); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); y = FMUL( m_CropResolution, m_Height ); m_ScaleY = ((y*100L) + nlin/2) / nlin; SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO ); x = FMUL( m_CropResolution, m_Width ); m_ScaleX = ((x*100L) + npix/2) / npix; SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO ); } } if ( m_Units == IDC_PREF_UNITPIXELS ) { if ( bResAdjust ) { // Extract the values again (inch values changed) m_CropResolution = m_Resolution; SetUnitResolution( m_Resolution ); ::SetFocus( hWnd = ::GetDlgItem( hDlg,IDC_HEIGHT ) ); FORWARD_WM_COMMAND(hDlg, IDC_HEIGHT, hWnd, EN_CHANGE, ::SendMessage); ::SetFocus( hWnd = ::GetDlgItem( hDlg,IDC_WIDTH ) ); FORWARD_WM_COMMAND(hDlg, IDC_WIDTH, hWnd, EN_CHANGE, ::SendMessage); ::SetFocus( ::GetDlgItem( hDlg,id ) ); } else { // Change the edit box SetUnitResolution( m_Resolution ); SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); } } ImageMemory( hDlg, IDC_MEMORY, m_MaintainSize ? FGET(npix,1) : m_Width, m_MaintainSize ? FGET(nlin,1) : m_Height, m_MaintainSize ? 1 : m_Resolution, m_Depth ); break; case IDC_SCALEX: if ( GetFocus() != GetDlgItem( id ) ) break; if ( codeNotify != EN_CHANGE ) break; m_ScaleX = GetDlgItemSpin( hDlg, IDC_SCALEX, &Bool, NO ); x = (((long)npix * m_ScaleX)+50L)/100L; m_Width = FGET( x, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES ); if (m_MaintainSize) { scale = FGET(FUNITY, m_Width); m_Resolution = FMUL(npix, scale); SetUnitResolution( m_Resolution ); SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO ); } if ( !m_Distortable ) { m_ScaleY = m_ScaleX; y = (((long)nlin * m_ScaleY)+50)/100L; m_Height = FGET( y, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO ); } ImageMemory( hDlg, IDC_MEMORY, m_MaintainSize ? FGET(npix,1) : m_Width, m_MaintainSize ? FGET(nlin,1) : m_Height, m_MaintainSize ? 1 : m_Resolution, m_Depth ); break; case IDC_SCALEY: if ( GetFocus() != GetDlgItem( id ) ) break; if ( codeNotify != EN_CHANGE ) break; m_ScaleY = GetDlgItemSpin( hDlg, IDC_SCALEY, &Bool, NO ); y = (((long)nlin * m_ScaleY)+50)/100L; m_Height = FGET( y, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES ); if (m_MaintainSize) { scale = FGET(FUNITY, m_Height); m_Resolution = FMUL(nlin, scale); SetUnitResolution( m_Resolution ); SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO ); } if ( !m_Distortable ) { m_ScaleX = m_ScaleY; x = (((long)npix * m_ScaleX)+50L)/100L; m_Width = FGET( x, m_CropResolution ); SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES); SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO ); } ImageMemory( hDlg, IDC_MEMORY, m_MaintainSize ? FGET(npix,1) : m_Width, m_MaintainSize ? FGET(nlin,1) : m_Height, m_MaintainSize ? 1 : m_Resolution, m_Depth ); break; case IDC_MEMORY: default: bResult = FALSE; break; } return bResult; }
void DumpACC1AF(FILE *src, FILE *dst,long Ndump,long ACC1A_count,long AHK1A_vp, long RmGdel,long ACC1A_ang, long ACC1A_lin, double Acc1aZbias) /*-----------------------------------------------------------------------------> / purpose: Dump Contents of Accelerometer Data level 1A file in file src / / coded by: Gerhard L.H. Kruizinga 07/24/01 / / input: / src pointer to source file to dump contents from / dst pointer to file to dump contents to / Ndump Maximum Number of records to dump / ACC1A_count Dump Time tag and count info only / AHK1A_vp Dump Time tag and vp info only / RmGdel do not dump records for which gdel flag is set / ACC1A_count Dump Time tag and angular accelerations only / Acc1aZbias Bias to be added to ACC Z-lin measurement when printing <-----------------------------------------------------------------------------*/ { ACC1A_t record; long ndump; double time; char Bits[8],Bits32[32]; ndump = 1; while(ReadACC1AFRecord(src,&record) == true) { if (ndump > Ndump && Ndump != DUMPALL) continue; time = (double) record.rcvtime_intg + 1e-6*(double)record.rcvtime_frac; if (InsideInterval(time)) continue; if (RmGdel) { GetCharBits( record.qualflg, Bits ); if( Bits[1] ) continue; /* remove record with no Pulse Sync */ if( Bits[3] ) continue; /* remove record with invalid timetag */ } if (ACC1A_count) { record.prod_flag = 0; SetLongBit(&record.prod_flag,26L); SetLongBit(&record.prod_flag,27L); SetLongBit(&record.prod_flag,28L); } if (ACC1A_ang) { GetLongBits( record.prod_flag, Bits32 ); record.prod_flag = 0; if (Bits32[3] != 1 || Bits32[4] != 1 || Bits32[5] != 1) { continue; } else { SetLongBit(&record.prod_flag,3L); SetLongBit(&record.prod_flag,4L); SetLongBit(&record.prod_flag,5L); } } if (ACC1A_lin) { GetLongBits( record.prod_flag, Bits32 ); record.prod_flag = 0; if (Bits32[0] != 1 || Bits32[1] != 1 || Bits32[2] != 1) { continue; } else { SetLongBit(&record.prod_flag,0L); SetLongBit(&record.prod_flag,1L); SetLongBit(&record.prod_flag,2L); } } if (AHK1A_vp) { record.prod_flag = 0; SetLongBit(&record.prod_flag,6L); } if (record.prod_flag == 0 && (ACC1A_ang || ACC1A_lin) ) continue; if (Acc1aZbias != 0.0) record.lin_accl_z += Acc1aZbias; WrAsciiACC1AFRecord(dst,&record); ndump++; } }