// JointList.cpp: implementation of the CJointList class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "pointtest.h"
#include "JointList.h"
#include "Component.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CJointList::CJointList()
{
m_pOldList=&m_pListJoint;
m_pCopyList=&m_copyListJoint;
m_pSaveList=&m_saveListJoint;
m_pSaveRealList = & m_saveRealList;
}
CJointList::~CJointList()
{
RemoveElList(&(m_pDiodeList));
RemoveAll(m_pOldList);
RemoveAll(m_pSaveList);
RemoveAll(m_pSaveRealList);
RemoveAll(m_pCopyList);
RemoveElList(&(m_VoltList));
RemoveElList(&(m_AmperList));
}
void CJointList::ClearUpAllList()
{
RemoveElList(&(m_pDiodeList));
RemoveAll(m_pOldList);
RemoveAll(m_pSaveList);
RemoveAll(m_pSaveRealList);
RemoveAll(m_pCopyList);
RemoveElList(&(m_VoltList));
RemoveElList(&(m_AmperList));
}
void CJointList::AddJoint(JointList *p,int order)
{
BOOL b;
POSITION pos;
if(p->IsEmpty())
{
b=false;
}
else
{
pos=p->GetHeadPosition();
while(pos!=NULL)
{
if((p->GetNext(pos))->GetOrder()==order)
{
b=true;
break;
}
else
{
b=false;
}
}
}
if(!b)
{
CAJoint *pJoint=new CAJoint(order);
pJoint->SetVoltage(0);
p->AddTail(pJoint);
}
}
void CJointList::RemoveJoint(CAJoint *pJoint,JointList *pList)
{
POSITION pos=pList->Find(pJoint,NULL);
pJoint=pList->GetAt(pos);
pList->RemoveAt(pos);
if(pJoint)
{
delete pJoint;
}
}
CAJoint* CJointList::GetJoint(int order,JointList *pList)
{
POSITION pos=pList->GetHeadPosition();
CAJoint *p;
while(pos!=NULL)
{
p=pList->GetNext(pos);
if(p->GetOrder()==order)
{
return p;
}
}
return NULL;
}
void CJointList::AdjustJoint(JointList *pList)
{
if(pList->IsEmpty())
{
return;
}
else
{
CAJoint *pJoint;
int i=1;
POSITION pos,sourcePos[10];
pos=pList->GetHeadPosition();
while(pos!=NULL)
{
pJoint=pList->GetAt(pos);
int b=pJoint->GetOrder();
// pJoint->SearchElecSource();
if(pJoint->IsHoldElecSource())
{
sourcePos[i]=pos;
i++;
}
pList->GetNext(pos);
}
for(int j=1;j<i;j++)
{
pList->RemoveAt(sourcePos[j]);//Is delete the power joint
}
}
}
void CJointList::CreateCopyJointList(JointList *pSourceList,JointList *pCopyList)
{
RegulateListAsOrder(pSourceList);
SetWorkedInList(false,pSourceList);
RemoveAll(pCopyList);
CAJoint *pJoint;
CAElement *pElement,*pNewElement;
int type;
float value;
BOOL bIsClose;
POSITION pos=pSourceList->GetHeadPosition();
while(pos!=NULL)
{
pJoint=pSourceList->GetNext(pos);
POSITION pos1=pJoint->pElementList.m_pListElement.GetHeadPosition();
while(pos1!=NULL)
{
pElement=pJoint->pElementList.m_pListElement.GetNext(pos1);
if(!(pElement->IsWorked()))
{
type=pElement->GetType();
if(type != ID_SWITCH)
{
value=pElement->GetValue();
pNewElement=NewElement(type,value);
}
else
{
bIsClose = pElement->IsClose();
pNewElement = NewSwitch(bIsClose);
}
CAJoint *p1,*p2;
p1=pElement->GetJointStruct()->pJoint1;
p2=pElement->GetJointStruct()->pJoint2;
int index = pElement->GetIndex();
pNewElement->SetIndex( index );
pNewElement->SetOrderStruct( p1->GetOrder(),p2->GetOrder() );
// p1->pElementList.AddElement(pNewElement);
int order1,order2;
order1=p1->GetOrder();
order2=p2->GetOrder();
AddJoint(pCopyList,order1);
AddJoint(pCopyList,order2);
pNewElement->SetStructJoint(GetJoint(order1,pCopyList),GetJoint(order2,pCopyList));
GetJoint(order1,pCopyList)->pElementList.AddElement(pNewElement);
GetJoint(order2,pCopyList)->pElementList.AddElement(pNewElement);
pElement->SetWorked(true);
}
}
}
RegulateListAsOrder(pCopyList);
}
POSITION CJointList::TwoLoop(POSITION pos,JointList *pList)
{
while(pos!=NULL)
{
CAJoint *pJoint=pList->GetAt(pos);
POSITION pos1=pos;
while(pos1!=NULL)
{
CAJoint *pJointNext=pList->GetAt(pos1);
if(pJoint->GetOrder()>pJointNext->GetOrder())
{
pList->RemoveAt(pos);
pos1=pList->Find(pJointNext,NULL);
pList->InsertAfter(pos1,pJoint);
return pos;
}
pList->GetNext(pos1);
}
pList->GetNext(pos);
}
return pos;
}
void CJointList::RegulateListAsOrder(JointList *pList)
{
POSITION pos;
pos=pList->GetHeadPosition();
while(pos!=NULL)
{
pos=TwoLoop(pos,pList);
if(pos!=NULL)
{
pos=pList->GetHeadPosition();
}
else
{
break;
}
}
}
void CJointList::RemoveAll(JointList *pList)
{
POSITION pos=pList->GetHeadPosition();
while(pos!=NULL)
{
CAJoint *pJoint=pList->GetNext(pos);
POSITION pos1=pJoint->pElementList.m_pListElement.GetHeadPosition();
while(pos1!=NULL)
{
CAElement *pElement=pJoint->pElementList.m_pListElement.GetNext(pos1);
CAJoint *p1,*p2,*pOther;
p1=pElement->GetJointStruct()->pJoint1;
p2=pElement->GetJointStruct()->pJoint2;
if(p1==pJoint)
{
pOther=p2;
}
else
{
pOther=p1;
}
POSITION pos3=pOther->pElementList.m_pListElement.GetHeadPosition();
while(pos3!=NULL)
{
CAElement *pElement1=pOther->pElementList.m_pListElement.GetAt(pos3);
if(pElement1==pElement)
{
pOther->pElementList.m_pListElement.RemoveAt(pos3);
break;
}
pOther->pElementList.m_pListElement.GetNext(pos3);
}
if(pElement)
{
delete pElement;
}
}
pJoint->pElementList.m_pListElement.RemoveAll();
if(pJoint)
{
delete pJoint;
}
}
pList->RemoveAll();
}
CAElement* CJointList::NewElement(int type, float value)
{
switch(type)
{
case ID_POWER:
return (new CAPower(value));
break;
case ID_RESISTANCE:
return (new CAResistance(value));
break;
case ID_CAPACITANCE:
return (new CACapacity(value));
break;
case ID_INDUCTANCE:
return (new CAInductor(value));
break;
// case ID_SWITCH:
// return (new CASwitch(BOOL(value)));
// break;
case ID_DIODE:
return (new CADiode());
break;
case ID_CURRENT_METER:
return (new CAAmpermeter());
break;
case ID_VOLTAGE_METER:
return (new CAVoltmeter());
break;
default:
return NULL;
break;
}
}
void CJointList::SetWorkedInList(BOOL b, JointList *pList)
{
CAJoint *pJoint;
POSITION pos=pList->GetHeadPosition();
while(pos!=NULL)
{
pJoint=pList->GetNext(pos);
CAElement *pElement;
POSITION pos1=pJoint->pElementList.m_pListElement.GetHeadPosition();
while(pos1!=NULL)
{
pElement=pJoint->pElementList.m_pListElement.GetNext(pos1);
pElement->SetWorked(b);
}
}
}
void CJointList::SetAllIsAllPowerInList(BOOL b,JointList *pList)
{
POSITION pos1=pList->GetHeadPosition();
while(pos1!=NULL)
{
CAJoint *pJoint=pList->GetNext(pos1);
CAElement *pElement;
POSITION pos2=pJoint->pElementList.m_pListElement.GetHeadPosition();
while(pos2!=NULL)
{
pElement=pJoint->pElementList.m_pListElement.GetNext(pos2);
pElement->SetIsAsPower(b);
}
}
}
void CJointList::SaveCapacityInList(JointList *pList,CList<CAElement*,CAElement*>*pCapaList)
{
POSITION posCapa=pCapaList->GetHeadPosition();
while(posCapa!=NULL)
{
CAElement *pCapa=pCapaList->GetNext(posCapa);
delete pCapa;
}
pCapaList->RemoveAll();
POSITION pos=pList->GetHeadPosition();
while(pos!=NULL)
{
CAJoint *pJoint=pList->GetNext(pos);
CAElement *pElement;
POSITION pos1=pJoint->pElementList.m_pListElement.GetHeadPosition();
while(pos1!=NULL)
{
pElement=pJoint->pElementList.m_pListElement.GetNext(pos1);
if(pElement->GetType()=
没有合适的资源?快使用搜索试试~ 我知道了~
VC写的电路画板-自己收藏的
共143个文件
h:64个
cpp:63个
bmp:7个
需积分: 10 24 下载量 63 浏览量
2009-05-19
11:00:51
上传
评论
收藏 150KB RAR 举报
温馨提示
VC写的电路画板-自己收藏的VC写的电路画板-自己收藏的VC写的电路画板-自己收藏的
资源推荐
资源详情
资源评论
收起资源包目录
VC写的电路画板-自己收藏的 (143个子文件)
splash.bmp 225KB
Toolbar.bmp 3KB
bmp00002.bmp 370B
bitmap1.bmp 370B
bmp00001.bmp 370B
button1.bmp 370B
bitmap2.bmp 358B
Pointtest.clw 4KB
JointList.cpp 33KB
Calculate.cpp 26KB
NumberDisplay.cpp 17KB
PointtestView.cpp 17KB
mysplash.cpp 11KB
WatchFace.cpp 10KB
MyWatch.cpp 9KB
NodeList.cpp 8KB
Ddutil.cpp 8KB
Rheostat.cpp 7KB
Base.cpp 7KB
SelectTool.cpp 5KB
ButtonList.cpp 5KB
Pointtest.cpp 4KB
SaveGraphic.cpp 4KB
TextTool.cpp 4KB
PointtestDoc.cpp 4KB
Elist.cpp 4KB
BaseTool.cpp 4KB
BaseList.cpp 4KB
Node.cpp 3KB
Text.cpp 3KB
Inductance.cpp 3KB
Current.cpp 3KB
Voltage.cpp 3KB
Diode.cpp 3KB
Element.cpp 3KB
Light.cpp 3KB
Switch.cpp 3KB
Component.cpp 3KB
Eline.cpp 3KB
Capacitance.cpp 3KB
MainFrm.cpp 3KB
Power.cpp 3KB
Ground.cpp 3KB
EDot.cpp 2KB
Propertiy.cpp 2KB
Joint.cpp 2KB
TextList.cpp 2KB
Button.cpp 2KB
Line.cpp 2KB
ElementList.cpp 2KB
DotTool.cpp 2KB
RheostatTool.cpp 2KB
CurrentTool.cpp 2KB
SwitchTool.cpp 2KB
DiodeTool.cpp 2KB
PowerTool.cpp 2KB
LightTool.cpp 2KB
CapTool.cpp 1KB
LineTool.cpp 1KB
IndTool.cpp 1KB
PointList.cpp 1KB
VoltageTool.cpp 1KB
GroundTool.cpp 1KB
ElementSerial.cpp 1KB
Epoint.cpp 1KB
LineList.cpp 1KB
ButtonMouseTool.cpp 1KB
PointTool.cpp 937B
WatchList.cpp 784B
ABaseList.cpp 553B
StdAfx.cpp 211B
Pointtest.dsp 12KB
Pointtest.dsw 541B
Base.h 5KB
PointtestView.h 4KB
JointList.h 4KB
resource.h 3KB
NumberDisplay.h 3KB
Component.h 2KB
Calculate.h 2KB
MyWatch.h 2KB
WatchFace.h 2KB
Pointtest.h 2KB
Element.h 2KB
BaseTool.h 2KB
PointtestDoc.h 2KB
NodeList.h 2KB
mysplash.h 2KB
MainFrm.h 2KB
Propertiy.h 1KB
Rheostat.h 1KB
SaveGraphic.h 1KB
BaseList.h 1KB
StdAfx.h 1KB
TextTool.h 1KB
SelectTool.h 1KB
ButtonList.h 1KB
Elist.h 1KB
Node.h 1KB
DDUTIL.H 1KB
共 143 条
- 1
- 2
资源评论
走在左边
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功