//--------------------------------------------------------------------------- // Copyright (c) Jim Wright 2004 // // JimPoint.cpp // This is the class for drawing and maintaining a point on the page. // //--------------------------------------------------------------------------- #include "StdAfx.h" #include "jimpoint.h" /* ** Basic constructor */ CJimPoint::CJimPoint(void) { m_x = 0.0; m_y = 0.0; m_size = 1; } /* ** Basic copy constructor */ CJimPoint::CJimPoint(const CJimPoint &right) { m_x = right.m_x; m_y = right.m_y; m_size = right.m_size; m_color = right.m_color; } /* ** Other constructors */ CJimPoint::CJimPoint(double x,double y) { m_x = x; m_y = y; m_size = 1; } CJimPoint::CJimPoint(double x,double y,int size) { m_x = x; m_y = y; m_size = size; } CJimPoint::CJimPoint(double x,double y,int size,COLORREF color) { m_x = x; m_y = y; m_size = size; m_color = color; } /* ** Basic destructor */ CJimPoint::~CJimPoint(void) { } /* ** This is the method that draws the item on the screen */ void CJimPoint::Draw(CDC* hDC, int x, int y,double scale) { CPen myPen; myPen.CreatePen( PS_SOLID, 1, m_color ); hDC->SelectObject(myPen); int halfsize = m_size+1/2; hDC->Ellipse( x+((int)((m_x-halfsize)*scale)), y+((int)((m_y-halfsize)*scale)), x+((int)((m_x+halfsize)*scale)), y+((int)((m_y+halfsize)*scale))); hDC->SetPixel(x+(int)(m_x*scale),y+(int)(m_y*scale),m_color); } /* ** Basic asignment operator */ CJimPoint & CJimPoint::operator=(const CJimPoint &right) { m_x = right.m_x; m_y = right.m_y; m_size = right.m_size; m_color = right.m_color; return *this; } /* ** Basic equation operator */ int CJimPoint::operator==(const CJimPoint &right) const { return ((m_x == right.m_x)&&(m_y == right.m_y)); } /* ** Returns various parts of this class. */ double CJimPoint::GetX(void) { return(m_x); } double CJimPoint::GetY(void) { return(m_y); } /* ** Sets various parts of this class. */ void CJimPoint::SetX(double x) { m_x = x; } void CJimPoint::SetY(double y) { m_y = y; } /* ** Returns math functions of two points. */ double CJimPoint::DistanceBetween(CJimPoint right) { return sqrt(pow((right.m_y-m_y),2)+pow((right.m_x-m_x),2)); } double CJimPoint::Slope(CJimPoint right) { return ((right.m_y-m_y)/(right.m_x-m_x)); } /* ** Methods for returning the range of this object. */ double CJimPoint::FindTop(void) { return m_y; } double CJimPoint::FindBottom(void) { return m_y; } double CJimPoint::FindLeft(void) { return m_x; } double CJimPoint::FindRight(void) { return m_x; }