700 lines
18 KiB
C++
700 lines
18 KiB
C++
// OpCreate3DSptDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "OpCreate3DSptDlg.h"
|
|
|
|
#include "Medium3D.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreate3DSptDlg dialog
|
|
extern HHOOK hHook;
|
|
extern int g_iUILanguage;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
|
|
COpCreate3DSptDlg::COpCreate3DSptDlg(CScript3D* pNewScript, CLinkList<CMedium*>* pMedLinkList, INT_PTR* pRet, CWnd* pParent /*=NULL*/)
|
|
: CDialog(COpCreate3DSptDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(COpCreate3DSptDlg)
|
|
m_operator = _T("");
|
|
m_desc = _T("");
|
|
m_scriptName = _T("");
|
|
m_x1 = 0;
|
|
m_x0 = 0;
|
|
m_y1 = 0;
|
|
m_y0 = 0;
|
|
m_area = _T("");
|
|
m_c1x = 0;
|
|
m_c1y = 0;
|
|
m_c2x = 0;
|
|
m_c2y = 0;
|
|
m_pDisX = 0;
|
|
m_pDisY = 0;
|
|
m_pStepX = 0;
|
|
m_pStepY = 0;
|
|
m_ScriptNum = 0;
|
|
m_DeDate = CTime::GetCurrentTime();
|
|
m_pStartX = 0.0f;
|
|
m_pStartY = 0.0f;
|
|
//}}AFX_DATA_INIT
|
|
|
|
// m_pRet = pRet;
|
|
m_pNewScript = pNewScript;
|
|
// m_pOpCreateSptFrame = NULL;
|
|
|
|
m_pMedLinkList = pMedLinkList;
|
|
|
|
// m_pOpCreateSptView = NULL;
|
|
// m_pOpCreateSptInfoView = NULL;
|
|
// m_pOpCreateSptRecListView = NULL;
|
|
|
|
}
|
|
|
|
|
|
void COpCreate3DSptDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(COpCreate3DSptDlg)
|
|
DDX_Control(pDX, IDC_SPT_CHNUMBER, m_chnumber);
|
|
DDX_Control(pDX, IDC_SPT_CHAMOUNT, m_chamount);
|
|
DDX_Control(pDX, IDC_CHECK, m_diagonal);
|
|
DDX_Control(pDX, IDC_SPT_AR, m_ar);
|
|
DDX_Text(pDX, IDC_SPT_DEFINER, m_operator);
|
|
DDX_Text(pDX, IDC_SPT_SCDESC, m_desc);
|
|
DDX_Text(pDX, IDC_SPT_SNAME, m_scriptName);
|
|
DDX_Text(pDX, IDC_XONE, m_x1);
|
|
DDX_Text(pDX, IDC_XZERO, m_x0);
|
|
DDX_Text(pDX, IDC_YONE, m_y1);
|
|
DDX_Text(pDX, IDC_YZERO, m_y0);
|
|
DDX_Text(pDX, IDC_SPT_AREA, m_area);
|
|
DDX_Text(pDX, IDC_C1X, m_c1x);
|
|
DDX_Text(pDX, IDC_C1Y, m_c1y);
|
|
DDX_Text(pDX, IDC_C2X, m_c2x);
|
|
DDX_Text(pDX, IDC_C2Y, m_c2y);
|
|
DDX_Text(pDX, IDC_P_DIS_X, m_pDisX);
|
|
DDX_Text(pDX, IDC_P_DIS_Y, m_pDisY);
|
|
DDX_Text(pDX, IDC_P_STEP_X, m_pStepX);
|
|
DDX_Text(pDX, IDC_P_STEP_Y, m_pStepY);
|
|
DDX_Text(pDX, IDC_SCRIPT_NUM, m_ScriptNum);
|
|
DDX_DateTimeCtrl(pDX, IDC_SPT_DATE, m_DeDate);
|
|
DDX_Text(pDX, IDC_P_START_X, m_pStartX);
|
|
DDX_Text(pDX, IDC_P_START_Y, m_pStartY);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpCreate3DSptDlg, CDialog)
|
|
//{{AFX_MSG_MAP(COpCreate3DSptDlg)
|
|
ON_WM_SIZE()
|
|
ON_BN_CLICKED(RET_OK, OnOk)
|
|
ON_CBN_SELCHANGE(IDC_SPT_AR, OnSelchangeSptAr)
|
|
ON_BN_CLICKED(IDC_OK, OnOk)
|
|
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreate3DSptDlg message handlers
|
|
|
|
|
|
BOOL COpCreate3DSptDlg::Create(UINT nID, CWnd* pParentWnd)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
pParentWnd->EnableWindow(FALSE);
|
|
return CDialog::Create(IDD, pParentWnd);
|
|
}
|
|
|
|
|
|
BOOL Zoom_Window(HWND hWnd, CRect TaregetEX_Pos, LPRECT mOrgRect, BOOL bZoomEx_Only)
|
|
{
|
|
if(hWnd)
|
|
{
|
|
BOOL IsVisable = IsWindowVisible(hWnd);
|
|
|
|
if(!bZoomEx_Only)
|
|
{
|
|
::SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_HIDEWINDOW);
|
|
|
|
CRect SrcWndRect;
|
|
if(mOrgRect)
|
|
{
|
|
SrcWndRect = mOrgRect;
|
|
}
|
|
else
|
|
{
|
|
GetWindowRect(hWnd,&SrcWndRect);
|
|
}
|
|
|
|
DWORD style = GetWindowLong(hWnd, GWL_STYLE);
|
|
|
|
INT_PTR Board_dx = 0, Board_dy = 0;
|
|
|
|
if( WS_CAPTION == (style & WS_CAPTION) )
|
|
{
|
|
Board_dy += GetSystemMetrics(SM_CYCAPTION);
|
|
}
|
|
|
|
if( WS_DLGFRAME == (style & WS_DLGFRAME) )
|
|
{
|
|
Board_dx += 2 * GetSystemMetrics(SM_CXBORDER);
|
|
Board_dy += 2 * GetSystemMetrics(SM_CYBORDER);
|
|
}
|
|
else if( WS_BORDER == (style & WS_BORDER) )
|
|
{
|
|
Board_dx += GetSystemMetrics(SM_CXBORDER);
|
|
Board_dy += GetSystemMetrics(SM_CYBORDER);
|
|
}
|
|
else
|
|
{
|
|
}
|
|
|
|
double dx = (double)(TaregetEX_Pos.Width() - Board_dx) / (double)(SrcWndRect.Width() - Board_dx);
|
|
double dy = (double)(TaregetEX_Pos.Height() - Board_dy) / (double)(SrcWndRect.Height() - Board_dy);
|
|
|
|
HWND hChild = ::GetWindow(hWnd, GW_CHILD);
|
|
while(hChild != NULL)
|
|
{
|
|
CRect rect;
|
|
GetWindowRect(hChild, &rect);
|
|
CPoint pt_lt(rect.left, rect.top);
|
|
ScreenToClient(hWnd, &pt_lt);
|
|
MoveWindow(hChild,
|
|
(INT)(pt_lt.x * dx),
|
|
(INT)(pt_lt.y * dy),
|
|
(INT)(rect.Width() * dx),
|
|
(INT)(rect.Height() * dy), true);
|
|
|
|
hChild = GetWindow(hChild, GW_HWNDNEXT);
|
|
}
|
|
}
|
|
//MoveWindow(hWnd, TaregetEX_Pos.left, TaregetEX_Pos.top, TaregetEX_Pos.right, TaregetEX_Pos.bottom, true);
|
|
UINT nFlage = SWP_NOZORDER|SWP_DRAWFRAME|SWP_DEFERERASE;
|
|
if(IsVisable) nFlage |= SWP_SHOWWINDOW;
|
|
::SetWindowPos(hWnd, 0,
|
|
TaregetEX_Pos.left, TaregetEX_Pos.top, TaregetEX_Pos.Width(), TaregetEX_Pos.Height(),
|
|
nFlage);
|
|
}
|
|
|
|
return(false);
|
|
}
|
|
|
|
BOOL COpCreate3DSptDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: Add extra initialization here
|
|
//窗口自适应大小
|
|
// Zoom_Window(GetSafeHwnd(), CRect(0,0, GetSystemMetrics(SM_CXSCREEN)/1.3, GetSystemMetrics(SM_CYSCREEN)/1.3));
|
|
// CenterWindow();//使窗口居中
|
|
|
|
//初始化控件
|
|
m_ar.SetItemData(m_ar.AddString("Pole-Pole"), 22);
|
|
m_ar.SetItemData(m_ar.AddString("Pole-Dipole"), 23);
|
|
m_ar.SetItemData(m_ar.AddString("Dipole-Dipole"), 24);
|
|
m_ar.SetItemData(m_ar.AddString("Schlumberger"), 25);
|
|
m_ar.SetItemData(m_ar.AddString("WennerAlfa"), 26);
|
|
m_ar.SetItemData(m_ar.AddString("WennerBeta"), 27);
|
|
m_ar.SetItemData(m_ar.AddString("Gradient"), 28);
|
|
|
|
m_chamount.AddString("1");
|
|
m_chamount.SetCurSel(0);
|
|
m_chamount.EnableWindow(false);
|
|
|
|
m_chnumber.AddString("1");
|
|
m_chnumber.SetCurSel(0);
|
|
m_chnumber.EnableWindow(false);
|
|
|
|
CChannel* pChannel = new CChannel;
|
|
pChannel->m_iChNumber = (int)VAL_ONE;
|
|
m_pNewScript->m_chaList.AddTail((void*)pChannel);
|
|
this->GetDlgItem(IDC_SPT_SNAME)->SetFocus();
|
|
|
|
//禁用C1 C2编辑框
|
|
this->GetDlgItem(IDC_C1X)->EnableWindow(FALSE);
|
|
this->GetDlgItem(IDC_C1Y)->EnableWindow(FALSE);
|
|
this->GetDlgItem(IDC_C2X)->EnableWindow(FALSE);
|
|
this->GetDlgItem(IDC_C2Y)->EnableWindow(FALSE);
|
|
|
|
//初始化步长和电极间距
|
|
m_ScriptNum = m_pStepX = m_pStepY = m_pDisY = m_pDisX = 1;
|
|
|
|
m_pStartX = m_pStartY = 0.0;
|
|
|
|
UpdateData(FALSE);
|
|
((CEdit*)GetDlgItem(IDC_SPT_SNAME))->SetLimitText(20);
|
|
|
|
return FALSE;
|
|
|
|
// return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void COpCreate3DSptDlg::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDialog::OnSize(nType, cx, cy);
|
|
|
|
// TODO: Add your message handler code here
|
|
}
|
|
|
|
void COpCreate3DSptDlg::OnOk()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
UpdateData(TRUE);
|
|
|
|
//检查界面的值是否有效
|
|
if (!CheckControlVaild())
|
|
return;
|
|
|
|
CMedium3D *pMedium3D = NULL;
|
|
CSptRecord* pSptRecord = NULL;
|
|
|
|
DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iAR = (int)VAL_ZERO;
|
|
|
|
//UpdateData(TRUE)会导致此处溢出,建议重新创建界面中的控件
|
|
POSITION pos = m_pNewScript->m_chaList.FindIndex(m_chnumber.GetCurSel());
|
|
CChannel* pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(pos);
|
|
|
|
iAR = m_ar.GetItemData(m_ar.GetCurSel());
|
|
|
|
dwMedHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
|
|
pChannel->m_pMedium = m_pMedLinkList->Find(dwMedHandle);
|
|
|
|
pMedium3D = (CMedium3D *)(pChannel->m_pMedium);
|
|
|
|
int nSig = 0;
|
|
memset(m_zone, 0, 8);
|
|
|
|
nSig = zoneCount(m_area); //计算测点区域的数量
|
|
|
|
switch (nSig)
|
|
{
|
|
case 1:
|
|
break;
|
|
case -1://参数过长
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox("your area parameter is too long, please check and reset the parameter");
|
|
memset(m_zone, 0, 8);
|
|
break;
|
|
case -2:
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox("your area parameter is invaild, please check and reset the parameter");
|
|
memset(m_zone, 0, 8);
|
|
break;
|
|
}
|
|
|
|
//初始化3d脚本对象
|
|
pMedium3D->create();
|
|
|
|
//检查是否勾选对角线选项
|
|
int nCheck = 0;
|
|
nCheck = m_diagonal.GetCheck();
|
|
if (nCheck) //判断是否取45°对角线
|
|
pMedium3D->SetFlags(TRUE);
|
|
|
|
//根据用户输入的置设置句型大小
|
|
pMedium3D->SetRect(m_x0, m_y0, m_x1, m_y1);
|
|
|
|
//设置电极步长
|
|
pMedium3D->SetPoleStep(m_pStepX, m_pStepY);
|
|
|
|
//设置电极间距
|
|
pMedium3D->SetPoleDistance(m_pDisX, m_pDisY);
|
|
|
|
//设置需要生成的测点区域
|
|
pMedium3D->setZone(true, nSig, m_zone); //m_zone[0]保存了长度
|
|
|
|
//中梯装置需要输入C1, C2信息
|
|
if (iAR == 28)
|
|
{
|
|
//设置中梯装置的c1,c2
|
|
pMedium3D->SetPointCPosition("C1",m_c1x, m_c1y);
|
|
pMedium3D->SetPointCPosition("C2",m_c2x, m_c2y);
|
|
}
|
|
|
|
//执行脚本生成
|
|
if (!pMedium3D->generate())
|
|
{
|
|
// AfxMessageBox("error");
|
|
return;
|
|
}
|
|
|
|
//3d脚本不再使用该字段记录测点总数
|
|
m_pNewScript->m_iEAmount = pMedium3D->getPoleCount();
|
|
|
|
pChannel->ClearSptRecList();
|
|
|
|
pMedium3D->GenerateSptRecElecVal3D(m_ScriptNum, m_pNewScript, &(pChannel->m_iPtAmount), &(pChannel->m_sptRecArray));
|
|
|
|
pMedium3D->Destroy();
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void COpCreate3DSptDlg::OnCancel()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
bool COpCreate3DSptDlg::CheckControlVaild()
|
|
{
|
|
CString szCaption;
|
|
//判断是否输入脚本名字
|
|
if (m_scriptName.GetLength() == 0)
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_OP_LC_SCON_INPUT_SNAME);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption, NULL, MB_ICONWARNING);
|
|
this->GetDlgItem(IDC_SPT_SNAME)->SetFocus();
|
|
return FALSE;
|
|
}
|
|
|
|
//判断是否选择装置类型
|
|
if ((int)VAL_MINUS_ONE == m_ar.GetCurSel())
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_OP_LC_SCON_SEL_AR);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption, NULL, MB_ICONWARNING);
|
|
this->GetDlgItem(IDC_SPT_AR)->SetFocus();
|
|
return FALSE;
|
|
}
|
|
|
|
//检查X0,Y0,X1,Y1是否有效,若两点重合则无效
|
|
if (m_x0 == m_x1 && m_y0 == m_y1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请设置一个有效的矩形"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please set a vaild rect"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
if (m_x1 > 30 || m_y1 > 30)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox("The cable num should less than 30", NULL, MB_ICONWARNING);
|
|
return FALSE;
|
|
}
|
|
|
|
//如果是中梯装置则检验C1,C2的值是否有效
|
|
CString szItem = _T("");
|
|
m_ar.GetLBText(m_ar.GetCurSel(),szItem);
|
|
|
|
if (szItem == "Gradient")
|
|
{
|
|
//C1、C2不能重合
|
|
if (m_c1x == m_c2x && m_c1y == m_c2y)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("C1不能等于C2!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("C1 can not equal to C2"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
//C1,C2不能落在矩形范围之内
|
|
if (m_c1x > m_x0 && m_c1x < m_x1 && m_c1y > m_y0 && m_c1y < m_y1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("C1不能处于矩阵范围内!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("C1 can not surround by rect"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
else if(m_c2x > m_x0 && m_c2x < m_x1 && m_c2y > m_y0 && m_c2y < m_y1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("C2不能处于矩阵范围内!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("C2 can not surround by rect"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
//判断电极间距是否有效(间距不能为0)
|
|
if (m_pDisX < 0 || m_pDisY < 0)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("电极间距无效"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Pole distance invalid"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
//步长也不能为0
|
|
if (m_pStepX < 0 || m_pStepY < 0)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("电极步长无效"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Pole step invalid"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
// //检查脚本分割数量是否超过最大值
|
|
// int maxCount = 0;//脚本最大分割数量
|
|
// CString szTmp = _T("");
|
|
//
|
|
// maxCount = m_y1 - m_y0 + 1;
|
|
//
|
|
// if (m_ScriptNum > maxCount || m_ScriptNum < 1)
|
|
// {
|
|
// szTmp.Format("script splitted can not more than %d", maxCount);
|
|
// AfxMessageBox(szTmp);
|
|
// return FALSE;
|
|
// }
|
|
|
|
//将电极间距、步长、矩形坐标,格式化成指定的格式
|
|
m_PoleDistance.Format("%.1f,%.1f", m_pDisX, m_pDisY);
|
|
m_PoleStep.Format("%d,%d", m_pStepX, m_pStepY);
|
|
m_Rect.Format("%d,%d,%d,%d",m_x0,m_y0,m_x1,m_y1);
|
|
m_PoleStart.Format("%.1f,%.1f", m_pStartX, m_pStartY);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int COpCreate3DSptDlg::zoneCount(CString f_szZone)
|
|
{
|
|
//TRUE:执行成功 -1:数据过长 -2:数据无效
|
|
|
|
CString szTmp;
|
|
int nLength;
|
|
int zoneNum = 0;
|
|
|
|
nLength = f_szZone.GetLength();
|
|
|
|
if (nLength > 15)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
int nData;
|
|
|
|
for (int i = 0; i < (nLength + 1)/2; i++)
|
|
{
|
|
szTmp = f_szZone.Left(f_szZone.GetLength() - (f_szZone.GetLength() - 1));
|
|
|
|
m_zone[i] = atoi(szTmp.GetBuffer(0));
|
|
|
|
if (m_zone[i] < 0 || m_zone[i] > 7)
|
|
{
|
|
return -2;
|
|
}
|
|
zoneNum++;
|
|
f_szZone = f_szZone.Right(f_szZone.GetLength() - 2);
|
|
}
|
|
|
|
// m_zone[0] = zoneNum;
|
|
|
|
return zoneNum;
|
|
}
|
|
|
|
void COpCreate3DSptDlg::OnSelchangeSptAr()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
//Gradient
|
|
CString szItem = _T("");
|
|
m_ar.GetLBText(m_ar.GetCurSel(),szItem);
|
|
|
|
if (szItem == "Gradient")
|
|
{
|
|
this->GetDlgItem(IDC_C1X)->EnableWindow(TRUE);
|
|
this->GetDlgItem(IDC_C1Y)->EnableWindow(TRUE);
|
|
this->GetDlgItem(IDC_C2X)->EnableWindow(TRUE);
|
|
this->GetDlgItem(IDC_C2Y)->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
this->GetDlgItem(IDC_C1X)->EnableWindow(FALSE);
|
|
this->GetDlgItem(IDC_C1Y)->EnableWindow(FALSE);
|
|
this->GetDlgItem(IDC_C2X)->EnableWindow(FALSE);
|
|
this->GetDlgItem(IDC_C2Y)->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
void COpCreate3DSptDlg::_save_scr(int q, _scriptor *scr)
|
|
{
|
|
struct _rect rect = { 1, 1, 3, 3 };
|
|
struct _rect *r;
|
|
struct _point *node, *head = NULL;
|
|
int length;
|
|
FILE *fd = NULL;
|
|
|
|
char *buf = NULL;
|
|
if (!scr)
|
|
return;
|
|
|
|
head = scr_get_points(scr);
|
|
if (!head)
|
|
goto __exit;
|
|
|
|
buf = (char *)malloc(512 * sizeof(char));
|
|
if (!buf)
|
|
{
|
|
printf("buffer alloc failed!\n");
|
|
goto __exit;
|
|
}
|
|
else
|
|
{
|
|
r = scr_get_rect(scr);
|
|
_snprintf(buf, 512, "red/%s(%d,%d,%d,%d)%d.scr",
|
|
scr_get_name(scr),
|
|
r->x0, r->y0, r->x1, r->y1,q);
|
|
fd = fopen(buf, "wb+");
|
|
}
|
|
|
|
if (fd < 0)
|
|
{
|
|
printf("open \"%s\" for write failed!\n", scr_get_name(scr));
|
|
goto __exit;
|
|
}
|
|
else
|
|
{
|
|
time_t now;
|
|
struct tm *ptm;
|
|
time(&now);
|
|
ptm = localtime(&now); //取得当地时间
|
|
|
|
r = scr_get_rect(scr);
|
|
length = _snprintf(buf, 512, "<?xml version=\"1.0\" encoding=\"ansi\" ?>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "<script>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(scr));
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(scr));
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(scr));
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(scr));
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<rect>%d,%d,%d,%d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(scr));
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(scr));
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<rect>%d,%d,%d,%d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
|
|
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<channel>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t</channel>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t<layout>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
}
|
|
|
|
for (node = head; node;)
|
|
{
|
|
length = _snprintf(buf, 512, "\t\t<array tsn=\"%d\" ch=\"1\" c1=\"%d\" c2=\"%d\" n=\"1\">\r\n", node->TSN, node->A, node->B);
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d,%d</ch>\r\n", node->KS, node->M, node->N);
|
|
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "\t\t</array>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
|
|
if (node->next == head)
|
|
break;
|
|
node = node->next;
|
|
}
|
|
length = _snprintf(buf, 512, "\t</layout>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
length = _snprintf(buf, 512, "</script>\r\n");
|
|
fwrite(buf, 1, length,fd);
|
|
__exit:
|
|
|
|
if (fd)
|
|
fclose(fd);
|
|
if (buf)
|
|
free(buf);
|
|
return;
|
|
|
|
}
|
|
|
|
BOOL COpCreate3DSptDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
int COpCreate3DSptDlg::PostionToStepPostion(int f_originalPostion)
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
int sum = 0;
|
|
|
|
//-1表示这个点在无穷远范围,不做处理
|
|
if (f_originalPostion == -1)
|
|
{
|
|
return f_originalPostion;
|
|
}
|
|
|
|
//计算行号
|
|
int nLineth = 0;//记录第几行
|
|
nLineth = f_originalPostion / (m_y1 - m_y0 + 1);
|
|
|
|
//记录余数,判断是否是新起一行
|
|
int remainder = 0;
|
|
remainder = f_originalPostion % (m_y1 - m_y0 + 1);
|
|
|
|
if (remainder == 0)
|
|
{
|
|
nLineth -= 1;
|
|
}
|
|
|
|
sum = f_originalPostion + (m_pStepX - 1) * (f_originalPostion - 1) + (m_pStepY - m_pStepX) * nLineth;
|
|
|
|
return sum;
|
|
}
|
|
|
|
CString COpCreate3DSptDlg::GetPoleStep()
|
|
{
|
|
return m_PoleStep;
|
|
}
|
|
|
|
CString COpCreate3DSptDlg::GetRect()
|
|
{
|
|
return m_Rect;
|
|
}
|
|
|
|
CString COpCreate3DSptDlg::GetPoleDistance()
|
|
{
|
|
return m_PoleDistance;
|
|
}
|
|
|
|
CString COpCreate3DSptDlg::GetPoleStart()
|
|
{
|
|
return m_PoleStart;
|
|
}
|