ModelCurve2AvB.cpp
资源名称:44757463.rar [点击查看]
上传用户:lj3531212
上传日期:2007-06-18
资源大小:346k
文件大小:18k
源码类别:
绘图程序
开发平台:
Visual C++
- // ModelCurve2AvB.cpp: implementation of the CModelCurve2AvB class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "GraphSoft.h"
- #include "ModelCurve2AvB.h"
- #include "math.h"
- #include "GlobalFunction.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- ///////////////////////////////////
- IMPLEMENT_SERIAL( CModelCurve2AvB, CShape, 0 )
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- CModelCurve2AvB::CModelCurve2AvB():CShape()
- {
- }
- CModelCurve2AvB::CModelCurve2AvB(COLORREF color,int penWidth,float angle):CShape(color,penWidth,angle)
- {
- }
- CModelCurve2AvB::CModelCurve2AvB(CModelCurve2AvB * const pModelCurve2AvB):CShape(pModelCurve2AvB)
- {
- int i=pModelCurve2AvB->m_flArrayxTemp.GetSize();
- int j=0;
- float fx,fy;
- m_flArrayxTemp.RemoveAll();
- m_flArrayyTemp.RemoveAll();
- while(j++<i){
- fx=pModelCurve2AvB->m_flArrayxTemp.GetAt(j-1);
- fy=pModelCurve2AvB->m_flArrayyTemp.GetAt(j-1);
- m_flArrayxTemp.Add(fx);
- m_flArrayyTemp.Add(fy);
- }
- i=pModelCurve2AvB->m_flArrayx.GetSize();
- j=0;
- m_flArrayx.RemoveAll();
- m_flArrayy.RemoveAll();
- while(j++<i){
- fx=pModelCurve2AvB->m_flArrayx.GetAt(j-1);
- fy=pModelCurve2AvB->m_flArrayy.GetAt(j-1);
- m_flArrayx.Add(fx);
- m_flArrayy.Add(fy);
- }
- }
- CModelCurve2AvB::~CModelCurve2AvB()
- {
- }
- //////////////////////////////////////////////////////////////////////////
- void CModelCurve2AvB::Serialize( CArchive& ar)
- {
- CShape::Serialize( ar ) ;
- int i=0,j;
- if ( ar.IsLoading() ){
- float fx,fy;
- ar>>i;
- j=0;
- while(j++ < i){
- ar>>fx;
- ar>>fy;
- m_flArrayx.Add(fx);
- m_flArrayy.Add(fy);
- //temp
- m_flArrayxTemp.Add(fx);
- m_flArrayyTemp.Add(fy);
- }
- } else {
- RefreshData(m_bModified);
- i=m_flArrayx.GetSize();
- j=0;
- ar<<i;
- while(j++ < i){
- ar<<((float)m_flArrayx.GetAt(j-1));
- ar<<((float)m_flArrayy.GetAt(j-1));
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////////
- void CModelCurve2AvB::Draw(CDC *pDC,COLORREF color,COLORREF fillColor,int penWidth)
- {
- CPen pen,*poldPen;
- pen.CreatePen(PS_SOLID,penWidth, color);
- poldPen=pDC->SelectObject(&pen);
- ErJunYunB(pDC,m_flArrayxTemp,m_flArrayyTemp,color,penWidth);
- if(GetDrawPointsFlag()==1){
- DrawPoints(pDC,color);
- }
- pDC->SelectObject(poldPen);
- }
- ///////////////////////////////////////////
- void CModelCurve2AvB::DrawPointsCutTo(CDC *pDC,COLORREF color,CFlRect m_rectFrom,CRect m_rectTo)
- {
- // if(!IsInRect(m_rectFrom)){
- // return;
- // }
- //得到移动扩缩后的关键数据
- CArray<float,float> flArrayx;
- CArray<float,float> flArrayy;;
- //移动
- int i=m_flArrayxTemp.GetSize(),j;
- float stepx=m_rectTo.left-m_rectFrom.left;
- float stepy=m_rectTo.top-m_rectFrom.top;
- for(j=0;j<i;j++){
- flArrayx.Add(m_flArrayxTemp.GetAt(j)+stepx);
- flArrayy.Add(m_flArrayyTemp.GetAt(j)+stepy);
- }
- //扩缩
- float cx,cy,flScale;
- cx=m_rectTo.left;
- cy=m_rectTo.top;
- if(m_rectFrom.Width()<0.01){
- m_rectFrom.right=m_rectFrom.left +1;
- }
- if(m_rectFrom.Height()<0.01){
- m_rectFrom.bottom=m_rectFrom.top +1;
- }
- flScale=(float)m_rectTo.Width()/m_rectFrom.Width();
- //flScale=min((float)m_rectTo.Width()/m_rectFrom.Width(),(float)m_rectTo.Height()/m_rectFrom.Height());
- i=flArrayx.GetSize();
- for(j=0;j<i;j++){
- flArrayx.SetAt(j,(flArrayx.GetAt(j)-cx)*flScale+cx);
- flArrayy.SetAt(j,(flArrayy.GetAt(j)-cy)*flScale+cy);
- }
- CPen pen,*poldPen;
- pen.CreatePen(PS_SOLID,1, color);
- poldPen=pDC->SelectObject(&pen);
- i=flArrayx.GetSize();
- int nSX,nSY;
- nSX=flArrayx.GetAt(0);
- nSY=flArrayy.GetAt(0);
- for(j=0;j<i;j++){
- //画点
- pDC->MoveTo(flArrayx.GetAt(j),flArrayy.GetAt(j)-1-GetPenWidth());
- pDC->LineTo(flArrayx.GetAt(j),flArrayy.GetAt(j)+2+GetPenWidth());
- pDC->MoveTo(flArrayx.GetAt(j)-1-GetPenWidth(),flArrayy.GetAt(j));
- pDC->LineTo(flArrayx.GetAt(j)+2+GetPenWidth(),flArrayy.GetAt(j));
- //画线
- pen.DeleteObject();
- CShape::DotLine(pDC,nSX,nSY,flArrayx.GetAt(j),flArrayy.GetAt(j),color);
- nSX=flArrayx.GetAt(j);
- nSY=flArrayy.GetAt(j);
- }
- pDC->SelectObject(poldPen);
- return;
- }
- void CModelCurve2AvB::DrawPoints(CDC *pDC,COLORREF color)
- {
- CPen pen,*poldPen;
- pen.CreatePen(PS_SOLID,1, color);
- poldPen=pDC->SelectObject(&pen);
- int i=m_flArrayxTemp.GetSize();
- int nSX,nSY;
- nSX=m_flArrayxTemp.GetAt(0);
- nSY=m_flArrayyTemp.GetAt(0);
- for(int j=0;j<i;j++){
- //画点
- pDC->MoveTo(m_flArrayxTemp.GetAt(j),m_flArrayyTemp.GetAt(j)-1-GetPenWidth());
- pDC->LineTo(m_flArrayxTemp.GetAt(j),m_flArrayyTemp.GetAt(j)+2+GetPenWidth());
- pDC->MoveTo(m_flArrayxTemp.GetAt(j)-1-GetPenWidth(),m_flArrayyTemp.GetAt(j));
- pDC->LineTo(m_flArrayxTemp.GetAt(j)+2+GetPenWidth(),m_flArrayyTemp.GetAt(j));
- //画线
- pen.DeleteObject();
- // pen.CreatePen(PS_DOT,1,color);
- // pDC->SelectObject(&pen);
- //pDC->MoveTo(nSX,nSY);
- //pDC->LineTo(m_flArrayxTemp.GetAt(j),m_flArrayyTemp.GetAt(j));
- CShape::DotLine(pDC,nSX,nSY,m_flArrayxTemp.GetAt(j),m_flArrayyTemp.GetAt(j),color);
- nSX=m_flArrayxTemp.GetAt(j);
- nSY=m_flArrayyTemp.GetAt(j);
- }
- pDC->SelectObject(poldPen);
- return;
- }
- /////////////////////////
- void CModelCurve2AvB::DrawCutToRect(CDC *pDC,COLORREF color,COLORREF fillColor,int penWidth,CFlRect m_rectFrom,CRect m_rectTo)
- {
- // if(!IsInRect(m_rectFrom)){
- // return;
- // }
- //得到移动扩缩后的关键数据
- CArray<float,float> flArrayx;
- CArray<float,float> flArrayy;;
- //移动
- int i=m_flArrayxTemp.GetSize(),j;
- float stepx=m_rectTo.left-m_rectFrom.left;
- float stepy=m_rectTo.top-m_rectFrom.top;
- for(j=0;j<i;j++){
- flArrayx.Add(m_flArrayxTemp.GetAt(j)+stepx);
- flArrayy.Add(m_flArrayyTemp.GetAt(j)+stepy);
- }
- //扩缩
- float cx,cy,flScale;
- cx=m_rectTo.left;
- cy=m_rectTo.top;
- if(m_rectFrom.Width()<0.01){
- m_rectFrom.right=m_rectFrom.left +1;
- }
- if(m_rectFrom.Height()<0.01){
- m_rectFrom.bottom=m_rectFrom.top +1;
- }
- flScale=(float)m_rectTo.Width()/m_rectFrom.Width();
- //flScale=min((float)m_rectTo.Width()/m_rectFrom.Width(),(float)m_rectTo.Height()/m_rectFrom.Height());
- i=flArrayx.GetSize();
- for(j=0;j<i;j++){
- flArrayx.SetAt(j,(flArrayx.GetAt(j)-cx)*flScale+cx);
- flArrayy.SetAt(j,(flArrayy.GetAt(j)-cy)*flScale+cy);
- }
- CPen pen,*poldPen;
- pen.CreatePen(PS_SOLID,penWidth, color);
- poldPen=pDC->SelectObject(&pen);
- ErJunYunB(pDC,flArrayx,flArrayy,color,penWidth);
- if(GetDrawPointsFlag()==1){
- DrawPointsCutTo(pDC,color,m_rectFrom,m_rectTo);
- }
- pDC->SelectObject(poldPen);
- }
- int CModelCurve2AvB::ErJunYunB(CDC *pDC,CArray<float,float>& flArrayx,CArray<float,float>& flArrayy,COLORREF color,int penWidth)
- {
- if(flArrayx.GetSize()!=flArrayy.GetSize())
- return 0;
- CArray<float,float> x,y;
- float dt,m,x0,y0,x1,y1,t;
- int i;
- int n=flArrayx.GetSize();
- //TRACE("i=%dn",n);
- if(n<2) return 0;
- for(i=0;i<n;i++)
- {
- x.Add(flArrayx.GetAt(i));
- y.Add(flArrayy.GetAt(i));
- }
- for(i=0;i<n-2;i++)
- {
- //m=abs(x.GetAt(i+1)-x.GetAt(i));
- //if(m>20){
- // dt=0.05;
- //}else{
- //dt=1.0/m;
- //}
- dt=0.1;//防止m=0;
- x0=(x.GetAt(i)+x.GetAt(i+1))/2;
- y0=(y.GetAt(i)+y.GetAt(i+1))/2;
- for(t=0;t<=1&&t>=-1;t=t+dt)
- {
- x1=((t*t-2*t+1)*x.GetAt(i)+(2*t-2*t*t+1)*x.GetAt(i+1)+t*t*x.GetAt(i+2))/2;
- y1=((t*t-2*t+1)*y.GetAt(i)+(2*t-2*t*t+1)*y.GetAt(i+1)+t*t*y.GetAt(i+2))/2;
- pDC->MoveTo(x0,y0);
- pDC->LineTo(x1,y1);
- x0=x1;
- y0=y1;
- // TRACE("x1=%f,y1=%fn",x1,y1);
- }
- pDC->MoveTo(x0,y0);
- pDC->LineTo((x.GetAt(i+1)+x.GetAt(i+2))/2,(y.GetAt(i+1)+y.GetAt(i+2))/2);
- // CPen pen,*poldPen;
- // LOGBRUSH logbr;
- // logbr.lbStyle=BS_SOLID;
- // logbr.lbColor=RGB(255,255,255);
- // pen.CreatePen(PS_GEOMETRIC,penWidth, &logbr);
- // poldPen=pDC->SelectObject(&pen);
- //
- // pDC->MoveTo(x.GetAt(i),y.GetAt(i));
- // pDC->LineTo(x.GetAt(i+1),y.GetAt(i+1));
- //
- // logbr.lbStyle=BS_SOLID;
- // logbr.lbColor=RGB(0,0,0);
- // pen.DeleteObject();
- // pen.CreatePen(PS_GEOMETRIC,penWidth, &logbr);
- // pDC->SelectObject(&pen);
- //
- pDC->MoveTo(x0,y0);
- pDC->LineTo((x.GetAt(i+1)+x.GetAt(i+2))/2,(y.GetAt(i+1)+y.GetAt(i+2))/2);
- //
- // pDC->SelectObject(poldPen);
- }
- return 1;
- }
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- void CModelCurve2AvB::RefreshData(bool bRefresh)
- {
- if(bRefresh){
- int i=m_flArrayxTemp.GetSize();
- int j=0;
- float fx,fy;
- m_flArrayx.RemoveAll();
- m_flArrayy.RemoveAll();
- while(j++<i){
- fx=m_flArrayxTemp.GetAt(j-1);
- fy=m_flArrayyTemp.GetAt(j-1);
- m_flArrayx.Add(fx);
- m_flArrayy.Add(fy);
- }
- m_bModified=FALSE;
- m_ptMagnifyCenterTemp=CPoint(0,0);
- m_flScaleTemp=1;
- m_ptRotateCenterTemp=CPoint(0,0);
- m_flAngleTemp=0;
- }
- }
- void CModelCurve2AvB::CreatGraph(CArray<float,float>& flArrayX,CArray<float,float>& flArrayY,int nPenWidth,COLORREF color,COLORREF fillColor,SHAPE_FILLSTYLE nStyle)
- {
- //if(ptArray.GetSize()<2){
- // return;
- //}
- CShape::CreatGraph(flArrayX,flArrayY,nPenWidth,color,fillColor,nStyle);
- int i=flArrayX.GetSize();
- int j=0;
- float flx,fly;
- m_flArrayx.RemoveAll();
- m_flArrayy.RemoveAll();
- m_flArrayxTemp.RemoveAll();
- m_flArrayyTemp.RemoveAll();
- while(j++<i){
- flx=flArrayX.GetAt(j-1);
- fly=flArrayY.GetAt(j-1);
- m_flArrayx.Add(flx);
- m_flArrayy.Add(fly);
- //temp
- m_flArrayxTemp.Add(flx);
- m_flArrayyTemp.Add(fly);
- }
- }
- void CModelCurve2AvB::CreatGraph(CArray<CPoint,CPoint>& ptArray,int nPenWidth,COLORREF color,COLORREF fillColor,SHAPE_FILLSTYLE nStyle)
- {
- //if(ptArray.GetSize()<2){
- // return;
- //}
- CShape::CreatGraph(ptArray,nPenWidth,color,fillColor,nStyle);
- int i=ptArray.GetSize();
- int j=0;
- CPoint pt;
- m_flArrayx.RemoveAll();
- m_flArrayy.RemoveAll();
- m_flArrayxTemp.RemoveAll();
- m_flArrayyTemp.RemoveAll();
- while(j++<i){
- pt=ptArray.GetAt(j-1);
- m_flArrayx.Add(pt.x);
- m_flArrayy.Add(pt.y);
- //temp
- m_flArrayxTemp.Add(pt.x);
- m_flArrayyTemp.Add(pt.y);
- }
- }
- void CModelCurve2AvB::SetPtData(CArray<float,float>& flArrayX,CArray<float,float>& flArrayY)
- {
- m_flArrayx.Copy(flArrayX);
- m_flArrayxTemp.Copy(flArrayX);
- m_flArrayy.Copy(flArrayY);
- m_flArrayyTemp.Copy(flArrayY);
- }
- void CModelCurve2AvB::GetPtData(CArray<float,float>& flArrayX,CArray<float,float>& flArrayY)
- {
- flArrayX.Copy(m_flArrayxTemp);
- flArrayY.Copy(m_flArrayyTemp);
- }
- CShape* CModelCurve2AvB::GetCopy()
- {
- CShape* pGraph=new CModelCurve2AvB(this);
- return pGraph;
- }
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- void CModelCurve2AvB::Move(CDC *pDC,float stepx,float stepy)
- {
- RefreshData(m_bModified);
- // CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
- int i=m_flArrayxTemp.GetSize();
- int j=0;
- float fx,fy;
- while(j++<i){
- fx=m_flArrayxTemp.GetAt(j-1);
- fy=m_flArrayyTemp.GetAt(j-1);
- m_flArrayx.SetAt(j-1,fx+stepx);
- m_flArrayy.SetAt(j-1,fy+stepy);
- m_flArrayxTemp.SetAt(j-1,fx+stepx);
- m_flArrayyTemp.SetAt(j-1,fy+stepy);
- }
- }
- void CModelCurve2AvB::PartMove(CDC *pDC,float PrevX,float PrevY,float CurX,float CurY)
- {
- RefreshData(m_bModified);
- if(m_nSelectPtNum>-1){
- // CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
- m_flArrayxTemp.SetAt(m_nSelectPtNum,CurX);
- m_flArrayyTemp.SetAt(m_nSelectPtNum,CurY);
- m_flArrayx.SetAt(m_nSelectPtNum,CurX);
- m_flArrayy.SetAt(m_nSelectPtNum,CurY);
- //CShape::Draw(pDC);
- }
- }
- void CModelCurve2AvB::Rotate(CDC *pDC,float CX,float CY,float flAngle)
- {
- if(m_flScaleTemp!=1){
- RefreshData(TRUE);
- }
- // CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
- m_ptRotateCenterTemp=CPoint(CX,CY);
- m_flAngleTemp=flAngle;
- m_bModified=TRUE;
- int i=m_flArrayx.GetSize();
- int j=0;
- float fx,fy,fxTemp,fyTemp;
- while(j++<i){
- fx=m_flArrayx.GetAt(j-1);
- fy=m_flArrayy.GetAt(j-1);
- fxTemp=((fx-CX)*cos(flAngle)-(fy-CY)*sin(flAngle))+CX;
- fyTemp=((fy-CY)*cos(flAngle)+(fx-CX)*sin(flAngle))+CY;
- m_flArrayxTemp.SetAt(j-1,fxTemp);
- m_flArrayyTemp.SetAt(j-1,fyTemp);
- }
- }
- void CModelCurve2AvB::Magnify(CDC *pDC,float CX,float CY,float flScale)
- {
- if(m_flAngleTemp!=0){
- RefreshData(TRUE);
- }
- // CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
- m_ptMagnifyCenterTemp=CPoint(CX,CY);
- m_flScaleTemp=flScale;
- m_bModified=TRUE;
- int i=m_flArrayx.GetSize();
- int j=0;
- float fx,fy;
- while(j++<i){
- fx=m_flArrayx.GetAt(j-1);
- fy=m_flArrayy.GetAt(j-1);
- fx=(fx-CX)*flScale+CX;
- fy=(fy-CY)*flScale+CY;
- m_flArrayxTemp.SetAt(j-1,fx);
- m_flArrayyTemp.SetAt(j-1,fy);
- }
- }
- ///////////////////
- void CModelCurve2AvB::LeftToRight(CDC* pDC,CRect rect)
- {
- RefreshData(m_bModified);
- // CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
- int i=m_flArrayx.GetSize();
- for(int j=0;j<i;j++){
- m_flArrayx.SetAt(j,rect.left/1000.0+rect.right/1000.0-m_flArrayx.GetAt(j));
- m_flArrayxTemp.SetAt(j,rect.left/1000.0+rect.right/1000.0-m_flArrayxTemp.GetAt(j));
- }
- // CShape::Draw(pDC);
- }
- void CModelCurve2AvB::TopToBottom(CDC* pDC,CRect rect)
- {
- RefreshData(m_bModified);
- // CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
- int i=m_flArrayx.GetSize();
- for(int j=0;j<i;j++){
- m_flArrayy.SetAt(j,rect.top/1000.0+rect.bottom/1000.0-m_flArrayy.GetAt(j));
- m_flArrayyTemp.SetAt(j,rect.top/1000.0+rect.bottom/1000.0-m_flArrayyTemp.GetAt(j));
- }
- // CShape::Draw(pDC);
- }
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- int CModelCurve2AvB::IsInRect(CRect rect)
- {
- int nRltVal=0,nTemp;
- int i=m_flArrayx.GetSize();
- int j=0;
- float fx1,fy1,fx2,fy2;
- while(++j < i){
- fx1=m_flArrayxTemp.GetAt(j-1);
- fy1=m_flArrayyTemp.GetAt(j-1);
- fx2=m_flArrayxTemp.GetAt(j);
- fy2=m_flArrayyTemp.GetAt(j);
- nTemp=GetLineStateToRect(fx1,fy1,fx2,fy2,rect);
- nRltVal=nRltVal | nTemp;
- }
- if(nRltVal==3){
- nRltVal=1;
- }
- return nRltVal;
- }
- CRect CModelCurve2AvB::GetBoundaryRect()
- {
- if(m_flArrayxTemp.GetSize()==0){
- return CRect(0,0,0,0);
- }
- CRect rect(1000*m_flArrayxTemp.GetAt(0),1000*m_flArrayyTemp.GetAt(0),1000*m_flArrayxTemp.GetAt(0),1000*m_flArrayyTemp.GetAt(0));
- int i=m_flArrayxTemp.GetSize();
- int j=0;
- float fx,fy;
- while(j++<i){
- fx=1000*m_flArrayxTemp.GetAt(j-1);
- fy=1000*m_flArrayyTemp.GetAt(j-1);
- if(fx<rect.left){
- rect.left=fx;
- }else if(fx>rect.right){
- rect.right=fx;
- }
- if(fy<rect.top){
- rect.top=fy;
- }else if(fy>rect.bottom){
- rect.bottom=fy;
- }
- }
- return rect;
- }
- CPoint CModelCurve2AvB::GetCenterPoint()
- {
- CRect rect=GetBoundaryRect();
- return rect.CenterPoint();
- }
- int CModelCurve2AvB::IsPointinRegion(POINT point)
- {
- int nRltVal=0;
- int i=m_flArrayx.GetSize();
- int j=0;
- CPoint pt1,pt2;
- CRect rect;
- while(++j < i){
- pt1.x=m_flArrayxTemp.GetAt(j-1);
- pt1.y=m_flArrayyTemp.GetAt(j-1);
- pt2.x=m_flArrayxTemp.GetAt(j);
- pt2.y=m_flArrayyTemp.GetAt(j);
- rect=GetRectFromPoint(pt1,pt2);
- if(rect.PtInRect(point)){
- nRltVal|=1;
- break;
- }
- }
- return nRltVal;
- }
- //////
- int CModelCurve2AvB::GetPtState(float flx,float fly,float flRate)
- {
- int nRltVal=0;
- int i=m_flArrayx.GetSize();
- int j=0;
- CRect rect;
- float tmpx,tmpy;
- while(j++<i){
- tmpx=m_flArrayxTemp.GetAt(j-1);
- tmpy=m_flArrayyTemp.GetAt(j-1);
- if(IsPtInRect(tmpx-3*flRate,tmpy-3*flRate,tmpx+3*flRate,tmpy+3*flRate,flx,fly)){
- nRltVal|=1;
- m_nSelectPtNum=j-1;
- m_nSelectLineNum=-1;
- break;
- }
- }
- if(nRltVal==0){
- m_nSelectPtNum=-1;
- m_nSelectLineNum=-1;
- }
- return nRltVal;
- }
- //////////////////////////////////////////////////////////////////////
- // MODULE :ExPort
- // ABSTRACT :Export to a txt file
- // FUNCTION :File->Export...
- // NOTE :
- // RETURN :
- // ARGUMENTS:
- // I/O TYPE NAME EXPLANATION
- // O FILE* outStream Out put File
- // CREATE : FNST)handwolf 2004-4-14
- // UPDATE :
- // :
- //////////////////////////////////////////////////////////////////////
- void CModelCurve2AvB::ExPort(FILE* outStream)//增加导出txt功能时用
- {
- fprintf(outStream, " CModelCurve2AvB n");
- CShape::ExPort(outStream);
- int n=m_flArrayxTemp.GetSize();
- int i=0;
- fprintf(outStream, " %d ",n);
- while(i++ < n){
- fprintf( outStream, " %f %f",(float)m_flArrayxTemp.GetAt(i-1),(float)m_flArrayyTemp.GetAt(i-1));
- }
- fprintf( outStream, "n");
- }
- //////////////////////////////////////////////////////////////////////
- // MODULE :ImPort
- // ABSTRACT :ImPort from a txt file
- // FUNCTION :File->ImPort...
- // NOTE :
- // RETURN :
- // ARGUMENTS:
- // I/O TYPE NAME EXPLANATION
- // I FILE* inStream in put File
- // CREATE : FNST)handwolf 2004-4-14
- // UPDATE :
- // :
- //////////////////////////////////////////////////////////////////////
- void CModelCurve2AvB::ImPort(FILE* inStream)
- {
- CShape::ImPort(inStream);
- float fx,fy;
- int n;
- fscanf(inStream, "%d",&n);
- int i=0;
- while(i++ < n){
- fscanf(inStream, "%f%f",&fx,&fy);
- m_flArrayx.Add(fx);
- m_flArrayy.Add(fy);
- //temp
- m_flArrayxTemp.Add(fx);
- m_flArrayyTemp.Add(fy);
- }
- }
- CString CModelCurve2AvB::GetNameString()
- {
- CString str;
- str.LoadString(IDS_MODELCURVE2AVB);
- return str;
- }
- //////////////////////////////////////////////////////////////////////
- //End of File////////////////
- ////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////