// WinLevelPrpoDlg.cpp : implementation file // #include "stdafx.h" #include "MSVC5conview.h" #include "WinLevelPrpoDlg.h" #include "leadrastercontainercell.h" #include "leadwindowlevelaction.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWinLevelPrpoDlg dialog CWinLevelPrpoDlg::CWinLevelPrpoDlg(CWnd* pParent /*=NULL*/) : CDialog(CWinLevelPrpoDlg::IDD, pParent) { //{{AFX_DATA_INIT(CWinLevelPrpoDlg) m_uCellIndex = 0; m_uSensitivity = 0; m_uSubCellIndex = 0; m_bCircleMouse = FALSE; m_uWidth = 1; m_nCenter = 0; m_ColorIn = 0; m_ColorOut = 0; m_hIcon = NULL; //}}AFX_DATA_INIT } void CWinLevelPrpoDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CWinLevelPrpoDlg) DDX_Control(pDX, IDC_ACTION_SEN_EDT, m_edtSensitivity); DDX_Control(pDX, IDC_ACTION_SUBCELLINDEX_EDT, m_edtSubCellIndex); DDX_Control(pDX, IDC_WLACTION_WIDTH_EDT, m_edtWidth); DDX_Control(pDX, IDC_WLACTION_CENTER_EDT, m_edtCenter); DDX_Control(pDX, IDC_ACTION_CELLINDEX_EDT, m_edtCellIndex); DDX_Control(pDX, IDC_ACTION_UPKEY_COM, m_cmbUpKey); DDX_Control(pDX, IDC_ACTION_DOWNKEY_COM, m_cmbDownKey); DDX_Control(pDX, IDC_WLACTION_FILLTYPE_COM, m_cmbFillType); DDX_Control(pDX, IDC_ACTION_SUBCELLINDEX_COM, m_cmbSubCellIndex); DDX_Control(pDX, IDC_ACTION_CUR_BTN, m_ActionCursor); DDX_Control(pDX, IDC_ACTION_CELLINDEX_COM, m_cmbCell); DDX_Control(pDX, IDC_ACTION_MOD_COM, m_cmbModifier); DDX_Control(pDX, IDC_ACTION_RIGHTKEY_COM, m_cmbRightKey); DDX_Control(pDX, IDC_ACTION_LEFTKEY_COM, m_cmbLeftKey); DDX_Text(pDX, IDC_ACTION_CELLINDEX_EDT, m_uCellIndex); DDX_Text(pDX, IDC_ACTION_SEN_EDT, m_uSensitivity); DDX_Text(pDX, IDC_ACTION_SUBCELLINDEX_EDT, m_uSubCellIndex); DDX_Check(pDX, IDC_ACTION_CIRCLE_CHK, m_bCircleMouse); DDX_Text(pDX, IDC_WLACTION_WIDTH_EDT, m_uWidth); DDX_Text(pDX, IDC_WLACTION_CENTER_EDT, m_nCenter); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CWinLevelPrpoDlg, CDialog) //{{AFX_MSG_MAP(CWinLevelPrpoDlg) ON_BN_CLICKED(IDC_ACTION_CUR_BTN, OnActionCurBtn) ON_BN_CLICKED(IDAPPLY, OnApply) ON_EN_CHANGE(IDC_ACTION_CELLINDEX_EDT, OnChangeActionCellindexEdt) ON_CBN_SELCHANGE(IDC_ACTION_CELLINDEX_COM, OnSelchangeActionCellindexCom) ON_CBN_SELCHANGE(IDC_ACTION_SUBCELLINDEX_COM, OnSelchangeActionSubcellindexCom) ON_EN_CHANGE(IDC_ACTION_SUBCELLINDEX_EDT, OnChangeActionSubcellindexEdt) ON_WM_PAINT() ON_WM_DRAWITEM() ON_BN_CLICKED(IDC_WLACTION_CLRIN_BTN, OnWlactionClrinBtn) ON_BN_CLICKED(IDC_WLACTION_CLROUT_BTN, OnWlactionClroutBtn) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWinLevelPrpoDlg message handlers void CWinLevelPrpoDlg::OnActionCurBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); if(pTheApp->GetIconFileName(m_FileName, (this->GetActiveWindow())->m_hWnd)) { m_hIcon = LoadCursorFromFile(m_FileName); m_ActionCursor.SetIcon(m_hIcon); } } void CWinLevelPrpoDlg::OnApply() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); INT nVk; UINT uState = (8 >> (4 - m_cmbModifier.GetCurSel())); UpdateData(); m_pView->m_ConView.WindowLevelAction().SetCursor(pTheApp->hIconToIPictureDisp(m_hIcon)); m_pView->m_ConView.WindowLevelAction().SetCircularMouseMove(m_bCircleMouse); m_pView->m_ConView.WindowLevelAction().SetChange(m_uSensitivity); m_pView->m_ConView.WindowLevelAction().SetStartColor(m_ColorIn); m_pView->m_ConView.WindowLevelAction().SetEndColor(m_ColorOut); if(m_cmbCell.GetCurSel()) { INT nIndex; INT nSubIndex; if (m_cmbCell.GetCurSel() == 1) nIndex = -1; else nIndex = m_uCellIndex; if (m_cmbSubCellIndex.GetCurSel() == 0) nSubIndex = -1; else nSubIndex = m_uSubCellIndex; m_pView->m_ConView.WindowLevelAction().SetWidth(m_uWidth); m_pView->m_ConView.WindowLevelAction().SetCenter(m_nCenter); m_pView->m_ConView.WindowLevelAction().SetFillType((m_cmbFillType.GetCurSel() + 1) << 4); m_pView->m_ConView.WindowLevelAction().SetAction(nIndex, nSubIndex, CONVIEW_ACTIONLEVEL_CELL); } nVk = pTheApp->GetVirtualKey(&m_cmbUpKey); if (nVk != 0) { m_pView->m_ConView.WindowLevelAction().SetKey(nVk); m_pView->m_ConView.WindowLevelAction().SetModifier(uState); m_pView->m_ConView.WindowLevelAction().SetKeyboardAction(CONVIEW_MOUSEMOVE_UP); } nVk = pTheApp->GetVirtualKey(&m_cmbDownKey); if (nVk != 0) { m_pView->m_ConView.WindowLevelAction().SetKey(nVk); m_pView->m_ConView.WindowLevelAction().SetModifier(uState); m_pView->m_ConView.WindowLevelAction().SetKeyboardAction(CONVIEW_MOUSEMOVE_DOWN); } nVk = pTheApp->GetVirtualKey(&m_cmbLeftKey); if (nVk != 0) { m_pView->m_ConView.WindowLevelAction().SetKey(nVk); m_pView->m_ConView.WindowLevelAction().SetModifier(uState); m_pView->m_ConView.WindowLevelAction().SetKeyboardAction(CONVIEW_MOUSEMOVE_LEFT); } nVk = pTheApp->GetVirtualKey(&m_cmbRightKey); if (nVk != 0) { m_pView->m_ConView.WindowLevelAction().SetKey(nVk); m_pView->m_ConView.WindowLevelAction().SetModifier(uState); m_pView->m_ConView.WindowLevelAction().SetKeyboardAction(CONVIEW_MOUSEMOVE_RIGHT); } m_pView->m_ConView.WindowLevelAction().SetAction(0,0, CONVIEW_ACTIONLEVEL_CONTAINER); } void CWinLevelPrpoDlg::OnOK() { OnApply(); CDialog::OnOK(); } BOOL CWinLevelPrpoDlg::OnInitDialog() { CDialog::OnInitDialog(); CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); INT nIndex = pTheApp->SearchForFirstSelectedCell(); nIndex = max(0, nIndex); m_pView->m_ConView.WindowLevelAction().GetAction(0, 0, CONVIEW_ACTIONLEVEL_CONTAINER); m_edtSensitivity.SetNumericEditBox(0, 100, 1, 0, 0); // TODO: Add extra initialization here if(m_pView->m_ConView.GetCellCount()) { m_pView->m_ConView.WindowLevelAction().GetAction(nIndex, 0, CONVIEW_ACTIONLEVEL_CELL); m_uSubCellIndex = 0; m_uCellIndex = nIndex; m_uWidth = m_pView->m_ConView.WindowLevelAction().GetWidth(); m_nCenter = m_pView->m_ConView.WindowLevelAction().GetCenter(); m_ColorIn = m_pView->m_ConView.WindowLevelAction().GetStartColor(); m_ColorOut = m_pView->m_ConView.WindowLevelAction().GetEndColor(); m_edtCellIndex.SetNumericEditBox(0, m_pView->m_ConView.GetCellCount() - 1, 1, 0, 0); pTheApp->m_pRaster = (ILEADRaster *)m_pView->m_ConView.Cell(nIndex).GetBitmapList(); short nCount; pTheApp->m_pRaster->get_BitmapListCount(&nCount); m_edtSubCellIndex.SetNumericEditBox(0, nCount - 1, 1, 0, 0); m_edtWidth.SetNumericEditBox(1, 0xffff, 1, 0, 0); m_edtCenter.SetNumericEditBox(-0xffff, 0xffff, 1, 0, 0); } m_cmbCell.AddString(TEXT("None")); m_cmbCell.AddString(TEXT("All")); m_cmbCell.AddString(TEXT("Custom")); m_cmbCell.SetCurSel(0); m_cmbSubCellIndex.AddString(TEXT("All")); m_cmbSubCellIndex.AddString(TEXT("Custom")); m_cmbSubCellIndex.SetCurSel(0); m_cmbFillType.AddString(TEXT("Linear")); m_cmbFillType.AddString(TEXT("Exponential")); m_cmbFillType.AddString(TEXT("Logarithmic")); m_cmbFillType.AddString(TEXT("Sigmoid")); m_cmbFillType.SetCurSel((m_pView->m_ConView.WindowLevelAction().GetFillType() >> 4) - 1); if(!m_pView->m_ConView.GetCellCount()) { (this->GetDlgItem(IDC_ACTION_CELLINDEX_COM))->EnableWindow(FALSE); (this->GetDlgItem(IDC_ACTION_SUBCELLINDEX_COM))->EnableWindow(FALSE); } this->GetDlgItem(IDC_ACTION_SUBCELLINDEX_COM)->EnableWindow(FALSE); this->GetDlgItem(IDC_ACTION_CELLINDEX_EDT)->EnableWindow(FALSE); this->GetDlgItem(IDC_ACTION_SUBCELLINDEX_EDT)->EnableWindow(FALSE); this->GetDlgItem(IDC_WLACTION_WIDTH_EDT)->EnableWindow(FALSE); this->GetDlgItem(IDC_WLACTION_CENTER_EDT)->EnableWindow(FALSE); this->GetDlgItem(IDC_WLACTION_FILLTYPE_COM)->EnableWindow(FALSE); pTheApp->AddSupString(&m_cmbModifier); pTheApp->AddVirtualKeyString(&m_cmbUpKey); pTheApp->AddVirtualKeyString(&m_cmbDownKey); pTheApp->AddVirtualKeyString(&m_cmbLeftKey); pTheApp->AddVirtualKeyString(&m_cmbRightKey); m_pView->m_ConView.WindowLevelAction().GetKeyboardAction(CONVIEW_MOUSEMOVE_UP, 0); pTheApp->GetKeyboardInfo(&m_cmbUpKey, &m_cmbModifier, m_pView->m_ConView.WindowLevelAction().GetKey(), m_pView->m_ConView.WindowLevelAction().GetModifier()); m_pView->m_ConView.WindowLevelAction().GetKeyboardAction(CONVIEW_MOUSEMOVE_DOWN, 0); pTheApp->GetKeyboardInfo(&m_cmbDownKey, &m_cmbModifier, m_pView->m_ConView.WindowLevelAction().GetKey(), m_pView->m_ConView.WindowLevelAction().GetModifier()); m_pView->m_ConView.WindowLevelAction().GetKeyboardAction(CONVIEW_MOUSEMOVE_LEFT, 0); pTheApp->GetKeyboardInfo(&m_cmbLeftKey, &m_cmbModifier, m_pView->m_ConView.WindowLevelAction().GetKey(), m_pView->m_ConView.WindowLevelAction().GetModifier()); m_pView->m_ConView.WindowLevelAction().GetKeyboardAction(CONVIEW_MOUSEMOVE_RIGHT, 0); pTheApp->GetKeyboardInfo(&m_cmbRightKey, &m_cmbModifier, m_pView->m_ConView.WindowLevelAction().GetKey(), m_pView->m_ConView.WindowLevelAction().GetModifier()); m_bCircleMouse = m_pView->m_ConView.WindowLevelAction().GetCircularMouseMove(); m_uSensitivity = m_pView->m_ConView.WindowLevelAction().GetChange(); m_hIcon = pTheApp->IPictureDispTohIcon((IPictureDisp *)(m_pView->m_ConView.WindowLevelAction().GetCursor().m_lpDispatch)); m_ActionCursor.SetIcon( m_hIcon); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CWinLevelPrpoDlg::OnChangeActionCellindexEdt() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); UpdateData(); m_pView->m_ConView.WindowLevelAction().GetAction(m_uCellIndex, m_uSubCellIndex, CONVIEW_ACTIONLEVEL_CELL); m_uWidth = m_pView->m_ConView.WindowLevelAction().GetWidth(); m_nCenter = m_pView->m_ConView.WindowLevelAction().GetCenter(); m_cmbFillType.SetCurSel((m_pView->m_ConView.WindowLevelAction().GetFillType() >> 4) - 1); pTheApp->m_pRaster = (ILEADRaster *)m_pView->m_ConView.Cell(m_uCellIndex).GetBitmapList(); short nCount; pTheApp->m_pRaster->get_BitmapListCount(&nCount); m_edtSubCellIndex.SetNumericEditBox(0, nCount - 1, 1, 0, 0); UpdateData(FALSE); } void CWinLevelPrpoDlg::OnSelchangeActionCellindexCom() { INT nRet = m_cmbCell.GetCurSel(); GetDlgItem(IDC_ACTION_CELLINDEX_EDT)->EnableWindow(nRet == 2); GetDlgItem(IDC_ACTION_SUBCELLINDEX_COM)->EnableWindow((nRet != 0)); GetDlgItem(IDC_ACTION_SUBCELLINDEX_EDT)->EnableWindow((nRet != 0) && (m_cmbSubCellIndex.GetCurSel())); GetDlgItem(IDC_WLACTION_WIDTH_EDT)->EnableWindow(nRet != 0); GetDlgItem(IDC_WLACTION_CENTER_EDT)->EnableWindow(nRet != 0); GetDlgItem(IDC_WLACTION_FILLTYPE_COM)->EnableWindow(nRet != 0); } void CWinLevelPrpoDlg::OnSelchangeActionSubcellindexCom() { GetDlgItem(IDC_ACTION_SUBCELLINDEX_EDT)->EnableWindow((m_cmbSubCellIndex.GetCurSel() == 1)); } void CWinLevelPrpoDlg::OnChangeActionSubcellindexEdt() { UpdateData(); m_pView->m_ConView.WindowLevelAction().GetAction(m_uCellIndex, m_uSubCellIndex, CONVIEW_ACTIONLEVEL_CELL); m_uWidth = m_pView->m_ConView.WindowLevelAction().GetWidth(); m_nCenter = m_pView->m_ConView.WindowLevelAction().GetCenter(); m_cmbFillType.SetCurSel((m_pView->m_ConView.WindowLevelAction().GetFillType() >> 4) - 1); UpdateData(FALSE); } void CWinLevelPrpoDlg::OnPaint() { CPaintDC dc(this); // device context for painting CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); pTheApp->RepaintButton(this, IDC_WLACTION_CLRIN_TXT, m_ColorIn); pTheApp->RepaintButton(this, IDC_WLACTION_CLROUT_TXT,m_ColorOut); } void CWinLevelPrpoDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); pTheApp->RepaintButton(this, IDC_WLACTION_CLRIN_TXT, m_ColorIn); pTheApp->RepaintButton(this, IDC_WLACTION_CLROUT_TXT,m_ColorOut); CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); } void CWinLevelPrpoDlg::OnWlactionClrinBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_ColorIn = pTheApp->ShowColorDlg (m_ColorIn, (this->GetSafeHwnd())); RedrawWindow(); } void CWinLevelPrpoDlg::OnWlactionClroutBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_ColorOut = pTheApp->ShowColorDlg (m_ColorIn, (this->GetSafeHwnd())); RedrawWindow(); }