1007 lines
26 KiB
C++
1007 lines
26 KiB
C++
// opcreatesptview.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "opcreatesptview.h"
|
|
#include "opcreatesptgndlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern BOOL DoEvent(HWND hWnd);
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreateSptView
|
|
extern int g_iUILanguage;
|
|
IMPLEMENT_DYNCREATE(COpCreateSptView, CScrollView)
|
|
|
|
COpCreateSptView::COpCreateSptView()
|
|
{
|
|
m_iMul = (int)VAL_ZERO;
|
|
m_pMemDC = NULL;
|
|
m_pNewChannel = NULL;
|
|
m_pCurSptRecord = NULL;
|
|
|
|
m_bIsDraw = FALSE;
|
|
|
|
m_bIsStartRect = FALSE;
|
|
}
|
|
|
|
COpCreateSptView::~COpCreateSptView()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpCreateSptView, CScrollView)
|
|
//{{AFX_MSG_MAP(COpCreateSptView)
|
|
ON_WM_MOUSEWHEEL()
|
|
ON_WM_ERASEBKGND()
|
|
ON_WM_HSCROLL()
|
|
ON_WM_VSCROLL()
|
|
ON_WM_LBUTTONDOWN()
|
|
ON_WM_LBUTTONUP()
|
|
ON_WM_MOUSEMOVE()
|
|
ON_WM_RBUTTONDOWN()
|
|
ON_COMMAND(IDM_OP_SPT_TP_GN, OnOpSptTpGn)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreateSptView drawing
|
|
|
|
void COpCreateSptView::OnInitialUpdate()
|
|
{
|
|
CScrollView::OnInitialUpdate();
|
|
|
|
// int iScreenCx = ::GetSystemMetrics(SM_CXSCREEN);
|
|
// int iScreenCy = ::GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
// SetScrollSizes(MM_TEXT, CSize(iScreenCx, iScreenCy));
|
|
|
|
|
|
CSize sizeTotal;
|
|
// TODO: calculate the total size of this view
|
|
sizeTotal.cx = sizeTotal.cy = 100;
|
|
SetScrollSizes(MM_TEXT, sizeTotal);
|
|
|
|
m_iMul = 2;
|
|
|
|
}
|
|
|
|
void COpCreateSptView::OnDraw(CDC* pDC)
|
|
{
|
|
CDocument* pDoc = GetDocument();
|
|
// TODO: add draw code here
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
CDC* pMemDC = new CDC;
|
|
CBitmap* pMemBmp = new CBitmap;
|
|
CBitmap* pOldMemBmp = NULL;
|
|
|
|
CRect rectMemBmp;
|
|
CRect rectView;
|
|
|
|
int iMaxViewWidth = (int)VAL_ZERO;
|
|
int iMaxViewHeight = (int)VAL_ZERO;
|
|
|
|
this->GetClientRect(&rectView);
|
|
|
|
if ((NULL != m_pNewChannel) && (TRUE == m_bIsDraw))
|
|
{
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
if (iRecCount > 0)
|
|
{
|
|
rectMemBmp.left = 0;
|
|
rectMemBmp.top = 0;
|
|
|
|
rectMemBmp.right = 200+(m_iEAmount-1)*(6+2)*m_iMul;
|
|
rectMemBmp.bottom = 200+(m_pNewChannel->m_iMaxLevel-1)*(6+2)*m_iMul;
|
|
|
|
if (rectMemBmp.Width() >= rectView.Width())
|
|
{
|
|
iMaxViewWidth = rectMemBmp.Width();
|
|
}
|
|
else
|
|
{
|
|
iMaxViewWidth = rectView.Width();
|
|
}
|
|
|
|
if (rectMemBmp.Height() >= rectView.Height())
|
|
{
|
|
iMaxViewHeight = rectMemBmp.Height();
|
|
}
|
|
else
|
|
{
|
|
iMaxViewHeight = rectView.Height();
|
|
}
|
|
|
|
pMemDC->CreateCompatibleDC(pDC);
|
|
pMemBmp->CreateCompatibleBitmap(pDC, iMaxViewWidth, iMaxViewHeight);
|
|
pOldMemBmp = pMemDC->SelectObject(pMemBmp);
|
|
|
|
pMemDC->FillSolidRect((int)VAL_ZERO, (int)VAL_ZERO, iMaxViewWidth, iMaxViewHeight, RGB(255,255,255));
|
|
|
|
this->DrawEX(pMemDC);
|
|
this->DrawLY(pMemDC);
|
|
|
|
this->DrawRecPoint(iRecCount, pMemDC);
|
|
|
|
// while (iRecIndex < iRecCount)
|
|
// {
|
|
// pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
// this->m_pNewChannel->m_pMedium->CalculatePtLoc(m_iMul, pSptRecord);
|
|
|
|
// pMemDC->Ellipse(pSptRecord->m_recPtArea);
|
|
|
|
// iRecIndex++;
|
|
// }
|
|
|
|
pDC->BitBlt((int)VAL_ZERO, (int)VAL_ZERO, iMaxViewWidth, iMaxViewHeight, pMemDC, (int)VAL_ZERO, (int)VAL_ZERO, SRCCOPY);
|
|
|
|
pMemDC->SelectObject(pOldMemBmp);
|
|
pMemBmp->DeleteObject();
|
|
pMemDC->DeleteDC();
|
|
|
|
delete pMemBmp;
|
|
delete pMemDC;
|
|
|
|
SetScrollSizes(MM_TEXT, CSize(m_iWinWidth, m_iWinHeight));
|
|
|
|
// CDC* DemoDC = NULL;
|
|
|
|
// if (NULL != ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView)
|
|
// {
|
|
// DemoDC = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->GetDC();
|
|
// }
|
|
// DemoDC->TextOut(20, 20, "OK");
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pDC->FillSolidRect((int)VAL_ZERO, (int)VAL_ZERO, rectView.Width(), rectView.Height(), RGB(255,255,255));
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreateSptView diagnostics
|
|
|
|
#ifdef _DEBUG
|
|
void COpCreateSptView::AssertValid() const
|
|
{
|
|
CScrollView::AssertValid();
|
|
}
|
|
|
|
void COpCreateSptView::Dump(CDumpContext& dc) const
|
|
{
|
|
CScrollView::Dump(dc);
|
|
}
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreateSptView message handlers
|
|
|
|
void COpCreateSptView::DrawEX(CDC* const pMemDC)
|
|
{
|
|
int iCurENum = (int)VAL_ZERO;
|
|
CString szLabel = _T("");
|
|
|
|
CFont ftEX;
|
|
CFont* pFtOldEX;
|
|
|
|
if (m_iEAmount < 1000)
|
|
{
|
|
ftEX.CreatePointFont(68, _T("Tahoma"));
|
|
}
|
|
else
|
|
{
|
|
ftEX.CreatePointFont(65, _T("Tahoma"));
|
|
}
|
|
|
|
pFtOldEX = pMemDC->SelectObject(&ftEX);
|
|
pMemDC->SetBkMode(OPAQUE);
|
|
|
|
for (iCurENum=1; iCurENum <= m_iEAmount; iCurENum++)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format("%d", iCurENum);
|
|
|
|
pMemDC->DrawText(szLabel, CRect(32+(iCurENum-1)*(6+2)*m_iMul, 10, 62+(iCurENum-1)*(6+2)*m_iMul, 30), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
pMemDC->MoveTo(46+(iCurENum-1)*(6+2)*m_iMul, 30);
|
|
pMemDC->LineTo(46+(iCurENum-1)*(6+2)*m_iMul, 40);
|
|
}
|
|
|
|
pMemDC->MoveTo(46, 40);
|
|
pMemDC->LineTo(46+(iCurENum-2)*(6+2)*m_iMul, 40);
|
|
|
|
ftEX.DeleteObject();
|
|
pMemDC->SelectObject(pFtOldEX);
|
|
|
|
this->m_iWinWidth = 46+(iCurENum-1)*(6+2)*m_iMul+50;
|
|
}
|
|
|
|
void COpCreateSptView::DrawLY(CDC* const pMemDC)
|
|
{
|
|
int iCurLNum = (int)VAL_ZERO;
|
|
CString szLabel = _T("");
|
|
|
|
CFont ftLY;
|
|
CFont* pFtOldLY = NULL;
|
|
|
|
CPen lPen(PS_DOT, 1, RGB(180, 180, 180));
|
|
CPen* pOldLPen = NULL;
|
|
if (m_iEAmount < 1000)
|
|
{
|
|
ftLY.CreatePointFont(70, _T("Tahoma"));
|
|
}
|
|
else
|
|
{
|
|
ftLY.CreatePointFont(65, _T("Tahoma"));
|
|
}
|
|
|
|
pFtOldLY = pMemDC->SelectObject(&ftLY);
|
|
pMemDC->SetBkMode(OPAQUE);
|
|
|
|
for (iCurLNum=1; iCurLNum <= (m_pNewChannel->m_iMaxLevel); iCurLNum++)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format("%d", iCurLNum);
|
|
|
|
pMemDC->DrawText(szLabel, CRect(10, 50+(iCurLNum-1)*(6+2)*m_iMul, 30, (50+6*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
pMemDC->MoveTo(30, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul);
|
|
pMemDC->LineTo(40, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul);
|
|
|
|
pOldLPen = pMemDC->SelectObject(&lPen);
|
|
pMemDC->LineTo(51+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul);
|
|
pMemDC->SelectObject(pOldLPen);
|
|
|
|
pMemDC->MoveTo(52+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul);
|
|
pMemDC->LineTo(62+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul);
|
|
|
|
pMemDC->DrawText(szLabel, CRect(5+62+(m_iEAmount-1)*(6+2)*m_iMul, 50+(iCurLNum-1)*(6+2)*m_iMul, 25+62+(m_iEAmount-1)*(6+2)*m_iMul, (50+6*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
}
|
|
|
|
pMemDC->MoveTo(40, 50+3*m_iMul);
|
|
pMemDC->LineTo(40, 50+3*m_iMul+(iCurLNum-2)*(6+2)*m_iMul);
|
|
|
|
pMemDC->MoveTo(52+(m_iEAmount-1)*(6+2)*m_iMul, 50+3*m_iMul);
|
|
pMemDC->LineTo(52+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-2)*(6+2)*m_iMul);
|
|
|
|
ftLY.DeleteObject();
|
|
pMemDC->SelectObject(pFtOldLY);
|
|
|
|
this->m_iWinHeight = (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul+50;
|
|
}
|
|
|
|
BOOL COpCreateSptView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
if (zDelta > 0)
|
|
{
|
|
if (m_iMul < 5)
|
|
{
|
|
m_iMul++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_iMul > 2)
|
|
{
|
|
m_iMul--;
|
|
}
|
|
}
|
|
this->Invalidate(FALSE);
|
|
|
|
return CScrollView::OnMouseWheel(nFlags, zDelta, pt);
|
|
}
|
|
|
|
BOOL COpCreateSptView::OnEraseBkgnd(CDC* pDC)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
|
|
return TRUE;
|
|
// return CScrollView::OnEraseBkgnd(pDC);
|
|
}
|
|
|
|
void COpCreateSptView::DrawRecPoint(int iRecCount, CDC* const pMemDC)
|
|
{
|
|
CString szLabel = _T("");
|
|
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
CSptRecord* pSptRecord = NULL;
|
|
|
|
CBrush BshPt;
|
|
CBrush* pOldBshPt = NULL;
|
|
|
|
CFont ftPt;
|
|
CFont* pOldFtPt = NULL;
|
|
|
|
ftPt.CreatePointFont(20+10*m_iMul, _T("Tahoma"));
|
|
pOldFtPt = pMemDC->SelectObject(&ftPt);
|
|
|
|
pMemDC->SetBkMode(TRANSPARENT);
|
|
|
|
while (iRecIndex < iRecCount)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
this->m_pNewChannel->m_pMedium->CalculateSptPtLoc(m_iMul, pSptRecord);
|
|
|
|
BshPt.CreateSolidBrush(pSptRecord->m_colorREF);
|
|
pOldBshPt = pMemDC->SelectObject(&BshPt);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), pSptRecord->m_iTsn);
|
|
|
|
pMemDC->Ellipse(pSptRecord->m_recPtArea);
|
|
pMemDC->DrawText(szLabel, pSptRecord->m_recPtArea, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
BshPt.DeleteObject();
|
|
iRecIndex++;
|
|
}
|
|
|
|
ftPt.DeleteObject();
|
|
|
|
pMemDC->SelectObject(pOldBshPt);
|
|
pMemDC->SelectObject(pOldFtPt);
|
|
}
|
|
|
|
void COpCreateSptView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
this->Invalidate(FALSE);
|
|
CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
|
|
}
|
|
|
|
void COpCreateSptView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
this->Invalidate(FALSE);
|
|
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
|
|
}
|
|
|
|
void COpCreateSptView::OnLButtonDown(UINT nFlags, CPoint point)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
//如果不需要画剖面图的话,则屏蔽相应的鼠标按键消息
|
|
if (!m_bIsDraw)
|
|
{
|
|
CScrollView::OnLButtonDown(nFlags, point);
|
|
return;
|
|
}
|
|
|
|
CSptRecord* pSptRecord = NULL;
|
|
LVFINDINFO info;
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szLabel = _T("");
|
|
|
|
pSptRecord = SelectByPoint(point);
|
|
|
|
if (NULL != pSptRecord)
|
|
{
|
|
m_pCurSptRecord = pSptRecord;
|
|
m_bIsStartRect = FALSE;
|
|
if (NULL != ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView)
|
|
{
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)pSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), pSptRecord->m_iN);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iIndex, 6, szLabel);
|
|
}
|
|
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetCheck(iIndex, pSptRecord->m_bIsSel);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetHotItem(iIndex);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().EnsureVisible(iIndex, TRUE);
|
|
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemState(iIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetFocus();
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemState(iIndex, LVIS_SELECTED , LVIS_SELECTED );
|
|
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->m_pCurSptRecord = m_pCurSptRecord;
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->Invalidate();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (TRUE == this->m_bIsDraw)
|
|
{
|
|
m_bIsStartRect = TRUE;
|
|
m_startPoint = point;
|
|
m_oldPoint = point;
|
|
|
|
SetCapture();
|
|
}
|
|
}
|
|
|
|
CScrollView::OnLButtonDown(nFlags, point);
|
|
}
|
|
|
|
CSptRecord* COpCreateSptView::SelectByPoint(CPoint point)
|
|
{
|
|
CClientDC viewDC(this);
|
|
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
CString szLabel = _T("");
|
|
CSptRecord* pSptRecord = NULL;
|
|
|
|
CPoint ptCur = point;
|
|
|
|
CBrush BshPt;
|
|
CBrush* pOldBshPt = NULL;
|
|
|
|
CFont ftPt;
|
|
CFont* pOldFtPt = NULL;
|
|
|
|
viewDC.SetViewportOrg(-(GetScrollPos(SB_HORZ)), -(GetScrollPos(SB_VERT)));
|
|
viewDC.DPtoLP(&ptCur);
|
|
|
|
if (NULL != m_pNewChannel)
|
|
{
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
if ((ptCur.x > 50) && (ptCur.y > 50))
|
|
{
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex <= (iRecCount-1); iRecIndex++)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
// viewDC.DPtoLP(&ptCur);
|
|
|
|
if ((NULL != pSptRecord) && (pSptRecord->PtInRegion(ptCur)))
|
|
{
|
|
viewDC.SetBkMode(TRANSPARENT);
|
|
|
|
// MessageBox(str);
|
|
|
|
if (TRUE == pSptRecord->m_bIsSel)
|
|
{
|
|
BshPt.CreateSolidBrush(RGB(150, 255, 255));
|
|
pSptRecord->m_iN = (int)VAL_ONE;
|
|
pSptRecord->m_colorREF = RGB(150, 255, 255);
|
|
pSptRecord->m_bIsSel = FALSE;
|
|
}
|
|
else
|
|
{
|
|
BshPt.CreateSolidBrush(RGB(0, 255, 0));
|
|
pSptRecord->m_colorREF = RGB(0, 255, 0);
|
|
pSptRecord->m_bIsSel = TRUE;
|
|
}
|
|
pOldBshPt = viewDC.SelectObject(&BshPt);
|
|
|
|
ftPt.CreatePointFont(20+10*m_iMul, _T("Tahoma"));
|
|
pOldFtPt = viewDC.SelectObject(&ftPt);
|
|
|
|
viewDC.Ellipse(pSptRecord->m_recPtArea);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), pSptRecord->m_iTsn);
|
|
viewDC.DrawText(szLabel, pSptRecord->m_recPtArea, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
viewDC.SelectObject(pOldBshPt);
|
|
viewDC.SelectObject(pOldFtPt);
|
|
return pSptRecord;
|
|
}
|
|
// ptCur = point;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void COpCreateSptView::OnLButtonUp(UINT nFlags, CPoint point)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
CClientDC viewDC(this);
|
|
//如果不需要画剖面图的话,则屏蔽相应的鼠标按键消息
|
|
if (!m_bIsDraw)
|
|
{
|
|
CScrollView::OnLButtonUp(nFlags, point);
|
|
return;
|
|
}
|
|
|
|
if (TRUE == m_bIsStartRect)
|
|
{
|
|
if (m_startPoint != point)
|
|
{
|
|
m_bIsStartRect = FALSE;
|
|
|
|
viewDC.SetROP2(R2_NOT);
|
|
viewDC.SelectStockObject(NULL_BRUSH);
|
|
|
|
viewDC.Rectangle(CRect(m_startPoint, m_oldPoint));
|
|
// viewDC.DrawFocusRect(CRect(m_startPoint, m_oldPoint));
|
|
this->m_endPoint = point;
|
|
|
|
SelectByRect(m_startPoint, m_endPoint);
|
|
}
|
|
ReleaseCapture();
|
|
}
|
|
|
|
CScrollView::OnLButtonUp(nFlags, point);
|
|
}
|
|
|
|
void COpCreateSptView::OnMouseMove(UINT nFlags, CPoint point)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
CClientDC viewDC(this);
|
|
|
|
CRect rectView;
|
|
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
CSptRecord* pSptRecord = NULL;
|
|
|
|
CPoint ptCur = point;
|
|
|
|
int iItem = (int)VAL_ZERO;
|
|
// POSITION posRec;
|
|
|
|
if ((TRUE == m_bIsStartRect) && (MK_LBUTTON == nFlags))
|
|
{
|
|
viewDC.SetROP2(R2_NOT);
|
|
viewDC.SelectStockObject(NULL_BRUSH);
|
|
|
|
viewDC.Rectangle(CRect(m_startPoint,m_oldPoint));
|
|
// viewDC.DrawFocusRect(CRect(m_startPoint,m_oldPoint));
|
|
|
|
this->GetClientRect(&rectView);
|
|
|
|
if (point.y > rectView.bottom)
|
|
{
|
|
point.y = rectView.bottom;
|
|
}
|
|
|
|
if (point.x > rectView.right)
|
|
{
|
|
point.x = rectView.right;
|
|
}
|
|
|
|
if (point.x < 0)
|
|
{
|
|
point.x = 0;
|
|
}
|
|
|
|
if (point.y < 0)
|
|
{
|
|
point.y = 0;
|
|
}
|
|
|
|
viewDC.Rectangle(CRect(m_startPoint,point));
|
|
// viewDC.DrawFocusRect(CRect(m_startPoint,point));
|
|
|
|
m_oldPoint = point;
|
|
}
|
|
|
|
/*
|
|
if (NULL != m_pNewChannel) //选出当前记录点
|
|
{
|
|
|
|
// posRec = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().GetFirstSelectedItemPosition();
|
|
// iItem = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().GetNextSelectedItem(posRec);
|
|
|
|
// if (iItem != (int)VAL_MINUS_ONE)
|
|
// {
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemState((int)iItem, 0, LVIS_SELECTED | LVIS_FOCUSED); //取消当前所选记录
|
|
// }
|
|
|
|
viewDC.SetViewportOrg(-(GetScrollPos(SB_HORZ)), -(GetScrollPos(SB_VERT)));
|
|
viewDC.DPtoLP(&ptCur);
|
|
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
if ((ptCur.x > 50) && (ptCur.y > 50))
|
|
{
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex <= (iRecCount-1); iRecIndex++)
|
|
{
|
|
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
// viewDC.DPtoLP(&ptCur);
|
|
|
|
if ((NULL != pSptRecord) && (pSptRecord->PtInRegion(ptCur)))
|
|
{
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->m_pCurSptRecord = pSptRecord;
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->Invalidate();
|
|
|
|
return;
|
|
}
|
|
// ptCur = point;
|
|
}
|
|
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->m_pCurSptRecord = NULL;
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->Invalidate();
|
|
}
|
|
}
|
|
*/
|
|
|
|
CScrollView::OnMouseMove(nFlags, point);
|
|
}
|
|
|
|
int COpCreateSptView::SelectByRect(CPoint startPoint, CPoint endPoint)
|
|
{
|
|
LVFINDINFO info;
|
|
|
|
CClientDC viewDC(this);
|
|
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
int iRecSelCount = (int)VAL_ZERO;
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
int iXY = (int)VAL_ZERO;
|
|
|
|
CString szLabel = _T("");
|
|
CSptRecord* pSptRecord = NULL;
|
|
|
|
CPoint ptStartCur = startPoint;
|
|
CPoint ptEndCur = endPoint;
|
|
|
|
CBrush BshPt;
|
|
CBrush* pOldBshPt = NULL;
|
|
|
|
CFont ftPt;
|
|
CFont* pOldFtPt = NULL;
|
|
|
|
viewDC.SetViewportOrg(-(GetScrollPos(SB_HORZ)), -(GetScrollPos(SB_VERT)));
|
|
viewDC.DPtoLP(&ptStartCur);
|
|
viewDC.DPtoLP(&ptEndCur);
|
|
|
|
if ((ptStartCur.x > ptEndCur.x) && (ptStartCur.y < ptEndCur.y))
|
|
{
|
|
iXY = ptStartCur.x;
|
|
ptStartCur.x = ptEndCur.x;
|
|
ptEndCur.x = iXY;
|
|
}
|
|
else if ((ptStartCur.x < ptEndCur.x) && (ptStartCur.y > ptEndCur.y))
|
|
{
|
|
iXY = ptStartCur.y;
|
|
ptStartCur.y = ptEndCur.y;
|
|
ptEndCur.y = iXY;
|
|
}
|
|
else if ((ptStartCur.x > ptEndCur.x) && (ptStartCur.y > ptEndCur.y))
|
|
{
|
|
iXY = ptStartCur.x;
|
|
ptStartCur.x = ptEndCur.x;
|
|
ptEndCur.x = iXY;
|
|
|
|
iXY = ptStartCur.y;
|
|
ptStartCur.y = ptEndCur.y;
|
|
ptEndCur.y = iXY;
|
|
|
|
}
|
|
|
|
if (NULL != m_pNewChannel)
|
|
{
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex <= (iRecCount-1); iRecIndex++)
|
|
{
|
|
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
if ((NULL != pSptRecord) && (pSptRecord->m_fPtCenterX >= ptStartCur.x) && (pSptRecord->m_fPtCenterY >= ptStartCur.y) && (pSptRecord->m_fPtCenterX <= ptEndCur.x) && (pSptRecord->m_fPtCenterY <= ptEndCur.y))
|
|
{
|
|
viewDC.SetBkMode(TRANSPARENT);
|
|
|
|
if (TRUE == pSptRecord->m_bIsSel)
|
|
{
|
|
BshPt.CreateSolidBrush(RGB(150, 255, 255));
|
|
pSptRecord->m_iN = (int)VAL_ONE;
|
|
pSptRecord->m_colorREF = RGB(150, 255, 255);
|
|
pSptRecord->m_bIsSel = FALSE;
|
|
}
|
|
else
|
|
{
|
|
BshPt.CreateSolidBrush(RGB(0, 255, 0));
|
|
pSptRecord->m_colorREF = RGB(0, 255, 0);
|
|
pSptRecord->m_bIsSel = TRUE;
|
|
}
|
|
pOldBshPt = viewDC.SelectObject(&BshPt);
|
|
|
|
ftPt.CreatePointFont(20+10*m_iMul, _T("Tahoma"));
|
|
pOldFtPt = viewDC.SelectObject(&ftPt);
|
|
|
|
viewDC.Ellipse(pSptRecord->m_recPtArea);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), pSptRecord->m_iTsn);
|
|
viewDC.DrawText(szLabel, pSptRecord->m_recPtArea, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
viewDC.SelectObject(pOldBshPt);
|
|
viewDC.SelectObject(pOldFtPt);
|
|
|
|
BshPt.DeleteObject();
|
|
ftPt.DeleteObject();
|
|
|
|
if (NULL != ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView)
|
|
{
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)pSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetCheck(iIndex, pSptRecord->m_bIsSel);
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetHotItem(iIndex);
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().EnsureVisible(iIndex, TRUE);
|
|
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemState(iIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), pSptRecord->m_iN);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iIndex, 6, szLabel);
|
|
}
|
|
}
|
|
|
|
iRecSelCount++;
|
|
}
|
|
}
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetHotItem(iIndex);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().EnsureVisible(iIndex, TRUE);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemState(iIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetFocus();
|
|
|
|
}
|
|
}
|
|
|
|
return iRecSelCount;
|
|
}
|
|
|
|
void COpCreateSptView::OnRButtonDown(UINT nFlags, CPoint point)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
//主机暂不支持多次迭代,故注释此代码,需要时打开
|
|
|
|
//如果不需要画剖面图的话,则屏蔽相应的鼠标按键消息
|
|
if (!m_bIsDraw)
|
|
{
|
|
CScrollView::OnRButtonDown(nFlags, point);
|
|
return;
|
|
}
|
|
|
|
CMenu gnMenu;
|
|
CMenu* pPopGnMenu = NULL;
|
|
LVFINDINFO info;
|
|
|
|
CClientDC viewDC(this);
|
|
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
CString szLabel = _T("");
|
|
CSptRecord* pSptRecord = NULL;
|
|
|
|
CPoint ptCur = point;
|
|
|
|
viewDC.SetViewportOrg(-(GetScrollPos(SB_HORZ)), -(GetScrollPos(SB_VERT)));
|
|
viewDC.DPtoLP(&ptCur);
|
|
|
|
if (NULL != m_pNewChannel)
|
|
{
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
if ((ptCur.x > 50) && (ptCur.y > 50))
|
|
{
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex < iRecCount; iRecIndex++)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
if ((NULL != pSptRecord) && (pSptRecord->PtInRegion(ptCur)))
|
|
{
|
|
if (TRUE == pSptRecord->m_bIsSel)
|
|
{
|
|
m_pCurSptRecord = pSptRecord;
|
|
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)m_pCurSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetHotItem(iIndex);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().EnsureVisible(iIndex, TRUE);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemState(iIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
|
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->m_pCurSptRecord = m_pCurSptRecord;
|
|
// ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->Invalidate();
|
|
}
|
|
|
|
gnMenu.LoadMenu(IDR_GN);
|
|
pPopGnMenu = gnMenu.GetSubMenu(0);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
pPopGnMenu->ModifyMenu(0, MF_BYPOSITION, IDM_OP_SPT_TP_GN, _T("修改迭代数"));
|
|
else
|
|
pPopGnMenu->ModifyMenu(0, MF_BYPOSITION, IDM_OP_SPT_TP_GN, _T("modify stacking"));
|
|
this->ClientToScreen(&point);
|
|
pPopGnMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CScrollView::OnRButtonDown(nFlags, point);
|
|
}
|
|
|
|
void COpCreateSptView::OnOpSptTpGn()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
COpCreateSptGNDlg opCreateSptGNDlg;
|
|
|
|
INT_PTR nRet = -1;
|
|
|
|
if (NULL != m_pCurSptRecord)
|
|
{
|
|
opCreateSptGNDlg.m_iN = m_pCurSptRecord->m_iN-1;
|
|
opCreateSptGNDlg.m_iCurLevel = m_pCurSptRecord->m_iLevel;
|
|
opCreateSptGNDlg.m_iMaxLevel = m_pNewChannel->m_iMaxLevel;
|
|
|
|
if (IDOK == opCreateSptGNDlg.DoModal())
|
|
{
|
|
switch (opCreateSptGNDlg.m_iEf)
|
|
{
|
|
case 0:
|
|
SetNToPoint(opCreateSptGNDlg.m_iN);
|
|
break;
|
|
case 1:
|
|
SetNToLevel(opCreateSptGNDlg.m_iN);
|
|
break;
|
|
case 2:
|
|
SetNUnderCurLevel(opCreateSptGNDlg.m_iN);
|
|
break;
|
|
case 3:
|
|
SetNToSelLevel(opCreateSptGNDlg.m_iN, opCreateSptGNDlg.m_iSelLevel);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
m_pCurSptRecord = NULL;
|
|
}
|
|
}
|
|
|
|
void COpCreateSptView::SetNToPoint(int iN)
|
|
{
|
|
CString szLabel = _T("");
|
|
LVFINDINFO info;
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
m_pCurSptRecord->m_iN = iN;
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)m_pCurSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), iN);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iIndex, 6, szLabel);
|
|
}
|
|
|
|
}
|
|
|
|
void COpCreateSptView::SetNToLevel(int iN)
|
|
{
|
|
CSptRecord* pSptRecord = NULL;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
LVFINDINFO info;
|
|
CString szLabel = _T("");
|
|
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex < iRecCount; iRecIndex++)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
if ((TRUE == pSptRecord->m_bIsSel) && (pSptRecord->m_iLevel == m_pCurSptRecord->m_iLevel))
|
|
{
|
|
pSptRecord->m_iN = iN;
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)pSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), iN);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iIndex, 6, szLabel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void COpCreateSptView::SetNUnderCurLevel(int iN)
|
|
{
|
|
CSptRecord* pSptRecord = NULL;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
LVFINDINFO info;
|
|
CString szLabel = _T("");
|
|
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex < iRecCount; iRecIndex++)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
if ((TRUE == pSptRecord->m_bIsSel) && (pSptRecord->m_iLevel >= m_pCurSptRecord->m_iLevel))
|
|
{
|
|
pSptRecord->m_iN = iN;
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)pSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), iN);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iIndex, 6, szLabel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void COpCreateSptView::SetNToSelLevel(int iN, int iSelLevel)
|
|
{
|
|
CSptRecord* pSptRecord = NULL;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
int iRecCount = (int)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
LVFINDINFO info;
|
|
CString szLabel = _T("");
|
|
|
|
iRecCount = m_pNewChannel->m_sptRecArray.GetSize();
|
|
|
|
for (iRecIndex = (int)VAL_ZERO; iRecIndex < iRecCount; iRecIndex++)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
if ((TRUE == pSptRecord->m_bIsSel) && (pSptRecord->m_iLevel >= m_pCurSptRecord->m_iLevel) && (pSptRecord->m_iLevel <= iSelLevel))
|
|
{
|
|
pSptRecord->m_iN = iN;
|
|
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
|
info.lParam = (long)pSptRecord;
|
|
|
|
iIndex = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
|
|
|
|
if (iIndex != (int)VAL_MINUS_ONE)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), iN);
|
|
((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iIndex, 6, szLabel);
|
|
}
|
|
}
|
|
}
|
|
}
|