|
|
#include "StdAfx.h"
|
|
|
#include "itempointadd.h"
|
|
|
#include "SigmaDoc.h"
|
|
|
#include "SigmaView.h"
|
|
|
#include "DCHelp.h"
|
|
|
|
|
|
static CPointNameEx * CreatePoint(double x, double y, double z, double angle, const char * pointName);
|
|
|
static CPointTwoName * CreateFractionPoint(double x, double y, double angle, const char * numeratorStr, const char * denominatorStr);
|
|
|
|
|
|
CItemPointAdd::CItemPointAdd(CSigmaDoc * ppDoc)
|
|
|
: CItem(ppDoc)
|
|
|
, m_pCurOne(0)
|
|
|
, m_mode(POINT_MODE_SINGLE)
|
|
|
, m_z(-1E101)
|
|
|
, m_angle(0)
|
|
|
{
|
|
|
this->SetType(ITEM_POINT);
|
|
|
}
|
|
|
|
|
|
CItemPointAdd::~CItemPointAdd(void)
|
|
|
{
|
|
|
ClearDisplayPoint();
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::OnDraw(CXyDC* pDC)
|
|
|
{
|
|
|
if (m_pCurOne)
|
|
|
m_pCurOne->Draw(*pDC);
|
|
|
}
|
|
|
bool CItemPointAdd::CreateMemDC(CMemoryDC* pMemDC, CRect rect, CDC* pDC)
|
|
|
{
|
|
|
if (pMemDC == NULL)
|
|
|
{
|
|
|
pMemDC = new CMemoryDC;
|
|
|
pMemDC->Create(CSize(rect.Width(), rect.Height()), 0, pDC);
|
|
|
}
|
|
|
else if (pMemDC->GetSize() != rect.Size())
|
|
|
{
|
|
|
pMemDC->Empty();
|
|
|
pMemDC->Create(CSize(rect.Width(), rect.Height()));
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
void CItemPointAdd::UpdateDraw()
|
|
|
{
|
|
|
CRect rect = m_client;
|
|
|
CDC* pDC = m_pScreenDC;
|
|
|
DCHelp::ClearDC(pDC, m_BackColor);
|
|
|
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), m_pBackGroundDC, 0, 0, SRCCOPY);
|
|
|
GetDC()->Create(pDC);
|
|
|
if (m_pCurOne)
|
|
|
{
|
|
|
UpdateOne(m_pCurOne);
|
|
|
}
|
|
|
else {
|
|
|
m_pCurOne = CreateOne();
|
|
|
}
|
|
|
m_pCurOne->Draw(*GetDC());
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::FillBackGround(CDC* pDes, CDC* pSrc, CRect rect)
|
|
|
{
|
|
|
int indexX = 0, indexY = 0;
|
|
|
int nWidth = rect.Width();
|
|
|
int nHeight = rect.Height();
|
|
|
for (int y = 0; y < nHeight; ++y)
|
|
|
{
|
|
|
for (int x = 0; x < nWidth; ++x)
|
|
|
{
|
|
|
indexX = rect.left + x; indexY = rect.top + y;
|
|
|
pDes->SetPixel(indexX, indexY, pSrc->GetPixel(indexX, indexY));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
void CItemPointAdd::UpdateOne(COne* pOne)
|
|
|
{
|
|
|
if (m_type == POINT_TYPE_COMMON)
|
|
|
{
|
|
|
CPointNameEx* pPoint = (CPointNameEx*)pOne->GetValue();
|
|
|
pPoint->x0 = m_pt.x0;
|
|
|
pPoint->y0 = m_pt.y0;
|
|
|
pPoint->z0 = m_pt.z0;
|
|
|
pPoint->angle = m_angle;
|
|
|
pPoint->SetName(m_pointName);
|
|
|
}
|
|
|
else if (m_type == POINT_TYPE_FRACTIOIN)
|
|
|
{
|
|
|
CPointTwoName* pPoint = (CPointTwoName*)pOne->GetValue();
|
|
|
pPoint->x0 = m_pt.x0;
|
|
|
pPoint->y0 = m_pt.y0;
|
|
|
pPoint->z0 = m_pt.z0;
|
|
|
pPoint->angle = m_angle;
|
|
|
pPoint->m_name1.SetName(m_numeratorString);
|
|
|
pPoint->m_name2.SetName(m_denominatorString);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::DrawAssistant(CDC * pDC, int mouseX, int mouseY)
|
|
|
{
|
|
|
if (m_pCurOne)
|
|
|
{
|
|
|
GetDC()->Create(pDC);
|
|
|
m_pCurOne->Draw(*GetDC());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
|
{
|
|
|
CPoint3D pt3D;
|
|
|
pt3D.x0 = point.x;
|
|
|
pt3D.y0 = point.y;
|
|
|
pt3D.z0 = m_z;
|
|
|
//m_pointName = _T("Point");
|
|
|
SetPoint(pt3D);
|
|
|
//GetDC()->Create(pDC);
|
|
|
SetScreenDC(pDC);
|
|
|
//this->m_pMemDC = GetView()->m_pImgDC;
|
|
|
if (m_mode == POINT_MODE_SINGLE)
|
|
|
{
|
|
|
//DrawSinglePoint(point);
|
|
|
UpdateDraw();
|
|
|
}
|
|
|
else //POINT_CONTINUE
|
|
|
{
|
|
|
//OnBnClickedButtonPointNext();
|
|
|
AddPoint(pt3D);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::ClearDisplayPoint(void)
|
|
|
{
|
|
|
m_pt.x0 = m_pt.y0 = m_pt.z0 = 0.0;
|
|
|
m_angle = 0;
|
|
|
m_z = -1E101;
|
|
|
m_pointName.Empty();
|
|
|
m_numeratorString.Empty();
|
|
|
m_denominatorString.Empty();
|
|
|
|
|
|
if (m_pCurOne == NULL)
|
|
|
return ;
|
|
|
|
|
|
delete m_pCurOne;
|
|
|
m_pCurOne = NULL;
|
|
|
}
|
|
|
|
|
|
bool CItemPointAdd::GetPoint(double * xOut, double * yOut, double * zOut)
|
|
|
{
|
|
|
*xOut = m_pt.x0;
|
|
|
*yOut = m_pt.y0;
|
|
|
*zOut = m_pt.z0;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::SetMode(POINT_MODE mode)
|
|
|
{
|
|
|
m_mode = mode;
|
|
|
if (m_mode == POINT_MODE_CONTINUE)
|
|
|
{
|
|
|
if (m_pCurOne)
|
|
|
{
|
|
|
CPointNameEx* pPoint = (CPointNameEx*)m_pCurOne->GetValue();
|
|
|
COne* pOne = nullptr;
|
|
|
if (m_type == POINT_TYPE_COMMON)
|
|
|
{
|
|
|
CPointNameEx * ptNameEx = CreatePoint(pPoint->x0, pPoint->y0, pPoint->z0, pPoint->angle, pPoint->GetName());
|
|
|
AddElement(ptNameEx, DOUBLEFOX_POINT);
|
|
|
|
|
|
CPointNameEx * ptTmp = CreatePoint(pPoint->x0, pPoint->y0, pPoint->z0, pPoint->angle, pPoint->GetName());
|
|
|
pOne = m_pDoc->GetDraw()->CreateOne(ptTmp, DOUBLEFOX_POINT);
|
|
|
}
|
|
|
else if (m_type == POINT_TYPE_FRACTIOIN) {
|
|
|
CPointTwoName * ptFraction = CreateFractionPoint(pPoint->x0, pPoint->y0, m_angle, m_numeratorString, m_denominatorString);
|
|
|
AddElement(ptFraction, DOUBLEFOX_TWOPOINT);
|
|
|
|
|
|
CPointNameEx * ptTmp = CreateFractionPoint(pPoint->x0, pPoint->y0, m_angle, m_numeratorString, m_denominatorString);
|
|
|
pOne = m_pDoc->GetDraw()->CreateOne(ptTmp, DOUBLEFOX_TWOPOINT);
|
|
|
}
|
|
|
|
|
|
CDC* pDC = m_pScreenDC;
|
|
|
GetDC()->Create(pDC);
|
|
|
pOne->Draw(*GetDC());
|
|
|
|
|
|
m_pDoc->GetDraw()->RemoveAt(pOne);
|
|
|
if (pOne != nullptr) {
|
|
|
delete pOne;
|
|
|
pOne = nullptr;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/************************************************************************/
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
/************************************************************************/
|
|
|
void CItemPointAdd::SetPointName(CDC* pDC, LPCTSTR pointName)
|
|
|
{
|
|
|
//SetScreenDC(pDC);
|
|
|
m_pointName = pointName;
|
|
|
//UpdateDraw();
|
|
|
}
|
|
|
void CItemPointAdd::SetPointDefaultName(LPCTSTR pointName)
|
|
|
{
|
|
|
m_pointName = pointName;
|
|
|
}
|
|
|
void CItemPointAdd::SetPointDefaultZ(double pointZ)
|
|
|
{
|
|
|
m_z = pointZ;
|
|
|
}
|
|
|
/************************************************************************/
|
|
|
/* <20><><EFBFBD>ýǶ<C3BD> */
|
|
|
/************************************************************************/
|
|
|
void CItemPointAdd::SetPointAngle(CDC* pDC, double angle)
|
|
|
{
|
|
|
SetScreenDC(pDC);
|
|
|
m_angle = angle;
|
|
|
UpdateDraw();
|
|
|
}
|
|
|
/************************************************************************/
|
|
|
/* <20><><EFBFBD><EFBFBD>X */
|
|
|
/************************************************************************/
|
|
|
void CItemPointAdd::SetPointX(CDC* pDC, double x)
|
|
|
{
|
|
|
//GetDC()->Create(pDC);
|
|
|
SetScreenDC(pDC);
|
|
|
m_pt.x0 = x;
|
|
|
UpdateDraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
/************************************************************************/
|
|
|
/* <20><><EFBFBD><EFBFBD>X */
|
|
|
/************************************************************************/
|
|
|
void CItemPointAdd::SetPointY(CDC* pDC, double y)
|
|
|
{
|
|
|
//GetDC()->Create(pDC);
|
|
|
SetScreenDC(pDC);
|
|
|
m_pt.y0 = y;
|
|
|
UpdateDraw();
|
|
|
//ChangeAngleOrNameOfCOne();
|
|
|
}
|
|
|
void CItemPointAdd::SetPointZ(CDC* pDC, double z)
|
|
|
{
|
|
|
m_pt.z0 = z;
|
|
|
}
|
|
|
void CItemPointAdd::ChangeAngle(double angle)
|
|
|
{
|
|
|
m_angle = angle;
|
|
|
|
|
|
//<2F>û<EFBFBD><C3BB>ڻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ʰȡ<CAB0><C8A1><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>㣬<EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD>иı<D0B8><C4B1>˽Ƕ<CBBD>ֵ<EFBFBD><D6B5>
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF>
|
|
|
ChangeAngleOrNameOfCOne();
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::SetPointType(POINT_TYPE type)
|
|
|
{
|
|
|
m_type = type;
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::SetNumeratorString(CDC* pDC, LPCTSTR numeratorStr)
|
|
|
{
|
|
|
//SetScreenDC(pDC);
|
|
|
m_numeratorString = numeratorStr;
|
|
|
//UpdateDraw();
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::SetDenominatorString(CDC* pDC, LPCTSTR denominatorStr)
|
|
|
{
|
|
|
//SetScreenDC(pDC);
|
|
|
m_denominatorString = denominatorStr;
|
|
|
//UpdateDraw();
|
|
|
}
|
|
|
|
|
|
COne* CItemPointAdd::CreateOne()
|
|
|
{
|
|
|
if (m_type == POINT_TYPE_COMMON)
|
|
|
{
|
|
|
CPointNameEx* pt = new CPointNameEx;
|
|
|
pt->x0 = m_pt.x0;
|
|
|
pt->y0 = m_pt.y0;
|
|
|
pt->z0 = m_z; // m_pt.z0;
|
|
|
pt->angle = m_angle;
|
|
|
pt->SetName(m_pointName);
|
|
|
return m_pDoc->GetDraw()->CreateOne(pt, DOUBLEFOX_POINT);
|
|
|
}
|
|
|
else if (m_type == POINT_TYPE_FRACTIOIN)
|
|
|
{
|
|
|
CPointTwoName* pPoint = new CPointTwoName;
|
|
|
pPoint->x0 = m_pt.x0;
|
|
|
pPoint->y0 = m_pt.y0;
|
|
|
pPoint->z0 = m_z; // m_pt.z0;
|
|
|
pPoint->angle = m_angle;
|
|
|
pPoint->m_name1.SetName(m_numeratorString);
|
|
|
pPoint->m_name2.SetName(m_denominatorString);
|
|
|
|
|
|
return m_pDoc->GetDraw()->CreateOne(pPoint, DOUBLEFOX_TWOPOINT);
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
|
COne* CItemPointAdd::CreateOne(double x, double y, double z)
|
|
|
{
|
|
|
if (m_type == POINT_TYPE_COMMON)
|
|
|
{
|
|
|
CPointNameEx * pt = CreatePoint(x, y, z, m_angle, m_pointName);
|
|
|
return m_pDoc->GetDraw()->CreateOne(pt, DOUBLEFOX_POINT);
|
|
|
}
|
|
|
|
|
|
else if (m_type == POINT_TYPE_FRACTIOIN)
|
|
|
{
|
|
|
return m_pDoc->GetDraw()->CreateOne(GetFractionPoint(), DOUBLEFOX_TWOPOINT);
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::DrawSinglePoint(CPoint3D & point)
|
|
|
{
|
|
|
CPoint2D pt = GetDC()->GetReal((CPoint2D)point); //<2F><><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
m_pt.x0 = pt.x0;
|
|
|
m_pt.y0 = pt.y0;
|
|
|
m_pt.z0 = point.z0;
|
|
|
if (m_pCurOne)
|
|
|
delete m_pCurOne;
|
|
|
|
|
|
m_pCurOne = CreateOne(pt.x0, pt.y0, m_pt.z0);
|
|
|
}
|
|
|
void CItemPointAdd::SetPoint(CPoint3D point)
|
|
|
{
|
|
|
|
|
|
CPoint2D pt = GetDC()->GetReal(point);
|
|
|
m_pt.x0 = pt.x0;
|
|
|
m_pt.y0 = pt.y0;
|
|
|
m_pt.z0 = point.z0;
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::AddPoint(CPoint3D & point)
|
|
|
{
|
|
|
CPoint2D pt = GetDC()->GetReal(point);
|
|
|
m_pt.x0 = pt.x0;
|
|
|
m_pt.y0 = pt.y0;
|
|
|
m_pt.z0 = point.z0;
|
|
|
COne* pOne = nullptr;
|
|
|
|
|
|
if (m_type == POINT_TYPE_COMMON)
|
|
|
{
|
|
|
CPointNameEx * ptNameEx = CreatePoint(pt.x0, pt.y0, m_pt.z0, m_angle, m_pointName);
|
|
|
AddElement(ptNameEx, DOUBLEFOX_POINT);
|
|
|
|
|
|
CPointNameEx * ptTmp = CreatePoint(pt.x0, pt.y0, m_pt.z0, m_angle, m_pointName);
|
|
|
pOne = m_pDoc->GetDraw()->CreateOne(ptTmp, DOUBLEFOX_POINT);
|
|
|
}
|
|
|
else if (m_type == POINT_TYPE_FRACTIOIN) {
|
|
|
CPointTwoName * ptFraction = CreateFractionPoint(pt.x0, pt.y0, m_angle, m_numeratorString, m_denominatorString);
|
|
|
AddElement(ptFraction, DOUBLEFOX_TWOPOINT);
|
|
|
|
|
|
CPointNameEx * ptTmp = CreateFractionPoint(pt.x0, pt.y0, m_angle, m_numeratorString, m_denominatorString);
|
|
|
pOne = m_pDoc->GetDraw()->CreateOne(ptTmp, DOUBLEFOX_TWOPOINT);
|
|
|
}
|
|
|
|
|
|
CDC* pDC = m_pScreenDC;
|
|
|
GetDC()->Create(pDC);
|
|
|
pOne->Draw(*GetDC());
|
|
|
|
|
|
m_pDoc->GetDraw()->RemoveAt(pOne);
|
|
|
if (pOne != nullptr) {
|
|
|
delete pOne;
|
|
|
pOne = nullptr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
CPointTwoName* CItemPointAdd::GetFractionPoint(void)
|
|
|
{
|
|
|
CPointTwoName* pPoint = new CPointTwoName;
|
|
|
pPoint->x0 = 100;
|
|
|
pPoint->y0 = 200;
|
|
|
pPoint->angle = 0;
|
|
|
pPoint->m_name1.SetName(m_numeratorString);
|
|
|
pPoint->m_name2.SetName(m_denominatorString);
|
|
|
return pPoint;
|
|
|
}
|
|
|
|
|
|
void CItemPointAdd::ChangeAngleOrNameOfCOne()
|
|
|
{
|
|
|
if (m_pCurOne == NULL)
|
|
|
return;
|
|
|
|
|
|
delete m_pCurOne;
|
|
|
m_pCurOne = CreateOne(m_pt.x0, m_pt.y0, m_pt.z0);
|
|
|
}
|
|
|
|
|
|
static CPointNameEx * CreatePoint(double x, double y, double z, double angle, const char * pointName)
|
|
|
{
|
|
|
CPointNameEx* pPoint = new CPointNameEx;
|
|
|
pPoint->x0 = x;
|
|
|
pPoint->y0 = y;
|
|
|
pPoint->z0 = z;
|
|
|
pPoint->angle = angle;
|
|
|
pPoint->SetName(pointName);
|
|
|
return pPoint;
|
|
|
}
|
|
|
|
|
|
static CPointTwoName * CreateFractionPoint(double x, double y, double angle, const char * numeratorStr, const char * denominatorStr)
|
|
|
{
|
|
|
CPointTwoName* pPoint = new CPointTwoName;
|
|
|
pPoint->x0 = x;
|
|
|
pPoint->y0 = y;
|
|
|
pPoint->angle = angle;
|
|
|
pPoint->m_name1.SetName(numeratorStr);
|
|
|
pPoint->m_name2.SetName(denominatorStr);
|
|
|
|
|
|
return pPoint;
|
|
|
} |