RECTANGE.cpp
上传用户:shangwu01
上传日期:2013-04-22
资源大小:707k
文件大小:3k
- // RECTANGE.cpp: implementation of the CRECTANGE class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "CAD.h"
- #include "RECTANGE.h"
- #include "math.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CRECTANGE::CRECTANGE()
- {
- }
- CRECTANGE::~CRECTANGE()
- {
- }
- void CRECTANGE::rectange_drawMove(CPoint m_pointorg,CPoint m_pointfal,CDC *pDC,int m_line_style,int m_line_width,COLORREF m_line_color)
- {
- CPen pen;
- pen.CreatePen(m_line_style,m_line_width,m_line_color);
- pDC->SelectObject(&pen);
- pDC->MoveTo(m_pointorg);
- pDC->LineTo(CPoint(m_pointfal.x,m_pointorg.y));
- pDC->MoveTo(CPoint(m_pointfal.x,m_pointorg.y));
- pDC->LineTo(m_pointfal);
- pDC->MoveTo(m_pointfal);
- pDC->LineTo(CPoint(m_pointorg.x,m_pointfal.y));
- pDC->MoveTo(CPoint(m_pointorg.x,m_pointfal.y));
- pDC->LineTo(m_pointorg);
- pen.DeleteObject();//矩形输出
-
- float sum1,sum2;
- CString str1,str2;
- sum1=fabs((m_pointfal.x-m_pointorg.x));
- sum2=fabs((m_pointfal.y-m_pointorg.y));
- str1.Format("length:%f",sum1);
- str2.Format("width:%f",sum2);//文本输出
- pDC->TextOut(m_pointfal.x+10,m_pointorg.y+10,str1,12);
- pDC->TextOut(m_pointorg.x+10,m_pointfal.y+10,str2,12);
-
-
- }
- void CRECTANGE::rectange_drawAttribution(CDC *pDC)
- {
- if(m_rectange_save.GetSize())
- for(int i=0;i<m_rectange_save.GetSize();i++)
- {
- CPen pen;
- pen.CreatePen(((rectange_data*)m_rectange_save.GetAt(i))->m_line_style,
- ((rectange_data*)m_rectange_save.GetAt(i))->m_line_width,
- ((rectange_data*)m_rectange_save.GetAt(i))->m_line_color);
- pDC->SelectObject(&pen);
- pDC->MoveTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg);
- pDC->LineTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.x,
- ((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.y));
- pDC->MoveTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.x,
- ((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.y));
- pDC->LineTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal);
- pDC->MoveTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal);
- pDC->LineTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.x,
- ((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.y));
- pDC->MoveTo(CPoint(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg.x,
- ((rectange_data*)m_rectange_save.GetAt(i))->m_pointfal.y));
- pDC->LineTo(((rectange_data*)m_rectange_save.GetAt(i))->m_pointorg);
- pen.DeleteObject();
- }
- }
- void CRECTANGE::rectange_store(CPoint m_pointorg,CPoint m_pointfal,int m_line_style,int m_line_width,COLORREF m_line_color)
- {
- rectange_data *prectange_data=new rectange_data(m_pointorg,m_pointfal,m_line_style,m_line_width,m_line_color);
- m_rectange_save.Add(prectange_data);//储存数据
- }
- ///////////////////////line_save//////////////////////////
- CRECTANGE::rectange_data::rectange_data(CPoint m_pointorg,CPoint m_pointfal,int m_line_style,int m_line_width,COLORREF m_line_color)
- {
- this->m_pointfal=m_pointfal;
- this->m_pointorg=m_pointorg;
- this->m_line_style=m_line_style;
- this->m_line_width=m_line_width;
- this->m_line_color=m_line_color;
- }
- CRECTANGE::rectange_data::~rectange_data()
- {
-
- }