RECTANGE.cpp
上传用户:shangwu01
上传日期:2013-04-22
资源大小:707k
文件大小:3k
源码类别:

CAD

开发平台:

Visual C++

  1. // RECTANGE.cpp: implementation of the CRECTANGE class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "CAD.h"
  6. #include "RECTANGE.h"
  7. #include "math.h"
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[]=__FILE__;
  11. #define new DEBUG_NEW
  12. #endif
  13. //////////////////////////////////////////////////////////////////////
  14. // Construction/Destruction
  15. //////////////////////////////////////////////////////////////////////
  16. CRECTANGE::CRECTANGE()
  17. {
  18. }
  19. CRECTANGE::~CRECTANGE()
  20. {
  21. }
  22. void CRECTANGE::rectange_drawMove(CPoint m_pointorg,CPoint m_pointfal,CDC *pDC,int m_line_style,int m_line_width,COLORREF m_line_color)
  23. {
  24. CPen pen;
  25. pen.CreatePen(m_line_style,m_line_width,m_line_color);
  26. pDC->SelectObject(&pen);
  27. pDC->MoveTo(m_pointorg);
  28. pDC->LineTo(CPoint(m_pointfal.x,m_pointorg.y));
  29. pDC->MoveTo(CPoint(m_pointfal.x,m_pointorg.y));
  30. pDC->LineTo(m_pointfal);
  31. pDC->MoveTo(m_pointfal);
  32. pDC->LineTo(CPoint(m_pointorg.x,m_pointfal.y));
  33. pDC->MoveTo(CPoint(m_pointorg.x,m_pointfal.y));
  34. pDC->LineTo(m_pointorg);
  35. pen.DeleteObject();//矩形输出
  36. float sum1,sum2;
  37. CString str1,str2;
  38. sum1=fabs((m_pointfal.x-m_pointorg.x));
  39. sum2=fabs((m_pointfal.y-m_pointorg.y));
  40. str1.Format("length:%f",sum1);
  41. str2.Format("width:%f",sum2);//文本输出
  42. pDC->TextOut(m_pointfal.x+10,m_pointorg.y+10,str1,12);
  43. pDC->TextOut(m_pointorg.x+10,m_pointfal.y+10,str2,12);
  44. }
  45. void CRECTANGE::rectange_drawAttribution(CDC *pDC)
  46. {
  47. if(m_rectange_save.GetSize())
  48. for(int i=0;i<m_rectange_save.GetSize();i++)
  49. {
  50. CPen pen;
  51. pen.CreatePen(((rectange_data*)m_rectange_save.GetAt(i))->m_line_style,
  52. ((rectange_data*)m_rectange_save.GetAt(i))->m_line_width,
  53. ((rectange_data*)m_rectange_save.GetAt(i))->m_line_color);
  54. pDC->SelectObject(&pen);
  55. pDC->MoveTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg);
  56. pDC->LineTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.x,
  57. ((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.y));
  58. pDC->MoveTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.x,
  59. ((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.y));
  60. pDC->LineTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal);
  61. pDC->MoveTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal);
  62. pDC->LineTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.x,
  63.   ((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.y));
  64. pDC->MoveTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.x,
  65. ((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.y));
  66. pDC->LineTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg);
  67. pen.DeleteObject();
  68. }
  69. }
  70. void CRECTANGE::rectange_store(CPoint m_pointorg,CPoint m_pointfal,int m_line_style,int m_line_width,COLORREF m_line_color)
  71. {
  72. rectange_data *prectange_data=new rectange_data(m_pointorg,m_pointfal,m_line_style,m_line_width,m_line_color);
  73. m_rectange_save.Add(prectange_data);//储存数据
  74. }
  75. ///////////////////////line_save//////////////////////////
  76. CRECTANGE::rectange_data::rectange_data(CPoint m_pointorg,CPoint m_pointfal,int m_line_style,int m_line_width,COLORREF m_line_color)
  77. {
  78. this->m_pointfal=m_pointfal;
  79. this->m_pointorg=m_pointorg;
  80. this->m_line_style=m_line_style;
  81. this->m_line_width=m_line_width;
  82. this->m_line_color=m_line_color;
  83. }
  84. CRECTANGE::rectange_data::~rectange_data()
  85. {
  86. }