Rectangle.cpp
上传用户:lj3531212
上传日期:2007-06-18
资源大小:346k
文件大小:31k
源码类别:

绘图程序

开发平台:

Visual C++

  1. // Rectangle.cpp: implementation of the CRectangle class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "GraphSoft.h"
  6. #include "Rectangle.h"
  7. #include "GlobalFunction.h"
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[]=__FILE__;
  11. #define new DEBUG_NEW
  12. #endif
  13. ///////////////////////////////////
  14. IMPLEMENT_SERIAL( CRectangle, CShape, 0 )
  15. //////////////////////////////////////////////////////////////////////
  16. // Construction/Destruction
  17. //////////////////////////////////////////////////////////////////////
  18. ///////////////////////////////////////////////////////////////////////
  19. CRectangle::CRectangle():CShape()
  20. {
  21.  m_flFirstxTemp=m_flFirstx=0;
  22.  m_flFirstyTemp=m_flFirsty=0;
  23.  m_flSecondxTemp=m_flSecondx=0;
  24.  m_flSecondyTemp=m_flSecondy=0;
  25.      m_flThirdxTemp=m_flThirdx=0;
  26.  m_flThirdyTemp=m_flThirdy=0;
  27.  m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  28.  m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  29.  m_flForthxTemp=m_flForthx;
  30.  m_flForthyTemp=m_flForthy;
  31. }
  32. ////////////////////////////
  33. CRectangle::CRectangle(COLORREF color,int penWidth,float angle):CShape(color,penWidth,angle)
  34. {
  35. m_flFirstxTemp=m_flFirstx=0;
  36. m_flFirstyTemp=m_flFirsty=0;
  37. m_flSecondxTemp=m_flSecondx=0;
  38. m_flSecondyTemp=m_flSecondy=0;
  39. m_flThirdxTemp=m_flThirdx=0;
  40. m_flThirdyTemp=m_flThirdy=0;
  41. m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  42. m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  43. m_flForthxTemp=m_flForthx;
  44. m_flForthyTemp=m_flForthy;
  45. }
  46. //////////////////////////////
  47. CRectangle::CRectangle(CRectangle * const pRect):CShape(pRect)
  48. {
  49. m_flFirstx=pRect->m_flFirstx;
  50. m_flFirsty=pRect->m_flFirsty;
  51. m_flSecondx=pRect->m_flSecondx;
  52. m_flSecondy=pRect->m_flSecondy;
  53. m_flThirdx=pRect->m_flThirdx;
  54. m_flThirdy=pRect->m_flThirdy;
  55.     ////
  56. m_flFirstxTemp=pRect->m_flFirstxTemp;
  57. m_flFirstyTemp=pRect->m_flFirstyTemp;
  58. m_flSecondxTemp=pRect->m_flSecondxTemp;
  59. m_flSecondyTemp=pRect->m_flSecondyTemp;
  60. m_flThirdxTemp=pRect->m_flThirdxTemp;
  61. m_flThirdyTemp=pRect->m_flThirdyTemp;
  62. m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  63. m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  64. m_flForthxTemp=m_flForthx;
  65. m_flForthyTemp=m_flForthy;
  66. }
  67. CRectangle::~CRectangle()
  68. {
  69. }
  70. //////////////////////////////////////////////////////////////////////
  71. //////////////////////////////////////////////////////////////////////
  72. //存储
  73. //////////////////////////////////////////////////////////////////////
  74.  void CRectangle::Serialize( CArchive& ar)
  75.  {
  76.  CShape::Serialize( ar ) ;
  77.  if ( ar.IsLoading() ){  
  78.  ar>>m_flFirstx;
  79.  ar>>m_flFirsty;
  80.  ar>>m_flSecondx;
  81.  ar>>m_flSecondy;
  82.  ar>>m_flThirdx;
  83.  ar>>m_flThirdy;
  84.  //temp
  85.  m_flFirstxTemp=m_flFirstx;
  86.  m_flFirstyTemp=m_flFirsty;
  87.  m_flSecondxTemp=m_flSecondx;
  88.  m_flSecondyTemp=m_flSecondy;
  89.  m_flThirdxTemp=m_flThirdx;
  90.  m_flThirdyTemp=m_flThirdy;
  91.  m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  92.  m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  93.  m_flForthxTemp=m_flForthx;
  94.  m_flForthyTemp=m_flForthy;
  95.  } else {
  96.  ar<<m_flFirstx;
  97.  ar<<m_flFirsty;
  98.  ar<<m_flSecondx;
  99.  ar<<m_flSecondy;
  100.  ar<<m_flThirdx;
  101.  ar<<m_flThirdy;  
  102.  }
  103.  return ;
  104.  }
  105.  //////////////////////////////////////////////////////////////////////
  106.  //////////////////////////////////////////////////////////////////////
  107.  //绘画
  108.  //////////////////////////////////////////////////////////////////////
  109.  void CRectangle::Draw(CDC *pDC,COLORREF color,COLORREF fillColor,int penWidth)
  110.  {  
  111.  CPen pen,*poldPen;
  112.  pen.CreatePen(PS_SOLID,1, fillColor);
  113.  poldPen=pDC->SelectObject(&pen);
  114.  if(m_nFillStyle==_shape_solid_fill){
  115.  CPoint ptArray[4];
  116.  ptArray[0].x=m_flFirstxTemp;
  117.  ptArray[0].y=m_flFirstyTemp;
  118.  ptArray[1].x=m_flSecondxTemp;
  119.  ptArray[1].y=m_flSecondyTemp;
  120.  ptArray[2].x=m_flThirdxTemp;
  121.  ptArray[2].y=m_flThirdyTemp;
  122.  ptArray[3].x=m_flForthxTemp;  
  123.  ptArray[3].y=m_flForthyTemp;
  124.  AreaFill(pDC,4,ptArray,fillColor);
  125.  }
  126.  pen.DeleteObject();
  127.  pen.CreatePen(PS_SOLID,penWidth,color);  
  128.  pDC->SelectObject(&pen);       
  129.  
  130.  pDC->MoveTo(m_flFirstxTemp,m_flFirstyTemp);
  131.  pDC->LineTo(m_flSecondxTemp,m_flSecondyTemp);
  132.  pDC->LineTo(m_flThirdxTemp,m_flThirdyTemp);
  133.  pDC->LineTo(m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp,m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp);
  134.  pDC->LineTo(m_flFirstxTemp,m_flFirstyTemp);
  135.  
  136.  if(GetDrawPointsFlag()==1){
  137.  DrawPoints(pDC,color);
  138.  }
  139.  
  140.  pDC->SelectObject(poldPen);  
  141.  }
  142.  ///////////////////////////////////////////
  143.  void CRectangle::DrawPointsCutTo(CDC *pDC,COLORREF color,CFlRect m_rectFrom,CRect m_rectTo)
  144.  {
  145.  //得到移动扩缩后的关键数据
  146.  float flFirstx,flFirsty,flSecondx,flSecondy,flThirdx,flThirdy,flForthx,flForthy;
  147.  //移动
  148.  
  149.  float stepx=m_rectTo.left-m_rectFrom.left;
  150.  float stepy=m_rectTo.top-m_rectFrom.top;
  151.  flFirstx=m_flFirstxTemp+stepx;
  152.  flFirsty=m_flFirstyTemp+stepy;
  153.  flSecondx=m_flSecondxTemp+stepx;
  154.  flSecondy=m_flSecondyTemp+stepy;
  155.  flThirdx=m_flThirdxTemp+stepx;
  156.  flThirdy=m_flThirdyTemp+stepy;
  157.  flForthx=m_flForthxTemp+stepx;
  158.  flForthy=m_flForthyTemp+stepy;
  159.  //扩缩
  160.  float cx,cy,flScale;
  161.  cx=m_rectTo.left;
  162.  cy=m_rectTo.top;  
  163.  if(m_rectFrom.Width()<0.01){
  164.  m_rectFrom.right=m_rectFrom.left +1;
  165.  }
  166.  if(m_rectFrom.Height()<0.01){
  167.  m_rectFrom.bottom=m_rectFrom.top +1;
  168.  }
  169.  flScale=(float)m_rectTo.Width()/m_rectFrom.Width();
  170.  //flScale=min((float)m_rectTo.Width()/m_rectFrom.Width(),(float)m_rectTo.Height()/m_rectFrom.Height());
  171.  flFirstx=(flFirstx-cx)*flScale+cx;
  172.  flFirsty=(flFirsty-cy)*flScale+cy;
  173.  flSecondx=(flSecondx-cx)*flScale+cx;
  174.  flSecondy=(flSecondy-cy)*flScale+cy;
  175.  flThirdx=(flThirdx-cx)*flScale+cx;
  176.  flThirdy=(flThirdy-cy)*flScale+cy;  
  177.  flForthx=(flForthx-cx)*flScale+cx;
  178.  flForthy=(flForthy-cy)*flScale+cy;
  179.  
  180.  CPen pen,*poldPen;
  181.  pen.CreatePen(PS_SOLID,1, color);
  182.  poldPen=pDC->SelectObject(&pen);
  183.  {
  184.  pDC->MoveTo(flFirstx,flFirsty-1-GetPenWidth());
  185.  pDC->LineTo(flFirstx,flFirsty+2+GetPenWidth());
  186.  pDC->MoveTo(flFirstx-1-GetPenWidth(),flFirsty);
  187.  pDC->LineTo(flFirstx+2+GetPenWidth(),flFirsty);
  188.  
  189.  pDC->MoveTo(flSecondx,flSecondy-1-GetPenWidth());
  190.  pDC->LineTo(flSecondx,flSecondy+2+GetPenWidth());
  191.  pDC->MoveTo(flSecondx-1-GetPenWidth(),flSecondy);
  192.  pDC->LineTo(flSecondx+2+GetPenWidth(),flSecondy);
  193.  
  194.  pDC->MoveTo(flThirdx,flThirdy-1-GetPenWidth());
  195.  pDC->LineTo(flThirdx,flThirdy+2+GetPenWidth());
  196.  pDC->MoveTo(flThirdx-1-GetPenWidth(),flThirdy);
  197.  pDC->LineTo(flThirdx+2+GetPenWidth(),flThirdy);
  198.  
  199.  pDC->MoveTo(flForthx,flForthy-1-GetPenWidth());
  200.  pDC->LineTo(flForthx,flForthy+2+GetPenWidth());
  201.  pDC->MoveTo(flForthx-1-GetPenWidth(),flForthy);
  202.  pDC->LineTo(flForthx+2+GetPenWidth(),flForthy);
  203.  }  
  204.  pDC->SelectObject(poldPen);      
  205.  return;
  206.  }
  207.  void CRectangle::DrawPoints(CDC *pDC,COLORREF color)
  208.  {
  209.  float flForthx,flForthy;
  210.  flForthx=m_flForthxTemp;
  211.  flForthy=m_flForthyTemp;  
  212.  CPen pen,*poldPen;
  213.  pen.CreatePen(PS_SOLID,1, color);
  214.  poldPen=pDC->SelectObject(&pen);
  215.  {
  216.  pDC->MoveTo(m_flFirstxTemp,m_flFirstyTemp-1-GetPenWidth());
  217.  pDC->LineTo(m_flFirstxTemp,m_flFirstyTemp+2+GetPenWidth());
  218.  pDC->MoveTo(m_flFirstxTemp-1-GetPenWidth(),m_flFirstyTemp);
  219.  pDC->LineTo(m_flFirstxTemp+2+GetPenWidth(),m_flFirstyTemp);
  220.  
  221.  pDC->MoveTo(m_flSecondxTemp,m_flSecondyTemp-1-GetPenWidth());
  222.  pDC->LineTo(m_flSecondxTemp,m_flSecondyTemp+2+GetPenWidth());
  223.  pDC->MoveTo(m_flSecondxTemp-1-GetPenWidth(),m_flSecondyTemp);
  224.  pDC->LineTo(m_flSecondxTemp+2+GetPenWidth(),m_flSecondyTemp);
  225.  
  226.  pDC->MoveTo(m_flThirdxTemp,m_flThirdyTemp-1-GetPenWidth());
  227.  pDC->LineTo(m_flThirdxTemp,m_flThirdyTemp+2+GetPenWidth());
  228.  pDC->MoveTo(m_flThirdxTemp-1-GetPenWidth(),m_flThirdyTemp);
  229.  pDC->LineTo(m_flThirdxTemp+2+GetPenWidth(),m_flThirdyTemp);
  230.  
  231.  pDC->MoveTo(flForthx,flForthy-1-GetPenWidth());
  232.  pDC->LineTo(flForthx,flForthy+2+GetPenWidth());
  233.  pDC->MoveTo(flForthx-1-GetPenWidth(),flForthy);
  234.  pDC->LineTo(flForthx+2+GetPenWidth(),flForthy);
  235.  }  
  236.  pDC->SelectObject(poldPen);      
  237.  return;
  238.  }
  239.  ////////////////////////////////////////////
  240.  void CRectangle::DrawCutToRect(CDC *pDC,COLORREF color,COLORREF fillColor,int penWidth,CFlRect m_rectFrom,CRect m_rectTo)
  241.  {
  242.  // if(!IsInRect(m_rectFrom)){
  243.  // return;
  244.  // }
  245.  //得到移动扩缩后的关键数据
  246.  float flFirstx,flFirsty,flSecondx,flSecondy,flThirdx,flThirdy,flForthx,flForthy;
  247.  //移动
  248.  
  249.  float stepx=m_rectTo.left-m_rectFrom.left;
  250.  float stepy=m_rectTo.top-m_rectFrom.top;
  251.  flFirstx=m_flFirstxTemp+stepx;
  252.  flFirsty=m_flFirstyTemp+stepy;
  253.  flSecondx=m_flSecondxTemp+stepx;
  254.  flSecondy=m_flSecondyTemp+stepy;
  255.  flThirdx=m_flThirdxTemp+stepx;
  256.  flThirdy=m_flThirdyTemp+stepy;
  257.  flForthx=m_flForthxTemp+stepx;
  258.  flForthy=m_flForthyTemp+stepy;
  259.  //扩缩
  260.  float cx,cy,flScale;
  261.  cx=m_rectTo.left;
  262.  cy=m_rectTo.top;  
  263.  if(m_rectFrom.Width()<0.01){
  264.  m_rectFrom.right=m_rectFrom.left +1;
  265.  }
  266.  if(m_rectFrom.Height()<0.01){
  267.  m_rectFrom.bottom=m_rectFrom.top +1;
  268.  }
  269.  flScale=(float)m_rectTo.Width()/m_rectFrom.Width();
  270.  // flScale=min((float)m_rectTo.Width()/m_rectFrom.Width(),(float)m_rectTo.Height()/m_rectFrom.Height());
  271.  flFirstx=(flFirstx-cx)*flScale+cx;
  272.  flFirsty=(flFirsty-cy)*flScale+cy;
  273.  flSecondx=(flSecondx-cx)*flScale+cx;
  274.  flSecondy=(flSecondy-cy)*flScale+cy;
  275.  flThirdx=(flThirdx-cx)*flScale+cx;
  276.  flThirdy=(flThirdy-cy)*flScale+cy;  
  277.  flForthx=(flForthx-cx)*flScale+cx;
  278.  flForthy=(flForthy-cy)*flScale+cy;
  279.  
  280.  CPen pen,*poldPen;  
  281.  pen.CreatePen(PS_SOLID,1, fillColor);
  282.  poldPen=pDC->SelectObject(&pen);  
  283.  
  284.  if(m_nFillStyle==_shape_solid_fill){
  285.  CPoint ptArray[4];
  286.  ptArray[0].x=flFirstx;
  287.  ptArray[0].y=flFirsty;
  288.  ptArray[1].x=flSecondx;
  289.  ptArray[1].y=flSecondy;
  290.  ptArray[2].x=flThirdx;
  291.  ptArray[2].y=flThirdy;
  292.  ptArray[3].x=flForthx;  
  293.  ptArray[3].y=flForthy;
  294.  AreaFill(pDC,4,ptArray,fillColor);
  295.  }
  296.  pen.DeleteObject();
  297.  pen.CreatePen(PS_SOLID,penWidth,color);  
  298.  pDC->SelectObject(&pen);       
  299.  
  300.  pDC->MoveTo(flFirstx,flFirsty);
  301.  pDC->LineTo(flSecondx,flSecondy);
  302.  pDC->LineTo(flThirdx,flThirdy);
  303.  pDC->LineTo(flForthx,flForthy);
  304.  pDC->LineTo(flFirstx,flFirsty);
  305.  
  306.  
  307.  if(GetDrawPointsFlag()==1){
  308.  DrawPointsCutTo(pDC,color,m_rectFrom,m_rectTo);
  309.  }
  310.  
  311.  pDC->SelectObject(poldPen);  
  312.  }
  313.  //////////////////////////////////////////////////////////////////////
  314.  //////////////////////////////////////////////////////////////////////
  315.  void CRectangle::CreatGraph(CArray<float,float>& flArrayX,CArray<float,float>& flArrayY,int nPenWidth,COLORREF color,COLORREF fillColor,SHAPE_FILLSTYLE nStyle)
  316.  {  
  317.      if(flArrayX.GetSize()<2){
  318.  return;
  319.  }
  320.  CShape::CreatGraph(flArrayX,flArrayY,nPenWidth,color,fillColor,nStyle);  
  321.      m_flFirstxTemp=m_flFirstx=flArrayX.GetAt(0);
  322.  m_flFirstyTemp=m_flFirsty=flArrayY.GetAt(0);
  323.  m_flSecondxTemp=m_flSecondx=flArrayX.GetAt(0);
  324.  m_flSecondyTemp=m_flSecondy=flArrayY.GetAt(1);
  325.  m_flThirdxTemp=m_flThirdx=flArrayX.GetAt(1);
  326.  m_flThirdyTemp=m_flThirdy=flArrayY.GetAt(1);
  327.  
  328.  m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  329.  m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  330.  m_flForthxTemp=m_flForthx;
  331.  m_flForthyTemp=m_flForthy;
  332.  }
  333.  //////////////////////////////////////////////////////////////////////
  334.  void CRectangle::CreatGraph(CArray<CPoint,CPoint>& ptArray,int nPenWidth,COLORREF color,COLORREF fillColor,SHAPE_FILLSTYLE nStyle)
  335.  {  
  336.  if(ptArray.GetSize()<2){
  337.  return;
  338.  }
  339.  CShape::CreatGraph(ptArray,nPenWidth,color,fillColor,nStyle);
  340.  m_flFirstxTemp=m_flFirstx=((CPoint)ptArray.GetAt(0)).x;
  341.  m_flFirstyTemp=m_flFirsty=((CPoint)ptArray.GetAt(0)).y;
  342.  m_flThirdxTemp=m_flThirdx=((CPoint)ptArray.GetAt(1)).x;
  343.  m_flThirdyTemp=m_flThirdy=((CPoint)ptArray.GetAt(1)).y;
  344.  m_flSecondxTemp=m_flSecondx=((CPoint)ptArray.GetAt(0)).x;
  345.  m_flSecondyTemp=m_flSecondy=((CPoint)ptArray.GetAt(1)).y;
  346.  m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  347.  m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  348.  m_flForthxTemp=m_flForthx;
  349.  m_flForthyTemp=m_flForthy;
  350.  }
  351.  void CRectangle::SetPtData(CArray<float,float>& flArrayX,CArray<float,float>& flArrayY)
  352.  {
  353.  m_flFirstxTemp=m_flFirstx=flArrayX.GetAt(0);
  354.  m_flFirstyTemp=m_flFirsty=flArrayY.GetAt(0);
  355.  m_flSecondxTemp=m_flSecondx=flArrayX.GetAt(1);
  356.  m_flSecondyTemp=m_flSecondy=flArrayY.GetAt(1);
  357.  m_flThirdxTemp=m_flThirdx=flArrayX.GetAt(2);
  358.  m_flThirdyTemp=m_flThirdy=flArrayY.GetAt(2);
  359.  
  360.  m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  361.  m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  362.  m_flForthxTemp=m_flForthx;
  363.  m_flForthyTemp=m_flForthy;
  364.  }
  365.  void CRectangle::GetPtData(CArray<float,float>& flArrayX,CArray<float,float>& flArrayY)
  366.  {
  367.  flArrayX.RemoveAll();
  368.  flArrayY.RemoveAll();
  369.  
  370.  flArrayX.Add(m_flFirstxTemp);
  371.  flArrayX.Add(m_flSecondxTemp);
  372.  flArrayX.Add(m_flThirdxTemp);
  373.  
  374.  flArrayY.Add(m_flFirstyTemp);
  375.  flArrayY.Add(m_flSecondyTemp);
  376.  flArrayY.Add(m_flThirdyTemp);
  377.  }
  378.  CShape* CRectangle::GetCopy()
  379.  {
  380.  CShape* pGraph=new CRectangle(this);
  381.  return pGraph;  
  382.  }
  383. //////////////////////////////////////////////////////////////////////
  384.  //////////////////////////////////////////////////////////////////////
  385.  void CRectangle::Move(CDC *pDC,float stepx,float stepy)
  386.  {
  387.  RefreshData(m_bModified);
  388. //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
  389.  m_flFirstx+=stepx;
  390.  m_flFirsty+=stepy;
  391.  m_flSecondx+=stepx;
  392.  m_flSecondy+=stepy;
  393.  m_flThirdx+=stepx;
  394.  m_flThirdy+=stepy;
  395.  //temp
  396.  m_flFirstxTemp+=stepx;
  397.  m_flFirstyTemp+=stepy;
  398.  m_flSecondxTemp+=stepx;
  399.  m_flSecondyTemp+=stepy;
  400.  m_flThirdxTemp+=stepx;
  401.  m_flThirdyTemp+=stepy;
  402.  m_flForthx+=stepx;
  403.  m_flForthy+=stepy;
  404.  m_flForthxTemp=m_flForthx;
  405.  m_flForthyTemp=m_flForthy;
  406.  }
  407.  void CRectangle::PartMove(CDC *pDC,float PrevX,float PrevY,float CurX,float CurY)
  408.  {
  409.   if(m_nSelectPtNum>-1){
  410. //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
  411.  float flX,flY;
  412.  float flDisA,flDisB;  
  413.  switch(m_nSelectPtNum) {
  414.  case 0:
  415.  flX = m_flThirdx;
  416.  flY = m_flThirdy;             
  417.  flDisA=GetDistance(m_flThirdx,m_flThirdy,m_flFirstx,m_flFirsty);
  418.  flDisB=GetDistance(m_flThirdx,m_flThirdy,CurX,CurY);  
  419.  break;
  420.  case 1:
  421.  flX = m_flForthx;
  422.  flY = m_flForthy;             
  423.  flDisA=GetDistance(m_flForthx,m_flForthy,m_flSecondx,m_flSecondy);
  424.  flDisB=GetDistance(m_flForthx,m_flForthy,CurX,CurY);
  425.  break;
  426.  case 2:
  427.  flX = m_flFirstx;
  428.  flY = m_flFirsty;             
  429.  flDisA=GetDistance(m_flFirstx,m_flFirsty,m_flThirdx,m_flThirdy);
  430.  flDisB=GetDistance(m_flFirstx,m_flFirsty,CurX,CurY);
  431.  break;
  432.  case 3:
  433.  flX = m_flSecondx;
  434.  flY = m_flSecondy;             
  435.  flDisA=GetDistance(m_flSecondx,m_flSecondy,m_flForthx,m_flForthy);
  436.  flDisB=GetDistance(m_flSecondx,m_flSecondy,CurX,CurY);
  437.  break;  
  438.  }
  439.  if(flDisA<1){
  440.  flDisA=1;
  441.  }
  442.  Magnify(pDC,flX,flY,flDisB/flDisA);
  443.  //CShape::Draw(pDC);
  444.  }else if(m_nSelectLineNum>-1){
  445. //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
  446. float flCut1x,flCut1y,flCut2x,flCut2y;
  447.  float flX1[4],flY1[4],flX2[4],flY2[4];
  448.  switch(m_nSelectLineNum) {
  449.  case 0:
  450.  flX1[0]=m_flForthx;
  451.  flY1[0]=m_flForthy;
  452.  flX1[1]=CurX;
  453.  flY1[1]=CurY;    
  454.  flX1[2] = m_flFirstx;
  455.  flY1[2] = m_flFirsty;
  456.  flX1[3] = m_flSecondx;
  457.  flY1[3] = m_flSecondy;
  458.  flX2[0]=m_flThirdx;
  459.  flY2[0]=m_flThirdy;
  460.  flX2[1]=CurX;
  461.  flY2[1]=CurY;    
  462.  flX2[2] = m_flFirstx;
  463.  flY2[2] = m_flFirsty;
  464.  flX2[3] = m_flSecondx;
  465.  flY2[3] = m_flSecondy;
  466.  if(GetCutPtFrom2Line(flX1,flY1,&flCut1x,&flCut1y) && GetCutPtFrom2Line(flX2,flY2,&flCut2x,&flCut2y)){
  467.  if(fabs(flCut1x-m_flForthx)>=0.01){
  468.  m_flFirstxTemp=(m_flFirstx-m_flForthx)*((float)CurX-flCut1x)/(flCut1x-m_flForthx)+m_flFirstx;
  469.  } 
  470.  if(fabs(flCut1y-m_flForthy)>=0.01){
  471.  m_flFirstyTemp=(m_flFirsty-m_flForthy)*((float)CurY-flCut1y)/(flCut1y-m_flForthy)+m_flFirsty;
  472.  }
  473.  if(fabs(flCut2x-m_flThirdx)>=0.01){
  474. m_flSecondxTemp=(m_flSecondx-m_flThirdx)*((float)CurX-flCut2x)/(flCut2x-m_flThirdx)+m_flSecondx;
  475.  }
  476.  if(fabs(flCut2y-m_flThirdy)>=0.01){
  477.   m_flSecondyTemp=(m_flSecondy-m_flThirdy)*((float)CurY-flCut2y)/(flCut2y-m_flThirdy)+m_flSecondy;
  478.  }
  479.  }
  480.  break;
  481.  case 1:
  482.  flX1[0]=m_flFirstx;
  483.  flY1[0]=m_flFirsty;
  484.  flX1[1]=CurX;
  485.  flY1[1]=CurY;    
  486.  flX1[2] = m_flSecondx;
  487.  flY1[2] = m_flSecondy;
  488.  flX1[3] = m_flThirdx;
  489.  flY1[3] = m_flThirdy;
  490.  flX2[0]=m_flForthx;
  491.  flY2[0]=m_flForthy;
  492.  flX2[1]=CurX;
  493.  flY2[1]=CurY;    
  494.  flX2[2] = flX1[2];
  495.  flY2[2] = flY1[2];
  496.  flX2[3] = flX1[3];
  497.  flY2[3] = flY1[3];
  498.  
  499.  if(GetCutPtFrom2Line(flX1,flY1,&flCut1x,&flCut1y) && GetCutPtFrom2Line(flX2,flY2,&flCut2x,&flCut2y)){
  500.  
  501.  if(fabs(flCut1x-m_flFirstx)>=0.01){
  502.  m_flSecondxTemp=(m_flSecondx-m_flFirstx)*((float)CurX-flCut1x)/(flCut1x-m_flFirstx)+m_flSecondx;
  503.  } 
  504.  if(fabs(flCut1y-m_flFirsty)>=0.01){
  505.      m_flSecondyTemp=(m_flSecondy-m_flFirsty)*((float)CurY-flCut1y)/(flCut1y-m_flFirsty)+m_flSecondy;
  506.  }
  507.  if(fabs(flCut2x-m_flForthx)>=0.01){
  508.  m_flThirdxTemp=(m_flThirdx-m_flForthx)*((float)CurX-flCut2x)/(flCut2x-m_flForthx)+m_flThirdx;
  509.  }
  510.  if(fabs(flCut2y-m_flForthy)>=0.01){
  511.  m_flThirdyTemp=(m_flThirdy-m_flForthy)*((float)CurY-flCut2y)/(flCut2y-m_flForthy)+m_flThirdy;
  512.  }
  513.  }
  514.  break;
  515.  case 2:
  516.  flX1[0]=m_flSecondx;
  517.  flY1[0]=m_flSecondy;
  518.  flX1[1]=CurX;
  519.  flY1[1]=CurY;    
  520.  flX1[2] = m_flThirdx;
  521.  flY1[2] = m_flThirdy;
  522.  flX1[3] = m_flForthx;
  523.  flY1[3] = m_flForthy;
  524.  flX2[0]=m_flFirstx;
  525.  flY2[0]=m_flFirsty;
  526.  flX2[1]=CurX;
  527.  flY2[1]=CurY;    
  528.  flX2[2] = flX1[2];
  529.  flY2[2] = flY1[2];
  530.  flX2[3] = flX1[3];
  531.  flY2[3] = flY1[3];
  532.  if(GetCutPtFrom2Line(flX1,flY1,&flCut1x,&flCut1y) && GetCutPtFrom2Line(flX2,flY2,&flCut2x,&flCut2y)){
  533.  
  534.  if(fabs(flCut1x-m_flSecondx)>=0.01){
  535.  m_flThirdxTemp=(m_flThirdx-m_flSecondx)*((float)CurX-flCut1x)/(flCut1x-m_flSecondx)+m_flThirdx;
  536.  } 
  537.  if(fabs(flCut1y-m_flSecondy)>=0.01){
  538. m_flThirdyTemp=(m_flThirdy-m_flSecondy)*((float)CurY-flCut1y)/(flCut1y-m_flSecondy)+m_flThirdy;
  539.  }
  540.  if(fabs(flCut2x-m_flFirstx)>=0.01){
  541.  m_flForthxTemp=(m_flForthx-m_flFirstx)*((float)CurX-flCut2x)/(flCut2x-m_flFirstx)+m_flForthx;
  542.  }
  543.  if(fabs(flCut2y-m_flFirsty)>=0.01){
  544.  m_flForthyTemp=(m_flForthy-m_flFirsty)*((float)CurY-flCut2y)/(flCut2y-m_flFirsty)+m_flForthy;
  545.  }
  546.  }
  547.  break;
  548.  case 3:
  549.  flX1[0]=m_flThirdx;
  550.  flY1[0]=m_flThirdy;
  551.  flX1[1]=CurX;
  552.  flY1[1]=CurY;    
  553.  flX1[2] = m_flForthx;
  554.  flY1[2] = m_flForthy;
  555.  flX1[3] = m_flFirstx;
  556.  flY1[3] = m_flFirsty;
  557.  flX2[0]=m_flSecondx;
  558.  flY2[0]=m_flSecondy;
  559.  flX2[1]=CurX;
  560.  flY2[1]=CurY;    
  561.  flX2[2] = flX1[2];
  562.  flY2[2] = flY1[2];
  563.  flX2[3] = flX1[3];
  564.  flY2[3] = flY1[3];
  565.  if(GetCutPtFrom2Line(flX1,flY1,&flCut1x,&flCut1y) && GetCutPtFrom2Line(flX2,flY2,&flCut2x,&flCut2y)){
  566.  
  567.  if(fabs(flCut1x-m_flThirdx)>=0.01){
  568.  m_flForthxTemp=(m_flForthx-m_flThirdx)*((float)CurX-flCut1x)/(flCut1x-m_flThirdx)+m_flForthx;
  569.  } 
  570.  if(fabs(flCut1y-m_flThirdy)>=0.01){
  571.  m_flForthyTemp=(m_flForthy-m_flThirdy)*((float)CurY-flCut1y)/(flCut1y-m_flThirdy)+m_flForthy;
  572.  }
  573.  if(fabs(flCut2x-m_flSecondx)>=0.01){
  574.  m_flFirstxTemp=(m_flFirstx-m_flSecondx)*((float)CurX-flCut2x)/(flCut2x-m_flSecondx)+m_flFirstx;
  575.  }
  576.  if(fabs(flCut2y-m_flSecondy)>=0.01){
  577. m_flFirstyTemp=(m_flFirsty-m_flSecondy)*((float)CurY-flCut2y)/(flCut2y-m_flSecondy)+m_flFirsty;
  578.  }
  579.  }  
  580.  break;  
  581.  }
  582.  //CShape::Draw(pDC);
  583.  }
  584.  }
  585.  /////////////////////////////////////////////
  586.  //function Rotate(...)
  587.  //Rotate flAngle degrees around the ptCenter given as a param
  588.  ////////////////////////////////////////////
  589.  void CRectangle::Rotate(CDC *pDC,float CX,float CY,float flAngle)
  590.  {
  591.  if(m_flScaleTemp!=1){
  592.  RefreshData(TRUE);
  593.  }
  594.  
  595.  //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
  596.  
  597.  m_ptRotateCenterTemp=CPoint(CX,CY);
  598.  m_flAngleTemp=flAngle;
  599.  m_bModified=TRUE;
  600.  
  601.  m_flFirstxTemp=((m_flFirstx-CX)*cos(flAngle)-(m_flFirsty-CY)*sin(flAngle))+CX;
  602.  m_flFirstyTemp=((m_flFirsty-CY)*cos(flAngle)+(m_flFirstx-CX)*sin(flAngle))+CY;
  603.  m_flSecondxTemp=((m_flSecondx-CX)*cos(flAngle)-(m_flSecondy-CY)*sin(flAngle))+CX;
  604.  m_flSecondyTemp=((m_flSecondy-CY)*cos(flAngle)+(m_flSecondx-CX)*sin(flAngle))+CY;
  605.  m_flThirdxTemp=((m_flThirdx-CX)*cos(flAngle)-(m_flThirdy-CY)*sin(flAngle))+CX;
  606.  m_flThirdyTemp=((m_flThirdy-CY)*cos(flAngle)+(m_flThirdx-CX)*sin(flAngle))+CY;
  607.  
  608.  m_flForthxTemp=((m_flForthx-CX)*cos(flAngle)-(m_flForthy-CY)*sin(flAngle))+CX;
  609.  m_flForthyTemp=((m_flForthy-CY)*cos(flAngle)+(m_flForthx-CX)*sin(flAngle))+CY;
  610.  //Draw(pDC);
  611.  }
  612.  /////////////////////////////////////////////
  613.  //function Magnify(...)
  614.  //Magnify flScale times relative to the ptCenter given as a param
  615.  ////////////////////////////////////////////
  616.  void CRectangle::Magnify(CDC *pDC,float CX,float CY,float flScale)
  617.  {
  618.  if(m_flAngleTemp!=0){
  619.  RefreshData(TRUE);
  620.  }
  621.  //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));  
  622.  m_ptMagnifyCenterTemp=CPoint(CX,CY);
  623.  m_flScaleTemp=flScale;
  624.  m_bModified=TRUE;
  625.  
  626.  m_flFirstxTemp=(m_flFirstx-CX)*flScale+CX;
  627.  m_flFirstyTemp=(m_flFirsty-CY)*flScale+CY;
  628.  m_flSecondxTemp=(m_flSecondx-CX)*flScale+CX;
  629.  m_flSecondyTemp=(m_flSecondy-CY)*flScale+CY;
  630.  m_flThirdxTemp=(m_flThirdx-CX)*flScale+CX;
  631.  m_flThirdyTemp=(m_flThirdy-CY)*flScale+CY;  
  632.  
  633.  m_flForthxTemp=(m_flForthx-CX)*flScale+CX;
  634.  m_flForthyTemp=(m_flForthy-CY)*flScale+CY;  
  635.  //Draw(pDC);
  636.  }
  637.  void CRectangle::TopToBottom(CDC* pDC,CRect rect)
  638.  {
  639.  RefreshData(m_bModified);
  640. //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
  641.  m_flFirstyTemp=rect.top/1000.0+rect.bottom/1000.0-m_flFirstyTemp;
  642.  m_flSecondyTemp=rect.top/1000.0+rect.bottom/1000.0-m_flSecondyTemp;
  643.  m_flThirdyTemp=rect.top/1000.0+rect.bottom/1000.0-m_flThirdyTemp;
  644.  
  645.  m_flFirsty=rect.top/1000.0+rect.bottom/1000.0-m_flFirsty;
  646.  m_flSecondy=rect.top/1000.0+rect.bottom/1000.0-m_flSecondy;
  647.  m_flThirdy=rect.top/1000.0+rect.bottom/1000.0-m_flThirdy;
  648.  
  649.  m_flForthyTemp=rect.top/1000.0+rect.bottom/1000.0-m_flForthyTemp;  
  650.  m_flForthy=rect.top/1000.0+rect.bottom/1000.0-m_flForthy;
  651.  //CShape::Draw(pDC);
  652.  }
  653.  void CRectangle::LeftToRight(CDC* pDC,CRect rect)
  654.  {
  655.  RefreshData(m_bModified);
  656. //  CShape::Draw(pDC,RGB(255,255,255),RGB(255,255,255));
  657.  m_flFirstxTemp=rect.left/1000.0+rect.right/1000.0-m_flFirstxTemp;
  658.  m_flSecondxTemp=rect.left/1000.0+rect.right/1000.0-m_flSecondxTemp;
  659.  m_flThirdxTemp=rect.left/1000.0+rect.right/1000.0-m_flThirdxTemp;
  660.  
  661.  m_flFirstx=rect.left/1000.0+rect.right/1000.0-m_flFirstx;
  662.  m_flSecondx=rect.left/1000.0+rect.right/1000.0-m_flSecondx;
  663.  m_flThirdx=rect.left/1000.0+rect.right/1000.0-m_flThirdx;
  664.  
  665.  m_flForthxTemp=rect.left/1000.0+rect.right/1000.0-m_flForthxTemp;  
  666.  m_flForthx=rect.left/1000.0+rect.right/1000.0-m_flForthx;
  667.  //CShape::Draw(pDC);
  668.  } 
  669.  ///
  670.  void CRectangle::RefreshData(bool bRefresh)
  671.  {
  672.  if(bRefresh){
  673.  
  674.  m_flFirstx = m_flFirstxTemp;
  675.      m_flFirsty = m_flFirstyTemp;
  676.  m_flSecondx = m_flSecondxTemp ;
  677.  m_flSecondy = m_flSecondyTemp;
  678.  m_flThirdx = m_flThirdxTemp;
  679.  m_flThirdy = m_flThirdyTemp;
  680.  m_flForthx = m_flForthxTemp;
  681.  m_flForthy = m_flForthyTemp;
  682.  
  683.  m_bModified=FALSE;
  684.  m_ptMagnifyCenterTemp=CPoint(0,0);
  685.  m_flScaleTemp=1;
  686.  m_ptRotateCenterTemp=CPoint(0,0);
  687.  m_flAngleTemp=0;
  688.  }
  689.  }
  690.  //////////////////////////////////////////////////////////////////////
  691.  //////////////////////////////////////////////////////////////////////
  692.  /////////////////////////////////////////////
  693.  //function------IsInRect
  694.  //return value
  695.  //0----------out
  696.  //1----------cut
  697.  //2----------in
  698.  /////////////////////////////////////////////
  699.  int CRectangle::IsInRect(CRect rect)
  700.  {
  701.  int nRltVal=0,nTemp;
  702.  float flForthx,flForthy;
  703.  flForthx=m_flForthxTemp;
  704.  flForthy=m_flForthyTemp;
  705.  
  706.  if((nTemp=GetLineStateToRect(m_flFirstxTemp,m_flFirstyTemp,m_flSecondxTemp,m_flSecondyTemp,rect))!=0){
  707.  nRltVal= nRltVal|nTemp;
  708.  }
  709.  if((nTemp=GetLineStateToRect(m_flSecondxTemp,m_flSecondyTemp,m_flThirdxTemp,m_flThirdyTemp,rect))!=0){
  710.  nRltVal= nRltVal|nTemp;
  711.  }
  712.  if((nTemp=GetLineStateToRect(m_flThirdxTemp,m_flThirdyTemp,flForthx,flForthy,rect))!=0){
  713.  nRltVal= nRltVal|nTemp;
  714.  }
  715.  if((nTemp=GetLineStateToRect(flForthx,flForthy,m_flFirstxTemp,m_flFirstyTemp,rect))!=0){
  716.  nRltVal= nRltVal|nTemp;
  717.  }
  718.  if(nRltVal==3){
  719.  nRltVal=1;
  720.  }else if(nRltVal==0){
  721.  CPoint pt[4];
  722.  pt[0].x=rect.left;
  723.  pt[0].y=rect.top;
  724.  pt[1].x=rect.right;
  725.  pt[1].y=rect.top;
  726.  pt[2].x=rect.right;
  727.  pt[2].y=rect.bottom;
  728.  pt[3].x=rect.left;
  729.  pt[3].y=rect.bottom;
  730.  if(IsPointinRegion(pt[0])&&IsPointinRegion(pt[1])&&
  731.   IsPointinRegion(pt[2])&&IsPointinRegion(pt[3])&&
  732.   m_nFillStyle==_shape_solid_fill){
  733.  nRltVal=1;      
  734.  }
  735.  }  
  736.  return nRltVal;
  737.  }
  738.  CRect CRectangle::GetBoundaryRect()
  739.  {
  740.  CRect rect;
  741.  float flForthx,flForthy;
  742.  flForthx=m_flForthxTemp;
  743.  flForthy=m_flForthyTemp;
  744.  rect.left=1000*min(m_flFirstxTemp,min(m_flSecondxTemp,min(m_flThirdxTemp,flForthx)));
  745.  rect.right=1000*max(m_flFirstxTemp,max(m_flSecondxTemp,max(m_flThirdxTemp,flForthx)));
  746.  rect.top=1000*min(m_flFirstyTemp,min(m_flSecondyTemp,min(m_flThirdyTemp,flForthy)));
  747.  rect.bottom=1000*max(m_flFirstyTemp,max(m_flSecondyTemp,max(m_flThirdyTemp,flForthy)));
  748.  
  749.  return rect;
  750.  }
  751.  CPoint CRectangle::GetCenterPoint()
  752.  {
  753.  CRect rect=GetBoundaryRect();
  754.  return rect.CenterPoint();
  755.  }
  756.  int CRectangle::IsPointinRegion(POINT point)
  757.  //方法:
  758.  //通过计算点的右射线与四边形各边(线段)的交点来判断!
  759.  //仅当焦点数为1时,点在四边形内
  760.  {
  761.  int nRltVal=0;
  762.  float flForthx,flForthy;
  763.  flForthx=m_flForthxTemp;
  764.  flForthy=m_flForthyTemp;
  765.  if(point.y>min(m_flFirstyTemp,m_flSecondyTemp)&&point.y<max(m_flFirstyTemp,m_flSecondyTemp))
  766.  {
  767.  if((m_flSecondxTemp-(m_flSecondxTemp-m_flFirstxTemp)*(m_flSecondyTemp-point.y)/(m_flSecondyTemp-m_flFirstyTemp))>=point.x){
  768.  nRltVal+=1;
  769.  }
  770.  }
  771.  if(point.y>min(m_flThirdyTemp,m_flSecondyTemp)&&point.y<max(m_flThirdyTemp,m_flSecondyTemp))
  772.  {
  773.  if((m_flSecondxTemp-(m_flSecondxTemp-m_flThirdxTemp)*(m_flSecondyTemp-point.y)/(m_flSecondyTemp-m_flThirdyTemp))>=point.x){
  774.  nRltVal+=1;
  775.  }
  776.  }
  777.  if(point.y>min(m_flThirdyTemp,flForthy)&&point.y<max(m_flThirdyTemp,flForthy))
  778.  {
  779.  if((flForthx-(flForthx-m_flThirdxTemp)*(flForthy-point.y)/(flForthy-m_flThirdyTemp))>=point.x){
  780.  nRltVal+=1;
  781.  }
  782.  }
  783.  if(point.y>min(m_flFirstyTemp,flForthy)&&point.y<max(m_flFirstyTemp,flForthy))
  784.  {
  785.  if((flForthx-(flForthx-m_flFirstxTemp)*(flForthy-point.y)/(flForthy-m_flFirstyTemp))>=point.x){
  786.  nRltVal+=1;
  787.  }
  788.  }
  789.  if(nRltVal!=1){
  790.  nRltVal=0;
  791.  }
  792.  return nRltVal;  
  793.  } 
  794.  
  795.  //////
  796.  int CRectangle::GetPtState(float flx,float fly,float flRate)
  797.  {
  798.  //on out point
  799.  if(IsPtInRect(m_flFirstxTemp-3*flRate,m_flFirstyTemp-3*flRate,m_flFirstxTemp+3*flRate,m_flFirstyTemp+3*flRate,flx,fly)){
  800.  m_nSelectPtNum=0;
  801.  m_nSelectLineNum=-1;
  802.  return 1;
  803.  }
  804.  
  805.  if(IsPtInRect(m_flSecondxTemp-3*flRate,m_flSecondyTemp-3*flRate,m_flSecondxTemp+3*flRate,m_flSecondyTemp+3*flRate,flx,fly)){
  806.  m_nSelectPtNum=1;
  807.  m_nSelectLineNum=-1;
  808.  return 1;
  809.  }  
  810.  
  811.  if(IsPtInRect(m_flThirdxTemp-3*flRate,m_flThirdyTemp-3*flRate,m_flThirdxTemp+3*flRate,m_flThirdyTemp+3*flRate,flx,fly)){
  812.  m_nSelectPtNum=2;
  813.  m_nSelectLineNum=-1;
  814.  return 1;
  815.  }  
  816.  
  817.  if(IsPtInRect(m_flForthxTemp-3*flRate,m_flForthyTemp-3*flRate,m_flForthxTemp+3*flRate,m_flForthyTemp+3*flRate,flx,fly)){
  818.  m_nSelectPtNum=3;
  819.  m_nSelectLineNum=-1;
  820.  return 1;
  821.  }
  822.  
  823.  //on out line
  824.  if(GetPtStateToBigLine(m_flFirstxTemp,m_flFirstyTemp,m_flSecondxTemp,m_flSecondyTemp,5*flRate,flx,fly)){
  825.  m_nSelectPtNum=-1;
  826.  m_nSelectLineNum=0;
  827.  return 2;
  828.  }
  829.  if(GetPtStateToBigLine(m_flSecondxTemp,m_flSecondyTemp,m_flThirdxTemp,m_flThirdyTemp,5*flRate,flx,fly)){
  830.  m_nSelectPtNum=-1;
  831.  m_nSelectLineNum=1;
  832.  return 2;
  833.  }
  834.  if(GetPtStateToBigLine(m_flThirdxTemp,m_flThirdyTemp,m_flForthxTemp,m_flForthyTemp,5*flRate,flx,fly)){
  835.  m_nSelectPtNum=-1;
  836.  m_nSelectLineNum=2;
  837.  return 2;
  838.  }
  839.  if(GetPtStateToBigLine(m_flForthxTemp,m_flForthyTemp,m_flFirstxTemp,m_flFirstyTemp,5*flRate,flx,fly)){
  840.  m_nSelectPtNum=-1;
  841.  m_nSelectLineNum=3;
  842.  return 2;
  843.  }      
  844.  //out
  845.  
  846.  m_nSelectPtNum=-1;
  847.  m_nSelectLineNum=-1;
  848.  
  849.  return 0;
  850.  }
  851.  float CRectangle::GetSelectLineRate()
  852.  {
  853.  if(m_nSelectLineNum==0||m_nSelectLineNum==2){
  854.  return -GetLineRate(m_flFirstxTemp,m_flFirstyTemp,m_flSecondxTemp,m_flSecondyTemp);
  855.  }
  856.  if(m_nSelectLineNum==1||m_nSelectLineNum==3){
  857.  return -GetLineRate(m_flSecondxTemp,m_flSecondyTemp,m_flThirdxTemp,m_flThirdyTemp);
  858.  }
  859.  return 0;
  860.  }
  861.  
  862.  //////////////////////////////////////////////////////////////////////
  863.  // MODULE   :ExPort
  864.  // ABSTRACT :Export to a txt file
  865.  // FUNCTION :File->Export...
  866.  // NOTE     :
  867.  // RETURN   :
  868.  // ARGUMENTS:
  869.  //              I/O           TYPE      NAME       EXPLANATION
  870.  //               O            FILE*    outStream    Out put File
  871.  // CREATE   :  FNST)handwolf  2004-4-14
  872.  // UPDATE   :  
  873.  //          : 
  874.  //////////////////////////////////////////////////////////////////////
  875.  
  876.  void CRectangle::ExPort(FILE* outStream)//增加导出txt功能时用
  877.  {
  878.  fprintf(outStream, " CRectangle n");
  879.  CShape::ExPort(outStream);
  880.  fprintf( outStream, "%f %f %f %f %f %fn",m_flFirstx, m_flFirsty, m_flSecondx, m_flSecondy,m_flThirdx,m_flThirdy);
  881.  }
  882.  
  883.  //////////////////////////////////////////////////////////////////////
  884.  // MODULE   :ImPort
  885.  // ABSTRACT :ImPort from a txt file
  886.  // FUNCTION :File->ImPort...
  887.  // NOTE     :
  888.  // RETURN   :
  889.  // ARGUMENTS:
  890.  //              I/O           TYPE      NAME       EXPLANATION
  891.  //               I            FILE*    inStream    in put File
  892.  // CREATE   :  FNST)handwolf  2004-4-14
  893.  // UPDATE   :  
  894.  //          : 
  895.  //////////////////////////////////////////////////////////////////////
  896.  void CRectangle::ImPort(FILE* inStream)
  897.  {
  898.  CShape::ImPort(inStream);
  899.  fscanf(inStream, "%f %f %f %f %f %f",&m_flFirstx, &m_flFirsty, &m_flSecondx, &m_flSecondy,&m_flThirdx,&m_flThirdy);
  900.  m_flFirstxTemp=m_flFirstx;
  901.  m_flFirstyTemp=m_flFirsty;
  902.  m_flSecondxTemp=m_flSecondx;
  903.  m_flSecondyTemp=m_flSecondy;
  904.  m_flThirdxTemp=m_flThirdx;
  905.  m_flThirdyTemp=m_flThirdy;
  906.  
  907.  m_flForthx=m_flThirdxTemp+m_flFirstxTemp-m_flSecondxTemp;
  908.  m_flForthy=m_flThirdyTemp+m_flFirstyTemp-m_flSecondyTemp;
  909.  m_flForthxTemp=m_flForthx;
  910.  m_flForthyTemp=m_flForthy;
  911.  }
  912.  CString CRectangle::GetNameString()
  913.  {
  914.  CString str;
  915.  str.LoadString(IDS_RECTANGLE);
  916.  return str;
  917.  }
  918.  //////////////////////////////////////////////////////////////////////
  919.  //End of File//////////////////////