📄 parameter.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// Application Programming Interface //
// //
// Library: SAGA_API //
// //
//-------------------------------------------------------//
// //
// parameter.cpp //
// //
// 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 //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#include "parameters.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CSG_Parameter::CSG_Parameter(CSG_Parameters *pOwner, CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, int Constraint)
{
m_pOwner = pOwner;
m_pParent = pParent;
m_Identifier = Identifier;
m_Name = Name;
m_Description = Description;
//-----------------------------------------------------
m_nChildren = 0;
m_Children = NULL;
if( m_pParent )
{
m_pParent->_Add_Child(this);
}
//-----------------------------------------------------
switch( Type )
{
default: m_pData = NULL; break;
case PARAMETER_TYPE_Node: m_pData = new CSG_Parameter_Node (this, Constraint); break;
case PARAMETER_TYPE_Bool: m_pData = new CSG_Parameter_Bool (this, Constraint); break;
case PARAMETER_TYPE_Int: m_pData = new CSG_Parameter_Int (this, Constraint); break;
case PARAMETER_TYPE_Double: m_pData = new CSG_Parameter_Double (this, Constraint); break;
case PARAMETER_TYPE_Degree: m_pData = new CSG_Parameter_Degree (this, Constraint); break;
case PARAMETER_TYPE_Range: m_pData = new CSG_Parameter_Range (this, Constraint); break;
case PARAMETER_TYPE_Choice: m_pData = new CSG_Parameter_Choice (this, Constraint); break;
case PARAMETER_TYPE_String: m_pData = new CSG_Parameter_String (this, Constraint); break;
case PARAMETER_TYPE_Text: m_pData = new CSG_Parameter_Text (this, Constraint); break;
case PARAMETER_TYPE_FilePath: m_pData = new CSG_Parameter_File_Name (this, Constraint); break;
case PARAMETER_TYPE_Font: m_pData = new CSG_Parameter_Font (this, Constraint); break;
case PARAMETER_TYPE_Color: m_pData = new CSG_Parameter_Color (this, Constraint); break;
case PARAMETER_TYPE_Colors: m_pData = new CSG_Parameter_Colors (this, Constraint); break;
case PARAMETER_TYPE_FixedTable: m_pData = new CSG_Parameter_Fixed_Table (this, Constraint); break;
case PARAMETER_TYPE_Grid_System: m_pData = new CSG_Parameter_Grid_System (this, Constraint); break;
case PARAMETER_TYPE_Table_Field: m_pData = new CSG_Parameter_Table_Field (this, Constraint); break;
case PARAMETER_TYPE_DataObject_Output: m_pData = new CSG_Parameter_Data_Object_Output (this, Constraint); break;
case PARAMETER_TYPE_Grid: m_pData = new CSG_Parameter_Grid (this, Constraint); break;
case PARAMETER_TYPE_Table: m_pData = new CSG_Parameter_Table (this, Constraint); break;
case PARAMETER_TYPE_Shapes: m_pData = new CSG_Parameter_Shapes (this, Constraint); break;
case PARAMETER_TYPE_TIN: m_pData = new CSG_Parameter_TIN (this, Constraint); break;
case PARAMETER_TYPE_Grid_List: m_pData = new CSG_Parameter_Grid_List (this, Constraint); break;
case PARAMETER_TYPE_Table_List: m_pData = new CSG_Parameter_Table_List (this, Constraint); break;
case PARAMETER_TYPE_Shapes_List: m_pData = new CSG_Parameter_Shapes_List (this, Constraint); break;
case PARAMETER_TYPE_TIN_List: m_pData = new CSG_Parameter_TIN_List (this, Constraint); break;
case PARAMETER_TYPE_Parameters: m_pData = new CSG_Parameter_Parameters (this, Constraint); break;
}
//-----------------------------------------------------
switch( Type )
{
default:
break;
case PARAMETER_TYPE_Range:
SG_Free(m_Children);
m_nChildren = 0;
m_Children = NULL;
break;
}
}
//---------------------------------------------------------
CSG_Parameter::~CSG_Parameter(void)
{
if( m_Children )
{
SG_Free(m_Children);
}
if( m_pData )
{
delete(m_pData);
}
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
void CSG_Parameter::_Add_Child(CSG_Parameter *pChild)
{
m_Children = (CSG_Parameter **)SG_Realloc(m_Children, (m_nChildren + 1) * sizeof(CSG_Parameter *));
m_Children[m_nChildren++] = pChild;
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
bool CSG_Parameter::is_Option(void)
{
if( !is_Information() )
{
switch( Get_Type() )
{
default:
return( false );
case PARAMETER_TYPE_Bool:
case PARAMETER_TYPE_Int:
case PARAMETER_TYPE_Double:
case PARAMETER_TYPE_Degree:
case PARAMETER_TYPE_Range:
case PARAMETER_TYPE_Choice:
case PARAMETER_TYPE_String:
case PARAMETER_TYPE_Text:
case PARAMETER_TYPE_FilePath:
case PARAMETER_TYPE_Font:
case PARAMETER_TYPE_Color:
case PARAMETER_TYPE_Colors:
case PARAMETER_TYPE_FixedTable:
case PARAMETER_TYPE_Grid_System:
case PARAMETER_TYPE_Table_Field:
case PARAMETER_TYPE_Parameters:
return( true );
}
}
return( false );
}
//---------------------------------------------------------
bool CSG_Parameter::is_DataObject(void)
{
switch( Get_Type() )
{
default:
return( false );
case PARAMETER_TYPE_DataObject_Output:
case PARAMETER_TYPE_Grid:
case PARAMETER_TYPE_Table:
case PARAMETER_TYPE_Shapes:
case PARAMETER_TYPE_TIN:
return( true );
}
}
//---------------------------------------------------------
bool CSG_Parameter::is_DataObject_List(void)
{
switch( Get_Type() )
{
default:
return( false );
case PARAMETER_TYPE_Grid_List:
case PARAMETER_TYPE_Table_List:
case PARAMETER_TYPE_Shapes_List:
case PARAMETER_TYPE_TIN_List:
return( true );
}
}
//---------------------------------------------------------
bool CSG_Parameter::is_Parameters(void)
{
return( Get_Type() == PARAMETER_TYPE_Parameters );
}
//---------------------------------------------------------
bool CSG_Parameter::is_Serializable(void)
{
switch( Get_Type() )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -