SAGA API  v9.2
tool_chain.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_chain.cpp //
15 // //
16 // Copyright (C) 2014 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 Hamburg //
44 // Germany //
45 // //
46 // e-mail: oconrad@saga-gis.org //
47 // //
49 
50 //---------------------------------------------------------
51 #include "saga_api.h"
52 
53 #include "tool_chain.h"
54 
55 
57 // //
58 // //
59 // //
61 
62 //---------------------------------------------------------
63 #define GET_XML_CONTENT(XML, ID, DEFAULT, TRANSLATE) (!XML(ID) ? CSG_String(DEFAULT) : !TRANSLATE ? XML[ID].Get_Content() : CSG_String(SG_Translate(XML[ID].Get_Content())))
64 
65 #define IS_TRUE_STRING(String) (!String.CmpNoCase("true") || !String.CmpNoCase("1"))
66 #define IS_TRUE_PROPERTY(Item, Property) (Item.Cmp_Property(Property, "true", true) || Item.Cmp_Property(Property, "1"))
67 
68 #define Get_List_Count(p) (p->asGridList() ? p->asGridList()->Get_Grid_Count() : p->asList() ? p->asList()->Get_Item_Count() : 0)
69 #define Get_List_Item(p, i) (p->asGridList() ? p->asGridList()->Get_Grid (i) : p->asList() ? p->asList()->Get_Item (i) : NULL)
70 
71 
73 // //
74 // //
75 // //
77 
78 //---------------------------------------------------------
80 {
81  // nop
82 }
83 
84 //---------------------------------------------------------
86 {
87  Create(Tool, bWithGUI);
88 }
89 
90 //---------------------------------------------------------
92 {
93  Create(File);
94 }
95 
96 //---------------------------------------------------------
98 {
99  Create(Chain);
100 }
101 
102 //---------------------------------------------------------
104 {
105  Reset();
106 }
107 
108 //---------------------------------------------------------
109 void CSG_Tool_Chain::Reset(void)
110 {
113 
114  m_Chain.Destroy();
115 
116  m_Conditions.Destroy();
117 
118  m_Menu.Clear();
119 }
120 
121 //---------------------------------------------------------
123 {
124  m_Library_Menu = Menu;
125 }
126 
127 
129 // //
131 
132 //---------------------------------------------------------
133 bool CSG_Tool_Chain::Create(const CSG_Tool_Chain &Tool, bool bWithGUI)
134 {
135  if( !Create(Tool.m_Chain) )
136  {
137  return( false );
138  }
139 
140  m_ID = Tool.m_ID;
141  m_Library = Tool.m_Library;
142  m_Library_Menu = Tool.m_Library_Menu;
143  m_File_Name = Tool.m_File_Name;
144  m_bWithGUI = bWithGUI;
145 
146  return( true );
147 }
148 
149 //---------------------------------------------------------
151 {
152  CSG_MetaData Chain;
153 
154  if( File.Right(sizeof(".pyt.xml")).Make_Lower().Find(".pyt.xml") >= 0 )
155  {
156  return( false );
157  }
158 
159  if( !Chain.Load(File) )
160  {
161  Error_Fmt("%s: %s", _TL("failed to load or parse xml file"), File.c_str());
162 
163  return( false );
164  }
165 
166  if( Chain.Cmp_Name("toolchains") ) // don't report any error, this xml-file provides info for a category of tool chains
167  {
168  return( false );
169  }
170 
171  if( !Chain.Cmp_Name("toolchain") || !Chain("identifier") || !Chain("parameters") )
172  {
173  Error_Fmt("%s: %s", _TL("xml file is not a valid tool chain"), File.c_str());
174 
175  return( false );
176  }
177 
178  //-----------------------------------------------------
179  SG_UI_Msg_Add(CSG_String::Format("%s: %s...", File.Cmp(m_File_Name) ? _TL("Loading tool chain") : _TL("Reloading tool chain"), File.c_str()), true);
180 
181  if( Create(Chain) )
182  {
183  m_File_Name = File;
184 
185  SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS);
186 
187  return( true );
188  }
189 
190  m_File_Name.Clear(); Reset();
191 
192  SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);
193 
194  return( false );
195 }
196 
197 //---------------------------------------------------------
199 {
200  if( !Chain.Cmp_Name("toolchain") || !Chain("identifier") || !Chain("parameters") || !Chain("tools") )
201  {
202  return( false );
203  }
204 
205  if( SG_Compare_Version(Chain.Get_Property("saga-version"), "2.1.3") < 0 )
206  {
207  Error_Fmt("%s %s: %s", _TL("Warning"), _TL("unsupported tool chain version"), Chain.Get_Property("saga-version"));
208  }
209 
210  //-----------------------------------------------------
211  Reset();
212 
213  m_Chain = Chain;
214  m_ID = GET_XML_CONTENT(m_Chain, "identifier" , "" , false) ;
215  m_Library = GET_XML_CONTENT(m_Chain, "group" , "toolchains" , false) ;
216  m_Menu = GET_XML_CONTENT(m_Chain, "menu" , "" , true) ;
217  Set_Name (GET_XML_CONTENT(m_Chain, "name" , _TL("Not Named" ), true));
218  Set_Author (GET_XML_CONTENT(m_Chain, "author" , _TL("unknown" ), false));
219  Set_Description (GET_XML_CONTENT(m_Chain, "description", _TL("no description"), true));
220 
221  if( m_Library.is_Empty() )
222  {
223  m_Library = "toolchains";
224  }
225 
226  Add_References();
227 
228  CSG_String Description = Get_Description();
229  Description.Replace("[[", "<"); // support for xml/html tags
230  Description.Replace("]]", ">");
231  Set_Description(Description);
232 
233  if( !m_Menu.is_Empty() && (m_Menu.Length() < 2 || m_Menu[1] != ':') )
234  {
235  if( IS_TRUE_PROPERTY(m_Chain["menu"], "absolute") )
236  m_Menu.Prepend("A:"); // absolute path
237  else
238  m_Menu.Prepend("R:"); // relative path
239  }
240 
241  m_bAddHistory = IS_TRUE_PROPERTY(m_Chain["tools"], "history");
242 
243  //-----------------------------------------------------
244  for(int i=0; i<m_Chain["parameters"].Get_Children_Count(); i++)
245  {
246  const CSG_MetaData &Parameter = m_Chain["parameters"][i];
247 
248  CSG_String ID = Parameter.Get_Property("varname");
249 
250  if( ID.is_Empty() || Parameters(ID) )
251  {
252  continue;
253  }
254 
255  if( Parameter.Get_Property("with_gui") && !IS_TRUE_PROPERTY(Parameter, "with_gui") && has_GUI() == false )
256  {
257  continue;
258  }
259 
260  if( Parameter.Get_Property("with_cmd") && !IS_TRUE_PROPERTY(Parameter, "with_cmd") && has_GUI() != false )
261  {
262  continue;
263  }
264 
265  //-------------------------------------------------
266  int Constraint = 0;
267  CSG_String Value;
268  bool bMin = false, bMax = false;
269  double Min = 0. , Max = 0.;
270 
271  if( Parameter.Cmp_Name("input") )
272  {
273  Constraint = IS_TRUE_PROPERTY(Parameter, "optional") ? PARAMETER_INPUT_OPTIONAL : PARAMETER_INPUT;
274  }
275  else if( Parameter.Cmp_Name("output") )
276  {
277  Constraint = IS_TRUE_PROPERTY(Parameter, "optional") ? PARAMETER_OUTPUT_OPTIONAL : PARAMETER_OUTPUT;
278  }
279  else if( Parameter.Cmp_Name("option") && Parameter("value") )
280  {
281  Value = Parameter.Get_Content("value");
282 
283  bMin = Parameter["value"].Get_Property("min", Min);
284  bMax = Parameter["value"].Get_Property("max", Max);
285  }
286 
287  //-------------------------------------------------
288  if( Parameter("condition") )
289  {
290  CSG_MetaData &Conditions = *m_Conditions.Add_Child(ID);
291 
292  for(int j=0; j<Parameter.Get_Children_Count(); j++) // there might be more than one condition to be checked
293  {
294  if( Parameter[j].Cmp_Name("condition") )
295  {
296  Conditions.Add_Child(Parameter[j]);
297  }
298  }
299  }
300 
301  //-------------------------------------------------
302  CSG_String Name = SG_Translate(Parameter.Get_Content("name" ));
303  CSG_String Desc = SG_Translate(Parameter.Get_Content("description"));
304 
305  CSG_Parameter *pParent = Parameters(Parameter.Get_Property("parent"));
306  CSG_String ParentID(pParent ? pParent->Get_Identifier() : SG_T(""));
307 
308  //-------------------------------------------------
309  switch( SG_Parameter_Type_Get_Type(Parameter.Get_Property("type")) )
310  {
311  case PARAMETER_TYPE_Node : Parameters.Add_Node (ParentID, ID, Name, Desc); break;
312 
313  case PARAMETER_TYPE_Bool : Parameters.Add_Bool (ParentID, ID, Name, Desc, IS_TRUE_STRING(Value)); break;
314  case PARAMETER_TYPE_Int : Parameters.Add_Int (ParentID, ID, Name, Desc, Value.asInt (), (int)Min, bMin, (int)Max, bMax); break;
315  case PARAMETER_TYPE_Double : Parameters.Add_Double (ParentID, ID, Name, Desc, Value.asDouble(), Min, bMin, Max, bMax); break;
316  case PARAMETER_TYPE_Degree : Parameters.Add_Degree (ParentID, ID, Name, Desc, Value.asDouble(), Min, bMin, Max, bMax); break;
317 
318  case PARAMETER_TYPE_Date : Parameters.Add_Date (ParentID, ID, Name, Desc, 0.)->Set_Value(Value); break;
319 
320  case PARAMETER_TYPE_Range : Parameters.Add_Range (ParentID, ID, Name, Desc, Value.BeforeFirst(';').asDouble(), Value.AfterFirst(';').asDouble(), Min, bMin, Max, bMax); break;
322  case PARAMETER_TYPE_Choice : Parameters.Add_Choice (ParentID, ID, Name, Desc, Parameter.Get_Content("choices"))->Set_Value(Value); break;
323  case PARAMETER_TYPE_Choices : Parameters.Add_Choices (ParentID, ID, Name, Desc, Parameter.Get_Content("choices"))->Set_Value(Value); break;
324 
325  case PARAMETER_TYPE_String : Parameters.Add_String (ParentID, ID, Name, Desc, Value, false); break;
326  case PARAMETER_TYPE_Text : Parameters.Add_String (ParentID, ID, Name, Desc, Value, true); break;
327 
328  case PARAMETER_TYPE_FilePath : Parameters.Add_FilePath (ParentID, ID, Name, Desc, Parameter.Get_Content("filter"), Value,
329  IS_TRUE_PROPERTY(Parameter, "save" ),
330  IS_TRUE_PROPERTY(Parameter, "directory"),
331  IS_TRUE_PROPERTY(Parameter, "multiple" )
332  ); break;
333 
334  case PARAMETER_TYPE_Font : break;
335  case PARAMETER_TYPE_Color : Parameters.Add_Color (ParentID, ID, Name, Desc, Value.asInt()); break;
336  case PARAMETER_TYPE_Colors : Parameters.Add_Colors (ParentID, ID, Name, Desc); break;
337  case PARAMETER_TYPE_FixedTable : Parameters.Add_FixedTable (ParentID, ID, Name, Desc)->Serialize(*Parameter("option"), false); break;
338 
339  case PARAMETER_TYPE_Grid_System : Parameters.Add_Grid_System (ParentID, ID, Name, Desc); break;
340 
341  case PARAMETER_TYPE_Table_Field : Parameters.Add_Table_Field (ParentID, ID, Name, Desc, (!Value.CmpNoCase("true") || !Value.CmpNoCase("1"))); break;
342  case PARAMETER_TYPE_Table_Fields : Parameters.Add_Table_Fields (ParentID, ID, Name, Desc); break;
343 
344  case PARAMETER_TYPE_Grid : Parameter.Cmp_Property("target", "none")
345  ? Parameters.Add_Grid_Output ( "", ID, Name, Desc)
346  : Parameters.Add_Grid (ParentID, ID, Name, Desc, Constraint); break;
347 
348  case PARAMETER_TYPE_Grids : Parameter.Cmp_Property("target", "none")
349  ? Parameters.Add_Grids_Output ( "", ID, Name, Desc)
350  : Parameters.Add_Grids (ParentID, ID, Name, Desc, Constraint); break;
351 
352  case PARAMETER_TYPE_Table : Parameters.Add_Table (ParentID, ID, Name, Desc, Constraint); break;
353 
354  case PARAMETER_TYPE_Shapes : Parameters.Add_Shapes (ParentID, ID, Name, Desc, Constraint,
355  Parameter.Cmp_Property("feature_type", "point" ) ? SHAPE_TYPE_Point :
356  Parameter.Cmp_Property("feature_type", "points" ) ? SHAPE_TYPE_Points :
357  Parameter.Cmp_Property("feature_type", "line" ) ? SHAPE_TYPE_Line :
358  Parameter.Cmp_Property("feature_type", "polygon") ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Undefined
359  ); break;
360 
361  case PARAMETER_TYPE_TIN : Parameters.Add_TIN (ParentID, ID, Name, Desc, Constraint); break;
362  case PARAMETER_TYPE_PointCloud : Parameters.Add_PointCloud (ParentID, ID, Name, Desc, Constraint); break;
363 
364  case PARAMETER_TYPE_Grid_List : Parameters.Add_Grid_List (ParentID, ID, Name, Desc, Constraint, !IS_TRUE_PROPERTY(Parameter, "no_system")); break;
365  case PARAMETER_TYPE_Grids_List : Parameters.Add_Grids_List (ParentID, ID, Name, Desc, Constraint, !IS_TRUE_PROPERTY(Parameter, "no_system")); break;
366  case PARAMETER_TYPE_Table_List : Parameters.Add_Table_List (ParentID, ID, Name, Desc, Constraint); break;
367  case PARAMETER_TYPE_Shapes_List : Parameters.Add_Shapes_List (ParentID, ID, Name, Desc, Constraint); break;
368  case PARAMETER_TYPE_TIN_List : Parameters.Add_TIN_List (ParentID, ID, Name, Desc, Constraint); break;
369  case PARAMETER_TYPE_PointCloud_List : Parameters.Add_PointCloud_List(ParentID, ID, Name, Desc, Constraint); break;
370 
372  case PARAMETER_TYPE_Parameters : break; // to do ?
373 
374  default: break;
375  }
376  }
377 
378  //-----------------------------------------------------
379  return( is_Okay() );
380 }
381 
382 
384 // //
386 
387 //---------------------------------------------------------
389 {
390  return( !m_Chain("CRS_SYNC") || IS_TRUE_STRING(m_Chain["CRS_SYNC"].Get_Content()) );
391 }
392 
393 //---------------------------------------------------------
394 void CSG_Tool_Chain::Add_References(void)
395 {
396  for(int i=0; i<m_Chain.Get_Children_Count(); i++)
397  {
398  if( !m_Chain[i].Get_Name().CmpNoCase("REFERENCE") )
399  {
400  CSG_String Authors, Year, Title, Where, Link, Link_Text, DOI;
401 
402  if( m_Chain[i]("AUTHORS" ) ) Authors = m_Chain[i].Get_Content("AUTHORS" );
403  if( m_Chain[i]("YEAR" ) ) Year = m_Chain[i].Get_Content("YEAR" );
404  if( m_Chain[i]("TITLE" ) ) Title = m_Chain[i].Get_Content("TITLE" );
405  if( m_Chain[i]("WHERE" ) ) Where = m_Chain[i].Get_Content("WHERE" );
406  if( m_Chain[i]("LINK" ) ) Link = m_Chain[i].Get_Content("LINK" );
407  if( m_Chain[i]("LINK_TEXT") ) Link_Text = m_Chain[i].Get_Content("LINK_TEXT");
408  if( m_Chain[i]("DOI" ) ) DOI = m_Chain[i].Get_Content("DOI" );
409 
410  if( !DOI.is_Empty() )
411  {
412  Link = "https://doi.org/" + DOI; Link_Text = "doi:" + DOI;
413  }
414 
415  if( !Authors.is_Empty() && !Year.is_Empty() && !Title.is_Empty() )
416  {
417  Add_Reference(Authors, Year, Title, Where, Link.c_str(), Link_Text.c_str());
418  }
419  else if( !Link.is_Empty() )
420  {
421  Add_Reference(Link, Link_Text.c_str());
422  }
423  }
424  }
425 }
426 
427 
429 // //
431 
432 //---------------------------------------------------------
434 {
435  for(int iParameter=0; iParameter<m_Conditions.Get_Children_Count(); iParameter++)
436  {
437  const CSG_MetaData &Conditions = m_Conditions[iParameter];
438 
439  if( (*pParameters)(Conditions.Get_Name()) )
440  {
441  bool bEnable = true;
442 
443  for(int iCondition=0; bEnable && iCondition<Conditions.Get_Children_Count(); iCondition++)
444  {
445  bEnable = Check_Condition(Conditions[iCondition], pParameters);
446  }
447 
448  (*pParameters)(Conditions.Get_Name())->Set_Enabled(bEnable);
449  }
450  }
451 
452  return( CSG_Tool::On_Parameters_Enable(pParameters, pParameter) );
453 }
454 
455 
457 // //
459 
460 //---------------------------------------------------------
462 {
463  bool bResult = Data_Initialize();
464 
465  if( !bResult )
466  {
467  Error_Set(_TL("no data objects"));
468  }
469 
470  for(int i=0; bResult && i<m_Chain["tools"].Get_Children_Count(); i++)
471  {
472  bResult = Tool_Run(m_Chain["tools"][i]);
473  }
474 
475  Data_Finalize();
476 
477  return( bResult );
478 }
479 
480 
482 // //
484 
485 //---------------------------------------------------------
486 bool CSG_Tool_Chain::Data_Add(const CSG_String &ID, CSG_Parameter *pData)
487 {
488  if( !pData )
489  {
490  return( false );
491  }
492 
493  CSG_Parameter *pParameter = m_Data(ID); // check if the local data manager already has a parameter with this identifier
494 
495  if( pParameter ) // it has, so don't add twice!
496  {
497  if( pParameter->is_Input() && pParameter->Get_Type() != pData->Get_Type() ) // don't allow to change parameter's data object type!
498  {
499  Error_Fmt("%s\n[%s] %s <> %s", _TL("Tool chain uses same variable name for different data object types."),
500  ID.c_str(), pParameter->Get_Type_Identifier().c_str(), pData->Get_Type_Identifier().c_str()
501  );
502 
503  return( false );
504  }
505  }
506 
507  //-----------------------------------------------------
508  else switch( pData->Get_Type() )
509  {
510  case PARAMETER_TYPE_PointCloud : pParameter = m_Data.Add_PointCloud ("", ID, "", "", 0 ); break;
511  case PARAMETER_TYPE_Grid : pParameter = m_Data.Add_Grid ("", ID, "", "", 0 ); break;
512  case PARAMETER_TYPE_Grids : pParameter = m_Data.Add_Grids ("", ID, "", "", 0 ); break;
513  case PARAMETER_TYPE_Table : pParameter = m_Data.Add_Table ("", ID, "", "", 0 ); break;
514  case PARAMETER_TYPE_Shapes : pParameter = m_Data.Add_Shapes ("", ID, "", "", 0 ); break;
515  case PARAMETER_TYPE_TIN : pParameter = m_Data.Add_TIN ("", ID, "", "", 0 ); break;
516 
517  case PARAMETER_TYPE_PointCloud_List: pParameter = m_Data.Add_PointCloud_List("", ID, "", "", 0 ); break;
518  case PARAMETER_TYPE_Grid_List : pParameter = m_Data.Add_Grid_List ("", ID, "", "", 0, false); break;
519  case PARAMETER_TYPE_Grids_List : pParameter = m_Data.Add_Grids_List ("", ID, "", "", 0, false); break;
520  case PARAMETER_TYPE_Table_List : pParameter = m_Data.Add_Table_List ("", ID, "", "", 0 ); break;
521  case PARAMETER_TYPE_Shapes_List : pParameter = m_Data.Add_Shapes_List ("", ID, "", "", 0 ); break;
522  case PARAMETER_TYPE_TIN_List : pParameter = m_Data.Add_TIN_List ("", ID, "", "", 0 ); break;
523 
525  switch( pData->Get_DataObject_Type() )
526  {
527  case SG_DATAOBJECT_TYPE_PointCloud: pParameter = m_Data.Add_PointCloud ("", ID, "", "", 0 ); break;
528  case SG_DATAOBJECT_TYPE_Grid : pParameter = m_Data.Add_Grid ("", ID, "", "", 0 ); break;
529  case SG_DATAOBJECT_TYPE_Grids : pParameter = m_Data.Add_Grids ("", ID, "", "", 0 ); break;
530  case SG_DATAOBJECT_TYPE_Table : pParameter = m_Data.Add_Table ("", ID, "", "", 0 ); break;
531  case SG_DATAOBJECT_TYPE_Shapes : pParameter = m_Data.Add_Shapes ("", ID, "", "", 0 ); break;
532  case SG_DATAOBJECT_TYPE_TIN : pParameter = m_Data.Add_TIN ("", ID, "", "", 0 ); break;
533  default:
534  return( true );
535  }
536  break;
537 
538  default:
539  return( true );
540  }
541 
542  //-----------------------------------------------------
543  if( pData->is_DataObject() )
544  {
545  if( pParameter->is_DataObject() )
546  {
547  pParameter->Set_Value(pData->asDataObject());
548  }
549  else
550  {
551  pParameter->asList()->Add_Item(pData->asDataObject());
552  }
553 
554  m_Data_Manager.Add(pData->asDataObject());
555  }
556  else if( pData->is_DataObject_List() && pParameter->is_DataObject_List() )
557  {
558  for(int i=0; i<Get_List_Count(pData); i++)
559  {
560  pParameter->asList()->Add_Item(Get_List_Item(pData, i));
561  m_Data_Manager.Add (Get_List_Item(pData, i));
562  }
563  }
564 
565  return( true );
566 }
567 
568 //---------------------------------------------------------
569 bool CSG_Tool_Chain::Data_Add_TempList(const CSG_String &ID, const CSG_String &Type)
570 {
571  if( !m_Data(ID) )
572  {
573  switch( SG_Parameter_Type_Get_Type(Type) )
574  {
575  case PARAMETER_TYPE_PointCloud_List: m_Data.Add_PointCloud_List("", ID, "", "", 0 ); break;
576  case PARAMETER_TYPE_Grid_List : m_Data.Add_Grid_List ("", ID, "", "", 0, false); break;
577  case PARAMETER_TYPE_Grids_List : m_Data.Add_Grids_List ("", ID, "", "", 0, false); break;
578  case PARAMETER_TYPE_Table_List : m_Data.Add_Table_List ("", ID, "", "", 0 ); break;
579  case PARAMETER_TYPE_Shapes_List : m_Data.Add_Shapes_List ("", ID, "", "", 0 ); break;
580  case PARAMETER_TYPE_TIN_List : m_Data.Add_TIN_List ("", ID, "", "", 0 ); break;
581 
582  default:
583  Error_Fmt("%s: %s [%s|%s]", SG_T("datalist"), _TL("unsupported data list type"), ID.c_str(), Type.c_str());
584 
585  return( false );
586  }
587  }
588 
589  return( true );
590 }
591 
592 //---------------------------------------------------------
593 bool CSG_Tool_Chain::Data_Del_Temp(const CSG_String &ID, bool bData)
594 {
595  CSG_Parameter *pData = m_Data(ID);
596 
597  if( pData )
598  {
599  if( bData )
600  {
601  if( pData->is_DataObject() )
602  {
603  m_Data_Manager.Delete(pData->asDataObject());
604  }
605  else if( pData->is_DataObject_List() )
606  {
607  for(int i=0; i<Get_List_Count(pData); i++)
608  {
609  m_Data_Manager.Delete(Get_List_Item(pData, i));
610  }
611  }
612  }
613 
614  m_Data.Del_Parameter(ID);
615  }
616 
617  return( true );
618 }
619 
620 
622 // //
624 
625 //---------------------------------------------------------
626 bool CSG_Tool_Chain::Data_Exists(CSG_Data_Object *pData)
627 {
628  for(int i=0; i<m_Data.Get_Count(); i++)
629  {
630  if( m_Data(i)->is_DataObject() )
631  {
632  if( pData == m_Data(i)->asDataObject() )
633  {
634  return( true );
635  }
636  }
637  else if( m_Data(i)->is_DataObject_List() )
638  {
639  for(int j=0; j<Get_List_Count(m_Data(i)); j++)
640  {
641  if( pData == Get_List_Item(m_Data(i), j) )
642  {
643  return( true );
644  }
645  }
646  }
647  }
648 
649  return( false );
650 }
651 
652 //---------------------------------------------------------
653 bool CSG_Tool_Chain::Data_Initialize(void)
654 {
655  m_Data.Set_Manager(NULL);
656 
657  for(int i=0; i<Parameters.Get_Count(); i++)
658  {
659  CSG_Parameter *pParameter = Parameters(i);
660 
661  if( !(pParameter->is_DataObject() && !pParameter->asDataObject()) )
662  {
663  if( !Data_Add(pParameter->Get_Identifier(), pParameter) )
664  {
665  return( false );
666  }
667  }
668  }
669 
670  return( true );
671 }
672 
673 //---------------------------------------------------------
674 bool CSG_Tool_Chain::Data_Finalize(void)
675 {
676  //-----------------------------------------------------
677  for(int i=0; i<Parameters.Get_Count(); i++) // detach non temporary data before freeing the local data manager !!!
678  {
679  if( Parameters(i)->is_DataObject() )
680  {
681  if( m_Data(Parameters(i)->Get_Identifier()) )
682  {
683  if( Parameters(i)->Get_Type() == PARAMETER_TYPE_DataObject_Output || (Parameters(i)->is_Output() && !Parameters(i)->is_Optional()) )
684  {
685  Parameters(i)->Set_Value(m_Data(Parameters(i)->Get_Identifier())->asDataObject());
686  }
687  }
688 
689  m_Data_Manager.Delete(Parameters(i)->asDataObject(), true);
690  }
691  else if( Parameters(i)->is_DataObject_List() )
692  {
693  if( Parameters(i)->is_Output() && m_Data(Parameters(i)->Get_Identifier()) ) // output lists cannot be up-to-date yet
694  {
695  CSG_Parameter *pData = m_Data(Parameters(i)->Get_Identifier());
696 
697  for(int j=0; j<Get_List_Count(pData); j++) // csg_parameter::assign() will not work, if parameters data manager is the standard data manager because it checks for existing data sets
698  {
699  Parameters(i)->asList()->Add_Item(Get_List_Item(pData, j));
700  }
701  }
702 
703  for(int j=0; j<Get_List_Count(Parameters(i)); j++)
704  {
705  m_Data_Manager.Delete(Get_List_Item(Parameters(i), j), true);
706  }
707  }
708  }
709 
710  m_Data_Manager.Delete_All();
711 
712  m_Data.Destroy();
713 
714  //-----------------------------------------------------
715  for(int i=0; i<m_Chain["parameters"].Get_Children_Count(); i++)
716  {
717  const CSG_MetaData &Parameter = m_Chain["parameters"][i];
718 
719  if( Parameter.Cmp_Name("output") )
720  {
721  CSG_Parameter *pParameter = Parameters(Parameter.Get_Property("varname"));
722 
723  if( pParameter && pParameter->is_DataObject() && pParameter->asDataObject() && pParameter->asDataObject() != DATAOBJECT_CREATE )
724  {
725  if( Parameter("colours") )
726  {
727  DataObject_Set_Colors(pParameter->asDataObject(), 11,
728  Parameter["colours"].Get_Content().asInt(), IS_TRUE_PROPERTY(Parameter["colours"], "revert")
729  );
730  }
731 
732  if( Parameter("output_name") )
733  {
734  if( IS_TRUE_PROPERTY(Parameter["output_name"], "input") )
735  {
736  CSG_Parameter *pInput = Parameters(Parameter["output_name"].Get_Content());
737 
738  if( pInput && pInput->is_DataObject() && pInput->asDataObject() )
739  {
740  CSG_String Suffix;
741 
742  if( Parameter["output_name"].Get_Property("suffix", Suffix) && !Suffix.is_Empty() )
743  {
744  Suffix = " [" + Suffix + "]";
745  }
746 
747  pParameter->asDataObject()->Set_Name(pInput->asDataObject()->Get_Name() + Suffix);
748  }
749  }
750  else if( !Parameter["output_name"].Get_Content().is_Empty() )
751  {
752  pParameter->asDataObject()->Set_Name(Parameter["output_name"].Get_Content());
753  }
754  }
755  }
756  }
757  }
758 
759  //-----------------------------------------------------
760  return( true );
761 }
762 
763 
765 // //
767 
768 //---------------------------------------------------------
769 bool CSG_Tool_Chain::Parameter_isCompatible(TSG_Parameter_Type A, TSG_Parameter_Type B)
770 {
771  if( A == B )
772  {
773  return( true );
774  }
775 
776  switch( A )
777  {
778  default:
779  return( false );
780 
782  return( B == PARAMETER_TYPE_Shapes
784  || B == PARAMETER_TYPE_TIN );
785 
787  return( B == PARAMETER_TYPE_PointCloud );
788  }
789 }
790 
791 
793 // //
795 
796 //---------------------------------------------------------
797 bool CSG_Tool_Chain::Check_Condition(const CSG_MetaData &Condition, CSG_Parameters *pData)
798 {
799  //-----------------------------------------------------
800  CSG_String Type;
801 
802  if( !Condition.Cmp_Name("condition") || !Condition.Get_Property("type", Type) )
803  {
804  return( true );
805  }
806 
807  //-----------------------------------------------------
808  CSG_String Variable;
809 
810  if( !Condition.Get_Property("varname", Variable) && !Condition.Get_Property("variable", Variable) )
811  {
812  Variable = Condition.Get_Content();
813  }
814 
815  //-----------------------------------------------------
816  if( !Type.CmpNoCase("has_gui" ) ) // executed from saga_gui ? (tool might offer different parameters if called from saga_cmd, python etc.)
817  {
818  return( IS_TRUE_STRING(Variable) ? has_GUI() != false : has_GUI() == false );
819  }
820 
821  //-----------------------------------------------------
822  if( !Type.CmpNoCase("exists" ) ) // data object exists
823  {
824  CSG_Parameter *pParameter = (*pData)(Variable);
825 
826  return( pParameter && ((pParameter->is_DataObject() && pParameter->asDataObject()) || (pParameter->is_DataObject_List() && pParameter->asList()->Get_Item_Count())) );
827  }
828 
829  if( !Type.CmpNoCase("not_exists") ) // data object does not exist
830  {
831  return( (*pData)(Variable) == NULL || (*pData)(Variable)->asDataObject() == NULL );
832  }
833 
834  //-----------------------------------------------------
835  CSG_Parameter *pOption = (*pData)(Variable);
836 
837  if( pOption == NULL )
838  {
839  return( true );
840  }
841 
842  switch( pOption->Get_Type() )
843  {
844  //-----------------------------------------------------
845  case PARAMETER_TYPE_Bool :
846  {
847  CSG_String Value;
848 
849  if( Condition.Get_Property("value", Value) )
850  {
851  if( !Type.CmpNoCase("=") || !Type.CmpNoCase("equal" ) ) { return( (IS_TRUE_STRING(Value) ? pOption->asBool() : !pOption->asBool()) ); }
852  else if( !Type.CmpNoCase("!") || !Type.CmpNoCase("not_equal") ) { return( (IS_TRUE_STRING(Value) ? !pOption->asBool() : pOption->asBool()) ); }
853  }
854  }
855  break;
856 
857  //-----------------------------------------------------
858  case PARAMETER_TYPE_Int :
859  case PARAMETER_TYPE_Color :
861  case PARAMETER_TYPE_Choice :
862  {
863  int Value;
864 
865  if( Condition.Get_Property("value", Value) )
866  {
867  if( !Type.CmpNoCase("=") || !Type.CmpNoCase("equal" ) ) { if( Value != pOption->asInt() ) { return( false ); } }
868  else if( !Type.CmpNoCase("!") || !Type.CmpNoCase("not_equal") ) { if( Value == pOption->asInt() ) { return( false ); } }
869  else if( !Type.CmpNoCase("<") || !Type.CmpNoCase("less" ) ) { if( Value >= pOption->asInt() ) { return( false ); } }
870  else if( !Type.CmpNoCase(">") || !Type.CmpNoCase("greater" ) ) { if( Value <= pOption->asInt() ) { return( false ); } }
871  }
872  }
873  break;
874 
875  //-----------------------------------------------------
876  case PARAMETER_TYPE_Double :
877  case PARAMETER_TYPE_Degree :
878  {
879  double Value;
880 
881  if( Condition.Get_Property("value", Value) )
882  {
883  if( !Type.CmpNoCase("=") || !Type.CmpNoCase("equal" ) ) { if( Value != pOption->asDouble() ) { return( false ); } }
884  else if( !Type.CmpNoCase("!") || !Type.CmpNoCase("not_equal") ) { if( Value == pOption->asDouble() ) { return( false ); } }
885  else if( !Type.CmpNoCase("<") || !Type.CmpNoCase("less" ) ) { if( Value >= pOption->asDouble() ) { return( false ); } }
886  else if( !Type.CmpNoCase(">") || !Type.CmpNoCase("greater" ) ) { if( Value <= pOption->asDouble() ) { return( false ); } }
887  }
888  }
889  break;
890 
891  //-----------------------------------------------------
892  case PARAMETER_TYPE_String :
893  case PARAMETER_TYPE_Text :
895  {
896  CSG_String Value;
897 
898  Condition.Get_Property("value", Value); // no 'if', bcos empty string would return false !!
899 
900  {
901  if( !Type.CmpNoCase("=") || !Type.CmpNoCase("equal" ) ) { if( Value.Cmp(pOption->asString()) != 0 ) { return( false ); } }
902  else if( !Type.CmpNoCase("!") || !Type.CmpNoCase("not_equal") ) { if( Value.Cmp(pOption->asString()) == 0 ) { return( false ); } }
903  else if( !Type.CmpNoCase("<") || !Type.CmpNoCase("less" ) ) { if( Value.Cmp(pOption->asString()) >= 0 ) { return( false ); } }
904  else if( !Type.CmpNoCase(">") || !Type.CmpNoCase("greater" ) ) { if( Value.Cmp(pOption->asString()) <= 0 ) { return( false ); } }
905  }
906  }
907  break;
908 
909  //-----------------------------------------------------
911  {
912  CSG_String Value;
913 
914  if( Condition.Get_Property("value", Value) )
915  {
916  bool bValid = pOption->asGrid_System()->is_Valid();
917 
918  if( !Type.CmpNoCase("=") || !Type.CmpNoCase("equal" ) ) { return( (IS_TRUE_STRING(Value) ? bValid : !bValid) ); }
919  else if( !Type.CmpNoCase("!") || !Type.CmpNoCase("not_equal") ) { return( (IS_TRUE_STRING(Value) ? !bValid : bValid) ); }
920  }
921  }
922  break;
923 
924  //-----------------------------------------------------
925  default:
926  // nop
927  break;
928  }
929 
930  return( true );
931 }
932 
933 
935 // //
937 
938 //---------------------------------------------------------
939 bool CSG_Tool_Chain::ForEach(const CSG_MetaData &Commands)
940 {
941  for(int i=0; i<Commands.Get_Children_Count(); i++) // add internal target lists, if any..
942  {
943  if( Commands[i].Cmp_Name("output") || Commands[i].Cmp_Name("datalist") )
944  {
945  Data_Add_TempList(Commands[i].Get_Content(), Commands[i].Get_Property("type"));
946  }
947  }
948 
949  //-----------------------------------------------------
950  bool bIgnoreErrors = IS_TRUE_PROPERTY(Commands, "ignore_errors");
951 
952  CSG_String VarName;
953 
954  if( Commands.Get_Property("varname", VarName) )
955  {
956  return( ForEach_Iterator(Commands, VarName, bIgnoreErrors) );
957  }
958 
959  if( Commands.Get_Property("input", VarName) )
960  {
961  return( ForEach_Object (Commands, VarName, bIgnoreErrors)
962  || ForEach_File (Commands, VarName, bIgnoreErrors) );
963  }
964 
965  Error_Set("foreach statement misses iterator or input list definition");
966 
967  return( false );
968 }
969 
970 //---------------------------------------------------------
971 bool CSG_Tool_Chain::ForEach_Iterator(const CSG_MetaData &Commands, const CSG_String &VarName, bool bIgnoreErrors)
972 {
973  CSG_Parameter *pIterator = Parameters(VarName);
974 
975  if( pIterator )
976  {
977  Error_Set("foreach statement iterator variable name is already in use");
978 
979  return( false );
980  }
981 
982  //-----------------------------------------------------
983  CSG_String s;
984 
985  double begin = Commands.Get_Property("begin", s) ? (Parameters(s) ? Parameters[s].asDouble() : s.asDouble()) : 0.;
986  double end = Commands.Get_Property("end" , s) ? (Parameters(s) ? Parameters[s].asDouble() : s.asDouble()) : 0.;
987 
988  if( begin >= end )
989  {
990  Error_Set("foreach iterator statement with invalid range (define begin < end)");
991 
992  return( false );
993  }
994 
995  double step = 1.;
996 
997  if( Commands.Get_Property("steps", s) )
998  {
999  double steps = Parameters(s) ? Parameters[s].asDouble() : s.asDouble();
1000 
1001  if( steps > 0 )
1002  {
1003  step = (end - begin) / steps;
1004  }
1005  }
1006  else if( Commands.Get_Property("step", s) )
1007  {
1008  step = Parameters(s) ? Parameters[s].asDouble() : s.asDouble();
1009  }
1010 
1011  if( step <= 0. )
1012  {
1013  Error_Set("foreach iterator statement with invalid step size (define step > 0 or steps > 0)");
1014 
1015  return( false );
1016  }
1017 
1018  Message_Fmt("\nfor i = %f to %f step %f (%d steps)", begin, end, step, (int)((end - begin) / step));
1019 
1020  //-----------------------------------------------------
1021  bool bResult = true;
1022 
1023  pIterator = Parameters.Add_Double("", VarName, "Iterator", "");
1024 
1025  for(double i=begin; bResult && i<=end; i+=step)
1026  {
1027  Message_Fmt("\nfor step: %f", i);
1028 
1029  pIterator->Set_Value(i);
1030 
1031  for(int iTool=0; bResult && iTool<Commands.Get_Children_Count(); iTool++)
1032  {
1033  const CSG_MetaData &Tool = Commands[iTool];
1034 
1035  if( Tool.Cmp_Name("tool") )
1036  {
1037  bResult = Tool_Run(Tool, bIgnoreErrors);
1038 
1039  if( !bResult && bIgnoreErrors )
1040  {
1041  bResult = true;
1042  }
1043  }
1044  }
1045  }
1046 
1047  Parameters.Del_Parameter(VarName);
1048 
1049  return( bResult );
1050 }
1051 
1052 //---------------------------------------------------------
1053 bool CSG_Tool_Chain::ForEach_Object(const CSG_MetaData &Commands, const CSG_String &ListVarName, bool bIgnoreErrors)
1054 {
1055  CSG_Parameter *pList = m_Data(ListVarName);
1056 
1057  if( !pList )
1058  {
1059  return( false );
1060  }
1061 
1062  //-----------------------------------------------------
1063  bool bResult = true;
1064 
1065  if( pList->is_DataObject_List() )
1066  {
1067  for(int iObject=0; bResult && iObject<Get_List_Count(pList->asList()); iObject++)
1068  {
1069  for(int iTool=0; bResult && iTool<Commands.Get_Children_Count(); iTool++)
1070  {
1071  const CSG_MetaData &Tool = Commands[iTool];
1072 
1073  if( Tool.Cmp_Name("tool") )
1074  {
1075  for(int j=0; j<Tool.Get_Children_Count(); j++)
1076  {
1077  if( Tool[j].Cmp_Name("input") && Tool[j].Get_Content().Find(ListVarName) == 0 )
1078  {
1079  Tool(j)->Set_Content(ListVarName + CSG_String::Format("[%d]", iObject));
1080  }
1081  }
1082  }
1083 
1084  bResult = Tool_Run(Tool, bIgnoreErrors);
1085  }
1086 
1087  if( !bResult && bIgnoreErrors )
1088  {
1089  bResult = true;
1090  }
1091  }
1092  }
1093 
1094  //-----------------------------------------------------
1095  else if( pList->Get_Type() == PARAMETER_TYPE_Grids )
1096  {
1097  for(int iObject=0; bResult && iObject<pList->asGrids()->Get_Grid_Count(); iObject++)
1098  {
1099  for(int iTool=0; bResult && iTool<Commands.Get_Children_Count(); iTool++)
1100  {
1101  const CSG_MetaData &Tool = Commands[iTool];
1102 
1103  if( Tool.Cmp_Name("tool") )
1104  {
1105  for(int j=0; j<Tool.Get_Children_Count(); j++)
1106  {
1107  if( Tool[j].Cmp_Name("input") && Tool[j].Get_Content().Find(ListVarName) == 0 )
1108  {
1109  Tool(j)->Set_Content(ListVarName + CSG_String::Format("[%d]", iObject));
1110  }
1111  }
1112  }
1113 
1114  bResult = Tool_Run(Tool, bIgnoreErrors);
1115  }
1116 
1117  if( !bResult && bIgnoreErrors )
1118  {
1119  bResult = true;
1120  }
1121  }
1122  }
1123 
1124  return( bResult );
1125 }
1126 
1127 //---------------------------------------------------------
1128 bool CSG_Tool_Chain::ForEach_File(const CSG_MetaData &Commands, const CSG_String &ListVarName, bool bIgnoreErrors)
1129 {
1130  CSG_Parameter *pList = Parameters(ListVarName);
1131 
1132  if( !pList || pList->Get_Type() != PARAMETER_TYPE_FilePath )
1133  {
1134  return( false );
1135  }
1136 
1137  CSG_Strings Files;
1138 
1139  pList->asFilePath()->Get_FilePaths(Files);
1140 
1141  //-----------------------------------------------------
1142  bool bResult = true;
1143 
1144  for(int iFile=0; bResult && iFile<Files.Get_Count(); iFile++)
1145  {
1146  for(int iTool=0; bResult && iTool<Commands.Get_Children_Count(); iTool++)
1147  {
1148  const CSG_MetaData &Tool = Commands[iTool];
1149 
1150  if( Tool.Cmp_Name("tool") )
1151  {
1152  CSG_Array_Int Input;
1153 
1154  for(int j=0; j<Tool.Get_Children_Count(); j++)
1155  {
1156  if( Tool[j].Cmp_Name("option") && Tool[j].Get_Content().Find(ListVarName) == 0 && IS_TRUE_PROPERTY(Tool[j], "varname") )
1157  {
1158  Tool(j)->Set_Content(Files[iFile]);
1159  Tool(j)->Set_Property("varname", "false");
1160 
1161  Input += j;
1162  }
1163  }
1164 
1165  bResult = Tool_Run(Tool, bIgnoreErrors);
1166 
1167  for(size_t i=0; i<Input.Get_uSize(); i++)
1168  {
1169  Tool(Input[i])->Set_Content(ListVarName);
1170  Tool(Input[i])->Set_Property("varname", "true");
1171  }
1172  }
1173  else
1174  {
1175  bResult = Tool_Run(Tool, bIgnoreErrors);
1176  }
1177 
1178  if( !bResult && bIgnoreErrors )
1179  {
1180  bResult = true;
1181  }
1182  }
1183  }
1184 
1185  return( bResult );
1186 }
1187 
1188 
1190 // //
1192 
1193 //---------------------------------------------------------
1194 bool CSG_Tool_Chain::Tool_Run(const CSG_MetaData &Tool, bool bShowError)
1195 {
1196  //-----------------------------------------------------
1197  if( Tool.Cmp_Name("comment") )
1198  {
1199  return( true );
1200  }
1201 
1202  //-----------------------------------------------------
1203  if( Tool.Cmp_Name("datalist") )
1204  {
1205  return( Data_Add_TempList(Tool.Get_Content(), Tool.Get_Property("type")) );
1206  }
1207 
1208  if( Tool.Cmp_Name("delete") )
1209  {
1210  return( Data_Del_Temp(Tool.Get_Content(), IS_TRUE_PROPERTY(Tool, "data")) );
1211  }
1212 
1213  //-----------------------------------------------------
1214  if( Tool.Cmp_Name("condition") )
1215  {
1216  const CSG_MetaData *pTools = (!Check_Condition(Tool, &m_Data) || !Check_Condition(Tool, &Parameters))
1217  ? Tool("else") : (Tool("if") ? Tool("if") : &Tool);
1218 
1219  for(int i=0; pTools && i<pTools->Get_Children_Count(); i++)
1220  {
1221  if( !Tool_Run((*pTools)[i]) )
1222  {
1223  return( false );
1224  }
1225  }
1226 
1227  return( true );
1228  }
1229 
1230  //-----------------------------------------------------
1231  if( Tool.Cmp_Name("foreach") )
1232  {
1233  return( ForEach(Tool) );
1234  }
1235 
1236  //-----------------------------------------------------
1237  if( !Tool.Cmp_Name("tool") )
1238  {
1239  return( true ); // only proceed, if it is tagged as tool...
1240  }
1241 
1242  if( !Tool.Get_Property("library") || !(Tool.Get_Property("tool") || Tool.Get_Property("module")) )
1243  {
1244  if( bShowError ) Error_Set(_TL("invalid tool definition"));
1245 
1246  return( false );
1247  }
1248 
1249  //-----------------------------------------------------
1250  const SG_Char *Name = Tool.Get_Property("tool") ? Tool.Get_Property("tool") : Tool.Get_Property("module");
1251 
1252  CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Create_Tool(Tool.Get_Property("library"), Name,
1253  IS_TRUE_PROPERTY(Tool, "with_gui") // this option allows to run a tool in 'gui-mode', e.g. to popup variogram dialogs for kriging interpolation
1254  );
1255 
1256  if( !pTool )
1257  {
1258  if( bShowError ) Error_Fmt("%s [%s].[%s]", _TL("could not find tool"), Tool.Get_Property("library"), Name);
1259 
1260  return( false );
1261  }
1262 
1263  //-----------------------------------------------------
1264  Process_Set_Text(pTool->Get_Name());
1265 
1266  pTool->Settings_Push(&m_Data_Manager);
1267 
1268  bool bResult = false;
1269 
1270  if( !pTool->On_Before_Execution() )
1271  {
1272  if( bShowError ) Error_Fmt("%s [%s].[%s]", _TL("before tool execution check failed"), pTool->Get_Library().c_str(), pTool->Get_Name().c_str());
1273  }
1274  else if( !Tool_Initialize(Tool, pTool) )
1275  {
1276  if( bShowError ) Error_Fmt("%s [%s].[%s]", _TL("tool initialization failed" ), pTool->Get_Library().c_str(), pTool->Get_Name().c_str());
1277  }
1278  else if( !(bResult = pTool->Execute(m_bAddHistory)) )
1279  {
1280  Message_Fmt ("%s [%s].[%s]", _TL("tool execution failed" ), pTool->Get_Library().c_str(), pTool->Get_Name().c_str());
1281  }
1282 
1283  if( bResult )
1284  {
1285  pTool->On_After_Execution();
1286  }
1287 
1288  Tool_Finalize(Tool, pTool);
1289 
1290  pTool->Settings_Pop();
1291 
1293 
1294  return( bResult );
1295 }
1296 
1297 
1299 // //
1301 
1302 //---------------------------------------------------------
1303 bool CSG_Tool_Chain::Tool_Check_Condition(const CSG_MetaData &Tool)
1304 {
1305  if( Tool("condition") )
1306  {
1307  for(int i=0; i<Tool.Get_Children_Count(); i++) // there might be more than one condition to be checked
1308  {
1309  if( !Check_Condition(Tool[i], &m_Data) )
1310  {
1311  return( false );
1312  }
1313  }
1314  }
1315 
1316  return( true );
1317 }
1318 
1319 
1321 // //
1323 
1324 //---------------------------------------------------------
1325 bool CSG_Tool_Chain::Tool_Get_Parameter(CSG_String ID, CSG_Parameters *pParameters, CSG_Parameter **ppParameter, CSG_Parameter **ppOwner)
1326 {
1327  CSG_Parameter *pParameter = (*pParameters)(ID.BeforeFirst('.'));
1328 
1329  if( pParameter )
1330  {
1331  switch( pParameter->Get_Type() )
1332  {
1333  default:
1334  *ppParameter = pParameter;
1335 
1336  return( true );
1337 
1339  *ppOwner = pParameter;
1340 
1341  return( Tool_Get_Parameter(ID.AfterFirst('.'), pParameter->asParameters(), ppParameter, ppOwner) );
1342 
1343  case PARAMETER_TYPE_Range:
1344  if( !ID.AfterFirst('.').CmpNoCase("min") || !ID.AfterFirst('.').CmpNoCase("minimum") )
1345  {
1346  *ppParameter = pParameter->asRange()->Get_Min_Parameter();
1347  *ppOwner = pParameter;
1348  }
1349  else if( !ID.AfterFirst('.').CmpNoCase("max") || !ID.AfterFirst('.').CmpNoCase("maximum") )
1350  {
1351  *ppParameter = pParameter->asRange()->Get_Max_Parameter();
1352  *ppOwner = pParameter;
1353  }
1354  else
1355  {
1356  *ppParameter = pParameter;
1357  }
1358 
1359  return( true );
1360  }
1361  }
1362 
1363  return( false );
1364 }
1365 
1366 //---------------------------------------------------------
1367 bool CSG_Tool_Chain::Tool_Get_Parameter(const CSG_MetaData &Parameter, CSG_Tool *pTool, CSG_Parameter **ppParameter, CSG_Parameter **ppOwner)
1368 {
1369  CSG_String ID(Parameter.Get_Property("parms"));
1370 
1371  if( !ID.is_Empty() )
1372  {
1373  ID += '.';
1374  }
1375 
1376  ID += Parameter.Get_Property("id");
1377 
1378  //-----------------------------------------------------
1379  CSG_Parameter *pOwner; if( !ppOwner ) { ppOwner = &pOwner; } *ppOwner = NULL;
1380 
1381  CSG_Parameters *pParameters = pTool->Get_Parameters(ID.BeforeFirst('.'));
1382 
1383  if( pParameters )
1384  {
1385  ID = ID.AfterFirst('.');
1386  }
1387  else
1388  {
1389  pParameters = pTool->Get_Parameters();
1390  }
1391 
1392  return( Tool_Get_Parameter(ID, pParameters, ppParameter, ppOwner) );
1393 }
1394 
1395 //---------------------------------------------------------
1396 bool CSG_Tool_Chain::Tool_Initialize(const CSG_MetaData &Tool, CSG_Tool *pTool)
1397 {
1398  //-----------------------------------------------------
1399  for(int i=0; i<Tool.Get_Children_Count(); i++) // check for invalid parameters...
1400  {
1401  const CSG_MetaData &Parameter = Tool[i]; if( Parameter.Cmp_Name("comment") ) { continue; }
1402 
1403  CSG_Parameter *pParameter, *pOwner;
1404 
1405  if( !Tool_Get_Parameter(Parameter, pTool, &pParameter, &pOwner) )
1406  {
1407  Error_Fmt("%s: %s", _TL("parameter not found"), Parameter.Get_Property("id"));
1408 
1409  return( false );
1410  }
1411  }
1412 
1413  //-----------------------------------------------------
1414  if( Tool.Get_Property("grid_system") )
1415  {
1416  CSG_Parameter *pParameter = Parameters(Tool.Get_Property("grid_system"));
1417 
1418  if( pParameter && pParameter->asGrid_System() )
1419  {
1420  if( !pTool->Set_Grid_System(*pParameter->asGrid_System()) )
1421  {
1422  Message_Fmt("\n%s: %s\n", _TL("Warning"), _TL("failed to set tool's grid system"));
1423  }
1424  }
1425  }
1426 
1427  //-----------------------------------------------------
1428  for(int i=0; i<Tool.Get_Children_Count(); i++) // initialize all options first, some might en-/disable mandatory input data
1429  {
1430  const CSG_MetaData &Parameter = Tool[i]; if( !Parameter.Cmp_Name("option") ) { continue; }
1431 
1432  CSG_Parameter *pParameter, *pOwner; Tool_Get_Parameter(Parameter, pTool, &pParameter, &pOwner);
1433 
1434  if( IS_TRUE_PROPERTY(Parameter, "varname")
1435  ? pParameter->Set_Value(Parameters(Parameter.Get_Content()))
1436  : pParameter->Set_Value( Parameter.Get_Content() ) )
1437  {
1438  pParameter->has_Changed(); if( pOwner ) { pOwner->has_Changed(); }
1439  }
1440  }
1441 
1442  //-----------------------------------------------------
1443  for(int i=0; i<Tool.Get_Children_Count(); i++) // set data input first
1444  {
1445  const CSG_MetaData &Parameter = Tool[i]; if( !Parameter.Cmp_Name("input") ) { continue; }
1446 
1447  CSG_Parameter *pParameter, *pOwner; Tool_Get_Parameter(Parameter, pTool, &pParameter, &pOwner);
1448 
1449  int Index;
1450 
1451  if( Parameter.Get_Content().Find('[') < 1 || !Parameter.Get_Content().AfterFirst('[').asInt(Index) )
1452  {
1453  Index = -1;
1454  }
1455 
1456  bool bResult = false;
1457 
1458  CSG_Parameter *pData = m_Data(Index < 0 ? Parameter.Get_Content() : Parameter.Get_Content().BeforeFirst('['));
1459 
1460  if( pData && (pParameter->is_DataObject() || pParameter->is_DataObject_List()) )
1461  {
1462  if( Index >= 0 && (pData->is_DataObject_List() || pData->asGrids()) )
1463  {
1464  CSG_Data_Object *pObject = pData->is_DataObject_List()
1465  ? pData->asList ()->Get_Item (Index)
1466  : pData->asGrids()->Get_Grid_Ptr(Index);
1467 
1468  if( pParameter->is_DataObject() )
1469  {
1470  bResult = pParameter->Set_Value(pObject);
1471  }
1472  if( pParameter->is_DataObject_List() )
1473  {
1474  bResult = pParameter->asList()->Add_Item(pObject);
1475  }
1476  }
1477  else if( pParameter->Get_Type() == pData->Get_Type() )
1478  {
1479  if( pParameter->is_DataObject_List() && pParameter->asList()->Get_Item_Count() > 0 )
1480  {
1481  bResult = true;
1482 
1483  for(int i=0; bResult && i<pData->asList()->Get_Item_Count(); i++)
1484  {
1485  bResult = pParameter->asList()->Add_Item(pData->asList()->Get_Item(i));
1486  }
1487  }
1488  else
1489  {
1490  bResult = pParameter->Assign(pData);
1491  }
1492  }
1493  else if( pParameter->is_DataObject_List() && pData->is_DataObject() )
1494  {
1495  bResult = pParameter->asList()->Add_Item(pData->asDataObject());
1496  }
1497  else if( Parameter_isCompatible(pParameter->Get_Type(), pData->Get_Type()) )
1498  {
1499  bResult = pParameter->Set_Value(pData->asDataObject());
1500  }
1501  }
1502 
1503  if( bResult )
1504  {
1505  pParameter->has_Changed(); if( pOwner ) { pOwner->has_Changed(); }
1506  }
1507  else if( pParameter->is_Enabled() )
1508  {
1509  Error_Fmt("%s: %s", _TL("set input"), Parameter.Get_Property("id"));
1510 
1511  return( false );
1512  }
1513  }
1514 
1515  //-----------------------------------------------------
1516  for(int i=0; i<Tool.Get_Children_Count(); i++) // now set all options
1517  {
1518  const CSG_MetaData &Parameter = Tool[i]; if( !Parameter.Cmp_Name("option") ) { continue; }
1519 
1520  CSG_Parameter *pParameter, *pOwner; Tool_Get_Parameter(Parameter, pTool, &pParameter, &pOwner);
1521 
1522  if( IS_TRUE_PROPERTY(Parameter, "varname") )
1523  { // does option want a value from tool chain parameters and do these provide one ?
1524  switch( pParameter->Get_Type() )
1525  {
1526  default:
1527  pParameter->Set_Value(Parameters(Parameter.Get_Content()));
1528  break;
1529 
1531  if( m_Data(Parameter.Get_Content()) && pParameter->asTable()->Assign_Values(m_Data(Parameter.Get_Content())->asTable()) )
1532  {
1533  pParameter->has_Changed();
1534  }
1535  break;
1536  }
1537  }
1538  else
1539  {
1540  switch( pParameter->Get_Type() )
1541  {
1543  if( Parameter("OPTION") )
1544  {
1545  pParameter->Serialize(*Parameter("OPTION"), false);
1546  }
1547  break;
1548 
1549  default: {
1550  CSG_String Value(Parameter.Get_Content());
1551 
1552  if( Value.Find("$(") >= 0 )
1553  {
1554  for(int j=0; j<Parameters.Get_Count(); j++)
1555  {
1556  CSG_String Var; Var.Printf("$(%s)", Parameters(j)->Get_Identifier());
1557 
1558  if( Value.Find(Var) >= 0 )
1559  {
1560  Value.Replace(Var, Parameters(j)->asString());
1561  }
1562  }
1563  }
1564 
1565  pParameter->Set_Value(Value);
1566 
1567  if( pOwner )
1568  {
1569  pOwner->has_Changed();
1570  }
1571 
1572  break; }
1573  }
1574  }
1575  }
1576 
1577  //-----------------------------------------------------
1578  for(int i=0; i<Tool.Get_Children_Count(); i++) // finally set the data output
1579  {
1580  const CSG_MetaData &Parameter = Tool[i]; if( !Parameter.Cmp_Name("output") ) { continue; }
1581 
1582  CSG_Parameter *pParameter, *pOwner; Tool_Get_Parameter(Parameter, pTool, &pParameter, &pOwner);
1583 
1584  if( !pParameter->Assign(m_Data(Parameter.Get_Content())) )
1585  {
1586  if( pParameter->is_DataObject() )
1587  {
1588  pParameter->Set_Value(DATAOBJECT_CREATE);
1589  }
1590  else if( pParameter->is_DataObject_List() )
1591  {
1592  pParameter->asList()->Del_Items();
1593  }
1594  else if( pParameter->asGrids() )
1595  {
1596  pParameter->asGrids()->Del_Grids();
1597  }
1598  }
1599  }
1600 
1601  //-----------------------------------------------------
1602  return( true );
1603 }
1604 
1605 //---------------------------------------------------------
1606 bool CSG_Tool_Chain::Tool_Finalize(const CSG_MetaData &Tool, CSG_Tool *pTool)
1607 {
1608  for(int i=0; i<Tool.Get_Children_Count(); i++) // add all data objects declared as output to variable list
1609  {
1610  const CSG_MetaData &Parameter = Tool[i];
1611 
1612  if( Parameter.Cmp_Name("output") )
1613  {
1614  CSG_String ID (Parameter.Get_Property("id" ));
1615  CSG_String ID_parms(Parameter.Get_Property("parms"));
1616 
1617  CSG_Parameter *pParameter = pTool->Get_Parameters(ID_parms)
1618  ? (*pTool->Get_Parameters(ID_parms))(ID)
1619  : (*pTool->Get_Parameters( ))(ID);
1620 
1621  if( !pParameter || !Data_Add(Parameter.Get_Content(), pParameter) )
1622  {
1623  return( false );
1624  }
1625  }
1626  }
1627 
1628  //-----------------------------------------------------
1629  for(int i=-1; i<pTool->Get_Parameters_Count(); i++) // save memory: free all data objects that have not been added to variable list
1630  {
1631  CSG_Parameters *pParameters = i < 0 ? pTool->Get_Parameters() : pTool->Get_Parameters(i);
1632 
1633  for(int j=0; j<pParameters->Get_Count(); j++)
1634  {
1635  CSG_Parameter *pParameter = (*pParameters)(j);
1636 
1637  if( pParameter->is_Output() )
1638  {
1639  if( pParameter->is_DataObject() )
1640  {
1641  if( !Data_Exists(pParameter->asDataObject()) )
1642  {
1643  m_Data_Manager.Delete(pParameter->asDataObject());
1644  }
1645  }
1646  else if( pParameter->is_DataObject_List() )
1647  {
1648  for(int k=0; k<Get_List_Count(pParameter); k++)
1649  {
1650  if( !Data_Exists(Get_List_Item(pParameter, k)) )
1651  {
1652  m_Data_Manager.Delete(Get_List_Item(pParameter, k));
1653  }
1654  }
1655  }
1656  }
1657  }
1658  }
1659 
1660  //-----------------------------------------------------
1661  return( true );
1662 }
1663 
1664 
1666 // //
1667 // //
1668 // //
1670 
1671 //---------------------------------------------------------
1672 CSG_String CSG_Tool_Chain::Get_Script(CSG_Tool *pTool, bool bHeader, bool bAllParameters)
1673 {
1674  CSG_MetaData Tool; Tool.Set_Name("tool");
1675 
1676  Tool.Add_Property("library", pTool->Get_Library());
1677  Tool.Add_Property("tool" , pTool->Get_ID ());
1678  Tool.Add_Property("name" , pTool->Get_Name ());
1679 
1680  _Get_Script_Tool(Tool, pTool->Get_Parameters(), bAllParameters, "", bHeader);
1681 
1682  for(int i=0; i<pTool->Get_Parameters_Count(); i++)
1683  {
1684  _Get_Script_Tool(Tool, pTool->Get_Parameters(i), bAllParameters, pTool->Get_Parameters(i)->Get_Identifier() + '.', bHeader);
1685  }
1686 
1687  if( !bHeader )
1688  {
1689  return( Tool.asText(1) );
1690  }
1691 
1692  //-----------------------------------------------------
1694 
1695  _Get_Script_Parameters(Parameters, pTool->Get_Parameters(), "");
1696 
1697  for(int i=0; i<pTool->Get_Parameters_Count(); i++)
1698  {
1699  _Get_Script_Parameters(Parameters, pTool->Get_Parameters(i), pTool->Get_Parameters(i)->Get_Identifier() + '.');
1700  }
1701 
1702  //-----------------------------------------------------
1703  CSG_MetaData Tools; Tools.Set_Name("toolchain");
1704 
1705  Tools.Add_Property("saga-version", SAGA_VERSION);
1706 
1707  Tools.Add_Child("group" );
1708  Tools.Add_Child("identifier" , "define-a-unique-tool-identifier-here");
1709  Tools.Add_Child("name" , pTool->Get_Name() + " [Tool Chain]");
1710  Tools.Add_Child("author" );
1711  Tools.Add_Child("description");
1712  Tools.Add_Child("menu" , pTool->Get_MenuPath(true))->Add_Property("absolute", "true");
1713  Tools.Add_Child("crs_sync" , "true");
1714  Tools.Add_Child("parameters" )->Add_Children(Parameters);
1715  Tools.Add_Child("tools" )->Add_Child(Tool);
1716  Tools ("tools" )->Add_Property("history", "false");
1717 
1718  return( Tools.asText(1) );
1719 }
1720 
1721 //---------------------------------------------------------
1722 bool CSG_Tool_Chain::_Get_Script_Tool(CSG_MetaData &Tool, CSG_Parameters *pParameters, bool bAllParameters, const CSG_String &Prefix, bool bVarNames)
1723 {
1724  for(int iParameter=0; iParameter<pParameters->Get_Count(); iParameter++)
1725  {
1726  CSG_Parameter *pParameter = pParameters->Get_Parameter(iParameter);
1727 
1728  if( !bAllParameters && (!pParameter->is_Enabled(false) || pParameter->is_Information()) )
1729  {
1730  continue;
1731  }
1732 
1733  CSG_MetaData *pChild = NULL;
1734 
1735  switch( pParameter->Get_Type() )
1736  {
1738  _Get_Script_Tool(Tool, pParameter->asParameters(), bAllParameters, Prefix + pParameter->Get_Identifier() + '.', true);
1739  break;
1740 
1741  case PARAMETER_TYPE_Bool :
1742  pChild = Tool.Add_Child("option", pParameter->asBool() ? "true" : "false");
1743  break;
1744 
1745  case PARAMETER_TYPE_Int :
1746  case PARAMETER_TYPE_Double :
1747  case PARAMETER_TYPE_Degree :
1748  case PARAMETER_TYPE_Date :
1749  case PARAMETER_TYPE_Range :
1750  case PARAMETER_TYPE_String :
1751  case PARAMETER_TYPE_Text :
1753  case PARAMETER_TYPE_Choices :
1756  pChild = Tool.Add_Child("option", pParameter->asString());
1757  break;
1758 
1760  case PARAMETER_TYPE_Choice :
1761  pChild = Tool.Add_Child("option", pParameter->asInt());
1762  break;
1763 
1765  pChild = Tool.Add_Child("option");
1766  pParameter->Serialize(*pChild, true);
1767  break;
1768 
1770  if( pParameter->Get_Children_Count() == 0 )
1771  {
1772  pChild = Tool.Add_Child("option", pParameter->asString());
1773  }
1774  break;
1775 
1776  default:
1777  if( pParameter->is_Input() )
1778  {
1779  pChild = Tool.Add_Child("input");
1780  pChild->Set_Content(pParameter->is_Optional() ? "INPUT_OPTIONAL" : "INPUT");
1781  }
1782  else if( pParameter->is_Output() )
1783  {
1784  pChild = Tool.Add_Child("output");
1785  pChild->Set_Content("OUTPUT");
1786  }
1787  break;
1788  }
1789 
1790  if( pChild )
1791  {
1792  pChild->Add_Property("id", Prefix + pParameter->Get_Identifier());
1793 
1794  if( bVarNames )
1795  {
1796  if( pParameter->is_Option() )
1797  {
1798  pChild->Add_Property("varname", "true");
1799  }
1800 
1801  pChild->Set_Content(Prefix + pParameter->Get_Identifier());
1802  }
1803  }
1804  }
1805 
1806  return( true );
1807 }
1808 
1809 //---------------------------------------------------------
1810 bool CSG_Tool_Chain::_Get_Script_Parameters(CSG_MetaData &Parameters, CSG_Parameters *pParameters, const CSG_String &Prefix)
1811 {
1812  for(int i=0; i<pParameters->Get_Count(); i++)
1813  {
1814  CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
1815 
1816  if( pParameter->Get_Type() == PARAMETER_TYPE_Parameters )
1817  {
1818  _Get_Script_Parameters(Parameters, pParameter->asParameters(), Prefix + pParameter->Get_Identifier() + '.');
1819 
1820  continue; // no support for sub-parameter-lists in here
1821  }
1822 
1823  CSG_MetaData &Parameter = *Parameters.Add_Child(
1824  pParameter->is_Option() ? "option" :
1825  pParameter->is_Output() ? "output" : "input"
1826  );
1827 
1828  Parameter.Add_Property("varname" , pParameter->Get_Identifier ());
1829  Parameter.Add_Property("type" , SG_Parameter_Type_Get_Identifier(pParameter->Get_Type()));
1830  Parameter.Add_Child ("name" , pParameter->Get_Name ());
1831  Parameter.Add_Child ("description", pParameter->Get_Description());
1832 
1833  if( pParameter->Get_Parent() )
1834  {
1835  Parameter.Add_Property("parent", pParameter->Get_Parent()->Get_Identifier());
1836  }
1837 
1838  if( pParameter->Get_Type() == PARAMETER_TYPE_Node
1839  || pParameter->Get_Type() == PARAMETER_TYPE_Grid_System )
1840  {
1841  continue; // nothing more to do for these types
1842  }
1843 
1844  if( pParameter->is_Option() )
1845  {
1846  CSG_MetaData &Value = *Parameter.Add_Child("value", pParameter->asString());
1847 
1848  if( pParameter->asValue() )
1849  {
1850  if( pParameter->asValue()->has_Minimum() ) Value.Add_Property("min", pParameter->asValue()->Get_Minimum());
1851  if( pParameter->asValue()->has_Maximum() ) Value.Add_Property("max", pParameter->asValue()->Get_Maximum());
1852  }
1853 
1854  if( pParameter->asChoice () ) Parameter.Add_Child("choices", pParameter->asChoice ()->Get_Items());
1855  if( pParameter->asChoices() ) Parameter.Add_Child("choices", pParameter->asChoices()->Get_Items());
1856 
1857  if( pParameter->asFilePath() )
1858  {
1859  Parameter.Add_Property("save" , pParameter->asFilePath()->is_Save () ? "true" : "false");
1860  Parameter.Add_Property("directory", pParameter->asFilePath()->is_Directory() ? "true" : "false");
1861  Parameter.Add_Property("multiple" , pParameter->asFilePath()->is_Multiple () ? "true" : "false");
1862  Parameter.Add_Child ("filter" , pParameter->asFilePath()->Get_Filter());
1863  }
1864 
1865  if( pParameter->Get_Type() == PARAMETER_TYPE_FixedTable )
1866  {
1867  pParameter->Serialize(Parameter, true);
1868  }
1869 
1870  if( pParameter->Get_Type() == PARAMETER_TYPE_Table_Field )
1871  {
1872  Value.Set_Content(pParameter->is_Optional() ? "true" : "false");
1873  }
1874  }
1875  else // data objects
1876  {
1877  if( pParameter->is_Optional() )
1878  {
1879  Parameter.Add_Property("optional", "true");
1880  }
1881 
1882  if( pParameter->Get_Type() == PARAMETER_TYPE_DataObject_Output )
1883  {
1884  switch( ((CSG_Parameter_Data_Object_Output *)pParameter)->Get_DataObject_Type() )
1885  {
1888  Parameter.Add_Property("target", "none");
1889  break;
1890 
1893  Parameter.Add_Property("target", "none");
1894  break;
1895 
1896  default:
1897  break;
1898  }
1899  }
1900 
1901  if( pParameter->Get_Type() == PARAMETER_TYPE_Shapes )
1902  {
1903  switch( ((CSG_Parameter_Shapes *)pParameter)->Get_Shape_Type() )
1904  {
1905  case SHAPE_TYPE_Point : Parameter.Add_Property("feature_type", "point" ); break;
1906  case SHAPE_TYPE_Points : Parameter.Add_Property("feature_type", "points" ); break;
1907  case SHAPE_TYPE_Line : Parameter.Add_Property("feature_type", "line" ); break;
1908  case SHAPE_TYPE_Polygon: Parameter.Add_Property("feature_type", "polygon"); break;
1909  default: break;
1910  }
1911  }
1912 
1913  if( pParameter->Get_Type() == PARAMETER_TYPE_Grid_List
1914  && !((CSG_Parameter_Grid_List *)pParameter)->Get_System() )
1915  {
1916  Parameter.Add_Property("no_system", "true");
1917  }
1918 
1919  if( pParameter->Get_Type() == PARAMETER_TYPE_Grids_List
1920  && !((CSG_Parameter_Grid_List *)pParameter)->Get_System() )
1921  {
1922  Parameter.Add_Property("no_system", "true");
1923  }
1924  }
1925  }
1926 
1927  return( true );
1928 }
1929 
1930 
1932 // //
1933 // //
1934 // //
1936 
1937 //---------------------------------------------------------
1938 CSG_Tool_Chains::CSG_Tool_Chains(const CSG_String &Library_Name, const CSG_String &Path)
1939 {
1940  m_Library_Name = Library_Name;
1941 
1942  //-----------------------------------------------------
1943  if( m_Library_Name.is_Empty() || !m_Library_Name.Cmp("toolchains") )
1944  {
1945  m_Library_Name = "_tool_chains_uncategorized";
1946  m_Name = _TL("Uncategorized Tool Chains");
1947  m_Description = _TL("Uncategorized Tool Chains");
1948  m_Menu = _TL("Uncategorized Tool Chains");
1949  }
1950 
1951  //-----------------------------------------------------
1952  else
1953  {
1954  CSG_MetaData XML(SG_File_Make_Path(Path, Library_Name, "xml"));
1955 
1956  if( !XML.Cmp_Name("toolchains") )
1957  {
1958  XML.Destroy();
1959  }
1960 
1961  m_Name = GET_XML_CONTENT(XML, "name" , m_Library_Name , true);
1962  m_Description = GET_XML_CONTENT(XML, "description", _TL("no description"), true);
1963  m_Menu = GET_XML_CONTENT(XML, "menu" , _TL("Tool Chains" ), true);
1964 
1965  m_Description.Replace("[[", "<"); // support for xml/html tags
1966  m_Description.Replace("]]", ">");
1967 
1968  // add references...
1969  for(int i=0; i<XML.Get_Children_Count(); i++)
1970  {
1971  if( !XML[i].Get_Name().CmpNoCase("REFERENCE") )
1972  {
1973  CSG_String Authors, Year, Title, Where, Link, Link_Text, DOI;
1974 
1975  if( XML[i]("AUTHORS" ) ) Authors = XML[i].Get_Content("AUTHORS" );
1976  if( XML[i]("YEAR" ) ) Year = XML[i].Get_Content("YEAR" );
1977  if( XML[i]("TITLE" ) ) Title = XML[i].Get_Content("TITLE" );
1978  if( XML[i]("WHERE" ) ) Where = XML[i].Get_Content("WHERE" );
1979  if( XML[i]("LINK" ) ) Link = XML[i].Get_Content("LINK" );
1980  if( XML[i]("LINK_TEXT") ) Link_Text = XML[i].Get_Content("LINK_TEXT");
1981  if( XML[i]("DOI" ) ) DOI = XML[i].Get_Content("DOI" );
1982 
1983  if( !DOI.is_Empty() )
1984  {
1985  Link = "https://doi.org/" + DOI; Link_Text = "doi:" + DOI;
1986  }
1987 
1988  if( !Authors.is_Empty() && !Year.is_Empty() && !Title.is_Empty() )
1989  {
1990  Add_Reference(Authors, Year, Title, Where, Link.c_str(), Link_Text.c_str());
1991  }
1992  else if( !Link.is_Empty() )
1993  {
1994  Add_Reference(Link, Link_Text.c_str());
1995  }
1996  }
1997  }
1998  }
1999 }
2000 
2001 //---------------------------------------------------------
2003 {
2004  Delete_Tools();
2005 
2006  for(size_t i=0; i<m_Tools.Get_uSize(); i++)
2007  {
2008  delete((CSG_Tool_Chain *)m_Tools[i]);
2009  }
2010 }
2011 
2012 
2014 // //
2016 
2017 //---------------------------------------------------------
2018 CSG_String CSG_Tool_Chains::Get_Info(int Type) const
2019 {
2020  switch( Type )
2021  {
2022  case TLB_INFO_Name : return( m_Name );
2023  case TLB_INFO_Description: return( m_Description );
2024  case TLB_INFO_Menu_Path : return( m_Menu );
2025  case TLB_INFO_Category : return( _TL("Tool Chains") );
2026  }
2027 
2028  return( "" );
2029 }
2030 
2031 //---------------------------------------------------------
2033 {
2034  m_Tools.Add(pTool);
2035 
2037 
2038  return( true );
2039 }
2040 
2041 //---------------------------------------------------------
2042 CSG_Tool * CSG_Tool_Chains::Get_Tool(int Index, TSG_Tool_Type Type) const
2043 {
2044  CSG_Tool *pTool = Index >= 0 && Index < Get_Count() ? (CSG_Tool_Chain *)m_Tools[Index] : NULL;
2045 
2046  return( pTool && (Type == TOOL_TYPE_Base || Type == pTool->Get_Type()) ? pTool : NULL );
2047 }
2048 
2049 
2051 // //
2053 
2054 //---------------------------------------------------------
2055 CSG_Tool * CSG_Tool_Chains::Create_Tool(const CSG_String &Name, bool bWithGUI)
2056 {
2057  CSG_Tool *pTool = CSG_Tool_Library::Get_Tool(Name);
2058 
2059  if( pTool && pTool->Get_Type() == TOOL_TYPE_Chain )
2060  {
2061  m_xTools.Add(pTool = new CSG_Tool_Chain(*((CSG_Tool_Chain *)pTool), bWithGUI));
2062 
2063  return( pTool );
2064  }
2065 
2066  return( NULL );
2067 }
2068 
2069 //---------------------------------------------------------
2071 {
2072  if( m_xTools.Del(pTool) || m_Tools.Del(pTool) )
2073  {
2074  delete((CSG_Tool_Chain *)pTool);
2075 
2076  return( true );
2077  }
2078 
2079  return( false );
2080 }
2081 
2082 //---------------------------------------------------------
2084 {
2085  for(size_t i=0; i<m_xTools.Get_uSize(); i++)
2086  {
2087  delete((CSG_Tool_Chain *)m_xTools[i]);
2088  }
2089 
2090  m_xTools.Destroy();
2091 
2092  return( true );
2093 }
2094 
2095 
2097 // //
2098 // //
2099 // //
2101 
2102 //---------------------------------------------------------
2103 bool CSG_Tool_Chain::Save_History_to_Model(const CSG_MetaData &History, const CSG_String &File)
2104 {
2105  if( SG_Compare_Version(History.Get_Property("saga-version"), "2.1.3") < 0 || !(History("TOOL") || History("MODULE")) )
2106  {
2107  return( false );
2108  }
2109 
2110  const CSG_MetaData &Tool(History("TOOL") ? History["TOOL"] : History["MODULE"]);
2111 
2112  if( !Tool("OUTPUT") )
2113  {
2114  return( false );
2115  }
2116 
2117  //-----------------------------------------------------
2118  CSG_MetaData Chain;
2119 
2120  Chain.Set_Name ("toolchain" );
2121  Chain.Add_Property("saga-version", SAGA_VERSION);
2122 
2123  Chain.Add_Child ("group" , "toolchains");
2124  Chain.Add_Child ("identifier" , SG_File_Get_Name(File, false));
2125  Chain.Add_Child ("name" , SG_File_Get_Name(File, false));
2126  Chain.Add_Child ("description", _TL("created from history"));
2127 
2128  Chain.Add_Child ("parameters" );
2129  Chain.Add_Child ("tools" );
2130 
2131  _Save_History_Add_Tool(Tool, *Chain("parameters"), *Chain("tools"), true);
2132 
2133  for(int i=0; i<Chain["tools"].Get_Children_Count(); i++)
2134  {
2135  Chain["tools"](i)->Del_Property("id");
2136  }
2137 
2138  return( Chain.Save(File) );
2139 }
2140 
2141 //---------------------------------------------------------
2142 bool CSG_Tool_Chain::_Save_History_Add_Tool(const CSG_MetaData &History, CSG_MetaData &Parms, CSG_MetaData &Tools, bool bAddOutput)
2143 {
2144  if( !History("OUTPUT") || !History["OUTPUT"].Get_Property("id") )
2145  {
2146  return( false );
2147  }
2148 
2149  //-----------------------------------------------------
2150  CSG_MetaData *pParameter, &Tool = *Tools.Ins_Child("tool", 0);
2151 
2152  CSG_String Tool_ID(CSG_String::Format("tool_%02d", Tools.Get_Children_Count()));
2153 
2154  Tool.Add_Property("id" , Tool_ID);
2155  Tool.Add_Property("library", History.Get_Property("library"));
2156  Tool.Add_Property("tool" , History.Get_Property("id" ));
2157  Tool.Add_Property("name" , History.Get_Property("name" ));
2158 
2159  //-----------------------------------------------------
2160  const CSG_MetaData &Output = History["OUTPUT"];
2161 
2162  CSG_String VarName = CSG_String::Format("%s__%s", Tool_ID.c_str(), Output.Get_Property("id"));
2163 
2164  pParameter = Tool.Add_Child("output", VarName);
2165  pParameter->Add_Property("parms", Output.Get_Property("parms"));
2166  pParameter->Add_Property("id" , Output.Get_Property("id" ));
2167 
2168  if( bAddOutput )
2169  {
2170  pParameter = Parms.Add_Child("output");
2171 
2172  pParameter->Add_Property("varname" , VarName);
2173  pParameter->Add_Property("type" , Output.Get_Property("type"));
2174  pParameter->Add_Child ("name" , Output.Get_Property("name"));
2175  // pParameter->Add_Child ("description", Output.Get_Property("name"));
2176  }
2177 
2178  //-----------------------------------------------------
2179  for(int i=0; i<History.Get_Children_Count(); i++) // Options and Input
2180  {
2181  CSG_MetaData *pChild = History.Get_Child(i);
2182 
2183  if( !pChild->Get_Name().Cmp("OPTION") )
2184  {
2185  pParameter = NULL;
2186 
2187  switch( SG_Parameter_Type_Get_Type(pChild->Get_Property("type")) )
2188  {
2189  case PARAMETER_TYPE_Bool :
2190  case PARAMETER_TYPE_Int :
2191  case PARAMETER_TYPE_Double :
2192  case PARAMETER_TYPE_Degree :
2193  case PARAMETER_TYPE_Date :
2194  case PARAMETER_TYPE_Range :
2195  case PARAMETER_TYPE_String :
2196  case PARAMETER_TYPE_Text :
2200  case PARAMETER_TYPE_Choices :
2201  pParameter = Tool.Add_Child("option", pChild->Get_Content());
2202  break;
2203 
2205  case PARAMETER_TYPE_Choice :
2206  pParameter = Tool.Add_Child("option", pChild->Get_Property("index"));
2207  break;
2208 
2210  if( pChild->Get_Children_Count() == 0 )
2211  {
2212  pParameter = Tool.Add_Child("option", pChild->Get_Content());
2213  }
2214  break;
2215 
2216  default: break;
2217  }
2218 
2219  if( pParameter )
2220  {
2221  pParameter->Add_Property("parms", pChild->Get_Property("parms"));
2222  pParameter->Add_Property("id" , pChild->Get_Property("id" ));
2223  }
2224  }
2225  else if( !pChild->Get_Name().Cmp("INPUT") )
2226  {
2227  _Save_History_Add_Input(*pChild, Parms, Tool);
2228  }
2229  else if( !pChild->Get_Name().Cmp("INPUT_LIST") )
2230  {
2231  for(int j=0; j<pChild->Get_Children_Count(); j++)
2232  {
2233  _Save_History_Add_Input(*pChild->Get_Child(j), Parms, Tool);
2234  }
2235  }
2236  }
2237 
2238  return( true );
2239 }
2240 
2241 //---------------------------------------------------------
2242 bool CSG_Tool_Chain::_Save_History_Add_Input(const CSG_MetaData &History, CSG_MetaData &Parms, CSG_MetaData &Tool)
2243 {
2244  CSG_MetaData *pInput = Tool.Add_Child("input");
2245 
2246  pInput->Add_Property("parms", History.Get_Property("parms"));
2247  pInput->Add_Property("id" , History.Get_Property("id" ));
2248 
2249  if( History("TOOL") || History("MODULE") )
2250  {
2251  const CSG_MetaData &History_Tool(History("TOOL") ? History["TOOL"] : History["MODULE"]);
2252 
2253  if( History_Tool("OUTPUT") && History_Tool["OUTPUT"].Get_Property("id") )
2254  {
2255  pInput->Fmt_Content("tool_%02d__%s", Tool.Get_Parent()->Get_Children_Count() + 1, History_Tool["OUTPUT"].Get_Property("id"));
2256 
2257  return( _Save_History_Add_Tool(History_Tool, Parms, *Tool.Get_Parent()) );
2258  }
2259  }
2260 
2261  CSG_String VarName = CSG_String::Format("%s__%s", Tool.Get_Property("id"), History.Get_Property("id"));
2262 
2263  pInput->Set_Content(VarName);
2264 
2265  CSG_MetaData *pParameter = Parms.Ins_Child("input", 0);
2266 
2267  pParameter->Add_Property("varname" , VarName);
2268  pParameter->Add_Property("type" , History.Get_Property("type"));
2269  pParameter->Add_Child ("name" , History.Get_Property("name"));
2270 // pParameter->Add_Child ("description", History.Get_Property("name"));
2271 
2272  return( true );
2273 }
2274 
2275 
2277 // //
2278 // //
2279 // //
2281 
2282 //---------------------------------------------------------
CSG_String::BeforeFirst
CSG_String BeforeFirst(char Character) const
Definition: api_string.cpp:666
CSG_MetaData::Destroy
void Destroy(void)
Definition: metadata.cpp:148
CSG_Parameter::Set_Value
virtual bool Set_Value(int Value)
Definition: parameter.cpp:745
PARAMETER_TYPE_Double
@ PARAMETER_TYPE_Double
Definition: parameters.h:127
CSG_Parameter_File_Name::Get_Filter
const SG_Char * Get_Filter(void) const
Definition: parameter_data.cpp:1553
CSG_Tool_Chains::Add_Tool
bool Add_Tool(CSG_Tool_Chain *pTool)
CSG_Parameters::Get_Parameter
CSG_Parameter * Get_Parameter(int i) const
Definition: parameters.h:1708
PARAMETER_TYPE_FilePath
@ PARAMETER_TYPE_FilePath
Definition: parameters.h:136
PARAMETER_TYPE_Degree
@ PARAMETER_TYPE_Degree
Definition: parameters.h:128
CSG_Tool::Parameters
CSG_Parameters Parameters
Definition: tool.h:251
CSG_Parameter_File_Name::Get_FilePaths
bool Get_FilePaths(CSG_Strings &FilePaths) const
Definition: parameter_data.cpp:1575
CSG_Parameters::Del_References
void Del_References(void)
Definition: parameters.cpp:326
SG_T
#define SG_T(s)
Definition: api_core.h:531
CSG_Parameters::Add_Date
CSG_Parameter * Add_Date(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0)
Definition: parameters.cpp:416
CSG_String::Printf
int Printf(const char *Format,...)
Definition: api_string.cpp:308
CSG_Parameters::Add_Grid_System
CSG_Parameter * Add_Grid_System(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Grid_System *pInit=NULL)
Definition: parameters.cpp:567
CSG_Tool_Chain::Get_Script
static CSG_String Get_Script(CSG_Tool *pTool, bool bHeader, bool bAllParameters=true)
CSG_Parameters::Add_Degree
CSG_Parameter * Add_Degree(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
Definition: parameters.cpp:411
TOOL_TYPE_Chain
@ TOOL_TYPE_Chain
Definition: tool.h:106
_TL
#define _TL(s)
Definition: api_core.h:1480
CSG_String::Make_Lower
CSG_String & Make_Lower(void)
Definition: api_string.cpp:543
CSG_Parameter_List::Add_Item
virtual bool Add_Item(CSG_Data_Object *pItem)
Definition: parameter_data.cpp:3013
SAGA_VERSION
#define SAGA_VERSION
Definition: saga_api.h:90
PARAMETER_TYPE_Table_Fields
@ PARAMETER_TYPE_Table_Fields
Definition: parameters.h:145
CSG_String::Length
size_t Length(void) const
Definition: api_string.cpp:172
CSG_Tool_Chain::CSG_Tool_Chain
CSG_Tool_Chain(void)
Definition: tool_chain.cpp:79
CSG_Parameters::Add_Colors
CSG_Parameter * Add_Colors(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Colors *pInit=NULL)
Definition: parameters.cpp:536
CSG_Tool_Chains::CSG_Tool_Chains
CSG_Tool_Chains(const CSG_String &Library_Name, const CSG_String &Path)
CSG_MetaData::Get_Children_Count
int Get_Children_Count(void) const
Definition: metadata.h:149
CSG_Parameter::Get_Identifier
const SG_Char * Get_Identifier(void) const
Definition: parameter.cpp:546
CSG_Parameter::asInt
int asInt(void) const
Definition: parameters.h:281
PARAMETER_TYPE_Node
@ PARAMETER_TYPE_Node
Definition: parameters.h:123
CSG_Tool::On_After_Execution
virtual bool On_After_Execution(void)
Definition: tool.h:240
CSG_Parameter::asString
const SG_Char * asString(void) const
Definition: parameters.h:284
CSG_Parameter::asTable
CSG_Table * asTable(void) const
Definition: parameter.cpp:994
CSG_MetaData::Get_Content
const CSG_String & Get_Content(void) const
Definition: metadata.h:135
A
#define A
CSG_MetaData::Set_Content
void Set_Content(const CSG_String &Content)
Definition: metadata.h:142
CSG_Parameter_Value::Get_Maximum
double Get_Maximum(void) const
Definition: parameters.h:444
CSG_Tool_Chains::Get_Info
virtual CSG_String Get_Info(int Type) const
CSG_Parameters::Del_Parameters
bool Del_Parameters(void)
Definition: parameters.cpp:1255
CSG_Parameter_Value::has_Minimum
bool has_Minimum(void) const
Definition: parameters.h:441
CSG_Tool_Chain::do_Sync_Projections
virtual bool do_Sync_Projections(void) const
SG_UI_MSG_STYLE_SUCCESS
@ SG_UI_MSG_STYLE_SUCCESS
Definition: api_core.h:1496
PARAMETER_TYPE_Grids_List
@ PARAMETER_TYPE_Grids_List
Definition: parameters.h:155
PARAMETER_TYPE_String
@ PARAMETER_TYPE_String
Definition: parameters.h:134
CSG_String::asInt
int asInt(void) const
Definition: api_string.cpp:722
PARAMETER_TYPE_Int
@ PARAMETER_TYPE_Int
Definition: parameters.h:126
CSG_Parameter_List::Get_Item
CSG_Data_Object * Get_Item(int Index) const
Definition: parameters.h:1368
CSG_Tool_Chain::On_Parameters_Enable
virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
CSG_Parameters::Add_Node
CSG_Parameter * Add_Node(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
Definition: parameters.cpp:371
SHAPE_TYPE_Polygon
@ SHAPE_TYPE_Polygon
Definition: shapes.h:105
CSG_MetaData::Set_Property
bool Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists=true)
Definition: metadata.cpp:600
CSG_Parameter::is_Input
bool is_Input(void) const
Definition: parameters.h:231
tool_chain.h
CSG_Tool_Library::Get_Name
CSG_String Get_Name(void) const
Definition: tool_library.h:120
TLB_INFO_Category
@ TLB_INFO_Category
Definition: tool.h:620
saga_api.h
PARAMETER_TYPE_TIN
@ PARAMETER_TYPE_TIN
Definition: parameters.h:152
CSG_Parameters::Add_Grids_List
CSG_Parameter * Add_Grids_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true)
Definition: parameters.cpp:698
CSG_Parameter_Data_Object_Output
Definition: parameters.h:1165
CSG_Tool
Definition: tool.h:149
SG_Translate
SAGA_API_DLL_EXPORT const SG_Char * SG_Translate(const CSG_String &Text)
Definition: api_translator.cpp:93
CSG_Parameters::Add_String
CSG_Parameter * Add_String(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &String, bool bLongText=false, bool bPassword=false)
Definition: parameters.cpp:489
CSG_Data_Object::Get_Name
const SG_Char * Get_Name(void) const
Definition: dataobject.cpp:290
CSG_Tool::Execute
bool Execute(bool bAddHistory=false)
Definition: tool.cpp:246
CSG_Parameter::Get_Description
const SG_Char * Get_Description(void) const
Definition: parameter.cpp:578
CSG_Parameters::Add_Double
CSG_Parameter * Add_Double(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
Definition: parameters.cpp:406
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:184
SG_DATAOBJECT_TYPE_Grids
@ SG_DATAOBJECT_TYPE_Grids
Definition: dataobject.h:119
CSG_Tool::Error_Set
bool Error_Set(TSG_Tool_Error Error_ID=TOOL_ERROR_Unknown)
Definition: tool.cpp:709
PARAMETER_TYPE_FixedTable
@ PARAMETER_TYPE_FixedTable
Definition: parameters.h:141
CSG_Tool::Get_Name
const CSG_String & Get_Name(void) const
Definition: tool.cpp:145
CSG_Parameter::asDataObject
CSG_Data_Object * asDataObject(void) const
Definition: parameter.cpp:972
CSG_Parameter::Assign
bool Assign(CSG_Parameter *pSource)
Definition: parameter.cpp:1072
CSG_Parameter_File_Name::is_Directory
bool is_Directory(void) const
Definition: parameters.h:868
CSG_MetaData::Save
bool Save(const CSG_String &File, const SG_Char *Extension=NULL) const
Definition: metadata.cpp:883
TSG_Tool_Type
TSG_Tool_Type
Definition: tool.h:101
CSG_MetaData::Get_Child
CSG_MetaData * Get_Child(int Index) const
Definition: metadata.h:150
TLB_INFO_Name
@ TLB_INFO_Name
Definition: tool.h:615
CSG_MetaData::Get_Name
const CSG_String & Get_Name(void) const
Definition: metadata.h:132
PARAMETER_TYPE_PointCloud
@ PARAMETER_TYPE_PointCloud
Definition: parameters.h:147
CSG_String::Prepend
CSG_String & Prepend(const CSG_String &String)
Definition: api_string.cpp:347
CSG_Parameter_File_Name::is_Save
bool is_Save(void) const
Definition: parameters.h:862
CSG_Parameter::asValue
class CSG_Parameter_Value * asValue(void) const
Definition: parameter.cpp:1022
CSG_String::Replace
size_t Replace(const CSG_String &sOld, const CSG_String &sNew, bool bReplaceAll=true)
Definition: api_string.cpp:563
CSG_Tool_Library_Manager::Delete_Tool
bool Delete_Tool(CSG_Tool *pTool) const
Definition: tool_library.cpp:726
CSG_Tool::Set_Author
void Set_Author(const CSG_String &String)
Definition: tool.cpp:151
CSG_Tool_Chain::Get_Type
virtual TSG_Tool_Type Get_Type(void) const
Definition: tool_chain.h:92
CSG_String::Cmp
int Cmp(const CSG_String &String) const
Definition: api_string.cpp:515
CSG_Parameter_File_Name::is_Multiple
bool is_Multiple(void) const
Definition: parameters.h:865
CSG_Parameters::Add_PointCloud
CSG_Parameter * Add_PointCloud(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition: parameters.cpp:886
PARAMETER_INPUT_OPTIONAL
#define PARAMETER_INPUT_OPTIONAL
Definition: parameters.h:102
PARAMETER_TYPE_Shapes_List
@ PARAMETER_TYPE_Shapes_List
Definition: parameters.h:157
PARAMETER_TYPE_Grids
@ PARAMETER_TYPE_Grids
Definition: parameters.h:149
CSG_MetaData::Get_Property
const SG_Char * Get_Property(int i) const
Definition: metadata.h:181
Get_List_Count
#define Get_List_Count(p)
Definition: tool_chain.cpp:68
CSG_Parameter::Get_Type
virtual TSG_Parameter_Type Get_Type(void) const =0
CSG_Parameter::Serialize
bool Serialize(CSG_MetaData &MetaData, bool bSave)
Definition: parameter.cpp:1096
CSG_Parameters::Add_Range
CSG_Parameter * Add_Range(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Range_Min=0.0, double Range_Max=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
Definition: parameters.cpp:432
CSG_Tool_Chain::On_Execute
virtual bool On_Execute(void)
SG_UI_MSG_STYLE_FAILURE
@ SG_UI_MSG_STYLE_FAILURE
Definition: api_core.h:1497
SG_File_Get_Name
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Name(const CSG_String &full_Path, bool bExtension)
Definition: api_file.cpp:862
CSG_Parameter::is_DataObject_List
bool is_DataObject_List(void) const
Definition: parameter.cpp:294
PARAMETER_TYPE_Choices
@ PARAMETER_TYPE_Choices
Definition: parameters.h:133
TLB_INFO_Description
@ TLB_INFO_Description
Definition: tool.h:616
PARAMETER_TYPE_Data_Type
@ PARAMETER_TYPE_Data_Type
Definition: parameters.h:131
CSG_Parameter_Shapes
Definition: parameters.h:1278
CSG_Parameter_List::Del_Items
virtual bool Del_Items(void)
Definition: parameter_data.cpp:3055
CSG_Tool_Chains::Delete_Tools
virtual bool Delete_Tools(void)
CSG_MetaData::Cmp_Name
bool Cmp_Name(const CSG_String &String, bool bNoCase=true) const
Definition: metadata.cpp:437
PARAMETER_TYPE_Colors
@ PARAMETER_TYPE_Colors
Definition: parameters.h:140
CSG_Parameters::Add_TIN_List
CSG_Parameter * Add_TIN_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition: parameters.cpp:871
CSG_MetaData::Ins_Child
CSG_MetaData * Ins_Child(int Position)
Definition: metadata.cpp:215
CSG_Data_Object
Definition: dataobject.h:180
CSG_Parameter
Definition: parameters.h:207
CSG_Array_Pointer::Del
bool Del(sLong Index)
Definition: api_memory.cpp:512
CSG_Parameters::Add_FixedTable
CSG_Parameter * Add_FixedTable(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Table *pInit=NULL)
Definition: parameters.cpp:548
PARAMETER_TYPE_Table
@ PARAMETER_TYPE_Table
Definition: parameters.h:150
PARAMETER_TYPE_Bool
@ PARAMETER_TYPE_Bool
Definition: parameters.h:125
CSG_Data_Manager::Delete_All
bool Delete_All(bool bDetach=false)
Definition: data_manager.cpp:782
CSG_Tool_Chains::Create_Tool
virtual CSG_Tool * Create_Tool(const CSG_String &Name, bool bWithGUI=false)
CSG_Parameters::Get_Count
int Get_Count(void) const
Definition: parameters.h:1681
DATAOBJECT_CREATE
#define DATAOBJECT_CREATE
Definition: dataobject.h:130
CSG_Tool::Get_Parameters
CSG_Parameters * Get_Parameters(void)
Definition: tool.h:179
PARAMETER_TYPE_Table_Field
@ PARAMETER_TYPE_Table_Field
Definition: parameters.h:144
CSG_Array_Pointer::Get_uSize
size_t Get_uSize(void) const
Definition: api_core.h:382
CSG_Parameters::Add_FilePath
CSG_Parameter * Add_FilePath(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const SG_Char *Filter=NULL, const SG_Char *Default=NULL, bool bSave=false, bool bDirectory=false, bool bMultiple=false)
Definition: parameters.cpp:500
CSG_Parameter::is_Enabled
bool is_Enabled(bool bCheckEnv=true) const
Definition: parameter.cpp:208
CSG_Tool_Chain::Set_Library_Menu
void Set_Library_Menu(const CSG_String &Menu)
Definition: tool_chain.cpp:122
PARAMETER_TYPE_Choice
@ PARAMETER_TYPE_Choice
Definition: parameters.h:132
CSG_Tool_Library_Manager::Create_Tool
CSG_Tool * Create_Tool(const CSG_String &Library, int Index, bool bWithGUI=false) const
Definition: tool_library.cpp:697
SG_Parameter_Type_Get_Identifier
CSG_String SG_Parameter_Type_Get_Identifier(TSG_Parameter_Type Type)
Definition: parameter_data.cpp:114
CSG_Parameters::Add_Shapes_List
CSG_Parameter * Add_Shapes_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, TSG_Shape_Type=SHAPE_TYPE_Undefined)
Definition: parameters.cpp:832
CSG_Parameter::asParameters
class CSG_Parameters * asParameters(void) const
Definition: parameter.cpp:969
CSG_Parameters::Add_Grid_List
CSG_Parameter * Add_Grid_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true)
Definition: parameters.cpp:632
CSG_Tool::Get_MenuPath
virtual CSG_String Get_MenuPath(void)
Definition: tool.h:175
CSG_Data_Manager::Delete
bool Delete(CSG_Data_Collection *pCollection, bool bDetach=false)
Definition: data_manager.cpp:686
CSG_Tool::Get_Library
const CSG_String & Get_Library(void) const
Definition: tool.cpp:128
SG_Get_Tool_Library_Manager
CSG_Tool_Library_Manager & SG_Get_Tool_Library_Manager(void)
Definition: tool_library.cpp:286
CSG_Tool_Chain::Create
bool Create(const CSG_Tool_Chain &Tool, bool bWithGUI)
Definition: tool_chain.cpp:133
CSG_MetaData::Add_Property
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition: metadata.cpp:544
CSG_Parameters::Add_Color
CSG_Parameter * Add_Color(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value=0)
Definition: parameters.cpp:426
SG_Parameter_Type_Get_Type
TSG_Parameter_Type SG_Parameter_Type_Get_Type(const CSG_String &Identifier)
Definition: parameter_data.cpp:164
CSG_Grids::Get_Grid_Ptr
CSG_Grid * Get_Grid_Ptr(int i) const
Definition: grids.h:248
CSG_Parameter_Grid_List
Definition: parameters.h:1402
CSG_Parameters::Add_Int
CSG_Parameter * Add_Int(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value=0, int Minimum=0, bool bMinimum=false, int Maximum=0, bool bMaximum=false)
Definition: parameters.cpp:401
PARAMETER_TYPE_Grid
@ PARAMETER_TYPE_Grid
Definition: parameters.h:148
CSG_Parameters::Add_Table_List
CSG_Parameter * Add_Table_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition: parameters.cpp:793
CSG_Table::Assign_Values
bool Assign_Values(const CSG_Table &Table)
Definition: table.cpp:401
CSG_Array_Int
Definition: api_core.h:421
CSG_Parameters::Add_Table
CSG_Parameter * Add_Table(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition: parameters.cpp:771
CSG_Tool_Library::m_Library_Name
CSG_String m_Library_Name
Definition: tool_library.h:161
PARAMETER_TYPE_Date
@ PARAMETER_TYPE_Date
Definition: parameters.h:129
CSG_Tool::Get_ID
const CSG_String & Get_ID(void) const
Definition: tool.h:163
PARAMETER_TYPE_Grid_List
@ PARAMETER_TYPE_Grid_List
Definition: parameters.h:154
CSG_Tool::Process_Set_Text
static void Process_Set_Text(const CSG_String &Text)
Definition: tool.cpp:854
CSG_Tool_Library::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_library.cpp:242
CSG_Parameters::Add_Grids
CSG_Parameter * Add_Grids(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true, TSG_Data_Type Preferred_Type=SG_DATATYPE_Undefined)
Definition: parameters.cpp:658
CSG_Parameter::is_Optional
bool is_Optional(void) const
Definition: parameters.h:233
SG_DATAOBJECT_TYPE_TIN
@ SG_DATAOBJECT_TYPE_TIN
Definition: dataobject.h:122
CSG_Strings
Definition: api_core.h:693
CSG_Parameters::Add_Table_Fields
CSG_Parameter * Add_Table_Fields(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
Definition: parameters.cpp:754
CSG_Parameters::Add_Grid
CSG_Parameter * Add_Grid(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true, TSG_Data_Type Preferred_Type=SG_DATATYPE_Undefined)
Definition: parameters.cpp:582
CSG_Tool_Chains::Delete_Tool
virtual bool Delete_Tool(CSG_Tool *pTool)
SG_DATAOBJECT_TYPE_Grid
@ SG_DATAOBJECT_TYPE_Grid
Definition: dataobject.h:118
CSG_Tool_Chain::Save_History_to_Model
static bool Save_History_to_Model(const CSG_MetaData &History, const CSG_String &File)
CSG_Parameter::asFilePath
class CSG_Parameter_File_Name * asFilePath(void) const
Definition: parameter.cpp:1042
CSG_Parameters::Del_Parameter
bool Del_Parameter(int i)
Definition: parameters.cpp:1191
CSG_Data_Object::Set_Name
void Set_Name(const CSG_String &Name)
Definition: dataobject.cpp:235
CSG_Parameter::is_Output
bool is_Output(void) const
Definition: parameters.h:232
CSG_MetaData::Add_Children
bool Add_Children(const CSG_MetaData &MetaData)
Definition: metadata.cpp:351
CSG_Tool::Set_Name
void Set_Name(const CSG_String &String)
Definition: tool.cpp:140
CSG_Parameters::Add_TIN
CSG_Parameter * Add_TIN(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition: parameters.cpp:849
CSG_Tool::Set_Description
void Set_Description(const CSG_String &String)
Definition: tool.cpp:173
CSG_String::Format
static CSG_String Format(const char *Format,...)
Definition: api_string.cpp:270
CSG_Parameters::Add_Grids_Output
CSG_Parameter * Add_Grids_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
Definition: parameters.cpp:686
CSG_Parameter_List::Get_Item_Count
int Get_Item_Count(void) const
Definition: parameters.h:1367
CSG_Tool_Chain
Definition: tool_chain.h:78
CSG_String::Find
int Find(char Character, bool fromEnd=false) const
Definition: api_string.cpp:616
CSG_Parameters::Get_Identifier
const CSG_String & Get_Identifier(void) const
Definition: parameters.h:1685
SHAPE_TYPE_Line
@ SHAPE_TYPE_Line
Definition: shapes.h:104
CSG_Parameter_Data_Object_Output::Get_Type
virtual TSG_Parameter_Type Get_Type(void) const
Definition: parameters.h:1168
CSG_Parameters::Add_Shapes
CSG_Parameter * Add_Shapes(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, TSG_Shape_Type Shape_Type=SHAPE_TYPE_Undefined)
Definition: parameters.cpp:808
CSG_Tool::has_GUI
bool has_GUI(void) const
Definition: tool.cpp:233
CSG_MetaData::Cmp_Property
bool Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase=false) const
Definition: metadata.cpp:673
CSG_Parameter_Value::has_Maximum
bool has_Maximum(void) const
Definition: parameters.h:445
SG_DATAOBJECT_TYPE_Shapes
@ SG_DATAOBJECT_TYPE_Shapes
Definition: dataobject.h:121
GET_XML_CONTENT
#define GET_XML_CONTENT(XML, ID, DEFAULT, TRANSLATE)
Definition: tool_chain.cpp:63
CSG_String::CmpNoCase
int CmpNoCase(const CSG_String &String) const
Definition: api_string.cpp:521
CSG_String::AfterFirst
CSG_String AfterFirst(char Character) const
Definition: api_string.cpp:644
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:254
CSG_Parameter::Get_Parent
CSG_Parameter * Get_Parent(void) const
Definition: parameter.cpp:105
CSG_Parameter::is_DataObject
bool is_DataObject(void) const
Definition: parameter.cpp:275
CSG_MetaData::Get_Parent
CSG_MetaData * Get_Parent(void) const
Definition: metadata.h:147
CSG_Array_Pointer::Destroy
void Destroy(void)
Definition: api_core.h:376
SG_Char
#define SG_Char
Definition: api_core.h:530
B
#define B
CSG_Tool::DataObject_Set_Colors
static bool DataObject_Set_Colors(CSG_Data_Object *pDataObject, const CSG_Colors &Colors)
Definition: tool.cpp:1004
CSG_String
Definition: api_core.h:557
CSG_Data_Manager::Add
bool Add(CSG_Data_Object *pObject)
Definition: data_manager.cpp:428
CSG_Parameter::asChoice
class CSG_Parameter_Choice * asChoice(void) const
Definition: parameter.cpp:1038
SHAPE_TYPE_Point
@ SHAPE_TYPE_Point
Definition: shapes.h:102
SG_DATAOBJECT_TYPE_Table
@ SG_DATAOBJECT_TYPE_Table
Definition: dataobject.h:120
CSG_Tool_Library::Get_Tool
virtual CSG_Tool * Get_Tool(int Index, TSG_Tool_Type Type=TOOL_TYPE_Base) const
Definition: tool_library.cpp:149
CSG_MetaData
Definition: metadata.h:88
CSG_Tool::Settings_Pop
bool Settings_Pop(void)
Definition: tool.cpp:627
CSG_Tool_Chain::is_Okay
bool is_Okay(void) const
Definition: tool_chain.h:96
CSG_MetaData::Load
bool Load(const CSG_String &File, const SG_Char *Extension=NULL)
Definition: metadata.cpp:790
CSG_Tool::Settings_Push
bool Settings_Push(class CSG_Data_Manager *pManager=NULL)
Definition: tool.cpp:600
CSG_Parameter_Shapes::Get_Type
virtual TSG_Parameter_Type Get_Type(void) const
Definition: parameters.h:1281
CSG_String::is_Empty
bool is_Empty(void) const
Definition: api_string.cpp:178
CSG_Parameter::has_Changed
bool has_Changed(int Check_Flags=PARAMETER_CHECK_ALL)
Definition: parameter.cpp:832
IS_TRUE_PROPERTY
#define IS_TRUE_PROPERTY(Item, Property)
Definition: tool_chain.cpp:66
CSG_Parameter::asDouble
double asDouble(void) const
Definition: parameters.h:283
CSG_Parameters::Add_Grid_Output
CSG_Parameter * Add_Grid_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
Definition: parameters.cpp:620
CSG_Parameters::Destroy
void Destroy(void)
Definition: parameters.cpp:182
PARAMETER_TYPE_Grid_System
@ PARAMETER_TYPE_Grid_System
Definition: parameters.h:143
CSG_Tool::Get_Description
const CSG_String & Get_Description(void) const
Definition: tool.cpp:178
TOOL_TYPE_Base
@ TOOL_TYPE_Base
Definition: tool.h:102
PARAMETER_TYPE_PointCloud_List
@ PARAMETER_TYPE_PointCloud_List
Definition: parameters.h:159
CSG_Parameter_Grid_List::Get_Type
virtual TSG_Parameter_Type Get_Type(void) const
Definition: parameters.h:1405
PARAMETER_TYPE_Table_List
@ PARAMETER_TYPE_Table_List
Definition: parameters.h:156
CSG_Parameter_Value::Get_Minimum
double Get_Minimum(void) const
Definition: parameters.h:440
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:1041
CSG_MetaData::Set_Name
void Set_Name(const CSG_String &Name)
Definition: metadata.h:133
CSG_Parameters::Add_PointCloud_List
CSG_Parameter * Add_PointCloud_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition: parameters.cpp:908
SG_Compare_Version
int SG_Compare_Version(const CSG_String &Version, int Major, int Minor, int Release)
Definition: saga_api.cpp:82
CSG_MetaData::Fmt_Content
void Fmt_Content(const char *Format,...)
Definition: metadata.cpp:491
CSG_Parameters::Set_Manager
void Set_Manager(class CSG_Data_Manager *pManager)
Definition: parameters.cpp:206
PARAMETER_TYPE_DataObject_Output
@ PARAMETER_TYPE_DataObject_Output
Definition: parameters.h:161
CSG_Tool_Chains::Get_Tool
virtual CSG_Tool * Get_Tool(int Index, TSG_Tool_Type Type=TOOL_TYPE_Base) const
CSG_String::asDouble
double asDouble(void) const
Definition: api_string.cpp:760
CSG_Tool::On_Before_Execution
virtual bool On_Before_Execution(void)
Definition: tool.h:239
CSG_Parameter_Range::Get_Min_Parameter
CSG_Parameter_Double * Get_Min_Parameter(void) const
Definition: parameters.h:620
SG_File_Make_Path
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
Definition: api_file.cpp:903
CSG_String::c_str
const SG_Char * c_str(void) const
Definition: api_string.cpp:236
SHAPE_TYPE_Points
@ SHAPE_TYPE_Points
Definition: shapes.h:103
CSG_Parameters::Add_Choices
CSG_Parameter * Add_Choices(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items)
Definition: parameters.cpp:479
CSG_Tool_Chains::~CSG_Tool_Chains
virtual ~CSG_Tool_Chains(void)
CSG_Strings::Get_Count
int Get_Count(void) const
Definition: api_core.h:706
CSG_Parameters
Definition: parameters.h:1650
CSG_Parameter::Get_DataObject_Type
TSG_Data_Object_Type Get_DataObject_Type(void) const
Definition: parameter.cpp:518
CSG_Array_Int::Get_uSize
size_t Get_uSize(void) const
Definition: api_core.h:435
CSG_MetaData::Add_Child
CSG_MetaData * Add_Child(void)
Definition: metadata.cpp:174
CSG_MetaData::asText
CSG_String asText(int Flags=0) const
Definition: metadata.cpp:700
CSG_Parameter::asGrids
CSG_Grids * asGrids(void) const
Definition: parameter.cpp:974
CSG_Parameter::asGrid_System
CSG_Grid_System * asGrid_System(void) const
Definition: parameter.cpp:968
CSG_Tool::Error_Fmt
bool Error_Fmt(const char *Format,...)
Definition: tool.cpp:746
CSG_Tool::Get_Type
virtual TSG_Tool_Type Get_Type(void) const
Definition: tool.h:161
CSG_Tool::Message_Fmt
void Message_Fmt(const char *Format,...)
Definition: tool.cpp:923
CSG_Parameter::Get_Name
const SG_Char * Get_Name(void) const
Definition: parameter.cpp:565
PARAMETER_TYPE_Range
@ PARAMETER_TYPE_Range
Definition: parameters.h:130
CSG_Parameter_Range::Get_Max_Parameter
CSG_Parameter_Double * Get_Max_Parameter(void) const
Definition: parameters.h:624
CSG_Parameter::is_Option
bool is_Option(void) const
Definition: parameter.cpp:238
CSG_Tool_Chains::Get_Count
virtual int Get_Count(void) const
Definition: tool_chain.h:183
PARAMETER_OUTPUT
#define PARAMETER_OUTPUT
Definition: parameters.h:95
CSG_Parameter_Choices::Get_Items
CSG_String Get_Items(void) const
Definition: parameter_data.cpp:1327
CSG_Tool::Set_Grid_System
bool Set_Grid_System(const CSG_Grid_System &System)
Definition: tool.cpp:1262
PARAMETER_TYPE_TIN_List
@ PARAMETER_TYPE_TIN_List
Definition: parameters.h:158
TSG_Parameter_Type
TSG_Parameter_Type
Definition: parameters.h:122
Get_List_Item
#define Get_List_Item(p, i)
Definition: tool_chain.cpp:69
PARAMETER_TYPE_Parameters
@ PARAMETER_TYPE_Parameters
Definition: parameters.h:163
PARAMETER_TYPE_Font
@ PARAMETER_TYPE_Font
Definition: parameters.h:138
CSG_Parameter::asList
class CSG_Parameter_List * asList(void) const
Definition: parameter.cpp:1046
IS_TRUE_STRING
#define IS_TRUE_STRING(String)
Definition: tool_chain.cpp:65
PARAMETER_TYPE_Color
@ PARAMETER_TYPE_Color
Definition: parameters.h:139
PARAMETER_TYPE_Shapes
@ PARAMETER_TYPE_Shapes
Definition: parameters.h:151
CSG_Parameter_Choice::Get_Items
CSG_String Get_Items(void) const
Definition: parameter_data.cpp:974
CSG_String::Right
CSG_String Right(size_t count) const
Definition: api_string.cpp:693
CSG_Tool::Get_Parameters_Count
int Get_Parameters_Count(void)
Definition: tool.h:178
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:470
SHAPE_TYPE_Undefined
@ SHAPE_TYPE_Undefined
Definition: shapes.h:101
CSG_Parameter::asChoices
class CSG_Parameter_Choices * asChoices(void) const
Definition: parameter.cpp:1040
CSG_Parameter::is_Information
bool is_Information(void) const
Definition: parameters.h:234
PARAMETER_INPUT
#define PARAMETER_INPUT
Definition: parameters.h:94
CSG_Parameters::Add_Bool
CSG_Parameter * Add_Bool(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool Value=false)
Definition: parameters.cpp:396
CSG_Grid_System::is_Valid
bool is_Valid(void) const
Definition: grid_system.cpp:243
CSG_Parameter::Get_Type_Identifier
CSG_String Get_Type_Identifier(void) const
Definition: parameter.cpp:122
CSG_Grids::Del_Grids
bool Del_Grids(bool bDetach=false)
Definition: grids.cpp:803
CSG_Parameter::asBool
bool asBool(void) const
Definition: parameters.h:280
TLB_INFO_Menu_Path
@ TLB_INFO_Menu_Path
Definition: tool.h:619
PARAMETER_OUTPUT_OPTIONAL
#define PARAMETER_OUTPUT_OPTIONAL
Definition: parameters.h:103
SG_UI_Msg_Add
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
Definition: api_callback.cpp:490
CSG_Parameters::Add_Table_Field
CSG_Parameter * Add_Table_Field(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bAllowNone=false)
Definition: parameters.cpp:724
CSG_Tool_Chain::~CSG_Tool_Chain
virtual ~CSG_Tool_Chain(void)
Definition: tool_chain.cpp:103
PARAMETER_TYPE_Text
@ PARAMETER_TYPE_Text
Definition: parameters.h:135
CSG_Parameters::Add_Choice
CSG_Parameter * Add_Choice(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items, int Default=0)
Definition: parameters.cpp:464