55#include <wx/filename.h>
79 if( m_pLibrary->IsLoaded()
87 if( m_pInterface->Get_Count() > 0 )
93 m_References.Set_Name(
_TL(
"References"));
117bool CSG_Tool_Library::_Destroy(
void)
148 if( m_pInterface != NULL )
150 return( m_pInterface->Get_Info(Type) );
164 CSG_Tool *pTool = m_pInterface && Index >= 0 && Index <
Get_Count() ? m_pInterface->Get_Tool(Index) : NULL;
205 return( m_pInterface ? m_pInterface->Create_Tool(Index, bWithGUI, bWithCMD) : NULL );
213 int Index;
return( Name.
asInt(Index) ?
Create_Tool(Index, bWithGUI, bWithCMD) : NULL );
224 return( m_pInterface ? m_pInterface->Delete_Tool(pTool) :
false );
230 return( m_pInterface ? m_pInterface->Delete_Tools() :
false );
243 return(
Get_Tool(i)->Get_MenuPath(
true) );
279 Add_Reference(Table[i].asString(0), Table[i].asString(1), Table[i].asString(2), Table[i].asString(3), Table[i].asString(4), Table[i].asString(5));
303 m_References.Sort(0);
315 return( m_References.Del_Records() );
323 for(
int i=0; i<m_References.Get_Count(); i++)
326 Authors(m_References[i].asString(0)),
327 Date (m_References[i].asString(1)),
328 Title (m_References[i].asString(2)),
329 Source (m_References[i].asString(3)),
330 Link (m_References[i].asString(4)),
331 LinkTxt(m_References[i].asString(5));
333 if( !Authors.is_Empty() )
335 if( Date.is_Empty() ) { Date =
"n.d."; }
337 Reference += bHTML ?
"<b>" + Authors +
" (" + Date +
"):</b>" : Authors +
" (" + Date +
"):";
339 else if( !Date.is_Empty() )
341 Reference += bHTML ?
"<b>(" + Date +
"):</b>" :
"(" + Date +
"):";
344 if( !Title.is_Empty() )
346 if( Title[Title.Length() - 1] !=
'.' ) { Title +=
'.'; }
348 if( !Reference.
is_Empty() ) { Reference +=
" "; }
350 Reference += bHTML ?
"<i>" + Title +
"</i>" : Title;
353 if( !Source.is_Empty() )
355 if( Source[Source.Length() - 1] !=
'.' ) { Source +=
'.'; }
357 if( !Reference.
is_Empty() ) { Reference +=
" "; }
362 if( !Link.is_Empty() )
364 if( !Reference.
is_Empty() ) { Reference +=
" "; }
366 Reference += bHTML ?
"<a href=\"" + Link +
"\">" + (LinkTxt.
is_Empty() ? Link : LinkTxt) +
"</a>" :
"[" + LinkTxt +
"](" + Link +
")";
371 References += Reference;
375 return( References );
427 for(
int i=0; i<m_nLibraries; i++)
429 nTools += m_pLibraries[i]->Get_Count();
443 if( bVerbose ==
false )
449 #if defined(_SAGA_MSW)
453 #elif defined(__WXMAC__)
483 #if defined(_SAGA_MSW)
496 if( bVerbose ==
false )
521 return( _Add_Tool_Chain(File) );
532 wxFileName FileName(File.
c_str());
538 if( FileName ==
Get_Library(i)->Get_File_Name().c_str() )
552 m_pLibraries[m_nLibraries++] = pLibrary;
571 int nOpened = 0; wxDir Dir;
573 if( Dir.Open(Directory.
c_str()) )
575 wxString FileName, DirName(Dir.GetName());
577 if( !bOnlySubDirectories && Dir.GetFirst(&FileName, wxEmptyString, wxDIR_FILES) )
580 {
if( FileName.Find(
"saga_") < 0 && FileName.Find(
"wx") < 0 )
586 while( Dir.GetNext(&FileName) );
589 if( Dir.GetFirst(&FileName, wxEmptyString, wxDIR_DIRS) )
593 if( FileName.CmpNoCase(
"dll") )
598 while( Dir.GetNext(&FileName) );
619 CSG_Tool_Chains *pLibrary = NULL;
620 CSG_Tool_Chain *pTool = NULL;
623 wxFileName FileName(File.
c_str());
625 for(
int iLibrary=0; !pTool && iLibrary<
Get_Count(); iLibrary++)
631 if( FileName == ((CSG_Tool_Chain *)
Get_Library(iLibrary)->
Get_Tool(iTool))->Get_File_Name().c_str() )
633 pLibrary = (CSG_Tool_Chains *)
Get_Library(iLibrary);
645 CSG_Tool_Chain Tool(File);
658 pTool =
new CSG_Tool_Chain(File);
660 if( !pTool || !pTool->
is_Okay() )
673 for(
int iLibrary=0; !pLibrary && iLibrary<
Get_Count(); iLibrary++)
678 pLibrary = (CSG_Tool_Chains *)
Get_Library(iLibrary);
684 m_pLibraries = (CSG_Tool_Library **)
SG_Realloc(m_pLibraries, (m_nLibraries + 1) *
sizeof(CSG_Tool_Library *));
685 m_pLibraries[m_nLibraries++] = pLibrary;
718 m_pLibraries[i]->m_pLibrary->Detach();
722 delete(m_pLibraries[i]);
758 delete(m_pLibraries[i]);
760 for(m_nLibraries--; i<m_nLibraries; i++)
762 m_pLibraries[i] = m_pLibraries[i + 1];
832 #if defined(_SAGA_MSW)
835 #elif defined(__WXMAC__)
842 if( _Add_Library_Chains(
Library,
CSG_String::Format(
"%s/toolchains" , CSG_String(SHARE_PATH).c_str() )) ) { bOkay =
true; }
849 if( _Add_Library_Chains(
Library,
CSG_String::Format(
"%s/toolchains" , CSG_String(SHARE_PATH).c_str() )) ) { bOkay =
true; }
858 #if defined(_SAGA_MSW)
859 const char *Format(
"%s\\%s.dll" ); CSG_Strings Path =
SG_String_Tokenize(Paths,
";" );
860 #elif defined(__WXMAC__)
861 const char *Format(
"%s/lib%s.dylib"); CSG_Strings Path =
SG_String_Tokenize(Paths,
";:");
863 const char *Format(
"%s/lib%s.so" ); CSG_Strings Path =
SG_String_Tokenize(Paths,
";:");
869 if( _Add_Library_Chains(
Library , Path[i]) ) { bOkay =
true; }
882 wxDir dir; wxString file;
bool bOkay =
false;
884 if( dir.Open(Directory.
c_str()) && dir.GetFirst(&file, wxEmptyString, wxDIR_FILES) )
890 if( Tool.is_Okay() && Tool.Get_Library().Cmp(
Library) == 0 && _Add_Tool_Chain(path,
false) )
895 while( dir.GetNext(&file) );
996 "#! /usr/bin/env python\n\n"
998 "Python Interface to SAGA Tools Library\n"
1006 "from PySAGA.helper import Tool_Wrapper\n\n";
1011 pDeprecated_Names = NULL;
1031 Stream.
Write(
"#! /usr/bin/env python\n\n'''\n");
1032 Stream.
Write(
"Python Interface to SAGA Tools\n");
1033 Stream.
Write(
"----------\n'''\n\n");
1034 Stream.
Write(
"from PySAGA.helper import Tool_Wrapper\n\n");
1097 for(
int iTool=0; iTool<pLibrary->
Get_Count(); iTool++)
1109 for(
int i=0; pDeprecated_Names && i<pDeprecated_Names->
Get_Count(); i++)
1166 for(
int iTool=0; iTool<pLibrary->
Get_Count(); iTool++)
1178 for(
int i=0; pDeprecated_Names && i<pDeprecated_Names->
Get_Count(); i++)
void SG_UI_Msg_Add_Error(const char *Message)
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
void SG_UI_Process_Set_Text(const CSG_String &Text)
bool SG_UI_Process_Set_Progress(int Position, int Range)
void * SG_UI_Get_Window_Main(void)
int SG_UI_Msg_Lock(bool bOn)
void SG_UI_ProgressAndMsg_Lock(bool bOn)
CSG_String SG_UI_Set_Application_Name(const CSG_String &Name)
CSG_String SG_UI_Get_Application_Path(bool bPathOnly)
CSG_String SG_UI_Get_API_Path(void)
SAGA_API_DLL_EXPORT bool SG_Get_Environment(const CSG_String &Variable, CSG_String *Value=NULL)
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
@ SG_UI_MSG_STYLE_FAILURE
@ SG_UI_MSG_STYLE_SUCCESS
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &File, const CSG_String &Extension)
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Path_Absolute(const CSG_String &full_Path, const CSG_String &CWD="")
SAGA_API_DLL_EXPORT bool SG_Dir_Create(const CSG_String &Directory, bool bFullPath=false)
SAGA_API_DLL_EXPORT bool SG_Dir_List_Files(CSG_Strings &List, const CSG_String &Directory, const CSG_String &Extension="", bool bRecursive=false)
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Path(const CSG_String &full_Path)
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
SAGA_API_DLL_EXPORT bool SG_File_Delete(const CSG_String &FileName)
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
SAGA_API_DLL_EXPORT CSG_Strings SG_String_Tokenize(const CSG_String &String, const CSG_String &Delimiters=SG_DEFAULT_DELIMITERS, TSG_String_Tokenizer_Mode Mode=SG_TOKEN_DEFAULT)
SAGA_API_DLL_EXPORT bool SG_Dir_Exists(const CSG_String &Directory)
virtual bool Open(const SG_Char *FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
bool Seek_End(void) const
size_t Write(void *Buffer, size_t Size, size_t Count=1) const
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
int Printf(const char *Format,...)
static void Initialize(void)
int Cmp(const CSG_String &String) const
static CSG_String Format(const char *Format,...)
const SG_Char * c_str(void) const
bool is_Empty(void) const
int Get_Count(void) const
bool Set_Value(int Field, const CSG_String &Value)
const SG_Char * asString(int Field, int Decimals=-99) const
sLong Get_Count(void) const
virtual CSG_Table_Record * Get_Record(sLong Index) const
int Get_Field_Count(void) const
virtual bool Set_Field_Type(int Field, TSG_Data_Type Type)
static CSG_String Html_Absolute_Image_Paths(const CSG_String &Text, const CSG_String &Path, bool bAltAsText=false)
static CSG_String Markdown_to_Html(const CSG_String &Text, bool bSimple=true)
static CSG_String Html_to_SimpleText(const CSG_String &Text)