SAGA API Version 9.14
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 = SG_Get_String(Value, -12);
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
1169
1170//---------------------------------------------------------
1178
1179
1181// //
1183
1184//---------------------------------------------------------
1185void CSG_Parameter::_Add_Child(CSG_Parameter *pChild)
1186{
1187 m_Children = (CSG_Parameter **)SG_Realloc(m_Children, (m_nChildren + 1) * sizeof(CSG_Parameter *));
1188 m_Children[m_nChildren++] = pChild;
1189}
1190
1191
1193// //
1195
1196//---------------------------------------------------------
1198{
1199 if( pSource && Get_Type() == pSource->Get_Type() )
1200 {
1201 m_bEnabled = pSource->m_bEnabled;
1202 m_Default = pSource->m_Default;
1203
1204 Set_Collapsed(pSource->is_Collapsed());
1205
1206 if( _Assign(pSource) )
1207 {
1208 _Set_String();
1209
1210 return( true );
1211 }
1212 }
1213
1214 return( false );
1215}
1216
1218{
1219 return( true );
1220}
1221
1222//---------------------------------------------------------
1223bool CSG_Parameter::Serialize(CSG_MetaData &MetaData, bool bSave)
1224{
1225 if( bSave )
1226 {
1228 {
1229 return( true );
1230 }
1231
1232 CSG_MetaData &Child = *MetaData.Add_Child(
1233 is_Option () ? "OPTION" :
1234 is_DataObject () ? "DATA" :
1235 is_DataObject_List() ? "DATA_LIST" : "PARAMETER"
1236 );
1237
1238 Child.Add_Property("type" , Get_Type_Identifier ());
1239 Child.Add_Property("id" , Get_Identifier ());
1240 Child.Add_Property("name" , Get_Name ());
1241 Child.Add_Property("parms", Get_Parameters()->Get_Identifier());
1242
1243 _Serialize(Child, bSave);
1244
1245 return( true );
1246 }
1247 else if( MetaData.Cmp_Property("type", Get_Type_Identifier())
1248 && MetaData.Cmp_Property("id" , Get_Identifier ())
1249 && _Serialize(MetaData, bSave) )
1250 {
1251 _Set_String();
1252
1253 return( true );
1254 }
1255
1256 return( false );
1257}
1258
1260{
1261 Entry.Set_Content("-");
1262
1263 return( true );
1264}
1265
1266
1268// //
1269// Coordinate System Reference Picker //
1270// //
1272
1273//---------------------------------------------------------
1278
1279//---------------------------------------------------------
1281{
1282 m_pParameters = &Parameters;
1283
1284 Parameters.Add_String(ParentID, "CRS_STRING", _TL("Coordinate System Definition"),
1285 _TL("Supported formats comprise PROJ and WKT strings, object codes (e.g. \"EPSG:4326\")."), ""
1286 )->Set_UseInGUI(false);
1287
1288 return( true );
1289}
1290
1291
1293// //
1295
1296//---------------------------------------------------------
1298{
1299 if( !m_pParameters || !m_pParameters->has_GUI() || m_pCRS )
1300 {
1301 return( false );
1302 }
1303
1304 m_pCRS = SG_Get_Tool_Library_Manager().Create_Tool("pj_proj4", 15, true); // CCRS_Picker
1305
1306 if( !m_pCRS )
1307 {
1308 return( false );
1309 }
1310
1311 m_pCRS->Set_Parameter("CRS_STRING", (*m_pParameters)["CRS_STRING"].asString());
1312
1313 m_pParameters->Add_Parameters((*m_pParameters)("CRS_STRING")->Get_Parent(),
1314 "CRS_PICKER", _TL("Coordinate Reference System"), _TL("")
1315 )->asParameters()->Create(*m_pCRS->Get_Parameters());
1316
1317 return( true );
1318}
1319
1320//---------------------------------------------------------
1322{
1323 if( m_pCRS )
1324 {
1325 m_pParameters->Del_Parameter("CRS_PICKER");
1326
1328
1329 m_pCRS = NULL;
1330
1331 return( true );
1332 }
1333
1334 return( false );
1335}
1336
1337
1339// //
1341
1342//---------------------------------------------------------
1344{
1345 if( pParameter->Cmp_Identifier("CRS_PICKER") )
1346 {
1347 pParameters->Set_Parameter("CRS_STRING", (*pParameter->asParameters())("CRS_WKT")->asString());
1348 }
1349
1350 return( true );
1351}
1352
1353//---------------------------------------------------------
1355{
1356 return( true );
1357}
1358
1359
1361// //
1363
1364//---------------------------------------------------------
1366{
1367 if( Projection.Create((*m_pParameters)["CRS_STRING"].asString()) )
1368 {
1369 if( bMessage )
1370 {
1371 SG_UI_Msg_Add_Execution(CSG_String::Format("\n%s: %s\n", _TL("CRS"), Projection.Get_PROJ().c_str()), false);
1372 }
1373
1374 return( true );
1375 }
1376
1377 if( bMessage )
1378 {
1379 SG_UI_Msg_Add_Execution(CSG_String::Format("\n%s: %s\n", _TL("Warning"), _TL("undefined coordinate reference system")), false);
1380 }
1381
1382 return( false );
1383}
1384
1385
1387// //
1388// Grid Target Selector //
1389// //
1391
1392//---------------------------------------------------------
1394{
1395 m_pParameters = NULL;
1396}
1397
1398//---------------------------------------------------------
1399bool CSG_Parameters_Grid_Target::Create(CSG_Parameters *pParameters, bool bAddDefaultGrid, CSG_Parameter *pParent, const CSG_String &Prefix)
1400{
1401 return( Create(pParameters, bAddDefaultGrid, pParent ? pParent->Get_Identifier() : SG_T(""), Prefix) );
1402}
1403
1404bool CSG_Parameters_Grid_Target::Create(CSG_Parameters *pParameters, bool bAddDefaultGrid, const CSG_String &ParentID, const CSG_String &Prefix)
1405{
1406 if( pParameters == NULL )
1407 {
1408 return( false );
1409 }
1410
1411 m_pParameters = pParameters;
1412 m_Prefix = Prefix;
1413
1414 //-----------------------------------------------------
1415 CSG_String TargetID(m_Prefix + "DEFINITION");
1416
1417 m_pParameters->Add_Choice(
1418 ParentID, TargetID, _TL("Target Grid System"),
1419 _TL(""),
1420 CSG_String::Format("%s|%s",
1421 _TL("user defined"),
1422 _TL("grid or grid system")
1423 ), 0
1424 );
1425
1426 //-----------------------------------------------------
1427 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_SIZE", _TL("Cellsize"), _TL(""), 1., 0., true);
1428 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_XMIN", _TL("West" ), _TL(""), 0.);
1429 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_XMAX", _TL("East" ), _TL(""), 100.);
1430 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_YMIN", _TL("South" ), _TL(""), 0.);
1431 m_pParameters->Add_Double(TargetID, m_Prefix + "USER_YMAX", _TL("North" ), _TL(""), 100.);
1432 m_pParameters->Add_Int (TargetID, m_Prefix + "USER_COLS", _TL("Columns" ), _TL("Number of cells in East-West direction." ), 101, 1, true);
1433 m_pParameters->Add_Int (TargetID, m_Prefix + "USER_ROWS", _TL("Rows" ), _TL("Number of cells in North-South direction."), 101, 1, true);
1434 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);
1435 m_pParameters->Add_Choice(TargetID, m_Prefix + "USER_FITS", _TL("Fit" ), _TL(""),
1436 CSG_String::Format("%s|%s",
1437 _TL("nodes"),
1438 _TL("cells")
1439 ), 0
1440 );
1441
1442 //-----------------------------------------------------
1443 m_pParameters->Add_Grid_System(TargetID, m_Prefix + "SYSTEM", _TL("Grid System"), _TL(""));
1444
1445 m_pParameters->Add_Grid(m_Prefix + "SYSTEM", m_Prefix + "TEMPLATE", _TL("Target System"),
1446 _TL("use this grid's system for output grids"), PARAMETER_INPUT_OPTIONAL, false
1447 )->Set_UseInGUI(false);
1448
1449 //-----------------------------------------------------
1450 if( bAddDefaultGrid )
1451 {
1452 Add_Grid(m_Prefix + "OUT_GRID", _TL("Target Grid"), false);
1453 }
1454
1455 return( true );
1456}
1457
1458
1460// //
1462
1463//---------------------------------------------------------
1465{
1466 return( pParameter && pParameters && m_pParameters && m_pParameters->Cmp_Identifier(pParameters->Get_Identifier())
1467 && On_Parameter_Changed(pParameters, pParameter, m_Prefix)
1468 );
1469}
1470
1471//---------------------------------------------------------
1473{
1474 if( !pParameters || !pParameter )
1475 {
1476 return( false );
1477 }
1478
1479 if( !pParameter->Cmp_Identifier(Prefix + "USER_SIZE")
1480 && !pParameter->Cmp_Identifier(Prefix + "USER_XMIN")
1481 && !pParameter->Cmp_Identifier(Prefix + "USER_XMAX")
1482 && !pParameter->Cmp_Identifier(Prefix + "USER_YMIN")
1483 && !pParameter->Cmp_Identifier(Prefix + "USER_YMAX")
1484 && !pParameter->Cmp_Identifier(Prefix + "USER_ROWS")
1485 && !pParameter->Cmp_Identifier(Prefix + "USER_COLS")
1486 && !pParameter->Cmp_Identifier(Prefix + "USER_FLAT")
1487 && !pParameter->Cmp_Identifier(Prefix + "USER_FITS") )
1488 {
1489 return( true );
1490 }
1491
1492 CSG_Parameter *pSize = (*pParameters)(Prefix + "USER_SIZE");
1493 CSG_Parameter *pXMin = (*pParameters)(Prefix + "USER_XMIN");
1494 CSG_Parameter *pXMax = (*pParameters)(Prefix + "USER_XMAX");
1495 CSG_Parameter *pYMin = (*pParameters)(Prefix + "USER_YMIN");
1496 CSG_Parameter *pYMax = (*pParameters)(Prefix + "USER_YMAX");
1497 CSG_Parameter *pRows = (*pParameters)(Prefix + "USER_ROWS");
1498 CSG_Parameter *pCols = (*pParameters)(Prefix + "USER_COLS");
1499 CSG_Parameter *pFlat = (*pParameters)(Prefix + "USER_FLAT");
1500 CSG_Parameter *pFits = (*pParameters)(Prefix + "USER_FITS");
1501
1502 double Size = pSize->asDouble();
1503
1504 double xMin = pXMin->asDouble(), xMax = pXMax->asDouble();
1505 double yMin = pYMin->asDouble(), yMax = pYMax->asDouble();
1506
1507 //-----------------------------------------------------
1508 bool bChanged = true;
1509
1510 if( pParameter->Cmp_Identifier(pFits->Get_Identifier()) )
1511 {
1512 if( pFits->asInt() == 0 ) // fit cells >> fit nodes
1513 {
1514 xMin += 0.5 * Size; xMax -= 0.5 * Size;
1515 yMin += 0.5 * Size; yMax -= 0.5 * Size;
1516 }
1517 }
1518 else
1519 {
1520 if( pFits->asInt() == 1 ) // fit cells >> fit nodes
1521 {
1522 xMin += 0.5 * Size; xMax -= 0.5 * Size;
1523 yMin += 0.5 * Size; yMax -= 0.5 * Size;
1524 }
1525
1526 if( pParameter->Cmp_Identifier(pSize->Get_Identifier()) && Size > 0. )
1527 {
1528 xMax = xMin + Size * (int)(0.5 + (xMax - xMin) / Size);
1529 yMax = yMin + Size * (int)(0.5 + (yMax - yMin) / Size);
1530 }
1531 else if( pParameter->Cmp_Identifier(pCols->Get_Identifier()) && pCols->asInt() > 0 )
1532 {
1533 xMax = xMin + Size * (pCols->asInt() - 1);
1534 }
1535 else if( pParameter->Cmp_Identifier(pXMin->Get_Identifier()) )
1536 {
1537 xMax = xMin + Size * (xMin > xMax ? (pCols->asInt() - 1) : (int)(0.5 + (xMax - xMin) / Size));
1538 }
1539 else if( pParameter->Cmp_Identifier(pXMax->Get_Identifier()) )
1540 {
1541 xMin = xMax - Size * (xMin > xMax ? (pCols->asInt() - 1) : (int)(0.5 + (xMax - xMin) / Size));
1542 }
1543 else if( pParameter->Cmp_Identifier(pRows->Get_Identifier()) && pRows->asInt() > 0 )
1544 {
1545 yMax = yMin + Size * (pRows->asInt() - 1);
1546 }
1547 else if( pParameter->Cmp_Identifier(pYMin->Get_Identifier()) )
1548 {
1549 yMax = yMin + Size * (yMin > yMax ? (pRows->asInt() - 1) : (int)(0.5 + (yMax - yMin) / Size));
1550 }
1551 else if( pParameter->Cmp_Identifier(pYMax->Get_Identifier()) )
1552 {
1553 yMin = yMax - Size * (yMin > yMax ? (pRows->asInt() - 1) : (int)(0.5 + (yMax - yMin) / Size));
1554 }
1555 else if( pParameter->Cmp_Identifier(pFlat->Get_Identifier()) )
1556 {
1557 bChanged = pFlat->asBool();
1558 }
1559 else
1560 {
1561 bChanged = false; // none of the relevant parameters did change so far
1562 }
1563 }
1564
1565 //-----------------------------------------------------
1566 if( bChanged )
1567 {
1568 if( (pParameter->Cmp_Identifier(pSize->Get_Identifier()) || pParameter->Cmp_Identifier(pFlat->Get_Identifier()))
1569 && pFlat->asBool() && !M_HAS_DECIMALS(Size) ) // rounding of bounds
1570 {
1571 xMin = floor(xMin / Size) * Size; xMax = ceil(xMax / Size) * Size;
1572 yMin = floor(yMin / Size) * Size; yMax = ceil(yMax / Size) * Size;
1573 }
1574
1575 pCols->Set_Value(1 + (int)((xMax - xMin) / Size));
1576 pRows->Set_Value(1 + (int)((yMax - yMin) / Size));
1577
1578 if( pFits->asInt() == 1 )
1579 {
1580 xMin -= 0.5 * Size; xMax += 0.5 * Size;
1581 yMin -= 0.5 * Size; yMax += 0.5 * Size;
1582 }
1583
1584 pXMin->Set_Value(xMin);
1585 pXMax->Set_Value(xMax);
1586 pYMin->Set_Value(yMin);
1587 pYMax->Set_Value(yMax);
1588
1589 return( true );
1590 }
1591
1592 //-----------------------------------------------------
1593 CSG_Parameter *pZSize = (*pParameters)(Prefix + "USER_ZSIZE");
1594 CSG_Parameter *pZMin = (*pParameters)(Prefix + "USER_ZMIN" );
1595 CSG_Parameter *pZMax = (*pParameters)(Prefix + "USER_ZMAX" );
1596 CSG_Parameter *pZNum = (*pParameters)(Prefix + "USER_ZNUM" );
1597
1598 if( pZSize && pZMin && pZMax && pZNum )
1599 {
1600 double zSize = pZSize->asDouble(), zMin = pZMin ->asDouble(), zMax = pZMax ->asDouble();
1601
1602 bChanged = true;
1603
1604 if ( pParameter->Cmp_Identifier(pZSize->Get_Identifier()) && zSize > 0. )
1605 {
1606 zMax = zMin + zSize * (int)(0.5 + (zMax - zMin) / zSize);
1607 }
1608 else if( pParameter->Cmp_Identifier(pZNum->Get_Identifier()) && pZNum->asInt() > 0 )
1609 {
1610 zMax = zMin + zSize * pZNum->asInt();
1611 }
1612 else if( pParameter->Cmp_Identifier(pZMin->Get_Identifier()) )
1613 {
1614 zMax = zMin + zSize * (zMin > zMax ? pZNum->asInt() : (int)(0.5 + (zMax - zMin) / zSize));
1615 }
1616 else if( pParameter->Cmp_Identifier(pZMax->Get_Identifier()) )
1617 {
1618 zMin = zMax - zSize * (zMin > zMax ? pZNum->asInt() : (int)(0.5 + (zMax - zMin) / zSize));
1619 }
1620 else
1621 {
1622 bChanged = false;
1623 }
1624
1625 if( bChanged )
1626 {
1627 pZNum->Set_Value(1 + (int)((zMax - zMin) / zSize));
1628
1629 pZMin->Set_Value(zMin);
1630 pZMax->Set_Value(zMax);
1631 }
1632 }
1633
1634 return( true );
1635}
1636
1637//---------------------------------------------------------
1639{
1640 return( pParameter && pParameters && m_pParameters && m_pParameters->Get_Identifier().Cmp(pParameters->Get_Identifier()) == 0
1641 && On_Parameters_Enable(pParameters, pParameter, m_Prefix)
1642 );
1643}
1644
1645//---------------------------------------------------------
1647{
1648 if( !pParameter || !pParameters || !(pParameter = (*pParameters)(Prefix + "DEFINITION")) )
1649 {
1650 return( false );
1651 }
1652
1653 pParameters->Set_Enabled(Prefix + "SYSTEM" , pParameter->asInt() == 1);
1654 pParameters->Set_Enabled(Prefix + "TEMPLATE" , pParameter->asInt() == 1);
1655
1656 pParameters->Set_Enabled(Prefix + "USER_SIZE", pParameter->asInt() == 0);
1657 pParameters->Set_Enabled(Prefix + "USER_XMIN", pParameter->asInt() == 0);
1658 pParameters->Set_Enabled(Prefix + "USER_XMAX", pParameter->asInt() == 0);
1659 pParameters->Set_Enabled(Prefix + "USER_YMIN", pParameter->asInt() == 0);
1660 pParameters->Set_Enabled(Prefix + "USER_YMAX", pParameter->asInt() == 0);
1661 pParameters->Set_Enabled(Prefix + "USER_ROWS", pParameter->asInt() == 0);
1662 pParameters->Set_Enabled(Prefix + "USER_COLS", pParameter->asInt() == 0);
1663 pParameters->Set_Enabled(Prefix + "USER_FLAT", pParameter->asInt() == 0);
1664 pParameters->Set_Enabled(Prefix + "USER_FITS", pParameter->asInt() == 0);
1665 pParameters->Set_Enabled(Prefix + "USER_OPTS", pParameter->asInt() == 0);
1666 pParameters->Set_Enabled(Prefix + "USER_Z" , pParameter->asInt() == 0);
1667
1668 return( true );
1669}
1670
1671
1673// //
1675
1676//---------------------------------------------------------
1685bool CSG_Parameters_Grid_Target::Set_User_Defined(CSG_Parameters *pParameters, const TSG_Rect &Extent, int Rows, int Rounding)
1686{
1687 if( !m_pParameters->Get_Tool() || !m_pParameters->Get_Tool()->has_GUI() ) // no cancel button, so set parameters directly
1688 {
1689 pParameters = m_pParameters;
1690 }
1691
1692 if( !m_pParameters || !pParameters || m_pParameters->Get_Identifier().Cmp(pParameters->Get_Identifier()) )
1693 {
1694 return( false );
1695 }
1696
1697 if( Rows < 1 && (Rows = (*m_pParameters)(m_Prefix + "USER_ROWS")->asInt()) < 1 )
1698 {
1699 Rows = 100;
1700 }
1701
1702 //-----------------------------------------------------
1703 CSG_Rect r(Extent);
1704
1705 if( r.Get_XRange() == 0. && r.Get_YRange() == 0. )
1706 {
1707 r.Inflate(0.5 * Rows, false); // assume cellsize = 1.
1708 }
1709 else if( r.Get_XRange() == 0. )
1710 {
1711 double d = 0.5 * r.Get_YRange() / Rows; r.xMin -= d; r.xMax += d; // inflate by half cellsize
1712 }
1713 else if( r.Get_YRange() == 0. )
1714 {
1715 double d = 0.5 * r.Get_XRange() / Rows; r.yMin -= d; r.yMax += d; // inflate by half cellsize
1716 }
1717
1718 //-----------------------------------------------------
1719 double Size = r.Get_YRange() / (Rows - 1);
1720
1721 int Cols = 1 + (int)(0.5 + r.Get_XRange() / Size);
1722
1723 if( Rounding > 0 ) // rounding of cell size!
1724 {
1725 Size = SG_Get_Rounded_To_SignificantFigures(Size, Rounding);
1726
1727 r.xMin = r.Get_XCenter() - Size * Cols / 2.;
1728 r.yMin = r.Get_YCenter() - Size * Rows / 2.;
1729 r.yMax = r.Get_YMin () + Size * (Rows - 1);
1730 }
1731
1732 r.xMax = r.Get_XMin() + Size * (Cols - 1);
1733
1734 //-----------------------------------------------------
1735 if( (*pParameters)(m_Prefix + "USER_FLAT")->asBool() && !M_HAS_DECIMALS(Size) ) // rounding of bounds
1736 {
1737 r.xMin = floor(r.xMin / Size) * Size; r.xMax = ceil(r.xMax / Size) * Size;
1738 r.yMin = floor(r.yMin / Size) * Size; r.yMax = ceil(r.yMax / Size) * Size;
1739 }
1740
1741 //-----------------------------------------------------
1742 if( (*pParameters)(m_Prefix + "USER_FITS")->asInt() == 1 ) // fit to cells
1743 {
1744 r.Inflate(0.5 * Size, false);
1745 }
1746
1747 bool bCallback = pParameters->Set_Callback(false);
1748
1749 pParameters->Set_Parameter(m_Prefix + "USER_SIZE", Size );
1750 pParameters->Set_Parameter(m_Prefix + "USER_XMIN", r.Get_XMin());
1751 pParameters->Set_Parameter(m_Prefix + "USER_XMAX", r.Get_XMax());
1752 pParameters->Set_Parameter(m_Prefix + "USER_YMIN", r.Get_YMin());
1753 pParameters->Set_Parameter(m_Prefix + "USER_YMAX", r.Get_YMax());
1754 pParameters->Set_Parameter(m_Prefix + "USER_COLS", Cols );
1755 pParameters->Set_Parameter(m_Prefix + "USER_ROWS", Rows );
1756
1757 pParameters->Set_Callback(bCallback);
1758
1759 return( true );
1760}
1761
1762//---------------------------------------------------------
1767bool CSG_Parameters_Grid_Target::Set_User_Defined(CSG_Parameters *pParameters, CSG_Shapes *pPoints, int Scale, int Rounding)
1768{
1769 if( !pPoints || pPoints->Get_Count() <= 0 || pPoints->Get_Extent().Get_Area() <= 0. )
1770 {
1771 return( false );
1772 }
1773
1774 CSG_Rect r(pPoints->Get_Extent());
1775
1776 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)
1777
1778 if( Size >= 1. && Rounding > 0 )
1779 {
1780 Size = SG_Get_Rounded_To_SignificantFigures(Size, Rounding);
1781
1782 r.xMin = Size * floor(r.xMin / Size);
1783 r.xMax = Size * ceil (r.xMax / Size);
1784 r.yMin = Size * floor(r.yMin / Size);
1785 r.yMax = Size * ceil (r.yMax / Size);
1786 }
1787
1788 int Rows = 1 + (int)(0.5 + r.Get_YRange() / Size);
1789
1790 return( Set_User_Defined(pParameters, r, Rows, 0) );
1791}
1792
1793//---------------------------------------------------------
1798{
1799 return( System.is_Valid() && Set_User_Defined(pParameters, System.Get_Extent(), System.Get_NY(), 0) );
1800}
1801
1802//---------------------------------------------------------
1806bool CSG_Parameters_Grid_Target::Set_User_Defined(CSG_Parameters *pParameters, double xMin, double yMin, double Cellsize, int nx, int ny)
1807{
1808 return( Set_User_Defined(pParameters, CSG_Grid_System(Cellsize, xMin, yMin, nx, ny)) );
1809}
1810
1811//---------------------------------------------------------
1815bool CSG_Parameters_Grid_Target::Set_User_Defined_ZLevels(CSG_Parameters *pParameters, double zMin, double zMax, int nLevels, int Rounding)
1816{
1817 if( !m_pParameters->Get_Tool()->has_GUI() ) // no cancel button, so set parameters directly
1818 {
1819 pParameters = m_pParameters;
1820 }
1821
1822 if( !m_pParameters || !pParameters || m_pParameters->Get_Identifier().Cmp(pParameters->Get_Identifier()) )
1823 {
1824 return( false );
1825 }
1826
1827 if( nLevels < 1 )
1828 {
1829 nLevels = 100;
1830 }
1831
1832 //-----------------------------------------------------
1833 if( zMin > zMax )
1834 {
1835 double z = zMin; zMin = zMax; zMax = z;
1836 }
1837
1838 if( zMax - zMin <= 0. )
1839 {
1840 zMin -= 0.5 * nLevels;
1841 zMax += 0.5 * nLevels; // assume cellsize = 1.
1842 }
1843
1844 //-----------------------------------------------------
1845 double Size = (zMax - zMin) / (nLevels - 1.);
1846
1847 if( Rounding > 0 )
1848 {
1849 Size = SG_Get_Rounded_To_SignificantFigures(Size, Rounding);
1850
1851 zMin = Size * floor(zMin / Size);
1852 zMax = Size * ceil (zMax / Size);
1853 }
1854
1855 //-----------------------------------------------------
1856 if( (*pParameters)(m_Prefix + "USER_FITS")->asInt() == 1 )
1857 {
1858 zMin -= 0.5 * Size;
1859 zMax += 0.5 * Size;
1860 }
1861
1862 bool bCallback = pParameters->Set_Callback(false);
1863
1864 pParameters->Set_Parameter(m_Prefix + "USER_ZSIZE", Size );
1865 pParameters->Set_Parameter(m_Prefix + "USER_ZMIN" , zMin );
1866 pParameters->Set_Parameter(m_Prefix + "USER_ZMAX" , zMax );
1867 pParameters->Set_Parameter(m_Prefix + "USER_ZNUM" , nLevels);
1868
1869 pParameters->Set_Callback(bCallback);
1870
1871 return( true );
1872}
1873
1874
1876// //
1878
1879//---------------------------------------------------------
1880bool CSG_Parameters_Grid_Target::Add_Grid(const CSG_String &Identifier, const CSG_String &Name, bool bOptional)
1881{
1882 if( !m_pParameters || Identifier.Length() == 0 || (*m_pParameters)(Identifier) != NULL )
1883 {
1884 return( false );
1885 }
1886
1887 CSG_Parameter *pTarget = (*m_pParameters)(m_Prefix + "DEFINITION");
1888 CSG_Parameter *pSystem = NULL;
1889
1890 for(int i=0; i<pTarget->Get_Children_Count() && !pSystem; i++)
1891 {
1892 if( pTarget->Get_Child(i)->Get_Type() == PARAMETER_TYPE_Grid_System )
1893 {
1894 pSystem = pTarget->Get_Child(i);
1895 }
1896 }
1897
1898 m_pParameters->Add_Grid(pSystem ? pSystem->Get_Identifier() : SG_T(""), Identifier, Name, _TL(""), bOptional ? PARAMETER_OUTPUT_OPTIONAL : PARAMETER_OUTPUT, false);
1899
1900 if( bOptional && m_pParameters->Get_Tool()->has_GUI() )
1901 {
1902 CSG_Parameter *pNode = (*m_pParameters)(m_Prefix + "USER_OPTS");
1903
1904 if( !pNode )
1905 {
1906 pNode = m_pParameters->Add_Node(pTarget->Get_Identifier(), m_Prefix + "USER_OPTS", _TL("Optional Target Grids"), _TL(""));
1907 }
1908
1909 m_pParameters->Add_Bool(pNode->Get_Identifier(), Identifier + "_CREATE", Name, _TL(""), false)->Set_UseInCMD(false);
1910 }
1911
1912 return( true );
1913}
1914
1915//---------------------------------------------------------
1916bool CSG_Parameters_Grid_Target::Add_Grids(const CSG_String &Identifier, const CSG_String &Name, bool bOptional, bool bZLevels)
1917{
1918 if( !m_pParameters || Identifier.Length() == 0 || (*m_pParameters)(Identifier) != NULL )
1919 {
1920 return( false );
1921 }
1922
1923 CSG_Parameter *pTarget = (*m_pParameters)(m_Prefix + "DEFINITION");
1924 CSG_Parameter *pSystem = NULL;
1925
1926 for(int i=0; i<pTarget->Get_Children_Count() && !pSystem; i++)
1927 {
1928 if( pTarget->Get_Child(i)->Get_Type() == PARAMETER_TYPE_Grid_System )
1929 {
1930 pSystem = pTarget->Get_Child(i);
1931 }
1932 }
1933
1934 m_pParameters->Add_Grids(pSystem ? pSystem->Get_Identifier() : SG_T(""), Identifier, Name, _TL(""), bOptional ? PARAMETER_OUTPUT_OPTIONAL : PARAMETER_OUTPUT, false);
1935
1936 if( bOptional && m_pParameters->Get_Tool()->has_GUI() )
1937 {
1938 CSG_Parameter *pNode = (*m_pParameters)(m_Prefix + "USER_OPTS");
1939
1940 if( !pNode )
1941 {
1942 pNode = m_pParameters->Add_Node(pTarget->Get_Identifier(), m_Prefix + "USER_OPTS", _TL("Optional Target Grids"), _TL(""));
1943 }
1944
1945 m_pParameters->Add_Bool(pNode->Get_Identifier(), Identifier + "_CREATE", Name, _TL(""), false);
1946 }
1947
1948 if( bZLevels )
1949 {
1950 pTarget = m_pParameters->Add_Node(pTarget, "USER_Z", _TL("Z Levels"), _TL(""));
1951
1952 m_pParameters->Add_Double(pTarget, m_Prefix + "USER_ZSIZE", _TL("Cellsize"), _TL(""), 1., 0., true);
1953 m_pParameters->Add_Double(pTarget, m_Prefix + "USER_ZMIN" , _TL("Bottom" ), _TL(""), 0.);
1954 m_pParameters->Add_Double(pTarget, m_Prefix + "USER_ZMAX" , _TL("Top" ), _TL(""), 100.);
1955 m_pParameters->Add_Int (pTarget, m_Prefix + "USER_ZNUM" , _TL("Levels" ), _TL(""), 101, 1, true);
1956 }
1957
1958 return( true );
1959}
1960
1961
1963// //
1965
1966//---------------------------------------------------------
1968{
1969 return( Get_System(m_pParameters) );
1970}
1971
1972//---------------------------------------------------------
1974{
1975 CSG_Grid_System System;
1976
1977 if( pParameters && (*pParameters)(m_Prefix + "DEFINITION") )
1978 {
1979 if( (*pParameters)(m_Prefix + "DEFINITION")->asInt() == 0 ) // user defined
1980 {
1981 if( (*pParameters)(m_Prefix + "USER_SIZE")
1982 && (*pParameters)(m_Prefix + "USER_XMIN")
1983 && (*pParameters)(m_Prefix + "USER_YMIN")
1984 && (*pParameters)(m_Prefix + "USER_XMAX")
1985 && (*pParameters)(m_Prefix + "USER_YMAX")
1986 && (*pParameters)(m_Prefix + "USER_FITS") )
1987 {
1988 double Size = (*pParameters)(m_Prefix + "USER_SIZE")->asDouble();
1989
1990 CSG_Rect r(
1991 (*pParameters)(m_Prefix + "USER_XMIN")->asDouble(),
1992 (*pParameters)(m_Prefix + "USER_YMIN")->asDouble(),
1993 (*pParameters)(m_Prefix + "USER_XMAX")->asDouble(),
1994 (*pParameters)(m_Prefix + "USER_YMAX")->asDouble()
1995 );
1996
1997 if( (*pParameters)(m_Prefix + "USER_FITS")->asInt() == 1 )
1998 {
1999 r.Deflate(0.5 * Size, false);
2000 }
2001
2002 System.Assign(Size, r);
2003 }
2004 }
2005 else if( (*pParameters)(m_Prefix + "SYSTEM") )
2006 {
2007 CSG_Parameter *pParameter = (*pParameters)(m_Prefix + "SYSTEM");
2008
2009 if( pParameter->asGrid_System() )
2010 {
2011 System.Assign(*pParameter->asGrid_System());
2012 }
2013 }
2014 }
2015
2016 return( System );
2017}
2018
2019//---------------------------------------------------------
2021{
2022 if( !m_pParameters )
2023 {
2024 return( NULL );
2025 }
2026
2027 CSG_Parameter *pParameter = (*m_pParameters)(Identifier);
2028
2029 if( !pParameter || pParameter->Get_Type() != PARAMETER_TYPE_Grid )
2030 {
2031 return( NULL );
2032 }
2033
2034 CSG_Grid_System System(Get_System());
2035
2036 if( !System.is_Valid() )
2037 {
2038 return( NULL );
2039 }
2040
2041 CSG_Parameter *pSystem = pParameter->Get_Parent();
2042
2043 if( pSystem->asGrid_System() && !pSystem->asGrid_System()->is_Equal(System) )
2044 {
2045 pSystem->asGrid_System()->Create(System);
2046 }
2047
2048 CSG_Grid *pGrid = NULL;
2049
2050 if( (*m_pParameters)(m_Prefix + "DEFINITION")->asInt() == 0 && m_pParameters->Get_Tool()->has_GUI() )
2051 {
2052 if( (*m_pParameters)(Identifier + "_CREATE") == NULL
2053 || (*m_pParameters)(Identifier + "_CREATE")->asBool() )
2054 {
2055 pGrid = SG_Create_Grid(System, Type);
2056 }
2057 }
2058 else
2059 {
2060 pGrid = pParameter->asGrid();
2061
2062 if( pParameter->asDataObject() == DATAOBJECT_CREATE || (!pGrid && !pParameter->is_Optional()) )
2063 {
2064 pGrid = SG_Create_Grid(System, Type);
2065 }
2066 else if( pGrid && (pGrid->Get_Type() != Type || !pGrid->Get_System().is_Equal(System)) )
2067 {
2068 pGrid->Create(System, Type);
2069 }
2070 }
2071
2072 if( pGrid )
2073 {
2074 if( pGrid != pParameter->asGrid() )
2075 {
2076 pParameter->Set_Value(pGrid);
2077 }
2078
2079 if( m_pParameters->Get_Manager() )
2080 {
2081 m_pParameters->Get_Manager()->Add(pGrid);
2082
2083 if( m_pParameters->Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
2084 {
2086 }
2087 }
2088 }
2089
2090 return( pGrid );
2091}
2092
2093
2095// //
2097
2098//---------------------------------------------------------
2100{
2101 return( Get_Grid(m_Prefix + "OUT_GRID", Type) );
2102}
2103
2104//---------------------------------------------------------
2106{
2107 if( !m_pParameters )
2108 {
2109 return( NULL );
2110 }
2111
2112 CSG_Parameter *pParameter = (*m_pParameters)(Identifier);
2113
2114 if( !pParameter || pParameter->Get_Type() != PARAMETER_TYPE_Grids )
2115 {
2116 return( NULL );
2117 }
2118
2119 CSG_Grid_System System(Get_System());
2120
2121 if( !System.is_Valid() )
2122 {
2123 return( NULL );
2124 }
2125
2126 CSG_Parameter *pSystem = pParameter->Get_Parent();
2127
2128 if( pSystem->asGrid_System() && !pSystem->asGrid_System()->is_Equal(System) )
2129 {
2130 pSystem->asGrid_System()->Create(System);
2131 }
2132
2133 CSG_Grids *pGrids = NULL;
2134
2135 if( (*m_pParameters)(m_Prefix + "DEFINITION")->asInt() == 0 && m_pParameters->Get_Tool()->has_GUI() )
2136 {
2137 if( (*m_pParameters)(Identifier + "_CREATE") == NULL
2138 || (*m_pParameters)(Identifier + "_CREATE")->asBool() )
2139 {
2140 pGrids = SG_Create_Grids(System, 0, 0., Type);
2141 }
2142 }
2143 else
2144 {
2145 pGrids = pParameter->asGrids();
2146
2147 if( pParameter->asPointer() == DATAOBJECT_CREATE || (!pGrids && !pParameter->is_Optional()) )
2148 {
2149 pGrids = SG_Create_Grids(System, 0, 0., Type);
2150 }
2151 else if( pGrids && (pGrids->Get_Type() != Type || !pGrids->Get_System().is_Equal(System)) )
2152 {
2153 pGrids->Create(System, 0, 0., Type);
2154 }
2155 }
2156
2157 if( pGrids && pGrids != pParameter->asGrids() )
2158 {
2159 pParameter->Set_Value(pGrids);
2160
2161 if( m_pParameters->Get_Manager() )
2162 {
2163 m_pParameters->Get_Manager()->Add(pGrids);
2164
2165 if( m_pParameters->Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
2166 {
2168 }
2169 }
2170 }
2171
2172 //-----------------------------------------------------
2173 if( pGrids
2174 && (*m_pParameters)(m_Prefix + "USER_ZSIZE")
2175 && (*m_pParameters)(m_Prefix + "USER_ZMIN" )
2176 && (*m_pParameters)(m_Prefix + "USER_ZNUM" ) )
2177 {
2178 int nz = (*m_pParameters)(m_Prefix + "USER_ZNUM" )->asInt ();
2179 double z = (*m_pParameters)(m_Prefix + "USER_ZMIN" )->asDouble();
2180 double dz = (*m_pParameters)(m_Prefix + "USER_ZSIZE")->asDouble();
2181
2182 pGrids->Del_Grids();
2183
2184 for(int iz=0; iz<nz; iz++, z+=dz)
2185 {
2186 pGrids->Add_Grid(z);
2187 }
2188 }
2189
2190 return( pGrids );
2191}
2192
2193//---------------------------------------------------------
2195{
2196 return( Get_Grids(m_Prefix + "OUT_GRIDS", Type) );
2197}
2198
2199
2201// //
2202// //
2203// //
2205
2206//---------------------------------------------------------
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:124
#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:1648
#define SG_STR_CMP(s1, s2)
Definition api_core.h:544
TSG_Data_Type
Definition api_core.h:1043
#define SG_Char
Definition api_core.h:536
#define _TL(s)
Definition api_core.h:1619
SAGA_API_DLL_EXPORT CSG_String SG_Get_String(double Value, int Precision=-99)
long Get_Color(int Index) const
Definition api_core.h:1494
int Get_Count(void) const
Definition api_core.h:1482
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:697
void Set_Content(const CSG_String &Content)
Definition metadata.h:146
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:169
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition metadata.cpp:585
const SG_Char * Get_Item(int Index) const
int Get_Count(void) const
Definition parameters.h:692
int Get_Selection_Count(void) const
Definition parameters.h:773
int Get_Item_Count(void) const
Definition parameters.h:769
const CSG_String & Get_Item(int i) const
Definition parameters.h:770
int Get_Selection_Index(int i) const
Definition parameters.h:776
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:333
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:338
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
class CSG_Parameter_Table_Field * asTableField(void) 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:818
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:410
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:412
int Get_Field_Count(void) const
Definition table.h:371
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:1659
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
#define asDouble(i)
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)