#include Segment::Segment() { } Segment::~Segment() { } Segment::Segment(const Point &firstPoint,const Point &secondPoint,WORD vectorIndex) { mFirstPoint=firstPoint; mSecondPoint=secondPoint; mVectorIndex=vectorIndex; } Segment::Segment(const Segment &someSegment) { mFirstPoint=someSegment.mFirstPoint; mSecondPoint=someSegment.mSecondPoint; mVectorIndex=someSegment.mVectorIndex; } WORD Segment::operator==(const Segment &someSegment)const { return ((mFirstPoint==someSegment.mFirstPoint && mSecondPoint==someSegment.mSecondPoint)|| (mFirstPoint==someSegment.mSecondPoint && mSecondPoint==someSegment.mFirstPoint)); } void Segment::operator=(const Segment &someSegment) { mFirstPoint=someSegment.mFirstPoint; mSecondPoint=someSegment.mSecondPoint; mVectorIndex=someSegment.mVectorIndex; } #if 0 void Segment::drawSegment(HDC hDC,HPEN hPen)const { DWORD currentPosition; HPEN hOldPen(0); int saveMode; saveMode=::SetROP2(hDC,R2_NOT); if(hPen)hOldPen=(HPEN)::SelectObject(hDC,hPen); currentPosition=::GetCurrentPosition(hDC); ::MoveTo(hDC,mFirstPoint.xPoint(),mFirstPoint.yPoint()); ::LineTo(hDC,mSecondPoint.xPoint(),mSecondPoint.yPoint()); ::MoveTo(hDC,LOWORD(currentPosition),HIWORD(currentPosition)); if(hOldPen)::SelectObject(hDC,hOldPen); ::SetROP2(hDC,saveMode); } #endif void Segment::drawSegment(HDC hDC,HPEN hPen)const { Point currentPosition; HPEN hOldPen(0); int saveMode; saveMode=::SetROP2(hDC,R2_NOT); if(hPen)hOldPen=(HPEN)::SelectObject(hDC,hPen); ::GetCurrentPositionEx(hDC,(POINT FAR*)¤tPosition); ::MoveToEx(hDC,mFirstPoint.xPoint(),mFirstPoint.yPoint(),(POINT FAR*)¤tPosition); ::LineTo(hDC,mSecondPoint.xPoint(),mSecondPoint.yPoint()); ::MoveToEx(hDC,currentPosition.xPoint(),currentPosition.yPoint(),(POINT FAR*)&mSecondPoint); if(hOldPen)::SelectObject(hDC,hOldPen); ::SetROP2(hDC,saveMode); }