📄 shapes.h
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// Application Programming Interface //
// //
// Library: SAGA_API //
// //
//-------------------------------------------------------//
// //
// shapes.h //
// //
// Copyright (C) 2005 by Olaf Conrad //
// //
//-------------------------------------------------------//
// //
// This file is part of 'SAGA - System for Automated //
// Geoscientific Analyses'. //
// //
// This library is free software; you can redistribute //
// it and/or modify it under the terms of the GNU Lesser //
// General Public License as published by the Free //
// Software Foundation, version 2.1 of the License. //
// //
// This library is distributed in the hope that it will //
// be useful, but WITHOUT ANY WARRANTY; without even the //
// implied warranty of MERCHANTABILITY or FITNESS FOR A //
// PARTICULAR PURPOSE. See the GNU Lesser General Public //
// License for more details. //
// //
// You should have received a copy of the GNU Lesser //
// General Public License along with this program; if //
// not, write to the Free Software Foundation, Inc., //
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
// USA. //
// //
//-------------------------------------------------------//
// //
// contact: Olaf Conrad //
// Institute of Geography //
// University of Goettingen //
// Goldschmidtstr. 5 //
// 37077 Goettingen //
// Germany //
// //
// e-mail: oconrad@saga-gis.org //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#ifndef HEADER_INCLUDED__SAGA_API__shapes_H
#define HEADER_INCLUDED__SAGA_API__shapes_H
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#include "table.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
typedef enum ESG_Shape_Type
{
SHAPE_TYPE_Undefined = 0,
SHAPE_TYPE_Point,
SHAPE_TYPE_Points,
SHAPE_TYPE_Line,
SHAPE_TYPE_Polygon
}
TSG_Shape_Type;
//---------------------------------------------------------
SAGA_API_DLL_EXPORT const SG_Char * SG_Get_ShapeType_Name (TSG_Shape_Type Type);
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shape
{
friend class CSG_Shapes;
public:
//-----------------------------------------------------
virtual void Destroy (void);
bool Assign (CSG_Shape *pShape, bool bAssign_Attributes = true);
CSG_Table_Record * Get_Record (void) { return( m_pRecord ); }
TSG_Shape_Type Get_Type (void);
virtual bool is_Valid (void) = 0;
bool is_Selected (void) { return( m_pRecord->is_Selected() ); }
//-----------------------------------------------------
virtual int Add_Point (double x, double y, int iPart = 0) = 0;
virtual int Ins_Point (double x, double y, int iPoint, int iPart = 0) = 0;
virtual int Set_Point (double x, double y, int iPoint, int iPart = 0) = 0;
virtual int Del_Point ( int iPoint, int iPart = 0) = 0;
int Add_Point (TSG_Point Point, int iPart = 0);
int Ins_Point (TSG_Point Point, int iPoint, int iPart = 0);
int Set_Point (TSG_Point Point, int iPoint, int iPart = 0);
virtual int Del_Part (int iPart) = 0;
virtual int Del_Parts (void) = 0;
virtual int Get_Part_Count (void) = 0;
int Get_Point_Count (void);
virtual int Get_Point_Count (int iPart) = 0;
virtual TSG_Point Get_Point (int iPoint, int iPart = 0) = 0;
//-----------------------------------------------------
virtual CSG_Rect Get_Extent (void) = 0;
int Intersects (TSG_Rect Extent);
virtual double Get_Distance (TSG_Point Point) = 0;
virtual double Get_Distance (TSG_Point Point, int iPart) = 0;
virtual double Get_Distance (TSG_Point Point, TSG_Point &Next) = 0;
virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) = 0;
protected:
CSG_Table_Record *m_pRecord;
class CSG_Shapes *m_pOwner;
CSG_Shape(class CSG_Shapes *pOwner, CSG_Table_Record *pRecord);
virtual ~CSG_Shape(void);
virtual bool On_Assign (CSG_Shape *pShape) = 0;
virtual int On_Intersects (TSG_Rect Extent) = 0;
virtual void _Extent_Invalidate (void);
};
///////////////////////////////////////////////////////////
// //
// Point //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shape_Point : public CSG_Shape
{
friend class CSG_Shapes;
public:
virtual bool is_Valid (void) { return( true ); }
virtual int Add_Point (double x, double y, int iPart = 0);
virtual int Ins_Point (double x, double y, int iPoint, int iPart = 0) { return( Add_Point(x, y) ); }
virtual int Set_Point (double x, double y, int iPoint, int iPart = 0) { return( Add_Point(x, y) ); }
virtual int Del_Point ( int iPoint, int iPart = 0) { return( -1 ); }
virtual int Del_Part (int iPart) { return( -1 ); }
virtual int Del_Parts (void) { return( -1 ); }
virtual int Get_Part_Count (void) { return( 1 ); }
virtual int Get_Point_Count (int iPart) { return( 1 ); }
virtual TSG_Point Get_Point (int iPoint, int iPart = 0) { return( m_Point ); }
virtual CSG_Rect Get_Extent (void);
virtual double Get_Distance (TSG_Point Point) { return( SG_Get_Distance(Point, m_Point) ); }
virtual double Get_Distance (TSG_Point Point, int iPart) { return( SG_Get_Distance(Point, m_Point) ); }
virtual double Get_Distance (TSG_Point Point, TSG_Point &Next) { Next = m_Point; return( SG_Get_Distance(Point, m_Point) ); }
virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) { Next = m_Point; return( SG_Get_Distance(Point, m_Point) ); }
protected:
CSG_Shape_Point(class CSG_Shapes *pOwner, CSG_Table_Record *pRecord);
virtual ~CSG_Shape_Point(void);
TSG_Point m_Point;
virtual bool On_Assign (CSG_Shape *pShape);
virtual int On_Intersects (TSG_Rect Region);
};
///////////////////////////////////////////////////////////
// //
// Points //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Shape_Points : public CSG_Shape
{
friend class CSG_Shapes;
public:
virtual void Destroy (void);
virtual bool is_Valid (void) { return( m_nParts > 0 && m_nPoints[0] > 0 ); }
virtual int Add_Point (double x, double y, int iPart = 0);
virtual int Ins_Point (double x, double y, int iPoint, int iPart = 0);
virtual int Set_Point (double x, double y, int iPoint, int iPart = 0);
virtual int Del_Point ( int iPoint, int iPart = 0);
virtual int Del_Part (int iPart);
virtual int Del_Parts (void);
virtual int Get_Part_Count (void)
{
return( m_nParts );
}
virtual int Get_Point_Count (int iPart)
{
return( iPart >= 0 && iPart < m_nParts ? m_nPoints[iPart] : 0 );
}
virtual TSG_Point Get_Point (int iPoint, int iPart = 0)
{
if( iPart >= 0 && iPart < m_nParts && iPoint >= 0 && iPoint < m_nPoints[iPart] )
{
return( m_Points[iPart][iPoint] );
}
return( CSG_Point(0.0, 0.0) );
}
virtual CSG_Rect Get_Extent (void) { _Extent_Update(); return( m_Extent ); }
virtual double Get_Distance (TSG_Point Point);
virtual double Get_Distance (TSG_Point Point, int iPart);
virtual double Get_Distance (TSG_Point Point, TSG_Point &Next);
virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart);
protected:
CSG_Shape_Points(class CSG_Shapes *pOwner, CSG_Table_Record *pRecord);
virtual ~CSG_Shape_Points(void);
bool m_bUpdate;
int *m_nPoints, m_nParts;
TSG_Point **m_Points;
CSG_Rect m_Extent;
int _Add_Part (void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -