SAGA API  v9.9
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"));
80  Parameters.Set_Tool(this);
81 
82  Set_Show_Progress(true);
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 
107 }
108 
109 
111 // //
113 
114 //---------------------------------------------------------
116 {
117  return( m_Library );
118 }
119 
120 //---------------------------------------------------------
122 {
123  return( m_File_Name );
124 }
125 
126 //---------------------------------------------------------
127 void CSG_Tool::Set_Name(const CSG_String &String)
128 {
129  Parameters.Set_Name(String);
130 }
131 
132 const CSG_String & CSG_Tool::Get_Name(void) const
133 {
134  return( Parameters.Get_Name() );
135 }
136 
137 //---------------------------------------------------------
138 void CSG_Tool::Set_Author(const CSG_String &String)
139 {
140  m_Author = String;
141 }
142 
143 const CSG_String & CSG_Tool::Get_Author(void) const
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 
166 {
168 }
169 
170 //---------------------------------------------------------
171 void 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)
172 {
173  Parameters.Add_Reference(Authors, Year, Title, Where, Link, Link_Text);
174 }
175 
176 void CSG_Tool::Add_Reference(const CSG_String &Link, const SG_Char *Link_Text)
177 {
178  Parameters.Add_Reference(Link, Link_Text);
179 }
180 
182 {
183  return( Parameters.Get_References() );
184 }
185 
186 //---------------------------------------------------------
188 {
189  if( !bSolved )
190  {
191  return( Get_MenuPath() );
192  }
193 
194  CSG_Strings Menu = SG_String_Tokenize(Get_MenuPath(), ";"); if( !Menu.Get_Count() ) { Menu += ""; }
195 
196  for(int i=0; i<Menu.Get_Count(); i++)
197  {
198  if( Menu[i].Length() > 1 && Menu[i][1] == ':' )
199  {
200  if( Menu[i][0] == 'A' || Menu[i][0] == 'a' ) // absolute menu path, overwrites library's default menu path
201  {
202  Menu[i] = Menu[i].AfterFirst(':');
203 
204  continue;
205  }
206 
207  Menu[i] = Menu[i].AfterFirst(':'); // Menu[0] == 'R' || Menu[0] == 'r' // menu path explicitly declared as relative to library's default menu path
208  }
209 
210  if( !m_Library_Menu.is_Empty() )
211  {
212  if( Menu[i].is_Empty() )
213  {
214  Menu[i] = m_Library_Menu;
215  }
216  else
217  {
218  Menu[i] = m_Library_Menu + "|" + Menu[i];
219  }
220  }
221  }
222 
223  CSG_String Menus;
224 
225  for(int i=0; i<Menu.Get_Count(); i++)
226  {
227  if( i > 0 )
228  {
229  Menus += ";";
230  }
231 
232  Menus += Menu[i];
233  }
234 
235  return( Menus );
236 }
237 
238 //---------------------------------------------------------
239 bool CSG_Tool::has_GUI(void) const
240 {
241  return( m_bGUI );
242 }
243 
244 //---------------------------------------------------------
245 bool CSG_Tool::has_CMD(void) const
246 {
247  return( m_bCMD );
248 }
249 
250 
252 // //
253 // //
254 // //
256 
257 //---------------------------------------------------------
258 bool CSG_Tool::Execute(bool bAddHistory)
259 {
260  #define ADD_MESSAGE_EXECUTION(Text, Style) { SG_UI_Msg_Add(Text, true, Style); if( has_GUI() ) { SG_UI_Msg_Add_Execution(Text, true, Style); } }
261 
262  //-----------------------------------------------------
263  if( m_bExecutes )
264  {
265  return( false );
266  }
267 
268  m_bExecutes = true;
269 
270  m_bError_Ignore = false;
271 
272  bool bResult = false;
273 
274  m_Execution_Info.Clear();
275 
277 
278  //-----------------------------------------------------
280  {
281  ADD_MESSAGE_EXECUTION(CSG_String::Format("[%s] %s...", Get_Name().c_str(), _TL("Execution started")), SG_UI_MSG_STYLE_SUCCESS);
282  }
283 
285 
286  if( Parameters.DataObjects_Create() == false )
287  {
288  _Synchronize_DataObjects(); // not all, but some objects might have been created!
289  }
290  else
291  {
292  Parameters.Msg_String(false);
293 
294  // SG_UI_Process_Set_Busy(true, CSG_String::Format("%s: %s...", _TL("Executing"), Get_Name().c_str()));
295  CSG_DateTime Started(CSG_DateTime::Now());
296 
298 //#if !defined(_DEBUG)
299 #define _TOOL_EXCEPTION
300  try
301  {
302 //#endif
304 
305  bResult = On_Execute();
306 
308 #ifdef _TOOL_EXCEPTION
309  } // try
310  catch(const std::exception &Exception)
311  {
312  Message_Dlg(Exception.what() , CSG_String::Format("%s | %s", Get_Name().c_str(), _TL("Access violation!")));
313  }
314  catch(...)
315  {
316  Message_Dlg(_TL("unspecified exception"), CSG_String::Format("%s | %s", Get_Name().c_str(), _TL("Access violation!")));
317  }
318  #endif
319 
321  CSG_TimeSpan Span = CSG_DateTime::Now() - Started;
322  // SG_UI_Process_Set_Busy(false);
323 
324  _Synchronize_DataObjects();
325 
326  if( !Process_Get_Okay(false) )
327  {
328  SG_UI_Msg_Add(_TL("Execution has been stopped by user!"), true, SG_UI_MSG_STYLE_BOLD);
329 
330  bResult = false;
331  }
332 
333  if( bResult && bAddHistory )
334  {
335  _Set_Output_History();
336  }
337 
338  //-------------------------------------------------
339  if( is_Interactive() )
340  {
341  if( bResult )
342  {
343  CSG_String Text(CSG_String::Format("\n%s...", _TL("Interactive tool started and is waiting for user input.")));
344 
345  SG_UI_Msg_Add (Text, false, SG_UI_MSG_STYLE_BOLD);
347  }
348  else
349  {
350  ADD_MESSAGE_EXECUTION(_TL("Interactive tool initialization failed."), SG_UI_MSG_STYLE_FAILURE);
351  }
352  }
353  else
354  {
355  CSG_String Time =
356  Span.Get_Hours () >= 1 ? (Span.Format("%Hh %Mm %Ss"))
357  : Span.Get_Minutes () >= 1 ? (Span.Format( "%Mm %Ss"))
358  : Span.Get_Seconds () >= 1 ? (Span.Format( "%Ss"))
359  : Span.Get_Milliseconds() >= 1 ? (Span.Format("%l ") + _TL("milliseconds"))
360  : CSG_String(_TL("less than 1 millisecond"));
361 
363  {
364  SG_UI_Msg_Add_Execution(CSG_String::Format("\n[%s] %s: %s", Get_Name().c_str(),
365  _TL("execution time"), Time.c_str()),
367  );
368  }
369  else
370  {
371  SG_UI_Msg_Add_Execution(CSG_String::Format("\n__________\n%s %s: %lld %s (%s)\n", _TL("total"),
372  _TL("execution time"), Span.Get_Milliseconds(), _TL("milliseconds"), Time.c_str()),
373  false, SG_UI_MSG_STYLE_BOLD
374  );
375 
376  ADD_MESSAGE_EXECUTION(CSG_String::Format("[%s] %s (%s)", Get_Name().c_str(),
377  bResult ? _TL("Execution succeeded") : _TL("Execution failed"), Time.c_str()),
379  );
380  }
381  }
382  }
383 
384  //-----------------------------------------------------
386 
387  m_bExecutes = false;
388 
391 
392  return( bResult );
393 }
394 
395 
397 // //
398 // //
399 // //
401 
402 //---------------------------------------------------------
403 bool CSG_Tool::_Synchronize_DataObjects(void)
404 {
405  Parameters.DataObjects_Synchronize();
406 
407  for(int i=0; i<Get_Parameters_Count(); i++)
408  {
409  Get_Parameters(i)->DataObjects_Synchronize();
410  }
411 
412  CSG_Projection Projection;
413 
414  if( do_Sync_Projections() && Get_Projection(Projection) )
415  {
416  Parameters.DataObjects_Set_Projection(Projection);
417 
418  for(int i=0; i<Get_Parameters_Count(); i++)
419  {
420  Get_Parameters(i)->DataObjects_Set_Projection(Projection);
421  }
422 
423  return( true );
424  }
425 
426  return( false );
427 }
428 
429 //---------------------------------------------------------
431 {
432  Projection.Destroy();
433 
434  Parameters.DataObjects_Get_Projection(Projection);
435 
436  for(int i=0; i<Get_Parameters_Count() && !Projection.is_Okay(); i++)
437  {
438  Get_Parameters(i)->DataObjects_Get_Projection(Projection);
439  }
440 
441  return( Projection.is_Okay() );
442 }
443 
444 
446 // //
447 // Parameters //
448 // //
450 
451 //---------------------------------------------------------
453 {
454  CSG_Parameters *pParameters = pParameter ? pParameter ->Get_Parameters() : NULL;
455  CSG_Tool *pTool = pParameters ? pParameters->Get_Tool () : NULL;
456 
457  if( pTool )
458  {
459  if( Flags & PARAMETER_CHECK_VALUES )
460  {
461  pTool->On_Parameter_Changed(pParameters, pParameter);
462  }
463 
464  if( Flags & PARAMETER_CHECK_ENABLE )
465  {
466  pTool->On_Parameters_Enable(pParameters, pParameter);
467  }
468 
469  return( 1 );
470  }
471 
472  return( 0 );
473 }
474 
475 //---------------------------------------------------------
477 {
478  return( 1 );
479 }
480 
481 //---------------------------------------------------------
483 {
484  return( 1 );
485 }
486 
487 
489 // //
490 // Extra Parameters //
491 // //
493 
494 //---------------------------------------------------------
495 CSG_Parameters * CSG_Tool::Add_Parameters(const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description)
496 {
497  CSG_Parameters *pParameters = new CSG_Parameters(); // (Name, Description, Identifier);
498 
499  pParameters->Create(this, Name, Description, Identifier);
501  pParameters->m_pTool = this;
502 
503  m_pParameters.Add(pParameters);
504 
505  return( pParameters );
506 }
507 
508 //---------------------------------------------------------
510 {
511  for(int i=0; i<Get_Parameters_Count(); i++)
512  {
513  if( Get_Parameters(i)->Cmp_Identifier(Identifier) )
514  {
515  return( Get_Parameters(i) );
516  }
517  }
518 
519  return( NULL );
520 }
521 
522 //---------------------------------------------------------
523 bool CSG_Tool::Dlg_Parameters(const CSG_String &Identifier)
524 {
525  CSG_Parameters *pParameters = Get_Parameters(Identifier);
526 
527  if( pParameters && (!pParameters->is_Managed() || Dlg_Parameters(pParameters, Get_Name())) )
528  {
529  pParameters->Set_History(History_Supplement);
530 
531  return( true );
532  }
533 
534  return( false );
535 }
536 
537 
539 // //
541 
542 //---------------------------------------------------------
543 bool CSG_Tool::Dlg_Parameters(CSG_Parameters *pParameters, const CSG_String &Caption)
544 {
545  return( pParameters ? Dlg_Parameters(*pParameters, Caption) : false );
546 }
547 
548 bool CSG_Tool::Dlg_Parameters(CSG_Parameters &Parameters, const CSG_String &Caption)
549 {
550  return( SG_UI_Dlg_Parameters(&Parameters, Caption.is_Empty() ? Get_Name() : Caption) );
551 }
552 
553 
555 // //
557 
558 //---------------------------------------------------------
559 void CSG_Tool::Set_Callback(bool bActive)
560 {
561  Parameters.Set_Callback(bActive);
562 
563  for(int i=0; i<Get_Parameters_Count(); i++)
564  {
565  Get_Parameters(i)->Set_Callback(bActive);
566  }
567 }
568 
569 //---------------------------------------------------------
571 {
572  Parameters.Set_Manager(pManager);
573 
574  for(int i=0; i<Get_Parameters_Count(); i++)
575  {
576  Get_Parameters(i)->Set_Manager(pManager);
577  }
578 
579  return( true );
580 }
581 
582 //---------------------------------------------------------
584 {
585  return( Parameters.Get_Manager() );
586 }
587 
588 //---------------------------------------------------------
590 {
592 
593  return( Get_Manager() );
594 }
595 
596 //---------------------------------------------------------
597 bool CSG_Tool::Delete_Manager(bool bDetachData, bool bReset)
598 {
599  CSG_Data_Manager *pManager = Get_Manager();
600 
601  if( pManager && pManager != &SG_Get_Data_Manager() )
602  {
603  pManager->Delete(bDetachData);
604 
605  delete(pManager);
606 
607  return( bReset ? Set_Manager(&SG_Get_Data_Manager()) : Set_Manager(NULL) );
608  }
609 
610  return( false );
611 }
612 
613 
615 // //
616 // //
617 // //
619 
620 //---------------------------------------------------------
622 {
623  Parameters.Push(pManager);
624 
625  for(int i=0; i<Get_Parameters_Count(); i++)
626  {
627  Get_Parameters(i)->Push(pManager);
628  }
629 
630  return( true );
631 }
632 
633 //---------------------------------------------------------
635 {
636  Parameters.Pop();
637 
638  for(int i=0; i<Get_Parameters_Count(); i++)
639  {
640  Get_Parameters(i)->Pop();
641  }
642 
643  return( true );
644 }
645 
646 
648 // //
649 // Progress //
650 // //
652 
653 //---------------------------------------------------------
655 {
656  m_bShow_Progress = bOn;
657 }
658 
659 //---------------------------------------------------------
660 bool CSG_Tool::Set_Progress(int Position, int Range) const
661 {
662  return( Set_Progress((double)Position / (double)Range) );
663 }
664 
665 //---------------------------------------------------------
666 bool CSG_Tool::Set_Progress(sLong Position, sLong Range) const
667 {
668  return( Set_Progress((double)Position / (double)Range) );
669 }
670 
671 //---------------------------------------------------------
672 bool CSG_Tool::Set_Progress(double Position, double Range) const
673 {
674  return( m_bShow_Progress ? SG_UI_Process_Set_Progress(Position, Range) : Process_Get_Okay(false) );
675 }
676 
677 //---------------------------------------------------------
678 bool CSG_Tool::Stop_Execution(bool bDialog)
679 {
680  m_bExecutes = false;
681 
682  return( SG_UI_Stop_Execution(bDialog) );
683 }
684 
685 
687 // //
688 // Message //
689 // //
691 
692 //---------------------------------------------------------
693 void CSG_Tool::Message_Dlg(const CSG_String &Text, const SG_Char *Caption)
694 {
695  SG_UI_Dlg_Message(Text, Caption && Caption[0] != '\0' ? Caption : Get_Name().c_str());
696 }
697 
698 //---------------------------------------------------------
699 bool CSG_Tool::Message_Dlg_Confirm(const CSG_String &Text, const SG_Char *Caption)
700 {
701  return( SG_UI_Dlg_Continue(Text, Caption && Caption[0] != '\0' ? Caption : Get_Name().c_str()) );
702 }
703 
704 //---------------------------------------------------------
706 {
707  switch( Error_ID )
708  {
709  default:
710  return( Error_Set(_TL("Unknown Error")) );
711 
713  return( Error_Set(_TL("Calculation Error")) );
714  }
715 }
716 
717 //---------------------------------------------------------
719 {
720  SG_UI_Msg_Add_Error(Text);
721 
722  m_Execution_Info += "\n____\n" + Text;
723 
724  if( SG_UI_Process_Get_Okay(false) && !m_bError_Ignore )
725  {
726  switch( SG_UI_Dlg_Error(Text, CSG_String::Format("%s: %s?", _TL("Error"), _TL("Ignore"))) )
727  {
728  default:
729  SG_UI_Process_Set_Okay(false);
730  break;
731 
732  case 1:
733  m_bError_Ignore = true;
734  break;
735  }
736  }
737 
738  return( SG_UI_Process_Get_Okay(false) );
739 }
740 
741 //---------------------------------------------------------
742 bool CSG_Tool::Error_Fmt(const char *Format, ...)
743 {
744  wxString _s;
745 
746  va_list argptr;
747 
748 #ifdef _SAGA_LINUX
749  // workaround as we only use wide characters
750  // since wx 2.9.4 so interpret strings as multibyte
751  wxString _Format(Format); _Format.Replace("%s", "%ls");
752  va_start(argptr, _Format);
753  _s.PrintfV(_Format, argptr);
754 #else
755  va_start(argptr, Format);
756  _s.PrintfV(Format, argptr);
757 #endif
758 
759  va_end(argptr);
760 
761  CSG_String s(&_s);
762 
763  return( Error_Set(s) );
764 }
765 
766 //---------------------------------------------------------
767 bool CSG_Tool::Error_Fmt(const wchar_t *Format, ...)
768 {
769  wxString _s;
770 
771  va_list argptr;
772 
773 #ifdef _SAGA_LINUX
774  // workaround as we only use wide characters
775  // since wx 2.9.4 so interpret strings as multibyte
776  wxString _Format(Format); _Format.Replace("%s", "%ls");
777  va_start(argptr, _Format);
778  _s.PrintfV(_Format, argptr);
779 #else
780  va_start(argptr, Format);
781  _s.PrintfV(Format, argptr);
782 #endif
783 
784  va_end(argptr);
785 
786  CSG_String s(&_s);
787 
788  return( Error_Set(s) );
789 }
790 
791 
793 // //
794 // DataObjects / GUI Interaction //
795 // //
797 
798 //---------------------------------------------------------
799 bool CSG_Tool::DataObject_Add(CSG_Data_Object *pDataObject, bool bShow)
800 {
801  if( Parameters.Get_Manager() )
802  {
803  Parameters.Get_Manager()->Add(pDataObject);
804  }
805 
806  if( Parameters.Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
807  {
809  }
810 
811  return( true );
812 }
813 
814 //---------------------------------------------------------
816 {
817  for(int i=0; i<Parameters.Get_Count(); i++)
818  {
819  if( Parameters(i)->is_Output() )
820  {
821  if( Parameters(i)->is_DataObject() )
822  {
823  DataObject_Update(Parameters(i)->asDataObject(), false);
824  }
825  else if( Parameters(i)->is_DataObject_List() )
826  {
827  for(int j=0; j<Parameters(i)->asList()->Get_Item_Count(); j++)
828  {
829  DataObject_Update(Parameters(i)->asList()->Get_Item(j), false);
830  }
831  }
832  }
833  }
834 
835  return( true );
836 }
837 
838 
840 // //
841 // Static Data Message/Progress Functions //
842 // //
844 
845 //---------------------------------------------------------
846 bool CSG_Tool::Process_Get_Okay(bool bBlink)
847 {
848  return( SG_UI_Process_Get_Okay(bBlink) );
849 }
850 
851 //---------------------------------------------------------
853 {
855 }
856 
857 //---------------------------------------------------------
858 void CSG_Tool::Process_Set_Text(const char *Format, ...)
859 {
860  wxString _s;
861 
862  va_list argptr;
863 
864  #ifdef _SAGA_LINUX
865  // workaround as we only use wide characters
866  // since wx 2.9.4 so interpret strings as multibyte
867  wxString _Format(Format); _Format.Replace("%s", "%ls");
868  va_start(argptr, _Format);
869  _s.PrintfV(_Format, argptr);
870  #else
871  va_start(argptr, Format);
872  _s.PrintfV(Format, argptr);
873  #endif
874 
875  va_end(argptr);
876 
877  CSG_String s(&_s);
878 
880 }
881 
882 //---------------------------------------------------------
883 void CSG_Tool::Process_Set_Text(const wchar_t *Format, ...)
884 {
885  wxString _s;
886 
887  va_list argptr;
888 
889  #ifdef _SAGA_LINUX
890  // workaround as we only use wide characters
891  // since wx 2.9.4 so interpret strings as multibyte
892  wxString _Format(Format); _Format.Replace("%s", "%ls");
893  va_start(argptr, _Format);
894  _s.PrintfV(_Format, argptr);
895  #else
896  va_start(argptr, Format);
897  _s.PrintfV(Format, argptr);
898  #endif
899 
900  va_end(argptr);
901 
902  CSG_String s(&_s);
903 
905 }
906 
907 //---------------------------------------------------------
908 void CSG_Tool::Message_Add(const CSG_String &Text, bool bNewLine)
909 {
910  SG_UI_Msg_Add_Execution(Text, bNewLine);
911 
912  if( bNewLine )
913  {
914  m_Execution_Info += "\n";
915  }
916 
917  m_Execution_Info += Text;
918 }
919 
920 //---------------------------------------------------------
921 void CSG_Tool::Message_Fmt(const char *Format, ...)
922 {
923  wxString _s;
924 
925  va_list argptr;
926 
927  #ifdef _SAGA_LINUX
928  // workaround as we only use wide characters
929  // since wx 2.9.4 so interpret strings as multibyte
930  wxString _Format(Format); _Format.Replace("%s", "%ls");
931  va_start(argptr, _Format);
932  _s.PrintfV(_Format, argptr);
933  #else
934  va_start(argptr, Format);
935  _s.PrintfV(Format, argptr);
936  #endif
937 
938  va_end(argptr);
939 
940  CSG_String s(&_s);
941 
942  Message_Add(s, false);
943 }
944 
945 //---------------------------------------------------------
946 void CSG_Tool::Message_Fmt(const wchar_t *Format, ...)
947 {
948  wxString _s;
949 
950  va_list argptr;
951 
952  #ifdef _SAGA_LINUX
953  // workaround as we only use wide characters
954  // since wx 2.9.4 so interpret strings as multibyte
955  wxString _Format(Format); _Format.Replace("%s", "%ls");
956  va_start(argptr, _Format);
957  _s.PrintfV(_Format, argptr);
958  #else
959  va_start(argptr, Format);
960  _s.PrintfV(Format, argptr);
961  #endif
962 
963  va_end(argptr);
964 
965  CSG_String s(&_s);
966 
967  Message_Add(s, false);
968 }
969 
970 
972 // //
973 // Static Data Object Property Functions //
974 // //
976 
977 //---------------------------------------------------------
978 bool CSG_Tool::DataObject_Update(CSG_Data_Object *pDataObject, int Show)
979 {
980  return( SG_UI_DataObject_Update(pDataObject, Show, NULL) );
981 }
982 
983 bool CSG_Tool::DataObject_Update(CSG_Data_Object *pDataObject, double Minimum, double Maximum, int Show)
984 {
985  CSG_Parameters P;
986 
987  return( DataObject_Get_Parameters(pDataObject, P)
988  && P.Set_Parameter("STRETCH_DEFAULT" , 3 ) // manual
989  && P.Set_Parameter("METRIC_ZRANGE.MIN", Minimum)
990  && P.Set_Parameter("METRIC_ZRANGE.MAX", Maximum)
991  && SG_UI_DataObject_Update(pDataObject, Show, &P)
992  );
993 }
994 
995 //---------------------------------------------------------
997 {
998  return( SG_UI_DataObject_Colors_Get(pDataObject, &Colors) );
999 }
1000 
1002 {
1003  CSG_Colors c(Colors);
1004 
1005  return( SG_UI_DataObject_Colors_Set(pDataObject, &c) );
1006 }
1007 
1008 bool CSG_Tool::DataObject_Set_Colors(CSG_Data_Object *pDataObject, int nColors, int Palette, bool bRevert)
1009 {
1010  CSG_Colors c(nColors, Palette, bRevert);
1011 
1012  return( SG_UI_DataObject_Colors_Set(pDataObject, &c) );
1013 }
1014 
1015 //---------------------------------------------------------
1017 {
1018  return( SG_UI_DataObject_Params_Get(pDataObject, &Parameters) );
1019 }
1020 
1022 {
1023  return( SG_UI_DataObject_Params_Set(pDataObject, &Parameters) );
1024 }
1025 
1027 {
1028  if( pDataObject == pCopy )
1029  {
1030  return( true );
1031  }
1032 
1033  CSG_Parameters P;
1034 
1035  if( DataObject_Get_Parameters(pCopy, P) )
1036  {
1037  P.Del_Parameter("OBJECT_NODATA" );
1038  P.Del_Parameter("OBJECT_Z_FACTOR");
1039  P.Del_Parameter("OBJECT_Z_OFFSET");
1040 
1041  return( DataObject_Set_Parameters(pDataObject, P) );
1042  }
1043 
1044  return( false );
1045 }
1046 
1047 //---------------------------------------------------------
1049 {
1050  static CSG_Parameters P;
1051 
1052  return( DataObject_Get_Parameters(pDataObject, P) ? P(ID) : NULL );
1053 }
1054 
1056 {
1057  CSG_Parameters P;
1058 
1059  return( P._Add(pParameter) != NULL && DataObject_Set_Parameters(pDataObject, P) );
1060 }
1061 
1063 {
1064  CSG_Parameter *pParameter = DataObject_Get_Parameter(pCopy, ID);
1065 
1066  return( DataObject_Set_Parameter(pDataObject, pParameter) );
1067 }
1068 
1069 bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, int Value)
1070 {
1071  CSG_Parameters P;
1072 
1073  if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1074  {
1075  return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1076  }
1077 
1078  return( false );
1079 }
1080 
1081 bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double Value)
1082 {
1083  CSG_Parameters P;
1084 
1085  if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1086  {
1087  return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1088  }
1089 
1090  return( false );
1091 }
1092 
1093 bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, void *Value)
1094 {
1095  CSG_Parameters P;
1096 
1097  if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1098  {
1099  return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1100  }
1101 
1102  return( false );
1103 }
1104 
1105 bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, const SG_Char *Value)
1106 {
1107  CSG_Parameters P;
1108 
1109  if( DataObject_Get_Parameters(pDataObject, P) && P(ID) )
1110  {
1111  return( P(ID)->Set_Value(Value) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1112  }
1113 
1114  return( false );
1115 }
1116 
1117 bool CSG_Tool::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double loVal, double hiVal) // Range Parameter
1118 {
1119  CSG_Parameters P;
1120 
1121  if( DataObject_Get_Parameters(pDataObject, P) && P(ID) && P(ID)->Get_Type() == PARAMETER_TYPE_Range )
1122  {
1123  return( P(ID)->asRange()->Set_Range(loVal, hiVal) && DataObject_Set_Parameter(pDataObject, P(ID)) );
1124  }
1125 
1126  return( false );
1127 }
1128 
1129 
1131 // //
1133 
1134 //---------------------------------------------------------
1135 #define INIT_STRETCH_OPTIONS(method) { if( !pDataObject || (pDataObject->asTable(true) && (Field < 0 || Field >= pDataObject->asTable(true)->Get_Field_Count())) ) { return( false ); }\
1136  if( Colors >= 0 ) { DataObject_Set_Colors(pDataObject, -1, Colors); }\
1137  DataObject_Set_Parameter(pDataObject, "COLORS_TYPE" , 3); /* graduated colors */\
1138  DataObject_Set_Parameter(pDataObject, "STRETCH_DEFAULT" , method);\
1139  DataObject_Set_Parameter(pDataObject, "METRIC_SCALE_MODE", Interval_Mode);\
1140  DataObject_Set_Parameter(pDataObject, "METRIC_SCALE_LOG" , Interval_Log );\
1141  if( pDataObject->asTable(true) )\
1142  { DataObject_Set_Parameter(pDataObject, "METRIC_FIELD" , Field);\
1143  DataObject_Set_Parameter(pDataObject, "METRIC_MORMAL", pDataObject->asTable(true)->Get_Field_Count());\
1144  }\
1145 }
1146 
1147 //---------------------------------------------------------
1148 bool 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)
1149 {
1151 
1152  DataObject_Set_Parameter(pDataObject, "STRETCH_LINEAR.MIN", Minimum);
1153  DataObject_Set_Parameter(pDataObject, "STRETCH_LINEAR.MAX", Maximum);
1154 
1155  return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1156 }
1157 
1158 //---------------------------------------------------------
1159 bool 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)
1160 {
1162 
1163  DataObject_Set_Parameter(pDataObject, "STRETCH_STDDEV" , StdDev );
1164  DataObject_Set_Parameter(pDataObject, "STRETCH_INRANGE", bKeepInRange);
1165  DataObject_Update(pDataObject);
1166 
1167  return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1168 }
1169 
1170 //---------------------------------------------------------
1171 bool 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)
1172 {
1174 
1175  DataObject_Set_Parameter(pDataObject, "STRETCH_PCTL.MIN", Minimum);
1176  DataObject_Set_Parameter(pDataObject, "STRETCH_PCTL.MAX", Maximum);
1177 
1178  return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1179 }
1180 
1181 //---------------------------------------------------------
1182 bool 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)
1183 {
1185 
1186  DataObject_Set_Parameter(pDataObject, "METRIC_ZRANGE.MIN", Minimum);
1187  DataObject_Set_Parameter(pDataObject, "METRIC_ZRANGE.MAX", Maximum);
1188 
1189  return( bUpdateNow ? DataObject_Update(pDataObject) : true );
1190 }
1191 
1192 
1194 // //
1196 
1197 //---------------------------------------------------------
1198 #define INIT_CLASSIFY_OPTIONS(method) if( !pDataObject || (pDataObject->asTable(true) && (Field < 0 || Field >= pDataObject->asTable(true)->Get_Field_Count())) ) { return( false ); }\
1199  CSG_MetaData Options; Options.Add_Child("METHOD", method); Options.Add_Child("COLORS", Colors); Options.Add_Child("FIELD", Field);
1200 
1201 //---------------------------------------------------------
1202 bool CSG_Tool::DataObject_Classify_Unique(CSG_Data_Object *pDataObject, int Field, int maxClasses, int Colors)
1203 {
1205 
1206  Options.Add_Child("MAXCLASSES", maxClasses);
1207 
1208  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1209 }
1210 
1211 //---------------------------------------------------------
1212 bool CSG_Tool::DataObject_Classify_Equal(CSG_Data_Object *pDataObject, int Field, int Classes, int Colors)
1213 {
1215 
1216  Options.Add_Child("CLASSES", Classes);
1217 
1218  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1219 }
1220 
1221 //---------------------------------------------------------
1222 bool CSG_Tool::DataObject_Classify_Defined(CSG_Data_Object *pDataObject, int Field, double Interval, bool bOffset, double Offset, int Colors)
1223 {
1225 
1226  Options.Add_Child("INTERVAL", Interval); if( bOffset ) { Options.Add_Child("OFFSET", Offset); }
1227 
1228  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1229 }
1230 
1231 //---------------------------------------------------------
1232 bool CSG_Tool::DataObject_Classify_Quantile(CSG_Data_Object *pDataObject, int Field, int Classes, bool bHistogram, int Colors)
1233 {
1235 
1236  Options.Add_Child("CLASSES", Classes); Options.Add_Child("HISTOGRAM", bHistogram ? 1 : 0);
1237 
1238  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1239 }
1240 
1241 //---------------------------------------------------------
1242 bool CSG_Tool::DataObject_Classify_Geometric(CSG_Data_Object *pDataObject, int Field, int Classes, bool bIncreasing, int Colors)
1243 {
1245 
1246  Options.Add_Child("CLASSES", Classes); Options.Add_Child("INCREASING", bIncreasing ? 1 : 0);
1247 
1248  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1249 }
1250 
1251 //---------------------------------------------------------
1252 bool CSG_Tool::DataObject_Classify_Natural(CSG_Data_Object *pDataObject, int Field, int Classes, int Colors)
1253 {
1255 
1256  Options.Add_Child("CLASSES", Classes);
1257 
1258  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1259 }
1260 
1261 //---------------------------------------------------------
1262 bool CSG_Tool::DataObject_Classify_StdDev(CSG_Data_Object *pDataObject, int Field, double StdDev, double StdDev_Max, int Colors)
1263 {
1265 
1266  Options.Add_Child("STDDEV", StdDev); Options.Add_Child("STDDEV_MAX", StdDev_Max);
1267 
1268  return( SG_UI_DataObject_Classify(pDataObject, Options) );
1269 }
1270 
1271 
1273 // //
1274 // //
1275 // //
1277 
1278 //---------------------------------------------------------
1282 //---------------------------------------------------------
1283 bool CSG_Tool::Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue) { return( Parameters.Set_Parameter(ID, pValue) ); }
1284 bool CSG_Tool::Set_Parameter(const char *ID, CSG_Parameter *pValue) { return( Parameters.Set_Parameter(ID, pValue) ); }
1285 bool CSG_Tool::Set_Parameter(const wchar_t *ID, CSG_Parameter *pValue) { return( Parameters.Set_Parameter(ID, pValue) ); }
1286 
1287 //---------------------------------------------------------
1291 //---------------------------------------------------------
1292 bool CSG_Tool::Set_Parameter(const CSG_String &ID, int Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1293 bool CSG_Tool::Set_Parameter(const char *ID, int Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1294 bool CSG_Tool::Set_Parameter(const wchar_t *ID, int Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1295 
1296 //---------------------------------------------------------
1300 //---------------------------------------------------------
1301 bool CSG_Tool::Set_Parameter(const CSG_String &ID, double Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1302 bool CSG_Tool::Set_Parameter(const char *ID, double Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1303 bool CSG_Tool::Set_Parameter(const wchar_t *ID, double Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1304 
1305 //---------------------------------------------------------
1309 //---------------------------------------------------------
1310 bool CSG_Tool::Set_Parameter(const CSG_String &ID, void *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1311 bool CSG_Tool::Set_Parameter(const char *ID, void *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1312 bool CSG_Tool::Set_Parameter(const wchar_t *ID, void *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1313 
1314 //---------------------------------------------------------
1318 //---------------------------------------------------------
1319 bool CSG_Tool::Set_Parameter(const CSG_String &ID, const CSG_String &Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1320 bool CSG_Tool::Set_Parameter(const char *ID, const CSG_String &Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1321 bool CSG_Tool::Set_Parameter(const wchar_t *ID, const CSG_String &Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1322 
1323 //---------------------------------------------------------
1327 //---------------------------------------------------------
1328 bool CSG_Tool::Set_Parameter(const CSG_String &ID, const char *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1329 bool CSG_Tool::Set_Parameter(const char *ID, const char *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1330 bool CSG_Tool::Set_Parameter(const wchar_t *ID, const char *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1331 
1332 //---------------------------------------------------------
1336 //---------------------------------------------------------
1337 bool CSG_Tool::Set_Parameter(const CSG_String &ID, const wchar_t *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1338 bool CSG_Tool::Set_Parameter(const char *ID, const wchar_t *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1339 bool CSG_Tool::Set_Parameter(const wchar_t *ID, const wchar_t *Value, int Type) { return( Parameters.Set_Parameter(ID, Value, Type) ); }
1340 
1341 
1343 // //
1344 // //
1345 // //
1347 
1348 //---------------------------------------------------------
1354 bool CSG_Tool::Reset(bool bManager)
1355 {
1357 
1358  if( bManager )
1359  {
1360  Reset_Manager();
1361  }
1362 
1363  for(int i=0; i<Get_Parameters_Count(); i++)
1364  {
1365  Get_Parameters(i)->Restore_Defaults(true);
1366  }
1367 
1368  return( Parameters.Restore_Defaults(true) );
1369 }
1370 
1371 //---------------------------------------------------------
1377 {
1378  return( Set_Manager(&SG_Get_Data_Manager()) );
1379 }
1380 
1381 //---------------------------------------------------------
1387 {
1388  for(int i=0; i<Get_Parameters_Count(); i++)
1389  {
1391  }
1392 
1393  return( Parameters.Reset_Grid_System() );
1394 }
1395 
1396 //---------------------------------------------------------
1402 {
1403  return( Parameters.Set_Grid_System(System) );
1404 }
1405 
1406 //---------------------------------------------------------
1412 {
1413  return( Parameters.Get_Grid_System() );
1414 }
1415 
1416 
1418 // //
1419 // //
1420 // //
1422 
1423 //---------------------------------------------------------
1425 {
1426  _Update_Parameter_States(&Parameters);
1427 
1428  for(int i=0; i<Get_Parameters_Count(); i++)
1429  {
1430  _Update_Parameter_States(Get_Parameters(i));
1431  }
1432 
1433  return( true );
1434 }
1435 
1436 //---------------------------------------------------------
1437 void CSG_Tool::_Update_Parameter_States(CSG_Parameters *pParameters)
1438 {
1439  if( pParameters )
1440  {
1441  for(int i=0; i<pParameters->Get_Count(); i++)
1442  {
1443  CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
1444 
1445  if( pParameter->Get_Type() == PARAMETER_TYPE_Parameters )
1446  {
1447  _Update_Parameter_States(pParameter->asParameters());
1448  }
1449  else
1450  {
1451  On_Parameters_Enable(pParameters, pParameter);
1452  }
1453  }
1454  }
1455 }
1456 
1457 
1459 // //
1460 // Script //
1461 // //
1463 
1464 //---------------------------------------------------------
1465 CSG_String CSG_Tool::Get_Script(Script_Format Format, bool bHeader, int Arguments, bool bWrapArgs)
1466 {
1467  switch( Format )
1468  {
1469  case Script_Format::CMD_Shell : return( _Get_Script_CMD ( bHeader, Arguments > 0, bWrapArgs, false ) );
1470  case Script_Format::CMD_Batch : return( _Get_Script_CMD ( bHeader, Arguments > 0, bWrapArgs, true ) );
1471  case Script_Format::CMD_Usage : return( _Get_Script_CMD_Usage ( ) );
1472 
1473  case Script_Format::Toolchain : return( CSG_Tool_Chain::Get_Script(this, bHeader, Arguments > 0 ) );
1474 
1475  case Script_Format::Python : return( _Get_Script_Python ( bHeader, Arguments > 0 ) );
1476 
1477  case Script_Format::Python_Wrapper_Func_Name : return( _Get_Script_Python_Wrap ( bHeader, true , false, 1, bWrapArgs ) );
1478  case Script_Format::Python_Wrapper_Func_ID : return( _Get_Script_Python_Wrap ( bHeader, false, false, 1, bWrapArgs ) );
1479 
1480  case Script_Format::Python_Wrapper_Call_Name : return( _Get_Script_Python_Wrap ( bHeader, true , true , Arguments, bWrapArgs ) );
1481  case Script_Format::Python_Wrapper_Call_ID : return( _Get_Script_Python_Wrap ( bHeader, false, true , Arguments, bWrapArgs ) );
1482  }
1483 
1484  return( "" );
1485 }
1486 
1487 
1489 // //
1491 
1492 //---------------------------------------------------------
1493 CSG_String CSG_Tool::_Get_Script_CMD(bool bHeader, bool bAllArguments, bool bWrapArgs, bool bBatch)
1494 {
1495  CSG_String Script;
1496 
1497  if( bHeader )
1498  {
1499  if( bBatch ) // DOS/Windows Batch Script
1500  {
1501  Script += "@ECHO OFF\n\n";
1502  Script += "PUSHD %~dp0\n\n";
1503  Script += "REM SET SAGA_TLB=C:\\MyTools\n\n";
1504  Script += "SET SAGA_CMD=" + SG_UI_Get_Application_Path(true) + "saga_cmd.exe\n\n";
1505  Script += "REM Tool: " + Get_Name() + "\n\n";
1506  Script += "%SAGA_CMD%";
1507  }
1508  else // Bash Shell Script
1509  {
1510  Script += "#!/bin/bash\n\n";
1511  Script += "# export SAGA_TLB=~/mytools\n\n";
1512  Script += "# tool: " + Get_Name() + "\n\n";
1513  Script += "saga_cmd";
1514  }
1515  }
1516  else
1517  {
1518  Script += "saga_cmd";
1519  }
1520 
1521  //-----------------------------------------------------
1522  Script += Get_Library().Contains(" ") // white space? use quotation marks!
1523  ? " \"" + Get_Library() + "\""
1524  : " " + Get_Library();
1525 
1526  Script += Get_ID().Contains (" ") // white space? use quotation marks!
1527  ? " \"" + Get_ID () + "\""
1528  : " " + Get_ID ();
1529 
1530  _Get_Script_CMD(Script, Get_Parameters(), bAllArguments, bWrapArgs, bBatch);
1531 
1532  for(int i=0; i<Get_Parameters_Count(); i++)
1533  {
1534  _Get_Script_CMD(Script, Get_Parameters(i), bAllArguments, bWrapArgs, bBatch);
1535  }
1536 
1537  //-----------------------------------------------------
1538  if( bHeader )
1539  {
1540  Script += bBatch ? "\n\nPAUSE\n" : "\n";
1541  }
1542 
1543  return( Script );
1544 }
1545 
1546 //---------------------------------------------------------
1547 void CSG_Tool::_Get_Script_CMD(CSG_String &Script, CSG_Parameters *pParameters, bool bAllArguments, bool bWrapArgs, bool bBatch)
1548 {
1549  #define GET_ID1(p) (p->Get_Parameters()->Get_Identifier().Length() > 0 \
1550  ? CSG_String::Format("%s_%s", p->Get_Parameters()->Get_Identifier().c_str(), p->Get_Identifier()) \
1551  : CSG_String::Format(p->Get_Identifier())).c_str()
1552 
1553  #define GET_ID2(p, s) CSG_String::Format("%s_%s", GET_ID1(p), s).c_str()
1554 
1555  const char *Prefix = !bWrapArgs ? " -" : bBatch ? " ^\n -" : " \\\n -";
1556  const char *StrFmt = bBatch ? "%s=\"%s\"" : "%s=\\\"\"%s\"\\\"";
1557 
1558  //-----------------------------------------------------
1559  for(int iParameter=0; iParameter<pParameters->Get_Count(); iParameter++)
1560  {
1561  CSG_Parameter *p = pParameters->Get_Parameter(iParameter);
1562 
1563  if( !bAllArguments && (!p->is_Enabled(false) || p->is_Information() || !p->do_UseInCMD()) )
1564  {
1565  continue;
1566  }
1567 
1568  switch( p->Get_Type() )
1569  {
1570  default:
1571  break;
1572 
1573  case PARAMETER_TYPE_Bool :
1574  Script += Prefix + CSG_String::Format("%s=%d", GET_ID1(p), p->asBool() ? 1 : 0);
1575  break;
1576 
1577  case PARAMETER_TYPE_Int :
1579  case PARAMETER_TYPE_Choice :
1581  Script += Prefix + CSG_String::Format("%s=%d", GET_ID1(p), p->asInt());
1582  break;
1583 
1584  case PARAMETER_TYPE_Choices :
1586  if( p->asString() && *p->asString() )
1587  {
1588  Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->asString());
1589  }
1590  break;
1591 
1592  case PARAMETER_TYPE_Color :
1593  Script += Prefix + CSG_String::Format("%s=\"%s\"", GET_ID1(p), SG_Color_To_Text(p->asColor()).c_str());
1594  break;
1595 
1596  case PARAMETER_TYPE_Double :
1597  case PARAMETER_TYPE_Degree :
1598  Script += Prefix + CSG_String::Format("%s=%g", GET_ID1(p), p->asDouble());
1599  break;
1600 
1601  case PARAMETER_TYPE_Range :
1602  Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T("MIN")), p->asRange()->Get_Min());
1603  Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T("MAX")), p->asRange()->Get_Max());
1604  break;
1605 
1606  case PARAMETER_TYPE_String :
1607  if( ((CSG_Parameter_String *)p)->is_Password() )
1608  {
1609  Script += Prefix + CSG_String::Format("%s=\"***\"", GET_ID1(p));
1610  break;
1611  }
1612 
1613  case PARAMETER_TYPE_Date :
1614  case PARAMETER_TYPE_Text :
1616  Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->asString());
1617  break;
1618 
1620  Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->asString());
1621  break;
1622 
1624  if( p->Get_Children_Count() == 0 )
1625  {
1626  Script += Prefix + CSG_String::Format("%s=%d", GET_ID2(p, SG_T("NX")), p->asGrid_System()->Get_NX ());
1627  Script += Prefix + CSG_String::Format("%s=%d", GET_ID2(p, SG_T("NY")), p->asGrid_System()->Get_NY ());
1628  Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T( "X")), p->asGrid_System()->Get_XMin ());
1629  Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T( "Y")), p->asGrid_System()->Get_YMin ());
1630  Script += Prefix + CSG_String::Format("%s=%g", GET_ID2(p, SG_T( "D")), p->asGrid_System()->Get_Cellsize());
1631  }
1632  break;
1633 
1635  case PARAMETER_TYPE_Grid :
1636  case PARAMETER_TYPE_Grids :
1637  case PARAMETER_TYPE_Table :
1638  case PARAMETER_TYPE_Shapes :
1639  case PARAMETER_TYPE_TIN :
1641  if( p->is_Input() )
1642  {
1643  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"));
1644  }
1645  else
1646  {
1647  CSG_String File(p->Get_Name());
1648 
1649  switch( p->Get_DataObject_Type() )
1650  {
1651  case SG_DATAOBJECT_TYPE_Grid : File += ".sg-grd-z"; break;
1652  case SG_DATAOBJECT_TYPE_Grids : File += ".sg-gds-z"; break;
1653  case SG_DATAOBJECT_TYPE_Table : File += ".txt" ; break;
1654  case SG_DATAOBJECT_TYPE_Shapes : File += ".geojson" ; break;
1655  case SG_DATAOBJECT_TYPE_PointCloud: File += ".sg-pts-z"; break;
1656  case SG_DATAOBJECT_TYPE_TIN : File += ".geojson" ; break;
1657  default : File += ".dat" ; break;
1658  }
1659 
1660  Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), File.c_str());
1661  }
1662  break;
1663 
1670  if( p->is_Input() )
1671  {
1672  Script += Prefix + CSG_String::Format("%s=", GET_ID1(p));
1673 
1674  if( p->asList()->Get_Item_Count() == 0 )
1675  {
1676  Script += "file(s)";
1677  }
1678  else
1679  {
1680  Script += SG_File_Exists(p->asList()->Get_Item(0)->Get_File_Name())
1681  ? p->asList()->Get_Item(0)->Get_File_Name() : _TL("memory");
1682 
1683  for(int iObject=1; iObject<p->asList()->Get_Item_Count(); iObject++)
1684  {
1685  Script += ";";
1686  Script += SG_File_Exists(p->asList()->Get_Item(iObject)->Get_File_Name())
1687  ? p->asList()->Get_Item(iObject)->Get_File_Name() : _TL("memory");
1688  }
1689  }
1690  }
1691  else
1692  {
1693  Script += Prefix + CSG_String::Format(StrFmt, GET_ID1(p), p->Get_Name());
1694  }
1695  break;
1696  }
1697  }
1698 }
1699 
1700 
1702 // //
1704 
1705 //---------------------------------------------------------
1706 CSG_String CSG_Tool::_Get_Script_CMD_Usage(void)
1707 {
1708  wxCmdLineParser Parser; Parser.SetSwitchChars("-");
1709 
1710  _Get_Script_CMD_Usage(Get_Parameters(), Parser);
1711 
1712  for(int i=0; i<Get_Parameters_Count(); i++)
1713  {
1714  _Get_Script_CMD_Usage(Get_Parameters(i), Parser);
1715  }
1716 
1717  wxString Usage = wxString::Format("\nUsage: saga_cmd %s %s %s", Get_Library().c_str(), Get_ID().c_str(),
1718  Parser.GetUsageString().AfterFirst(' ').AfterFirst(' ')
1719  );
1720 
1721  CSG_String _Usage(&Usage);
1722 
1723  return( _Usage );
1724 }
1725 
1726 //---------------------------------------------------------
1727 void CSG_Tool::_Get_Script_CMD_Usage(CSG_Parameters *pParameters, wxCmdLineParser &Parser)
1728 {
1729  for(int i=0; i<pParameters->Get_Count(); i++)
1730  {
1731  CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
1732 
1733  //-------------------------------------------------
1734  if( pParameter->is_DataObject() ) // reset data object parameters, avoids problems when tool is called more than once without un-/reloading
1735  {
1736  pParameter->Set_Value(DATAOBJECT_NOTSET);
1737  }
1738  else if( pParameter->is_DataObject_List() )
1739  {
1740  pParameter->asList()->Del_Items();
1741  }
1742 
1743  //-------------------------------------------------
1744  if( pParameter->do_UseInCMD() == false )
1745  {
1746  continue;
1747  }
1748 
1749  wxString Description = pParameter->Get_Description(
1751  ).c_str();
1752 
1753  Description.Replace("\xb", ""); // unicode problem: quick'n'dirty bug fix, to be replaced
1754 
1755  wxString ID(pParameter->Get_CmdID().c_str());
1756 
1757  if( pParameter->is_Input() || pParameter->is_Output() )
1758  {
1759  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_NEEDS_SEPARATOR|wxCMD_LINE_PARAM_OPTIONAL);
1760  }
1761 
1762  //-------------------------------------------------
1763  else if( pParameter->is_Option() && !pParameter->is_Information() )
1764  {
1765  switch( pParameter->Get_Type() )
1766  {
1768  _Get_Script_CMD_Usage(pParameter->asParameters(), Parser);
1769  break;
1770 
1771  case PARAMETER_TYPE_Bool :
1772  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1773  break;
1774 
1775  case PARAMETER_TYPE_Int :
1776  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
1777  break;
1778 
1780  case PARAMETER_TYPE_Choice :
1781  case PARAMETER_TYPE_Choices :
1784  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1785  break;
1786 
1787  case PARAMETER_TYPE_Double :
1788  case PARAMETER_TYPE_Degree :
1789  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1790  break;
1791 
1792  case PARAMETER_TYPE_Date :
1793  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_DATE , wxCMD_LINE_PARAM_OPTIONAL);
1794  break;
1795 
1796  case PARAMETER_TYPE_Range :
1797  Parser.AddOption(ID + "_MIN", wxEmptyString, Description, wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1798  Parser.AddOption(ID + "_MAX", wxEmptyString, Description, wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1799  break;
1800 
1801  case PARAMETER_TYPE_Color :
1802  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1803  break;
1804 
1805  case PARAMETER_TYPE_Colors :
1806  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1807  break;
1808 
1809  case PARAMETER_TYPE_String :
1810  case PARAMETER_TYPE_Text :
1812  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1813  break;
1814 
1816  Parser.AddOption(ID, wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1817  break;
1818 
1820  if( pParameter->Get_Children_Count() == 0 )
1821  {
1822  Parser.AddOption(ID + "_D" , wxEmptyString, _TL("Cell Size" ), wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1823  Parser.AddOption(ID + "_X" , wxEmptyString, _TL("Lower Left Center Cell X-Coordinate"), wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1824  Parser.AddOption(ID + "_Y" , wxEmptyString, _TL("Lower Left Center Cell Y-Coordinate"), wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_PARAM_OPTIONAL);
1825  Parser.AddOption(ID + "_NX" , wxEmptyString, _TL("Number of Columns" ), wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
1826  Parser.AddOption(ID + "_NY" , wxEmptyString, _TL("Number of Rows" ), wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
1827  Parser.AddOption(ID + "_FILE", wxEmptyString, _TL("Grid File" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
1828  }
1829  break;
1830 
1831  default:
1832  break;
1833  }
1834  }
1835  }
1836 }
1837 
1838 
1840 // //
1842 
1843 //---------------------------------------------------------
1844 CSG_String CSG_Tool::_Get_Script_Python(bool bHeader, bool bAllArguments)
1845 {
1846  CSG_String Script, Name(Get_Name());
1847 
1848  Name.Replace(" ", "_");
1849  Name.Replace("(", "");
1850  Name.Replace(")", "");
1851  Name.Replace("[", "");
1852  Name.Replace("]", "");
1853  Name.Replace(".", "");
1854  Name.Replace(",", "");
1855  Name.Replace("/", "");
1856  Name.Replace("-", "");
1857 
1858  //-----------------------------------------------------
1859  if( bHeader )
1860  {
1861  Script += "#! /usr/bin/env python\n";
1862  Script += "\n";
1863  Script += "#_________________________________________\n";
1864  Script += "##########################################\n";
1865  Script += "\n";
1866 #ifdef _SAGA_MSW
1867  CSG_String AppPath = SG_UI_Get_Application_Path(true); AppPath.Replace("\\", "/");
1868  Script += "# Initialize the environment...\n";
1869  Script += "\n";
1870  Script += "# Windows: Let the 'SAGA_PATH' environment variable point to\n";
1871  Script += "# the SAGA installation folder before importing 'saga_api'!\n";
1872  Script += "# This can be defined globally in the Windows system or\n";
1873  Script += "# user environment variable settings, in the 'PySAGA/__init__.py'\n";
1874  Script += "# file, or in the individual Python script itself. To do the latter\n";
1875  Script += "# just uncomment the following line and adjust the path accordingly:\n";
1876  Script += "###import os; os.environ['SAGA_PATH'] = '" + AppPath + "'\n";
1877  Script += "\n";
1878  Script += "# Windows: The most convenient way to make PySAGA available to all your\n";
1879  Script += "# Python scripts is to copy the PySAGA folder to the 'Lib/site-packages/'\n";
1880  Script += "# folder of your Python installation. If don't want to do this or if you\n";
1881  Script += "# don't have the rights to do so, you can also copy it to the folder with\n";
1882  Script += "# the Python scripts in which you want to use PySAGA, or alternatively\n";
1883  Script += "# you can add the path containing the PySAGA folder (e.g. the path to your\n";
1884  Script += "# SAGA installation) to the PYTHONPATH environment variable. To do this\n";
1885  Script += "# from within your script you can also take the following command (just\n";
1886  Script += "# uncomment the following line and adjust the path accordingly):\n";
1887  Script += "###import sys; sys.path.insert(1, '" + AppPath + "')\n";
1888  Script += "\n";
1889 #endif // _SAGA_MSW
1890  Script += "# Import saga_api from PySAGA:\n";
1891  Script += "from PySAGA import saga_api\n";
1892  Script += "\n";
1893  Script += "\n";
1894  Script += "#_________________________________________\n";
1895  Script += "##########################################\n";
1896  Script += "def Run_" + Name + "(Results):\n";
1897  }
1898 
1899  //-----------------------------------------------------
1900  if( bHeader ) Script += " # Get the tool:\n";
1901  Script += " Tool = saga_api.SG_Get_Tool_Library_Manager().Get_Tool('" + Get_Library() + "', '" + Get_ID() + "')\n";
1902  Script += " if not Tool:\n";
1903  Script += " saga_api.SG_UI_Msg_Add_Error('Failed to request tool: " + Get_Name() + "')\n";
1904  Script += " return False\n";
1905  Script += "\n";
1906  if( bHeader ) Script += " # Set the parameter interface:\n";
1907  Script += " Tool.Reset()\n";
1908 
1909  //-------------------------------------------------
1910  _Get_Script_Python(Script, Get_Parameters(), bAllArguments);
1911 
1912  for(int iParameters=0; iParameters<Get_Parameters_Count(); iParameters++)
1913  {
1914  _Get_Script_Python(Script, Get_Parameters(iParameters), bAllArguments, Get_Parameters(iParameters)->Get_Identifier());
1915  }
1916 
1917  //-------------------------------------------------
1918  Script += "\n";
1919  if( bHeader ) Script += " # Execute the tool:\n";
1920  Script += " if not Tool.Execute():\n";
1921  Script += " saga_api.SG_UI_Msg_Add_Error('failed to execute tool: ' + Tool.Get_Name().c_str())\n";
1922  Script += " return False\n";
1923  Script += "\n";
1924  if( bHeader ) Script += " # Request the results:\n";
1925 
1926  for(int iParameter=0; iParameter<Get_Parameters()->Get_Count(); iParameter++)
1927  {
1928  CSG_Parameter *p = Get_Parameters()->Get_Parameter(iParameter);
1929 
1930  if( p->is_Output() )
1931  {
1932  CSG_String id(p->Get_Identifier()), type, ext;
1933 
1934  switch( p->Get_DataObject_Type() )
1935  {
1936  case SG_DATAOBJECT_TYPE_Grid : type = "Grid" ; ext = "sg-grd-z"; break;
1937  case SG_DATAOBJECT_TYPE_Grids : type = "Grids" ; ext = "sg-gds-z"; break;
1938  case SG_DATAOBJECT_TYPE_Table : type = "Table" ; ext = "txt" ; break;
1939  case SG_DATAOBJECT_TYPE_Shapes : type = "Shapes" ; ext = "geojson" ; break;
1940  case SG_DATAOBJECT_TYPE_PointCloud: type = "PointCloud"; ext = "sg-pts-z"; break;
1941  case SG_DATAOBJECT_TYPE_TIN : type = "TIN" ; ext = "geojson" ; break;
1942  default : type = "" ; ext = "" ; break;
1943  }
1944 
1945  if( p->is_DataObject() )
1946  {
1947  Script += " Data = Tool.Get_Parameter('" + id + "').as" + type + "()\n";
1948 
1949  if( bHeader )
1950  {
1951  Script += " Data.Save('{:s}/{:s}.{:s}'.format(Results, Data.Get_Name(), '" + ext + "'))\n\n";
1952  }
1953  }
1954  else if( p->is_DataObject_List() )
1955  {
1956  Script += " List = Tool.Get_Parameter('" + id + "').as" + type + "List()\n";
1957  Script += " for i in range(0, List.Get_Item_Count()):\n";
1958 
1959  if( bHeader )
1960  {
1961  Script += " List.Get_Item(i).Save('{:s}/{:s}_{:d}.{:s}'.format(Results, List.Get_Name(), i, '" + ext + "'))\n\n";
1962  }
1963  else
1964  {
1965  Script += " Data = List.Get_Item(i)\n";
1966  }
1967  }
1968  }
1969  }
1970 
1971  //-----------------------------------------------------
1972  if( bHeader )
1973  {
1974  Script += " # job is done, free memory resources:\n";
1975  Script += " saga_api.SG_Get_Data_Manager().Delete_All()\n";
1976  Script += "\n";
1977  Script += " return True\n";
1978  Script += "\n";
1979  Script += "\n";
1980  Script += "#_________________________________________\n";
1981  Script += "##########################################\n";
1982  Script += "print('This is a simple template for using a SAGA tool through Python.')\n";
1983  Script += "print('Please edit the script to make it work properly before using it!')\n";
1984  Script += "\n";
1985  Script += "# Run_" + Name + "('.')\n";
1986  }
1987 
1988  return( Script );
1989 }
1990 
1991 //---------------------------------------------------------
1992 void CSG_Tool::_Get_Script_Python(CSG_String &Script, CSG_Parameters *pParameters, bool bAllArguments, const CSG_String &Prefix)
1993 {
1994  for(int iParameter=0; iParameter<pParameters->Get_Count(); iParameter++)
1995  {
1996  CSG_Parameter *p = pParameters->Get_Parameter(iParameter);
1997 
1998  if( !bAllArguments && (!p->is_Enabled(false) || p->is_Information() || !p->do_UseInCMD()) )
1999  {
2000  continue;
2001  }
2002 
2003  CSG_String ID(p->Get_Identifier());
2004 
2005  if( !Prefix.is_Empty() )
2006  {
2007  ID.Prepend(Prefix + ".");
2008  }
2009 
2010  switch( p->Get_Type() )
2011  {
2012  default:
2013  break;
2014 
2015  case PARAMETER_TYPE_Bool :
2016  Script += CSG_String::Format(" Tool.Set_Parameter('%s', %s)\n", ID.c_str(), p->asBool() ? SG_T("True") : SG_T("False"));
2017  break;
2018 
2019  case PARAMETER_TYPE_Int :
2020  Script += CSG_String::Format(" Tool.Set_Parameter('%s', %d)\n", ID.c_str(), p->asInt());
2021  break;
2022 
2024  case PARAMETER_TYPE_Choice :
2025  Script += CSG_String::Format(" Tool.Set_Parameter('%s', %d) # '%s'\n", ID.c_str(), p->asInt(), p->asString());
2026  break;
2027 
2028  case PARAMETER_TYPE_Choices :
2031  Script += CSG_String::Format(" Tool.Set_Parameter('%s', '%s')\n", ID.c_str(), p->asString());
2032  break;
2033 
2034  case PARAMETER_TYPE_Color :
2035  Script += CSG_String::Format(" Tool.Set_Parameter('%s', '%s')\n", ID.c_str(), SG_Color_To_Text(p->asColor()).c_str());
2036  break;
2037 
2038  case PARAMETER_TYPE_Double :
2039  case PARAMETER_TYPE_Degree :
2040  Script += CSG_String::Format(" Tool.Set_Parameter('%s', %g)\n", ID.c_str(), p->asDouble());
2041  break;
2042 
2043  case PARAMETER_TYPE_Range :
2044  Script += CSG_String::Format(" Tool.Set_Parameter('%s.MIN', %g)\n", ID.c_str(), p->asRange()->Get_Min());
2045  Script += CSG_String::Format(" Tool.Set_Parameter('%s.MAX', %g)\n", ID.c_str(), p->asRange()->Get_Max());
2046  break;
2047 
2048  case PARAMETER_TYPE_String :
2049  if( ((CSG_Parameter_String *)p)->is_Password() )
2050  {
2051  Script += CSG_String::Format(" Tool.Set_Parameter('%s', '***')\n", ID.c_str());
2052  break;
2053  }
2054 
2055  case PARAMETER_TYPE_Date :
2056  case PARAMETER_TYPE_Text :
2058  Script += CSG_String::Format(" Tool.Set_Parameter('%s', '%s')\n", ID.c_str(), p->asString());
2059  break;
2060 
2062  Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.SG_Create_Table('table.txt'))\n", ID.c_str());
2063  break;
2064 
2066  if( p->Get_Children_Count() == 0 )
2067  {
2068  Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.CSG_Grid_System(%g, %g, %g, %d, %d))\n", ID.c_str(),
2069  p->asGrid_System()->Get_Cellsize(),
2070  p->asGrid_System()->Get_XMin(), p->asGrid_System()->Get_YMin(),
2071  p->asGrid_System()->Get_NX (), p->asGrid_System()->Get_NY ()
2072  );
2073  }
2074  break;
2075 
2076  case PARAMETER_TYPE_Grid :
2077  case PARAMETER_TYPE_Grids :
2078  case PARAMETER_TYPE_Table :
2079  case PARAMETER_TYPE_Shapes :
2080  case PARAMETER_TYPE_TIN :
2082  if( p->is_Input() )
2083  {
2084  Script += CSG_String::Format(" Tool.Set_Parameter('%s', saga_api.SG_Get_Data_Manager().Add('%s input file%s'))\n", ID.c_str(),
2085  SG_Get_DataObject_Name(p->Get_DataObject_Type()).c_str(), p->is_Optional() ? SG_T(", optional") : SG_T("")
2086  );
2087  }
2088  else if( p->is_Output() && p->is_Optional() )
2089  {
2090  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());
2091  }
2092  break;
2093 
2100  if( p->is_Input() )
2101  {
2102  Script += CSG_String::Format(" Tool.Get_Parameter('%s').asList().Add_Item('%s input list%s')\n", ID.c_str(),
2103  SG_Get_DataObject_Name(p->Get_DataObject_Type()).c_str(), p->is_Optional() ? SG_T(", optional") : SG_T("")
2104  );
2105  }
2106  break;
2107 
2109  _Get_Script_Python(Script, p->asParameters(), bAllArguments, ID);
2110  break;
2111  }
2112  }
2113 }
2114 
2115 
2117 // //
2119 
2120 //---------------------------------------------------------
2121 CSG_String CSG_Tool::_Get_Script_Python_Wrap(bool bHeader, bool bName, bool bCall, int AllArguments, bool bWrapArgs)
2122 {
2123  CSG_String Arguments, Description, Code;
2124 
2125  if( AllArguments >= 0 ) // if( AllArguments < 0 ) => skip arguments list
2126  {
2127  for(int i=0; i<Parameters.Get_Count(); i++) // add input that is not optional in 1st place
2128  {
2129  _Get_Script_Python_Wrap(Parameters[i], PARAMETER_INPUT , Arguments, Description, Code, bCall && bHeader, AllArguments == 0, bWrapArgs);
2130  }
2131 
2132  for(int i=0; i<Parameters.Get_Count(); i++) // add optional input in 2nd place
2133  {
2134  _Get_Script_Python_Wrap(Parameters[i], PARAMETER_INPUT_OPTIONAL, Arguments, Description, Code, bCall && bHeader, AllArguments == 0, bWrapArgs);
2135  }
2136 
2137  for(int i=0; i<Parameters.Get_Count(); i++) // add output
2138  {
2139  _Get_Script_Python_Wrap(Parameters[i], PARAMETER_OUTPUT , Arguments, Description, Code, bCall && bHeader, AllArguments == 0, bWrapArgs);
2140  }
2141 
2142  for(int i=0; i<Parameters.Get_Count(); i++) // add options
2143  {
2144  _Get_Script_Python_Wrap(Parameters[i], 0 , Arguments, Description, Code, bCall , AllArguments == 0, bWrapArgs);
2145  }
2146  }
2147 
2148  //---------------------------------------------------------
2149  CSG_String Name, Expected(Get_Name()); Expected.Replace("'", "\\'");
2150 
2151  if( bName )
2152  {
2153  Name = Get_Name();
2154 
2155  if( isdigit(Name[0]) ) // ...in case first letter is a numeric character, what is not allowed for Python function names!
2156  {
2157  Name.Prepend("_");
2158  }
2159 
2160  Name.Replace(" ", "_");
2161  Name.Replace("(", "");
2162  Name.Replace(")", "");
2163  Name.Replace("[", "");
2164  Name.Replace("]", "");
2165  Name.Replace(".", "");
2166  Name.Replace(",", "");
2167  Name.Replace("/", "");
2168  Name.Replace("-", "");
2169  Name.Replace("'", "");
2170  Name.Replace("&", "and");
2171  }
2172  else
2173  {
2174  Name = "run_tool_" + Get_Library() + "_" + Get_ID();
2175 
2176  Name.Replace(" ", "_");
2177  }
2178 
2179  //---------------------------------------------------------
2180  CSG_String Script;
2181 
2182  if( bCall )
2183  {
2184  if( bHeader )
2185  {
2186  Script += "from PySAGA.tools import " + Get_Library() + "\n\n";
2187 
2188  if( !Code.is_Empty() )
2189  {
2190  Script += Code + "\n";
2191  }
2192  }
2193 
2194  Script += Get_Library() + '.' + Name + "(" + Arguments + ")\n";
2195  }
2196  else
2197  {
2199 
2200  if( bHeader )
2201  {
2202  Script += "#! /usr/bin/env python\n";
2203  Script += "from PySAGA.helper import Tool_Wrapper\n\n";
2204  }
2205 
2206  Script += "def " + Name + "(" + Arguments + ", Verbose=2):\n";
2207  Script += " '''\n";
2208  Script += " " + Get_Name() + "\n";
2209  Script += " ----------\n";
2210  Script += " [" + Get_Library() + "." + Get_ID() + "]\\n\n";
2211  for(int i=0; i<_Description.Get_Count(); i++)
2212  {
2213  _Description[i].Trim_Both(); Script += " " + _Description[i] + "\\n\n";
2214  }
2215  Script += " Arguments\n";
2216  Script += " ----------\n";
2217  Script += Description + "\n";
2218  Script += " - Verbose [`integer number`] : Verbosity level, 0=silent, 1=tool name and success notification, 2=complete tool output.\\n\n";
2219  Script += " Returns\n";
2220  Script += " ----------\n";
2221  Script += " `boolean` : `True` on success, `False` on failure.\n";
2222  Script += " '''\n";
2223  Script += " Tool = Tool_Wrapper('" + Get_Library() + "', '" + Get_ID() + "', '" + Expected + "')\n";
2224  Script += " if Tool.is_Okay():\n";
2225  Script += Code;
2226  Script += " return Tool.Execute(Verbose)\n";
2227  Script += " return False\n\n";
2228  }
2229 
2230  return( Script );
2231 }
2232 
2233 //---------------------------------------------------------
2234 bool 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)
2235 {
2236  if( Parameter.do_UseInCMD() == false
2237  || Parameter.is_Information()
2238  || Parameter.Get_Type() == PARAMETER_TYPE_Node
2239  || Parameter.Cmp_Identifier("PARAMETERS_GRID_SYSTEM") )
2240  {
2241  return( false );
2242  }
2243 
2244  if( bCall && !Parameter.is_Enabled() && !(Parameter.is_Output() && Parameter.Get_Parent() && Parameter.Get_Parent()->Cmp_Identifier("TARGET_SYSTEM")) )
2245  {
2246  return( false );
2247  }
2248 
2249  //-----------------------------------------------------
2250  CSG_String ID(Parameter.Get_Identifier());
2251 
2252  if( !Prefix.is_Empty() )
2253  {
2254  ID.Prepend(Prefix + ".");
2255  }
2256 
2257  CSG_String Argument(ID);
2258 
2259  if( Argument[0] >= '0' && Argument[0] <= '9' )
2260  {
2261  Argument.Prepend('_');
2262  }
2263 
2264  Argument.Replace(".", "_");
2265  Argument.Replace("|", "_");
2266  Argument.Replace(" ", "_");
2267 
2268  if( Argument.Length() > 2 )
2269  {
2270  Argument.Make_Upper();
2271  }
2272 
2273  //-----------------------------------------------------
2274  if( Parameter.asParameters() ) // PARAMETER_TYPE_Parameters
2275  {
2276  bool bResult = false;
2277 
2278  for(int i=0; i<(*Parameter.asParameters()).Get_Count(); i++)
2279  {
2280  if( _Get_Script_Python_Wrap((*Parameter.asParameters())[i], Constraint, Arguments, Description, Code, bCall, bOnlyNonDefaults, bWrapArgs, ID) )
2281  {
2282  bResult = true;
2283  }
2284  }
2285 
2286  return( bResult );
2287  }
2288 
2289  //-----------------------------------------------------
2290  if( Parameter.is_Input () && !Parameter.is_Optional() && Constraint != PARAMETER_INPUT ) { return( false ); }
2291  if( Parameter.is_Input () && Parameter.is_Optional() && Constraint != PARAMETER_INPUT_OPTIONAL ) { return( false ); }
2292  if( Parameter.is_Output() && Constraint != PARAMETER_OUTPUT ) { return( false ); }
2293  if( Parameter.is_Option() && Constraint != 0 ) { return( false ); }
2294 
2295  //-----------------------------------------------------
2296  if( bCall )
2297  {
2298  CSG_String Value;
2299 
2300  if( Parameter.is_DataObject() )
2301  {
2302  Value = Parameter.Get_Identifier(); Value.Make_Lower();
2303 
2304  if( Parameter.is_Input() )
2305  {
2306  if( (bOnlyNonDefaults && !Parameter.asDataObject()) && Parameter.is_Optional() ) // don't add optional input that has not been set
2307  {
2308  return( false );
2309  }
2310 
2311  CSG_String File(Parameter.asDataObject() && Parameter.asDataObject()->Get_File_Name(false)
2312  ? Parameter.asDataObject()->Get_File_Name(false) : SG_T("data object file")
2313  ); File.Replace("\\", "/");
2314 
2315  Code += Value + " = saga_api.SG_Get_Data_Manager().Add_" + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()).AfterFirst('_') + "('" + File + "') # input data object\n";
2316  }
2317  else // if( Parameter.is_Output() )
2318  {
2319  if( (bOnlyNonDefaults && !Parameter.asDataObject()) && Parameter.is_Optional() ) // don't add optional output that has not been requested
2320  {
2321  return( false );
2322  }
2323 
2324  Code += Value + " = saga_api.SG_Get_Data_Manager().Add_" + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()).AfterFirst('_') + "() # output data object\n";
2325  }
2326  }
2327  else if( Parameter.is_DataObject_List() )
2328  {
2329  Value = Parameter.Get_Identifier(); Value.Make_Lower();
2330 
2331  if( Parameter.is_Input() )
2332  {
2333  if( (bOnlyNonDefaults && Parameter.asList()->Get_Item_Count() < 1) && Parameter.is_Optional() ) // don't add optional input that has not been set
2334  {
2335  return( false );
2336  }
2337 
2338  Code += Value + " = [] # Python list with input data objects of type 'saga_api." + SG_Get_DataObject_Class_Name(Parameter.Get_DataObject_Type()) + "'\n";
2339  }
2340  else // if( Parameter.is_Output() )
2341  {
2342  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";
2343  }
2344  }
2345  else if( Parameter.is_Option() )
2346  {
2347  if( bOnlyNonDefaults && Parameter.is_Default() )
2348  {
2349  return( false );
2350  }
2351 
2352  switch( Parameter.Get_Type() )
2353  {
2354  case PARAMETER_TYPE_Bool : Value = Parameter.asBool() ? "True" : "False"; break;
2355 
2356  case PARAMETER_TYPE_Int : Value.Printf("%d", Parameter.asInt()); break;
2357 
2358  case PARAMETER_TYPE_Double :
2359  case PARAMETER_TYPE_Degree : Value.Printf("%f", Parameter.asDouble()); break;
2360 
2361  case PARAMETER_TYPE_Color : Value = SG_Color_To_Text(Parameter.asColor()); break;
2362 
2363  case PARAMETER_TYPE_String :
2364  case PARAMETER_TYPE_Text :
2365  case PARAMETER_TYPE_Date :
2366  case PARAMETER_TYPE_Range :
2368  case PARAMETER_TYPE_Choice :
2369  case PARAMETER_TYPE_Choices :
2372  case PARAMETER_TYPE_FilePath : Value.Printf("'%s'", Parameter.asString()); break;
2373 
2375  if( !Parameter.Cmp_Identifier("TARGET_SYSTEM") )
2376  {
2377  return( false );
2378  }
2379 
2380  Value.Printf("'%s'", Parameter.asGrid_System()->asString());
2381  break;
2382 
2383  default : return( false );
2384  }
2385  }
2386 
2387  if( !Value.is_Empty() )
2388  {
2389  if( bWrapArgs )
2390  {
2391  Arguments += !Arguments.is_Empty() ? ",\n " : "\n ";
2392  }
2393  else if( !Arguments.is_Empty() )
2394  {
2395  Arguments += ", ";
2396  }
2397 
2398  Arguments += Argument + "=" + Value;
2399  }
2400 
2401  return( true );
2402  }
2403 
2404  //-----------------------------------------------------
2405  if( bWrapArgs )
2406  {
2407  Arguments += !Arguments.is_Empty() ? ",\n " : "\n ";
2408  }
2409  else if( !Arguments.is_Empty() )
2410  {
2411  Arguments += ", ";
2412  }
2413 
2414  Arguments += Argument + "=None";
2415 
2416  //-----------------------------------------------------
2417  Code += " ";
2418 
2419  if( Parameter.is_Input () ) { Code += "Tool.Set_Input "; }
2420  if( Parameter.is_Output() ) { Code += "Tool.Set_Output"; }
2421  if( Parameter.is_Option() ) { Code += "Tool.Set_Option"; }
2422 
2423  Code += CSG_String::Format("('%s', %s)\n", ID.c_str(), Argument.c_str());
2424 
2425  //-----------------------------------------------------
2426  Description += " - " + Argument + " [`";
2427 
2428  if( Parameter.is_Input() )
2429  {
2430  Description += Parameter.is_Optional() ? "optional input " : "input ";
2431  }
2432  else if( Parameter.is_Output() )
2433  {
2434  Description += "output ";
2435  }
2436 
2437  Description += Parameter.Get_Type_Name() + "`] : " + Parameter.Get_Name();
2438 
2440 
2441  if( !s.is_Empty() )
2442  {
2443  Description += ". " + s;
2444  }
2445 
2446  Description += "\n";
2447 
2448  return( true );
2449 }
2450 
2451 
2453 // //
2454 // //
2455 // //
2457 
2458 //---------------------------------------------------------
2460 {
2461  CSG_MetaData History;
2462 
2463  History.Set_Name(SG_META_HISTORY);
2464  History.Add_Property("saga-version", SAGA_VERSION);
2465 
2466  if( Depth )
2467  {
2468  CSG_MetaData *pTool = History.Add_Child("TOOL");
2469 
2470  pTool->Add_Property("library", Get_Library());
2471  pTool->Add_Property("id" , Get_ID ());
2472  pTool->Add_Property("name" , Get_Name ());
2473 
2474  Parameters.Set_History(*pTool);
2475 
2477 
2478  CSG_MetaData *pOutput = pTool->Add_Child("OUTPUT");
2479  pOutput->Add_Property("type", "");
2480  pOutput->Add_Property("id" , "");
2481  pOutput->Add_Property("name", "");
2482 
2483  pTool->Del_Children(Depth, SG_T("TOOL"));
2484  }
2485 
2486  return( History );
2487 }
2488 
2489 //---------------------------------------------------------
2490 bool CSG_Tool::Set_History(CSG_Data_Object *pDataObject, int Depth)
2491 {
2492  if( pDataObject )
2493  {
2494  CSG_MetaData History(Get_History(Depth));
2495 
2496  CSG_MetaData *pOutput = History("TOOL") ? History["TOOL"]("OUTPUT") : NULL;
2497 
2498  if( pOutput )
2499  {
2500  pOutput->Set_Property("name", pDataObject->Get_Name());
2501  }
2502 
2503  pDataObject->Get_History() = History;
2504 
2505  return( true );
2506  }
2507 
2508  return( false );
2509 }
2510 
2511 //---------------------------------------------------------
2512 void CSG_Tool::_Set_Output_History(void)
2513 {
2515 
2516  for(int j=-1; j<Get_Parameters_Count(); j++)
2517  {
2518  CSG_Parameters *pParameters = j < 0 ? &Parameters : Get_Parameters(j);
2519 
2520  for(int i=0; i<pParameters->Get_Count(); i++)
2521  {
2522  CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
2523 
2524  if( pParameter->is_Output() )//&& (pParameter->is_Enabled() || !has_GUI()) )
2525  {
2526  DataObject_Set_History(pParameter, &History);
2527  }
2528  }
2529  }
2530 }
2531 
2532 //---------------------------------------------------------
2534 {
2535  if( !pParameter && !((pParameter->is_DataObject() && pParameter->asDataObject()) || !(pParameter->is_DataObject_List() && pParameter->asList()->Get_Item_Count() > 0)) )
2536  {
2537  return( false );
2538  }
2539 
2540  //-----------------------------------------------------
2541  CSG_MetaData History;
2542 
2543  if( !pHistory )
2544  {
2545  History = Get_History(SG_Get_History_Depth()); pHistory = &History;
2546  }
2547 
2548  //-----------------------------------------------------
2549  CSG_MetaData *pOutput = pHistory->Get_Child("TOOL") ? pHistory->Get_Child("TOOL")->Get_Child("OUTPUT") : NULL;
2550 
2551  if( pOutput )
2552  {
2553  pOutput->Set_Property("type", pParameter->Get_Type_Identifier());
2554  pOutput->Set_Property("id" , pParameter->Get_Identifier ());
2555  pOutput->Set_Property("name", pParameter->Get_Name ());
2556  }
2557 
2558  //-----------------------------------------------------
2559  if( pParameter->is_DataObject() && pParameter->asDataObject() )
2560  {
2561  if( pOutput )
2562  {
2563  pOutput->Set_Content(pParameter->asDataObject()->Get_Name());
2564  }
2565 
2566  pParameter->asDataObject()->Get_History().Assign(*pHistory);
2567  }
2568 
2569  //-----------------------------------------------------
2570  else if( pParameter->is_DataObject_List() )
2571  {
2572  for(int j=0; j<pParameter->asList()->Get_Item_Count(); j++)
2573  {
2574  if( pOutput )
2575  {
2576  pOutput->Set_Content(pParameter->asList()->Get_Item(j)->Get_Name());
2577  }
2578 
2579  pParameter->asList()->Get_Item(j)->Get_History().Assign(*pHistory);
2580  }
2581  }
2582 
2583  //-----------------------------------------------------
2584  return( true );
2585 }
2586 
2587 
2589 // //
2590 // //
2591 // //
2593 
2594 //---------------------------------------------------------
CSG_Tool::DataObject_Classify_Geometric
static bool DataObject_Classify_Geometric(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, bool bIncreasing=true, int Colors=-1)
Definition: tool.cpp:1242
CSG_MetaData::Destroy
void Destroy(void)
Definition: metadata.cpp:140
CSG_Tool::DataObject_Update_All
bool DataObject_Update_All(void)
Definition: tool.cpp:815
CSG_Parameter::Set_Value
virtual bool Set_Value(int Value)
Definition: parameter.cpp:814
CSG_Parameters::Get_Description
const CSG_String & Get_Description(void) const
Definition: parameters.h:1741
CSG_Tool::Script_Format::Python
@ Python
PARAMETER_TYPE_Double
@ PARAMETER_TYPE_Double
Definition: parameters.h:128
CSG_Parameters::Get_Parameter
CSG_Parameter * Get_Parameter(int i) const
Definition: parameters.h:1758
PARAMETER_TYPE_FilePath
@ PARAMETER_TYPE_FilePath
Definition: parameters.h:137
CSG_Parameters::Get_Grid_System
CSG_Grid_System * Get_Grid_System(void) const
Definition: parameters.h:1902
PARAMETER_TYPE_Degree
@ PARAMETER_TYPE_Degree
Definition: parameters.h:129
GET_ID1
#define GET_ID1(p)
CSG_Tool::Reset_Manager
bool Reset_Manager(void)
Definition: tool.cpp:1376
CSG_Tool::Parameters
CSG_Parameters Parameters
Definition: tool.h:255
SG_T
#define SG_T(s)
Definition: api_core.h:537
CSG_Tool::Get_Projection
bool Get_Projection(CSG_Projection &Projection) const
Definition: tool.cpp:430
CSG_String::Printf
int Printf(const char *Format,...)
Definition: api_string.cpp:308
CSG_Tool_Chain::Get_Script
static CSG_String Get_Script(CSG_Tool *pTool, bool bHeader, bool bAllParameters=true)
CSG_Grid_System::Get_Cellsize
double Get_Cellsize(void) const
Definition: grid.h:255
_TL
#define _TL(s)
Definition: api_core.h:1559
CSG_String::Make_Lower
CSG_String & Make_Lower(void)
Definition: api_string.cpp:543
CSG_Tool::DataObject_Update
static bool DataObject_Update(CSG_Data_Object *pDataObject, int Show=SG_UI_DATAOBJECT_UPDATE)
Definition: tool.cpp:978
CSG_Tool::DataObject_Set_Parameter
static bool DataObject_Set_Parameter(CSG_Data_Object *pDataObject, CSG_Parameter *pParameter)
Definition: tool.cpp:1055
SG_UI_DataObject_Params_Set
bool SG_UI_DataObject_Params_Set(CSG_Data_Object *pDataObject, CSG_Parameters *pParameters)
Definition: api_callback.cpp:732
SAGA_VERSION
#define SAGA_VERSION
Definition: saga_api.h:90
PARAMETER_TYPE_Table_Fields
@ PARAMETER_TYPE_Table_Fields
Definition: parameters.h:146
CSG_Tool::DataObject_Set_Stretch_StdDev
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:1159
CSG_Tool::Get_History
CSG_MetaData Get_History(int Depth=-1)
Definition: tool.cpp:2459
CSG_Data_Object::Get_History
CSG_MetaData & Get_History(void)
Definition: dataobject.h:236
CSG_Tool::Add_Parameters
CSG_Parameters * Add_Parameters(const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description)
Definition: tool.cpp:495
SG_HTML_Tag_Replacer
SAGA_API_DLL_EXPORT CSG_String SG_HTML_Tag_Replacer(const CSG_String &Text)
Definition: api_string.cpp:1446
CSG_Tool::History_Supplement
CSG_MetaData History_Supplement
Definition: tool.h:257
SG_UI_Dlg_Continue
bool SG_UI_Dlg_Continue(const CSG_String &Message, const CSG_String &Caption)
Definition: api_callback.cpp:386
CSG_DateTime::Now
static CSG_DateTime Now(void)
Definition: datetime.cpp:581
CSG_Tool::Message_Add
void Message_Add(const CSG_String &Text, bool bNewLine=true)
Definition: tool.cpp:908
CSG_Parameter_Range::Get_Max
double Get_Max(void) const
Definition: parameter_data.cpp:834
CSG_Tool::Set_Show_Progress
void Set_Show_Progress(bool bOn=true)
Definition: tool.cpp:654
CSG_TimeSpan::Get_Hours
int Get_Hours(void) const
Definition: datetime.h:161
CSG_Tool::Set_History
bool Set_History(CSG_Data_Object *pDataObject, int Depth=-1)
Definition: tool.cpp:2490
CSG_Parameters::Set_Grid_System
bool Set_Grid_System(const CSG_Grid_System &System)
Definition: parameters.cpp:2116
CSG_Parameters::Reset_Grid_System
bool Reset_Grid_System(void)
Definition: parameters.cpp:2127
CSG_Parameter::Get_Identifier
const SG_Char * Get_Identifier(void) const
Definition: parameter.cpp:562
CSG_Parameter::asInt
int asInt(void) const
Definition: parameters.h:286
CSG_Parameters::Get_Manager
class CSG_Data_Manager * Get_Manager(void) const
Definition: parameters.h:1721
PARAMETER_TYPE_Node
@ PARAMETER_TYPE_Node
Definition: parameters.h:124
CSG_Parameter::Get_Type_Name
CSG_String Get_Type_Name(void) const
Definition: parameter.cpp:129
CSG_Parameter::asString
const SG_Char * asString(void) const
Definition: parameters.h:289
CSG_MetaData::Set_Content
void Set_Content(const CSG_String &Content)
Definition: metadata.h:140
CSG_Grid_System::Get_XMin
double Get_XMin(bool bCells=false) const
Definition: grid.h:264
CSG_Tool::Create_Manager
class CSG_Data_Manager * Create_Manager(void)
Definition: tool.cpp:589
data_manager.h
SG_UI_MSG_STYLE_NORMAL
@ SG_UI_MSG_STYLE_NORMAL
Definition: api_core.h:1572
CSG_Tool::DataObject_Classify_StdDev
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:1262
CSG_Tool::DataObject_Set_Stretch_Linear
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:1148
SG_UI_MSG_STYLE_SUCCESS
@ SG_UI_MSG_STYLE_SUCCESS
Definition: api_core.h:1575
PARAMETER_TYPE_Grids_List
@ PARAMETER_TYPE_Grids_List
Definition: parameters.h:156
SG_UI_Get_Application_Name
CSG_String SG_UI_Get_Application_Name(void)
Definition: api_core.cpp:378
PARAMETER_TYPE_String
@ PARAMETER_TYPE_String
Definition: parameters.h:135
CSG_Grid_System
Definition: grid.h:220
SG_Get_DataObject_Name
CSG_String SG_Get_DataObject_Name(TSG_Data_Object_Type Type)
Definition: dataobject.cpp:86
PARAMETER_TYPE_Int
@ PARAMETER_TYPE_Int
Definition: parameters.h:127
CSG_Parameter_List::Get_Item
CSG_Data_Object * Get_Item(int Index) const
Definition: parameters.h:1379
CSG_Tool::Set_Version
void Set_Version(const CSG_String &String)
Definition: tool.cpp:149
CSG_Parameter::asColor
long asColor(void) const
Definition: parameters.h:287
SG_UI_Msg_Add_Execution
void SG_UI_Msg_Add_Execution(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
Definition: api_callback.cpp:526
SG_UI_Process_Get_Okay
bool SG_UI_Process_Get_Okay(bool bBlink)
Definition: api_callback.cpp:207
CSG_MetaData::Set_Property
bool Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists=true)
Definition: metadata.cpp:615
SG_UI_Process_Set_Okay
bool SG_UI_Process_Set_Okay(bool bOkay)
Definition: api_callback.cpp:229
CSG_Parameter::is_Input
bool is_Input(void) const
Definition: parameters.h:236
CSG_Tool::Dlg_Parameters
bool Dlg_Parameters(const CSG_String &Identifier)
Definition: tool.cpp:523
tool_chain.h
CSG_Projection::is_Okay
bool is_Okay(void) const
Definition: geo_tools.h:863
CSG_Parameters::is_Managed
bool is_Managed(void) const
Definition: parameters.h:1899
CSG_Tool::Get_Script
CSG_String Get_Script(Script_Format Format, bool bHeader=true, int Arguments=0, bool bWrapArgs=true)
Definition: tool.cpp:1465
saga_api.h
PARAMETER_TYPE_TIN
@ PARAMETER_TYPE_TIN
Definition: parameters.h:153
CSG_Tool::Reset
bool Reset(bool bManager=true)
Definition: tool.cpp:1354
CSG_Tool::DataObject_Classify_Equal
static bool DataObject_Classify_Equal(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, int Colors=-1)
Definition: tool.cpp:1212
SG_UI_Stop_Execution
bool SG_UI_Stop_Execution(bool bDialog)
Definition: api_callback.cpp:348
CSG_Tool
Definition: tool.h:135
CSG_TimeSpan::Get_Milliseconds
sLong Get_Milliseconds(void) const
Definition: datetime.h:164
CSG_Tool::DataObject_Set_History
bool DataObject_Set_History(CSG_Parameter *pParameter, CSG_MetaData *pHistory=NULL)
Definition: tool.cpp:2533
CSG_Data_Object::Get_Name
const SG_Char * Get_Name(void) const
Definition: dataobject.cpp:349
CSG_Tool::Execute
bool Execute(bool bAddHistory=false)
Definition: tool.cpp:258
CSG_Parameter::Get_Description
const SG_Char * Get_Description(void) const
Definition: parameter.cpp:617
SG_Get_Data_Manager
CSG_Data_Manager & SG_Get_Data_Manager(void)
Definition: data_manager.cpp:65
CSG_Tool::Add_Reference
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:171
CSG_Parameters::Cmp_Identifier
bool Cmp_Identifier(const CSG_String &Identifier) const
Definition: parameters.cpp:331
SG_DATAOBJECT_TYPE_Grids
@ SG_DATAOBJECT_TYPE_Grids
Definition: dataobject.h:119
CSG_Tool::~CSG_Tool
virtual ~CSG_Tool(void)
Definition: tool.cpp:86
CSG_Tool::Error_Set
bool Error_Set(TSG_Tool_Error Error_ID=TOOL_ERROR_Unknown)
Definition: tool.cpp:705
CSG_Parameter::do_UseInCMD
bool do_UseInCMD(void) const
Definition: parameter.cpp:187
PARAMETER_TYPE_FixedTable
@ PARAMETER_TYPE_FixedTable
Definition: parameters.h:142
CSG_Tool::Get_Name
const CSG_String & Get_Name(void) const
Definition: tool.cpp:132
CSG_Parameter::asDataObject
CSG_Data_Object * asDataObject(void) const
Definition: parameter.cpp:1080
SG_UI_DataObject_Classify
bool SG_UI_DataObject_Classify(CSG_Data_Object *pDataObject, const CSG_MetaData &Options)
Definition: api_callback.cpp:706
CSG_Tool::Script_Format::Python_Wrapper_Call_ID
@ Python_Wrapper_Call_ID
CSG_Tool::do_Sync_Projections
virtual bool do_Sync_Projections(void) const
Definition: tool.h:216
CSG_MetaData::Get_Child
CSG_MetaData * Get_Child(int Index) const
Definition: metadata.h:149
CSG_TimeSpan
Definition: datetime.h:91
CSG_Tool::Get_References
const CSG_Strings & Get_References(void) const
Definition: tool.cpp:181
PARAMETER_TYPE_PointCloud
@ PARAMETER_TYPE_PointCloud
Definition: parameters.h:148
CSG_String::Prepend
CSG_String & Prepend(const CSG_String &String)
Definition: api_string.cpp:347
CSG_Grid_System::asString
const SG_Char * asString(void)
Definition: grid_system.cpp:341
CSG_Parameters::Push
bool Push(class CSG_Data_Manager *pManager=NULL, bool bRestoreDefaults=true)
Definition: parameters.cpp:262
CSG_Parameter::Get_Parameters
CSG_Parameters * Get_Parameters(void) const
Definition: parameter.cpp:100
CSG_Projection::Destroy
void Destroy(void)
Definition: projections.cpp:235
CSG_Parameters::Pop
bool Pop(void)
Definition: parameters.cpp:285
CSG_Tool::Set_Author
void Set_Author(const CSG_String &String)
Definition: tool.cpp:138
CSG_String::Cmp
int Cmp(const CSG_String &String) const
Definition: api_string.cpp:515
CSG_Tool::Get_Parameters_Count
int Get_Parameters_Count(void) const
Definition: tool.h:167
CSG_Tool::Script_Format
Script_Format
Definition: tool.h:242
tool.h
PARAMETER_INPUT_OPTIONAL
#define PARAMETER_INPUT_OPTIONAL
Definition: parameters.h:103
CSG_Tool::Get_Manager
class CSG_Data_Manager * Get_Manager(void) const
Definition: tool.cpp:583
CSG_Tool::Get_Version
const CSG_String & Get_Version(void) const
Definition: tool.cpp:154
CSG_Parameters::Msg_String
bool Msg_String(bool bOptionsOnly)
Definition: parameters.cpp:1977
PARAMETER_TYPE_Shapes_List
@ PARAMETER_TYPE_Shapes_List
Definition: parameters.h:158
CSG_Tool::DataObject_Get_Parameter
static CSG_Parameter * DataObject_Get_Parameter(CSG_Data_Object *pDataObject, const CSG_String &ID)
Definition: tool.cpp:1048
PARAMETER_TYPE_Grids
@ PARAMETER_TYPE_Grids
Definition: parameters.h:150
CSG_Parameter::Get_Type
virtual TSG_Parameter_Type Get_Type(void) const =0
CSG_Tool::Set_Parameter
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
Definition: tool.cpp:1283
CSG_Tool::Stop_Execution
bool Stop_Execution(bool bDialog=true)
Definition: tool.cpp:678
SG_UI_MSG_STYLE_FAILURE
@ SG_UI_MSG_STYLE_FAILURE
Definition: api_core.h:1576
SG_UI_DATAOBJECT_UPDATE
@ SG_UI_DATAOBJECT_UPDATE
Definition: api_core.h:1588
CSG_Parameter::is_DataObject_List
bool is_DataObject_List(void) const
Definition: parameter.cpp:310
GET_ID2
#define GET_ID2(p, s)
PARAMETER_TYPE_Choices
@ PARAMETER_TYPE_Choices
Definition: parameters.h:134
CSG_Tool::DataObject_Set_Parameters
static bool DataObject_Set_Parameters(CSG_Data_Object *pDataObject, CSG_Parameters &Parameters)
Definition: tool.cpp:1021
PARAMETER_TYPE_Data_Type
@ PARAMETER_TYPE_Data_Type
Definition: parameters.h:132
CSG_Parameter_List::Del_Items
virtual bool Del_Items(void)
Definition: parameter_data.cpp:3084
INIT_CLASSIFY_OPTIONS
#define INIT_CLASSIFY_OPTIONS(method)
Definition: tool.cpp:1198
SG_File_Exists
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
Definition: api_file.cpp:1078
PARAMETER_TYPE_Colors
@ PARAMETER_TYPE_Colors
Definition: parameters.h:141
CSG_Parameters::Set_Name
void Set_Name(const CSG_String &Name)
Definition: parameters.cpp:341
CSG_Tool::Script_Format::CMD_Batch
@ CMD_Batch
SG_UI_Dlg_Message
void SG_UI_Dlg_Message(const CSG_String &Message, const CSG_String &Caption)
Definition: api_callback.cpp:368
CSG_Data_Object
Definition: dataobject.h:180
CSG_Parameter
Definition: parameters.h:208
TSG_Tool_Error
TSG_Tool_Error
Definition: tool.h:112
CSG_TimeSpan::Format
CSG_String Format(const CSG_String &format="") const
Definition: datetime.cpp:65
CSG_Tool::DataObject_Add
bool DataObject_Add(CSG_Data_Object *pDataObject, bool bUpdate=false)
Definition: tool.cpp:799
PARAMETER_TYPE_Table
@ PARAMETER_TYPE_Table
Definition: parameters.h:151
PARAMETER_TYPE_Bool
@ PARAMETER_TYPE_Bool
Definition: parameters.h:126
CSG_Parameters::Get_Count
int Get_Count(void) const
Definition: parameters.h:1731
CSG_Parameters::Restore_Defaults
bool Restore_Defaults(bool bClearData=false)
Definition: parameters.cpp:1513
CSG_Tool::DataObject_Classify_Quantile
static bool DataObject_Classify_Quantile(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, bool bHistogram=true, int Colors=-1)
Definition: tool.cpp:1232
CSG_Tool::Get_Parameters
CSG_Parameters * Get_Parameters(void)
Definition: tool.h:165
PARAMETER_TYPE_Table_Field
@ PARAMETER_TYPE_Table_Field
Definition: parameters.h:145
CSG_Tool::Process_Get_Okay
static bool Process_Get_Okay(bool bBlink=false)
Definition: tool.cpp:846
CSG_Parameter::is_Enabled
bool is_Enabled(bool bCheckEnv=true) const
Definition: parameter.cpp:224
CSG_MetaData::Del_Children
bool Del_Children(int Depth=0, const SG_Char *Name=NULL)
Definition: metadata.cpp:381
SG_META_HISTORY
#define SG_META_HISTORY
Definition: dataobject.h:93
PARAMETER_TYPE_Choice
@ PARAMETER_TYPE_Choice
Definition: parameters.h:133
CSG_Parameter::asParameters
class CSG_Parameters * asParameters(void) const
Definition: parameter.cpp:1052
SG_UI_Dlg_Parameters
bool SG_UI_Dlg_Parameters(CSG_Parameters *pParameters, const CSG_String &Caption)
Definition: api_callback.cpp:445
CSG_Parameters::Get_Tool
class CSG_Tool * Get_Tool(void) const
Definition: parameters.h:1718
SG_UI_DataObject_Update
bool SG_UI_DataObject_Update(CSG_Data_Object *pDataObject, int Show, CSG_Parameters *pParameters)
Definition: api_callback.cpp:633
CSG_Parameters::Add_Reference
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: parameters.cpp:361
CSG_Tool::Get_MenuPath
virtual CSG_String Get_MenuPath(void)
Definition: tool.h:162
sLong
signed long long sLong
Definition: api_core.h:158
CSG_Tool::Get_Library
const CSG_String & Get_Library(void) const
Definition: tool.cpp:115
CSG_Tool::DataObject_Get_Colors
static bool DataObject_Get_Colors(CSG_Data_Object *pDataObject, CSG_Colors &Colors)
Definition: tool.cpp:996
SG_UI_DataObject_Add
bool SG_UI_DataObject_Add(CSG_Data_Object *pDataObject, int Show)
Definition: api_callback.cpp:607
CSG_MetaData::Add_Property
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition: metadata.cpp:559
CSG_Tool::Destroy
virtual void Destroy(void)
Definition: tool.cpp:102
SG_UI_DataObject_Colors_Set
bool SG_UI_DataObject_Colors_Set(CSG_Data_Object *pDataObject, CSG_Colors *pColors)
Definition: api_callback.cpp:693
CSG_Tool::DataObject_Get_Parameters
static bool DataObject_Get_Parameters(CSG_Data_Object *pDataObject, CSG_Parameters &Parameters)
Definition: tool.cpp:1016
CSG_Tool::Set_Callback
void Set_Callback(bool bActive=true)
Definition: tool.cpp:559
CSG_Tool::Script_Format::Python_Wrapper_Func_ID
@ Python_Wrapper_Func_ID
PARAMETER_DESCRIPTION_TYPE
#define PARAMETER_DESCRIPTION_TYPE
Definition: parameters.h:108
CSG_Tool::DataObject_Classify_Defined
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:1222
CSG_Tool::Message_Dlg
void Message_Dlg(const CSG_String &Text, const SG_Char *Caption=NULL)
Definition: tool.cpp:693
CSG_Tool::_On_Parameter_Changed
static int _On_Parameter_Changed(CSG_Parameter *pParameter, int Flags)
Definition: tool.cpp:452
SG_UI_Process_Set_Text
void SG_UI_Process_Set_Text(const CSG_String &Text)
Definition: api_callback.cpp:323
PARAMETER_TYPE_Grid
@ PARAMETER_TYPE_Grid
Definition: parameters.h:149
CSG_Parameter::Get_CmdID
CSG_String Get_CmdID(void) const
Definition: parameter.cpp:578
SG_String_Tokenize
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)
Definition: api_string.cpp:1597
CSG_Tool::Script_Format::Python_Wrapper_Call_Name
@ Python_Wrapper_Call_Name
PARAMETER_TYPE_Date
@ PARAMETER_TYPE_Date
Definition: parameters.h:130
CSG_Tool::Message_Dlg_Confirm
bool Message_Dlg_Confirm(const CSG_String &Text, const SG_Char *Caption=NULL)
Definition: tool.cpp:699
CSG_Data_Object::Get_File_Name
const SG_Char * Get_File_Name(bool bNative=true) const
Definition: dataobject.cpp:390
SG_Color_To_Text
CSG_String SG_Color_To_Text(long Color, bool bHexadecimal)
Definition: api_colors.cpp:144
CSG_Tool::Get_ID
const CSG_String & Get_ID(void) const
Definition: tool.h:150
CSG_Parameters::Get_References
const CSG_Strings & Get_References(void) const
Definition: parameters.h:1746
PARAMETER_TYPE_Grid_List
@ PARAMETER_TYPE_Grid_List
Definition: parameters.h:155
CSG_Tool::Process_Set_Text
static void Process_Set_Text(const CSG_String &Text)
Definition: tool.cpp:852
CSG_Data_Manager::Delete
bool Delete(CSG_Data_Object *pObject, bool bDetach=false)
Definition: data_manager.cpp:623
SG_UI_MSG_STYLE_BOLD
@ SG_UI_MSG_STYLE_BOLD
Definition: api_core.h:1573
CSG_Parameter::is_Optional
bool is_Optional(void) const
Definition: parameters.h:238
SG_DATAOBJECT_TYPE_TIN
@ SG_DATAOBJECT_TYPE_TIN
Definition: dataobject.h:122
CSG_Parameters::Create
bool Create(const CSG_Parameters &Parameters)
Definition: parameters.cpp:124
CSG_Strings
Definition: api_core.h:701
CSG_Tool::has_CMD
bool has_CMD(void) const
Definition: tool.cpp:245
CSG_Tool::Update_Parameter_States
bool Update_Parameter_States(void)
Definition: tool.cpp:1424
CSG_Tool::On_Execute
virtual bool On_Execute(void)=0
CSG_Tool::Script_Format::Toolchain
@ Toolchain
TOOL_ERROR_Calculation
@ TOOL_ERROR_Calculation
Definition: tool.h:114
CSG_DateTime
Definition: datetime.h:183
SG_DATAOBJECT_TYPE_Grid
@ SG_DATAOBJECT_TYPE_Grid
Definition: dataobject.h:118
CSG_String::Replace
size_t Replace(const CSG_String &Old, const CSG_String &New, bool bReplaceAll=true)
Definition: api_string.cpp:563
CSG_Parameters::Del_Parameter
bool Del_Parameter(int i)
Definition: parameters.cpp:1283
CSG_Data_Manager::Add
CSG_Data_Object * Add(CSG_Data_Object *pObject)
Definition: data_manager.cpp:310
CSG_Tool::Get_File_Name
const CSG_String & Get_File_Name(void) const
Definition: tool.cpp:121
CSG_Tool::On_Parameter_Changed
virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
Definition: tool.cpp:476
CSG_Grid_System::Get_NY
int Get_NY(void) const
Definition: grid.h:259
CSG_Parameter::is_Output
bool is_Output(void) const
Definition: parameters.h:237
CSG_MetaData::Add_Children
bool Add_Children(const CSG_MetaData &MetaData)
Definition: metadata.cpp:359
CSG_Tool::Set_Name
void Set_Name(const CSG_String &String)
Definition: tool.cpp:127
CSG_MetaData::Assign
bool Assign(const CSG_MetaData &MetaData, bool bAddChildren=true)
Definition: metadata.cpp:757
ADD_MESSAGE_EXECUTION
#define ADD_MESSAGE_EXECUTION(Text, Style)
CSG_Tool::Set_Description
void Set_Description(const CSG_String &String)
Definition: tool.cpp:160
CSG_String::Format
static CSG_String Format(const char *Format,...)
Definition: api_string.cpp:270
CSG_TimeSpan::Get_Minutes
int Get_Minutes(void) const
Definition: datetime.h:162
CSG_Parameter_List::Get_Item_Count
int Get_Item_Count(void) const
Definition: parameters.h:1378
SG_UI_DataObject_Colors_Get
bool SG_UI_DataObject_Colors_Get(CSG_Data_Object *pDataObject, CSG_Colors *pColors)
Definition: api_callback.cpp:680
CSG_Projection
Definition: geo_tools.h:827
CSG_Tool::Script_Format::CMD_Usage
@ CMD_Usage
CSG_Tool::has_GUI
bool has_GUI(void) const
Definition: tool.cpp:239
CSG_Tool::Reset_Grid_System
bool Reset_Grid_System(void)
Definition: tool.cpp:1386
SG_UI_Dlg_Error
int SG_UI_Dlg_Error(const CSG_String &Message, const CSG_String &Caption)
Definition: api_callback.cpp:402
CSG_Tool::DataObject_Set_Stretch_Percentile
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:1171
SG_DATAOBJECT_TYPE_Shapes
@ SG_DATAOBJECT_TYPE_Shapes
Definition: dataobject.h:121
CSG_String::AfterFirst
CSG_String AfterFirst(char Character) const
Definition: api_string.cpp:691
CSG_String::Clear
void Clear(void)
Definition: api_string.cpp:259
CSG_Parameter::Get_Children_Count
int Get_Children_Count(void) const
Definition: parameters.h:259
CSG_Parameter::Get_Parent
CSG_Parameter * Get_Parent(void) const
Definition: parameter.cpp:106
CSG_Parameter::is_DataObject
bool is_DataObject(void) const
Definition: parameter.cpp:291
SG_UI_DataObject_Params_Get
bool SG_UI_DataObject_Params_Get(CSG_Data_Object *pDataObject, CSG_Parameters *pParameters)
Definition: api_callback.cpp:719
CSG_TimeSpan::Get_Seconds
sLong Get_Seconds(void) const
Definition: datetime.h:163
SG_Char
#define SG_Char
Definition: api_core.h:536
CSG_Parameters::Set_Description
void Set_Description(const CSG_String &Description)
Definition: parameters.cpp:351
INIT_STRETCH_OPTIONS
#define INIT_STRETCH_OPTIONS(method)
Definition: tool.cpp:1135
CSG_String::Contains
bool Contains(const CSG_String &String) const
Definition: api_string.cpp:680
CSG_Tool::DataObject_Set_Colors
static bool DataObject_Set_Colors(CSG_Data_Object *pDataObject, const CSG_Colors &Colors)
Definition: tool.cpp:1001
SG_UI_DATAOBJECT_SHOW_MAP
@ SG_UI_DATAOBJECT_SHOW_MAP
Definition: api_core.h:1589
CSG_String
Definition: api_core.h:563
CSG_Parameters::Set_Tool
void Set_Tool(class CSG_Tool *pTool)
Definition: parameters.cpp:202
SG_UI_Get_Application_Path
CSG_String SG_UI_Get_Application_Path(bool bPathOnly)
Definition: api_core.cpp:356
CSG_Tool::Get_Author
const CSG_String & Get_Author(void) const
Definition: tool.cpp:143
CSG_Tool::Set_Manager
bool Set_Manager(class CSG_Data_Manager *pManager)
Definition: tool.cpp:570
CSG_Tool::DataObject_Set_Stretch
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:1182
SG_DATAOBJECT_TYPE_Table
@ SG_DATAOBJECT_TYPE_Table
Definition: dataobject.h:120
CSG_Data_Manager
Definition: data_manager.h:129
CSG_MetaData
Definition: metadata.h:88
CSG_Tool::Settings_Pop
bool Settings_Pop(void)
Definition: tool.cpp:634
CSG_Parameter_String
Definition: parameters.h:805
SG_Get_History_Depth
int SG_Get_History_Depth(void)
Definition: dataobject.cpp:159
CSG_Tool::Settings_Push
bool Settings_Push(class CSG_Data_Manager *pManager=NULL)
Definition: tool.cpp:621
CSG_String::is_Empty
bool is_Empty(void) const
Definition: api_string.cpp:178
CSG_Tool::DataObject_Classify_Unique
static bool DataObject_Classify_Unique(CSG_Data_Object *pDataObject, int Field=-1, int Classes_Max=1024, int Colors=-1)
Definition: tool.cpp:1202
SG_UI_Process_Set_Progress
bool SG_UI_Process_Set_Progress(int Position, int Range)
Definition: api_callback.cpp:255
PARAMETER_DESCRIPTION_TEXT
#define PARAMETER_DESCRIPTION_TEXT
Definition: parameters.h:111
CSG_Parameter::asDouble
double asDouble(void) const
Definition: parameters.h:288
PARAMETER_TYPE_Grid_System
@ PARAMETER_TYPE_Grid_System
Definition: parameters.h:144
CSG_Tool::Get_Description
const CSG_String & Get_Description(void) const
Definition: tool.cpp:165
PARAMETER_TYPE_PointCloud_List
@ PARAMETER_TYPE_PointCloud_List
Definition: parameters.h:160
CSG_Tool::is_Interactive
virtual bool is_Interactive(void) const
Definition: tool.h:223
CSG_Tool::Set_Progress
virtual bool Set_Progress(int Position, int Range) const
Definition: tool.cpp:660
CSG_Tool::Delete_Manager
bool Delete_Manager(bool bDetachData=false, bool bReset=true)
Definition: tool.cpp:597
PARAMETER_TYPE_Table_List
@ PARAMETER_TYPE_Table_List
Definition: parameters.h:157
CSG_Array_Pointer::Add
bool Add(void *Value)
Definition: api_memory.cpp:485
CSG_Parameter::asRange
class CSG_Parameter_Range * asRange(void) const
Definition: parameter.cpp:1149
CSG_Tool::CSG_Tool
CSG_Tool(void)
Definition: tool.cpp:67
CSG_MetaData::Set_Name
void Set_Name(const CSG_String &Name)
Definition: metadata.h:130
CSG_Tool::Script_Format::Python_Wrapper_Func_Name
@ Python_Wrapper_Func_Name
CSG_Parameters::Set_Manager
void Set_Manager(class CSG_Data_Manager *pManager)
Definition: parameters.cpp:223
CSG_Tool::Script_Format::CMD_Shell
@ CMD_Shell
CSG_Tool::DataObject_Classify_Natural
static bool DataObject_Classify_Natural(CSG_Data_Object *pDataObject, int Field=-1, int Classes=10, int Colors=-1)
Definition: tool.cpp:1252
PARAMETER_TYPE_DataObject_Output
@ PARAMETER_TYPE_DataObject_Output
Definition: parameters.h:162
CSG_Parameters::Set_Parameter
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
Definition: parameters.cpp:1440
CSG_Grid_System::Get_NX
int Get_NX(void) const
Definition: grid.h:258
PARAMETER_DESCRIPTION_PROPERTIES
#define PARAMETER_DESCRIPTION_PROPERTIES
Definition: parameters.h:110
PARAMETER_CHECK_VALUES
#define PARAMETER_CHECK_VALUES
Definition: parameters.h:190
CSG_Parameters::Get_Name
const CSG_String & Get_Name(void) const
Definition: parameters.h:1738
CSG_String::c_str
const SG_Char * c_str(void) const
Definition: api_string.cpp:236
CSG_Parameters::Set_Callback_On_Parameter_Changed
TSG_PFNC_Parameter_Changed Set_Callback_On_Parameter_Changed(TSG_PFNC_Parameter_Changed pCallback)
Definition: parameters.cpp:1377
SG_UI_Process_Set_Ready
bool SG_UI_Process_Set_Ready(void)
Definition: api_callback.cpp:305
CSG_Strings::Get_Count
int Get_Count(void) const
Definition: api_core.h:714
PARAMETER_CHECK_ENABLE
#define PARAMETER_CHECK_ENABLE
Definition: parameters.h:191
CSG_Parameters
Definition: parameters.h:1696
CSG_Parameter::Get_DataObject_Type
TSG_Data_Object_Type Get_DataObject_Type(void) const
Definition: parameter.cpp:534
CSG_Parameter_Range::Get_Min
double Get_Min(void) const
Definition: parameter_data.cpp:816
CSG_MetaData::Add_Child
CSG_MetaData * Add_Child(void)
Definition: metadata.cpp:166
SG_UI_Msg_Add_Error
void SG_UI_Msg_Add_Error(const char *Message)
Definition: api_callback.cpp:553
CSG_Parameter::Cmp_Identifier
bool Cmp_Identifier(const CSG_String &Identifier) const
Definition: parameter.cpp:568
CSG_Parameter::asGrid_System
CSG_Grid_System * asGrid_System(void) const
Definition: parameter.cpp:1053
CSG_Tool::Error_Fmt
bool Error_Fmt(const char *Format,...)
Definition: tool.cpp:742
CSG_Tool::Get_Type
virtual TSG_Tool_Type Get_Type(void) const
Definition: tool.h:148
CSG_Tool::Message_Fmt
void Message_Fmt(const char *Format,...)
Definition: tool.cpp:921
CSG_Parameter::Get_Name
const SG_Char * Get_Name(void) const
Definition: parameter.cpp:604
CSG_Parameter::is_Default
virtual bool is_Default(void) const
Definition: parameter.cpp:950
PARAMETER_TYPE_Range
@ PARAMETER_TYPE_Range
Definition: parameters.h:131
CSG_Parameter::is_Option
bool is_Option(void) const
Definition: parameter.cpp:254
PARAMETER_OUTPUT
#define PARAMETER_OUTPUT
Definition: parameters.h:95
CSG_Tool::Set_Grid_System
bool Set_Grid_System(const CSG_Grid_System &System)
Definition: tool.cpp:1401
PARAMETER_TYPE_TIN_List
@ PARAMETER_TYPE_TIN_List
Definition: parameters.h:159
CSG_Grid_System::Get_YMin
double Get_YMin(bool bCells=false) const
Definition: grid.h:268
PARAMETER_TYPE_Parameters
@ PARAMETER_TYPE_Parameters
Definition: parameters.h:164
CSG_Parameter::asList
class CSG_Parameter_List * asList(void) const
Definition: parameter.cpp:1154
PARAMETER_TYPE_Color
@ PARAMETER_TYPE_Color
Definition: parameters.h:140
PARAMETER_TYPE_Shapes
@ PARAMETER_TYPE_Shapes
Definition: parameters.h:152
SG_Get_DataObject_Class_Name
CSG_String SG_Get_DataObject_Class_Name(TSG_Data_Object_Type Type)
Definition: dataobject.cpp:101
SG_DATAOBJECT_TYPE_PointCloud
@ SG_DATAOBJECT_TYPE_PointCloud
Definition: dataobject.h:123
CSG_Tool::On_Parameters_Enable
virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
Definition: tool.cpp:482
CSG_Parameters::Set_History
bool Set_History(CSG_MetaData &History, bool bOptions=true, bool bDataObjects=true)
Definition: parameters.cpp:2002
CSG_Parameters::Set_Callback
bool Set_Callback(bool bActive=true)
Definition: parameters.cpp:1398
CSG_Parameter::is_Information
bool is_Information(void) const
Definition: parameters.h:239
PARAMETER_INPUT
#define PARAMETER_INPUT
Definition: parameters.h:94
PARAMETER_DESCRIPTION_NAME
#define PARAMETER_DESCRIPTION_NAME
Definition: parameters.h:107
CSG_Parameter::Get_Type_Identifier
CSG_String Get_Type_Identifier(void) const
Definition: parameter.cpp:123
CSG_Colors
Definition: api_core.h:1408
CSG_Parameter::asBool
bool asBool(void) const
Definition: parameters.h:285
SG_UI_Msg_Add
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
Definition: api_callback.cpp:499
CSG_Tool::Get_Grid_System
CSG_Grid_System * Get_Grid_System(void) const
Definition: tool.cpp:1411
DATAOBJECT_NOTSET
#define DATAOBJECT_NOTSET
Definition: dataobject.h:129
PARAMETER_TYPE_Text
@ PARAMETER_TYPE_Text
Definition: parameters.h:136