📄 parameters.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// Application Programming Interface //
// //
// Library: SAGA_API //
// //
//-------------------------------------------------------//
// //
// parameters.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_Parameters::CSG_Parameters(void)
{
_On_Construction();
}
//---------------------------------------------------------
CSG_Parameters::CSG_Parameters(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
{
_On_Construction();
Create(pOwner, Name, Description, Identifier, bGrid_System);
}
//---------------------------------------------------------
CSG_Parameters::~CSG_Parameters(void)
{
Destroy();
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
void CSG_Parameters::_On_Construction(void)
{
m_pOwner = NULL;
m_Parameters = NULL;
m_nParameters = 0;
m_Callback = NULL;
m_bCallback = false;
m_pGrid_System = NULL;
m_bManaged = true;
}
//---------------------------------------------------------
void CSG_Parameters::Create(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
{
Destroy();
m_pOwner = pOwner;
Set_Identifier (Identifier);
Set_Name (Name);
Set_Description (Description);
if( bGrid_System )
{
m_pGrid_System = Add_Grid_System(
NULL, SG_T("PARAMETERS_GRID_SYSTEM"),
LNG("[PRM] Grid system"),
LNG("[PRM] Grid system")
);
}
}
//---------------------------------------------------------
void CSG_Parameters::Destroy(void)
{
m_pOwner = NULL;
m_pGrid_System = NULL;
if( m_nParameters > 0 )
{
for(int i=0; i<m_nParameters; i++)
{
delete(m_Parameters[i]);
}
SG_Free(m_Parameters);
m_Parameters = NULL;
m_nParameters = 0;
}
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
void CSG_Parameters::Set_Identifier(const SG_Char *String)
{
if( String )
{
m_Identifier.Printf(String);
}
else
{
m_Identifier.Clear();
}
}
const SG_Char * CSG_Parameters::Get_Identifier(void)
{
return( m_Identifier );
}
//---------------------------------------------------------
void CSG_Parameters::Set_Name(const SG_Char *String)
{
if( String )
{
m_Name.Printf(String);
}
else
{
m_Name.Clear();
}
}
const SG_Char * CSG_Parameters::Get_Name(void)
{
return( m_Name );
}
//---------------------------------------------------------
void CSG_Parameters::Set_Description(const SG_Char *String)
{
if( String )
{
m_Description.Printf(String);
}
else
{
m_Description.Clear();
}
}
const SG_Char * CSG_Parameters::Get_Description(void)
{
return( m_Description );
}
//---------------------------------------------------------
void CSG_Parameters::Set_Translation(CSG_Translator &Translator)
{
m_Name = Translator.Get_Translation(m_Name);
m_Description = Translator.Get_Translation(m_Description);
for(int i=0; i<m_nParameters; i++)
{
m_Parameters[i]->m_Name = Translator.Get_Translation(m_Parameters[i]->m_Name);
m_Parameters[i]->m_Description = Translator.Get_Translation(m_Parameters[i]->m_Description);
}
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_Node(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
{
return( _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Node, PARAMETER_INFORMATION) );
}
//---------------------------------------------------------
/**
* Following parameter types can be used:
* PARAMETER_TYPE_Bool
* PARAMETER_TYPE_Int
* PARAMETER_TYPE_Double
* PARAMETER_TYPE_Degree
* PARAMETER_TYPE_Color
*/
CSG_Parameter * CSG_Parameters::Add_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
{
return( _Add_Value(pParent, Identifier, Name, Description, false, Type, Value, Minimum, bMinimum, Maximum, bMaximum) );
}
CSG_Parameter * CSG_Parameters::Add_Info_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value)
{
return( _Add_Value(pParent, Identifier, Name, Description, true, Type, Value, 0.0, false, 0.0, false) );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
{
return( _Add_Range(pParent, Identifier, Name, Description, false, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) );
}
CSG_Parameter * CSG_Parameters::Add_Info_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max)
{
return( _Add_Range(pParent, Identifier, Name, Description, true, Range_Min, Range_Max, 0.0, false, 0.0, false) );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_Choice(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Items, int Default)
{
CSG_Parameter *pParameter;
CSG_Parameter_Choice *m_pData;
pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Choice, 0);
m_pData = (CSG_Parameter_Choice *)pParameter->m_pData;
m_pData->Set_Items(Items);
pParameter->Set_Value(Default);
return( pParameter );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText, bool bPassword)
{
return( _Add_String(pParent, Identifier, Name, Description, false, String, bLongText, bPassword) );
}
CSG_Parameter * CSG_Parameters::Add_Info_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText)
{
return( _Add_String(pParent, Identifier, Name, Description, true, String, bLongText, false) );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_FilePath(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
{
CSG_Parameter *pParameter;
CSG_Parameter_File_Name *m_pData;
pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_FilePath, 0);
m_pData = (CSG_Parameter_File_Name *)pParameter->m_pData;
m_pData->Set_Filter (Filter);
m_pData->Set_Flag_Save (bSave);
m_pData->Set_Flag_Multiple (bMultiple);
m_pData->Set_Flag_Directory (bDirectory);
pParameter->Set_Value((void *)Default);
return( pParameter );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_Font(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, wxFont *pInit)
{
CSG_Parameter *pParameter;
pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Font, 0);
if( pInit )
{
pParameter->Set_Value(pInit);
}
return( pParameter );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_Colors(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Colors *pInit)
{
CSG_Parameter *pParameter;
pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Colors, 0);
pParameter->asColors()->Assign(pInit);
return( pParameter );
}
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_FixedTable(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Table *pTemplate)
{
CSG_Parameter *pParameter;
pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_FixedTable, 0);
pParameter->asTable()->Create(pTemplate);
return( pParameter );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CSG_Parameter * CSG_Parameters::Add_Grid_System(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Grid_System *pInit)
{
CSG_Parameter *pParameter;
pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid_System, 0);
if( pInit )
{
pParameter->asGrid_System()->Assign(*pInit);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -