55#include <wx/filename.h>
79 if( m_pLibrary->IsLoaded()
87 if( m_pInterface->Get_Count() > 0 )
106bool CSG_Tool_Library::_Destroy(
void)
135 if( m_pInterface != NULL )
137 return( m_pInterface->Get_Info(Type) );
151 CSG_Tool *pTool = m_pInterface && Index >= 0 && Index <
Get_Count() ? m_pInterface->Get_Tool(Index) : NULL;
192 return( m_pInterface ? m_pInterface->Create_Tool(Index, bWithGUI, bWithCMD) : NULL );
200 int Index;
return( Name.
asInt(Index) ?
Create_Tool(Index, bWithGUI, bWithCMD) : NULL );
211 return( m_pInterface ? m_pInterface->Delete_Tool(pTool) :
false );
217 return( m_pInterface ? m_pInterface->Delete_Tools() :
false );
230 return(
Get_Tool(i)->Get_MenuPath(
true) );
250 Reference +=
CSG_String::Format(
" <a href=\"%s\">%s</a>.", Link, Link_Text && *Link_Text ? Link_Text : Link);
255 m_References += Reference;
272 m_References.Clear();
324 for(
int i=0; i<m_nLibraries; i++)
326 nTools += m_pLibraries[i]->Get_Count();
340 if( bVerbose ==
false )
346 #if defined(_SAGA_MSW)
350 #elif defined(__WXMAC__)
380 #if defined(_SAGA_MSW)
393 if( bVerbose ==
false )
418 return( _Add_Tool_Chain(File) );
429 wxFileName FileName(File.
c_str());
435 if( FileName ==
Get_Library(i)->Get_File_Name().c_str() )
449 m_pLibraries[m_nLibraries++] = pLibrary;
468 int nOpened = 0; wxDir Dir;
470 if( Dir.Open(Directory.
c_str()) )
472 wxString FileName, DirName(Dir.GetName());
474 if( !bOnlySubDirectories && Dir.GetFirst(&FileName, wxEmptyString, wxDIR_FILES) )
477 {
if( FileName.Find(
"saga_") < 0 && FileName.Find(
"wx") < 0 )
483 while( Dir.GetNext(&FileName) );
486 if( Dir.GetFirst(&FileName, wxEmptyString, wxDIR_DIRS) )
490 if( FileName.CmpNoCase(
"dll") )
495 while( Dir.GetNext(&FileName) );
516 CSG_Tool_Chains *pLibrary = NULL;
517 CSG_Tool_Chain *pTool = NULL;
520 wxFileName FileName(File.
c_str());
522 for(
int iLibrary=0; !pTool && iLibrary<
Get_Count(); iLibrary++)
528 if( FileName == ((CSG_Tool_Chain *)
Get_Library(iLibrary)->
Get_Tool(iTool))->Get_File_Name().c_str() )
530 pLibrary = (CSG_Tool_Chains *)
Get_Library(iLibrary);
542 CSG_Tool_Chain Tool(File);
555 pTool =
new CSG_Tool_Chain(File);
557 if( !pTool || !pTool->
is_Okay() )
570 for(
int iLibrary=0; !pLibrary && iLibrary<
Get_Count(); iLibrary++)
575 pLibrary = (CSG_Tool_Chains *)
Get_Library(iLibrary);
581 m_pLibraries = (CSG_Tool_Library **)
SG_Realloc(m_pLibraries, (m_nLibraries + 1) *
sizeof(CSG_Tool_Library *));
582 m_pLibraries[m_nLibraries++] = pLibrary;
615 m_pLibraries[i]->m_pLibrary->Detach();
619 delete(m_pLibraries[i]);
655 delete(m_pLibraries[i]);
657 for(m_nLibraries--; i<m_nLibraries; i++)
659 m_pLibraries[i] = m_pLibraries[i + 1];
723 #if defined(_SAGA_MSW)
726 #elif defined(__WXMAC__)
733 if( _Add_Library_Chains(
Library,
CSG_String::Format(
"%s/toolchains" , CSG_String(SHARE_PATH).c_str() )) ) { bOkay =
true; }
740 if( _Add_Library_Chains(
Library,
CSG_String::Format(
"%s/toolchains" , CSG_String(SHARE_PATH).c_str() )) ) { bOkay =
true; }
749 #if defined(_SAGA_MSW)
750 const char *Format(
"%s\\%s.dll" ); CSG_Strings Path =
SG_String_Tokenize(Paths,
";" );
751 #elif defined(__WXMAC__)
752 const char *Format(
"%s/lib%s.dylib"); CSG_Strings Path =
SG_String_Tokenize(Paths,
";:");
754 const char *Format(
"%s/lib%s.so" ); CSG_Strings Path =
SG_String_Tokenize(Paths,
";:");
760 if( _Add_Library_Chains(
Library , Path[i]) ) { bOkay =
true; }
773 wxDir dir; wxString file;
bool bOkay =
false;
775 if( dir.Open(Directory.
c_str()) && dir.GetFirst(&file, wxEmptyString, wxDIR_FILES) )
781 if( Tool.is_Okay() && Tool.Get_Library().Cmp(
Library) == 0 && _Add_Tool_Chain(path,
false) )
786 while( dir.GetNext(&file) );
887 "#! /usr/bin/env python\n\n"
889 "Python Interface to SAGA Tools Library\n"
897 "from PySAGA.helper import Tool_Wrapper\n\n";
915 Stream.
Write(
"#! /usr/bin/env python\n\n'''\n");
916 Stream.
Write(
"Python Interface to SAGA Tools\n");
917 Stream.
Write(
"----------\n'''\n\n");
918 Stream.
Write(
"from PySAGA.helper import Tool_Wrapper\n\n");
972 for(
int iTool=0; iTool<pLibrary->
Get_Count(); iTool++)
1029 for(
int iTool=0; iTool<pLibrary->
Get_Count(); iTool++)
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_HTML_Tag_Replacer(const CSG_String &Text)
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Path_Absolute(const CSG_String &full_Path)
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
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
int Printf(const char *Format,...)
bool is_Empty(void) const
int Get_Count(void) const