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.

100 lines
1.9 KiB
C++

#include "StdAfx.h"
#include "DataPoint.h"
#include "GlobalDrawMgr.h"
#include "GlobalFunction.h"
CDataPoint::CDataPoint(Dbxy _pt)
{
m_bIsNode = false;//是否为节点
m_pt = _pt;
}
CDataPoint::CDataPoint()
{
m_bIsNode = false;//是否为节点
}
CDataPoint::~CDataPoint(void)
{
}
//返回绘制用的屏幕坐标
CPoint CDataPoint::GetDevicePt()
{
return gDraw->Dbxy2CPoint(m_pt);
}
#if 1
//根据操作类型来分发参数
void CDataPoint::Operate(SObjOperatePar &par)
{
switch(par.OpType)
{
case _OP_MOVE:
Move(par.MoveX,par.MoveY);
break;
case _OP_MIRROR:
Mirror(par.BasePt,par.xy);
break;
case _OP_ROTATO:
Rotato(par.BasePt,_360ToAngle(par.Angle));
break;
case _OP_STRETCH:
Stretch(par.BasePt,par.OldSize,par.Diff,par.xy);
break;
default:
break;
}
}
//移动
void CDataPoint::Move(double MoveX,double MoveY)
{
m_pt.x = m_pt.x+MoveX;
m_pt.y = m_pt.y+MoveY;
}
//拉伸
//BasePt 拉伸基准点
//Size 拉伸前的尺寸
//Diff 是旧尺寸和新尺寸的差
void CDataPoint::Stretch(Dbxy BasePt,double Size,double Diff,X_OR_Y xy)
{
if(Diff == 0)
return;
if(xy == _X)
{
m_pt.x = m_pt.x+Diff*((m_pt.x-BasePt.x)/Size);
}
else
{
m_pt.y = m_pt.y+Diff*((m_pt.y-BasePt.y)/Size);
}
}
//pt 为镜像基准点
void CDataPoint::Mirror(Dbxy pt,X_OR_Y xy)
{
if(xy == _X)
{
m_pt.x = m_pt.x+(pt.x-m_pt.x)*2;
}
else
{
m_pt.y = m_pt.y+(pt.y-m_pt.y)*2;
}
}
//Angle : 弧度角pt : 旋转中心点
void CDataPoint::Rotato(Dbxy pt,double Angle)
{
m_pt = RotatoPt(m_pt,Angle,pt);
}
#endif
bool CDataPoint::Equal(CDataPoint &pt)
{
return pt.GetPt().Equal(m_pt);
}
//判断两条线段是否连续
bool DbLine::IsSerialLine(DbLine &line)
{
if(m_pt1.Equal(line.m_pt1)||m_pt1.Equal(line.m_pt2)
||m_pt2.Equal(line.m_pt1)||m_pt2.Equal(line.m_pt2))
{
return true;
}
return false;
}