SAGA API v9.10
Loading...
Searching...
No Matches
parameter.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// parameter.cpp //
15// //
16// Copyright (C) 2005 by Olaf Conrad //
17// //
18//-------------------------------------------------------//
19// //
20// This file is part of 'SAGA - System for Automated //
21// Geoscientific Analyses'. //
22// //
23// This library is free software; you can redistribute //
24// it and/or modify it under the terms of the GNU Lesser //
25// General Public License as published by the Free //
26// Software Foundation, either version 2.1 of the //
27// License, or (at your option) any later version. //
28// //
29// This library is distributed in the hope that it will //
30// be useful, but WITHOUT ANY WARRANTY; without even the //
31// implied warranty of MERCHANTABILITY or FITNESS FOR A //
32// PARTICULAR PURPOSE. See the GNU Lesser General Public //
33// License for more details. //
34// //
35// You should have received a copy of the GNU Lesser //
36// General Public License along with this program; if //
37// not, see <http://www.gnu.org/licenses/>. //
38// //
39//-------------------------------------------------------//
40// //
41// contact: Olaf Conrad //
42// Institute of Geography //
43// University of Goettingen //
44// Germany //
45// //
46// e-mail: oconrad@saga-gis.org //
47// //
49
50//---------------------------------------------------------
51#include "parameters.h"
52#include "data_manager.h"
53#include "tool.h"
54#include "tool_library.h"
55
56
58// //
59// //
60// //
62
63//---------------------------------------------------------
64CSG_Parameter::CSG_Parameter(CSG_Parameters *pParameters, CSG_Parameter *pParent, const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description, int Constraint)
65{
66 m_pParameters = pParameters;
67 m_pParent = pParent;
68 m_Identifier = Identifier;
69 m_Name = Name;
70 m_Description = Description;
71 m_Constraint = Constraint;
72
73 m_bEnabled = true;
74
75 //-----------------------------------------------------
76 m_nChildren = 0;
77 m_Children = NULL;
78
79 if( m_pParent )
80 {
81 m_pParent->_Add_Child(this);
82 }
83}
84
85//---------------------------------------------------------
87{
88 if( m_Children )
89 {
90 SG_Free(m_Children);
91 }
92}
93
94
96// //
98
99//---------------------------------------------------------
101{
102 return( m_pParameters );
103}
104
105//---------------------------------------------------------
107{
108 return( m_pParent );
109}
110
111//---------------------------------------------------------
113{
114 return( m_pParameters ? m_pParameters->Get_Manager() : NULL );
115}
116
117
119// //
121
122//---------------------------------------------------------
127
128//---------------------------------------------------------
133
134
136// //
138
139//---------------------------------------------------------
141{
142 if( bOn )
143 {
144 m_Constraint |= PARAMETER_GUI_COLLAPSED;
145 }
146 else
147 {
148 m_Constraint &= ~PARAMETER_GUI_COLLAPSED;
149 }
150
151 return( is_Collapsed() );
152}
153
154//---------------------------------------------------------
156{
157 if( bOn )
158 {
159 m_Constraint &= ~PARAMETER_NOT_FOR_GUI;
160 }
161 else
162 {
163 m_Constraint |= PARAMETER_NOT_FOR_GUI;
164 }
165}
166
167//---------------------------------------------------------
169{
170 if( bOn )
171 {
172 m_Constraint &= ~PARAMETER_NOT_FOR_CMD;
173 }
174 else
175 {
176 m_Constraint |= PARAMETER_NOT_FOR_CMD;
177 }
178}
179
180//---------------------------------------------------------
182{
183 return( !(m_Constraint & PARAMETER_NOT_FOR_GUI) && (Get_Parent() == NULL || Get_Parent()->do_UseInGUI()) );
184}
185
186//---------------------------------------------------------
188{
189 return( !(m_Constraint & PARAMETER_NOT_FOR_CMD) && (Get_Parent() == NULL || Get_Parent()->do_UseInCMD()) );
190}
191
192//---------------------------------------------------------
194{
195 if( bIgnore )
196 {
197 m_Constraint &= ~PARAMETER_IGNORE_PROJECTION;
198 }
199 else
200 {
201 m_Constraint |= PARAMETER_IGNORE_PROJECTION;
202 }
203}
204
205
207// //
209
210//---------------------------------------------------------
211bool CSG_Parameter::Set_Enabled(bool bEnabled)
212{
213 if( m_bEnabled != bEnabled )
214 {
215 m_bEnabled = bEnabled;
216
217 return( !bEnabled );
218 }
219
220 return( bEnabled );
221}
222
223//---------------------------------------------------------
224bool CSG_Parameter::is_Enabled(bool bCheckEnv) const
225{
226 if( bCheckEnv )
227 {
228 if( !do_UseInGUI() && m_pParameters->has_GUI() )
229 {
230 return( false );
231 }
232
233 if( !do_UseInCMD() && !m_pParameters->has_GUI() )
234 {
235 return( false );
236 }
237 }
238
239 return( m_bEnabled && (m_pParent == NULL || m_pParent->is_Enabled()) );
240}
241
242//---------------------------------------------------------
244{
245 for(int i=0; i<Get_Children_Count(); i++)
246 {
247 Get_Child(i)->Set_Enabled(bEnabled);
248 }
249
250 return( true );
251}
252
253//---------------------------------------------------------
255{
256 if( !is_Information() )
257 {
258 switch( Get_Type() )
259 {
261 case PARAMETER_TYPE_Int :
280 return( true );
281
282 default:
283 return( false );
284 }
285 }
286
287 return( false );
288}
289
290//---------------------------------------------------------
292{
293 switch( Get_Type() )
294 {
300 case PARAMETER_TYPE_TIN :
302 return( true );
303
304 default:
305 return( false );
306 }
307}
308
309//---------------------------------------------------------
311{
312 switch( Get_Type() )
313 {
320 return( true );
321
322 default:
323 return( false );
324 }
325}
326
327//---------------------------------------------------------
329{
330 return( Get_Type() == PARAMETER_TYPE_Parameters );
331}
332
333//---------------------------------------------------------
335{
336 switch( Get_Type() )
337 {
341 return( false );
342
344 return( ((CSG_Parameter_String *)this)->is_Password() == false );
345
346 default:
347 return( !is_Information() );
348 }
349}
350
351//---------------------------------------------------------
353{
354 if( pParameter && pParameter->Get_Type() == Get_Type() )
355 {
356 switch( Get_Type() )
357 {
358 //-------------------------------------------------
361 {
362 bool bResult = pParameter->asChoice()->Get_Count() == asChoice()->Get_Count();
363
364 for(int i=0; bResult && i<asChoice()->Get_Count(); i++)
365 {
366 bResult = SG_STR_CMP(pParameter->asChoice()->Get_Item(i), asChoice()->Get_Item(i)) == 0;
367 }
368
369 return( bResult );
370 }
371
372 //-------------------------------------------------
374 {
375 bool bResult = pParameter->asChoices()->Get_Item_Count() == asChoices()->Get_Item_Count();
376
377 for(int i=0; bResult && i<asChoices()->Get_Item_Count(); i++)
378 {
379 bResult = SG_STR_CMP(pParameter->asChoices()->Get_Item(i), asChoices()->Get_Item(i)) == 0;
380 }
381
382 return( bResult );
383 }
384
385 //-------------------------------------------------
386 case PARAMETER_TYPE_FixedTable : return( pParameter->asTable()->is_Compatible(asTable()) );
387
388 //-------------------------------------------------
390 {
391 bool bResult = pParameter->asParameters()->Get_Count() == asParameters()->Get_Count();
392
393 for(int i=0; bResult && i<asParameters()->Get_Count(); i++)
394 {
395 bResult = pParameter->asParameters()->Get_Parameter(i)->is_Compatible(asParameters()->Get_Parameter(i));
396 }
397
398 return( bResult );
399 }
400
401 //-------------------------------------------------
402 default:
403 return( true );
404 }
405 }
406
407 return( false );
408}
409
410//---------------------------------------------------------
412{
413 if( pParameter && pParameter->Get_Type() == Get_Type() )
414 {
415 switch( Get_Type() )
416 {
417 case PARAMETER_TYPE_Node : return( true );
418
419 //-------------------------------------------------
420 case PARAMETER_TYPE_Bool : return( pParameter->asBool () == asBool () );
425 case PARAMETER_TYPE_Int : return( pParameter->asInt () == asInt () );
428 case PARAMETER_TYPE_Double : return( pParameter->asDouble() == asDouble() );
429
434 case PARAMETER_TYPE_String : return( SG_STR_CMP(pParameter->asString(), asString()) == 0 );
435
436 case PARAMETER_TYPE_Range : return( pParameter->asRange()->Get_Min() == asRange()->Get_Min()
437 && pParameter->asRange()->Get_Max() == asRange()->Get_Max() );
438
439 case PARAMETER_TYPE_Grid_System : return( pParameter->asGrid_System()->is_Equal(*asGrid_System()) );
440
441 //-------------------------------------------------
443 {
444 bool bResult = pParameter->asChoices()->Get_Selection_Count() == asChoices()->Get_Selection_Count();
445
446 for(int i=0; bResult && i<asChoices()->Get_Selection_Count(); i++)
447 {
448 bResult = pParameter->asChoices()->Get_Selection_Index(i) == asChoices()->Get_Selection_Index(i);
449 }
450
451 return( bResult );
452 }
453
454 //-------------------------------------------------
456 {
457 bool bResult = pParameter->asColors()->Get_Count() == asColors()->Get_Count();
458
459 for(int i=0; bResult && i<asColors()->Get_Count(); i++)
460 {
461 bResult = pParameter->asColors()->Get_Color(i) == asColors()->Get_Color(i);
462 }
463
464 return( bResult );
465 }
466
467 //-------------------------------------------------
469 {
470 bool bResult = pParameter->asTable()->is_Compatible(asTable()) && pParameter->asTable()->Get_Count() == asTable()->Get_Count();
471
472 for(int i=0; bResult && i<asTable()->Get_Count(); i++)
473 {
474 CSG_Table_Record *pA = pParameter->asTable()->Get_Record(i), *pB = asTable()->Get_Record(i);
475
476 for(int j=0; bResult && j<asTable()->Get_Field_Count(); j++)
477 {
478 bResult = SG_STR_CMP(pA->asString(j), pB->asString(j)) == 0;
479 }
480 }
481
482 return( bResult );
483 }
484
485 //-------------------------------------------------
491 case PARAMETER_TYPE_TIN :
492 case PARAMETER_TYPE_PointCloud : return( pParameter->asDataObject() == asDataObject() );
493
494 //-------------------------------------------------
501 {
502 bool bResult = pParameter->asList()->Get_Item_Count() == asList()->Get_Item_Count();
503
504 for(int i=0; bResult && i<asList()->Get_Item_Count(); i++)
505 {
506 bResult = pParameter->asList()->Get_Item(i) == asList()->Get_Item(i);
507 }
508
509 return( bResult );
510 }
511
512 //-------------------------------------------------
514 {
515 bool bResult = pParameter->asParameters()->Get_Count() == asParameters()->Get_Count();
516
517 for(int i=0; bResult && i<asParameters()->Get_Count(); i++)
518 {
519 bResult = pParameter->asParameters()->Get_Parameter(i)->is_Value_Equal(asParameters()->Get_Parameter(i));
520 }
521
522 return( bResult );
523 }
524
525 //-------------------------------------------------
526 default: break;
527 }
528 }
529
530 return( false );
531}
532
533//---------------------------------------------------------
555
556
558// //
560
561//---------------------------------------------------------
563{
564 return( m_Identifier );
565}
566
567//---------------------------------------------------------
568bool CSG_Parameter::Cmp_Identifier(const CSG_String &Identifier) const
569{
570 return( !m_Identifier.Cmp(Identifier) || !m_Identifier.Cmp(Identifier + ".Default") );
571}
572
573//---------------------------------------------------------
577//---------------------------------------------------------
579{
581
582 if( ID.Length() > 0 )
583 {
584 ID += "_";
585 }
586
587 ID += Get_Identifier();
588
589 ID.Replace(".", "_");
590 ID.Replace("|", "_");
591 ID.Replace(" ", "_");
592
593 return( ID );
594}
595
596//---------------------------------------------------------
598{
599 m_Name = Name;
600
601 return( true );
602}
603
605{
606 return( m_Name );
607}
608
609//---------------------------------------------------------
611{
612 m_Description = Description;
613
614 return( true );
615}
616
618{
619 return( m_Description );
620}
621
622//---------------------------------------------------------
624{
625 return( Get_Description(Flags, SG_T("\n")) );
626}
627
628//---------------------------------------------------------
629CSG_String CSG_Parameter::Get_Description(int Flags, const SG_Char *Separator) const
630{
631 #define SEPARATE if( !s.is_Empty() ) { s.Append(Separator); }
632
633 if( !Separator || !Separator[0] )
634 {
635 return( Get_Description(Flags) );
636 }
637
638 CSG_String s;
639
640 //-----------------------------------------------------
641 if( (Flags & PARAMETER_DESCRIPTION_NAME) != 0 )
642 {
643 SEPARATE; s += CSG_String::Format("%s", Get_Name());
644 }
645
646 //-----------------------------------------------------
647 if( (Flags & PARAMETER_DESCRIPTION_TYPE) != 0 )
648 {
649 SEPARATE;
650
652 {
654 }
655 else
656 {
657 s += CSG_String::Format("%s", Get_Type_Name().c_str());
658 }
659
661 {
662 s += CSG_String::Format(", %s", is_Input() ? _TL("input") : _TL("output"));
663
664 if( is_Optional() )
665 {
666 s += CSG_String::Format(", %s", _TL("optional"));
667 }
668 }
669
670 if( do_UseInGUI() != do_UseInCMD() )
671 {
672 if( m_pParameters->has_GUI() || do_UseInGUI() )
673 {
674 s += CSG_String::Format("\n[%s]", do_UseInGUI() ? SG_T("GUI") : SG_T("CMD"));
675 }
676 }
677 }
678
679 //-----------------------------------------------------
680 if( (Flags & PARAMETER_DESCRIPTION_OPTIONAL) != 0 && is_Optional() )
681 {
682 SEPARATE; s += CSG_String::Format("%s", _TL("optional"));
683 }
684
685 //-----------------------------------------------------
686 if( (Flags & PARAMETER_DESCRIPTION_PROPERTIES) != 0 )
687 {
688 switch( Get_Type() )
689 {
690 default:
691 break;
692
694 SEPARATE; s += CSG_String::Format("%s:", _TL("Available Choices"));
695
696 for(int i=0; i<asChoice()->Get_Count(); i++)
697 {
698 s += CSG_String::Format("%s[%d] %s", Separator, i, asChoice()->Get_Item(i));
699 }
700 break;
701
703 if( do_UseInCMD() || asChoice()->Get_Count() < 32 )
704 {
705 SEPARATE; s += CSG_String::Format("%s:", _TL("Available Choices"));
706
707 for(int i=0; i<asChoice()->Get_Count(); i++)
708 {
709 s += CSG_String::Format("%s[%d] %s", Separator, i, asChoice()->Get_Item(i));
710 }
711 }
712 else
713 {
714 SEPARATE; s += CSG_String::Format("%d %s:", asChoice()->Get_Count(), _TL("Choices"));
715 }
716 break;
717
719 if( do_UseInCMD() || asChoices()->Get_Item_Count() < 32 )
720 {
721 SEPARATE; s += CSG_String::Format("%s:", _TL("Available Choices"));
722
723 for(int i=0; i<asChoices()->Get_Item_Count(); i++)
724 {
725 s += CSG_String::Format("%s[%d] %s", Separator, i, asChoices()->Get_Item(i).c_str());
726 }
727 }
728 else
729 {
730 SEPARATE; s += CSG_String::Format("%d %s:", asChoices()->Get_Item_Count(), _TL("Choices"));
731 }
732 break;
733
734 case PARAMETER_TYPE_Int :
735 if( asValue()->has_Minimum() )
736 {
737 SEPARATE; s += CSG_String::Format("%s: %d", _TL("Minimum"), (int)asValue()->Get_Minimum());
738 }
739
740 if( asValue()->has_Maximum() )
741 {
742 SEPARATE; s += CSG_String::Format("%s: %d", _TL("Maximum"), (int)asValue()->Get_Maximum());
743 }
744 break;
745
748// case PARAMETER_TYPE_Range :
749 if( asValue()->has_Minimum() )
750 {
751 SEPARATE; s += CSG_String::Format("%s: %f", _TL("Minimum"), asValue()->Get_Minimum());
752 }
753
754 if( asValue()->has_Maximum() )
755 {
756 SEPARATE; s += CSG_String::Format("%s: %f", _TL("Maximum"), asValue()->Get_Maximum());
757 }
758 break;
759
761 SEPARATE; s += CSG_String::Format("%d %s:%s", asTable()->Get_Field_Count(), _TL("Fields"), Separator);
762
763 for(int i=0; i<asTable()->Get_Field_Count(); i++)
764 {
765 s += CSG_String::Format("- %d. [%s] %s%s", i + 1, SG_Data_Type_Get_Name(asTable()->Get_Field_Type(i)).c_str(), asTable()->Get_Field_Name(i), Separator);
766 }
767 break;
768
770 SEPARATE; s += CSG_String::Format("%d %s", asParameters()->Get_Count(), _TL("Parameters"));
771
772 if( do_UseInCMD() )
773 {
774 s += CSG_String::Format(":%s", Separator);
775
776 for(int i=0; i<asParameters()->Get_Count(); i++)
777 {
778 s += CSG_String::Format("- %d. %s%s", i + 1, asParameters()->Get_Parameter(i)->Get_Description(Flags, Separator).c_str(), Separator);
779 }
780 }
781 break;
782 }
783
784 if( !m_Default.is_Empty() )
785 {
786 SEPARATE; s += CSG_String::Format("%s: %s", _TL("Default"), m_Default.c_str());
787 }
788 }
789
790 //-----------------------------------------------------
791 if( (Flags & PARAMETER_DESCRIPTION_TEXT) != 0 && m_Description.Length() > 0 )
792 {
793 SEPARATE; s += m_Description;
794 }
795
796 //-----------------------------------------------------
797 #undef SEPARATE
798
799 return( s );
800}
801
802
804// //
806
807//---------------------------------------------------------
813
814//---------------------------------------------------------
816{
817 switch( _Set_Value(Value) )
818 {
820 return( false );
821
823 has_Changed();
824 }
825
826 return( true );
827}
828
829//---------------------------------------------------------
830bool CSG_Parameter::Set_Value(double Value)
831{
832 switch( _Set_Value(Value) )
833 {
835 return( false );
836
838 has_Changed();
839 }
840
841 return( true );
842}
843
844//---------------------------------------------------------
846{
847 switch( _Set_Value(Value) )
848 {
850 return( false );
851
853 has_Changed();
854 }
855
856 return( true );
857}
858
859//---------------------------------------------------------
860bool CSG_Parameter::Set_Value(const char *Value) { return( Set_Value(CSG_String(Value)) ); }
861bool CSG_Parameter::Set_Value(const wchar_t *Value) { return( Set_Value(CSG_String(Value)) ); }
863{
864 switch( _Set_Value(Value) )
865 {
867 return( false );
868
870 has_Changed();
871 }
872
873 return( true );
874}
875
876//---------------------------------------------------------
878{
879 switch( _Set_Value(Value) )
880 {
882 return( false );
883
885 has_Changed();
886 }
887
888 return( true );
889}
890
891//---------------------------------------------------------
893{
894 if( Value )
895 {
896 switch( Value->Get_Type() )
897 {
898 default:
899 break;
900
903 return( Set_Value(Value->asInt()) );
904 }
905 }
906
907 return( Assign(Value) );
908}
909
910//---------------------------------------------------------
912{
913 return( false );
914}
915
916//---------------------------------------------------------
917bool CSG_Parameter::has_Changed(int Check_Flags)
918{
919 _Set_String();
920
921 return( m_pParameters && m_pParameters->_On_Parameter_Changed(this, Check_Flags) );
922}
923
924//---------------------------------------------------------
926{
927 // nop
928}
929
930
932// //
934
935//---------------------------------------------------------
937{
938 m_Default.Printf("%d", Value);
939
940 return( true );
941}
942
943//---------------------------------------------------------
945{
946 m_Default.Printf("%f", Value);
947
948 return( true );
949}
950
951//---------------------------------------------------------
953{
954 m_Default = Value;
955
956 return( true );
957}
958
959//---------------------------------------------------------
961{
962 return( m_Default );
963}
964
965//---------------------------------------------------------
967{
968 return( m_Default.Cmp(asString()) == 0 );
969}
970
971//---------------------------------------------------------
973{
974 return( Set_Value(m_Default) );
975}
976
977
979// //
981
982//---------------------------------------------------------
983bool CSG_Parameter::Check(bool bSilent)
984{
986 {
987 return( asParameters()->DataObjects_Check(bSilent) );
988 }
989
990 //-----------------------------------------------------
992 {
993 if( m_pParameters->Get_Manager() )
994 {
995 bool bExists = false; CSG_Data_Manager &Manager = *m_pParameters->Get_Manager();
996
997 for(size_t i=0; !bExists && i<Manager.Grid ().Count(); i++)
998 {
999 bExists = Manager.Grid (i).Get_System() == *asGrid_System();
1000 }
1001
1002 for(size_t i=0; !bExists && i<Manager.Grids().Count(); i++)
1003 {
1004 bExists = Manager.Grids(i).Get_System() == *asGrid_System();
1005 }
1006
1007 if( bExists == false )
1008 {
1009 Set_Value((void *)NULL);
1010 }
1011 }
1012
1013 return( true ); // ( false );
1014 }
1015
1016 //-----------------------------------------------------
1017 if( is_DataObject() )
1018 {
1019 if( is_Input() || (is_Output() && asDataObject() != DATAOBJECT_CREATE) )
1020 {
1021 if( m_pParameters->Get_Manager() && !m_pParameters->Get_Manager()->Exists(asDataObject()) )
1022 {
1024 }
1025 }
1026
1027 return( is_Optional() || !is_Enabled() || asDataObject() );
1028 }
1029
1030 //-----------------------------------------------------
1031 else if( is_DataObject_List() )
1032 {
1033 for(int j=asList()->Get_Item_Count()-1; j>=0; j--)
1034 {
1035 CSG_Data_Object *pDataObject = asList()->Get_Item(j);
1036
1037 if( !pDataObject || (m_pParameters->Get_Manager() && !m_pParameters->Get_Manager()->Exists(pDataObject)) )
1038 {
1039 asList()->Del_Item(j, false);
1040 }
1041 }
1042
1043 _Set_String();
1044
1045 asList()->Update_Data();
1046
1047 return( is_Optional() || !is_Enabled() || is_Output() || asList()->Get_Item_Count() > 0 );
1048 }
1049
1050 //-----------------------------------------------------
1051 return( true );
1052}
1053
1054
1056// //
1058
1059//---------------------------------------------------------
1060int CSG_Parameter::_asInt (void) const { return( 0 ); }
1061double CSG_Parameter::_asDouble (void) const { return( 0. ); }
1062void * CSG_Parameter::_asPointer (void) const { return( NULL ); }
1063const SG_Char * CSG_Parameter::_asString (void) const { return( m_String ); }
1064
1065//---------------------------------------------------------
1067const SG_Char * CSG_Parameter::asFont (void) const { return( Get_Type() != PARAMETER_TYPE_Font ? NULL : (const SG_Char *)asPointer() ); }
1070
1071//---------------------------------------------------------
1094
1095//---------------------------------------------------------
1097CSG_Grid * CSG_Parameter::asGrid (void) const { CSG_Data_Object *pObject = asDataObject(); return( !pObject || pObject == DATAOBJECT_CREATE || pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_Grid ? NULL : (CSG_Grid *)pObject ); }
1098CSG_Grids * CSG_Parameter::asGrids (void) const { CSG_Data_Object *pObject = asDataObject(); return( !pObject || pObject == DATAOBJECT_CREATE || pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_Grids ? NULL : (CSG_Grids *)pObject ); }
1099CSG_TIN * CSG_Parameter::asTIN (void) const { CSG_Data_Object *pObject = asDataObject(); return( !pObject || pObject == DATAOBJECT_CREATE || pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_TIN ? NULL : (CSG_TIN *)pObject ); }
1100CSG_PointCloud * CSG_Parameter::asPointCloud (void) const { CSG_Data_Object *pObject = asDataObject(); return( !pObject || pObject == DATAOBJECT_CREATE || pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_PointCloud ? NULL : (CSG_PointCloud *)pObject ); }
1101
1102//---------------------------------------------------------
1104{
1105 CSG_Data_Object *pObject = asDataObject();
1106
1107 if( pObject && pObject != DATAOBJECT_CREATE
1110 {
1111 return( (CSG_Shapes *)pObject );
1112 }
1113
1114 return( NULL );
1115}
1116
1117//---------------------------------------------------------
1119{
1120 switch( Get_Type() )
1121 {
1122 default: {
1123 CSG_Data_Object *pObject = asDataObject();
1124
1125 if( pObject && pObject != DATAOBJECT_CREATE
1128 || pObject->Get_ObjectType() == SG_DATAOBJECT_TYPE_TIN
1130 {
1131 return( (CSG_Table *)pObject );
1132 }
1133 } break;
1134
1136 return( asGrids() ? asGrids()->Get_Attributes_Ptr() : NULL );
1137
1139 return( (CSG_Table *)asPointer() );
1140 }
1141
1142 return( NULL );
1143}
1144
1145//---------------------------------------------------------
1147{
1153 {
1154 return( (CSG_Parameter_Value *)this );
1155 }
1156
1157 return( NULL );
1158}
1159
1168
1169//---------------------------------------------------------
1177
1178
1180// //
1182
1183//---------------------------------------------------------
1184void CSG_Parameter::_Add_Child(CSG_Parameter *pChild)
1185{
1186 m_Children = (CSG_Parameter **)SG_Realloc(m_Children, (m_nChildren + 1) * sizeof(CSG_Parameter *));
1187 m_Children[m_nChildren++] = pChild;
1188}
1189
1190
1192// //
1194
1195//---------------------------------------------------------
1197{
1198 if( pSource && Get_Type() == pSource->Get_Type() )
1199 {
1200 m_bEnabled = pSource->m_bEnabled;
1201 m_Default = pSource->m_Default;
1202
1203 Set_Collapsed(pSource->is_Collapsed());
1204
1205 if( _Assign(pSource) )
1206 {
1207 _Set_String();
1208
1209 return( true );
1210 }
1211 }
1212
1213 return( false );
1214}
1215
1217{
1218 return( true );
1219}
1220
1221//---------------------------------------------------------
1222bool CSG_Parameter::Serialize(CSG_MetaData &MetaData, bool bSave)
1223{
1224 if( bSave )
1225 {
1227 {
1228 return( true );
1229 }
1230
1231 CSG_MetaData &Child = *MetaData.Add_Child(
1232 is_Option () ? "OPTION" :
1233 is_DataObject () ? "DATA" :
1234 is_DataObject_List() ? "DATA_LIST" : "PARAMETER"
1235 );
1236
1237 Child.Add_Property("type" , Get_Type_Identifier ());
1238 Child.Add_Property("id" , Get_Identifier ());
1239 Child.Add_Property("name" , Get_Name ());
1240 Child.Add_Property("parms", Get_Parameters()->Get_Identifier());
1241
1242 _Serialize(Child, bSave);
1243
1244 return( true );
1245 }
1246 else if( MetaData.Cmp_Property("type", Get_Type_Identifier())
1247 && MetaData.Cmp_Property("id" , Get_Identifier ())
1248 && _Serialize(MetaData, bSave) )
1249 {
1250 _Set_String();
1251
1252 return( true );
1253 }
1254
1255 return( false );
1256}
1257
1259{
1260 Entry.Set_Content("-");
1261
1262 return( true );
1263}
1264
1265
1267// //
1268// Coordinate System Reference Picker //
1269// //
1271
1272//---------------------------------------------------------
1277
1278//---------------------------------------------------------
1280{
1281 m_pParameters = &Parameters;
1282
1283 Parameters.Add_String(ParentID, "CRS_STRING", _TL("Coordinate System Definition"),
1284 _TL("Supported formats comprise PROJ and WKT strings, object codes (e.g. \"EPSG:4326\")."), ""
1285 )->Set_UseInGUI(false);
1286
1287 return( true );
1288}
1289
1290
1292// //
1294
1295//---------------------------------------------------------
1297{
1298 if( !m_pParameters || !m_pParameters->has_GUI() || m_pCRS )
1299 {
1300 return( false );
1301 }
1302
1303 m_pCRS = SG_Get_Tool_Library_Manager().Create_Tool("pj_proj4", 15, true); // CCRS_Picker
1304
1305 if( !m_pCRS )
1306 {
1307 return( false );
1308 }
1309
1310 m_pCRS->Set_Parameter("CRS_STRING", (*m_pParameters)["CRS_STRING"].asString());
1311
1312 m_pParameters->Add_Parameters((*m_pParameters)("CRS_STRING")->Get_Parent(),
1313 "CRS_PICKER", _TL("Coordinate Reference System"), _TL("")
1314 )->asParameters()->Create(*m_pCRS->Get_Parameters());
1315
1316 return( true );
1317}
1318
1319//---------------------------------------------------------
1321{
1322 if( m_pCRS )
1323 {
1324 m_pParameters->Del_Parameter("CRS_PICKER");
1325
1327
1328 m_pCRS = NULL;
1329
1330 return( true );
1331 }
1332
1333 return( false );
1334}
1335
1336
1338// //
1340
1341//---------------------------------------------------------
1343{
1344 if( pParameter->Cmp_Identifier("CRS_PICKER") )
1345 {
1346 pParameters->Set_Parameter("CRS_STRING", (*pParameter->asParameters())("CRS_WKT")->asString());
1347 }
1348
1349 return( true );
1350}
1351
1352//---------------------------------------------------------
1354{
1355 return( true );
1356}
1357
1358
1360// //
1362
1363//---------------------------------------------------------
1365{
1366 if( Projection.Create((*m_pParameters)["CRS_STRING"].asString()) )
1367 {
1368 if( bMessage )
1369 {
1370 SG_UI_Msg_Add_Execution(CSG_String::Format("\n%s: %s\n", _TL("CRS"), Projection.Get_PROJ().c_str()), false);
1371 }
1372
1373 return( true );
1374 }
1375
1376 if( bMessage )
1377 {
1378 SG_UI_Msg_Add_Execution(CSG_String::Format("\n%s: %s\n", _TL("Warning"), _TL("undefined coordinate reference system")), false);
1379 }
1380
1381 return( false );
1382}
1383
1384
1386// //
1387// Grid Target Selector //
1388// //
1390
1391//---------------------------------------------------------
1393{
1394 m_pParameters = NULL;
1395}
1396
1397//---------------------------------------------------------
1398bool CSG_Parameters_Grid_Target::Create(CSG_Parameters *pParameters, bool bAddDefaultGrid, CSG_Parameter *pParent, const CSG_String &Prefix)
1399{
1400 return( Create(pParameters, bAddDefaultGrid, pParent ? pParent->Get_Identifier() : SG_T(""), Prefix) );
1401}
1402
1403bool CSG_Parameters_Grid_Target::Create(CSG_Parameters *pParameters, bool bAddDefaultGrid, const CSG_String &ParentID, const CSG_String &Prefix)
1404{
1405 if( pParameters == NULL )
1406 {
1407 return( false );
1408 }
1409
1410 m_pParameters = pParameters;
1411 m_Prefix = Prefix;
1412
1413 //-----------------------------------------------------
1414 CSG_String TargetID(m_Prefix + "DEFINITION");
1415
1416 m_pParameters->Add_Choice(
1417 ParentID, TargetID, _TL("Target Grid System"),
1418 _TL(""),
1419 CSG_String::Format("%s|%s",
1420 _TL("user defined"),
1421 _TL("grid or grid system")
1422 ), 0
1423 );
1424
1425 //-----------------------------------------------------
1426 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_SIZE", _TL("Cellsize"), _TL(""), 1., 0., true);
1427 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_XMIN", _TL("West" ), _TL(""), 0.);
1428 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_XMAX", _TL("East" ), _TL(""), 100.);
1429 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_YMIN", _TL("South" ), _TL(""), 0.);
1430 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_YMAX", _TL("North" ), _TL(""), 100.);
1431 m_pParameters->Add_Int (TargetID, m_Prefix + "USER_COLS", _TL("Columns" ), _TL("Number of cells in East-West direction." ), 101, 1, true);
1432 m_pParameters->Add_Int (TargetID, m_Prefix + "USER_ROWS", _TL("Rows" ), _TL("Number of cells in North-South direction."), 101, 1, true);
1433 m_pParameters->Add_Bool (TargetID, m_Prefix + "USER_FLAT", _TL("Rounding"), _TL("Round bounding coordinates to multiples of cell size. Ignored if cell size has decimal places."), true);
1434 m_pParameters->Add_Choice(TargetID, m_Prefix + "USER_FITS", _TL("Fit" ), _TL(""),
1435 CSG_String::Format("%s|%s",
1436 _TL("nodes"),
1437 _TL("cells")
1438 ), 0
1439 );
1440
1441 //-----------------------------------------------------
1442 m_pParameters->Add_Grid_System(TargetID, m_Prefix + "SYSTEM", _TL("Grid System"), _TL(""));
1443
1444 m_pParameters->Add_Grid(m_Prefix + "SYSTEM", m_Prefix + "TEMPLATE", _TL("Target System"),
1445 _TL("use this grid's system for output grids"), PARAMETER_INPUT_OPTIONAL, false
1446 )->Set_UseInGUI(false);
1447
1448 //-----------------------------------------------------
1449 if( bAddDefaultGrid )
1450 {
1451 Add_Grid(m_Prefix + "OUT_GRID", _TL("Target Grid"), false);
1452 }
1453
1454 return( true );
1455}
1456
1457
1459// //
1461
1462//---------------------------------------------------------
1464{
1465 return( pParameter && pParameters && m_pParameters && m_pParameters->Cmp_Identifier(pParameters->Get_Identifier())
1466 && On_Parameter_Changed(pParameters, pParameter, m_Prefix)
1467 );
1468}
1469
1470//---------------------------------------------------------
1472{
1473 if( !pParameters || !pParameter )
1474 {
1475 return( false );
1476 }
1477
1478 if( !pParameter->Cmp_Identifier(Prefix + "USER_SIZE")
1479 && !pParameter->Cmp_Identifier(Prefix + "USER_XMIN")
1480 && !pParameter->Cmp_Identifier(Prefix + "USER_XMAX")
1481 && !pParameter->Cmp_Identifier(Prefix + "USER_YMIN")
1482 && !pParameter->Cmp_Identifier(Prefix + "USER_YMAX")
1483 && !pParameter->Cmp_Identifier(Prefix + "USER_ROWS")
1484 && !pParameter->Cmp_Identifier(Prefix + "USER_COLS")
1485 && !pParameter->Cmp_Identifier(Prefix + "USER_FLAT")
1486 && !pParameter->Cmp_Identifier(Prefix + "USER_FITS") )
1487 {
1488 return( true );
1489 }
1490
1491 CSG_Parameter *pSize = (*pParameters)(Prefix + "USER_SIZE");
1492 CSG_Parameter *pXMin = (*pParameters)(Prefix + "USER_XMIN");
1493 CSG_Parameter *pXMax = (*pParameters)(Prefix + "USER_XMAX");
1494 CSG_Parameter *pYMin = (*pParameters)(Prefix + "USER_YMIN");
1495 CSG_Parameter *pYMax = (*pParameters)(Prefix + "USER_YMAX");
1496 CSG_Parameter *pRows = (*pParameters)(Prefix + "USER_ROWS");
1497 CSG_Parameter *pCols = (*pParameters)(Prefix + "USER_COLS");
1498 CSG_Parameter *pFlat = (*pParameters)(Prefix + "USER_FLAT");
1499 CSG_Parameter *pFits = (*pParameters)(Prefix + "USER_FITS");
1500
1501 double Size = pSize->asDouble();
1502
1503 double xMin = pXMin->asDouble(), xMax = pXMax->asDouble();
1504 double yMin = pYMin->asDouble(), yMax = pYMax->asDouble();
1505
1506 //-----------------------------------------------------
1507 bool bChanged = true;
1508
1509 if( pParameter->Cmp_Identifier(pFits->Get_Identifier()) )
1510 {
1511 if( pFits->asInt() == 0 ) // fit cells >> fit nodes
1512 {
1513 xMin += 0.5 * Size; xMax -= 0.5 * Size;
1514 yMin += 0.5 * Size; yMax -= 0.5 * Size;
1515 }
1516 }
1517 else
1518 {
1519 if( pFits->asInt() == 1 ) // fit cells >> fit nodes
1520 {
1521 xMin += 0.5 * Size; xMax -= 0.5 * Size;
1522 yMin += 0.5 * Size; yMax -= 0.5 * Size;
1523 }
1524
1525 if( pParameter->Cmp_Identifier(pSize->Get_Identifier()) && Size > 0. )
1526 {
1527 xMax = xMin + Size * (int)(0.5 + (xMax - xMin) / Size);
1528 yMax = yMin + Size * (int)(0.5 + (yMax - yMin) / Size);
1529 }
1530 else if( pParameter->Cmp_Identifier(pCols->Get_Identifier()) && pCols->asInt() > 0 )
1531 {
1532 xMax = xMin + Size * (pCols->asInt() - 1);
1533 }
1534 else if( pParameter->Cmp_Identifier(pXMin->Get_Identifier()) )
1535 {
1536 xMax = xMin + Size * (xMin > xMax ? (pCols->asInt() - 1) : (int)(0.5 + (xMax - xMin) / Size));
1537 }
1538 else if( pParameter->Cmp_Identifier(pXMax->Get_Identifier()) )
1539 {
1540 xMin = xMax - Size * (xMin > xMax ? (pCols->asInt() - 1) : (int)(0.5 + (xMax - xMin) / Size));
1541 }
1542 else if( pParameter->Cmp_Identifier(pRows->Get_Identifier()) && pRows->asInt() > 0 )
1543 {
1544 yMax = yMin + Size * (pRows->asInt() - 1);
1545 }
1546 else if( pParameter->Cmp_Identifier(pYMin->Get_Identifier()) )
1547 {
1548 yMax = yMin + Size * (yMin > yMax ? (pRows->asInt() - 1) : (int)(0.5 + (yMax - yMin) / Size));
1549 }
1550 else if( pParameter->Cmp_Identifier(pYMax->Get_Identifier()) )
1551 {
1552 yMin = yMax - Size * (yMin > yMax ? (pRows->asInt() - 1) : (int)(0.5 + (yMax - yMin) / Size));
1553 }
1554 else if( pParameter->Cmp_Identifier(pFlat->Get_Identifier()) )
1555 {
1556 bChanged = pFlat->asBool();
1557 }
1558 else
1559 {
1560 bChanged = false; // none of the relevant parameters did change so far
1561 }
1562 }
1563
1564 //-----------------------------------------------------
1565 if( bChanged )
1566 {
1567 if( (pParameter->Cmp_Identifier(pSize->Get_Identifier()) || pParameter->Cmp_Identifier(pFlat->Get_Identifier()))
1568 && pFlat->asBool() && !M_HAS_DECIMALS(Size) ) // rounding of bounds
1569 {
1570 xMin = floor(xMin / Size) * Size; xMax = ceil(xMax / Size) * Size;
1571 yMin = floor(yMin / Size) * Size; yMax = ceil(yMax / Size) * Size;
1572 }
1573
1574 pCols->Set_Value(1 + (int)((xMax - xMin) / Size));
1575 pRows->Set_Value(1 + (int)((yMax - yMin) / Size));
1576
1577 if( pFits->asInt() == 1 )
1578 {
1579 xMin -= 0.5 * Size; xMax += 0.5 * Size;
1580 yMin -= 0.5 * Size; yMax += 0.5 * Size;
1581 }
1582
1583 pXMin->Set_Value(xMin);
1584 pXMax->Set_Value(xMax);
1585 pYMin->Set_Value(yMin);
1586 pYMax->Set_Value(yMax);
1587
1588 return( true );
1589 }
1590
1591 //-----------------------------------------------------
1592 CSG_Parameter *pZSize = (*pParameters)(Prefix + "USER_ZSIZE");
1593 CSG_Parameter *pZMin = (*pParameters)(Prefix + "USER_ZMIN" );
1594 CSG_Parameter *pZMax = (*pParameters)(Prefix + "USER_ZMAX" );
1595 CSG_Parameter *pZNum = (*pParameters)(Prefix + "USER_ZNUM" );
1596
1597 if( pZSize && pZMin && pZMax && pZNum )
1598 {
1599 double zSize = pZSize->asDouble(), zMin = pZMin ->asDouble(), zMax = pZMax ->asDouble();
1600
1601 bChanged = true;
1602
1603 if ( pParameter->Cmp_Identifier(pZSize->Get_Identifier()) && zSize > 0. )
1604 {
1605 zMax = zMin + zSize * (int)(0.5 + (zMax - zMin) / zSize);
1606 }
1607 else if( pParameter->Cmp_Identifier(pZNum->Get_Identifier()) && pZNum->asInt() > 0 )
1608 {
1609 zMax = zMin + zSize * pZNum->asInt();
1610 }
1611 else if( pParameter->Cmp_Identifier(pZMin->Get_Identifier()) )
1612 {
1613 zMax = zMin + zSize * (zMin > zMax ? pZNum->asInt() : (int)(0.5 + (zMax - zMin) / zSize));
1614 }
1615 else if( pParameter->Cmp_Identifier(pZMax->Get_Identifier()) )
1616 {
1617 zMin = zMax - zSize * (zMin > zMax ? pZNum->asInt() : (int)(0.5 + (zMax - zMin) / zSize));
1618 }
1619 else
1620 {
1621 bChanged = false;
1622 }
1623
1624 if( bChanged )
1625 {
1626 pZNum->Set_Value(1 + (int)((zMax - zMin) / zSize));
1627
1628 pZMin->Set_Value(zMin);
1629 pZMax->Set_Value(zMax);
1630 }
1631 }
1632
1633 return( true );
1634}
1635
1636//---------------------------------------------------------
1638{
1639 return( pParameter && pParameters && m_pParameters && m_pParameters->Get_Identifier().Cmp(pParameters->Get_Identifier()) == 0
1640 && On_Parameters_Enable(pParameters, pParameter, m_Prefix)
1641 );
1642}
1643
1644//---------------------------------------------------------
1646{
1647 if( !pParameter || !pParameters || !(pParameter = (*pParameters)(Prefix + "DEFINITION")) )
1648 {
1649 return( false );
1650 }
1651
1652 pParameters->Set_Enabled(Prefix + "SYSTEM" , pParameter->asInt() == 1);
1653 pParameters->Set_Enabled(Prefix + "TEMPLATE" , pParameter->asInt() == 1);
1654
1655 pParameters->Set_Enabled(Prefix + "USER_SIZE", pParameter->asInt() == 0);
1656 pParameters->Set_Enabled(Prefix + "USER_XMIN", pParameter->asInt() == 0);
1657 pParameters->Set_Enabled(Prefix + "USER_XMAX", pParameter->asInt() == 0);
1658 pParameters->Set_Enabled(Prefix + "USER_YMIN", pParameter->asInt() == 0);
1659 pParameters->Set_Enabled(Prefix + "USER_YMAX", pParameter->asInt() == 0);
1660 pParameters->Set_Enabled(Prefix + "USER_ROWS", pParameter->asInt() == 0);
1661 pParameters->Set_Enabled(Prefix + "USER_COLS", pParameter->asInt() == 0);
1662 pParameters->Set_Enabled(Prefix + "USER_FLAT", pParameter->asInt() == 0);
1663 pParameters->Set_Enabled(Prefix + "USER_FITS", pParameter->asInt() == 0);
1664 pParameters->Set_Enabled(Prefix + "USER_OPTS", pParameter->asInt() == 0);
1665 pParameters->Set_Enabled(Prefix + "USER_Z" , pParameter->asInt() == 0);
1666
1667 return( true );
1668}
1669
1670
1672// //
1674
1675//---------------------------------------------------------
1684bool CSG_Parameters_Grid_Target::Set_User_Defined(CSG_Parameters *pParameters, const TSG_Rect &Extent, int Rows, int Rounding)
1685{
1686 if( !m_pParameters->Get_Tool() || !m_pParameters->Get_Tool()->has_GUI() ) // no cancel button, so set parameters directly
1687 {
1688 pParameters = m_pParameters;
1689 }
1690
1691 if( !m_pParameters || !pParameters || m_pParameters->Get_Identifier().Cmp(pParameters->Get_Identifier()) )
1692 {
1693 return( false );
1694 }
1695
1696 if( Rows < 1 && (Rows = (*m_pParameters)(m_Prefix + "USER_ROWS")->asInt()) < 1 )
1697 {
1698 Rows = 100;
1699 }
1700
1701 //-----------------------------------------------------
1702 CSG_Rect r(Extent);
1703
1704 if( r.Get_XRange() == 0. && r.Get_YRange() == 0. )
1705 {
1706 r.Inflate(0.5 * Rows, false); // assume cellsize = 1.
1707 }
1708 else if( r.Get_XRange() == 0. )
1709 {
1710 double d = 0.5 * r.Get_YRange() / Rows; r.xMin -= d; r.xMax += d; // inflate by half cellsize
1711 }
1712 else if( r.Get_YRange() == 0. )
1713 {
1714 double d = 0.5 * r.Get_XRange() / Rows; r.yMin -= d; r.yMax += d; // inflate by half cellsize
1715 }
1716
1717 //-----------------------------------------------------
1718 double Size = r.Get_YRange() / (Rows - 1);
1719
1720 int Cols = 1 + (int)(0.5 + r.Get_XRange() / Size);
1721
1722 if( Rounding > 0 ) // rounding of cell size!
1723 {
1724 Size = SG_Get_Rounded_To_SignificantFigures(Size, Rounding);
1725
1726 r.xMin = r.Get_XCenter() - Size * Cols / 2.;
1727 r.yMin = r.Get_YCenter() - Size * Rows / 2.;
1728 r.yMax = r.Get_YMin () + Size * (Rows - 1);
1729 }
1730
1731 r.xMax = r.Get_XMin() + Size * (Cols - 1);
1732
1733 //-----------------------------------------------------
1734 if( (*pParameters)(m_Prefix + "USER_FLAT")->asBool() && !M_HAS_DECIMALS(Size) ) // rounding of bounds
1735 {
1736 r.xMin = floor(r.xMin / Size) * Size; r.xMax = ceil(r.xMax / Size) * Size;
1737 r.yMin = floor(r.yMin / Size) * Size; r.yMax = ceil(r.yMax / Size) * Size;
1738 }
1739
1740 //-----------------------------------------------------
1741 if( (*pParameters)(m_Prefix + "USER_FITS")->asInt() == 1 ) // fit to cells
1742 {
1743 r.Inflate(0.5 * Size, false);
1744 }
1745
1746 bool bCallback = pParameters->Set_Callback(false);
1747
1748 pParameters->Set_Parameter(m_Prefix + "USER_SIZE", Size );
1749 pParameters->Set_Parameter(m_Prefix + "USER_XMIN", r.Get_XMin());
1750 pParameters->Set_Parameter(m_Prefix + "USER_XMAX", r.Get_XMax());
1751 pParameters->Set_Parameter(m_Prefix + "USER_YMIN", r.Get_YMin());
1752 pParameters->Set_Parameter(m_Prefix + "USER_YMAX", r.Get_YMax());
1753 pParameters->Set_Parameter(m_Prefix + "USER_COLS", Cols );
1754 pParameters->Set_Parameter(m_Prefix + "USER_ROWS", Rows );
1755
1756 pParameters->Set_Callback(bCallback);
1757
1758 return( true );
1759}
1760
1761//---------------------------------------------------------
1766bool CSG_Parameters_Grid_Target::Set_User_Defined(CSG_Parameters *pParameters, CSG_Shapes *pPoints, int Scale, int Rounding)
1767{
1768 if( !pPoints || pPoints->Get_Count() <= 0 || pPoints->Get_Extent().Get_Area() <= 0. )
1769 {
1770 return( false );
1771 }
1772
1773 CSG_Rect r(pPoints->Get_Extent());
1774
1775 double Size = sqrt(r.Get_Area() / pPoints->Get_Count()) / (Scale > 1 ? Scale : 1); // edge length of a square given as average area per point (cell size)
1776
1777 if( Size >= 1. && Rounding > 0 )
1778 {
1779 Size = SG_Get_Rounded_To_SignificantFigures(Size, Rounding);
1780
1781 r.xMin = Size * floor(r.xMin / Size);
1782 r.xMax = Size * ceil (r.xMax / Size);
1783 r.yMin = Size * floor(r.yMin / Size);
1784 r.yMax = Size * ceil (r.yMax / Size);
1785 }
1786
1787 int Rows = 1 + (int)(0.5 + r.Get_YRange() / Size);
1788
1789 return( Set_User_Defined(pParameters, r, Rows, 0) );
1790}
1791
1792//---------------------------------------------------------
1797{
1798 return( System.is_Valid() && Set_User_Defined(pParameters, System.Get_Extent(), System.Get_NY(), 0) );
1799}
1800
1801//---------------------------------------------------------
1805bool CSG_Parameters_Grid_Target::Set_User_Defined(CSG_Parameters *pParameters, double xMin, double yMin, double Cellsize, int nx, int ny)
1806{
1807 return( Set_User_Defined(pParameters, CSG_Grid_System(Cellsize, xMin, yMin, nx, ny)) );
1808}
1809
1810//---------------------------------------------------------
1814bool CSG_Parameters_Grid_Target::Set_User_Defined_ZLevels(CSG_Parameters *pParameters, double zMin, double zMax, int nLevels, int Rounding)
1815{
1816 if( !m_pParameters->Get_Tool()->has_GUI() ) // no cancel button, so set parameters directly
1817 {
1818 pParameters = m_pParameters;
1819 }
1820
1821 if( !m_pParameters || !pParameters || m_pParameters->Get_Identifier().Cmp(pParameters->Get_Identifier()) )
1822 {
1823 return( false );
1824 }
1825
1826 if( nLevels < 1 )
1827 {
1828 nLevels = 100;
1829 }
1830
1831 //-----------------------------------------------------
1832 if( zMin > zMax )
1833 {
1834 double z = zMin; zMin = zMax; zMax = z;
1835 }
1836
1837 if( zMax - zMin <= 0. )
1838 {
1839 zMin -= 0.5 * nLevels;
1840 zMax += 0.5 * nLevels; // assume cellsize = 1.
1841 }
1842
1843 //-----------------------------------------------------
1844 double Size = (zMax - zMin) / (nLevels - 1.);
1845
1846 if( Rounding > 0 )
1847 {
1848 Size = SG_Get_Rounded_To_SignificantFigures(Size, Rounding);
1849
1850 zMin = Size * floor(zMin / Size);
1851 zMax = Size * ceil (zMax / Size);
1852 }
1853
1854 //-----------------------------------------------------
1855 if( (*pParameters)(m_Prefix + "USER_FITS")->asInt() == 1 )
1856 {
1857 zMin -= 0.5 * Size;
1858 zMax += 0.5 * Size;
1859 }
1860
1861 bool bCallback = pParameters->Set_Callback(false);
1862
1863 pParameters->Set_Parameter(m_Prefix + "USER_ZSIZE", Size );
1864 pParameters->Set_Parameter(m_Prefix + "USER_ZMIN" , zMin );
1865 pParameters->Set_Parameter(m_Prefix + "USER_ZMAX" , zMax );
1866 pParameters->Set_Parameter(m_Prefix + "USER_ZNUM" , nLevels);
1867
1868 pParameters->Set_Callback(bCallback);
1869
1870 return( true );
1871}
1872
1873
1875// //
1877
1878//---------------------------------------------------------
1879bool CSG_Parameters_Grid_Target::Add_Grid(const CSG_String &Identifier, const CSG_String &Name, bool bOptional)
1880{
1881 if( !m_pParameters || Identifier.Length() == 0 || (*m_pParameters)(Identifier) != NULL )
1882 {
1883 return( false );
1884 }
1885
1886 CSG_Parameter *pTarget = (*m_pParameters)(m_Prefix + "DEFINITION");
1887 CSG_Parameter *pSystem = NULL;
1888
1889 for(int i=0; i<pTarget->Get_Children_Count() && !pSystem; i++)
1890 {
1891 if( pTarget->Get_Child(i)->Get_Type() == PARAMETER_TYPE_Grid_System )
1892 {
1893 pSystem = pTarget->Get_Child(i);
1894 }
1895 }
1896
1897 m_pParameters->Add_Grid(pSystem ? pSystem->Get_Identifier() : SG_T(""), Identifier, Name, _TL(""), bOptional ? PARAMETER_OUTPUT_OPTIONAL : PARAMETER_OUTPUT, false);
1898
1899 if( bOptional && m_pParameters->Get_Tool()->has_GUI() )
1900 {
1901 CSG_Parameter *pNode = (*m_pParameters)(m_Prefix + "USER_OPTS");
1902
1903 if( !pNode )
1904 {
1905 pNode = m_pParameters->Add_Node(pTarget->Get_Identifier(), m_Prefix + "USER_OPTS", _TL("Optional Target Grids"), _TL(""));
1906 }
1907
1908 m_pParameters->Add_Bool(pNode->Get_Identifier(), Identifier + "_CREATE", Name, _TL(""), false);
1909 }
1910
1911 return( true );
1912}
1913
1914//---------------------------------------------------------
1915bool CSG_Parameters_Grid_Target::Add_Grids(const CSG_String &Identifier, const CSG_String &Name, bool bOptional, bool bZLevels)
1916{
1917 if( !m_pParameters || Identifier.Length() == 0 || (*m_pParameters)(Identifier) != NULL )
1918 {
1919 return( false );
1920 }
1921
1922 CSG_Parameter *pTarget = (*m_pParameters)(m_Prefix + "DEFINITION");
1923 CSG_Parameter *pSystem = NULL;
1924
1925 for(int i=0; i<pTarget->Get_Children_Count() && !pSystem; i++)
1926 {
1927 if( pTarget->Get_Child(i)->Get_Type() == PARAMETER_TYPE_Grid_System )
1928 {
1929 pSystem = pTarget->Get_Child(i);
1930 }
1931 }
1932
1933 m_pParameters->Add_Grids(pSystem ? pSystem->Get_Identifier() : SG_T(""), Identifier, Name, _TL(""), bOptional ? PARAMETER_OUTPUT_OPTIONAL : PARAMETER_OUTPUT, false);
1934
1935 if( bOptional && m_pParameters->Get_Tool()->has_GUI() )
1936 {
1937 CSG_Parameter *pNode = (*m_pParameters)(m_Prefix + "USER_OPTS");
1938
1939 if( !pNode )
1940 {
1941 pNode = m_pParameters->Add_Node(pTarget->Get_Identifier(), m_Prefix + "USER_OPTS", _TL("Optional Target Grids"), _TL(""));
1942 }
1943
1944 m_pParameters->Add_Bool(pNode->Get_Identifier(), Identifier + "_CREATE", Name, _TL(""), false);
1945 }
1946
1947 if( bZLevels )
1948 {
1949 pTarget = m_pParameters->Add_Node(pTarget, "USER_Z", _TL("Z Levels"), _TL(""));
1950
1951 m_pParameters->Add_Double(pTarget, m_Prefix + "USER_ZSIZE", _TL("Cellsize"), _TL(""), 1., 0., true);
1952 m_pParameters->Add_Double(pTarget, m_Prefix + "USER_ZMIN" , _TL("Bottom" ), _TL(""), 0.);
1953 m_pParameters->Add_Double(pTarget, m_Prefix + "USER_ZMAX" , _TL("Top" ), _TL(""), 100.);
1954 m_pParameters->Add_Int (pTarget, m_Prefix + "USER_ZNUM" , _TL("Levels" ), _TL(""), 101, 1, true);
1955 }
1956
1957 return( true );
1958}
1959
1960
1962// //
1964
1965//---------------------------------------------------------
1967{
1968 return( Get_System(m_pParameters) );
1969}
1970
1971//---------------------------------------------------------
1973{
1974 CSG_Grid_System System;
1975
1976 if( pParameters && (*pParameters)(m_Prefix + "DEFINITION") )
1977 {
1978 if( (*pParameters)(m_Prefix + "DEFINITION")->asInt() == 0 ) // user defined
1979 {
1980 if( (*pParameters)(m_Prefix + "USER_SIZE")
1981 && (*pParameters)(m_Prefix + "USER_XMIN")
1982 && (*pParameters)(m_Prefix + "USER_YMIN")
1983 && (*pParameters)(m_Prefix + "USER_XMAX")
1984 && (*pParameters)(m_Prefix + "USER_YMAX")
1985 && (*pParameters)(m_Prefix + "USER_FITS") )
1986 {
1987 double Size = (*pParameters)(m_Prefix + "USER_SIZE")->asDouble();
1988
1989 CSG_Rect r(
1990 (*pParameters)(m_Prefix + "USER_XMIN")->asDouble(),
1991 (*pParameters)(m_Prefix + "USER_YMIN")->asDouble(),
1992 (*pParameters)(m_Prefix + "USER_XMAX")->asDouble(),
1993 (*pParameters)(m_Prefix + "USER_YMAX")->asDouble()
1994 );
1995
1996 if( (*pParameters)(m_Prefix + "USER_FITS")->asInt() == 1 )
1997 {
1998 r.Deflate(0.5 * Size, false);
1999 }
2000
2001 System.Assign(Size, r);
2002 }
2003 }
2004 else if( (*pParameters)(m_Prefix + "SYSTEM") )
2005 {
2006 CSG_Parameter *pParameter = (*pParameters)(m_Prefix + "SYSTEM");
2007
2008 if( pParameter->asGrid_System() )
2009 {
2010 System.Assign(*pParameter->asGrid_System());
2011 }
2012 }
2013 }
2014
2015 return( System );
2016}
2017
2018//---------------------------------------------------------
2020{
2021 if( !m_pParameters )
2022 {
2023 return( NULL );
2024 }
2025
2026 CSG_Parameter *pParameter = (*m_pParameters)(Identifier);
2027
2028 if( !pParameter || pParameter->Get_Type() != PARAMETER_TYPE_Grid )
2029 {
2030 return( NULL );
2031 }
2032
2033 CSG_Grid_System System(Get_System());
2034
2035 if( !System.is_Valid() )
2036 {
2037 return( NULL );
2038 }
2039
2040 CSG_Parameter *pSystem = pParameter->Get_Parent();
2041
2042 if( pSystem->asGrid_System() && !pSystem->asGrid_System()->is_Equal(System) )
2043 {
2044 pSystem->asGrid_System()->Create(System);
2045 }
2046
2047 CSG_Grid *pGrid = NULL;
2048
2049 if( (*m_pParameters)(m_Prefix + "DEFINITION")->asInt() == 0 && m_pParameters->Get_Tool()->has_GUI() )
2050 {
2051 if( (*m_pParameters)(Identifier + "_CREATE") == NULL
2052 || (*m_pParameters)(Identifier + "_CREATE")->asBool() )
2053 {
2054 pGrid = SG_Create_Grid(System, Type);
2055 }
2056 }
2057 else
2058 {
2059 pGrid = pParameter->asGrid();
2060
2061 if( pParameter->asDataObject() == DATAOBJECT_CREATE || (!pGrid && !pParameter->is_Optional()) )
2062 {
2063 pGrid = SG_Create_Grid(System, Type);
2064 }
2065 else if( pGrid && (pGrid->Get_Type() != Type || !pGrid->Get_System().is_Equal(System)) )
2066 {
2067 pGrid->Create(System, Type);
2068 }
2069 }
2070
2071 if( pGrid )
2072 {
2073 if( pGrid != pParameter->asGrid() )
2074 {
2075 pParameter->Set_Value(pGrid);
2076 }
2077
2078 if( m_pParameters->Get_Manager() )
2079 {
2080 m_pParameters->Get_Manager()->Add(pGrid);
2081
2082 if( m_pParameters->Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
2083 {
2085 }
2086 }
2087 }
2088
2089 return( pGrid );
2090}
2091
2092
2094// //
2096
2097//---------------------------------------------------------
2099{
2100 return( Get_Grid(m_Prefix + "OUT_GRID", Type) );
2101}
2102
2103//---------------------------------------------------------
2105{
2106 if( !m_pParameters )
2107 {
2108 return( NULL );
2109 }
2110
2111 CSG_Parameter *pParameter = (*m_pParameters)(Identifier);
2112
2113 if( !pParameter || pParameter->Get_Type() != PARAMETER_TYPE_Grids )
2114 {
2115 return( NULL );
2116 }
2117
2118 CSG_Grid_System System(Get_System());
2119
2120 if( !System.is_Valid() )
2121 {
2122 return( NULL );
2123 }
2124
2125 CSG_Parameter *pSystem = pParameter->Get_Parent();
2126
2127 if( pSystem->asGrid_System() && !pSystem->asGrid_System()->is_Equal(System) )
2128 {
2129 pSystem->asGrid_System()->Create(System);
2130 }
2131
2132 CSG_Grids *pGrids = NULL;
2133
2134 if( (*m_pParameters)(m_Prefix + "DEFINITION")->asInt() == 0 && m_pParameters->Get_Tool()->has_GUI() )
2135 {
2136 if( (*m_pParameters)(Identifier + "_CREATE") == NULL
2137 || (*m_pParameters)(Identifier + "_CREATE")->asBool() )
2138 {
2139 pGrids = SG_Create_Grids(System, 0, 0., Type);
2140 }
2141 }
2142 else
2143 {
2144 pGrids = pParameter->asGrids();
2145
2146 if( pParameter->asPointer() == DATAOBJECT_CREATE || (!pGrids && !pParameter->is_Optional()) )
2147 {
2148 pGrids = SG_Create_Grids(System, 0, 0., Type);
2149 }
2150 else if( pGrids && (pGrids->Get_Type() != Type || !pGrids->Get_System().is_Equal(System)) )
2151 {
2152 pGrids->Create(System, 0, 0., Type);
2153 }
2154 }
2155
2156 if( pGrids && pGrids != pParameter->asGrids() )
2157 {
2158 pParameter->Set_Value(pGrids);
2159
2160 if( m_pParameters->Get_Manager() )
2161 {
2162 m_pParameters->Get_Manager()->Add(pGrids);
2163
2164 if( m_pParameters->Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
2165 {
2167 }
2168 }
2169 }
2170
2171 //-----------------------------------------------------
2172 if( pGrids
2173 && (*m_pParameters)(m_Prefix + "USER_ZSIZE")
2174 && (*m_pParameters)(m_Prefix + "USER_ZMIN" )
2175 && (*m_pParameters)(m_Prefix + "USER_ZNUM" ) )
2176 {
2177 int nz = (*m_pParameters)(m_Prefix + "USER_ZNUM" )->asInt ();
2178 double z = (*m_pParameters)(m_Prefix + "USER_ZMIN" )->asDouble();
2179 double dz = (*m_pParameters)(m_Prefix + "USER_ZSIZE")->asDouble();
2180
2181 pGrids->Del_Grids();
2182
2183 for(int iz=0; iz<nz; iz++, z+=dz)
2184 {
2185 pGrids->Add_Grid(z);
2186 }
2187 }
2188
2189 return( pGrids );
2190}
2191
2192//---------------------------------------------------------
2194{
2195 return( Get_Grids(m_Prefix + "OUT_GRIDS", Type) );
2196}
2197
2198
2200// //
2201// //
2202// //
2204
2205//---------------------------------------------------------
bool SG_UI_DataObject_Add(CSG_Data_Object *pDataObject, int Show)
void SG_UI_Msg_Add_Execution(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
CSG_String SG_Data_Type_Get_Name(TSG_Data_Type Type, bool bShort)
Definition api_core.cpp:123
#define SG_T(s)
Definition api_core.h:537
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
@ SG_UI_DATAOBJECT_UPDATE
Definition api_core.h:1597
#define SG_STR_CMP(s1, s2)
Definition api_core.h:544
TSG_Data_Type
Definition api_core.h:997
#define SG_Char
Definition api_core.h:536
#define _TL(s)
Definition api_core.h:1568
long Get_Color(int Index) const
Definition api_core.h:1443
int Get_Count(void) const
Definition api_core.h:1431
CSG_Data_Collection & Grid(void) const
CSG_Data_Collection & Grids(void) const
virtual TSG_Data_Object_Type Get_ObjectType(void) const =0
Returns the object type as defined by TSG_Data_Object_Type. Used for run time type checking.
bool is_Equal(const CSG_Grid_System &System) const
bool Assign(const CSG_Grid_System &System)
const CSG_Rect & Get_Extent(bool bCells=false) const
Definition grid.h:262
int Get_NY(void) const
Definition grid.h:259
bool Create(const CSG_Grid_System &System, int Precision=-1)
bool is_Valid(void) const
bool Create(const CSG_Grid &Grid)
Definition grid.cpp:235
const CSG_Grid_System & Get_System(void) const
Definition grid.h:559
TSG_Data_Type Get_Type(void) const
Definition grid.h:547
TSG_Data_Type Get_Type(void) const
Definition grids.h:172
bool Del_Grids(bool bDetach=false)
Definition grids.cpp:891
const CSG_Grid_System & Get_System(void) const
Definition grids.h:184
virtual bool Create(const CSG_Grids &Grids)
Definition grids.cpp:319
bool Add_Grid(double Z)
Definition grids.cpp:726
bool Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase=false) const
Definition metadata.cpp:671
void Set_Content(const CSG_String &Content)
Definition metadata.h:140
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:166
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition metadata.cpp:559
const SG_Char * Get_Item(int Index) const
int Get_Count(void) const
Definition parameters.h:690
int Get_Selection_Count(void) const
Definition parameters.h:771
int Get_Item_Count(void) const
Definition parameters.h:767
const CSG_String & Get_Item(int i) const
Definition parameters.h:768
int Get_Selection_Index(int i) const
Definition parameters.h:774
virtual bool Update_Data(void)
virtual bool Del_Item(CSG_Data_Object *pItem, bool bUpdateData=true)
CSG_Data_Object * Get_Item(int Index) const
int Get_Item_Count(void) const
double Get_Max(void) const
double Get_Min(void) const
CSG_String Get_CmdID(void) const
const SG_Char * Get_Identifier(void) const
class CSG_Parameter_Table_List * asTableList(void) const
bool is_DataObject(void) const
virtual bool _Serialize(CSG_MetaData &MetaData, bool bSave)
CSG_Parameter(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
Definition parameter.cpp:64
class CSG_Parameters * asParameters(void) const
bool Check(bool bSilent=true)
void Set_UseInGUI(bool bOn=false)
CSG_Grid_Resampling asGrid_Resampling(void) const
const SG_Char * asFont(void) const
bool is_Value_Equal(CSG_Parameter *pParameter) const
bool Set_Name(const CSG_String &Name)
bool Assign(CSG_Parameter *pSource)
class CSG_Parameter_TIN_List * asTINList(void) const
bool is_Compatible(CSG_Parameter *pParameter) const
class CSG_Parameter_PointCloud_List * asPointCloudList(void) const
void * asPointer(void) const
Definition parameters.h:291
CSG_Grids * asGrids(void) const
class CSG_Parameter_Table_Fields * asTableFields(void) const
virtual bool _Assign(CSG_Parameter *pSource)
bool is_Parameters(void) const
virtual int _Set_Value(int Value)
CSG_String Get_Type_Identifier(void) const
friend class CSG_Parameters
Definition parameters.h:332
class CSG_Parameter_Shapes_List * asShapesList(void) const
CSG_String Get_Type_Name(void) const
class CSG_Parameter_Grids_List * asGridsList(void) const
bool Set_Default(int Value)
virtual const SG_Char * _asString(void) const
bool Set_Collapsed(bool bOn=true)
bool Set_Children_Enabled(bool bEnabled=true)
CSG_PointCloud * asPointCloud(void) const
bool Set_Enabled(bool bEnabled=true)
bool is_Optional(void) const
Definition parameters.h:238
TSG_Data_Object_Type Get_DataObject_Type(void) const
bool Set_Description(const CSG_String &Description)
virtual int _asInt(void) const
bool Serialize(CSG_MetaData &MetaData, bool bSave)
virtual ~CSG_Parameter(void)
Definition parameter.cpp:86
int Get_Children_Count(void) const
Definition parameters.h:259
CSG_String m_String
Definition parameters.h:337
class CSG_Parameter_Choice * asChoice(void) const
bool ignore_Projection(void) const
Definition parameters.h:255
class CSG_Parameter_Value * asValue(void) const
double asDouble(void) const
Definition parameters.h:289
CSG_Parameter * Get_Parent(void) const
virtual TSG_Parameter_Type Get_Type(void) const =0
class CSG_Parameter_Data_Type * asDataType(void) const
bool asBool(void) const
Definition parameters.h:286
bool is_Input(void) const
Definition parameters.h:236
CSG_TIN * asTIN(void) const
CSG_Parameters * Get_Parameters(void) const
virtual bool Toggle_Value(void)
bool is_Serializable(void) const
const SG_Char * Get_Name(void) const
class CSG_Parameter_Choices * asChoices(void) const
void Set_UseInCMD(bool bOn=false)
virtual void _Set_String(void)
CSG_Colors * asColors(void) const
bool is_Enabled(bool bCheckEnv=true) const
bool is_Option(void) const
virtual double _asDouble(void) const
CSG_Grid * asGrid(void) const
virtual bool Set_Value(int Value)
class CSG_Parameter_List * asList(void) const
CSG_Grid_System * asGrid_System(void) const
class CSG_Parameter_Grid_List * asGridList(void) const
CSG_Data_Object * asDataObject(void) const
class CSG_Parameter_Range * asRange(void) const
class CSG_Parameter_Date * asDate(void) const
CSG_Parameter * Get_Child(int iChild) const
Definition parameters.h:260
bool is_Output(void) const
Definition parameters.h:237
bool has_Changed(int Check_Flags=PARAMETER_CHECK_ALL)
class CSG_Parameter_File_Name * asFilePath(void) const
virtual void * _asPointer(void) const
virtual bool is_Default(void) const
CSG_Shapes * asShapes(void) const
bool is_Information(void) const
Definition parameters.h:239
bool do_UseInCMD(void) const
const SG_Char * asString(void) const
Definition parameters.h:290
const CSG_String & Get_Default(void) const
bool Cmp_Identifier(const CSG_String &Identifier) const
CSG_Table * asTable(void) const
bool is_Collapsed(void) const
Definition parameters.h:233
const SG_Char * Get_Description(void) const
bool do_UseInGUI(void) const
bool is_DataObject_List(void) const
int asInt(void) const
Definition parameters.h:287
virtual bool Restore_Default(void)
class CSG_Data_Manager * Get_Manager(void) const
bool Create(CSG_Parameters &Parameters, const CSG_String &ParentID="")
static bool On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
bool Activate_GUI(bool bReset=false)
bool Get_CRS(CSG_Projection &Projection, bool bMessage=false) const
static bool On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
bool Set_User_Defined_ZLevels(CSG_Parameters *pParameters, double zMin, double zMax, int nLevels, int Rounding=2)
bool On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
bool Create(CSG_Parameters *pParameters, bool bAddDefaultGrid, CSG_Parameter *pParent, const CSG_String &Prefix="")
bool Add_Grid(const CSG_String &ID, const CSG_String &Name, bool bOptional)
bool Set_User_Defined(CSG_Parameters *pParameters, const TSG_Rect &Extent, int Rows=0, int Rounding=2)
bool On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
bool Add_Grids(const CSG_String &ID, const CSG_String &Name, bool bOptional, bool bZLevels=false)
CSG_Grid_System Get_System(void) const
CSG_Grids * Get_Grids(const CSG_String &ID, TSG_Data_Type Type=SG_DATATYPE_Float)
CSG_Grid * Get_Grid(const CSG_String &ID, TSG_Data_Type Type=SG_DATATYPE_Float)
bool Set_Callback(bool bActive=true)
const CSG_String & Get_Identifier(void) const
int Get_Count(void) const
void Set_Enabled(bool bEnabled=true)
CSG_Parameter * Get_Parameter(int i) const
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
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)
bool Cmp_Identifier(const CSG_String &Identifier) const
double Get_Area(void) const
Definition geo_tools.h:513
double Get_YRange(void) const
Definition geo_tools.h:511
CSG_Rect & Inflate(double d, bool bPercent=true)
CSG_Rect & Deflate(double d, bool bPercent=true)
double Get_YCenter(void) const
Definition geo_tools.h:521
double Get_XMax(void) const
Definition geo_tools.h:506
double Get_XRange(void) const
Definition geo_tools.h:510
double Get_XMin(void) const
Definition geo_tools.h:505
double Get_YMin(void) const
Definition geo_tools.h:507
double Get_XCenter(void) const
Definition geo_tools.h:520
double Get_YMax(void) const
Definition geo_tools.h:508
virtual const CSG_Rect & Get_Extent(void)
Definition shapes.h:810
size_t Length(void) const
int Cmp(const CSG_String &String) const
size_t Replace(const CSG_String &Old, const CSG_String &New, bool bReplaceAll=true)
static CSG_String Format(const char *Format,...)
Definition tin.h:222
const SG_Char * asString(int Field, int Decimals=-99) const
sLong Get_Count(void) const
Definition table.h:400
bool is_Compatible(const CSG_Table &Table, bool bExactMatch=false) const
Definition table.cpp:413
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition table.h:402
int Get_Field_Count(void) const
Definition table.h:361
bool Delete_Tool(CSG_Tool *pTool) const
CSG_Tool * Create_Tool(const CSG_String &Library, int Index, bool bWithGUI=false, bool bWithCMD=true) const
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
Definition tool.cpp:1284
CSG_Data_Manager & SG_Get_Data_Manager(void)
CSG_String SG_Get_DataObject_Name(TSG_Data_Object_Type Type)
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_Undefined
Definition dataobject.h:124
@ SG_DATAOBJECT_TYPE_PointCloud
Definition dataobject.h:123
@ SG_DATAOBJECT_TYPE_Grids
Definition dataobject.h:119
@ SG_DATAOBJECT_TYPE_TIN
Definition dataobject.h:122
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
@ SG_DATAOBJECT_TYPE_Grid
Definition dataobject.h:118
@ SG_DATAOBJECT_TYPE_Table
Definition dataobject.h:120
#define DATAOBJECT_NOTSET
Definition dataobject.h:129
#define DATAOBJECT_CREATE
Definition dataobject.h:130
struct SSG_Rect TSG_Rect
CSG_Grid * SG_Create_Grid(void)
Definition grid.cpp:72
CSG_Grid_Resampling
Definition grid.h:156
CSG_Grids * SG_Create_Grids(void)
Definition grids.cpp:65
double SG_Get_Rounded_To_SignificantFigures(double Value, int Decimals)
#define M_HAS_DECIMALS(x)
Definition mat_tools.h:147
#define SEPARATE
#define PARAMETER_NOT_FOR_GUI
Definition parameters.h:99
SAGA_API_DLL_EXPORT CSG_String SG_Parameter_Type_Get_Name(TSG_Parameter_Type Type)
SAGA_API_DLL_EXPORT CSG_String SG_Parameter_Type_Get_Identifier(TSG_Parameter_Type Type)
#define PARAMETER_DESCRIPTION_PROPERTIES
Definition parameters.h:110
#define PARAMETER_NOT_FOR_CMD
Definition parameters.h:100
#define PARAMETER_INPUT_OPTIONAL
Definition parameters.h:103
#define PARAMETER_DESCRIPTION_TYPE
Definition parameters.h:108
#define PARAMETER_DESCRIPTION_OPTIONAL
Definition parameters.h:109
#define PARAMETER_IGNORE_PROJECTION
Definition parameters.h:98
#define PARAMETER_OUTPUT_OPTIONAL
Definition parameters.h:104
#define SG_PARAMETER_DATA_SET_FALSE
Definition parameters.h:195
#define PARAMETER_GUI_COLLAPSED
Definition parameters.h:101
#define PARAMETER_DESCRIPTION_NAME
Definition parameters.h:107
#define SG_PARAMETER_DATA_SET_CHANGED
Definition parameters.h:197
@ PARAMETER_TYPE_Degree
Definition parameters.h:129
@ PARAMETER_TYPE_FixedTable
Definition parameters.h:142
@ PARAMETER_TYPE_Node
Definition parameters.h:124
@ PARAMETER_TYPE_Grid
Definition parameters.h:149
@ PARAMETER_TYPE_Grid_List
Definition parameters.h:155
@ PARAMETER_TYPE_Text
Definition parameters.h:136
@ PARAMETER_TYPE_TIN
Definition parameters.h:153
@ PARAMETER_TYPE_Table
Definition parameters.h:151
@ PARAMETER_TYPE_Int
Definition parameters.h:127
@ PARAMETER_TYPE_Table_Fields
Definition parameters.h:146
@ PARAMETER_TYPE_Grids
Definition parameters.h:150
@ PARAMETER_TYPE_Color
Definition parameters.h:140
@ PARAMETER_TYPE_Colors
Definition parameters.h:141
@ PARAMETER_TYPE_DataObject_Output
Definition parameters.h:162
@ PARAMETER_TYPE_Table_List
Definition parameters.h:157
@ PARAMETER_TYPE_Double
Definition parameters.h:128
@ PARAMETER_TYPE_TIN_List
Definition parameters.h:159
@ PARAMETER_TYPE_Grid_System
Definition parameters.h:144
@ PARAMETER_TYPE_Font
Definition parameters.h:139
@ PARAMETER_TYPE_Date
Definition parameters.h:130
@ PARAMETER_TYPE_PointCloud_List
Definition parameters.h:160
@ PARAMETER_TYPE_Choices
Definition parameters.h:134
@ PARAMETER_TYPE_Undefined
Definition parameters.h:166
@ PARAMETER_TYPE_Data_Type
Definition parameters.h:132
@ PARAMETER_TYPE_Shapes
Definition parameters.h:152
@ PARAMETER_TYPE_Shapes_List
Definition parameters.h:158
@ PARAMETER_TYPE_Range
Definition parameters.h:131
@ PARAMETER_TYPE_PointCloud
Definition parameters.h:148
@ PARAMETER_TYPE_Table_Field
Definition parameters.h:145
@ PARAMETER_TYPE_Parameters
Definition parameters.h:164
@ PARAMETER_TYPE_FilePath
Definition parameters.h:137
@ PARAMETER_TYPE_Bool
Definition parameters.h:126
@ PARAMETER_TYPE_Grids_List
Definition parameters.h:156
@ PARAMETER_TYPE_String
Definition parameters.h:135
@ PARAMETER_TYPE_Choice
Definition parameters.h:133
#define PARAMETER_OUTPUT
Definition parameters.h:95
#define PARAMETER_DESCRIPTION_TEXT
Definition parameters.h:111
double xMin
Definition geo_tools.h:468
double xMax
Definition geo_tools.h:468
double yMin
Definition geo_tools.h:468
double yMax
Definition geo_tools.h:468
CSG_Tool_Library_Manager & SG_Get_Tool_Library_Manager(void)