⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapes.h

📁 这是一个GPS相关的程序
💻 H
📖 第 1 页 / 共 2 页
字号:

	virtual void				_Extent_Invalidate	(void)
	{
		if( !m_bUpdate )
		{
			m_bUpdate	= true;

			CSG_Shape::_Extent_Invalidate();
		}
	}

	void						_Extent_Update		(void);

	virtual bool				On_Assign			(CSG_Shape *pShape);

	virtual int					On_Intersects		(TSG_Rect Region);

};


///////////////////////////////////////////////////////////
//														 //
//						Line							 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shape_Line : public CSG_Shape_Points
{
	friend class CSG_Shapes;

public:

	virtual bool				is_Valid			(void)	{	return( m_nParts > 0 && m_nPoints[0] > 1 );	}

	double						Get_Length			(void);
	double						Get_Length			(int iPart);

	virtual double				Get_Distance		(TSG_Point Point, TSG_Point &Next, int iPart);


protected:

	CSG_Shape_Line(class CSG_Shapes *pOwner, CSG_Table_Record *pRecord);
	virtual ~CSG_Shape_Line(void);

	virtual int					On_Intersects		(TSG_Rect Region);

};


///////////////////////////////////////////////////////////
//														 //
//						Polygon							 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shape_Polygon : public CSG_Shape_Points
{
	friend class CSG_Shapes;

public:

	virtual bool				is_Valid			(void)	{	return( m_nParts > 0 && m_nPoints[0] > 2 );	}


	bool						is_Containing		(const TSG_Point &Point);
	bool						is_Containing		(double x, double y);
	bool						is_Containing		(const TSG_Point &Point, int iPart);
	bool						is_Containing		(double x, double y, int iPart);

	bool						is_Clockwise		(int iPart);

	bool						is_Lake				(int iPart);

	double						Get_Perimeter		(void);
	double						Get_Perimeter		(int iPart);

	double						Get_Area			(void);
	double						Get_Area			(int iPart);

	TSG_Point					Get_Centroid		(void);
	TSG_Point					Get_Centroid		(int iPart);

	virtual double				Get_Distance		(TSG_Point Point, TSG_Point &Next, int iPart);


protected:

	CSG_Shape_Polygon(class CSG_Shapes *pOwner, CSG_Table_Record *pRecord);
	virtual ~CSG_Shape_Polygon(void);

	virtual int					On_Intersects		(TSG_Rect Region);

	double						_Get_Area			(int iPart);

};


///////////////////////////////////////////////////////////
//														 //
//						Shapes							 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shapes : public CSG_Data_Object
{
	friend class CSG_Shape;

public:

	CSG_Shapes(void);

								CSG_Shapes	(const CSG_Shapes &Shapes);
	bool						Create		(const CSG_Shapes &Shapes);

								CSG_Shapes	(const SG_Char *File_Name);
	bool						Create		(const SG_Char *File_Name);

								CSG_Shapes	(TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL);
	bool						Create		(TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL);

	virtual ~CSG_Shapes(void);

	virtual bool				Destroy					(void);

	virtual TSG_Data_Object_Type	Get_ObjectType		(void)	const		{	return( DATAOBJECT_TYPE_Shapes );	}

	virtual bool				Assign					(CSG_Data_Object *pObject);

	virtual bool				Save					(const SG_Char *File_Name, int Format = 0);

	virtual bool				is_Valid				(void)	const		{	return( m_Type != SHAPE_TYPE_Undefined && m_nShapes >= 0 );				}

	TSG_Shape_Type				Get_Type				(void)	const		{	return( m_Type );		}

	CSG_Table &					Get_Table				(void)				{	return( m_Table );		}

	CSG_Rect					Get_Extent				(void)				{	_Extent_Update();	return( m_Extent );	}

	//-----------------------------------------------------
	CSG_Shape *					Add_Shape				(void);
	CSG_Shape *					Add_Shape				(CSG_Table_Record *pValues);
	CSG_Shape *					Add_Shape				(CSG_Shape *pShape, bool bCopyAttributes = false);
	bool						Del_Shape				(int iShape);
	bool						Del_Shape				(CSG_Shape *pShape);

	int							Get_Count				(void)	const		{	return( m_nShapes );	}
	CSG_Shape *					Get_Shape				(int iShape)		{	return( iShape >= 0 && iShape < m_nShapes ? m_Shapes[iShape] : NULL );	}
	int							Get_Shape_Index			(CSG_Shape *pShape)	{	return( pShape ? pShape->Get_Record()->Get_Index() : -1 );	}

	CSG_Shape *					Get_Shape				(TSG_Point Point, double Epsilon = 0.0);

	//-----------------------------------------------------
	int							Get_Selection_Count		(void)				{	return( m_Table.m_nSelected );	}
	CSG_Shape *					Get_Selection			(int Index = 0);
	const CSG_Rect &			Get_Selection_Extent	(void);

	bool						Select					(TSG_Rect Extent		, bool bInvert = false);
	bool						Select					(int iShape				, bool bInvert = false);
	bool						Select					(CSG_Shape *pShape = NULL	, bool bInvert = false);

	int							Del_Selection			(void);


protected:

	bool						m_bUpdate;

	int							m_nShapes;

	TSG_Shape_Type				m_Type;

	CSG_Rect					m_Extent, m_Extent_Selected;

	CSG_Table					m_Table;

	CSG_Shape					**m_Shapes;


	void						_On_Construction		(void);

	void						_Extent_Invalidate		(void)				{	m_bUpdate	= true;	}
	void						_Extent_Update			(void);

	CSG_Shape *					_Add_Shape				(CSG_Table_Record *pRecord);

	bool						_Load_ESRI				(const SG_Char *File_Name);
	bool						_Save_ESRI				(const SG_Char *File_Name);

};


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
/** Safe shapes construction */
SAGA_API_DLL_EXPORT CSG_Shapes *	SG_Create_Shapes	(void);

/** Safe shapes construction */
SAGA_API_DLL_EXPORT CSG_Shapes *	SG_Create_Shapes	(const CSG_Shapes &Shapes);

/** Safe shapes construction */
SAGA_API_DLL_EXPORT CSG_Shapes *	SG_Create_Shapes	(const SG_Char *FileName);

/** Safe shapes construction */
SAGA_API_DLL_EXPORT CSG_Shapes *	SG_Create_Shapes	(TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL);


///////////////////////////////////////////////////////////
//														 //
//					Search Engine						 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shapes_Search
{
public:
	CSG_Shapes_Search(void);
	CSG_Shapes_Search(CSG_Shapes *pPoints);

	virtual ~CSG_Shapes_Search(void);

	bool						Create				(CSG_Shapes *pPoints);
	void						Destroy				(void);

	bool						is_Valid			(void)	{	return( m_nPoints > 0 );	}

	CSG_Shape *					Get_Point_Nearest	(double x, double y);
	CSG_Shape *					Get_Point_Nearest	(double x, double y, int iQuadrant);

	int							Select_Radius		(double x, double y, double Radius, bool bSort = false, int MaxPoints = -1);
	int							Get_Selected_Count	(void)	{	return( m_nSelected );		}

	CSG_Shape *					Get_Selected_Point	(int iSelected)
	{
		if( iSelected >= 0 && iSelected < m_nSelected )
		{
			return( m_nSelected == m_Selected_Idx.Get_Count()
				? m_Selected[m_Selected_Idx[iSelected]]
				: m_Selected               [iSelected]
			);
		}

		return( NULL );
	}


protected:

	bool						m_bDestroy;

	int							m_nPoints, m_nSelected, m_Selected_Buf;

	double						*m_Selected_Dst;

	TSG_Point					*m_Pos;

	CSG_Index					m_Idx, m_Selected_Idx;

	CSG_Shape					**m_Selected;

	CSG_Shapes					*m_pPoints;


	void						_On_Construction	(void);

	int							_Get_Index_Next		(double Position);
	int							_Get_Point_Nearest	(double x, double y, int iQuadrant);
	void						_Select_Add			(CSG_Shape *pPoint, double Distance);

};


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
#endif // #ifndef HEADER_INCLUDED__SAGA_API__shapes_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -