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

绘图程序

开发平台:

Visual C++

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