|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "LaiPuLaser.h"
|
|
|
|
|
#include "DlgObjComponent.h"
|
|
|
|
|
#include "DlgObjComponentArr.h"
|
|
|
|
|
#include "afxdialogex.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "TemplateMgr.h"
|
|
|
|
|
#include "MsgBox.h"
|
|
|
|
|
#include "MeasureMgr.h"
|
|
|
|
|
#include "ProductMgr.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CDlgObjComponent, CDialogEx)
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDlgObjComponent, CDialogEx)
|
|
|
|
|
ON_BN_CLICKED(IDC_NEW, &CDlgObjComponent::OnBnClickedNew)
|
|
|
|
|
ON_BN_CLICKED(IDC_DELETE, &CDlgObjComponent::OnBnClickedDelete)
|
|
|
|
|
ON_BN_CLICKED(IDC_COMMIT, &CDlgObjComponent::OnBnClickedCommit)
|
|
|
|
|
ON_NOTIFY(NM_CLICK, IDC_BASE_OBJ_LIST, &CDlgObjComponent::OnNMClickValStrList)
|
|
|
|
|
ON_BN_CLICKED(ID_OK, &CDlgObjComponent::OnBnClickedOk)
|
|
|
|
|
ON_BN_CLICKED(IDC_ZOOM_IN, &CDlgObjComponent::OnBnClickedZoomIn)
|
|
|
|
|
ON_BN_CLICKED(IDC_ZOOM_OUT, &CDlgObjComponent::OnBnClickedZoomOut)
|
|
|
|
|
ON_BN_CLICKED(IDCANCEL, &CDlgObjComponent::OnBnClickedCancel)
|
|
|
|
|
ON_BN_CLICKED(IDC_ARRAY_INFO, &CDlgObjComponent::OnBnClickedArrayInfo)
|
|
|
|
|
ON_BN_CLICKED(IDC_RADIO_CIRCLE, &CDlgObjComponent::OnBnClickedRadioCircle)
|
|
|
|
|
ON_BN_CLICKED(IDC_RADIO_RECT, &CDlgObjComponent::OnBnClickedRadioRect)
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
CDlgObjComponent::CDlgObjComponent(CObjComponentMgr &Mgr,CWnd* pParent)
|
|
|
|
|
: CDialogEx(CDlgObjComponent::IDD, pParent),m_ObjComponentMgr(Mgr)
|
|
|
|
|
{
|
|
|
|
|
m_DefualtAng = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CDlgObjComponent::~CDlgObjComponent()
|
|
|
|
|
{
|
|
|
|
|
m_ObjComponentMgr.SetDrawBase(false);
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDlgObjComponent::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
{
|
|
|
|
|
CDialogEx::DoDataExchange(pDX);
|
|
|
|
|
DDX_Control(pDX, IDC_BASE_OBJ_LIST, m_List);
|
|
|
|
|
DDX_Text(pDX, IDC_CENTER_X, m_CurObj.m_BasePt.x);
|
|
|
|
|
DDX_Text(pDX, IDC_CENTER_Y, m_CurObj.m_BasePt.y);
|
|
|
|
|
DDX_Text(pDX, IDC_WIDTH, m_CurObj.m_Size.w);
|
|
|
|
|
DDX_Text(pDX, IDC_HEIGHT, m_CurObj.m_Size.h);
|
|
|
|
|
DDX_Text(pDX, IDC_DEFAULT_ANG, m_DefualtAng);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL CDlgObjComponent::OnInitDialog()
|
|
|
|
|
{
|
|
|
|
|
CDialogEx::OnInitDialog();
|
|
|
|
|
|
|
|
|
|
m_ObjComponentMgr.SetDrawAllObj(true);
|
|
|
|
|
m_ObjComponentMgrBak = m_ObjComponentMgr;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
m_ObjComponentMgr.SetDrawBase(true);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>б<EFBFBD>
|
|
|
|
|
IniList();
|
|
|
|
|
|
|
|
|
|
//ˢ<><CBA2><EFBFBD>б<EFBFBD>
|
|
|
|
|
UpdateAreaList();
|
|
|
|
|
|
|
|
|
|
gTemplateMgr->ClearTempNull();
|
|
|
|
|
gTemplateMgr->BindNullTemp();
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
|
|
|
|
|
m_DefualtAng = AngleTo360(m_ObjComponentMgr.GetDefaultAng());//Ĭ<>ϽǶ<CFBD>
|
|
|
|
|
|
|
|
|
|
UpdateData(FALSE);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>б<EFBFBD>
|
|
|
|
|
void CDlgObjComponent::IniList()
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
|
|
|
|
|
m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int idx = 0;
|
|
|
|
|
int w = 60;
|
|
|
|
|
m_List.InsertColumn(idx,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",LVCFMT_CENTER,50,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
m_List.InsertColumn(idx,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X",LVCFMT_CENTER,w,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
m_List.InsertColumn(idx,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y",LVCFMT_CENTER,w,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
m_List.InsertColumn(idx,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",LVCFMT_CENTER,w,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
m_List.InsertColumn(idx,"<EFBFBD>߶<EFBFBD>",LVCFMT_CENTER,w,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
//ˢ<><CBA2><EFBFBD>б<EFBFBD>
|
|
|
|
|
void CDlgObjComponent::UpdateAreaList()
|
|
|
|
|
{
|
|
|
|
|
m_List.DeleteAllItems();
|
|
|
|
|
m_ObjComponentMgr.InsertList(m_List);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
|
|
|
|
|
m_List.SetItemState(m_CurSelListIdx,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
|
|
|
|
|
m_List.SetFocus();
|
|
|
|
|
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
|
|
|
|
|
UpdateData(FALSE);
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡlist <20><>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>
|
|
|
|
|
int CDlgObjComponent::GetCurListIdx(CListCtrl &list)
|
|
|
|
|
{
|
|
|
|
|
POSITION pos = m_List.GetFirstSelectedItemPosition();
|
|
|
|
|
if (pos == NULL)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (pos)
|
|
|
|
|
{
|
|
|
|
|
int nItem = m_List.GetNextSelectedItem(pos);
|
|
|
|
|
return nItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
void CDlgObjComponent::OnNMClickValStrList(NMHDR *pNMHDR, LRESULT *pResult)
|
|
|
|
|
{
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
AreaListEvent();
|
|
|
|
|
SetCtrlState();
|
|
|
|
|
}
|
|
|
|
|
//list <20>¼<EFBFBD>
|
|
|
|
|
void CDlgObjComponent::AreaListEvent()
|
|
|
|
|
{
|
|
|
|
|
UpdateData(TRUE);
|
|
|
|
|
m_CurSelListIdx=GetCurListIdx(m_List);
|
|
|
|
|
m_ObjComponentMgr.OpArea(m_CurSelListIdx,m_CurObj,true);
|
|
|
|
|
m_ObjComponentMgr.SetCurSelIdx(m_CurSelListIdx);
|
|
|
|
|
UpdateData(FALSE);
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD>obj
|
|
|
|
|
void CDlgObjComponent::OnBnClickedNew()
|
|
|
|
|
{
|
|
|
|
|
m_ObjComponentMgr.AddBaseComponent();
|
|
|
|
|
UpdateAreaList();
|
|
|
|
|
}
|
|
|
|
|
void CDlgObjComponent::OnBnClickedDelete()
|
|
|
|
|
{
|
|
|
|
|
if(m_CurSelListIdx>=0)
|
|
|
|
|
{
|
|
|
|
|
m_ObjComponentMgr.DelSel(m_CurSelListIdx);
|
|
|
|
|
UpdateAreaList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>Ļ<DEB8>Ԫ<D7BC><D4AA>
|
|
|
|
|
void CDlgObjComponent::OnBnClickedCommit()
|
|
|
|
|
{
|
|
|
|
|
UpdateData(TRUE);
|
|
|
|
|
m_ObjComponentMgr.OpArea(m_CurSelListIdx,m_CurObj,false);
|
|
|
|
|
m_ObjComponentMgr.Array();
|
|
|
|
|
UpdateAreaList();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1//<2F>۲<EFBFBD>
|
|
|
|
|
void CDlgObjComponent::OnBnClickedZoomOut()
|
|
|
|
|
{
|
|
|
|
|
GetCurViewPtr()->OnZoomOut();
|
|
|
|
|
}
|
|
|
|
|
void CDlgObjComponent::OnBnClickedZoomIn()
|
|
|
|
|
{
|
|
|
|
|
GetCurViewPtr()->OnZoomIn();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
void CDlgObjComponent::OnBnClickedOk()
|
|
|
|
|
{
|
|
|
|
|
//<2F>Ļ<DEB8>Ԫ<D7BC><D4AA>
|
|
|
|
|
OnBnClickedCommit();
|
|
|
|
|
OnOK();
|
|
|
|
|
}
|
|
|
|
|
void CDlgObjComponent::OnBnClickedCancel()
|
|
|
|
|
{
|
|
|
|
|
m_ObjComponentMgr = m_ObjComponentMgrBak;//<2F>ָ<EFBFBD>
|
|
|
|
|
CDialogEx::OnCancel();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
void CDlgObjComponent::OnBnClickedArrayInfo()
|
|
|
|
|
{
|
|
|
|
|
CDlgObjComponentArr dlg(m_ObjComponentMgr);
|
|
|
|
|
dlg.DoModal();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
void CDlgObjComponent::SetCtrlState()
|
|
|
|
|
{
|
|
|
|
|
if(m_CurObj.IsCircle())
|
|
|
|
|
{
|
|
|
|
|
((CButton *)GetDlgItem(IDC_RADIO_CIRCLE))->SetCheck(true);
|
|
|
|
|
((CButton *)GetDlgItem(IDC_RADIO_RECT))->SetCheck(false);
|
|
|
|
|
GetDlgItem(IDC_OBJ_W)->SetWindowText("ֱ<EFBFBD><EFBFBD>");
|
|
|
|
|
GetDlgItem(IDC_OBJ_H)->ShowWindow(SW_HIDE);
|
|
|
|
|
GetDlgItem(IDC_HEIGHT)->ShowWindow(SW_HIDE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
((CButton *)GetDlgItem(IDC_RADIO_RECT))->SetCheck(true);
|
|
|
|
|
((CButton *)GetDlgItem(IDC_RADIO_CIRCLE))->SetCheck(false);
|
|
|
|
|
GetDlgItem(IDC_OBJ_W)->SetWindowText("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
GetDlgItem(IDC_OBJ_H)->ShowWindow(SW_SHOW);
|
|
|
|
|
GetDlgItem(IDC_HEIGHT)->ShowWindow(SW_SHOW);
|
|
|
|
|
}
|
|
|
|
|
UpdateData(FALSE);
|
|
|
|
|
}
|
|
|
|
|
void CDlgObjComponent::OnBnClickedRadioCircle()
|
|
|
|
|
{
|
|
|
|
|
m_CurObj.SetIsCircle(true);
|
|
|
|
|
SetCtrlState();
|
|
|
|
|
}
|
|
|
|
|
void CDlgObjComponent::OnBnClickedRadioRect()
|
|
|
|
|
{
|
|
|
|
|
m_CurObj.SetIsCircle(false);
|
|
|
|
|
SetCtrlState();
|
|
|
|
|
}
|
|
|
|
|
#endif
|