欢迎来到天天文库
浏览记录
ID:22716918
大小:112.01 KB
页数:18页
时间:2018-10-31
《《电子元器件系统》word版》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、电子元器件系统代码分析一、类的定义与实现1、器件类l器件类定义classCComponent:publicCObject{public:staticCOLORREFm_fillColor;//由类的所有对象共享BOOLIsNum(CStringstr);BOOLIsInList(inti,CObList*pNumList);DECLARE_SERIAL(CComponent)voidSerialize(CArchive&ar);voidSetName(constCString&Name);CStringGetName();virtualvoi
2、dDraw(CDC*pDC);virtualCStringCalculateName(CObList*pList);floatGetRotateAngle();voidSetRotateAngle(floatangle);BOOLGetIsSelected();voidSetIsSelected(BOOLIsSel);intGetLineWidth();voidSetLineWidth(intLWidth);voidSetColor(COLORREFcolor);COLORREFGetColor();CComponent();virtual~
3、CComponent();private:floatm_RotateAngle;BOOLm_IsSelected;intm_iLineWidth;COLORREFm_Color;CStringm_strName;};l器件类实现COLORREFCComponent::m_fillColor=RGB(176,176,176);//在文件范围内初始化CComponent::CComponent(){m_RotateAngle=0;m_IsSelected=FALSE;//m_iLineWidth=4;m_iLineWidth=40;m_Color
4、=RGB(0,0,255);}CComponent::~CComponent(){}COLORREFCComponent::GetColor(){returnm_Color;}voidCComponent::SetColor(COLORREFcolor){m_Color=color;}voidCComponent::SetLineWidth(intLWidth){m_iLineWidth=LWidth;}intCComponent::GetLineWidth(){returnm_iLineWidth;}voidCComponent::SetI
5、sSelected(BOOLIsSel){m_IsSelected=IsSel;}BOOLCComponent::GetIsSelected(){returnm_IsSelected;}voidCComponent::SetRotateAngle(floatangle){m_RotateAngle=angle;}floatCComponent::GetRotateAngle(){returnm_RotateAngle;}CStringCComponent::CalculateName(CObList*pObList){return"器件";}
6、voidCComponent::Draw(CDC*pDC){}CStringCComponent::GetName(){returnm_strName;}voidCComponent::SetName(constCString&Name){m_strName=Name;}voidCComponent::Serialize(CArchive&ar){if(ar.IsStoring()){ar<>m_Color>>m_iLineWi
7、dth>>m_strName>>m_RotateAngle;}}BOOLCComponent::IsInList(inti,CObList*pNumList)//判断数字i是否在链表pNumList中{POSITIONpos=pNumList->GetHeadPosition();CObject*pObject;int*p;while(pos!=NULL){pObject=pNumList->GetAt(pos);p=(int*)pObject;if(i==(*p)){returnTRUE;}pNumList->GetNext(pos);}r
8、eturnFALSE;}BOOLCComponent::IsNum(CStringstr)//判断一个字符串是否是数字,在各个派生类的CalculateName函数
此文档下载收益归作者所有