📄 power.cpp
字号:
// Power.cpp: implementation of the CPower class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DrawChip.h"
#include "Power.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_SERIAL(CPower, CComponent,0)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//##ModelId=3E18E0CC03CB
CPower::CPower()
{
}
//##ModelId=3E18E0CD0014
CPower::~CPower()
{
}
//##ModelId=3E18E0CC038E
void CPower::CopyPowerToStruPower(POWER &Power)
{
lstrcpy(Power.m_strClassType, "Power");
Power.m_color = this->GetColor();
Power.m_iLineWidth = this->GetLineWidth();
Power.m_IsSelected = this->GetIsSelected();
lstrcpy(Power.m_strFirPressure, this->GetFirPressure());
lstrcpy(Power.m_strSecPressure , this->GetSecPressure());
lstrcpy(Power.m_strThrPressure , this->GetThrPressure());
lstrcpy(Power.m_strOutPressure , this->GetOutPressure());
lstrcpy(Power.m_strWorkPressure , this->GetWorkPressure());
Power.m_RotateAngle =this->GetRotateAngle();
lstrcpy(Power.m_strName , this->GetName());
}
//##ModelId=3E18E0CC0360
void CPower::SetFirPressure(CString &FirPressure)
{
m_strFirPressure = FirPressure;
}
//##ModelId=3E18E0CC035E
void CPower::SetSecPressure(CString &SecPressure)
{
m_strSecPressure = SecPressure;
}
//##ModelId=3E18E0CC035C
void CPower::SetThrPressure(CString &ThrPressure)
{
m_strThrPressure = ThrPressure;
}
//##ModelId=3E18E0CC0324
CString CPower::GetFirPressure()
{
return m_strFirPressure;
}
//##ModelId=3E18E0CC0323
CString CPower::GetSecPressure()
{
return m_strSecPressure;
}
//##ModelId=3E18E0CC0322
CString CPower::GetThrPressure()
{
return m_strThrPressure;
}
//##ModelId=3E18E0CC0321
CString CPower::GetOutPressure()
{
return m_strOutPressure;
}
//##ModelId=3E18E0CC0320
CString CPower::GetWorkPressure()
{
return m_strWorkPressure;
}
//##ModelId=3E18E0CC02F2
void CPower::SetOutPressure(CString &OutPressure)
{
m_strOutPressure = OutPressure;
}
//##ModelId=3E18E0CC02F0
void CPower::SetWorkPressure(CString &WorkPressure)
{
m_strWorkPressure = WorkPressure;
}
//##ModelId=3E18E0CC02EE
CString CPower::CalculateName(CObList *pObList)
{
CObList *pNumSer = new CObList;
int max;
char buf[10];
GetNumInNameSer(pObList,pNumSer,&max);
//分析数字序列
for (int i=1;i<=max;i++)
{
if (IsInList(i,pNumSer))
{
}
else
{
break;
}
}
itoa(i,buf,10);
while (pNumSer->GetHeadPosition())
{
delete (int *)pNumSer->RemoveHead();
}
delete pNumSer;
return "P"+ CString(buf);
}
//##ModelId=3E18E0CC02BC
void CPower::Draw(CDC *pDC)
{
/*根据元器件对象的颜色和线宽属性值绘制*/
CString name = this->GetName();
int width = m_Rect.Width() ;
int height = m_Rect.Height() ;
CPen newpen(PS_SOLID,GetLineWidth(),GetColor());
CPen *pOldPen = pDC->SelectObject(&newpen);
pDC->Rectangle ((int)(m_Rect.left),(int)(m_Rect.top),
(int)(m_Rect.left + width),(int)( m_Rect.top + height*0.4));
pDC->MoveTo ((int)(m_Rect.left + width * 0.25) ,(int)(m_Rect.top + height * 0.4));
pDC->LineTo((int)(m_Rect.left + width*0.25) ,(int)(m_Rect.top + height * 0.6));
pDC->MoveTo ((int)(m_Rect.left + width * 0.5) ,(int)(m_Rect.top + height * 0.4));
pDC->LineTo((int)(m_Rect.left + width*0.5) ,(int)(m_Rect.top + height * 0.6));
pDC->MoveTo ((int)(m_Rect.left + width * 0.75) ,(int)(m_Rect.top + height * 0.4));
pDC->LineTo((int)(m_Rect.left + width*0.75) ,(int)(m_Rect.top + height * 0.6));
pDC->SetBkMode(TRANSPARENT);
pDC->TextOut((int)(m_Rect.left + width * 0.3),(int)(m_Rect.top + height*0.6),name);
pDC->SelectObject(pOldPen);
}
//##ModelId=3E18E0CC02B8
void CPower::GetNumInNameSer(CObList *pObList, CObList *pNumSer, int *pMax)
{
*pMax = 0;
POSITION pos = pObList->GetHeadPosition();
CObject *pObject;
CPower *pPower;
CString strName;
CString strLastName;
while (pos != NULL)
{
pObject = pObList->GetAt(pos);
if (pObject->IsKindOf(RUNTIME_CLASS(CPower)))
{
pPower = (CPower*)pObject;
strName = pPower->GetName();
if ((strName.GetAt(0) == 'P') || (strName.GetAt(0) == 'p'))
//如果名称的第一个字母是P或p
{
strLastName = strName.Mid(1);
//判断余下的字符是否数字
if (IsNum(strLastName))
//余下的字符全部都是数字
{
int i;
i = atoi(strLastName);
int *p = new int(i);
pNumSer->AddHead((CObject *)p);
if (i>(*pMax))
{
*pMax = i;
}
}
else
//余下的字符不全是数字
{
//忽略不记
}
}
else
//名称的第一个字母不是R或r
{
}
}
else
{
}
pObList->GetNext(pos);
}
}
//##ModelId=3E18E0CC02B6
void CPower::Serialize(CArchive &ar)
{
CComponent::Serialize(ar);
//需要序列化m_RectLP
if (ar.IsStoring())
{
ar<<m_Rect<<m_RectLP<<m_RectTracker.m_nStyle<<m_strFirPressure<<m_strSecPressure<<m_strThrPressure<<m_strOutPressure<<m_strWorkPressure;
//<<m_RectTracker.m_rect
}
else
{
ar>>m_Rect>>m_RectLP>>m_RectTracker.m_nStyle>>m_strFirPressure>>m_strSecPressure>>m_strThrPressure>>m_strOutPressure>>m_strWorkPressure;
//>>m_RectTracker.m_rect
}
}
//##ModelId=3E18E0CC02B4
CPower::CPower(CPoint *pt)
{
m_Rect.left = pt->x;
m_Rect.top = pt->y;
m_Rect.right = m_Rect.left + 2000; //100;
m_Rect.bottom = m_Rect.top -1000; //+ 60;
m_RectLP = m_Rect;
m_RectTracker.m_rect = m_Rect;
m_RectTracker.m_nStyle = CRectTracker::resizeOutside;
}
//##ModelId=3E18E0CC02B2
CPower::CPower(POWER Power)
{
SetColor(Power.m_color);
SetLineWidth(Power.m_iLineWidth);
SetRotateAngle(Power.m_RotateAngle);
SetName(Power.m_strName);
SetIsSelected(Power.m_IsSelected);
m_strFirPressure = Power.m_strFirPressure;
m_strSecPressure = Power.m_strSecPressure;
m_strThrPressure = Power.m_strThrPressure;
m_strOutPressure = Power.m_strOutPressure;
m_strWorkPressure = Power.m_strWorkPressure;
//m_Rect = CRect(0,0,100,60);
m_Rect = CRect(1000,-1000,3000,-2000);
m_RectLP = m_Rect;
m_RectTracker.m_rect = m_Rect;
m_RectTracker.m_nStyle = CRectTracker::resizeOutside;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -