12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #include "stdafx.h"
- #include "OTSRect.h"
- OTSDATA::COTSRect::COTSRect()
- {
- m_left = 0;
- m_top = 0;
- m_right = 0;
- m_bottom = 0;
- }
- OTSDATA::COTSRect::COTSRect(int left, int top, int right, int bottom)
- {
- m_left = left;
- m_top = top;
- m_right = right;
- m_bottom = bottom;
- }
- OTSDATA::COTSRect::COTSRect(CPoint leftTop, CPoint bottomRight)
- {
- m_left = leftTop.x;
- m_top = leftTop.y;
- m_right = bottomRight.x;
- m_bottom = bottomRight.y;
- }
- BOOL OTSDATA::COTSRect::operator==(const COTSRect& a_oSource) // ==operator
- {
- // return FASLE, if the two segments list are in different size
- return (m_left == a_oSource.m_left &&
- m_top == a_oSource.m_top &&
- m_right == a_oSource.m_right &&
- m_bottom == a_oSource.m_bottom);
- }
- void OTSDATA::COTSRect::SetRectData(int left, int top, int right, int bottom)
- {
- m_left = left;
- m_top = top;
- m_right = right;
- m_bottom = bottom;
- }
- bool OTSDATA::COTSRect::PointInRect(CPoint p)
- {
- if (p.x > m_left && p.x<m_right && p.y>m_bottom && p.y < m_top)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool OTSDATA::COTSRect::IntersectOtherRect(COTSRect r)
- {
- CPoint leftTop = r.GetTopLeft();
- CPoint rightBottom = r.GetBottomRight();
- CPoint rightTop = CPoint(rightBottom.x, leftTop.y);
- CPoint leftBottom = CPoint(leftTop.x, rightBottom.y);
- if (PointInRect(leftTop))
- {
- return true;
- }
- else if (PointInRect(rightBottom))
- {
- return true;
- }
- else if (PointInRect(rightTop))
- {
- return true;
- }
- else if (PointInRect(leftBottom))
- {
- return true;
- }
- else if (r.PointInRect(CPoint(m_left, m_top)) || r.PointInRect(CPoint(m_right, m_bottom)))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- OTSDATA::COTSRect::~COTSRect()
- {
- }
|