SAGA API Version 9.11
Loading...
Searching...
No Matches
tool.cpp
Go to the documentation of this file.
1
3// //
4// SAGA //
5// //
6// System for Automated Geoscientific Analyses //
7// //
8// Application Programming Interface //
9// //
10// Library: SAGA_API //
11// //
12//-------------------------------------------------------//
13// //
14// tool.cpp //
15// //
16// Copyright (C) 2005 by Olaf Conrad //
17// //
18//-------------------------------------------------------//
19// //
20// This file is part of 'SAGA - System for Automated //
21// Geoscientific Analyses'. //
22// //
23// This library is free software; you can redistribute //
24// it and/or modify it under the terms of the GNU Lesser //
25// General Public License as published by the Free //
26// Software Foundation, either version 2.1 of the //
27// License, or (at your option) any later version. //
28// //
29// This library is distributed in the hope that it will //
30// be useful, but WITHOUT ANY WARRANTY; without even the //
31// implied warranty of MERCHANTABILITY or FITNESS FOR A //
32// PARTICULAR PURPOSE. See the GNU Lesser General Public //
33// License for more details. //
34// //
35// You should have received a copy of the GNU Lesser //
36// General Public License along with this program; if //
37// not, see <http://www.gnu.org/licenses/>. //
38// //
39//-------------------------------------------------------//
40// //
41// contact: Olaf Conrad //
42// Institute of Geography //
43// University of Goettingen //
44// Germany //
45// //
46// e-mail: oconrad@saga-gis.org //
47// //
49
50//---------------------------------------------------------
51#include "saga_api.h"
52#include "data_manager.h"
53#include "tool.h"
54#include "tool_chain.h"
55
56#include <wx/string.h>
57#include <wx/cmdline.h>
58
59
61// //
62// //
63// //
65
66//---------------------------------------------------------
68{
69 m_ID = "-1";
70 m_Version = "1.0";
71
72 m_bError_Ignore = false;
73 m_bExecutes = false;
74
75 m_bGUI = SG_UI_Get_Application_Name().Cmp("saga_gui") == 0;
76 m_bCMD = SG_UI_Get_Application_Name().Cmp("saga_cmd") == 0;
77
78 Parameters.Create(this, SG_T("Tool"));
79 Parameters.Set_Callback_On_Parameter_Changed(&_On_Parameter_Changed);
80 Parameters.Set_Tool(this);
81
83}
84
85//---------------------------------------------------------
87{
88 for(int i=0; i<Get_Parameters_Count(); i++)
89 {
90 delete(Get_Parameters(i));
91 }
92
93 Destroy();
94}
95
96
98// //
100
101//---------------------------------------------------------
103{
104 m_bError_Ignore = false;
105
106 History_Supplement.Destroy();
107}
108
109
111// //
113
114//---------------------------------------------------------
116{
117 return( m_Library );
118}
119
120//---------------------------------------------------------
122{
123 return( m_File_Name );
124}
125
126//---------------------------------------------------------
128{
129 Parameters.Set_Name(String);
130}
131
133{
134 return( Parameters.Get_Name() );
135}
136
137//---------------------------------------------------------
139{
140 m_Author = String;
141}
142
144{
145 return( m_Author );
146}
147
148//---------------------------------------------------------
150{
151 m_Version = String;
152}
153
155{
156 return( m_Version );
157}
158
159//---------------------------------------------------------
161{
162 Parameters.Set_Description(String);
163}
164
165void CSG_Tool::Add_Description(const CSG_String &String, bool bNewLine)
166{
167 CSG_String Description(Get_Description());
168
169 if( bNewLine ) { Description += "\n"; }
170
171 Set_Description(Description + String);
172}
173
175{
176 return( Parameters.Get_Description().is_Empty() ? Get_Name() : Parameters.Get_Description() );
177}
178
179//---------------------------------------------------------
180void CSG_Tool::Add_Reference(const CSG_String &Authors, const CSG_String &Year, const CSG_String &Title, const CSG_String &Where, const SG_Char *Link, const SG_Char *Link_Text)
181{
182 Parameters.Add_Reference(Authors, Year, Title, Where, Link, Link_Text);
183}
184
185void CSG_Tool::Add_Reference(const CSG_String &Link, const SG_Char *Link_Text)
186{
187 Parameters.Add_Reference(Link, Link_Text);
188}
189
191{
192 return( Parameters.Get_References() );
193}
194
195//---------------------------------------------------------
197{
198 if( !bSolved )
199 {
200 return( Get_MenuPath() );
201 }
202
203 CSG_Strings Menu = SG_String_Tokenize(Get_MenuPath(), ";"); if( !Menu.Get_Count() ) { Menu += ""; }
204
205 for(int i=0; i<Menu.Get_Count(); i++)
206 {
207 if( Menu[i].Length() > 1 && Menu[i][1] == ':' )
208 {
209 if( Menu[i][0] == 'A' || Menu[i][0] == 'a' ) // absolute menu path, overwrites library's default menu path
210 {
211 Menu[i] = Menu[i].AfterFirst(':');
212
213 continue;
214 }
215
216 Menu[i] = Menu[i].AfterFirst(':'); // Menu[0] == 'R' || Menu[0] == 'r' // menu path explicitly declared as relative to library's default menu path
217 }
218
219 if( !m_Library_Menu.is_Empty() )
220 {
221 if( Menu[i].is_Empty() )
222 {
223 Menu[i] = m_Library_Menu;
224 }
225 else
226 {
227 Menu[i] = m_Library_Menu + "|" + Menu[i];
228 }
229 }
230 }
231
232 CSG_String Menus;
233
234 for(int i=0; i<Menu.Get_Count(); i++)
235 {
236 if( i > 0 )
237 {
238 Menus += ";";
239 }
240
241 Menus += Menu[i];
242 }
243
244 return( Menus );
245}
246
247//---------------------------------------------------------
248bool CSG_Tool::has_GUI(void) const
249{
250 return( m_bGUI );
251}
252
253//---------------------------------------------------------
254bool CSG_Tool::has_CMD(void) const
255{
256 return( m_bCMD );
257}
258
259
261// //
262// //
263// //
265
266//---------------------------------------------------------
267bool CSG_Tool::Execute(bool bAddHistory)
268{
269 #define ADD_MESSAGE_EXECUTION(Text, Style) { SG_UI_Msg_Add(Text, true, Style); if( has_GUI() ) { SG_UI_Msg_Add_Execution(Text, true, Style); } }
270
271 //-----------------------------------------------------
272 if( m_bExecutes )
273 {
274 return( false );
275 }
276
277 m_bExecutes = true;
278
279 m_bError_Ignore = false;
280
281 bool bResult = false;
282
283 m_Execution_Info.Clear();
284
285 History_Supplement.Destroy();
286
287 //-----------------------------------------------------
288 if( Parameters.Get_Manager() == &SG_Get_Data_Manager() )
289 {
290 ADD_MESSAGE_EXECUTION(CSG_String::Format("[%s] %s...", Get_Name().c_str(), _TL("Execution started")), SG_UI_MSG_STYLE_SUCCESS);
291 }
292
294
295 if( Parameters.DataObjects_Create() == false )
296 {
297 _Synchronize_DataObjects(); // not all, but some objects might have been created!
298 }
299 else
300 {
301 Parameters.Msg_String(false);
302
303 // SG_UI_Process_Set_Busy(true, CSG_String::Format("%s: %s...", _TL("Executing"), Get_Name().c_str()));
305
307//#if !defined(_DEBUG)
308#define _TOOL_EXCEPTION
309 try
310 {
311//#endif
313
314 bResult = On_Execute();
315
317#ifdef _TOOL_EXCEPTION
318 } // try
319 catch(const std::exception &Exception)
320 {
321 Message_Dlg(Exception.what() , CSG_String::Format("%s | %s", Get_Name().c_str(), _TL("Access violation!")));
322 }
323 catch(...)
324 {
325 Message_Dlg(_TL("unspecified exception"), CSG_String::Format("%s | %s", Get_Name().c_str(), _TL("Access violation!")));
326 }
327 #endif
329
330 CSG_TimeSpan Span = CSG_DateTime::Now() - Started;
331 // SG_UI_Process_Set_Busy(false);
332
333 _Synchronize_DataObjects();
334
335 if( !Process_Get_Okay(false) )
336 {
337 SG_UI_Msg_Add(_TL("Execution has been stopped by user!"), true, SG_UI_MSG_STYLE_BOLD);
338
339 bResult = false;
340 }
341
342 if( bResult && bAddHistory )
343 {
344 _Set_Output_History();
345 }
346
347 //-------------------------------------------------
348 if( is_Interactive() )
349 {
350 if( bResult )
351 {
352 CSG_String Text(CSG_String::Format("\n%s...", _TL("Interactive tool started and is waiting for user input.")));
353
354 SG_UI_Msg_Add (Text, false, SG_UI_MSG_STYLE_BOLD);
356 }
357 else
358 {
359 ADD_MESSAGE_EXECUTION(_TL("Interactive tool initialization failed."), SG_UI_MSG_STYLE_FAILURE);
360 }
361 }
362 else
363 {
364 CSG_String Time =
365 Span.Get_Hours () >= 1 ? (Span.Format("%Hh %Mm %Ss"))
366 : Span.Get_Minutes () >= 1 ? (Span.Format( "%Mm %Ss"))
367 : Span.Get_Seconds () >= 1 ? (Span.Format( "%Ss"))
368 : Span.Get_Milliseconds() >= 1 ? (Span.Format("%l ") + _TL("milliseconds"))
369 : CSG_String(_TL("less than 1 millisecond"));
370
371 if( Parameters.Get_Manager() != &SG_Get_Data_Manager() )
372 {
373 SG_UI_Msg_Add_Execution(CSG_String::Format("\n[%s] %s: %s", Get_Name().c_str(),
374 _TL("execution time"), Time.c_str()),
376 );
377 }
378 else
379 {
380 SG_UI_Msg_Add_Execution(CSG_String::Format("\n__________\n%s %s: %lld %s (%s)\n", _TL("total"),
381 _TL("execution time"), Span.Get_Milliseconds(), _TL("milliseconds"), Time.c_str()),
383 );
384
385 ADD_MESSAGE_EXECUTION(CSG_String::Format("[%s] %s (%s)", Get_Name().c_str(),
386 bResult ? _TL("Execution succeeded") : _TL("Execution failed"), Time.c_str()),
388 );
389 }
390 }
391 }
392
393 //-----------------------------------------------------
394 History_Supplement.Destroy();
395
396 m_bExecutes = false;
397
400
401 return( bResult );
402}
403
404
406// //
407// //
408// //
410
411//---------------------------------------------------------
412bool CSG_Tool::_Synchronize_DataObjects(void)
413{
414 Parameters.DataObjects_Synchronize();
415
416 for(int i=0; i<Get_Parameters_Count(); i++)
417 {
418 Get_Parameters(i)->DataObjects_Synchronize();
419 }
420
421 CSG_Projection Projection;
422
424 {
425 Parameters.DataObjects_Set_Projection(Projection);
426
427 for(int i=0; i<Get_Parameters_Count(); i++)
428 {
429 Get_Parameters(i)->DataObjects_Set_Projection(Projection);
430 }
431
432 return( true );
433 }
434
435 return( false );
436}
437
438//---------------------------------------------------------
440{
441 Projection.Destroy();
442
443 Parameters.DataObjects_Get_Projection(Projection);
444
445 for(int i=0; i<Get_Parameters_Count() && !Projection.is_Okay(); i++)
446 {
447 Get_Parameters(i)->DataObjects_Get_Projection(Projection);
448 }
449
450 return( Projection.is_Okay() );
451}
452
453
455// //
456// Parameters //
457// //
459
460//---------------------------------------------------------
462{
463 CSG_Parameters *pParameters = pParameter ? pParameter ->Get_Parameters() : NULL;
464 CSG_Tool *pTool = pParameters ? pParameters->Get_Tool () : NULL;
465
466 if( pTool )
467 {
468 if( Flags & PARAMETER_CHECK_VALUES )
469 {
470 pTool->On_Parameter_Changed(pParameters, pParameter);
471 }
472
473 if( Flags & PARAMETER_CHECK_ENABLE )
474 {
475 pTool->On_Parameters_Enable(pParameters, pParameter);
476 }
477
478 return( 1 );
479 }
480
481 return( 0 );
482}
483
484//---------------------------------------------------------
486{
487 return( 1 );
488}
489
490//---------------------------------------------------------
492{
493 return( 1 );
494}
495
496
498// //
499// Extra Parameters //
500// //
502
503//---------------------------------------------------------
504CSG_Parameters * CSG_Tool::Add_Parameters(const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description)
505{
506 CSG_Parameters *pParameters = new CSG_Parameters(); // (Name, Description, Identifier);
507
508 pParameters->Create(this, Name, Description, Identifier);
510 pParameters->m_pTool = this;
511
512 m_pParameters.Add(pParameters);
513
514 return( pParameters );
515}
516
517//---------------------------------------------------------
519{
520 for(int i=0; i<Get_Parameters_Count(); i++)
521 {
522 if( Get_Parameters(i)->Cmp_Identifier(Identifier) )
523 {
524 return( Get_Parameters(i) );
525 }
526 }
527
528 return( NULL );
529}
530
531//---------------------------------------------------------
533{
534 CSG_Parameters *pParameters = Get_Parameters(Identifier);
535
536 if( pParameters && (!pParameters->is_Managed() || Dlg_Parameters(pParameters, Get_Name())) )
537 {
538 pParameters->Set_History(History_Supplement);
539
540 return( true );
541 }
542
543 return( false );
544}
545
546
548// //
550
551//---------------------------------------------------------
552bool CSG_Tool::Dlg_Parameters(CSG_Parameters *pParameters, const CSG_String &Caption)
553{
554 return( pParameters ? Dlg_Parameters(*pParameters, Caption) : false );
555}
556
558{
559 return( SG_UI_Dlg_Parameters(&Parameters, Caption.is_Empty() ? Get_Name() : Caption) );
560}
561
562
564// //
566
567//---------------------------------------------------------
568void CSG_Tool::Set_Callback(bool bActive)
569{
570 Parameters.Set_Callback(bActive);
571
572 for(int i=0; i<Get_Parameters_Count(); i++)
573 {
574 Get_Parameters(i)->Set_Callback(bActive);
575 }
576}
577
578//---------------------------------------------------------
580{
581 Parameters.Set_Manager(pManager);
582
583 for(int i=0; i<Get_Parameters_Count(); i++)
584 {
585 Get_Parameters(i)->Set_Manager(pManager);
586 }
587
588 return( true );
589}
590
591//---------------------------------------------------------
593{
594 return( Parameters.Get_Manager() );
595}
596
597//---------------------------------------------------------
599{
601
602 return( Get_Manager() );
603}
604
605//---------------------------------------------------------
606bool CSG_Tool::Delete_Manager(bool bDetachData, bool bReset)
607{
608 CSG_Data_Manager *pManager = Get_Manager();
609
610 if( pManager && pManager != &SG_Get_Data_Manager() )
611 {
612 pManager->Delete(bDetachData);
613
614 delete(pManager);
615
616 return( bReset ? Set_Manager(&SG_Get_Data_Manager()) : Set_Manager(NULL) );
617 }
618
619 return( false );
620}
621
622
624// //
625// //
626// //
628
629//---------------------------------------------------------
631{
632 Parameters.Push(pManager);
633
634 for(int i=0; i<Get_Parameters_Count(); i++)
635 {
636 Get_Parameters(i)->Push(pManager);
637 }
638
639 return( true );
640}
641
642//---------------------------------------------------------
644{
645 Parameters.Pop();
646
647 for(int i=0; i<Get_Parameters_Count(); i++)
648 {
649 Get_Parameters(i)->Pop();
650 }
651
652 return( true );
653}
654
655
657// //
658// Progress //
659// //
661
662//---------------------------------------------------------
664{
665 m_bShow_Progress = bOn;
666}
667
668//---------------------------------------------------------
669bool CSG_Tool::Set_Progress(int Position, int Range) const
670{
671 return( Set_Progress((double)Position / (double)Range) );
672}
673
674//---------------------------------------------------------
675bool CSG_Tool::Set_Progress(sLong Position, sLong Range) const
676{
677 return( Set_Progress((double)Position / (double)Range) );
678}
679
680//---------------------------------------------------------
681bool CSG_Tool::Set_Progress(double Position, double Range) const
682{
683 return( m_bShow_Progress ? SG_UI_Process_Set_Progress(Position, Range) : Process_Get_Okay(false) );
684}
685
686//---------------------------------------------------------
687bool CSG_Tool::Stop_Execution(bool bDialog)
688{
689 m_bExecutes = false;
690
691 return( SG_UI_Stop_Execution(bDialog) );
692}
693
694
696// //
697// Message //
698// //
700
701//---------------------------------------------------------
702void CSG_Tool::Message_Dlg(const CSG_String &Text, const SG_Char *Caption)
703{
704 SG_UI_Dlg_Message(Text, Caption && Caption[0] != '\0' ? Caption : Get_Name().c_str());
705}
706
707//---------------------------------------------------------
708bool CSG_Tool::Message_Dlg_Confirm(const CSG_String &Text, const SG_Char *Caption)
709{
710 return( SG_UI_Dlg_Continue(Text, Caption && Caption[0] != '\0' ? Caption : Get_Name().c_str()) );
711}
712
713//---------------------------------------------------------
715{
716 switch( Error_ID )
717 {
718 default:
719 return( Error_Set(_TL("Unknown Error")) );
720
722 return( Error_Set(_TL("Calculation Error")) );
723 }
724}
725
726//---------------------------------------------------------
728{
730
731 m_Execution_Info += "\n____\n" + Text;
732
733 if( SG_UI_Process_Get_Okay(false) && !m_bError_Ignore )
734 {
735 switch( SG_UI_Dlg_Error(Text, CSG_String::Format("%s: %s?", _TL("Error"), _TL("Ignore"))) )
736 {
737 default:
739 break;
740
741 case 1:
742 m_bError_Ignore = true;
743 break;
744 }
745 }
746
747 return( SG_UI_Process_Get_Okay(false) );
748}
749
750//---------------------------------------------------------
751bool CSG_Tool::Error_Fmt(const char *Format, ...)
752{
753 wxString _s;
754
755 va_list argptr;
756
757#ifdef _SAGA_LINUX
758 // workaround as we only use wide characters
759 // since wx 2.9.4 so interpret strings as multibyte
760 wxString _Format(Format); _Format.Replace("%s", "%ls");
761 va_start(argptr, _Format);
762 _s.PrintfV(_Format, argptr);
763#else
764 va_start(argptr, Format);
765 _s.PrintfV(Format, argptr);
766#endif
767
768 va_end(argptr);
769
770 CSG_String s(&_s);
771
772 return( Error_Set(s) );
773}
774
775//---------------------------------------------------------
776bool CSG_Tool::Error_Fmt(const wchar_t *Format, ...)
777{
778 wxString _s;
779
780 va_list argptr;
781
782#ifdef _SAGA_LINUX
783 // workaround as we only use wide characters
784 // since wx 2.9.4 so interpret strings as multibyte
785 wxString _Format(Format); _Format.Replace("%s", "%ls");
786 va_start(argptr, _Format);
787 _s.PrintfV(_Format, argptr);
788#else
789 va_start(argptr, Format);
790 _s.PrintfV(Format, argptr);
791#endif
792
793 va_end(argptr);
794
795 CSG_String s(&_s);
796
797 return( Error_Set(s) );
798}
799
800
802// //
803// DataObjects / GUI Interaction //
804// //
806
807//---------------------------------------------------------
808bool CSG_Tool::DataObject_Add(CSG_Data_Object *pDataObject, bool bShow)
809{
810 if( Parameters.Get_Manager() )
811 {
812 Parameters.Get_Manager()->Add(pDataObject);
813 }
814
815 if( Parameters.Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
816 {
818 }
819
820 return( true );
821}
822
823//---------------------------------------------------------
825{
826 for(int i=0; i<Parameters.Get_Count(); i++)
827 {
828 if( Parameters(i)->is_Output() )
829 {
830 if( Parameters(i)->is_DataObject() )
831 {
832 DataObject_Update(Parameters(i)->asDataObject(), false);
833 }
834 else if( Parameters(i)->is_DataObject_List() )
835 {
836 for(int j=0; j<Parameters(i)->asList()->Get_Item_Count(); j++)
837 {
838 DataObject_Update(Parameters(i)->asList()->Get_Item(j), false);
839 }
840 }
841 }
842 }
843
844 return( true );
845}
846
847
849// //
850// Static Data Message/Progress Functions //
851// //
853
854//---------------------------------------------------------
856{
857 return( SG_UI_Process_Get_Okay(bBlink) );
858}
859
860//---------------------------------------------------------
862{
864}
865
866//---------------------------------------------------------
867void CSG_Tool::Process_Set_Text(const char *Format, ...)
868{
869 wxString _s;
870
871 va_list argptr;
872
873 #ifdef _SAGA_LINUX
874 // workaround as we only use wide characters
875 // since wx 2.9.4 so interpret strings as multibyte
876 wxString _Format(Format); _Format.Replace("%s", "%ls");
877 va_start(argptr, _Format);
878 _s.PrintfV(_Format, argptr);
879 #else
880 va_start(argptr, Format);
881 _s.PrintfV(Format, argptr);
882 #endif
883
884 va_end(argptr);
885
886 CSG_String s(&_s);
887
889}
890
891//---------------------------------------------------------
892void CSG_Tool::Process_Set_Text(const wchar_t *Format, ...)
893{
894 wxString _s;
895
896 va_list argptr;
897
898 #ifdef _SAGA_LINUX
899 // workaround as we only use wide characters
900 // since wx 2.9.4 so interpret strings as multibyte
901 wxString _Format(Format); _Format.Replace("%s", "%ls");
902 va_start(argptr, _Format);
903 _s.PrintfV(_Format, argptr);
904 #else
905 va_start(argptr, Format);
906 _s.PrintfV(Format, argptr);
907 #endif
908
909 va_end(argptr);
910
911 CSG_String s(&_s);
912
914}
915
916//---------------------------------------------------------
917void CSG_Tool::Message_Add(const CSG_String &Text, bool bNewLine)
918{
919 SG_UI_Msg_Add_Execution(Text, bNewLine);
920
921 if( bNewLine )
922 {
923 m_Execution_Info += "\n";
924 }
925
926 m_Execution_Info += Text;
927}
928
929//---------------------------------------------------------
930void CSG_Tool::Message_Fmt(const char *Format, ...)
931{
932 wxString _s;
933
934 va_list argptr;
935
936 #ifdef _SAGA_LINUX
937 // workaround as we only use wide characters
938 // since wx 2.9.4 so interpret strings as multibyte
939 wxString _Format(Format); _Format.Replace("%s", "%ls");
940 va_start(argptr, _Format);
941 _s.PrintfV(_Format, argptr);
942 #else
943 va_start(argptr, Format);
944 _s.PrintfV(Format, argptr);
945 #endif
946
947 va_end(argptr);
948
949 CSG_String s(&_s);
950
951 Message_Add(s, false);
952}
953
954//---------------------------------------------------------
955void CSG_Tool::Message_Fmt(const wchar_t *Format, ...)
956{
957 wxString _s;
958
959 va_list argptr;
960
961 #ifdef _SAGA_LINUX
962 // workaround as we only use wide characters
963 // since wx 2.9.4 so interpret strings as multibyte
964 wxString _Format(Format); _Format.Replace("%s", "%ls");
965 va_start(argptr, _Format);
966 _s.PrintfV(_Format, argptr);
967 #else
968 va_start(argptr, Format);
969 _s.PrintfV(Format, argptr);
970 #endif
971
972 va_end(argptr);
973
974 CSG_String s(&_s);
975
976 Message_Add(s, false);
977}
978
979
981// //
982// Static Data Object Property Functions //
983// //
985
986//---------------------------------------------------------
988{
989 return( SG_UI_DataObject_Update(pDataObject, Show, NULL) );
990}
991
992bool CSG_Tool::DataObject_Update(CSG_Data_Object *pDataObject, double Minimum, double Maximum, int Show)
993{
995
996 return( DataObject_Get_Parameters(pDataObject, P)
997 && P.Set_Parameter("STRETCH_DEFAULT" , 3 ) // manual
998 && P.Set_Parameter("METRIC_ZRANGE.MIN", Minimum)
999 && P.Set_Parameter("METRIC_ZRANGE.MAX", Maximum)
1000 && SG_UI_DataObject_Update(pDataObject, Show, &P)
1001 );
1002}
1003
1004//---------------------------------------------------------
1006{
1007 return( SG_UI_DataObject_Colors_Get(pDataObject, &Colors) );
1008}
1009
1011{
1012 CSG_Colors c; return( c.Create(Colors) && SG_UI_DataObject_Colors_Set(pDataObject, &c) );
1013}
1014
1015bool CSG_Tool::DataObject_Set_Colors(CSG_Data_Object *pDataObject, int nColors, int Colors, bool bRevert)
1016{
1017 CSG_Colors c; return( c.Set_Predefined(Colors, bRevert, nColors) && SG_UI_DataObject_Colors_Set(pDataObject, &c) );
1018}
1019
1020bool CSG_Tool::DataObject_Set_Colors(CSG_Data_Object *pDataObject, const CSG_String &Colors, int nColors, bool bRevert)
1021{
1022 CSG_Colors c; return( c.Set_Predefined(Colors, bRevert, nColors) && SG_UI_DataObject_Colors_Set(pDataObject, &c) );
1023}
1024
1025//---------------------------------------------------------
1030
1035
1037{
1038 if( pDataObject == pCopy )
1039 {
1040 return( true );
1041 }
1042
1044
1045 if( DataObject_Get_Parameters(pCopy, P) )
1046 {
1047 P.Del_Parameter("OBJECT_NODATA" );
1048 P.Del_Parameter("OBJECT_Z_FACTOR");
1049 P.Del_Parameter("OBJECT_Z_OFFSET");
1050
1051 return( DataObject_Set_Parameters(pDataObject, P) );
1052 }
1053
1054 return( false );
1055}
1056
1057//---------------------------------------------------------
1059{
1060 static CSG_Parameters P;
1061
1062 return( DataObject_Get_Parameters(pDataObject, P) ? P(ID) : NULL );
1063}
1064
1066{
1068
1069 return( P._Add(pParameter) != NULL && DataObject_Set_Parameters(pDataObject, P) );
1070}
1071
1073{
1074 CSG_Parameter *pParameter = DataObject_Get_Parameter(pCopy, ID);
1075
1076 return( DataObject_Set_Parameter(pDataObject, pParameter) );
1077}
1078
1079bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, int Value)
1080{
1082
1083 if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1084 {
1085 return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1086 }
1087
1088 return( false );
1089}
1090
1091bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double Value)
1092{
1094
1095 if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1096 {
1097 return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1098 }
1099
1100 return( false );
1101}
1102
1103bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, void *Value)
1104{
1106
1107 if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1108 {
1109 return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1110 }
1111
1112 return( false );
1113}
1114
1115bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, const SG_Char *Value)
1116{
1118
1119 if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1120 {
1121 return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1122 }
1123
1124 return( false );
1125}
1126
1127bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double loVal, double hiVal) // Range Parameter
1128{
1130
1131 if( DataObject_Get_Parameters(pDataObject, P) && P(ID) && P(ID)->Get_Type() == PARAMETER_TYPE_Range )
1132 {
1133 return( P(ID)->asRange()->Set_Range(loVal, hiVal) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1134 }
1135
1136 return( false );
1137}
1138
1139
1141// //
1143
1144//---------------------------------------------------------
1145#define INIT_STRETCH_OPTIONS(method) { if( !pDataObject || (pDataObject->asTable(true) && (Field < 0 || Field >= pDataObject->asTable(true)->Get_Field_Count())) ) { return( false ); }\
1146 if( Colors >= 0 ) { DataObject_Set_Colors(pDataObject, -1, Colors); }\
1147 DataObject_Set_Parameter(pDataObject, "COLORS_TYPE" , 3); /* graduated colors */\
1148 DataObject_Set_Parameter(pDataObject, "STRETCH_DEFAULT" , method);\
1149 DataObject_Set_Parameter(pDataObject, "METRIC_SCALE_MODE", Interval_Mode);\
1150 DataObject_Set_Parameter(pDataObject, "METRIC_SCALE_LOG" , Interval_Log );\
1151 if( pDataObject->asTable(true) )\
1152 { DataObject_Set_Parameter(pDataObject, "METRIC_FIELD" , Field);\
1153 DataObject_Set_Parameter(pDataObject, "METRIC_MORMAL", pDataObject->asTable(true)->Get_Field_Count());\
1154 }\
1155}
1156
1157//---------------------------------------------------------
1158bool CSG_Tool::DataObject_Set_Stretch_Linear(CSG_Data_Object *pDataObject, int Field, double Minimum, double Maximum, int Interval_Mode, double Interval_Log, int Colors, bool bUpdateNow)
1159{
1161
1162 DataObject_Set_Parameter(pDataObject, "STRETCH_LINEAR.MIN", Minimum);
1163 DataObject_Set_Parameter(pDataObject, "STRETCH_LINEAR.MAX", Maximum);
1164
1165 return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1166}
1167
1168//---------------------------------------------------------
1169bool CSG_Tool::DataObject_Set_Stretch_StdDev(CSG_Data_Object *pDataObject, int Field, double StdDev, bool bKeepInRange, int Interval_Mode, double Interval_Log, int Colors, bool bUpdateNow)
1170{
1172
1173 DataObject_Set_Parameter(pDataObject, "STRETCH_STDDEV" , StdDev );
1174 DataObject_Set_Parameter(pDataObject, "STRETCH_INRANGE", bKeepInRange);
1175 DataObject_Update(pDataObject);
1176
1177 return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1178}
1179
1180//---------------------------------------------------------
1181bool CSG_Tool::DataObject_Set_Stretch_Percentile(CSG_Data_Object *pDataObject, int Field, double Minimum, double Maximum, int Interval_Mode, double Interval_Log, int Colors, bool bUpdateNow)
1182{
1184
1185 DataObject_Set_Parameter(pDataObject, "STRETCH_PCTL.MIN", Minimum);
1186 DataObject_Set_Parameter(pDataObject, "STRETCH_PCTL.MAX", Maximum);
1187
1188 return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1189}
1190
1191//---------------------------------------------------------
1192bool CSG_Tool::DataObject_Set_Stretch(CSG_Data_Object *pDataObject, int Field, double Minimum, double Maximum, int Interval_Mode, double Interval_Log, int Colors, bool bUpdateNow)
1193{
1195
1196 DataObject_Set_Parameter(pDataObject, "METRIC_ZRANGE.MIN", Minimum);
1197 DataObject_Set_Parameter(pDataObject, "METRIC_ZRANGE.MAX", Maximum);
1198
1199 return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1200}
1201
1202
1204// //
1206
1207//---------------------------------------------------------
1208#define INIT_CLASSIFY_OPTIONS(method) if( !pDataObject || (pDataObject->asTable(true) && (Field < 0 || Field >= pDataObject->asTable(true)->Get_Field_Count())) ) { return( false ); }\
1209 CSG_MetaData Options; Options.Add_Child("METHOD", method); Options.Add_Child("COLORS", Colors); Options.Add_Child("FIELD", Field);
1210
1211//---------------------------------------------------------
1212bool CSG_Tool::DataObject_Classify_Unique(CSG_Data_Object *pDataObject, int Field, int maxClasses, int Colors)
1213{
1215
1216 Options.Add_Child("MAXCLASSES", maxClasses);
1217
1218 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1219}
1220
1221//---------------------------------------------------------
1222bool CSG_Tool::DataObject_Classify_Equal(CSG_Data_Object *pDataObject, int Field, int Classes, int Colors)
1223{
1225
1226 Options.Add_Child("CLASSES", Classes);
1227
1228 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1229}
1230
1231//---------------------------------------------------------
1232bool CSG_Tool::DataObject_Classify_Defined(CSG_Data_Object *pDataObject, int Field, double Interval, bool bOffset, double Offset, int Colors)
1233{
1235
1236 Options.Add_Child("INTERVAL", Interval); if( bOffset ) { Options.Add_Child("OFFSET", Offset); }
1237
1238 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1239}
1240
1241//---------------------------------------------------------
1242bool CSG_Tool::DataObject_Classify_Quantile(CSG_Data_Object *pDataObject, int Field, int Classes, bool bHistogram, int Colors)
1243{
1245
1246 Options.Add_Child("CLASSES", Classes); Options.Add_Child("HISTOGRAM", bHistogram ? 1 : 0);
1247
1248 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1249}
1250
1251//---------------------------------------------------------
1252bool CSG_Tool::DataObject_Classify_Geometric(CSG_Data_Object *pDataObject, int Field, int Classes, bool bIncreasing, int Colors)
1253{
1255
1256 Options.Add_Child("CLASSES", Classes); Options.Add_Child("INCREASING", bIncreasing ? 1 : 0);
1257
1258 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1259}
1260
1261//---------------------------------------------------------
1262bool CSG_Tool::DataObject_Classify_Natural(CSG_Data_Object *pDataObject, int Field, int Classes, int Colors)
1263{
1265
1266 Options.Add_Child("CLASSES", Classes);
1267
1268 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1269}
1270
1271//---------------------------------------------------------
1272bool CSG_Tool::DataObject_Classify_StdDev(CSG_Data_Object *pDataObject, int Field, double StdDev, double StdDev_Max, int Colors)
1273{
1275
1276 Options.Add_Child("STDDEV", StdDev); Options.Add_Child("STDDEV_MAX", StdDev_Max);
1277
1278 return( SG_UI_DataObject_Classify(pDataObject, Options) );
1279}
1280
1281
1283// //
1284// //
1285// //
1287
1288//---------------------------------------------------------
1292//---------------------------------------------------------
1293bool CSG_Tool::Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue) { return( Parameters.Set_Parameter(ID, pValue) ); }
1294bool CSG_Tool::Set_Parameter(const char *ID, CSG_Parameter *pValue) { return( Parameters.Set_Parameter(ID, pValue) ); }
1295bool CSG_Tool::Set_Parameter(const wchar_t *ID, CSG_Parameter *pValue) { return( Parameters.Set_Parameter(ID, pValue) ); }
1296
1297//---------------------------------------------------------
1301//---------------------------------------------------------
1302bool CSG_Tool::Set_Parameter(const CSG_String &ID, int Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1303bool CSG_Tool::Set_Parameter(const char *ID, int Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1304bool CSG_Tool::Set_Parameter(const wchar_t *ID, int Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1305
1306//---------------------------------------------------------
1310//---------------------------------------------------------
1311bool CSG_Tool::Set_Parameter(const CSG_String &ID, double Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1312bool CSG_Tool::Set_Parameter(const char *ID, double Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1313bool CSG_Tool::Set_Parameter(const wchar_t *ID, double Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1314
1315//---------------------------------------------------------
1319//---------------------------------------------------------
1320bool CSG_Tool::Set_Parameter(const CSG_String &ID, void *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1321bool CSG_Tool::Set_Parameter(const char *ID, void *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1322bool CSG_Tool::Set_Parameter(const wchar_t *ID, void *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1323
1324//---------------------------------------------------------
1328//---------------------------------------------------------
1329bool CSG_Tool::Set_Parameter(const CSG_String &ID, const CSG_String &Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1330bool CSG_Tool::Set_Parameter(const char *ID, const CSG_String &Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1331bool CSG_Tool::Set_Parameter(const wchar_t *ID, const CSG_String &Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1332
1333//---------------------------------------------------------
1337//---------------------------------------------------------
1338bool CSG_Tool::Set_Parameter(const CSG_String &ID, const char *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1339bool CSG_Tool::Set_Parameter(const char *ID, const char *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1340bool CSG_Tool::Set_Parameter(const wchar_t *ID, const char *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1341
1342//---------------------------------------------------------
1346//---------------------------------------------------------
1347bool CSG_Tool::Set_Parameter(const CSG_String &ID, const wchar_t *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1348bool CSG_Tool::Set_Parameter(const char *ID, const wchar_t *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1349bool CSG_Tool::Set_Parameter(const wchar_t *ID, const wchar_t *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1350
1351
1353// //
1354// //
1355// //
1357
1358//---------------------------------------------------------
1364bool CSG_Tool::Reset(bool bManager)
1365{
1367
1368 if( bManager )
1369 {
1370 Reset_Manager();
1371 }
1372
1373 for(int i=0; i<Get_Parameters_Count(); i++)
1374 {
1376 }
1377
1378 return( Parameters.Restore_Defaults(true) );
1379}
1380
1381//---------------------------------------------------------
1387{
1388 return( Set_Manager(&SG_Get_Data_Manager()) );
1389}
1390
1391//---------------------------------------------------------
1397{
1398 for(int i=0; i<Get_Parameters_Count(); i++)
1399 {
1401 }
1402
1403 return( Parameters.Reset_Grid_System() );
1404}
1405
1406//---------------------------------------------------------
1412{
1413 return( Parameters.Set_Grid_System(System) );
1414}
1415
1416//---------------------------------------------------------
1422{
1423 return( Parameters.Get_Grid_System() );
1424}
1425
1426
1428// //
1429// //
1430// //
1432
1433//---------------------------------------------------------
1435{
1436 _Update_Parameter_States(&Parameters);
1437
1438 for(int i=0; i<Get_Parameters_Count(); i++)
1439 {
1440 _Update_Parameter_States(Get_Parameters(i));
1441 }
1442
1443 return( true );
1444}
1445
1446//---------------------------------------------------------
1447void CSG_Tool::_Update_Parameter_States(CSG_Parameters *pParameters)
1448{
1449 if( pParameters )
1450 {
1451 for(int i=0; i<pParameters->Get_Count(); i++)
1452 {
1453 CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
1454
1455 if( pParameter->Get_Type() == PARAMETER_TYPE_Parameters )
1456 {
1457 _Update_Parameter_States(pParameter->asParameters());
1458 }
1459 else
1460 {
1461 On_Parameters_Enable(pParameters, pParameter);
1462 }
1463 }
1464 }
1465}
1466
1467
1469// //
1470// Script //
1471// //
1473
1474//---------------------------------------------------------
1475CSG_String CSG_Tool::Get_Script(Script_Format Format, bool bHeader, int Arguments, bool bWrapArgs)
1476{
1477 switch( Format )
1478 {
1479 case Script_Format::CMD_Shell : return( _Get_Script_CMD ( bHeader, Arguments > 0, bWrapArgs, false ) );
1480 case Script_Format::CMD_Batch : return( _Get_Script_CMD ( bHeader, Arguments > 0, bWrapArgs, true ) );
1481 case Script_Format::CMD_Usage : return( _Get_Script_CMD_Usage ( ) );
1482
1483 case Script_Format::Toolchain : return( CSG_Tool_Chain::Get_Script(this, bHeader, Arguments > 0 ) );
1484
1485 case Script_Format::Python : return( _Get_Script_Python ( bHeader, Arguments > 0 ) );
1486
1487 case Script_Format::Python_Wrapper_Func_Name : return( _Get_Script_Python_Wrap ( bHeader, true , false, 1, bWrapArgs ) );
1488 case Script_Format::Python_Wrapper_Func_ID : return( _Get_Script_Python_Wrap ( bHeader, false, false, 1, bWrapArgs ) );
1489
1490 case Script_Format::Python_Wrapper_Call_Name : return( _Get_Script_Python_Wrap ( bHeader, true , true , Arguments, bWrapArgs ) );
1491 case Script_Format::Python_Wrapper_Call_ID : return( _Get_Script_Python_Wrap ( bHeader, false, true , Arguments, bWrapArgs ) );
1492
1493 case Script_Format::Markdown_Table : return( _Get_Script_Markdown ( bHeader, Arguments ) );
1494 }
1495
1496 return( "" );
1497}
1498
1499
1501// //
1503
1504//---------------------------------------------------------
1505CSG_String CSG_Tool::_Get_Script_CMD(bool bHeader, bool bAllArguments, bool bWrapArgs, bool bBatch)
1506{
1507 CSG_String Script;
1508
1509 if( bHeader )
1510 {
1511 if( bBatch ) // DOS/Windows Batch Script
1512 {
1513 Script += "@ECHO OFF\n\n";
1514 Script += "PUSHD %~dp0\n\n";
1515 Script += "REM SET SAGA_TLB=C:\\MyTools\n\n";
1516 Script += "SET SAGA_CMD=" + SG_UI_Get_Application_Path(true) + "saga_cmd.exe\n\n";
1517 Script += "REM Tool: " + Get_Name() + "\n\n";
1518 Script += "%SAGA_CMD%";
1519 }
1520 else // Bash Shell Script
1521 {
1522 Script += "#!/bin/bash\n\n";
1523 Script += "# export SAGA_TLB=~/mytools\n\n";
1524 Script += "# tool: " + Get_Name() + "\n\n";
1525 Script += "saga_cmd";
1526 }
1527 }
1528 else
1529 {
1530 Script += "saga_cmd";
1531 }
1532
1533 //-----------------------------------------------------
1534 Script += Get_Library().Contains(" ") // white space? use quotation marks!
1535 ? " \"" + Get_Library() + "\""
1536 : " " + Get_Library();
1537
1538 Script += Get_ID().Contains (" ") // white space? use quotation marks!
1539 ? " \"" + Get_ID () + "\""
1540 : " " + Get_ID ();
1541
1542 _Get_Script_CMD(Script, Get_Parameters(), bAllArguments, bWrapArgs, bBatch);
1543
1544 for(int i=0; i<Get_Parameters_Count(); i++)
1545 {
1546 _Get_Script_CMD(Script, Get_Parameters(i), bAllArguments, bWrapArgs, bBatch);
1547 }
1548
1549 //-----------------------------------------------------
1550 if( bHeader )
1551 {
1552 Script += bBatch ? "\n\nPAUSE\n" : "\n";
1553 }
1554
1555 return( Script );
1556}
1557
1558//---------------------------------------------------------
1559void CSG_Tool::_Get_Script_CMD(CSG_String &Script, CSG_Parameters *pParameters, bool bAllArguments, bool bWrapArgs, bool bBatch)
1560{
1561 #define GET_ID1(p) (p->Get_Parameters()->Get_Identifier().Length() > 0 \
1562 ? CSG_String::Format("%s_%s", p->Get_Parameters()->Get_Identifier().c_str(), p->Get_Identifier()) \
1563 : CSG_String::Format(p->Get_Identifier())).c_str()
1564
1565 #define GET_ID2(p, s) CSG_String::Format("%s_%s", GET_ID1(p), s).c_str()
1566
1567 const char *Prefix = !bWrapArgs ? " -" : bBatch ? " ^\n -" : " \\\n -";
1568 const char *StrFmt = bBatch ? "%s=\"%s\"" : "%s=\\\"\"%s\"\\\"";
1569
1570 //-----------------------------------------------------
1571 for(int iParameter=0; iParameter<pParameters->Get_Count(); iParameter++)
1572 {
1573 CSG_Parameter *p = pParameters->Get_Parameter(iParameter);
1574
1575 if( !bAllArguments && (!p->is_Enabled(false) || p->is_Information() || !p->do_UseInCMD()) )
1576 {
1577 continue;
1578 }
1579
1580 switch( p->Get_Type() )
1581 {
1582 default:
1583 break;
1584
1585 case PARAMETER_TYPE_Bool :
1586 Script += Prefix + CSG_String::Format("%s=%d", GET_ID1(p), p->asBool() ? 1 : 0);
1587 break;
1588
1589 case PARAMETER_TYPE_Int :
1593 Script += Prefix + CSG_String::Format("%s=%d", GET_ID1(p), p->asInt());
1594 break;
1595
1598 if( p->asString() && *p->asString() )
1599 {
1600 Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->asString());
1601 }
1602 break;
1603
1605 Script += Prefix + CSG_String::Format("%s=\"%s\"", GET_ID1(p), SG_Color_To_Text(p->asColor()).c_str());
1606 break;
1607
1610 Script += Prefix + CSG_String::Format("%s=%g", GET_ID1(p), p->asDouble());
1611 break;
1612
1614 Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T("MIN")), p->asRange()->Get_Min());
1615 Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T("MAX")), p->asRange()->Get_Max());
1616 break;
1617
1619 if( ((CSG_Parameter_String *)p)->is_Password() )
1620 {
1621 Script += Prefix + CSG_String::Format("%s=\"***\"", GET_ID1(p));
1622 break;
1623 }
1624
1625 case PARAMETER_TYPE_Date :
1626 case PARAMETER_TYPE_Text :
1628 Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->asString());
1629 break;
1630
1632 Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->asString());
1633 break;
1634
1636 if( p->Get_Children_Count() == 0 )
1637 {
1638 Script += Prefix + CSG_String::Format("%s=%d", GET_ID2(p, SG_T("NX")), p->asGrid_System()->Get_NX ());
1639 Script += Prefix + CSG_String::Format("%s=%d", GET_ID2(p, SG_T("NY")), p->asGrid_System()->Get_NY ());
1640 Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T( "X")), p->asGrid_System()->Get_XMin ());
1641 Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T( "Y")), p->asGrid_System()->Get_YMin ());
1642 Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T( "D")), p->asGrid_System()->Get_Cellsize());
1643 }
1644 break;
1645
1647 case PARAMETER_TYPE_Grid :
1651 case PARAMETER_TYPE_TIN :
1653 if( p->is_Input() )
1654 {
1655 Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), SG_Get_Data_Manager().Exists(p->asDataObject()) && p->asDataObject()->Get_File_Name() ? p->asDataObject()->Get_File_Name() : SG_T("input file"));
1656 }
1657 else
1658 {
1659 CSG_String File(p->Get_Name());
1660
1661 switch( p->Get_DataObject_Type() )
1662 {
1663 case SG_DATAOBJECT_TYPE_Grid : File += ".sg-grd-z"; break;
1664 case SG_DATAOBJECT_TYPE_Grids : File += ".sg-gds-z"; break;
1665 case SG_DATAOBJECT_TYPE_Table : File += ".txt" ; break;
1666 case SG_DATAOBJECT_TYPE_Shapes : File += ".geojson" ; break;
1667 case SG_DATAOBJECT_TYPE_PointCloud: File += ".sg-pts-z"; break;
1668 case SG_DATAOBJECT_TYPE_TIN : File += ".geojson" ; break;
1669 default : File += ".dat" ; break;
1670 }
1671
1672 Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), File.c_str());
1673 }
1674 break;
1675
1682 if( p->is_Input() )
1683 {
1684 Script += Prefix + CSG_String::Format("%s=", GET_ID1(p));
1685
1686 if( p->asList()->Get_Item_Count() == 0 )
1687 {
1688 Script += "file(s)";
1689 }
1690 else
1691 {
1692 Script += SG_File_Exists(p->asList()->Get_Item(0)->Get_File_Name())
1693 ? p->asList()->Get_Item(0)->Get_File_Name() : _TL("memory");
1694
1695 for(int iObject=1; iObject<p->asList()->Get_Item_Count(); iObject++)
1696 {
1697 Script += ";";
1698 Script += SG_File_Exists(p->asList()->Get_Item(iObject)->Get_File_Name())
1699 ? p->asList()->Get_Item(iObject)->Get_File_Name() : _TL("memory");
1700 }
1701 }
1702 }
1703 else
1704 {
1705 Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->Get_Name());
1706 }
1707 break;
1708 }
1709 }
1710}
1711
1712
1714// //
1716
1717//---------------------------------------------------------
1718CSG_String CSG_Tool::_Get_Script_CMD_Usage(void)
1719{
1720 wxCmdLineParser Parser; Parser.SetSwitchChars("-");
1721
1722 _Get_Script_CMD_Usage(Get_Parameters(), Parser);
1723
1724 for(int i=0; i<Get_Parameters_Count(); i++)
1725 {
1726 _Get_Script_CMD_Usage(Get_Parameters(i), Parser);
1727 }
1728
1729 wxString Usage = wxString::Format("\nUsage: saga_cmd %s %s %s", Get_Library().c_str(), Get_ID().c_str(),
1730 Parser.GetUsageString().AfterFirst(' ').AfterFirst(' ')
1731 );
1732
1733 CSG_String _Usage(&Usage);
1734
1735 return( _Usage );
1736}
1737
1738//---------------------------------------------------------
1739void CSG_Tool::_Get_Script_CMD_Usage(CSG_Parameters *pParameters, wxCmdLineParser &Parser)
1740{
1741 for(int i=0; i<pParameters->Get_Count(); i++)
1742 {
1743 CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
1744
1745 //-------------------------------------------------
1746 if( pParameter->is_DataObject() ) // reset data object parameters, avoids problems when tool is called more than once without un-/reloading
1747 {
1748 pParameter->Set_Value(DATAOBJECT_NOTSET);
1749 }
1750 else if( pParameter->is_DataObject_List() )
1751 {
1752 pParameter->asList()->Del_Items();
1753 }
1754
1755 //-------------------------------------------------
1756 if( pParameter->do_UseInCMD() == false )
1757 {
1758 continue;
1759 }
1760
1761 wxString Description = pParameter->Get_Description(
1763 ).c_str();
1764
1765 Description.Replace("\xb", ""); // unicode problem: quick'n'dirty bug fix, to be replaced
1766
1767 wxString ID(pParameter->Get_CmdID().c_str());
1768
1769 if( pParameter->is_Input() || pParameter->is_Output() )
1770 {
1771 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_NEEDS_SEPARATOR|wxCMD_LINE_PARAM_OPTIONAL);
1772 }
1773
1774 //-------------------------------------------------
1775 else if( pParameter->is_Option() && !pParameter->is_Information() )
1776 {
1777 switch( pParameter->Get_Type() )
1778 {
1780 _Get_Script_CMD_Usage(pParameter->asParameters(), Parser);
1781 break;
1782
1783 case PARAMETER_TYPE_Bool :
1784 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1785 break;
1786
1787 case PARAMETER_TYPE_Int :
1788 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
1789 break;
1790
1796 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1797 break;
1798
1801 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1802 break;
1803
1804 case PARAMETER_TYPE_Date :
1805 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_DATE , wxCMD_LINE_PARAM_OPTIONAL);
1806 break;
1807
1809 Parser.AddOption(ID + "_MIN", wxEmptyString, Description, wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1810 Parser.AddOption(ID + "_MAX", wxEmptyString, Description, wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1811 break;
1812
1814 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1815 break;
1816
1818 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1819 break;
1820
1822 case PARAMETER_TYPE_Text :
1824 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1825 break;
1826
1828 Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1829 break;
1830
1832 if( pParameter->Get_Children_Count() == 0 )
1833 {
1834 Parser.AddOption(ID + "_D" , wxEmptyString, _TL("Cell Size" ), wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1835 Parser.AddOption(ID + "_X" , wxEmptyString, _TL("Lower Left Center Cell X-Coordinate"), wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1836 Parser.AddOption(ID + "_Y" , wxEmptyString, _TL("Lower Left Center Cell Y-Coordinate"), wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1837 Parser.AddOption(ID + "_NX" , wxEmptyString, _TL("Number of Columns" ), wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
1838 Parser.AddOption(ID + "_NY" , wxEmptyString, _TL("Number of Rows" ), wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
1839 Parser.AddOption(ID + "_FILE", wxEmptyString, _TL("Grid File" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1840 }
1841 break;
1842
1843 default:
1844 break;
1845 }
1846 }
1847 }
1848}
1849
1850
1852// //
1854
1855//---------------------------------------------------------
1856CSG_String CSG_Tool::_Get_Script_Python(bool bHeader, bool bAllArguments)
1857{
1858 CSG_String Script, Name(Get_Name());
1859
1860 Name.Replace(" ", "_");
1861 Name.Replace("(", "");
1862 Name.Replace(")", "");
1863 Name.Replace("[", "");
1864 Name.Replace("]", "");
1865 Name.Replace(".", "");
1866 Name.Replace(",", "");
1867 Name.Replace("/", "");
1868 Name.Replace("-", "");
1869
1870 //-----------------------------------------------------
1871 if( bHeader )
1872 {
1873 Script += "#! /usr/bin/env python\n";
1874 Script += "\n";
1875 Script += "#_________________________________________\n";
1876 Script += "##########################################\n";
1877 Script += "\n";
1878#ifdef _SAGA_MSW
1879 CSG_String AppPath = SG_UI_Get_Application_Path(true); AppPath.Replace("\\", "/");
1880 Script += "# Initialize the environment...\n";
1881 Script += "\n";
1882 Script += "# Windows: Let the 'SAGA_PATH' environment variable point to\n";
1883 Script += "# the SAGA installation folder before importing 'saga_api'!\n";
1884 Script += "# This can be defined globally in the Windows system or\n";
1885 Script += "# user environment variable settings, in the 'PySAGA/__init__.py'\n";
1886 Script += "# file, or in the individual Python script itself. To do the latter\n";
1887 Script += "# just uncomment the following line and adjust the path accordingly:\n";
1888 Script += "###import os; os.environ['SAGA_PATH'] = '" + AppPath + "'\n";
1889 Script += "\n";
1890 Script += "# Windows: The most convenient way to make PySAGA available to all your\n";
1891 Script += "# Python scripts is to copy the PySAGA folder to the 'Lib/site-packages/'\n";
1892 Script += "# folder of your Python installation. If don't want to do this or if you\n";
1893 Script += "# don't have the rights to do so, you can also copy it to the folder with\n";
1894 Script += "# the Python scripts in which you want to use PySAGA, or alternatively\n";
1895 Script += "# you can add the path containing the PySAGA folder (e.g. the path to your\n";
1896 Script += "# SAGA installation) to the PYTHONPATH environment variable. To do this\n";
1897 Script += "# from within your script you can also take the following command (just\n";
1898 Script += "# uncomment the following line and adjust the path accordingly):\n";
1899 Script += "###import sys; sys.path.insert(1, '" + AppPath + "')\n";
1900 Script += "\n";
1901#endif // _SAGA_MSW
1902 Script += "# Import saga_api from PySAGA:\n";
1903 Script += "from PySAGA import saga_api\n";
1904 Script += "\n";
1905 Script += "\n";
1906 Script += "#_________________________________________\n";
1907 Script += "##########################################\n";
1908 Script += "def Run_" + Name + "(Results):\n";
1909 }
1910
1911 //-----------------------------------------------------
1912 if( bHeader ) Script += " # Get the tool:\n";
1913 Script += " Tool = saga_api.SG_Get_Tool_Library_Manager().Get_Tool('" + Get_Library() + "', '" + Get_ID() + "')\n";
1914 Script += " if not Tool:\n";
1915 Script += " saga_api.SG_UI_Msg_Add_Error('Failed to request tool: " + Get_Name() + "')\n";
1916 Script += " return False\n";
1917 Script += "\n";
1918 if( bHeader ) Script += " # Set the parameter interface:\n";
1919 Script += " Tool.Reset()\n";
1920
1921 //-------------------------------------------------
1922 _Get_Script_Python(Script, Get_Parameters(), bAllArguments);
1923
1924 for(int iParameters=0; iParameters<Get_Parameters_Count(); iParameters++)
1925 {
1926 _Get_Script_Python(Script, Get_Parameters(iParameters), bAllArguments, Get_Parameters(iParameters)->Get_Identifier());
1927 }
1928
1929 //-------------------------------------------------
1930 Script += "\n";
1931 if( bHeader ) Script += " # Execute the tool:\n";
1932 Script += " if not Tool.Execute():\n";
1933 Script += " saga_api.SG_UI_Msg_Add_Error('failed to execute tool: ' + Tool.Get_Name().c_str())\n";
1934 Script += " return False\n";
1935 Script += "\n";
1936 if( bHeader ) Script += " # Request the results:\n";
1937
1938 for(int iParameter=0; iParameter<Get_Parameters()->Get_Count(); iParameter++)
1939 {
1940 CSG_Parameter *p = Get_Parameters()->Get_Parameter(iParameter);
1941
1942 if( p->is_Output() )
1943 {
1944 CSG_String id(p->Get_Identifier()), type, ext;
1945
1946 switch( p->Get_DataObject_Type() )
1947 {
1948 case SG_DATAOBJECT_TYPE_Grid : type = "Grid" ; ext = "sg-grd-z"; break;
1949 case SG_DATAOBJECT_TYPE_Grids : type = "Grids" ; ext = "sg-gds-z"; break;
1950 case SG_DATAOBJECT_TYPE_Table : type = "Table" ; ext = "txt" ; break;
1951 case SG_DATAOBJECT_TYPE_Shapes : type = "Shapes" ; ext = "geojson" ; break;
1952 case SG_DATAOBJECT_TYPE_PointCloud: type = "PointCloud"; ext = "sg-pts-z"; break;
1953 case SG_DATAOBJECT_TYPE_TIN : type = "TIN" ; ext = "geojson" ; break;
1954 default : type = "" ; ext = "" ; break;
1955 }
1956
1957 if( p->is_DataObject() )
1958 {
1959 Script += " Data = Tool.Get_Parameter('" + id + "').as" + type + "()\n";
1960
1961 if( bHeader )
1962 {
1963 Script += " Data.Save('{:s}/{:s}.{:s}'.format(Results, Data.Get_Name(), '" + ext + "'))\n\n";
1964 }
1965 }
1966 else if( p->is_DataObject_List() )
1967 {
1968 Script += " List = Tool.Get_Parameter('" + id + "').as" + type + "List()\n";
1969 Script += " for i in range(0, List.Get_Item_Count()):\n";
1970
1971 if( bHeader )
1972 {
1973 Script += " List.Get_Item(i).Save('{:s}/{:s}_{:d}.{:s}'.format(Results, List.Get_Name(), i, '" + ext + "'))\n\n";
1974 }
1975 else
1976 {
1977 Script += " Data = List.Get_Item(i)\n";
1978 }
1979 }
1980 }
1981 }
1982
1983 //-----------------------------------------------------
1984 if( bHeader )
1985 {
1986 Script += " # job is done, free memory resources:\n";
1987 Script += " saga_api.SG_Get_Data_Manager().Delete_All()\n";
1988 Script += "\n";
1989 Script += " return True\n";
1990 Script += "\n";
1991 Script += "\n";
1992 Script += "#_________________________________________\n";
1993 Script += "##########################################\n";
1994 Script += "print('This is a simple template for using a SAGA tool through Python.')\n";
1995 Script += "print('Please edit the script to make it work properly before using it!')\n";
1996 Script += "\n";
1997 Script += "# Run_" + Name + "('.')\n";
1998 }
1999
2000 return( Script );
2001}
2002
2003//---------------------------------------------------------
2004void CSG_Tool::_Get_Script_Python(CSG_String &Script, CSG_Parameters *pParameters, bool bAllArguments, const CSG_String &Prefix)
2005{
2006 for(int iParameter=0; iParameter<pParameters->Get_Count(); iParameter++)
2007 {
2008 CSG_Parameter *p = pParameters->Get_Parameter(iParameter);
2009
2010 if( !bAllArguments && (!p->is_Enabled(false) || p->is_Information() || !p->do_UseInCMD()) )
2011 {
2012 continue;
2013 }
2014
2015 CSG_String ID(p->Get_Identifier());
2016
2017 if( !Prefix.is_Empty() )
2018 {
2019 ID.Prepend(Prefix + ".");
2020 }
2021
2022 switch( p->Get_Type() )
2023 {
2024 default:
2025 break;
2026
2027 case PARAMETER_TYPE_Bool :
2028 Script += CSG_String::Format(" Tool.Set_Parameter('%s', %s)\n", ID.c_str(), p->asBool() ? SG_T("True") : SG_T("False"));
2029 break;
2030
2031 case PARAMETER_TYPE_Int :
2032 Script += CSG_String::Format(" Tool.Set_Parameter('%s', %d)\n", ID.c_str(), p->asInt());
2033 break;
2034
2037 Script += CSG_String::Format(" Tool.Set_Parameter('%s', %d) # '%s'\n", ID.c_str(), p->asInt(), p->asString());
2038 break;
2039
2043 Script += CSG_String::Format(" Tool.Set_Parameter('%s', '%s')\n", ID.c_str(), p->asString());
2044 break;
2045
2047 Script += CSG_String::Format(" Tool.Set_Parameter('%s', '%s')\n", ID.c_str(), SG_Color_To_Text(p->asColor()).c_str());
2048 break;
2049
2052 Script += CSG_String::Format(" Tool.Set_Parameter('%s', %g)\n", ID.c_str(), p->asDouble());
2053 break;
2054
2056 Script += CSG_String::Format(" Tool.Set_Parameter('%s.MIN', %g)\n", ID.c_str(), p->asRange()->Get_Min());
2057 Script += CSG_String::Format(" Tool.Set_Parameter('%s.MAX', %g)\n", ID.c_str(), p->asRange()->Get_Max());
2058 break;
2059
2061 if( ((CSG_Parameter_String *)p)->is_Password() )
2062 {
2063 Script += CSG_String::Format(" Tool.Set_Parameter('%s', '***')\n", ID.c_str());
2064 break;
2065 }
2066
2067 case PARAMETER_TYPE_Date :
2068 case PARAMETER_TYPE_Text :
2070 Script += CSG_String::Format(" Tool.Set_Parameter('%s', '%s')\n", ID.c_str(), p->asString());
2071 break;
2072
2074 Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.SG_Create_Table('table.txt'))\n", ID.c_str());
2075 break;
2076
2078 if( p->Get_Children_Count() == 0 )
2079 {
2080 Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.CSG_Grid_System(%g, %g, %g, %d, %d))\n", ID.c_str(),
2083 p->asGrid_System()->Get_NX (), p->asGrid_System()->Get_NY ()
2084 );
2085 }
2086 break;
2087
2088 case PARAMETER_TYPE_Grid :
2092 case PARAMETER_TYPE_TIN :
2094 if( p->is_Input() )
2095 {
2096 Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.SG_Get_Data_Manager().Add('%s input file%s'))\n", ID.c_str(),
2097 SG_Get_DataObject_Name(p->Get_DataObject_Type()).c_str(), p->is_Optional() ? SG_T(", optional") : SG_T("")
2098 );
2099 }
2100 else if( p->is_Output() && p->is_Optional() )
2101 {
2102 Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.SG_Get_Create_Pointer()) # optional output, remove this line, if you don't want to create it\n", ID.c_str());
2103 }
2104 break;
2105
2112 if( p->is_Input() )
2113 {
2114 Script += CSG_String::Format(" Tool.Get_Parameter('%s').asList().Add_Item('%s input list%s')\n", ID.c_str(),
2115 SG_Get_DataObject_Name(p->Get_DataObject_Type()).c_str(), p->is_Optional() ? SG_T(", optional") : SG_T("")
2116 );
2117 }
2118 break;
2119
2121 _Get_Script_Python(Script, p->asParameters(), bAllArguments, ID);
2122 break;
2123 }
2124 }
2125}
2126
2127
2129// //
2131
2132//---------------------------------------------------------
2133CSG_String CSG_Tool::_Get_Script_Python_Wrap(bool bHeader, bool bName, bool bCall, int AllArguments, bool bWrapArgs)
2134{
2135 CSG_String Arguments, Description, Code;
2136
2137 if( AllArguments >= 0 ) // if( AllArguments < 0 ) => skip arguments list
2138 {
2139 for(int i=0; i<Parameters.Get_Count(); i++) // add input that is not optional in 1st place
2140 {
2141 _Get_Script_Python_Wrap(Parameters[i], PARAMETER_INPUT , Arguments, Description, Code, bCall && bHeader, AllArguments == 0, bWrapArgs);
2142 }
2143
2144 for(int i=0; i<Parameters.Get_Count(); i++) // add optional input in 2nd place
2145 {
2146 _Get_Script_Python_Wrap(Parameters[i], PARAMETER_INPUT_OPTIONAL, Arguments, Description, Code, bCall && bHeader, AllArguments == 0, bWrapArgs);
2147 }
2148
2149 for(int i=0; i<Parameters.Get_Count(); i++) // add output
2150 {
2151 _Get_Script_Python_Wrap(Parameters[i], PARAMETER_OUTPUT , Arguments, Description, Code, bCall && bHeader, AllArguments == 0, bWrapArgs);
2152 }
2153
2154 for(int i=0; i<Parameters.Get_Count(); i++) // add options
2155 {
2156 _Get_Script_Python_Wrap(Parameters[i], 0 , Arguments, Description, Code, bCall , AllArguments == 0, bWrapArgs);
2157 }
2158 }
2159
2160 //---------------------------------------------------------
2161 CSG_String Name, Expected(Get_Name()); Expected.Replace("'", "\\'");
2162
2163 if( bName )
2164 {
2165 Name = Get_Name();
2166
2167 if( isdigit(Name[0]) ) // ...in case first letter is a numeric character, what is not allowed for Python function names!
2168 {
2169 Name.Prepend("_");
2170 }
2171
2172 Name.Replace(" ", "_");
2173 Name.Replace("(", "");
2174 Name.Replace(")", "");
2175 Name.Replace("[", "");
2176 Name.Replace("]", "");
2177 Name.Replace(".", "");
2178 Name.Replace(",", "");
2179 Name.Replace("/", "");
2180 Name.Replace("-", "");
2181 Name.Replace("'", "");
2182 Name.Replace("&", "and");
2183 }
2184 else
2185 {
2186 Name = "run_tool_" + Get_Library() + "_" + Get_ID();
2187
2188 Name.Replace(" ", "_");
2189 }
2190
2191 //---------------------------------------------------------
2192 CSG_String Script;
2193
2194 if( bCall )
2195 {
2196 if( bHeader )
2197 {
2198 Script += "from PySAGA.tools import " + Get_Library() + "\n\n";
2199
2200 if( !Code.is_Empty() )
2201 {
2202 Script += Code + "\n";
2203 }
2204 }
2205
2206 Script += Get_Library() + '.' + Name + "(" + Arguments + ")\n";
2207 }
2208 else
2209 {
2210 CSG_Strings _Description = SG_String_Tokenize(SG_HTML_Tag_Replacer(Get_Description()), "\n");
2211
2212 if( bHeader )
2213 {
2214 Script += "#! /usr/bin/env python\n";
2215 Script += "from PySAGA.helper import Tool_Wrapper\n\n";
2216 }
2217
2218 Script += "def " + Name + "(" + Arguments + ", Verbose=2):\n";
2219 Script += " '''\n";
2220 Script += " " + Get_Name() + "\n";
2221 Script += " ----------\n";
2222 Script += " [" + Get_Library() + "." + Get_ID() + "]\\n\n";
2223 for(int i=0; i<_Description.Get_Count(); i++)
2224 {
2225 _Description[i].Trim_Both(); Script += " " + _Description[i] + "\\n\n";
2226 }
2227 Script += " Arguments\n";
2228 Script += " ----------\n";
2229 Script += Description + "\n";
2230 Script += " - Verbose [`integer number`] : Verbosity level, 0=silent, 1=tool name and success notification, 2=complete tool output.\\n\n";
2231 Script += " Returns\n";
2232 Script += " ----------\n";
2233 Script += " `boolean` : `True` on success, `False` on failure.\n";
2234 Script += " '''\n";
2235 Script += " Tool = Tool_Wrapper('" + Get_Library() + "', '" + Get_ID() + "', '" + Expected + "')\n";
2236 Script += " if Tool.is_Okay():\n";
2237 Script += Code;
2238 Script += " return Tool.Execute(Verbose)\n";
2239 Script += " return False\n\n";
2240 }
2241
2242 return( Script );
2243}
2244
2245//---------------------------------------------------------
2246bool CSG_Tool::_Get_Script_Python_Wrap(const CSG_Parameter &Parameter, int Constraint, CSG_String &Arguments, CSG_String &Description, CSG_String &Code, bool bCall, bool bOnlyNonDefaults, bool bWrapArgs, const CSG_String &Prefix)
2247{
2248 if( Parameter.do_UseInCMD() == false
2249 || Parameter.is_Information()
2250 || Parameter.Get_Type() == PARAMETER_TYPE_Node
2251 || Parameter.Cmp_Identifier("PARAMETERS_GRID_SYSTEM") )
2252 {
2253 return( false );
2254 }
2255
2256 if( bCall && !Parameter.is_Enabled() && !(Parameter.is_Output() && Parameter.Get_Parent() && Parameter.Get_Parent()->Cmp_Identifier("TARGET_SYSTEM")) )
2257 {
2258 return( false );
2259 }
2260
2261 //-----------------------------------------------------
2262 CSG_String ID(Parameter.Get_Identifier());
2263
2264 if( !Prefix.is_Empty() )
2265 {
2266 ID.Prepend(Prefix + ".");
2267 }
2268
2269 CSG_String Argument(ID);
2270
2271 if( Argument[0] >= '0' && Argument[0] <= '9' )
2272 {
2273 Argument.Prepend('_');
2274 }
2275
2276 Argument.Replace(".", "_");
2277 Argument.Replace("|", "_");
2278 Argument.Replace(" ", "_");
2279
2280 if( Argument.Length() > 2 )
2281 {
2282 Argument.Make_Upper();
2283 }
2284
2285 //-----------------------------------------------------
2286 if( Parameter.asParameters() ) // PARAMETER_TYPE_Parameters
2287 {
2288 bool bResult = false;
2289
2290 for(int i=0; i<(*Parameter.asParameters()).Get_Count(); i++)
2291 {
2292 if( _Get_Script_Python_Wrap((*Parameter.asParameters())[i], Constraint, Arguments, Description, Code, bCall, bOnlyNonDefaults, bWrapArgs, ID) )
2293 {
2294 bResult = true;
2295 }
2296 }
2297
2298 return( bResult );
2299 }
2300
2301 //-----------------------------------------------------
2302 if( Parameter.is_Input () && !Parameter.is_Optional() && Constraint != PARAMETER_INPUT ) { return( false ); }
2303 if( Parameter.is_Input () && Parameter.is_Optional() && Constraint != PARAMETER_INPUT_OPTIONAL ) { return( false ); }
2304 if( Parameter.is_Output() && Constraint != PARAMETER_OUTPUT ) { return( false ); }
2305 if( Parameter.is_Option() && Constraint != 0 ) { return( false ); }
2306
2307 //-----------------------------------------------------
2308 if( bCall )
2309 {
2310 CSG_String Value;
2311
2312 if( Parameter.is_DataObject() )
2313 {
2314 Value = Parameter.Get_Identifier(); Value.Make_Lower();
2315
2316 if( Parameter.is_Input() )
2317 {
2318 if( (bOnlyNonDefaults && !Parameter.asDataObject()) && Parameter.is_Optional() ) // don't add optional input that has not been set
2319 {
2320 return( false );
2321 }
2322
2323 CSG_String File(Parameter.asDataObject() && Parameter.asDataObject()->Get_File_Name(false)
2324 ? Parameter.asDataObject()->Get_File_Name(false) : SG_T("data object file")
2325 ); File.Replace("\\", "/");
2326
2327 Code += Value + " = saga_api.SG_Get_Data_Manager().Add_" + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()).AfterFirst('_') + "('" + File + "') # input data object\n";
2328 }
2329 else // if( Parameter.is_Output() )
2330 {
2331 if( (bOnlyNonDefaults && !Parameter.asDataObject()) && Parameter.is_Optional() ) // don't add optional output that has not been requested
2332 {
2333 return( false );
2334 }
2335
2336 Code += Value + " = saga_api.SG_Get_Data_Manager().Add_" + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()).AfterFirst('_') + "() # output data object\n";
2337 }
2338 }
2339 else if( Parameter.is_DataObject_List() )
2340 {
2341 Value = Parameter.Get_Identifier(); Value.Make_Lower();
2342
2343 if( Parameter.is_Input() )
2344 {
2345 if( (bOnlyNonDefaults && Parameter.asList()->Get_Item_Count() < 1) && Parameter.is_Optional() ) // don't add optional input that has not been set
2346 {
2347 return( false );
2348 }
2349
2350 Code += Value + " = [] # Python list with input data objects of type 'saga_api." + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()) + "'\n";
2351 }
2352 else // if( Parameter.is_Output() )
2353 {
2354 Code += Value + " = [] # Python list, will become filled after successful execution with output data objects of type 'saga_api." + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()) + "'\n";
2355 }
2356 }
2357 else if( Parameter.is_Option() )
2358 {
2359 if( bOnlyNonDefaults && Parameter.is_Default() )
2360 {
2361 return( false );
2362 }
2363
2364 switch( Parameter.Get_Type() )
2365 {
2366 case PARAMETER_TYPE_Bool : Value = Parameter.asBool() ? "True" : "False"; break;
2367
2368 case PARAMETER_TYPE_Int : Value.Printf("%d", Parameter.asInt()); break;
2369
2371 case PARAMETER_TYPE_Degree : Value.Printf("%f", Parameter.asDouble()); break;
2372
2373 case PARAMETER_TYPE_Color : Value = SG_Color_To_Text(Parameter.asColor()); break;
2374
2376 case PARAMETER_TYPE_Text :
2377 case PARAMETER_TYPE_Date :
2384 case PARAMETER_TYPE_FilePath : Value.Printf("'%s'", Parameter.asString()); break;
2385
2387 if( !Parameter.Cmp_Identifier("TARGET_SYSTEM") )
2388 {
2389 return( false );
2390 }
2391
2392 Value.Printf("'%s'", Parameter.asGrid_System()->asString());
2393 break;
2394
2395 default : return( false );
2396 }
2397 }
2398
2399 if( !Value.is_Empty() )
2400 {
2401 if( bWrapArgs )
2402 {
2403 Arguments += !Arguments.is_Empty() ? ",\n " : "\n ";
2404 }
2405 else if( !Arguments.is_Empty() )
2406 {
2407 Arguments += ", ";
2408 }
2409
2410 Arguments += Argument + "=" + Value;
2411 }
2412
2413 return( true );
2414 }
2415
2416 //-----------------------------------------------------
2417 if( bWrapArgs )
2418 {
2419 Arguments += !Arguments.is_Empty() ? ",\n " : "\n ";
2420 }
2421 else if( !Arguments.is_Empty() )
2422 {
2423 Arguments += ", ";
2424 }
2425
2426 Arguments += Argument + "=None";
2427
2428 //-----------------------------------------------------
2429 Code += " ";
2430
2431 if( Parameter.is_Input () ) { Code += "Tool.Set_Input "; }
2432 if( Parameter.is_Output() ) { Code += "Tool.Set_Output"; }
2433 if( Parameter.is_Option() ) { Code += "Tool.Set_Option"; }
2434
2435 Code += CSG_String::Format("('%s', %s)\n", ID.c_str(), Argument.c_str());
2436
2437 //-----------------------------------------------------
2438 Description += " - " + Argument + " [`";
2439
2440 if( Parameter.is_Input() )
2441 {
2442 Description += Parameter.is_Optional() ? "optional input " : "input ";
2443 }
2444 else if( Parameter.is_Output() )
2445 {
2446 Description += "output ";
2447 }
2448
2449 Description += Parameter.Get_Type_Name() + "`] : " + Parameter.Get_Name();
2450
2452
2453 if( !s.is_Empty() )
2454 {
2455 Description += ". " + s;
2456 }
2457
2458 Description += "\n";
2459
2460 return( true );
2461}
2462
2464// //
2466
2467//---------------------------------------------------------
2468CSG_String CSG_Tool::_Get_Script_Markdown(bool bHeader, int iArguments)
2469{
2470 CSG_String Script;
2471
2472 if( bHeader )
2473 {
2474 CSG_String Menu = Get_MenuPath(true); Menu.Replace("|", " &rarr; ");
2475 CSG_Tool_Library *pT = SG_Get_Tool_Library_Manager().Get_Library(Get_Library(), true);
2476 CSG_String Category = pT->Get_Category();
2477 Category += CSG_String::Format(" &rarr; %s", pT->Get_Name().c_str());
2478
2479 Script += CSG_String::Format("**Tool:** %s \n", Get_Name().c_str());
2480 Script += CSG_String::Format("**Geoprocessing** &rarr; *%s*&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp; **Tools** &rarr; *%s*\n\n", Menu.c_str(), Category.c_str());
2481 }
2482
2483 Script += "|**Parameter**|**Setting**|\n";
2484 Script += "|---|---|\n";
2485
2486 //-------------------------------------------------
2487 _Get_Script_Markdown(Script, Get_Parameters(), iArguments);
2488
2489 Script.Replace(SG_T("\n\n"), SG_T("\n"));
2490
2491 return( Script );
2492}
2493
2494
2495//---------------------------------------------------------
2496void CSG_Tool::_Get_Script_Markdown(CSG_String &Script, CSG_Parameters *pParameters, int iArguments, const CSG_String &Prefix)
2497{
2498 #define WRITE_CHILD(pChild, Prefix) Script += CSG_String::Format("|%s%s||\n", Prefix.c_str(), pChild->Get_Name().c_str());\
2499 for (int i=0; i<pChild->Get_Children_Count(); i++)\
2500 {\
2501 Script += CSG_String::Format("%s\n", pChild->Get_Child(i)->Get_Content().c_str());\
2502 }
2503
2504 CSG_MetaData Properties;
2505
2506 for(int iParameter=0; iParameter<pParameters->Get_Count(); iParameter++)
2507 {
2508 _Format_Markdown(pParameters->Get_Parameter(iParameter), Script, Properties, iArguments, Prefix);
2509 }
2510
2511 if( CSG_MetaData *pChild = Properties.Get_Child(_TL("Data Objects")) ) { WRITE_CHILD(pChild, Prefix); }
2512
2513 for (int i=0; i<Properties.Get_Children_Count(); i++)
2514 {
2515 CSG_MetaData *pChild = Properties.Get_Child(i);
2516
2517 if( pChild->Get_Name().Cmp(_TL("Data Objects")) && pChild->Get_Name().Cmp(_TL("Options")) )
2518 {
2519 WRITE_CHILD(pChild, Prefix);
2520 }
2521 }
2522
2523 if( CSG_MetaData *pChild = Properties.Get_Child(_TL("Options")) ) { WRITE_CHILD(pChild, Prefix); }
2524}
2525
2526
2527//---------------------------------------------------------
2528void CSG_Tool::_Format_Markdown(CSG_Parameter *p, CSG_String &Script, CSG_MetaData &Properties, int iArguments, CSG_String Prefix)
2529{
2530 #define CHECK_OBJECTS_NODE() pChild = Properties.Get_Child(_TL("Options"));\
2531 if( !pChild )\
2532 {\
2533 pChild = Properties.Add_Child(_TL("Options"));\
2534 }\
2535 \
2536 pRoot = pChild;
2537
2538 #define CHECK_DATA_NODE(Name) pChild = Properties.Get_Child(Name);\
2539 if( !pChild )\
2540 {\
2541 CSG_MetaData *pData = Properties.Get_Child(_TL("Data Objects"));\
2542 if( !pData )\
2543 {\
2544 Properties.Add_Child(_TL("Data Objects"));\
2545 }\
2546 pChild = Properties.Add_Child(Name);\
2547 }\
2548 \
2549 pRoot = pChild;
2550
2551 #define GET_PARENT_NODE(prt) bool bFound = false;\
2552 for (int i=0; i<Properties.Get_Children_Count(); i++)\
2553 {\
2554 CSG_MetaData *pDatatype = Properties.Get_Child(i);\
2555 for (int j=0; j<Properties.Get_Children_Count(); j++)\
2556 {\
2557 pParent = pDatatype->Get_Child(prt);\
2558 if( pParent )\
2559 {\
2560 bFound = true;\
2561 break;\
2562 }\
2563 }\
2564 if( bFound )\
2565 {\
2566 break;\
2567 }\
2568 }
2569
2570 #define FORMAT_DATASET() if( p->is_Input() )\
2571 {\
2572 CSG_String Input = p->is_Optional() ? ">" : ">>";\
2573 CSG_String s = p->asString();\
2574 if( s.Contains(_TL("not set")) || s.Contains(_TL("No objects")) ) { Bold = ""; }\
2575 s.Replace("<", "\\<");\
2576 Parameter = CSG_String::Format("|%s%s %s%s%s|%s%s%s|", Space.c_str(), Input.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), s.c_str(), Bold.c_str());\
2577 }\
2578 else if( p->is_Output() )\
2579 {\
2580 CSG_String Output = p->is_Optional() ? "\\<" : "<<";\
2581 CSG_String s = p->asString();\
2582 if( !p->is_Optional() && s.Contains(_TL("create")) ) { Bold = ""; }\
2583 else if( p->is_Optional() && (s.Contains(_TL("not set")) || s.Contains(_TL("No objects"))) ) { Bold = ""; }\
2584 s.Replace("<", "\\<");\
2585 Parameter = CSG_String::Format("|%s%s %s%s%s|%s%s%s|", Space.c_str(), Output.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), s.c_str(), Bold.c_str());\
2586 }
2587
2588 if( iArguments == 0 && !p->do_UseInCMD() )
2589 {
2590 return;
2591 }
2592 else if( iArguments == 1 && !p->do_UseInGUI() )
2593 {
2594 return;
2595 }
2596
2597 if( !p->is_Enabled(false) )
2598 {
2599 return;
2600 }
2601
2602 CSG_String Name(p->Get_Name());
2603
2604 CSG_String Bold;
2605
2606 if( !p->is_Default() )
2607 {
2608 Bold = "**";
2609 }
2610
2611 CSG_String Space = Prefix;
2612
2613 if( p->Get_Parent() != NULL )
2614 {
2615 Space += "&nbsp;&nbsp;&nbsp;";
2616 }
2617
2618 CSG_String Parameter;
2619 CSG_MetaData *pRoot = NULL, *pChild;
2620
2621 switch( p->Get_Type() )
2622 {
2623 default:
2624 break;
2625
2627 {
2628 if( p->Get_Parent() )
2629 {
2631 }
2632 else if( p->Get_Children_Count() == 0 )
2633 {
2634 CHECK_DATA_NODE(_TL("Grids"));
2635 }
2636 else for (int i=0; i<p->Get_Children_Count() && !pRoot; i++)
2637 {
2640 || p->Get_Child(i)->is_Input() )
2641 {
2642 CHECK_DATA_NODE(_TL("Grids"));
2643 }
2644 }
2645
2646 CSG_String s = p->asString();
2647 if( s.Contains(_TL("not set")) )
2648 {
2649 s.Replace("<", "\\<");
2650 Parameter += CSG_String::Format("|%s%s|%s|", Space.c_str(), Name.c_str(), s.c_str());
2651 }
2652 else
2653 {
2654 Parameter += CSG_String::Format("|%s%s%s%s|%s%g; %dx, %dy; %.0f...x %.0f...y%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(),
2656 p->asGrid_System()->Get_NX (), p->asGrid_System()->Get_NY (),
2658 Bold.c_str()
2659 );
2660 }
2661 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2662 break;
2663 }
2664
2667 if( p->is_Input() )
2668 {
2669 if( !p->Get_Parent() || (p->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System && !p->Get_Parent()->Get_Parent()) )
2670 {
2671 CHECK_DATA_NODE(_TL("Grids"));
2672 }
2673 else
2674 {
2676 }
2678 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2679 }
2680 break;
2681
2682 case PARAMETER_TYPE_Grid :
2684 if( !p->Get_Parent() || (p->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System && !p->Get_Parent()->Get_Parent()) )
2685 {
2686 CHECK_DATA_NODE(_TL("Grids"));
2687 }
2688 else
2689 {
2691 }
2693 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2694 break;
2695
2697 if( p->is_Input() )
2698 {
2699 if( !p->Get_Parent() )
2700 {
2701 CHECK_DATA_NODE(_TL("Tables"));
2702 }
2703 else
2704 {
2706 }
2708 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2709 }
2710 break;
2711
2713 if( !p->Get_Parent() )
2714 {
2715 CHECK_DATA_NODE(_TL("Tables"));
2716 }
2717 else
2718 {
2720 }
2722 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2723 break;
2724
2726 if( p->is_Input() )
2727 {
2728 if( !p->Get_Parent() )
2729 {
2730 CHECK_DATA_NODE(_TL("Shapes"));
2731 }
2732 else
2733 {
2735 }
2737 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2738 }
2739 break;
2740
2742 if( !p->Get_Parent() )
2743 {
2744 CHECK_DATA_NODE(_TL("Shapes"));
2745 }
2746 else
2747 {
2749 }
2751 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2752 break;
2753
2755 if( p->is_Input() )
2756 {
2757 if( !p->Get_Parent() )
2758 {
2759 CHECK_DATA_NODE(_TL("TIN"));
2760 }
2761 else
2762 {
2764 }
2766 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2767 }
2768 break;
2769
2770 case PARAMETER_TYPE_TIN :
2771 if( !p->Get_Parent() )
2772 {
2773 CHECK_DATA_NODE(_TL("TIN"));
2774 }
2775 else
2776 {
2778 }
2780 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2781 break;
2782
2784 if( p->is_Input() )
2785 {
2786 if( !p->Get_Parent() )
2787 {
2788 CHECK_DATA_NODE(_TL("Point Clouds"));
2789 }
2790 else
2791 {
2793 }
2795 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2796 }
2797 break;
2798
2800 if( !p->Get_Parent() )
2801 {
2802 CHECK_DATA_NODE(_TL("Point Clouds"));
2803 }
2804 else
2805 {
2807 }
2809 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2810 break;
2811
2812 case PARAMETER_TYPE_Node :
2814 Parameter = CSG_String::Format("|%s%s||", Space.c_str(), Name.c_str());
2815 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2816 break;
2817
2818 case PARAMETER_TYPE_Bool :
2820 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), p->asBool() ? SG_T("&#x1f5f9;") : SG_T("&#x2610;"), Bold.c_str());
2821 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2822 break;
2823
2824 case PARAMETER_TYPE_Int :
2826 Parameter = CSG_String::Format("|%s%s%s%s|%s%d%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), p->asInt(), Bold.c_str());
2827 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2828 break;
2829
2832 {
2834 CSG_String s = p->asString();
2835 if( s.Contains(_TL("no choice available")) ) { Bold = ""; }
2836 s.Replace("<", "\\<");
2837 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), s.c_str(), Bold.c_str());
2838 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2839 break;
2840 }
2841
2843 {
2844 CSG_String s = p->asString();
2845 if( s.Contains(_TL("no attributes")) ) { Bold = ""; }
2846 s.Replace("<", "\\<");
2847 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), s.c_str(), Bold.c_str());
2848 if( p->Get_Parent() != NULL && (p->Get_Parent()->is_DataObject() || p->Get_Parent()->is_DataObject_List()) )
2849 {
2850 CSG_MetaData *pParent = NULL;
2852 if( pParent )
2853 {
2854 CSG_String c = pParent->Get_Content();
2855 c += SG_T("\n") + Parameter;
2856 pParent->Set_Content(c);
2857 }
2858 }
2859 else
2860 {
2862 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2863 }
2864 break;
2865 }
2866
2869 {
2870 CSG_String s = p->asString();
2871 s.Replace("<", "\\<");
2872 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), s.c_str(), Bold.c_str());
2873 if( p->Get_Parent() != NULL && (p->Get_Parent()->is_DataObject() || p->Get_Parent()->is_DataObject_List()) )
2874 {
2875 CSG_MetaData *pParent = NULL;
2877 if( pParent )
2878 {
2879 CSG_String c = pParent->Get_Content();
2880 c += SG_T("\n") + Parameter;
2881 pParent->Set_Content(c);
2882 }
2883 }
2884 else
2885 {
2887 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2888 }
2889 break;
2890 }
2891
2894 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), SG_Color_To_Text(p->asColor()).c_str(), Bold.c_str());
2895 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2896 break;
2897
2901 Parameter = CSG_String::Format("|%s%s%s%s|%s%g%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), p->asDouble(), Bold.c_str());
2902 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2903 break;
2904
2907 Parameter = CSG_String::Format("|%s%s%s%s|%s%g;%g%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), p->asRange()->Get_Min(), p->asRange()->Get_Max(), Bold.c_str());
2908 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2909 break;
2910
2912 if( ((CSG_Parameter_String *)p)->is_Password() )
2913 {
2915 Parameter = CSG_String::Format("|%s%s%s%s|%s***%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), Bold.c_str());
2916 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2917 break;
2918 }
2919
2920 case PARAMETER_TYPE_Date :
2921 case PARAMETER_TYPE_Text :
2923 {
2925 CSG_String s = p->asString();
2926 s.Replace("\\", "/");
2927 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), s.c_str(), Bold.c_str());
2928 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2929 break;
2930 }
2931
2934 Parameter = CSG_String::Format("|%s%s%s%s|%s%s%s|", Space.c_str(), Bold.c_str(), Name.c_str(), Bold.c_str(), Bold.c_str(), p->asString(), Bold.c_str());
2935 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2936 break;
2937
2940 Parameter = CSG_String::Format("|%s%s||\n", Space.c_str(), Name.c_str());
2941 CSG_String Prefix = Space + "&nbsp;&nbsp;&nbsp;";
2942 _Get_Script_Markdown(Parameter, p->asParameters(), iArguments, Prefix);
2943 if( pRoot ) { pRoot->Add_Child(p->Get_Identifier(), Parameter); }
2944 break;
2945 }
2946
2947 return;
2948}
2949
2951// //
2952// //
2953// //
2955
2956//---------------------------------------------------------
2958{
2959 CSG_MetaData History;
2960
2961 History.Set_Name(SG_META_HISTORY);
2962 History.Add_Property("saga-version", SAGA_VERSION);
2963
2964 if( Depth )
2965 {
2966 CSG_MetaData *pTool = History.Add_Child("TOOL");
2967
2968 pTool->Add_Property("library", Get_Library());
2969 pTool->Add_Property("id" , Get_ID ());
2970 pTool->Add_Property("name" , Get_Name ());
2971
2972 Parameters.Set_History(*pTool);
2973
2975
2976 CSG_MetaData *pOutput = pTool->Add_Child("OUTPUT");
2977 pOutput->Add_Property("type", "");
2978 pOutput->Add_Property("id" , "");
2979 pOutput->Add_Property("name", "");
2980
2981 pTool->Del_Children(Depth, SG_T("TOOL"));
2982 }
2983
2984 return( History );
2985}
2986
2987//---------------------------------------------------------
2988bool CSG_Tool::Set_History(CSG_Data_Object *pDataObject, int Depth)
2989{
2990 if( pDataObject )
2991 {
2992 CSG_MetaData History(Get_History(Depth));
2993
2994 CSG_MetaData *pOutput = History("TOOL") ? History["TOOL"]("OUTPUT") : NULL;
2995
2996 if( pOutput )
2997 {
2998 pOutput->Set_Property("name", pDataObject->Get_Name());
2999 }
3000
3001 pDataObject->Get_History() = History;
3002
3003 return( true );
3004 }
3005
3006 return( false );
3007}
3008
3009//---------------------------------------------------------
3010void CSG_Tool::_Set_Output_History(void)
3011{
3013
3014 for(int j=-1; j<Get_Parameters_Count(); j++)
3015 {
3016 CSG_Parameters *pParameters = j < 0 ? &Parameters : Get_Parameters(j);
3017
3018 for(int i=0; i<pParameters->Get_Count(); i++)
3019 {
3020 CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
3021
3022 if( pParameter->is_Output() )//&& (pParameter->is_Enabled() || !has_GUI()) )
3023 {
3024 DataObject_Set_History(pParameter, &History);
3025 }
3026 }
3027 }
3028}
3029
3030//---------------------------------------------------------
3032{
3033 if( !pParameter && !((pParameter->is_DataObject() && pParameter->asDataObject()) || !(pParameter->is_DataObject_List() && pParameter->asList()->Get_Item_Count() > 0)) )
3034 {
3035 return( false );
3036 }
3037
3038 //-----------------------------------------------------
3039 CSG_MetaData History;
3040
3041 if( !pHistory )
3042 {
3043 History = Get_History(SG_Get_History_Depth()); pHistory = &History;
3044 }
3045
3046 //-----------------------------------------------------
3047 CSG_MetaData *pOutput = pHistory->Get_Child("TOOL") ? pHistory->Get_Child("TOOL")->Get_Child("OUTPUT") : NULL;
3048
3049 if( pOutput )
3050 {
3051 pOutput->Set_Property("type", pParameter->Get_Type_Identifier());
3052 pOutput->Set_Property("id" , pParameter->Get_Identifier ());
3053 pOutput->Set_Property("name", pParameter->Get_Name ());
3054 }
3055
3056 //-----------------------------------------------------
3057 if( pParameter->is_DataObject() && pParameter->asDataObject() )
3058 {
3059 if( pOutput )
3060 {
3061 pOutput->Set_Content(pParameter->asDataObject()->Get_Name());
3062 }
3063
3064 pParameter->asDataObject()->Get_History().Assign(*pHistory);
3065 }
3066
3067 //-----------------------------------------------------
3068 else if( pParameter->is_DataObject_List() )
3069 {
3070 for(int j=0; j<pParameter->asList()->Get_Item_Count(); j++)
3071 {
3072 if( pOutput )
3073 {
3074 pOutput->Set_Content(pParameter->asList()->Get_Item(j)->Get_Name());
3075 }
3076
3077 pParameter->asList()->Get_Item(j)->Get_History().Assign(*pHistory);
3078 }
3079 }
3080
3081 //-----------------------------------------------------
3082 return( true );
3083}
3084
3085
3087// //
3088// //
3089// //
3091
3092//---------------------------------------------------------
bool SG_UI_DataObject_Update(CSG_Data_Object *pDataObject, int Show, CSG_Parameters *pParameters)
void SG_UI_Msg_Add_Error(const char *Message)
int SG_UI_Dlg_Error(const CSG_String &Message, const CSG_String &Caption)
bool SG_UI_Stop_Execution(bool bDialog)
bool SG_UI_Process_Get_Okay(bool bBlink)
bool SG_UI_Dlg_Parameters(CSG_Parameters *pParameters, const CSG_String &Caption)
bool SG_UI_DataObject_Colors_Get(CSG_Data_Object *pDataObject, CSG_Colors *pColors)
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
bool SG_UI_DataObject_Params_Get(CSG_Data_Object *pDataObject, CSG_Parameters *pParameters)
void SG_UI_Process_Set_Text(const CSG_String &Text)
bool SG_UI_Process_Set_Ready(void)
bool SG_UI_Process_Set_Progress(int Position, int Range)
bool SG_UI_DataObject_Add(CSG_Data_Object *pDataObject, int Show)
void SG_UI_Msg_Add_Execution(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
bool SG_UI_Process_Set_Okay(bool bOkay)
bool SG_UI_DataObject_Params_Set(CSG_Data_Object *pDataObject, CSG_Parameters *pParameters)
void SG_UI_Dlg_Message(const CSG_String &Message, const CSG_String &Caption)
bool SG_UI_DataObject_Colors_Set(CSG_Data_Object *pDataObject, CSG_Colors *pColors)
bool SG_UI_Dlg_Continue(const CSG_String &Message, const CSG_String &Caption)
bool SG_UI_DataObject_Classify(CSG_Data_Object *pDataObject, const CSG_MetaData &Options)
CSG_String SG_Color_To_Text(long Color, bool bHexadecimal)
CSG_String SG_UI_Get_Application_Name(void)
Definition api_core.cpp:378
CSG_String SG_UI_Get_Application_Path(bool bPathOnly)
Definition api_core.cpp:356
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
@ SG_UI_MSG_STYLE_FAILURE
Definition api_core.h:1585
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1584
@ SG_UI_MSG_STYLE_BOLD
Definition api_core.h:1582
@ SG_UI_MSG_STYLE_NORMAL
Definition api_core.h:1581
SAGA_API_DLL_EXPORT CSG_String SG_HTML_Tag_Replacer(const CSG_String &Text)
signed long long sLong
Definition api_core.h:158
#define SG_T(s)
Definition api_core.h:537
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)
@ SG_UI_DATAOBJECT_SHOW_MAP
Definition api_core.h:1598
@ SG_UI_DATAOBJECT_UPDATE
Definition api_core.h:1597
#define SG_Char
Definition api_core.h:536
#define _TL(s)
Definition api_core.h:1568
bool Create(void)
bool Set_Predefined(int Index, bool bRevert=false, int nColors=0)
bool Delete(CSG_Data_Object *pObject, bool bDetach=false)
const SG_Char * Get_Name(void) const
const SG_Char * Get_File_Name(bool bNative=true) const
CSG_MetaData & Get_History(void)
Definition dataobject.h:236
static CSG_DateTime Now(void)
Definition datetime.cpp:585
double Get_XMin(bool bCells=false) const
Definition grid.h:264
double Get_YMin(bool bCells=false) const
Definition grid.h:268
double Get_Cellsize(void) const
Definition grid.h:255
int Get_NX(void) const
Definition grid.h:258
const SG_Char * asString(void)
int Get_NY(void) const
Definition grid.h:259
const CSG_String & Get_Name(void) const
Definition metadata.h:132
bool Assign(const CSG_MetaData &MetaData, bool bAddChildren=true)
Definition metadata.cpp:757
bool Del_Children(int Depth=0, const SG_Char *Name=NULL)
Definition metadata.cpp:381
int Get_Children_Count(void) const
Definition metadata.h:148
CSG_MetaData * Get_Child(int Index) const
Definition metadata.h:149
bool Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists=true)
Definition metadata.cpp:615
bool Add_Children(const CSG_MetaData &MetaData)
Definition metadata.cpp:359
const CSG_String & Get_Content(void) const
Definition metadata.h:133
void Set_Name(const CSG_String &Name)
Definition metadata.h:130
void Set_Content(const CSG_String &Content)
Definition metadata.h:140
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:166
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition metadata.cpp:559
virtual bool Del_Items(void)
CSG_Data_Object * Get_Item(int Index) const
int Get_Item_Count(void) const
double Get_Max(void) const
double Get_Min(void) const
CSG_String Get_CmdID(void) const
const SG_Char * Get_Identifier(void) const
bool is_DataObject(void) const
class CSG_Parameters * asParameters(void) const
CSG_String Get_Type_Identifier(void) const
CSG_String Get_Type_Name(void) const
bool is_Optional(void) const
Definition parameters.h:238
TSG_Data_Object_Type Get_DataObject_Type(void) const
int Get_Children_Count(void) const
Definition parameters.h:259
double asDouble(void) const
Definition parameters.h:289
CSG_Parameter * Get_Parent(void) const
virtual TSG_Parameter_Type Get_Type(void) const =0
bool asBool(void) const
Definition parameters.h:286
bool is_Input(void) const
Definition parameters.h:236
CSG_Parameters * Get_Parameters(void) const
const SG_Char * Get_Name(void) const
bool is_Enabled(bool bCheckEnv=true) const
bool is_Option(void) const
virtual bool Set_Value(int Value)
class CSG_Parameter_List * asList(void) const
CSG_Grid_System * asGrid_System(void) const
CSG_Data_Object * asDataObject(void) const
class CSG_Parameter_Range * asRange(void) const
CSG_Parameter * Get_Child(int iChild) const
Definition parameters.h:260
bool is_Output(void) const
Definition parameters.h:237
virtual bool is_Default(void) const
bool is_Information(void) const
Definition parameters.h:239
bool do_UseInCMD(void) const
const SG_Char * asString(void) const
Definition parameters.h:290
bool Cmp_Identifier(const CSG_String &Identifier) const
long asColor(void) const
Definition parameters.h:288
const SG_Char * Get_Description(void) const
bool do_UseInGUI(void) const
bool is_DataObject_List(void) const
int asInt(void) const
Definition parameters.h:287
bool is_Managed(void) const
bool Set_Callback(bool bActive=true)
bool Reset_Grid_System(void)
int Get_Count(void) const
void Set_Manager(class CSG_Data_Manager *pManager)
class CSG_Tool * Get_Tool(void) const
bool Set_History(CSG_MetaData &History, bool bOptions=true, bool bDataObjects=true)
CSG_Parameter * Get_Parameter(int i) const
bool Create(const CSG_Parameters &Parameters)
bool Restore_Defaults(bool bClearData=false)
bool Push(class CSG_Data_Manager *pManager=NULL, bool bRestoreDefaults=true)
TSG_PFNC_Parameter_Changed Set_Callback_On_Parameter_Changed(TSG_PFNC_Parameter_Changed pCallback)
bool Del_Parameter(int i)
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
bool Pop(void)
CSG_String AfterFirst(char Character) const
int Cmp(const CSG_String &String) const
void Clear(void)
size_t Replace(const CSG_String &Old, const CSG_String &New, bool bReplaceAll=true)
static CSG_String Format(const char *Format,...)
const SG_Char * c_str(void) const
CSG_String & Make_Lower(void)
int Printf(const char *Format,...)
bool is_Empty(void) const
bool Contains(const CSG_String &String) const
CSG_String & Prepend(const CSG_String &String)
int Get_Count(void) const
Definition api_core.h:714
CSG_String Format(const CSG_String &format="") const
Definition datetime.cpp:65
int Get_Minutes(void) const
Definition datetime.h:162
sLong Get_Milliseconds(void) const
Definition datetime.h:164
sLong Get_Seconds(void) const
Definition datetime.h:163
int Get_Hours(void) const
Definition datetime.h:161
static CSG_String Get_Script(CSG_Tool *pTool, bool bHeader, bool bAllParameters=true)
CSG_Tool_Library * Get_Library(int i) const
CSG_String Get_Category(void) const
CSG_String Get_Name(void) const
bool Reset_Grid_System(void)
Definition tool.cpp:1396
bool Message_Dlg_Confirm(const CSG_String &Text, const SG_Char *Caption=NULL)
Definition tool.cpp:708
const CSG_String & Get_Library(void) const
Definition tool.cpp:115
bool Dlg_Parameters(const CSG_String &Identifier)
Definition tool.cpp:532
const CSG_String & Get_File_Name(void) const
Definition tool.cpp:121
bool Set_Grid_System(const CSG_Grid_System &System)
Definition tool.cpp:1411
int Get_Parameters_Count(void) const
Definition tool.h:167
bool Set_Manager(class CSG_Data_Manager *pManager)
Definition tool.cpp:579
CSG_Grid_System * Get_Grid_System(void) const
Definition tool.cpp:1421
CSG_MetaData Get_History(int Depth=-1)
Definition tool.cpp:2957
bool Settings_Pop(void)
Definition tool.cpp:643
static bool Process_Get_Okay(bool bBlink=false)
Definition tool.cpp:855
bool Stop_Execution(bool bDialog=true)
Definition tool.cpp:687
class CSG_Data_Manager * Get_Manager(void) const
Definition tool.cpp:592
bool has_GUI(void) const
Definition tool.cpp:248
const CSG_String & Get_Author(void) const
Definition tool.cpp:143
bool Update_Parameter_States(void)
Definition tool.cpp:1434
static bool DataObject_Classify_StdDev(CSG_Data_Object *pDataObject, int Field=-1, double StdDev=0.5, double StdDev_Max=4.5, int Colors=-1)
Definition tool.cpp:1272
virtual bool is_Interactive(void) const
Definition tool.h:223
static bool DataObject_Classify_Quantile(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, bool bHistogram=true, int Colors=-1)
Definition tool.cpp:1242
CSG_Parameters * Get_Parameters(void)
Definition tool.h:165
CSG_String Get_Script(Script_Format Format, bool bHeader=true, int Arguments=0, bool bWrapArgs=true)
Definition tool.cpp:1475
CSG_Parameters * Add_Parameters(const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description)
Definition tool.cpp:504
static bool DataObject_Set_Colors(CSG_Data_Object *pDataObject, const CSG_Colors &Colors)
Definition tool.cpp:1010
const CSG_String & Get_Name(void) const
Definition tool.cpp:132
static CSG_Parameter * DataObject_Get_Parameter(CSG_Data_Object *pDataObject, const CSG_String &ID)
Definition tool.cpp:1058
static bool DataObject_Classify_Unique(CSG_Data_Object *pDataObject, int Field=-1, int Classes_Max=1024, int Colors=-1)
Definition tool.cpp:1212
static void Process_Set_Text(const CSG_String &Text)
Definition tool.cpp:861
bool Settings_Push(class CSG_Data_Manager *pManager=NULL)
Definition tool.cpp:630
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
Definition tool.cpp:1293
virtual void Destroy(void)
Definition tool.cpp:102
static bool DataObject_Classify_Geometric(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, bool bIncreasing=true, int Colors=-1)
Definition tool.cpp:1252
virtual bool On_Execute(void)=0
const CSG_Strings & Get_References(void) const
Definition tool.cpp:190
CSG_MetaData History_Supplement
Definition tool.h:258
bool has_CMD(void) const
Definition tool.cpp:254
static int _On_Parameter_Changed(CSG_Parameter *pParameter, int Flags)
Definition tool.cpp:461
void Add_Description(const CSG_String &String, bool bNewLine=true)
Definition tool.cpp:165
virtual ~CSG_Tool(void)
Definition tool.cpp:86
CSG_Parameters Parameters
Definition tool.h:256
void Set_Show_Progress(bool bOn=true)
Definition tool.cpp:663
virtual TSG_Tool_Type Get_Type(void) const
Definition tool.h:148
static bool DataObject_Get_Parameters(CSG_Data_Object *pDataObject, CSG_Parameters &Parameters)
Definition tool.cpp:1026
virtual bool do_Sync_Projections(void) const
Definition tool.h:216
static bool DataObject_Update(CSG_Data_Object *pDataObject, int Show=SG_UI_DATAOBJECT_UPDATE)
Definition tool.cpp:987
virtual bool Set_Progress(int Position, int Range) const
Definition tool.cpp:669
CSG_Tool(void)
Definition tool.cpp:67
bool Reset(bool bManager=true)
Definition tool.cpp:1364
virtual CSG_String Get_MenuPath(void)
Definition tool.h:162
void Set_Description(const CSG_String &String)
Definition tool.cpp:160
static bool DataObject_Set_Parameters(CSG_Data_Object *pDataObject, CSG_Parameters &Parameters)
Definition tool.cpp:1031
bool DataObject_Update_All(void)
Definition tool.cpp:824
void Set_Callback(bool bActive=true)
Definition tool.cpp:568
bool Reset_Manager(void)
Definition tool.cpp:1386
static bool DataObject_Set_Stretch_Percentile(CSG_Data_Object *pDataObject, int Field=-1, double Minimum=2., double Maximum=98., int Interval_Mode=0, double Interval_Log=1., int Colors=-1, bool bUpdateNow=false)
Definition tool.cpp:1181
bool Set_History(CSG_Data_Object *pDataObject, int Depth=-1)
Definition tool.cpp:2988
bool Execute(bool bAddHistory=false)
Definition tool.cpp:267
static bool DataObject_Get_Colors(CSG_Data_Object *pDataObject, CSG_Colors &Colors)
Definition tool.cpp:1005
void Message_Fmt(const char *Format,...)
Definition tool.cpp:930
static bool DataObject_Set_Parameter(CSG_Data_Object *pDataObject, CSG_Parameter *pParameter)
Definition tool.cpp:1065
void Set_Author(const CSG_String &String)
Definition tool.cpp:138
const CSG_String & Get_Version(void) const
Definition tool.cpp:154
static bool DataObject_Set_Stretch(CSG_Data_Object *pDataObject, int Field, double Minimum, double Maximum, int Interval_Mode=0, double Interval_Log=1., int Colors=-1, bool bUpdateNow=false)
Definition tool.cpp:1192
static bool DataObject_Set_Stretch_Linear(CSG_Data_Object *pDataObject, int Field=-1, double Minimum=5., double Maximum=95., int Interval_Mode=0, double Interval_Log=1., int Colors=-1, bool bUpdateNow=false)
Definition tool.cpp:1158
static bool DataObject_Classify_Natural(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, int Colors=-1)
Definition tool.cpp:1262
static bool DataObject_Classify_Equal(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, int Colors=-1)
Definition tool.cpp:1222
static bool DataObject_Set_Stretch_StdDev(CSG_Data_Object *pDataObject, int Field=-1, double StdDev=2., bool bKeepInRange=false, int Interval_Mode=0, double Interval_Log=1., int Colors=-1, bool bUpdateNow=false)
Definition tool.cpp:1169
const CSG_String & Get_Description(void) const
Definition tool.cpp:174
bool DataObject_Set_History(CSG_Parameter *pParameter, CSG_MetaData *pHistory=NULL)
Definition tool.cpp:3031
const CSG_String & Get_ID(void) const
Definition tool.h:150
bool Error_Set(TSG_Tool_Error Error_ID=TOOL_ERROR_Unknown)
Definition tool.cpp:714
bool Error_Fmt(const char *Format,...)
Definition tool.cpp:751
Script_Format
Definition tool.h:242
virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
Definition tool.cpp:491
bool Get_Projection(CSG_Projection &Projection) const
Definition tool.cpp:439
virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
Definition tool.cpp:485
void Add_Reference(const CSG_String &Authors, const CSG_String &Year, const CSG_String &Title, const CSG_String &Where, const SG_Char *Link=NULL, const SG_Char *Link_Text=NULL)
Definition tool.cpp:180
void Message_Add(const CSG_String &Text, bool bNewLine=true)
Definition tool.cpp:917
void Set_Version(const CSG_String &String)
Definition tool.cpp:149
void Message_Dlg(const CSG_String &Text, const SG_Char *Caption=NULL)
Definition tool.cpp:702
class CSG_Data_Manager * Create_Manager(void)
Definition tool.cpp:598
void Set_Name(const CSG_String &String)
Definition tool.cpp:127
static bool DataObject_Classify_Defined(CSG_Data_Object *pDataObject, int Field, double Interval, bool bOffset=false, double Offset=0., int Colors=-1)
Definition tool.cpp:1232
bool DataObject_Add(CSG_Data_Object *pDataObject, bool bUpdate=false)
Definition tool.cpp:808
bool Delete_Manager(bool bDetachData=false, bool bReset=true)
Definition tool.cpp:606
CSG_Data_Manager & SG_Get_Data_Manager(void)
int SG_Get_History_Depth(void)
CSG_String SG_Get_DataObject_Name(TSG_Data_Object_Type Type)
CSG_String SG_Get_DataObject_Class_Name(TSG_Data_Object_Type Type)
@ SG_DATAOBJECT_TYPE_PointCloud
Definition dataobject.h:123
@ SG_DATAOBJECT_TYPE_Grids
Definition dataobject.h:119
@ SG_DATAOBJECT_TYPE_TIN
Definition dataobject.h:122
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
@ SG_DATAOBJECT_TYPE_Grid
Definition dataobject.h:118
@ SG_DATAOBJECT_TYPE_Table
Definition dataobject.h:120
#define DATAOBJECT_NOTSET
Definition dataobject.h:129
#define SG_META_HISTORY
Definition dataobject.h:93
#define PARAMETER_CHECK_ENABLE
Definition parameters.h:191
#define PARAMETER_DESCRIPTION_PROPERTIES
Definition parameters.h:110
#define PARAMETER_CHECK_VALUES
Definition parameters.h:190
#define PARAMETER_INPUT_OPTIONAL
Definition parameters.h:103
#define PARAMETER_DESCRIPTION_TYPE
Definition parameters.h:108
#define PARAMETER_DESCRIPTION_NAME
Definition parameters.h:107
@ PARAMETER_TYPE_Degree
Definition parameters.h:129
@ PARAMETER_TYPE_FixedTable
Definition parameters.h:142
@ PARAMETER_TYPE_Node
Definition parameters.h:124
@ PARAMETER_TYPE_Grid
Definition parameters.h:149
@ PARAMETER_TYPE_Grid_List
Definition parameters.h:155
@ PARAMETER_TYPE_Text
Definition parameters.h:136
@ PARAMETER_TYPE_TIN
Definition parameters.h:153
@ PARAMETER_TYPE_Table
Definition parameters.h:151
@ PARAMETER_TYPE_Int
Definition parameters.h:127
@ PARAMETER_TYPE_Table_Fields
Definition parameters.h:146
@ PARAMETER_TYPE_Grids
Definition parameters.h:150
@ PARAMETER_TYPE_Color
Definition parameters.h:140
@ PARAMETER_TYPE_Colors
Definition parameters.h:141
@ PARAMETER_TYPE_DataObject_Output
Definition parameters.h:162
@ PARAMETER_TYPE_Table_List
Definition parameters.h:157
@ PARAMETER_TYPE_Double
Definition parameters.h:128
@ PARAMETER_TYPE_TIN_List
Definition parameters.h:159
@ PARAMETER_TYPE_Grid_System
Definition parameters.h:144
@ PARAMETER_TYPE_Date
Definition parameters.h:130
@ PARAMETER_TYPE_PointCloud_List
Definition parameters.h:160
@ PARAMETER_TYPE_Choices
Definition parameters.h:134
@ PARAMETER_TYPE_Data_Type
Definition parameters.h:132
@ PARAMETER_TYPE_Shapes
Definition parameters.h:152
@ PARAMETER_TYPE_Shapes_List
Definition parameters.h:158
@ PARAMETER_TYPE_Range
Definition parameters.h:131
@ PARAMETER_TYPE_PointCloud
Definition parameters.h:148
@ PARAMETER_TYPE_Table_Field
Definition parameters.h:145
@ PARAMETER_TYPE_Parameters
Definition parameters.h:164
@ PARAMETER_TYPE_FilePath
Definition parameters.h:137
@ PARAMETER_TYPE_Bool
Definition parameters.h:126
@ PARAMETER_TYPE_Grids_List
Definition parameters.h:156
@ PARAMETER_TYPE_String
Definition parameters.h:135
@ PARAMETER_TYPE_Choice
Definition parameters.h:133
#define PARAMETER_OUTPUT
Definition parameters.h:95
#define PARAMETER_DESCRIPTION_TEXT
Definition parameters.h:111
#define PARAMETER_INPUT
Definition parameters.h:94
#define SAGA_VERSION
Definition saga_api.h:90
#define GET_ID2(p, s)
#define INIT_CLASSIFY_OPTIONS(method)
Definition tool.cpp:1208
#define WRITE_CHILD(pChild, Prefix)
#define INIT_STRETCH_OPTIONS(method)
Definition tool.cpp:1145
#define CHECK_OBJECTS_NODE()
#define FORMAT_DATASET()
#define ADD_MESSAGE_EXECUTION(Text, Style)
#define GET_PARENT_NODE(prt)
#define CHECK_DATA_NODE(Name)
#define GET_ID1(p)
TSG_Tool_Error
Definition tool.h:112
@ TOOL_ERROR_Calculation
Definition tool.h:114
CSG_Tool_Library_Manager & SG_Get_Tool_Library_Manager(void)