You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
5.9 KiB
C++
238 lines
5.9 KiB
C++
|
|
#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;//备份修改之前的信息
|
|
m_ObjComponentMgr.SetDrawBase(true);
|
|
|
|
//初始化列表
|
|
IniList();
|
|
|
|
//刷新列表
|
|
UpdateAreaList();
|
|
|
|
gTemplateMgr->ClearTempNull();
|
|
gTemplateMgr->BindNullTemp();
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
m_DefualtAng = AngleTo360(m_ObjComponentMgr.GetDefaultAng());//默认角度
|
|
|
|
UpdateData(FALSE);
|
|
return TRUE;
|
|
}
|
|
#if 1
|
|
//初始化列表
|
|
void CDlgObjComponent::IniList()
|
|
{
|
|
//设置风格
|
|
m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
|
|
//设置列
|
|
int idx = 0;
|
|
int w = 60;
|
|
m_List.InsertColumn(idx,"序号",LVCFMT_CENTER,50,-1);
|
|
idx++;
|
|
m_List.InsertColumn(idx,"坐标X",LVCFMT_CENTER,w,-1);
|
|
idx++;
|
|
m_List.InsertColumn(idx,"坐标Y",LVCFMT_CENTER,w,-1);
|
|
idx++;
|
|
m_List.InsertColumn(idx,"宽度",LVCFMT_CENTER,w,-1);
|
|
idx++;
|
|
m_List.InsertColumn(idx,"高度",LVCFMT_CENTER,w,-1);
|
|
idx++;
|
|
}
|
|
//刷新列表
|
|
void CDlgObjComponent::UpdateAreaList()
|
|
{
|
|
m_List.DeleteAllItems();
|
|
m_ObjComponentMgr.InsertList(m_List);
|
|
|
|
//设置列表的选中项
|
|
m_List.SetItemState(m_CurSelListIdx,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
|
|
m_List.SetFocus();
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
//获取list 当前选择的行号
|
|
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;
|
|
}
|
|
|
|
//单击列表
|
|
void CDlgObjComponent::OnNMClickValStrList(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
*pResult = 0;
|
|
AreaListEvent();
|
|
SetCtrlState();
|
|
}
|
|
//list 事件
|
|
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
|
|
//新建基本obj
|
|
void CDlgObjComponent::OnBnClickedNew()
|
|
{
|
|
m_ObjComponentMgr.AddBaseComponent();
|
|
UpdateAreaList();
|
|
}
|
|
void CDlgObjComponent::OnBnClickedDelete()
|
|
{
|
|
if(m_CurSelListIdx>=0)
|
|
{
|
|
m_ObjComponentMgr.DelSel(m_CurSelListIdx);
|
|
UpdateAreaList();
|
|
}
|
|
}
|
|
//修改基准元件
|
|
void CDlgObjComponent::OnBnClickedCommit()
|
|
{
|
|
UpdateData(TRUE);
|
|
m_ObjComponentMgr.OpArea(m_CurSelListIdx,m_CurObj,false);
|
|
m_ObjComponentMgr.Array();
|
|
UpdateAreaList();
|
|
}
|
|
#endif
|
|
#if 1//观察
|
|
void CDlgObjComponent::OnBnClickedZoomOut()
|
|
{
|
|
GetCurViewPtr()->OnZoomOut();
|
|
}
|
|
void CDlgObjComponent::OnBnClickedZoomIn()
|
|
{
|
|
GetCurViewPtr()->OnZoomIn();
|
|
}
|
|
#endif
|
|
|
|
#if 1
|
|
void CDlgObjComponent::OnBnClickedOk()
|
|
{
|
|
//修改基准元件
|
|
OnBnClickedCommit();
|
|
OnOK();
|
|
}
|
|
void CDlgObjComponent::OnBnClickedCancel()
|
|
{
|
|
m_ObjComponentMgr = m_ObjComponentMgrBak;//恢复
|
|
CDialogEx::OnCancel();
|
|
}
|
|
#endif
|
|
|
|
#if 1
|
|
//原件阵列信息
|
|
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("直径");
|
|
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("宽度");
|
|
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
|