📄 diode.cpp
字号:
// Diode.cpp: implementation of the CDiode class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Pointtest.h"
#include "Diode.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDiode::CDiode(int nType,CBaseList* pBaseList) : CBase(ID_DIODE,pBaseList)
{
left = CPoint(0,0);
right = CPoint(0,0);
Content_Of_Ob = "D";
AddString(ID_DIODE);
Value = 1;
}
CDiode::CDiode(CBase* pp1,CBase* pp2,CBaseList* pBaseList) : CBase(ID_DIODE,pBaseList)
{
p1 = pp1;
p2 = pp2;
AddSon(p1);
AddSon(p2);
left = CPoint(0,0);
right = CPoint(0,0);
Content_Of_Ob = "D";
AddString(ID_DIODE);
Value = 1;
}
CDiode::~CDiode()
{
}
void CDiode::Draw(CDC* pDC)
{
CPoint Three_Point[3];
Three_Point[0] = aa;
Three_Point[1] = bb;
Three_Point[2] = right;
if(IsSelected()){
CPen pen(PS_SOLID, 2,RED);
CPen *Oldpen = pDC->SelectObject(&pen);
CBrush brush(RED);
CBrush* oldBrush = pDC->SelectObject(&brush);
pDC->MoveTo(left);
pDC->LineTo(p1->CenterPoint);
pDC->MoveTo(right);
pDC->LineTo(p2->CenterPoint);
pDC->Polygon(Three_Point,3);
pDC->MoveTo(cc);
pDC->LineTo(dd);
pDC->SelectObject(oldBrush);
pDC->SelectObject(Oldpen);
}else{
CBrush brush(BLACK);
CBrush* oldBrush = pDC->SelectObject(&brush);
pDC->Polygon(Three_Point,3);
CPen pen(PS_SOLID, 2,BLACK);
CPen *Oldpen = pDC->SelectObject(&pen);
pDC->MoveTo(left);
pDC->LineTo(p1->CenterPoint);
pDC->MoveTo(right);
pDC->LineTo(p2->CenterPoint);
//pDC->Polygon(Three_Point,3);
pDC->MoveTo(cc);
pDC->LineTo(dd);
pDC->SelectObject(oldBrush);
pDC->SelectObject(Oldpen);
}
TextOut(pDC);
}
void CDiode::SetPoint(CPoint pp)
{
left = right = CenterPoint = pp;
left.Offset(CSize(-5,0));// = pp - CPoint(5,0);
right.Offset(CSize(5,0));// = pp + CPoint(5,0);
p1->CenterPoint = pp - CPoint(15,0);
p2->CenterPoint = pp + CPoint(14,0);
aa = bb = left;
cc = dd = right;
aa.Offset(CSize(0,-10));
bb.Offset(CSize(0,10));
cc.Offset(CSize(0,-10));
dd.Offset(CSize(0,10));
RotateCell(TotalAngle);
}
void CDiode::OffSet(CSize size)
{
CenterPoint.Offset(size);
left.Offset(size);
right.Offset(size);
p1->OffSet(size);
p2->OffSet(size);
aa.Offset(size);
bb.Offset(size);
cc.Offset(size);
dd.Offset(size);
}
CRect CDiode::GetGraphRect()
{
CPoint up_left,down_right;
up_left = down_right = CenterPoint;
up_left.Offset(-5,-5);
down_right.Offset(5,5);
return CRect(up_left,down_right);
}
void CDiode::RotateCell(double angle)
{
left = Rotate(angle,left);
right = Rotate(angle,right);
p1->CenterPoint = Rotate(angle,p1->CenterPoint);
p2->CenterPoint = Rotate(angle,p2->CenterPoint);
aa = Rotate(angle,aa);
bb = Rotate(angle,bb);
cc = Rotate(angle,cc);
dd = Rotate(angle,dd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -