Files
Work/mesh/segment.cpp
2024-08-07 09:16:27 -04:00

56 lines
1.5 KiB
C++

#include <mesh/segment.hpp>
#include <common/purehdc.hpp>
Segment::Segment()
{
}
Segment::~Segment()
{
}
Segment::Segment(const GDIPoint &firstPoint,const GDIPoint &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;
}
void Segment::drawSegment(PureDevice &displayDevice,HPEN hPen,bool setROP)const
{
GDIPoint currentPosition;
HPEN hOldPen(0);
int saveMode;
if(setROP)saveMode=::SetROP2(displayDevice,R2_NOT);
if(hPen)hOldPen=(HPEN)::SelectObject(displayDevice,hPen);
::GetCurrentPositionEx(displayDevice,(POINT FAR*)&currentPosition);
::MoveToEx(displayDevice,mFirstPoint.x(),mFirstPoint.y(),(POINT FAR*)&currentPosition);
::LineTo(displayDevice,mSecondPoint.x(),mSecondPoint.y());
::MoveToEx(displayDevice,currentPosition.x(),currentPosition.y(),(POINT FAR*)&mSecondPoint);
if(hOldPen)::SelectObject(displayDevice,hOldPen);
if(setROP)::SetROP2(displayDevice,saveMode);
}