You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.2 KiB
C++

//////////////////////////////////////////////////////////////////////////////////////
//Polygon.h
#pragma once
#include "CommonDefines.h"
class CGDFPolygon
{
public:
CGDFPolygon();
~CGDFPolygon();
//Attributes
private:
CArray<CPoint2D,CPoint2D> m_pointarray;
int m_iType;//0--internal 1--external
CRect8 m_rect;
CString m_strTypeName;
CArray<POINT,POINT> m_drawarray;//其点数与m_pointarray的点数相等
GDFLOGPEN m_logpen;
BOOL m_bClose;
POINT m_oldpoint;
POINT m_originpoint;
int m_iSelectedIndex;
BOOL m_bIsEditing;
//Operations
public:
void SetPointArray(CPoint2D* p,int count);
int GetPointCount();
CPoint2D* GetPointArray();
void SetPoint(int index,CPoint2D p);
int GetType();
void SetType(int iType);
CRect8 GetRect();
void AddPoint(CPoint2D point);
void AddPoint(CPoint2D* point,int count);
int PointInRegion(CPoint2D point);
void Clear();
int GetDirection();//1--顺时针 -1--逆时针 0--无法判断
void ReversePointArray();
void Copy(CGDFPolygon* pPolygon);
void Normalize(CTypedPtrArray<CPtrArray,CGDFPolygon*>& polygonarray);
void NormalizeBorder();
double CalculateArea();
CString GetTypeName();
void SetTypeName(LPCTSTR strTypeName);
BOOL ReadFromFile(CString strFileName);
BOOL SaveToFile(CString strFileName);
BOOL ReadFromFile(CStdioFile& file);
BOOL SaveToFile(CStdioFile& file);
POINT* GetDrawArray();
void SetDrawArray(POINT* point,int count);
int GetDrawPointCount();
//mouse message
BOOL OnLButtonDown(CView* pView,CDC* pDC,UINT nFlags,CPoint p,double dZoomFactor);
BOOL OnLButtonUp(CView* pView,CDC* pDC,UINT nFlags,CPoint p,double dZoomFactor);
BOOL OnMouseMove(CView* pView,CDC* pDC,UINT nFlags,CPoint p,double dZoomFactor);
BOOL OnLButtonDblClick(CView* pView,CDC* pDC,UINT nFlags,CPoint p,double dZoomFactor);
BOOL OnRButtonDown(CView* pView,CDC* pDC,UINT nFlags,CPoint p,double dZoomFactor);
void GetLogPen(GDFLOGPEN* logpen);
void SetLogPen(GDFLOGPEN* logpen);
void DrawSelectedMark(CDC* pDC,CView* pView,double dZoomFactor);
void Draw(CDC* pDC,CView* pView,double dZoomFactor);
void SetClose(BOOL bValue);
BOOL GetClose();
void SetEditing(BOOL bValue);
BOOL GetEditing();
void UpdateRect();
double GetArea();
};