www.pudn.com > XRayImg.rar > AjustHue.cpp
// AjustHue.cpp : implementation file
//
#include "stdafx.h"
#include "XRayImg.h"
#include "AjustHue.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAjustHue dialog
CAjustHue::CAjustHue(CWnd* pParent /*=NULL*/)
: CDialog(CAjustHue::IDD, pParent)
{
//{{AFX_DATA_INIT(CAjustHue)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bCreated=FALSE;
}
void CAjustHue::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAjustHue)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDC_PIC_OLD, m_picOld);
DDX_Control(pDX, IDC_PIC_NEW, m_picNew);
DDX_Control(pDX, IDC_EDIT3, m_edt1);
DDX_Control(pDX, IDC_EDIT2, m_edt2);
DDX_Control(pDX, IDC_EDIT1, m_edt3);
DDX_Text(pDX, IDC_EDIT1, m_iEdt1);
DDV_MinMaxInt(pDX, m_iEdt1, 0, 200);
DDX_Text(pDX, IDC_EDIT2, m_iEdt2);
DDV_MinMaxInt(pDX, m_iEdt2, 0, 200);
DDX_Text(pDX, IDC_EDIT3, m_iEdt3);
DDV_MinMaxInt(pDX, m_iEdt3, 0, 200);
DDX_Control(pDX, IDC_SLIDER1,m_slider1 );
DDX_Control(pDX, IDC_SLIDER2,m_slider2 );
DDX_Control(pDX, IDC_SLIDER3,m_slider3 );
DDX_Control(pDX, IDC_SPIN1,m_spin1 );
DDX_Control(pDX, IDC_SPIN2,m_spin2 );
DDX_Control(pDX, IDC_SPIN3,m_spin3 );
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAjustHue, CDialog)
//{{AFX_MSG_MAP(CAjustHue)
// NOTE: the ClassWizard will add message map macros here
ON_BN_CLICKED(IDC_DEFAULT, OnDefault)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSlider1)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER2, OnReleasedcaptureSlider2)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER3, OnReleasedcaptureSlider3)
ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAjustHue message handlers
//***************************************************************
//函数功能: init
// 1) 设置参数
// 2) 创建完毕标志
//
//说明:
//***************************************************************
BOOL CAjustHue::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
OnDefault();
m_bCreated=TRUE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//***************************************************************
//函数功能: 调整亮度
// 1)
// 2)
//
//说明:
//***************************************************************
void CAjustHue::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
m_iEdt1=m_slider1.GetPos();
if( !UpdateData(FALSE) ) return;
m_picNew.AdjustHSL(m_iEdt1,m_iEdt2,m_iEdt3);
*pResult = 0;
}
void CAjustHue::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
if(!m_bCreated) return;
this->UpdateData(TRUE);
m_slider1.SetPos(m_iEdt1);
m_picNew.AdjustHSL(m_iEdt1,m_iEdt2,m_iEdt3);
}
//***************************************************************
//函数功能: 调整对比度
// 1)
// 2)
//
//说明:
//***************************************************************
void CAjustHue::OnReleasedcaptureSlider2(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
m_iEdt2=m_slider2.GetPos();
if( !UpdateData(FALSE) ) return;
m_picNew.AdjustHSL(m_iEdt1,m_iEdt2,m_iEdt3);
*pResult = 0;
}
void CAjustHue::OnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
if(!m_bCreated) return;
this->UpdateData(TRUE);
m_slider2.SetPos(m_iEdt2);
m_picNew.AdjustHSL(m_iEdt1,m_iEdt2,m_iEdt3);
}
//***************************************************************
//函数功能: 调整GAMMA
// 1)
// 2)
//
//说明:
//***************************************************************
void CAjustHue::OnReleasedcaptureSlider3(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
m_iEdt3=m_slider3.GetPos();
if( !UpdateData(FALSE) ) return;
m_picNew.AdjustHSL(m_iEdt1,m_iEdt2,m_iEdt3);
*pResult = 0;
}
void CAjustHue::OnChangeEdit3()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
if(!m_bCreated) return;
this->UpdateData(TRUE);
m_slider3.SetPos(m_iEdt3);
m_picNew.AdjustHSL(m_iEdt1,m_iEdt2,m_iEdt3);
}
//***************************************************************
//函数功能: 设置初始化或复位参数
// 1) 设置初始化参数
// 2) 复位调整状态
//
//说明:
//***************************************************************
void CAjustHue::OnDefault()
{
// TODO: Add your control notification handler code here
CWaitCursor wait;
m_picNew.SetUndoID(IDS_DI_UNDO_ADJUST_HSL);
m_slider1.SetRange(0,200,TRUE);
m_spin1.SetRange(0,200);
m_iEdt1=100;
m_slider1.SetPos(100);
m_slider2.SetRange(0,200);
m_spin2.SetRange(0,200);
m_iEdt2=100;
m_slider2.SetPos(100);
m_slider3.SetRange(0,200);
m_spin3.SetRange(0,200);
m_iEdt3=100;
m_slider3.SetPos(100);
this->UpdateData(FALSE);
m_picNew.ResetColor();
}
//***************************************************************
//函数功能: 保存数据到视图中
// 1)
// 2)
//
//说明:
//***************************************************************
void CAjustHue::OnOK()
{
// TODO: Add extra validation here
BOOL bRst;
bRst=this->UpdateData(TRUE);
if( !bRst ) return;
bRst=g_theApp.ChangeDocDibSource(IDS_DI_UNDO_ADJUST_HSL,m_iEdt1,m_iEdt2,m_iEdt3);
if(!bRst)
{
::AfxMessageBox(_T("颜色调整失败"),MB_OK+MB_APPLMODAL+MB_ICONSTOP);
return ;
}
CDialog::OnOK();
}
//***************************************************************
//函数功能: 结束
// 1)
// 2)
//
//说明:
//***************************************************************
void CAjustHue::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}