📄 parameters.cpp
字号:
for(int i=0; i<Get_Count(); i++)
{
switch( m_Parameters[i]->Get_Type() )
{
default:
bInvalid = false;
break;
case PARAMETER_TYPE_Parameters:
bInvalid = m_Parameters[i]->asParameters()->DataObjects_Check(bSilent);
break;
case PARAMETER_TYPE_Grid:
case PARAMETER_TYPE_Table:
case PARAMETER_TYPE_Shapes:
case PARAMETER_TYPE_TIN:
bInvalid = m_Parameters[i]->is_Input() == true
&& m_Parameters[i]->is_Optional() == false
&& m_Parameters[i]->asDataObject() == NULL;
break;
case PARAMETER_TYPE_Grid_List:
case PARAMETER_TYPE_Table_List:
case PARAMETER_TYPE_Shapes_List:
case PARAMETER_TYPE_TIN_List:
bInvalid = m_Parameters[i]->is_Input() == true
&& m_Parameters[i]->is_Optional() == false
&& m_Parameters[i]->asList()->Get_Count() == 0;
break;
}
if( bInvalid )
{
bResult = false;
s.Append(CSG_String::Format(SG_T("\n%s: %s"), m_Parameters[i]->Get_Type_Name(), m_Parameters[i]->Get_Name()));
}
}
//-----------------------------------------------------
if( !bResult && !bSilent )
{
SG_UI_Dlg_Message(CSG_String::Format(SG_T("%s\n%s"), LNG("[DLG] Invalid parameters!"), s.c_str() ), Get_Name() );
}
return( bResult );
}
//---------------------------------------------------------
bool CSG_Parameters::DataObjects_Create(void)
{
if( m_bManaged )
{
for(int i=0; i<Get_Count(); i++)
{
CSG_Data_Object *pDataObject;
CSG_Grid_System *pGrid_System;
CSG_Parameter *p = m_Parameters[i];
if( p->Get_Type() == PARAMETER_TYPE_Parameters )
{
p->asParameters()->DataObjects_Create();
}
else if( p->Get_Type() == PARAMETER_TYPE_DataObject_Output )
{
p->Set_Value(DATAOBJECT_NOTSET);
}
else if( p->is_DataObject() && p->is_Output()
&& ( (p->asDataObject() == DATAOBJECT_CREATE)
|| (p->asDataObject() == NULL && !p->is_Optional()) ) )
{
pDataObject = NULL;
switch( p->Get_Type() )
{
default:
break;
case PARAMETER_TYPE_Grid:
if( p->Get_Parent() && p->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System
&& (pGrid_System = p->Get_Parent()->asGrid_System()) != NULL && pGrid_System->is_Valid() )
{
pDataObject = SG_Create_Grid(*pGrid_System, ((CSG_Parameter_Grid *)p->Get_Data())->Get_Preferred_Type());
}
break;
case PARAMETER_TYPE_Table:
pDataObject = SG_Create_Table();
break;
case PARAMETER_TYPE_Shapes:
pDataObject = SG_Create_Shapes(((CSG_Parameter_Shapes *)p->Get_Data())->Get_Shape_Type());
break;
case PARAMETER_TYPE_TIN:
pDataObject = SG_Create_TIN();
break;
}
p->Set_Value(pDataObject);
if( pDataObject )
{
pDataObject->Set_Name(p->Get_Name());
SG_UI_DataObject_Add(pDataObject, false);
}
}
}
}
return( true );
}
//---------------------------------------------------------
bool CSG_Parameters::DataObjects_Synchronize(void)
{
if( m_bManaged )
{
for(int i=0; i<Get_Count(); i++)
{
CSG_Parameter *p = m_Parameters[i];
if( p->Get_Type() == PARAMETER_TYPE_Parameters )
{
p->asParameters()->DataObjects_Synchronize();
}
else
{
if( p->Get_Type() == PARAMETER_TYPE_Shapes && p->asShapes() && p->asShapes()->Get_Type() == SHAPE_TYPE_Undefined )
{
delete(p->asShapes());
p->Set_Value(DATAOBJECT_NOTSET);
}
if( p->is_Output() )
{
if( p->is_DataObject() )
{
if( p->asDataObject() )
{
SG_UI_DataObject_Add (p->asDataObject(), false);
SG_UI_DataObject_Update (p->asDataObject(), false, NULL);
}
}
else if( p->is_DataObject_List() )
{
for(int j=0; j<p->asList()->Get_Count(); j++)
{
SG_UI_DataObject_Add (p->asList()->asDataObject(j), false);
SG_UI_DataObject_Update (p->asList()->asDataObject(j), false, NULL);
}
}
}
}
}
}
return( true );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
bool CSG_Parameters::Get_String(CSG_String &String, bool bOptionsOnly)
{
bool bResult = false;
if( Get_Count() > 0 )
{
String.Printf(SG_T("%s:"), bOptionsOnly ? LNG("[CAP] Options") : LNG("[CAP] Parameters"));
for(int i=0; i<Get_Count(); i++)
{
if( (!bOptionsOnly || m_Parameters[i]->is_Option()) && !m_Parameters[i]->is_Information() )
{
bResult = true;
String.Append(CSG_String::Format(SG_T("\n[%s] %s: %s"),
m_Parameters[i]->Get_Type_Name(),
m_Parameters[i]->Get_Name(),
m_Parameters[i]->asString())
);
}
}
}
return( bResult );
}
//---------------------------------------------------------
bool CSG_Parameters::Msg_String(bool bOptionsOnly)
{
CSG_String s;
if( Get_String(s, bOptionsOnly) )
{
SG_UI_Msg_Add_Execution(s, true);
return( true );
}
return( false );
}
//---------------------------------------------------------
bool CSG_Parameters::Set_History(CSG_History &History, bool bOptions, bool bDataObjects)
{
int i, j;
CSG_Data_Object *pObject;
CSG_Parameter *p;
//-----------------------------------------------------
if( bOptions )
{
for(i=0; i<Get_Count(); i++) // get options...
{
p = m_Parameters[i];
if( p->is_Option() && !p->is_Information() )
{
History.Add_Entry(p->Get_Name(), p->asString());
}
if( p->is_Parameters() )
{
p->asParameters()->Set_History(History, true, false);
}
}
}
//-----------------------------------------------------
if( bDataObjects )
{
for(i=0; i<Get_Count(); i++) // get input with history...
{
p = m_Parameters[i];
if( p->is_Input() && p->is_DataObject() && (pObject = p->asDataObject()) != NULL )
{
History.Add_Entry(p->Get_Name(), pObject->Get_Name(), &pObject->Get_History());
}
if( p->is_Input() && p->is_DataObject_List() )
{
History.Add_Entry(p->Get_Name(), p->asString());
for(j=0; j<p->asList()->Get_Count(); j++)
{
pObject = p->asList()->asDataObject(j);
History.Add_Entry(p->Get_Name(), pObject->Get_Name(), &pObject->Get_History());
}
}
if( p->is_Parameters() )
{
p->asParameters()->Set_History(History, false, true);
}
}
}
return( true );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#ifdef _SAGA_UNICODE
CSG_Parameter * CSG_Parameters::Get_Parameter(const char *Identifier)
{ return( Get_Parameter(SG_STR_MBTOSG(Identifier)) ); }
CSG_Parameter * CSG_Parameters::Add_Node (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_Node (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
CSG_Parameter * CSG_Parameters::Add_Value (CSG_Parameter *pParent, const 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, SG_STR_MBTOSG(Identifier), Name, Description, Type, Value, Minimum, bMinimum, Maximum, bMaximum) ); }
CSG_Parameter * CSG_Parameters::Add_Info_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value)
{ return( Add_Info_Value (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Type, Value) ); }
CSG_Parameter * CSG_Parameters::Add_Range (CSG_Parameter *pParent, const 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, SG_STR_MBTOSG(Identifier), Name, Description, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) ); }
CSG_Parameter * CSG_Parameters::Add_Info_Range (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max)
{ return( Add_Info_Range (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Range_Min, Range_Max) ); }
CSG_Parameter * CSG_Parameters::Add_Choice (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Items, int Default)
{ return( Add_Choice (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Items, Default) ); }
CSG_Parameter * CSG_Parameters::Add_String (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText, bool bPassword)
{ return( Add_String (pParent, SG_STR_MBTOSG(Identifier), Name, Description, String, bLongText, bPassword) ); }
CSG_Parameter * CSG_Parameters::Add_Info_String (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText)
{ return( Add_Info_String (pParent, SG_STR_MBTOSG(Identifier), Name, Description, String, bLongText) ); }
CSG_Parameter * CSG_Parameters::Add_FilePath (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
{ return( Add_FilePath (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Filter, Default, bSave, bDirectory, bMultiple) ); }
CSG_Parameter * CSG_Parameters::Add_Font (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, class wxFont *pInit)
{ return( Add_Font (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
CSG_Parameter * CSG_Parameters::Add_Colors (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Colors *pInit)
{ return( Add_Colors (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
CSG_Parameter * CSG_Parameters::Add_FixedTable (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Table *pTemplate)
{ return( Add_FixedTable (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pTemplate) ); }
CSG_Parameter * CSG_Parameters::Add_Grid_System (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Grid_System *pInit)
{ return( Add_Grid_System (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
CSG_Parameter * CSG_Parameters::Add_Grid (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent, TSG_Grid_Type Preferred_Type)
{ return( Add_Grid (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, bSystem_Dependent, Preferred_Type) ); }
CSG_Parameter * CSG_Parameters::Add_Grid_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_Grid_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
CSG_Parameter * CSG_Parameters::Add_Grid_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent)
{ return( Add_Grid_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, bSystem_Dependent) ); }
CSG_Parameter * CSG_Parameters::Add_Table_Field (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_Table_Field (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
CSG_Parameter * CSG_Parameters::Add_Table (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
{ return( Add_Table (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
CSG_Parameter * CSG_Parameters::Add_Table_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_Table_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
CSG_Parameter * CSG_Parameters::Add_Table_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
{ return( Add_Table_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
CSG_Parameter * CSG_Parameters::Add_Shapes (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
{ return( Add_Shapes (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, Shape_Type) ); }
CSG_Parameter * CSG_Parameters::Add_Shapes_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_Shapes_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
CSG_Parameter * CSG_Parameters::Add_Shapes_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
{ return( Add_Shapes_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, Shape_Type) ); }
CSG_Parameter * CSG_Parameters::Add_TIN (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
{ return( Add_TIN (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
CSG_Parameter * CSG_Parameters::Add_TIN_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_TIN_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
CSG_Parameter * CSG_Parameters::Add_TIN_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
{ return( Add_TIN_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
CSG_Parameter * CSG_Parameters::Add_Parameters (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
{ return( Add_Parameters (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
#endif
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -