SAGA API Version 9.14
Loading...
Searching...
No Matches
parameters.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// parameters.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// Goldschmidtstr. 5 //
45// 37077 Goettingen //
46// Germany //
47// //
48// e-mail: oconrad@saga-gis.org //
49// //
51
52//---------------------------------------------------------
53#include "parameters.h"
54#include "data_manager.h"
55#include "tool.h"
56
57
59// //
60// //
61// //
63
64//---------------------------------------------------------
66{
67 _On_Construction();
68}
69
70//---------------------------------------------------------
72{
73 _On_Construction();
74
75 Create(Parameters);
76}
77
78//---------------------------------------------------------
79CSG_Parameters::CSG_Parameters(const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
80{
81 _On_Construction();
82
83 Create(Name, Description, Identifier, bGrid_System);
84}
85
86//---------------------------------------------------------
87CSG_Parameters::CSG_Parameters(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
88{
89 _On_Construction();
90
91 Create(pOwner, Name, Description, Identifier, bGrid_System);
92}
93
94//---------------------------------------------------------
99
100
102// //
104
105//---------------------------------------------------------
106void CSG_Parameters::_On_Construction(void)
107{
108 m_pOwner = NULL;
109 m_pTool = NULL;
110 m_pManager = &SG_Get_Data_Manager();
111
112 m_Callback = NULL;
113 m_bCallback = true;
114
115 m_Parameters = NULL;
116 m_nParameters = 0;
117
118 m_pGrid_System = NULL;
119
120 m_pStack = NULL;
121
122 m_bInfo = false;
123 m_Info = "";
124}
125
126//---------------------------------------------------------
128{
129 Destroy();
130
131 Set_Identifier (Parameters.Get_Identifier ());
132 Set_Name (Parameters.Get_Name ());
133 Set_Description(Parameters.Get_Description());
134
135 m_pOwner = Parameters.m_pOwner;
136 m_pTool = Parameters.m_pTool;
137 m_pManager = Parameters.m_pManager;
138
139 m_Callback = Parameters.m_Callback;
140 m_bCallback = Parameters.m_bCallback;
141
142 for(int i=0; i<Parameters.m_nParameters; i++)
143 {
144 _Add(Parameters.m_Parameters[i]);
145 }
146
147 if( Parameters.m_pGrid_System )
148 {
149 m_pGrid_System = Get_Parameter(Parameters.m_pGrid_System->Get_Identifier());
150 }
151
152 return( m_nParameters == Parameters.m_nParameters );
153}
154
155//---------------------------------------------------------
156bool CSG_Parameters::Create(const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
157{
158 Destroy();
159
160 Set_Identifier (Identifier);
161 Set_Name (Name);
162 Set_Description(Description ? Description : SG_T(""));
163
164 if( bGrid_System )
165 {
167 }
168
169 return( true );
170}
171
172//---------------------------------------------------------
173bool CSG_Parameters::Create(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
174{
175 if( Create(Name, Description, Identifier, bGrid_System) )
176 {
177 m_pOwner = pOwner;
178
179 return( true );
180 }
181
182 return( false );
183}
184
185//---------------------------------------------------------
187{
188 Pop();
189
190 m_pOwner = NULL;
191 m_pTool = NULL;
192 m_pGrid_System = NULL;
193
195}
196
197
199// //
201
202//---------------------------------------------------------
204{
205 m_pTool = pTool;
206
207 for(int i=0; i<Get_Count(); i++)
208 {
209 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters )
210 {
211 m_Parameters[i]->asParameters()->Set_Tool(pTool);
212 }
213 }
214}
215
216//---------------------------------------------------------
223//---------------------------------------------------------
225{
226 m_pManager = pManager;
227
228 for(int i=0; i<Get_Count(); i++)
229 {
230 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters )
231 {
232 m_Parameters[i]->asParameters()->Set_Manager(pManager);
233 }
234 }
235}
236
237//---------------------------------------------------------
241//---------------------------------------------------------
243{
244 if( !m_pGrid_System )
245 {
246 m_pGrid_System = Add_Grid_System("", "PARAMETERS_GRID_SYSTEM", _TL("Grid System"), _TL(""));
247
248 return( true );
249 }
250
251 return( false );
252}
253
254
255//---------------------------------------------------------
262//---------------------------------------------------------
263bool CSG_Parameters::Push(CSG_Data_Manager *pManager, bool bRestoreDefaults)
264{
265 CSG_Parameters *pStack = m_pStack;
266
267 m_pStack = new CSG_Parameters(*this);
268
269 m_pStack->m_pStack = pStack;
270
271 m_pManager = pManager;
272
273 if( bRestoreDefaults )
274 {
275 Restore_Defaults(true);
276 }
277
278 return( true );
279}
280
281//---------------------------------------------------------
285//---------------------------------------------------------
287{
288 if( m_pStack )
289 {
290 m_pManager = m_pStack->m_pManager;
291
292 Assign_Values(m_pStack);
293
294 CSG_Parameters *pStack = m_pStack->m_pStack;
295
296 delete( m_pStack );
297
298 m_pStack = pStack;
299
300 return( true );
301 }
302
303 return( false );
304}
305
306//---------------------------------------------------------
311//---------------------------------------------------------
313{
314 return( Get_Tool() ? Get_Tool()->has_GUI() : (Get_Owner() && SG_UI_Get_Window_Main()) );
315}
316
317//---------------------------------------------------------
321//---------------------------------------------------------
323{
324 m_Identifier = Identifier;
325}
326
327//---------------------------------------------------------
331//---------------------------------------------------------
332bool CSG_Parameters::Cmp_Identifier(const CSG_String &Identifier) const
333{
334 return( m_Identifier.Cmp(Identifier) == 0 );
335}
336
337//---------------------------------------------------------
341//---------------------------------------------------------
343{
344 m_Name = Name;
345}
346
347//---------------------------------------------------------
351//---------------------------------------------------------
353{
354 m_Description = Description;
355}
356
357//---------------------------------------------------------
361//---------------------------------------------------------
363{
364 for(int i=0; i<m_nParameters; i++)
365 {
366 m_Parameters[i]->Set_Enabled(bEnabled);
367 }
368}
369
370//---------------------------------------------------------
374//---------------------------------------------------------
375void CSG_Parameters::Set_Enabled(const CSG_String &Identifier, bool bEnabled)
376{
377 CSG_Parameter *pParameter = Get_Parameter(Identifier);
378
379 if( pParameter )
380 {
381 pParameter->Set_Enabled(bEnabled);
382 }
383}
384
385
387// //
389
390//---------------------------------------------------------
392{
393 Listing.Destroy(); Listing.Set_Name(Get_Name());
394
395 Listing.Add_Field("Identifier" , SG_DATATYPE_String); // 0
396 Listing.Add_Field("Name" , SG_DATATYPE_String); // 1
397 Listing.Add_Field("Description", SG_DATATYPE_String); // 2
398 Listing.Add_Field("Constraints", SG_DATATYPE_String); // 3
399 Listing.Add_Field("Default" , SG_DATATYPE_String); // 4
400 Listing.Add_Field("Value" , SG_DATATYPE_String); // 5
401
402 for(int i=0; i<m_nParameters; i++)
403 {
404 CSG_Parameter &Parameter = *m_Parameters[i];
405
406 if( Parameter.Get_Type() != PARAMETER_TYPE_Node && Parameter.Get_Type() != PARAMETER_TYPE_Grid_System )
407 {
408 CSG_Table_Record &Record = *Listing.Add_Record();
409
410 CSG_String Constraints;
411
412 if( Parameter.asChoice() )
413 {
414 Constraints = Parameter.asChoice()->Get_Items();
415 }
416 else if( Parameter.asValue() )
417 {
418 if( Parameter.asValue()->has_Minimum() && Parameter.asValue()->has_Maximum() )
419 {
420 Constraints = "range = " + SG_Get_String(Parameter.asValue()->Get_Minimum(), -12) + " - " + SG_Get_String(Parameter.asValue()->Get_Maximum(), -12);
421 }
422 else if( Parameter.asValue()->has_Minimum() )
423 {
424 Constraints = "minimum = " + SG_Get_String(Parameter.asValue()->Get_Minimum(), -12);
425 }
426 else if( Parameter.asValue()->has_Maximum() )
427 {
428 Constraints = "minimum = " + SG_Get_String(Parameter.asValue()->Get_Minimum(), -12);
429 }
430 }
431 // else if( Parameter.asTableField() )
432 // {
433 // CSG_Table *pTable = Parameter.asTableField()->Get_Table();
434
435 // if( pTable )
436 // {
437 // Constraints = Parameter.asTableField()->Get_Choices(*pTable);
438 // }
439 // }
440
441 Record.Set_Value(0, Parameter.Get_Identifier ());
442 Record.Set_Value(1, Parameter.Get_Name ());
443 Record.Set_Value(2, Parameter.Get_Description());
444 Record.Set_Value(3, Constraints );
445 Record.Set_Value(4, Parameter.Get_Default ());
446 Record.Set_Value(5, Parameter.asString ());
447 }
448 }
449
450 return( Listing.Get_Count() > 0 );
451}
452
453//---------------------------------------------------------
454CSG_String CSG_Parameters::Get_Parameter_Listing(bool bHeader, bool bDescription, bool bConstraints, bool bValue, int SortField) const
455{
456 CSG_String Listing; CSG_Table Table;
457
458 if( Get_Parameter_Listing(Table) && Table.Get_Field_Count() == 6 )
459 {
460 if( SortField >= 0 && SortField < Table.Get_Field_Count() )
461 {
462 Table.Sort(SortField);
463 }
464
465 if( bHeader )
466 {
467 Listing.Printf("\n___\n%s\n___\n", Table.Get_Name());
468 }
469
470 for(sLong i=0; i<Table.Get_Count(); i++)
471 {
472 Listing += CSG_String::Format("[%s] %s", Table[i].asString(0), Table[i].asString(1));
473
474 CSG_String Description(Table[i].asString(2)); Description.Replace("\n", " | ");
475 CSG_String Constraints(Table[i].asString(3)); Constraints.Replace("\n", " | ");
476 CSG_String Default (Table[i].asString(4)); Default .Replace("\n", " | ");
477 CSG_String Value (Table[i].asString(5)); Value .Replace("\n", " | ");
478
479 if( bConstraints && !Constraints.is_Empty() )
480 {
481 Listing += CSG_String::Format(" [%s]", Constraints.c_str());
482 }
483
484 if( bValue && !Value.is_Empty() )
485 {
486 Listing += " [";
487
488 if( !Default.is_Empty() )
489 {
490 Listing += CSG_String::Format("default = \'%s\', ", Default.c_str());
491 }
492
493 Listing += CSG_String::Format("value = \'%s\']", Value.c_str());
494 }
495
496 if( bDescription && !Description.is_Empty() )
497 {
498 Listing += CSG_String::Format(" => %s", Description.c_str());
499 }
500
501 Listing += "\n";
502 }
503 }
504
505 return( Listing );
506}
507
508
510// //
512
513//---------------------------------------------------------
515{
516 return( _Add(pParameter) );
517}
518
519//---------------------------------------------------------
520CSG_Parameter * CSG_Parameters::Add_Node(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bCollapsed)
521{
522 return( _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Node, bCollapsed ? PARAMETER_GUI_COLLAPSED|PARAMETER_INFORMATION : PARAMETER_INFORMATION) );
523}
524
525//---------------------------------------------------------
534CSG_Parameter * CSG_Parameters::Add_Value(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
535{
536 return( _Add_Value(ParentID, ID, Name, Description, false, Type, Value, Minimum, bMinimum, Maximum, bMaximum) );
537}
538
539CSG_Parameter * CSG_Parameters::Add_Info_Value(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, TSG_Parameter_Type Type, double Value)
540{
541 return( _Add_Value(ParentID, ID, Name, Description, true, Type, Value, 0.0, false, 0.0, false) );
542}
543
544//---------------------------------------------------------
545CSG_Parameter * CSG_Parameters::Add_Bool (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool Value)
546{
547 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Bool , Value ? 1.0 : 0.0) );
548}
549
550CSG_Parameter * CSG_Parameters::Add_Int (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value, int Minimum, bool bMinimum, int Maximum, bool bMaximum)
551{
552 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Int , Value, Minimum, bMinimum, Maximum, bMaximum) );
553}
554
555CSG_Parameter * CSG_Parameters::Add_Double(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
556{
557 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Double, Value, Minimum, bMinimum, Maximum, bMaximum) );
558}
559
560CSG_Parameter * CSG_Parameters::Add_Degree(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
561{
562 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Degree, Value, Minimum, bMinimum, Maximum, bMaximum) );
563}
564
565CSG_Parameter * CSG_Parameters::Add_Date (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value) // Julian Day Number
566{
567 if( !Value )
568 {
569 Value = CSG_DateTime::Now().Get_JDN();
570 }
571
572 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Date , Value) );
573}
574
575CSG_Parameter * CSG_Parameters::Add_Color (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value)
576{
577 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Color , Value) );
578}
579
580//---------------------------------------------------------
581CSG_Parameter * CSG_Parameters::Add_Range (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Range_Min, double Range_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
582{
583 return( _Add_Range(ParentID, ID, Name, Description, false, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) );
584}
585
586CSG_Parameter * CSG_Parameters::Add_Info_Range(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Range_Min, double Range_Max)
587{
588 return( _Add_Range(ParentID, ID, Name, Description, true, Range_Min, Range_Max, 0.0, false, 0.0, false) );
589}
590
591//---------------------------------------------------------
600//---------------------------------------------------------
601CSG_Parameter * CSG_Parameters::Add_Data_Type(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Data_Types, TSG_Data_Type Default, const CSG_String &User)
602{
603 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Data_Type, 0);
604
605 bool bCallback = Set_Callback(false);
606 pParameter->asDataType()->Set_Data_Types(Data_Types, Default, User);
607 Set_Callback(bCallback);
608
609 return( pParameter );
610}
611
612//---------------------------------------------------------
613CSG_Parameter * CSG_Parameters::Add_Choice(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items, int Default)
614{
615 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Choice, 0);
616
617 pParameter->asChoice()->Set_Items(Items);
618
619 bool bCallback = Set_Callback(false);
620 pParameter->Set_Value (Default);
621 pParameter->Set_Default(Default);
622 Set_Callback(bCallback);
623
624 return( pParameter );
625}
626
627//---------------------------------------------------------
628CSG_Parameter * CSG_Parameters::Add_Choices(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items)
629{
630 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Choices, 0);
631
632 pParameter->asChoices()->Set_Items(Items);
633
634 return( pParameter );
635}
636
637//---------------------------------------------------------
638CSG_Parameter * CSG_Parameters::Add_String(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &String, bool bLongText, bool bPassword)
639{
640 return( _Add_String(ParentID, ID, Name, Description, false, String, bLongText, bPassword) );
641}
642
643CSG_Parameter * CSG_Parameters::Add_Info_String(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &String, bool bLongText)
644{
645 return( _Add_String(ParentID, ID, Name, Description, true, String, bLongText, false) );
646}
647
648//---------------------------------------------------------
649CSG_Parameter * CSG_Parameters::Add_FilePath(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
650{
651 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_FilePath, 0);
652
653 pParameter->asFilePath()->Set_Filter (Filter );
654 pParameter->asFilePath()->Set_Flag_Save (bSave );
655 pParameter->asFilePath()->Set_Flag_Multiple (bMultiple );
656 pParameter->asFilePath()->Set_Flag_Directory(bDirectory);
657
658 bool bCallback = Set_Callback(false);
659 pParameter->Set_Value (Default);
660 pParameter->Set_Default(Default);
661 Set_Callback(bCallback);
662
663 return( pParameter );
664}
665
666//---------------------------------------------------------
667CSG_Parameter * CSG_Parameters::Add_Colors(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Palette, int nColors, bool bRevert)
668{
669 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Colors, 0);
670
671 pParameter->asColors()->Create(nColors, Palette, bRevert);
672
673 return( pParameter );
674}
675
676CSG_Parameter * CSG_Parameters::Add_Colors(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Colors *pInit)
677{
678 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Colors, 0);
679
680 if( pInit )
681 {
682 pParameter->asColors()->Create(*pInit);
683 }
684
685 return( pParameter );
686}
687
688//---------------------------------------------------------
689CSG_Parameter * CSG_Parameters::Add_Font(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const SG_Char *pInit)
690{
691 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Font, 0);
692
693 if( pInit && *pInit )
694 {
695 bool bCallback = Set_Callback(false);
696 pParameter->Set_Value (pInit);
697 pParameter->Set_Default(pInit);
698 Set_Callback(bCallback);
699 }
700
701 return( pParameter );
702}
703
704//---------------------------------------------------------
705CSG_Parameter * CSG_Parameters::Add_FixedTable(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Table *pTemplate)
706{
707 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_FixedTable, 0);
708
709 pParameter->asTable()->Create(pTemplate);
710 pParameter->asTable()->Set_Name(Name);
711 pParameter->asTable()->Assign_Values(pTemplate);
712
713 return( pParameter );
714}
715
716
718// //
720
721//---------------------------------------------------------
722CSG_Parameter * CSG_Parameters::Add_Grid_Resampling(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Grid_Resampling Methods, CSG_Grid_Resampling Default)
723{
724 CSG_String Choices; int Choice = 0, nChoices = 0;
725
726 #define ADD_METHOD(method, name) if( ((int)Methods & (int)method) != 0 ) { if( !Choices.is_Empty() ) { Choices += "|"; } Choices += CSG_String::Format("{%d}", (int)method); Choices += name; if( method == Default ) { Choice = nChoices; } nChoices++; }
727
733 ADD_METHOD(CSG_Grid_Resampling::Mean_Cells , _TL("Mean Value (cell area weighted)"));
734 ADD_METHOD(CSG_Grid_Resampling::Minimum , _TL("Minimum Value"));
735 ADD_METHOD(CSG_Grid_Resampling::Maximum , _TL("Maximum Value"));
737
738 //-----------------------------------------------------
739 if( nChoices > 0 )
740 {
741 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Choice, 0);
742
743 pParameter->asChoice()->Set_Items(Choices);
744
745 bool bCallback = Set_Callback(false);
746 pParameter->Set_Value (Choice);
747 pParameter->Set_Default(Choice);
748 Set_Callback(bCallback);
749
750 return( pParameter );
751 }
752
753 return( NULL );
754}
755
756//---------------------------------------------------------
757CSG_Parameter * CSG_Parameters::Add_Grid_System(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Grid_System *pInit)
758{
759 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Grid_System, 0);
760
761 if( pInit )
762 {
763 pParameter->asGrid_System()->Assign(*pInit);
764 }
765
766 return( pParameter );
767}
768
769//---------------------------------------------------------
770CSG_Parameter * CSG_Parameters::Add_Grid(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent, TSG_Data_Type Preferred_Type)
771{
772 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
773
774 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
775 {
776 SystemID = pParent->Get_Identifier();
777 }
778 else if( bSystem_Dependent && m_pGrid_System )
779 {
780 SystemID = m_pGrid_System->Get_Identifier();
781 }
782 else
783 {
784 pParent = Add_Grid_System(pParent ? pParent->Get_Identifier() : SG_T(""), ID + "_GRIDSYSTEM", _TL("Grid system"), "");
785 SystemID = pParent->Get_Identifier();
786 }
787
788 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grid, Constraint);
789
790 ((CSG_Parameter_Grid *)pParameter)->Set_Preferred_Type(Preferred_Type);
791
792 return( pParameter );
793}
794
795//---------------------------------------------------------
796CSG_Parameter * CSG_Parameters::Add_Grid_or_Const(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum, bool bSystem_Dependent)
797{
798 CSG_Parameter *pParameter = Add_Grid(ParentID, ID, Name, Description, PARAMETER_INPUT_OPTIONAL, bSystem_Dependent);
799
800 ((CSG_Parameter_Grid *)pParameter)->Add_Default(Value, Minimum, bMinimum, Maximum, bMaximum);
801
802 return( pParameter );
803}
804
805//---------------------------------------------------------
806CSG_Parameter * CSG_Parameters::Add_Grid_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
807{
808 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
809
810 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Grid);
811
812 return( pParameter );
813}
814
815//---------------------------------------------------------
816CSG_Parameter * CSG_Parameters::Add_Grid_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent)
817{
818 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
819
820 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
821 {
822 SystemID = pParent->Get_Identifier();
823 }
824 else if( bSystem_Dependent && m_pGrid_System && !((Constraint & PARAMETER_OUTPUT) && (Constraint & PARAMETER_OPTIONAL)) )
825 {
826 SystemID = m_pGrid_System->Get_Identifier();
827 }
828
829 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grid_List, Constraint);
830
831 return( pParameter );
832}
833
834
836// //
838
839//---------------------------------------------------------
840CSG_Parameter * CSG_Parameters::Add_Grids(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent, TSG_Data_Type Preferred_Type)
841{
842 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
843
844 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
845 {
846 SystemID = pParent->Get_Identifier();
847 }
848 else if( bSystem_Dependent && m_pGrid_System )
849 {
850 SystemID = m_pGrid_System->Get_Identifier();
851 }
852 else
853 {
854 pParent = Add_Grid_System(pParent ? pParent->Get_Identifier() : SG_T(""), ID + "_GRIDSYSTEM", _TL("Grid system"), "");
855 SystemID = pParent->Get_Identifier();
856 }
857
858 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grids, Constraint);
859
860 ((CSG_Parameter_Grids *)pParameter)->Set_Preferred_Type(Preferred_Type);
861
862 return( pParameter );
863}
864
865//---------------------------------------------------------
866CSG_Parameter * CSG_Parameters::Add_Grids_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
867{
868 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
869
870 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Grids);
871
872 return( pParameter );
873}
874
875//---------------------------------------------------------
876CSG_Parameter * CSG_Parameters::Add_Grids_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent)
877{
878 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
879
880 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
881 {
882 SystemID = pParent->Get_Identifier();
883 }
884 else if( bSystem_Dependent && m_pGrid_System && !((Constraint & PARAMETER_OUTPUT) && (Constraint & PARAMETER_OPTIONAL)) )
885 {
886 SystemID = m_pGrid_System->Get_Identifier();
887 }
888
889 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grids_List, Constraint);
890
891 return( pParameter );
892}
893
894
896// //
898
899//---------------------------------------------------------
900CSG_Parameter * CSG_Parameters::Add_Table_Field(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bAllowNone)
901{
902 CSG_Parameter *pParent = Get_Parameter(ParentID);
903
904 if( pParent && (
905 pParent->Get_Type() == PARAMETER_TYPE_Table
906 || pParent->Get_Type() == PARAMETER_TYPE_Shapes
907 || pParent->Get_Type() == PARAMETER_TYPE_TIN
908 || pParent->Get_Type() == PARAMETER_TYPE_PointCloud) )
909 {
910 return( _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table_Field, bAllowNone ? PARAMETER_OPTIONAL : 0) );
911 }
912
913 return( NULL );
914}
915
916//---------------------------------------------------------
917CSG_Parameter * CSG_Parameters::Add_Table_Field_or_Const(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
918{
919 CSG_Parameter *pParameter = Add_Table_Field(ParentID, ID, Name, Description, true);
920
921 if( pParameter )
922 {
923 ((CSG_Parameter_Table_Field *)pParameter)->Add_Default(Value, Minimum, bMinimum, Maximum, bMaximum);
924 }
925
926 return( pParameter );
927}
928
929//---------------------------------------------------------
930CSG_Parameter * CSG_Parameters::Add_Table_Fields(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
931{
932 CSG_Parameter *pParent = Get_Parameter(ParentID);
933
934 if( pParent && (
935 pParent->Get_Type() == PARAMETER_TYPE_Table
936 || pParent->Get_Type() == PARAMETER_TYPE_Shapes
937 || pParent->Get_Type() == PARAMETER_TYPE_TIN
938 || pParent->Get_Type() == PARAMETER_TYPE_PointCloud) )
939 {
940 return( _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table_Fields, 0) );
941 }
942
943 return( NULL );
944}
945
946//---------------------------------------------------------
947CSG_Parameter * CSG_Parameters::Add_Table(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
948{
949 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table, Constraint);
950
951 return( pParameter );
952}
953
954//---------------------------------------------------------
955CSG_Parameter * CSG_Parameters::Add_Table_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
956{
957 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
958
959 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Table);
960
961 return( pParameter );
962}
963
964//---------------------------------------------------------
965CSG_Parameter * CSG_Parameters::Add_Table_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
966{
967 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table_List, Constraint);
968
969 return( pParameter );
970}
971
972
974// //
976
977//---------------------------------------------------------
978CSG_Parameter * CSG_Parameters::Add_Shapes(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, TSG_Shape_Type Shape_Type)
979{
980 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Shapes, Constraint);
981
982 ((CSG_Parameter_Shapes *)pParameter)->Set_Shape_Type(Shape_Type);
983
984 return( pParameter );
985}
986
987//---------------------------------------------------------
988CSG_Parameter * CSG_Parameters::Add_Shapes_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
989{
990 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
991
992 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Shapes);
993
994 return( pParameter );
995}
996
997//---------------------------------------------------------
998CSG_Parameter * CSG_Parameters::Add_Shapes_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, TSG_Shape_Type Type)
999{
1000 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Shapes_List, Constraint);
1001
1002 ((CSG_Parameter_Shapes_List *)pParameter)->Set_Shape_Type(Type);
1003
1004 return( pParameter );
1005}
1006
1007
1009// //
1011
1012//---------------------------------------------------------
1013CSG_Parameter * CSG_Parameters::Add_TIN(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1014{
1015 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_TIN, Constraint);
1016
1017 return( pParameter );
1018}
1019
1020//---------------------------------------------------------
1021CSG_Parameter * CSG_Parameters::Add_TIN_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
1022{
1023 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
1024
1025 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_TIN);
1026
1027 return( pParameter );
1028}
1029
1030//---------------------------------------------------------
1031CSG_Parameter * CSG_Parameters::Add_TIN_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1032{
1033 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_TIN_List, Constraint);
1034
1035 return( pParameter );
1036}
1037
1038
1040// //
1042
1043//---------------------------------------------------------
1044CSG_Parameter * CSG_Parameters::Add_PointCloud(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1045{
1046 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_PointCloud, Constraint);
1047
1048 return( pParameter );
1049}
1050
1051//---------------------------------------------------------
1052CSG_Parameter * CSG_Parameters::Add_PointCloud_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
1053{
1054 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
1055
1056 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_PointCloud);
1057
1058 return( pParameter );
1059}
1060
1061//---------------------------------------------------------
1062CSG_Parameter * CSG_Parameters::Add_PointCloud_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1063{
1064 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_PointCloud_List, Constraint);
1065
1066 return( pParameter );
1067}
1068
1069
1071// //
1073
1074//---------------------------------------------------------
1075CSG_Parameter * CSG_Parameters::Add_Parameters(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
1076{
1077 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Parameters, 0);
1078
1079 pParameter->asParameters()->m_Callback = m_Callback;
1080 pParameter->asParameters()->m_pTool = m_pTool;
1081
1082 return( pParameter );
1083}
1084
1085
1087// //
1089
1090//---------------------------------------------------------
1091CSG_Parameter * CSG_Parameters::_Add_Value(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bInformation, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
1092{
1093 switch( Type ) // Check if Type is valid...
1094 {
1095 case PARAMETER_TYPE_Bool :
1096 case PARAMETER_TYPE_Int :
1099 case PARAMETER_TYPE_Date :
1101 break;
1102
1103 default: // if not valid set Type to [double]...
1104 Type = PARAMETER_TYPE_Double;
1105 }
1106
1107 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, Type, bInformation ? PARAMETER_INFORMATION : 0);
1108
1109 bool bCallback = Set_Callback(false);
1110
1111 if( !bInformation )
1112 {
1113 if( Type == PARAMETER_TYPE_Int
1114 || Type == PARAMETER_TYPE_Double
1115 || Type == PARAMETER_TYPE_Degree )
1116 {
1117 pParameter->asValue()->Set_Minimum(Minimum, bMinimum);
1118 pParameter->asValue()->Set_Maximum(Maximum, bMaximum);
1119 }
1120 }
1121
1122 pParameter->Set_Value(Value);
1123
1124 Set_Callback(bCallback);
1125
1126 if( !bInformation )
1127 {
1128 switch( Type )
1129 {
1130 case PARAMETER_TYPE_Bool :
1131 case PARAMETER_TYPE_Int :
1133 pParameter->Set_Default((int)Value);
1134 break;
1135
1136 case PARAMETER_TYPE_Date :
1137 pParameter->Set_Default(pParameter->asString());
1138 break;
1139
1140 default:
1141 pParameter->Set_Default( Value);
1142 }
1143 }
1144
1145 return( pParameter );
1146}
1147
1148//---------------------------------------------------------
1149CSG_Parameter * CSG_Parameters::_Add_Range(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bInformation, double Default_Min, double Default_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
1150{
1151 //-----------------------------------------------------
1152 if( Default_Min > Default_Max )
1153 {
1154 double d = Default_Min;
1155 Default_Min = Default_Max;
1156 Default_Max = d;
1157 }
1158
1159 //-----------------------------------------------------
1160 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Range, bInformation ? PARAMETER_INFORMATION : 0);
1161
1162 bool bCallback = Set_Callback(false);
1163
1164 pParameter->asRange()->Get_Min_Parameter()->Set_Minimum(Minimum, bMinimum);
1165 pParameter->asRange()->Get_Min_Parameter()->Set_Maximum(Maximum, bMaximum);
1166 pParameter->asRange()->Get_Min_Parameter()->Set_Default(Default_Min);
1167 pParameter->asRange()->Set_Min(Default_Min);
1168
1169 pParameter->asRange()->Get_Max_Parameter()->Set_Minimum(Minimum, bMinimum);
1170 pParameter->asRange()->Get_Max_Parameter()->Set_Maximum(Maximum, bMaximum);
1171 pParameter->asRange()->Get_Max_Parameter()->Set_Default(Default_Max);
1172 pParameter->asRange()->Set_Max(Default_Max);
1173
1174 pParameter->Set_Default(SG_Get_String(Default_Min, -16) + "; " + SG_Get_String(Default_Max, -16));
1175 pParameter->_Set_String();
1176
1177 Set_Callback(bCallback);
1178
1179 return( pParameter );
1180}
1181
1182//---------------------------------------------------------
1183CSG_Parameter * CSG_Parameters::_Add_String(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bInformation, const SG_Char *String, bool bLongText, bool bPassword)
1184{
1185 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, bLongText ? PARAMETER_TYPE_Text : PARAMETER_TYPE_String, bInformation ? PARAMETER_INFORMATION : 0);
1186
1187 bool bCallback = Set_Callback(false);
1188 pParameter->Set_Value (String);
1189 pParameter->Set_Default(String);
1190 Set_Callback(bCallback);
1191
1192 ((CSG_Parameter_String *)pParameter)->Set_Password(bPassword);
1193
1194 return( pParameter );
1195}
1196
1197
1199// //
1201
1202//---------------------------------------------------------
1203#ifdef _DEBUG
1204#include <wx/debug.h>
1205#include <wx/string.h>
1206#endif
1207
1208//---------------------------------------------------------
1209CSG_Parameter * CSG_Parameters::_Add(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, TSG_Parameter_Type Type, int Constraint)
1210{
1211#ifdef _DEBUG
1212 wxASSERT_MSG(!ID.is_Empty() , wxString::Format("CSG_Parameter::_Add(): Parameter ID is empty!"));
1213 wxASSERT_MSG(!Get_Parameter(ID), wxString::Format("CSG_Parameter::_Add(): Parameter ID \"%s\" is already in use!", ID.c_str()));
1214#endif
1215
1216 CSG_Parameter *pParameter;
1217
1218 switch( Type )
1219 {
1220 default:
1221 return( NULL );
1222
1223 case PARAMETER_TYPE_Node : pParameter = new CSG_Parameter_Node (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1224
1225 case PARAMETER_TYPE_Bool : pParameter = new CSG_Parameter_Bool (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1226 case PARAMETER_TYPE_Int : pParameter = new CSG_Parameter_Int (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1227 case PARAMETER_TYPE_Double : pParameter = new CSG_Parameter_Double (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1228 case PARAMETER_TYPE_Degree : pParameter = new CSG_Parameter_Degree (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1229 case PARAMETER_TYPE_Date : pParameter = new CSG_Parameter_Date (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1230 case PARAMETER_TYPE_Range : pParameter = new CSG_Parameter_Range (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1231 case PARAMETER_TYPE_Data_Type : pParameter = new CSG_Parameter_Data_Type (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1232 case PARAMETER_TYPE_Choice : pParameter = new CSG_Parameter_Choice (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1233 case PARAMETER_TYPE_Choices : pParameter = new CSG_Parameter_Choices (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1234
1235 case PARAMETER_TYPE_String : pParameter = new CSG_Parameter_String (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1236 case PARAMETER_TYPE_Text : pParameter = new CSG_Parameter_Text (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1237 case PARAMETER_TYPE_FilePath : pParameter = new CSG_Parameter_File_Name (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1238
1239 case PARAMETER_TYPE_Font : pParameter = new CSG_Parameter_Font (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1240 case PARAMETER_TYPE_Color : pParameter = new CSG_Parameter_Color (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1241 case PARAMETER_TYPE_Colors : pParameter = new CSG_Parameter_Colors (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1242 case PARAMETER_TYPE_FixedTable : pParameter = new CSG_Parameter_Fixed_Table (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1243 case PARAMETER_TYPE_Grid_System : pParameter = new CSG_Parameter_Grid_System (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1244 case PARAMETER_TYPE_Table_Field : pParameter = new CSG_Parameter_Table_Field (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1245 case PARAMETER_TYPE_Table_Fields : pParameter = new CSG_Parameter_Table_Fields (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1246
1247 case PARAMETER_TYPE_DataObject_Output: pParameter = new CSG_Parameter_Data_Object_Output(this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1248 case PARAMETER_TYPE_Grid : pParameter = new CSG_Parameter_Grid (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1249 case PARAMETER_TYPE_Grids : pParameter = new CSG_Parameter_Grids (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1250 case PARAMETER_TYPE_Table : pParameter = new CSG_Parameter_Table (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1251 case PARAMETER_TYPE_Shapes : pParameter = new CSG_Parameter_Shapes (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1252 case PARAMETER_TYPE_TIN : pParameter = new CSG_Parameter_TIN (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1253 case PARAMETER_TYPE_PointCloud : pParameter = new CSG_Parameter_PointCloud (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1254
1255 case PARAMETER_TYPE_Grid_List : pParameter = new CSG_Parameter_Grid_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1256 case PARAMETER_TYPE_Grids_List : pParameter = new CSG_Parameter_Grids_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1257 case PARAMETER_TYPE_Table_List : pParameter = new CSG_Parameter_Table_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1258 case PARAMETER_TYPE_Shapes_List : pParameter = new CSG_Parameter_Shapes_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1259 case PARAMETER_TYPE_TIN_List : pParameter = new CSG_Parameter_TIN_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1260 case PARAMETER_TYPE_PointCloud_List : pParameter = new CSG_Parameter_PointCloud_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1261
1262 case PARAMETER_TYPE_Parameters : pParameter = new CSG_Parameter_Parameters (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1263 }
1264
1265 m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, (m_nParameters + 1) * sizeof(CSG_Parameter *));
1266 m_Parameters[m_nParameters++] = pParameter;
1267
1268 pParameter->_Set_String();
1269
1270 return( pParameter );
1271}
1272
1273//---------------------------------------------------------
1274CSG_Parameter * CSG_Parameters::_Add(CSG_Parameter *pSource)
1275{
1276 CSG_Parameter *pParameter = !pSource ? NULL : _Add(
1277 pSource->Get_Parent() ? pSource->Get_Parent()->Get_Identifier() : SG_T(""),
1278 pSource->Get_Identifier (),
1279 pSource->Get_Name (),
1280 pSource->Get_Description(),
1281 pSource->Get_Type (),
1282 pSource->m_Constraint
1283 );
1284
1285 if( pParameter )
1286 {
1287 pParameter->Assign(pSource);
1288 }
1289
1290 return( pParameter );
1291}
1292
1293
1295// //
1297
1298//---------------------------------------------------------
1299CSG_Parameter * CSG_Parameters::Get_Parameter(int i, bool MsgOnError) const
1300{
1301 if( i >= 0 && i < m_nParameters )
1302 {
1303 return( m_Parameters[i] );
1304 }
1305
1306 if( MsgOnError )
1307 {
1308 SG_UI_Msg_Add_Error(CSG_String::Format("%s index=[%d]", _TL("Could not find requested parameter!"), i));
1309 }
1310
1311 return( NULL );
1312}
1313
1314//---------------------------------------------------------
1315CSG_Parameter * CSG_Parameters::Get_Parameter(const char *ID, bool MsgOnError) const { return( Get_Parameter(CSG_String(ID), MsgOnError) ); }
1316CSG_Parameter * CSG_Parameters::Get_Parameter(const wchar_t *ID, bool MsgOnError) const { return( Get_Parameter(CSG_String(ID), MsgOnError) ); }
1317CSG_Parameter * CSG_Parameters::Get_Parameter(const CSG_String &ID, bool MsgOnError) const
1318{
1319 if( m_Parameters && !ID.is_Empty() )
1320 {
1321 for(int i=0; i<m_nParameters; i++)
1322 {
1323 if( m_Parameters[i]->Cmp_Identifier(ID) )
1324 {
1325 return( m_Parameters[i] );
1326 }
1327 }
1328
1329 //-------------------------------------------------
1330 if( ID.Find('.') > 0 ) // id not found? check for sub-parameter ('id.id')!
1331 {
1332 CSG_Parameter *pParameter = Get_Parameter(ID.BeforeFirst('.'));
1333
1334 if( pParameter )
1335 {
1336 switch( pParameter->Get_Type() )
1337 {
1339 return( pParameter->asParameters()->Get_Parameter(ID.AfterFirst('.')) );
1340
1342 if( !ID.AfterFirst('.').CmpNoCase("min") || !ID.AfterFirst('.').CmpNoCase("minimum") )
1343 {
1344 return( pParameter->asRange()->Get_Min_Parameter() );
1345 }
1346
1347 if( !ID.AfterFirst('.').CmpNoCase("max") || !ID.AfterFirst('.').CmpNoCase("maximum") )
1348 {
1349 return( pParameter->asRange()->Get_Max_Parameter() );
1350 }
1351 break;
1352
1353 default:
1354 break;
1355 }
1356 }
1357 }
1358
1359 //-------------------------------------------------
1360 if( MsgOnError )
1361 {
1362 SG_UI_Msg_Add_Error(CSG_String::Format("%s id=[%s]", _TL("Could not find requested parameter!"), ID.c_str()));
1363 }
1364 }
1365
1366 return( NULL );
1367}
1368
1369//---------------------------------------------------------
1371{
1372 if( m_Parameters && iParameter >= 0 && iParameter < m_nParameters )
1373 {
1374 CSG_Parameter *pParameter = m_Parameters[iParameter];
1375
1376 for(m_nParameters--; iParameter<m_nParameters; iParameter++)
1377 {
1378 m_Parameters[iParameter] = m_Parameters[iParameter + 1];
1379 }
1380
1381 m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, m_nParameters * sizeof(CSG_Parameter *));
1382
1383 for(iParameter=pParameter->Get_Children_Count()-1; iParameter>=0; iParameter--)
1384 {
1385 Del_Parameter(pParameter->Get_Child(iParameter)->Get_Identifier());
1386 }
1387
1388 CSG_Parameter *pParent = pParameter->Get_Parent();
1389
1390 if( pParent )
1391 {
1392 for(iParameter=0; iParameter<pParent->m_nChildren; iParameter++)
1393 {
1394 if( pParent->m_Children[iParameter] == pParameter )
1395 {
1396 pParent->m_nChildren--;
1397
1398 for( ; iParameter<pParent->m_nChildren; iParameter++)
1399 {
1400 pParent->m_Children[iParameter] = pParent->m_Children[iParameter + 1];
1401 }
1402 }
1403 }
1404
1405 pParent->m_Children = (CSG_Parameter **)SG_Realloc(pParent->m_Children, pParent->m_nChildren * sizeof(CSG_Parameter *));
1406 }
1407
1408 delete(pParameter);
1409
1410 return( true );
1411 }
1412
1413 return( false );
1414}
1415
1416//---------------------------------------------------------
1418{
1419 if( m_Parameters && Identifier.Length() )
1420 {
1421 for(int i=0; i<m_nParameters; i++)
1422 {
1423 if( !m_Parameters[i]->m_Identifier.Cmp(Identifier) )
1424 {
1425 return( Del_Parameter(i) );
1426 }
1427 }
1428 }
1429
1430 return( false );
1431}
1432
1433//---------------------------------------------------------
1435{
1436 if( m_nParameters > 0 )
1437 {
1438 m_pGrid_System = NULL;
1439
1440 for(int i=0; i<m_nParameters; i++)
1441 {
1442 delete(m_Parameters[i]);
1443 }
1444
1445 SG_Free(m_Parameters);
1446
1447 m_Parameters = NULL;
1448 m_nParameters = 0;
1449 }
1450
1451 return( true );
1452}
1453
1454
1456// //
1457// Callback //
1458// //
1460
1461//---------------------------------------------------------
1462// Callback function used to react on parameter changes.
1463// Return value is the previously set callback function.
1465{
1466 TSG_PFNC_Parameter_Changed Previous = m_Callback;
1467
1468 m_Callback = Callback;
1469
1470 for(int i=0; i<m_nParameters; i++)
1471 {
1472 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters)
1473 {
1474 m_Parameters[i]->asParameters()->Set_Callback_On_Parameter_Changed(Callback);
1475 }
1476 }
1477
1478 return( Previous );
1479}
1480
1481//---------------------------------------------------------
1482// If switched off parameter changes will not invoke a
1483// consecutive call to the On_Parameter_Changed function.
1484// Return value is the previous state.
1486{
1487 bool bPrevious = m_bCallback;
1488
1489 m_bCallback = bActive;
1490
1491 for(int i=0; i<m_nParameters; i++)
1492 {
1493 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters)
1494 {
1495 m_Parameters[i]->asParameters()->Set_Callback(bActive);
1496 }
1497 }
1498
1499 return( bPrevious );
1500}
1501
1502//---------------------------------------------------------
1503bool CSG_Parameters::_On_Parameter_Changed(CSG_Parameter *pParameter, int Flags)
1504{
1505 if( m_Callback && m_bCallback )
1506 {
1507 bool bCallback = Set_Callback(false);
1508
1509 m_Callback(pParameter, Flags);
1510
1511 Set_Callback(bCallback);
1512
1513 return( true );
1514 }
1515
1516 return( false );
1517}
1518
1519
1521// //
1523
1524//---------------------------------------------------------
1525bool CSG_Parameters::Set_Parameter(const char *ID, CSG_Parameter *pValue) { return( Set_Parameter(CSG_String(ID), pValue) ); }
1526bool CSG_Parameters::Set_Parameter(const wchar_t *ID, CSG_Parameter *pValue) { return( Set_Parameter(CSG_String(ID), pValue) ); }
1528{
1529 CSG_Parameter *pTarget = Get_Parameter(ID);
1530
1531 return( pTarget && pValue && pTarget->Get_Type() == pValue->Get_Type() && pTarget->Assign(pValue) );
1532}
1533
1534//---------------------------------------------------------
1535bool CSG_Parameters::Set_Parameter(const char *ID, void *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1536bool CSG_Parameters::Set_Parameter(const wchar_t *ID, void *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1537bool CSG_Parameters::Set_Parameter(const CSG_String &ID, void *Value, int Type)
1538{
1539 CSG_Parameter *pTarget = Get_Parameter(ID);
1540
1541 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1542}
1543
1544//---------------------------------------------------------
1545bool CSG_Parameters::Set_Parameter(const char *ID, CSG_Data_Object *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1546bool CSG_Parameters::Set_Parameter(const wchar_t *ID, CSG_Data_Object *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1548{
1549 CSG_Parameter *pTarget = Get_Parameter(ID);
1550
1551 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1552}
1553
1554//---------------------------------------------------------
1555bool CSG_Parameters::Set_Parameter(const char *ID, int Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1556bool CSG_Parameters::Set_Parameter(const wchar_t *ID, int Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1557bool CSG_Parameters::Set_Parameter(const CSG_String &ID, int Value, int Type)
1558{
1559 CSG_Parameter *pTarget = Get_Parameter(ID);
1560
1561 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1562}
1563
1564//---------------------------------------------------------
1565bool CSG_Parameters::Set_Parameter(const char *ID, double Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1566bool CSG_Parameters::Set_Parameter(const wchar_t *ID, double Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1567bool CSG_Parameters::Set_Parameter(const CSG_String &ID, double Value, int Type)
1568{
1569 CSG_Parameter *pTarget = Get_Parameter(ID);
1570
1571 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1572}
1573
1574//---------------------------------------------------------
1575bool CSG_Parameters::Set_Parameter(const char *ID, const CSG_String &Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1576bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const CSG_String &Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1577bool CSG_Parameters::Set_Parameter(const CSG_String &ID, const CSG_String &Value, int Type)
1578{
1579 CSG_Parameter *pTarget = Get_Parameter(ID);
1580
1581 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1582}
1583
1584//---------------------------------------------------------
1585bool CSG_Parameters::Set_Parameter(const CSG_String &ID, const char *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value), Type) ); }
1586bool CSG_Parameters::Set_Parameter(const char *ID, const char *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value), Type) ); }
1587bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const char *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value), Type) ); }
1588
1589//---------------------------------------------------------
1590bool CSG_Parameters::Set_Parameter(const CSG_String &ID, const wchar_t *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1591bool CSG_Parameters::Set_Parameter(const char *ID, const wchar_t *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1592bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const wchar_t *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1593
1594//---------------------------------------------------------
1595bool CSG_Parameters::Set_Parameter(const char *ID, const CSG_Colors &Value) { return( Set_Parameter(CSG_String(ID), Value) ); }
1596bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const CSG_Colors &Value) { return( Set_Parameter(CSG_String(ID), Value) ); }
1598{
1599 CSG_Parameter *pTarget = Get_Parameter(ID);
1600
1601 return( pTarget && pTarget->Get_Type() == PARAMETER_TYPE_Colors && pTarget->Set_Value((void *)&Value) );
1602}
1603
1604//---------------------------------------------------------
1605bool CSG_Parameters::Set_Parameter(const char *ID, const CSG_Grid_System &Value) { return( Set_Parameter(CSG_String(ID), Value) ); }
1606bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const CSG_Grid_System &Value) { return( Set_Parameter(CSG_String(ID), Value) ); }
1608{
1609 CSG_Parameter *pTarget = Get_Parameter(ID);
1610
1611 return( pTarget && pTarget->asGrid_System() && pTarget->asGrid_System()->Create(Value) );
1612}
1613
1614
1616// //
1618
1619//---------------------------------------------------------
1621{
1622 Set_Callback(false);
1623
1624 for(int i=0; i<Get_Count(); i++)
1625 {
1626 m_Parameters[i]->Restore_Default();
1627
1628 if( bClearData )
1629 {
1630 if( m_Parameters[i]->is_DataObject() )
1631 {
1632 m_Parameters[i]->Set_Value(DATAOBJECT_NOTSET);
1633 }
1634 else if( m_Parameters[i]->is_DataObject_List() )
1635 {
1636 m_Parameters[i]->asList()->Del_Items();
1637 }
1638 }
1639 }
1640
1641 Set_Callback(true);
1642
1643 return( true );
1644}
1645
1646
1648// //
1650
1651//---------------------------------------------------------
1653{
1654 return( pSource && pSource != this && Create(*pSource) );
1655}
1656
1657//---------------------------------------------------------
1659{
1660 if( !pSource || pSource == this )
1661 {
1662 return( false );
1663 }
1664
1665 //-----------------------------------------------------
1666 int n = 0;
1667
1668 for(int i=0; i<pSource->Get_Count(); i++)
1669 {
1670 CSG_Parameter *pParameter = Get_Parameter(pSource->Get_Parameter(i)->Get_Identifier());
1671
1672 if( pParameter && pParameter->Get_Type() == pSource->Get_Parameter(i)->Get_Type() )
1673 {
1674 n++; pParameter->Assign(pSource->Get_Parameter(i));
1675 }
1676 }
1677
1678 return( n > 0 );
1679}
1680
1681//---------------------------------------------------------
1683{
1684 if( !pSource || pSource == this )
1685 {
1686 return( false );
1687 }
1688
1690
1691 //-----------------------------------------------------
1692 for(int i=0; i<pSource->m_nParameters; i++)
1693 {
1694 _Add(pSource->m_Parameters[i]);
1695
1696 if( m_Parameters[i]->asParameters() )
1697 {
1698 m_Parameters[i]->asParameters()->Set_Tool(m_pTool);
1699 }
1700 }
1701
1702 if( pSource->m_pGrid_System )
1703 {
1704 m_pGrid_System = Get_Parameter(pSource->m_pGrid_System->Get_Identifier());
1705 }
1706
1707 return( m_nParameters == pSource->m_nParameters );
1708}
1709
1710
1712// //
1714
1715//---------------------------------------------------------
1717{
1718 bool bResult = true; CSG_String sError;
1719
1720 //-----------------------------------------------------
1721 for(int i=0; i<Get_Count(); i++)
1722 {
1723 if( m_Parameters[i]->Check(bSilent) == false )
1724 {
1725 bResult = false;
1726
1727 sError.Append(CSG_String::Format("\n%s: %s", m_Parameters[i]->Get_Type_Name().c_str(), m_Parameters[i]->Get_Name()));
1728 }
1729 }
1730
1731 //-----------------------------------------------------
1732 if( !bResult && !bSilent )
1733 {
1734 SG_UI_Dlg_Message(CSG_String::Format("%s\n%s", _TL("invalid input!"), sError.c_str()), Get_Name() );
1735 }
1736
1737 return( bResult );
1738}
1739
1740//---------------------------------------------------------
1741bool CSG_Parameters::DataObjects_Create(void)
1742{
1743 bool bResult = true;
1744
1745 for(int i=0; bResult && i<Get_Count(); i++)
1746 {
1747 CSG_Parameter &P = *m_Parameters[i];
1748
1749 //-------------------------------------------------
1751 {
1752 if( !P.asParameters()->DataObjects_Create() )
1753 {
1754 bResult = false;
1755 }
1756 }
1757 else if( P.is_Input() )
1758 {
1759 if( P.is_Enabled() && P.Check(true) == false )
1760 {
1761 bResult = false;
1762
1763 SG_UI_Dlg_Message(CSG_String::Format("%s\n[%s]\n%s", _TL("Input Error"), P.Get_Identifier(), P.Get_Name()), Get_Name());
1764 }
1765 }
1766
1767 //-------------------------------------------------
1768 else if( P.is_DataObject_List() )
1769 {
1770 for(int j=P.asList()->Get_Item_Count()-1; j>=0; j--)
1771 {
1772 if( m_pManager && !m_pManager->Exists(P.asList()->Get_Item(j)) )
1773 {
1774 P.asList()->Del_Item(j);
1775 }
1776 }
1777 }
1778
1779 //-------------------------------------------------
1780 else if( P.is_DataObject() && P.is_Enabled() == false && has_GUI() )
1781 {
1782 if( P.asDataObject() != DATAOBJECT_CREATE && (m_pManager && !m_pManager->Exists(P.asDataObject())) )
1783 {
1785 }
1786 }
1787
1788 else if( P.is_DataObject() )
1789 {
1790 CSG_Data_Object *pObject = P.asDataObject();
1791
1792 if( pObject != DATAOBJECT_CREATE )
1793 {
1795 {
1796 pObject = (CSG_Data_Object *)DATAOBJECT_CREATE;
1797 }
1798 else if( m_pManager && !m_pManager->Exists(pObject) )
1799 {
1800 pObject = (CSG_Data_Object *)DATAOBJECT_NOTSET;
1801 }
1802
1803 if( pObject == DATAOBJECT_NOTSET && !P.is_Optional() )
1804 {
1805 pObject = (CSG_Data_Object *)DATAOBJECT_CREATE;
1806 }
1807 }
1808
1809 if( pObject == DATAOBJECT_CREATE )
1810 {
1811 switch( P.Get_DataObject_Type() )
1812 {
1813 case SG_DATAOBJECT_TYPE_Table : pObject = SG_Create_Table (); break;
1814 case SG_DATAOBJECT_TYPE_Shapes : pObject = SG_Create_Shapes (); break;
1815 case SG_DATAOBJECT_TYPE_PointCloud: pObject = SG_Create_PointCloud(); break;
1816 case SG_DATAOBJECT_TYPE_TIN : pObject = SG_Create_TIN (); break;
1817 case SG_DATAOBJECT_TYPE_Grid : pObject = SG_Create_Grid (); break;
1818 case SG_DATAOBJECT_TYPE_Grids : pObject = SG_Create_Grids (); break;
1819 default : pObject = NULL ; break;
1820 }
1821 }
1822
1823 if( pObject )
1824 {
1826 && ((CSG_Parameter_Shapes *)&P)->Get_Shape_Type() != SHAPE_TYPE_Undefined
1827 && ((CSG_Parameter_Shapes *)&P)->Get_Shape_Type() != pObject->asShapes()->Get_Type() )
1828 {
1829 if( has_GUI() && pObject->asShapes()->Get_Type() != SHAPE_TYPE_Undefined )
1830 {
1831 pObject = SG_Create_Shapes (((CSG_Parameter_Shapes *)&P)->Get_Shape_Type());
1832 }
1833 else
1834 {
1835 pObject->asShapes()->Create(((CSG_Parameter_Shapes *)&P)->Get_Shape_Type());
1836 }
1837 }
1838
1840 {
1841 if( P.Get_Parent() && P.Get_Parent()->asGrid_System() && P.Get_Parent()->asGrid_System()->is_Valid() )
1842 {
1843 CSG_Grid_System System(*P.Get_Parent()->asGrid_System());
1844
1845 if( P.Get_Type() == PARAMETER_TYPE_Grid && !System.is_Equal(pObject->asGrid ()->Get_System()) )
1846 {
1847 pObject->asGrid ()->Create(System , ((CSG_Parameter_Grid *)&P)->Get_Preferred_Type());
1848 }
1849
1850 if( P.Get_Type() == PARAMETER_TYPE_Grids && !System.is_Equal(pObject->asGrids()->Get_System()) )
1851 {
1852 pObject->asGrids()->Create(System, 0, 0., ((CSG_Parameter_Grids *)&P)->Get_Preferred_Type());
1853 }
1854 }
1855 }
1856
1857 if( P.Set_Value(pObject) )
1858 {
1859 pObject->Set_Name(P.Get_Name());
1860 pObject->Get_MetaData().Del_Children();
1861
1862 if( m_pManager )
1863 {
1864 m_pManager->Add(pObject);
1865 }
1866 }
1867 else
1868 {
1869 delete(pObject);
1870
1871 bResult = false;
1872
1873 SG_UI_Dlg_Message(CSG_String::Format("%s\n[%s]\n%s", _TL("Output Error"), P.Get_Identifier(), P.Get_Name()), Get_Name());
1874 }
1875 }
1876 else // if( pObject == NULL )
1877 {
1878 if( !P.is_Optional() )
1879 {
1880 bResult = false;
1881
1882 SG_UI_Dlg_Message(CSG_String::Format("%s\n[%s]\n%s", _TL("Output Error"), P.Get_Identifier(), P.Get_Name()), Get_Name());
1883 }
1884 }
1885 }
1886 }
1887
1888 return( bResult );
1889}
1890
1891//---------------------------------------------------------
1892bool CSG_Parameters::DataObjects_Synchronize(void)
1893{
1894 for(int i=0; i<Get_Count(); i++)
1895 {
1896 CSG_Parameter &P = *m_Parameters[i];
1897
1899 {
1900 P.asParameters()->DataObjects_Synchronize();
1901 }
1902
1903 //-------------------------------------------------
1904 else if( P.is_Output() )
1905 {
1906 if( P.is_DataObject() )
1907 {
1908 CSG_Data_Object *pObject = P.asDataObject();
1909
1910 if( pObject == DATAOBJECT_CREATE )
1911 {
1913 }
1914 else if( pObject != DATAOBJECT_NOTSET )
1915 {
1916 if( pObject->asShapes() && pObject->asShapes()->Get_Type() == SHAPE_TYPE_Undefined
1917 && (m_pManager == &SG_Get_Data_Manager() || !SG_Get_Data_Manager().Exists(pObject)) )
1918 {
1919 if( m_pManager && !m_pManager->Delete(pObject) )
1920 {
1921 delete(pObject);
1922 }
1923
1925 }
1926 else if( (pObject->asGrid() || pObject->asGrids()) && !pObject->is_Valid() && has_GUI() && m_pManager == &SG_Get_Data_Manager() )
1927 {
1928 m_pManager->Delete(pObject);
1929
1931 }
1932 else
1933 {
1934 if( m_pManager )
1935 {
1936 m_pManager->Add(pObject);
1937
1938 if( m_pManager == &SG_Get_Data_Manager() )
1939 {
1940 SG_UI_DataObject_Add(pObject, 0);
1941 }
1942 }
1943
1945 }
1946 }
1947 }
1948
1949 //---------------------------------------------
1950 else if( P.is_DataObject_List() )
1951 {
1952 for(int j=0; j<P.asList()->Get_Item_Count(); j++)
1953 {
1954 CSG_Data_Object *pObject = P.asList()->Get_Item(j);
1955
1956 if( m_pManager )
1957 {
1958 m_pManager->Add(pObject);
1959
1960 if( m_pManager == &SG_Get_Data_Manager() )
1961 {
1962 SG_UI_DataObject_Add(pObject, 0);
1963 }
1964 }
1965
1967 }
1968 }
1969 }
1970 }
1971
1972 return( true );
1973}
1974
1975//---------------------------------------------------------
1976bool CSG_Parameters::DataObjects_Get_Projection(CSG_Projection &Projection) const
1977{
1978 for(int i=0; i<Get_Count() && !Projection.is_Okay(); i++)
1979 {
1980 CSG_Parameter *p = m_Parameters[i];
1981
1982 if( p->is_Enabled() && !p->ignore_Projection() )
1983 {
1985 {
1986 p->asParameters()->DataObjects_Get_Projection(Projection);
1987 }
1988 else if( p->is_Input() )
1989 {
1990 if( p->is_DataObject()
1992 && p->asDataObject() != DATAOBJECT_CREATE )
1993 {
1995 }
1996 else if( p->is_DataObject_List() )
1997 {
1998 for(int j=0; j<p->asList()->Get_Item_Count() && !Projection.is_Okay(); j++)
1999 {
2001 }
2002 }
2003 }
2004 }
2005 }
2006
2007 return( Projection.is_Okay() );
2008}
2009
2010//---------------------------------------------------------
2011bool CSG_Parameters::DataObjects_Set_Projection(const CSG_Projection &Projection)
2012{
2013 if( !Projection.is_Okay() )
2014 {
2015 return( false );
2016 }
2017
2018 for(int i=0; i<Get_Count(); i++)
2019 {
2020 CSG_Parameter *p = m_Parameters[i];
2021
2022 if( !p->ignore_Projection() )
2023 {
2025 {
2026 p->asParameters()->DataObjects_Set_Projection(Projection);
2027 }
2028 else if( p->is_Output() )
2029 {
2030 if( p->is_DataObject()
2032 && p->asDataObject() != DATAOBJECT_CREATE )
2033 {
2035 }
2036 else if( p->is_DataObject_List() )
2037 {
2038 for(int j=0; j<p->asList()->Get_Item_Count(); j++)
2039 {
2041 }
2042 }
2043 }
2044 }
2045 }
2046
2047 return( true );
2048}
2049
2050
2052// //
2054
2055//---------------------------------------------------------
2056bool CSG_Parameters::Get_String(CSG_String &String, bool bOptionsOnly)
2057{
2058 bool bResult = false;
2059
2060 if( Get_Count() > 0 )
2061 {
2062 if( m_pGrid_System )
2063 {
2064 m_pGrid_System->_Set_String();
2065
2066 String += CSG_String::Format("%s: %s\n", m_pGrid_System->Get_Name(), m_pGrid_System->asString());
2067 }
2068
2069 for(int i=0; i<Get_Count(); i++)
2070 {
2071 CSG_Parameter &P = *m_Parameters[i];
2072
2073 if( (!bOptionsOnly || P.is_Option()) && !P.asGrid_System() && P.is_Enabled() && !P.is_Information() && !(P.Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)&P)->is_Password()) )
2074 {
2075 bResult = true;
2076
2077 P._Set_String(); // forcing update (at scripting level some parameter types can be changed without the Set_Parameter() mechanism)
2078
2079 CSG_String s(P.asString()); if( s.Length() > 256 ) { s = s.Left(256) + "..."; }
2080
2081 String += CSG_String::Format("%s: %s\n", P.Get_Name(), s.c_str());
2082 }
2083 }
2084 }
2085
2086 return( bResult );
2087}
2088
2089//---------------------------------------------------------
2090bool CSG_Parameters::Msg_String(bool bOptionsOnly)
2091{
2092 CSG_String Message;
2093
2094 if( Get_String(Message, bOptionsOnly) )
2095 {
2096 SG_UI_Msg_Add_Execution(CSG_String::Format("\n__________\n[%s] %s:\n", m_Name.c_str(),
2097 bOptionsOnly ? _TL("Options") : _TL("Parameters")),
2099 );
2100
2102
2103 return( true );
2104 }
2105
2106 return( false );
2107}
2108
2109
2111// //
2113
2114//---------------------------------------------------------
2115bool CSG_Parameters::Set_History(CSG_MetaData &MetaData, bool bOptions, bool bDataObjects)
2116{
2117 if( bOptions ) // get options...
2118 {
2119 for(int i=0; i<Get_Count(); i++)
2120 {
2121 CSG_Parameter &P = *m_Parameters[i];
2122
2123 if( P.is_Option() && P.is_Enabled() && !P.is_Information() && !(P.Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)&P)->is_Password()) )
2124 {
2125 P.Serialize(MetaData, true);
2126 }
2127 else if( P.is_Parameters() )
2128 {
2129 P.asParameters()->Set_History(MetaData, true, false);
2130 }
2131 }
2132 }
2133
2134 //-----------------------------------------------------
2135 if( bDataObjects ) // get input with history...
2136 {
2137 for(int i=0; i<Get_Count(); i++)
2138 {
2139 CSG_Parameter &P = *m_Parameters[i];
2140
2141 //---------------------------------------------
2142 if( P.is_Input() )
2143 {
2144 if( P.is_DataObject() && P.asDataObject() )
2145 {
2146 CSG_Data_Object *pObject = P.asDataObject();
2147
2148 CSG_MetaData *pEntry = MetaData.Add_Child("INPUT");
2149
2150 pEntry->Add_Property("type" , P.Get_Type_Identifier());
2151 pEntry->Add_Property("id" , P.Get_Identifier ());
2152 pEntry->Add_Property("name" , P.Get_Name ());
2153 pEntry->Add_Property("parms", Get_Identifier ());
2154
2155 if( P.Get_Type() == PARAMETER_TYPE_Grid
2156 || P.Get_Type() == PARAMETER_TYPE_Grids )
2157 {
2158 pEntry->Add_Property("system", P.Get_Parent()->Get_Identifier());
2159 }
2160
2161 if( pObject->Get_History().Get_Children_Count() > 0 )
2162 {
2163 pEntry->Add_Children(pObject->Get_History());
2164 }
2165 else if( pObject->Get_File_Name() && *pObject->Get_File_Name() )
2166 {
2167 pEntry = pEntry->Add_Child("FILE", pObject->Get_File_Name());
2168 }
2169 }
2170
2171 else if( P.is_DataObject_List() && P.asList()->Get_Item_Count() > 0 )
2172 {
2173 CSG_MetaData *pList = MetaData.Add_Child("INPUT_LIST");
2174
2175 pList->Add_Property("type" , P.Get_Type_Identifier());
2176 pList->Add_Property("id" , P.Get_Identifier ());
2177 pList->Add_Property("name" , P.Get_Name ());
2178 pList->Add_Property("parms", Get_Identifier ());
2179
2181 {
2182 pList->Add_Property("system", P.Get_Parent()->Get_Identifier());
2183 }
2184
2185 for(int j=0; j<P.asList()->Get_Item_Count(); j++)
2186 {
2187 CSG_Data_Object *pObject = P.asList()->Get_Item(j);
2188
2189 CSG_MetaData *pEntry = pList->Add_Child(*pList, false);
2190
2191 pEntry->Set_Name("INPUT");
2192
2194 {
2195 pEntry->Add_Children(pObject->Get_History());
2196 }
2197 else if( pObject->Get_File_Name() && *pObject->Get_File_Name() )
2198 {
2199 pEntry = pEntry->Add_Child("FILE", pObject->Get_File_Name());
2200 }
2201 }
2202 }
2203 }
2204
2205 //---------------------------------------------
2206 else if( P.is_Parameters() )
2207 {
2208 P.asParameters()->Set_History(MetaData, false, true);
2209 }
2210 }
2211 }
2212
2213 return( true );
2214}
2215
2216
2218// //
2219// Grid System //
2220// //
2222
2223//---------------------------------------------------------
2230{
2231 return( m_pGrid_System && m_pGrid_System->asGrid_System() && m_pGrid_System->Set_Value((void *)&System) );
2232}
2233
2234//---------------------------------------------------------
2241{
2242 CSG_Grid_System System;
2243
2244 return( Set_Grid_System(System) );
2245}
2246
2247
2249// //
2250// Serialize //
2251// //
2253
2254//---------------------------------------------------------
2256{
2257 if( Data.Cmp_Name("parameters") )
2258 {
2259 Data.Get_Property("name", m_Name);
2260
2261 for(int i=0; i<Data.Get_Children_Count(); i++)
2262 {
2263 CSG_Parameter *pParameter = Get_Parameter(Data(i)->Get_Property("id"));
2264
2265 if( pParameter && pParameter->Serialize(*Data(i), false) )
2266 {
2267 pParameter->has_Changed();
2268 }
2269 }
2270
2271 return( true );
2272 }
2273
2274 return( false );
2275}
2276
2277//---------------------------------------------------------
2279{
2280 Data.Destroy();
2281
2282 Data.Set_Name("parameters");
2283 Data.Set_Property("name", m_Name);
2284
2285 for(int i=0; i<Get_Count(); i++)
2286 {
2287 m_Parameters[i]->Serialize(Data, true);
2288 }
2289
2290 return( true );
2291}
2292
2293//---------------------------------------------------------
2294bool CSG_Parameters::Load(const char *File) { return( Load(CSG_String(File)) ); }
2295bool CSG_Parameters::Load(const wchar_t *File) { return( Load(CSG_String(File)) ); }
2297{
2298 CSG_MetaData Data; return( Data.Load(File) && Load(Data) );
2299}
2300
2301//---------------------------------------------------------
2302bool CSG_Parameters::Save(const char *File) const { return( Save(CSG_String(File)) ); }
2303bool CSG_Parameters::Save(const wchar_t *File) const { return( Save(CSG_String(File)) ); }
2304bool CSG_Parameters::Save(const CSG_String &File) const
2305{
2306 CSG_MetaData Data; return( Save(Data) && Data.Save(File) );
2307}
2308
2309//---------------------------------------------------------
2310// SAGA 2.0 compatibility...
2312{
2313 CSG_Parameter *pParameter = NULL;
2314 CSG_String sLine;
2315
2316 if( !Stream.is_Open() )
2317 {
2318 return( false );
2319 }
2320
2321 //-----------------------------------------------------
2322 while( Stream.Read_Line(sLine) && sLine.Cmp("[PARAMETER_ENTRIES_BEGIN]") );
2323
2324 if( sLine.Cmp("[PARAMETER_ENTRIES_BEGIN]") )
2325 {
2326 return( false );
2327 }
2328
2329 //-----------------------------------------------------
2330 while( Stream.Read_Line(sLine) && sLine.Cmp("[PARAMETER_ENTRIES_END]") )
2331 {
2332 if( !sLine.Cmp("[PARAMETER_ENTRY_BEGIN]")
2333 && Stream.Read_Line(sLine) && (pParameter = Get_Parameter(sLine)) != NULL
2334 && Stream.Read_Line(sLine) )
2335 {
2336 int i;
2337 double d;
2338 TSG_Rect r;
2339 CSG_String s;
2340 CSG_Table t;
2341
2342 switch( sLine.asInt() )
2343 {
2344 case 1: // PARAMETER_TYPE_Bool:
2345 case 2: // PARAMETER_TYPE_Int:
2346 case 6: // PARAMETER_TYPE_Choice:
2347 case 11: // PARAMETER_TYPE_Color:
2348 case 15: // PARAMETER_TYPE_Table_Field:
2349 pParameter->Set_Value(Stream.Scan_Int());
2350 break;
2351
2352 case 3: // PARAMETER_TYPE_Double:
2353 case 4: // PARAMETER_TYPE_Degree:
2354 pParameter->Set_Value(Stream.Scan_Double());
2355 break;
2356
2357 case 5: // PARAMETER_TYPE_Range:
2358 pParameter->asRange()->Set_Range(Stream.Scan_Double(), Stream.Scan_Double());
2359 break;
2360
2361 case 7: // PARAMETER_TYPE_String:
2362 case 9: // PARAMETER_TYPE_FilePath:
2363 Stream.Read_Line(sLine);
2364 pParameter->Set_Value(sLine);
2365 break;
2366
2367 case 8: // PARAMETER_TYPE_Text:
2368 s.Clear();
2369 while( Stream.Read_Line(sLine) && sLine.Cmp("[TEXT_ENTRY_END]") )
2370 {
2371 s += sLine + "\n";
2372 }
2373 pParameter->Set_Value(s);
2374 break;
2375
2376 case 10: // PARAMETER_TYPE_Font:
2377 Stream.Read(&i, sizeof(i));
2378 pParameter->Set_Value(i);
2379 break;
2380
2381 case 12: // PARAMETER_TYPE_Colors:
2382 pParameter->asColors()->Serialize(Stream, false, false);
2383 break;
2384
2385 case 13: // PARAMETER_TYPE_FixedTable:
2386 if( t.Serialize(Stream, false) )
2387 {
2388 pParameter->asTable()->Assign_Values(&t);
2389 }
2390 break;
2391
2392 case 14: // PARAMETER_TYPE_Grid_System:
2393 Stream.Read(&d, sizeof(d));
2394 Stream.Read(&r, sizeof(r));
2395 pParameter->asGrid_System()->Assign(d, r);
2396 break;
2397
2398 case 16: // PARAMETER_TYPE_Grid:
2399 case 17: // PARAMETER_TYPE_Table:
2400 case 18: // PARAMETER_TYPE_Shapes:
2401 case 19: // PARAMETER_TYPE_TIN:
2402 case 24: // PARAMETER_TYPE_DataObject_Output:
2403 if( Stream.Read_Line(sLine) )
2404 {
2405 if( !sLine.Cmp("[ENTRY_DATAOBJECT_CREATE]") )
2406 {
2407 pParameter->Set_Value(DATAOBJECT_CREATE);
2408 }
2409 else
2410 {
2411 pParameter->Set_Value(m_pManager ? m_pManager->Find(sLine) : NULL);
2412 }
2413 }
2414 break;
2415
2416 case 20: // PARAMETER_TYPE_Grid_List:
2417 case 21: // PARAMETER_TYPE_Table_List:
2418 case 22: // PARAMETER_TYPE_Shapes_List:
2419 case 23: // PARAMETER_TYPE_TIN_List:
2420 while( Stream.Read_Line(sLine) && sLine.Cmp("[ENTRY_DATAOBJECTLIST_END]") )
2421 {
2422 CSG_Data_Object *pObject = m_pManager ? m_pManager->Find(sLine) : NULL;
2423
2424 if( pObject )
2425 {
2426 pParameter->asList()->Add_Item(pObject);
2427 }
2428 }
2429 break;
2430
2431 case 25: // PARAMETER_TYPE_Parameters:
2432 pParameter->asParameters()->Serialize_Compatibility(Stream);
2433 break;
2434 }
2435 }
2436 }
2437
2438 return( true );
2439}
2440
2441//---------------------------------------------------------
2443{
2444 m_Info = HTML;
2445 m_bInfo = true;
2446}
2447
2448
2450// //
2451// //
2452// //
2454
2455//---------------------------------------------------------
bool SG_UI_DataObject_Update(CSG_Data_Object *pDataObject, int Show, CSG_Parameters *pParameters)
void SG_UI_Msg_Add_Error(const char *Message)
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)
void * SG_UI_Get_Window_Main(void)
void SG_UI_Dlg_Message(const CSG_String &Message, const CSG_String &Caption)
@ SG_UI_MSG_STYLE_NORMAL
Definition api_core.h:1632
@ SG_UI_MSG_STYLE_01
Definition api_core.h:1639
signed long long sLong
Definition api_core.h:158
#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
TSG_Data_Type
Definition api_core.h:1043
@ SG_DATATYPE_String
Definition api_core.h:1055
#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)
bool Serialize(CSG_File &Stream, bool bSave, bool bBinary)
bool Create(void)
const SG_Char * Get_Name(void) const
void Set_Name(const CSG_String &Name)
virtual bool is_Valid(void) const =0
CSG_MetaData & Get_MetaData(void) const
Definition dataobject.h:237
const SG_Char * Get_File_Name(bool bNative=true) const
class CSG_Shapes * asShapes(bool bPolymorph=false) const
CSG_MetaData & Get_History(void)
Definition dataobject.h:239
CSG_Projection & Get_Projection(void)
class CSG_Grids * asGrids(bool bPolymorph=false) const
class CSG_Grid * asGrid(bool bPolymorph=false) const
double Get_JDN(void) const
Definition datetime.cpp:426
static CSG_DateTime Now(void)
Definition datetime.cpp:600
bool is_Open(void) const
Definition api_core.h:1195
bool Read_Line(CSG_String &Line) const
Definition api_file.cpp:409
int Scan_Int(void) const
Definition api_file.cpp:567
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
Definition api_file.cpp:338
double Scan_Double(void) const
Definition api_file.cpp:572
bool Assign(const CSG_Grid_System &System)
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
const CSG_Grid_System & Get_System(void) const
Definition grids.h:184
virtual bool Create(const CSG_Grids &Grids)
Definition grids.cpp:319
bool Cmp_Name(const CSG_String &String, bool bNoCase=true) const
Definition metadata.cpp:487
bool Save(const CSG_String &File, const SG_Char *Extension=NULL) const
Definition metadata.cpp:907
bool Del_Children(int Depth=0, const SG_Char *Name=NULL)
Definition metadata.cpp:384
int Get_Children_Count(void) const
Definition metadata.h:154
bool Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists=true)
Definition metadata.cpp:641
bool Add_Children(const CSG_MetaData &MetaData)
Definition metadata.cpp:362
const SG_Char * Get_Property(int Index) const
Definition metadata.h:188
void Set_Name(const CSG_String &Name)
Definition metadata.h:136
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:169
bool Load(const CSG_String &File, const SG_Char *Extension=NULL)
Definition metadata.cpp:812
void Destroy(void)
Definition metadata.cpp:143
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition metadata.cpp:585
CSG_String Get_Items(bool bIncludeData=false) const
bool Set_Items(const SG_Char *String)
void Set_Items(const CSG_String &Items)
bool Set_Data_Types(int Data_Types, TSG_Data_Type Default=SG_DATATYPE_Undefined, const CSG_String &User="")
void Set_Filter(const SG_Char *Filter)
void Set_Flag_Directory(bool bFlag)
void Set_Flag_Save(bool bFlag)
void Set_Flag_Multiple(bool bFlag)
virtual TSG_Parameter_Type Get_Type(void) const
virtual bool Del_Item(CSG_Data_Object *pItem, bool bUpdateData=true)
CSG_Data_Object * Get_Item(int Index) const
virtual bool Add_Item(CSG_Data_Object *pItem)
int Get_Item_Count(void) const
CSG_Parameter_Double * Get_Min_Parameter(void) const
Definition parameters.h:629
CSG_Parameter_Double * Get_Max_Parameter(void) const
Definition parameters.h:633
bool Set_Max(double Max)
bool Set_Min(double Min)
bool Set_Range(double Min, double Max)
virtual TSG_Parameter_Type Get_Type(void) const
double Get_Minimum(void) const
Definition parameters.h:449
double Get_Maximum(void) const
Definition parameters.h:453
void Set_Minimum(double Minimum, bool bOn=true)
bool has_Maximum(void) const
Definition parameters.h:454
bool has_Minimum(void) const
Definition parameters.h:450
void Set_Maximum(double Maximum, bool bOn=true)
const SG_Char * Get_Identifier(void) const
bool is_DataObject(void) const
class CSG_Parameters * asParameters(void) const
bool Check(bool bSilent=true)
bool Assign(CSG_Parameter *pSource)
bool is_Parameters(void) const
CSG_String Get_Type_Identifier(void) const
void ignore_Projection(bool bIgnore)
bool Set_Default(int Value)
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 Serialize(CSG_MetaData &MetaData, bool bSave)
int Get_Children_Count(void) const
Definition parameters.h:259
class CSG_Parameter_Choice * asChoice(void) const
class CSG_Parameter_Value * asValue(void) const
CSG_Parameter * Get_Parent(void) const
virtual TSG_Parameter_Type Get_Type(void) const =0
class CSG_Parameter_Data_Type * asDataType(void) const
bool is_Input(void) const
Definition parameters.h:236
const SG_Char * Get_Name(void) const
class CSG_Parameter_Choices * asChoices(void) const
virtual void _Set_String(void)
CSG_Colors * asColors(void) const
bool is_Enabled(bool bCheckEnv=true) const
bool is_Option(void) const
virtual bool Set_Value(int Value)
class CSG_Parameter_List * asList(void) const
CSG_Grid_System * asGrid_System(void) const
CSG_Data_Object * asDataObject(void) const
class CSG_Parameter_Range * asRange(void) const
CSG_Parameter * Get_Child(int iChild) const
Definition parameters.h:260
bool is_Output(void) const
Definition parameters.h:237
bool has_Changed(int Check_Flags=PARAMETER_CHECK_ALL)
class CSG_Parameter_File_Name * asFilePath(void) const
bool is_Information(void) const
Definition parameters.h:239
const SG_Char * asString(void) const
Definition parameters.h:290
const CSG_String & Get_Default(void) const
CSG_Table * asTable(void) const
const SG_Char * Get_Description(void) const
bool is_DataObject_List(void) const
void Set_Tool(class CSG_Tool *pTool)
CSG_Parameter * Add_TIN_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
virtual ~CSG_Parameters(void)
CSG_Parameter * Add_Shapes_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
CSG_Parameter * Add_Table_Fields(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
void Set_Name(const CSG_String &Name)
CSG_Parameter * Add_TIN(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
bool Set_Callback(bool bActive=true)
CSG_Parameter * Add_Grid_Resampling(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Grid_Resampling Methods=CSG_Grid_Resampling::Interpolations, CSG_Grid_Resampling Default=CSG_Grid_Resampling::Bicubic_2)
bool has_GUI(void) const
CSG_Parameter * Add_Table_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
CSG_Parameter * Add_Table(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
CSG_Parameter * Add_Parameter(CSG_Parameter *pParameter)
const CSG_String & Get_Identifier(void) const
CSG_Parameter * Add_Info_Value(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, TSG_Parameter_Type Type, double Value=0.0)
CSG_Parameter * Add_Shapes_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, TSG_Shape_Type=SHAPE_TYPE_Undefined)
CSG_Parameter * Add_Grids_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true)
CSG_Parameter * Add_Grid_System(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Grid_System *pInit=NULL)
CSG_Parameter * Add_Choice(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items, int Default=0)
bool Reset_Grid_System(void)
CSG_Parameter * Add_PointCloud(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
bool Msg_String(bool bOptionsOnly)
CSG_Parameter * Add_Shapes(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, TSG_Shape_Type Shape_Type=SHAPE_TYPE_Undefined)
int Get_Count(void) const
CSG_Parameter * Add_TIN_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
CSG_Parameter * Add_Table_Field_or_Const(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
void Set_Manager(class CSG_Data_Manager *pManager)
class CSG_Tool * Get_Tool(void) const
CSG_Parameter * Add_Grid_or_Const(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false, bool bSystem_Dependent=true)
bool Use_Grid_System(void)
void Set_Enabled(bool bEnabled=true)
bool Get_String(CSG_String &String, bool bOptionsOnly)
CSG_Parameter * Add_Choices(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items)
bool Set_History(CSG_MetaData &History, bool bOptions=true, bool bDataObjects=true)
CSG_Parameter * Add_Degree(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
CSG_Parameter * Add_Grid_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
void Set_Description(const CSG_String &Description)
bool Set_Grid_System(const CSG_Grid_System &System)
CSG_Parameter * Add_FilePath(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const SG_Char *Filter=NULL, const SG_Char *Default=NULL, bool bSave=false, bool bDirectory=false, bool bMultiple=false)
CSG_Parameter * Add_Table_Field(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bAllowNone=false)
bool Del_Parameters(void)
void Set_Identifier(const CSG_String &Identifier)
bool Get_Parameter_Listing(CSG_Table &Listing) const
CSG_Parameter * Add_Value(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, TSG_Parameter_Type Type, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
CSG_Parameter * Add_Double(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
const CSG_String & Get_Name(void) const
CSG_Parameter * Add_PointCloud_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
CSG_Parameter * Get_Parameter(int i) const
bool Create(const CSG_Parameters &Parameters)
bool Restore_Defaults(bool bClearData=false)
CSG_Parameter * Add_Grids(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true, TSG_Data_Type Preferred_Type=SG_DATATYPE_Undefined)
bool Serialize_Compatibility(CSG_File &Stream)
friend class CSG_Tool
CSG_Parameter * Add_Parameters(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
bool Push(class CSG_Data_Manager *pManager=NULL, bool bRestoreDefaults=true)
CSG_Parameter * Add_Int(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value=0, int Minimum=0, bool bMinimum=false, int Maximum=0, bool bMaximum=false)
TSG_PFNC_Parameter_Changed Set_Callback_On_Parameter_Changed(TSG_PFNC_Parameter_Changed pCallback)
bool DataObjects_Check(bool bSilent=false)
bool Del_Parameter(int i)
void Set_Info(const CSG_String &HTML)
CSG_Parameter * Add_Node(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bCollapsed=false)
bool Assign_Parameters(const CSG_Parameters *pSource)
bool Assign_Values(const CSG_Parameters *pSource)
CSG_Parameter * Add_Color(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value=0)
CSG_Parameter * Add_Grid_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true)
CSG_Parameter * Add_Grids_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
void * Get_Owner(void) const
void Destroy(void)
const CSG_String & Get_Description(void) const
CSG_Parameter * Add_FixedTable(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Table *pInit=NULL)
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
CSG_Parameter * Add_Table_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
CSG_Parameter * Add_Font(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const SG_Char *pInit=NULL)
CSG_Parameter * Add_Data_Type(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Data_Types, TSG_Data_Type Default=SG_DATATYPE_Undefined, const CSG_String &User="")
bool Save(CSG_MetaData &Data) const
bool Pop(void)
CSG_Parameter * Add_Bool(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool Value=false)
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)
CSG_Parameter * Add_Date(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0)
friend class CSG_Parameter
CSG_Parameter * Add_Info_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 Cmp_Identifier(const CSG_String &Identifier) const
CSG_Parameter * Add_Range(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Range_Min=0.0, double Range_Max=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
CSG_Parameter * Add_Grid(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true, TSG_Data_Type Preferred_Type=SG_DATATYPE_Undefined)
bool Assign(const CSG_Parameters *pSource)
CSG_Parameter * Add_PointCloud_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
CSG_Parameter * Add_Colors(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Palette=0, int nColors=11, bool bRevert=false)
CSG_Parameter * Add_Info_Range(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Range_Min=0.0, double Range_Max=0.0)
bool Load(const CSG_MetaData &Data)
bool Create(const CSG_Shapes &Shapes)
Definition shapes.cpp:209
virtual TSG_Shape_Type Get_Type(void) const
Definition shapes.h:814
size_t Length(void) const
CSG_String AfterFirst(char Character) const
bool asInt(int &Value) const
int CmpNoCase(const CSG_String &String) const
int Cmp(const CSG_String &String) const
void Clear(void)
CSG_String BeforeFirst(char Character) const
size_t Replace(const CSG_String &Old, const CSG_String &New, bool bReplaceAll=true)
static CSG_String Format(const char *Format,...)
CSG_String & Append(const CSG_String &String)
int Find(char Character, bool fromEnd=false) const
const SG_Char * c_str(void) const
int Printf(const char *Format,...)
bool is_Empty(void) const
CSG_String Left(size_t count) const
bool Set_Value(int Field, const CSG_String &Value)
bool Create(void)
Definition table.cpp:153
sLong Get_Count(void) const
Definition table.h:410
virtual bool Destroy(void)
Definition table.cpp:314
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
Definition table.cpp:823
bool Assign_Values(const CSG_Table &Table)
Definition table.cpp:378
bool Sort(const char *Field, bool bAscending=true)
Definition table.cpp:1390
int Get_Field_Count(void) const
Definition table.h:371
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition table.cpp:479
bool Serialize(CSG_File &Stream, bool bSave)
Definition table_io.cpp:706
CSG_Data_Manager & SG_Get_Data_Manager(void)
int SG_Get_History_Ignore_Lists(void)
@ 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 ADD_METHOD(method, name)
int(* TSG_PFNC_Parameter_Changed)(CSG_Parameter *pParameter, int Flags)
#define PARAMETER_INPUT_OPTIONAL
Definition parameters.h:103
#define PARAMETER_INFORMATION
Definition parameters.h:97
#define PARAMETER_OUTPUT_OPTIONAL
Definition parameters.h:104
#define PARAMETER_OPTIONAL
Definition parameters.h:96
#define PARAMETER_GUI_COLLAPSED
Definition parameters.h:101
TSG_Parameter_Type
Definition parameters.h:123
@ 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
CSG_PointCloud * SG_Create_PointCloud(void)
CSG_Shapes * SG_Create_Shapes(void)
Definition shapes.cpp:85
TSG_Shape_Type
Definition shapes.h:100
@ SHAPE_TYPE_Undefined
Definition shapes.h:101
CSG_Table * SG_Create_Table(void)
Definition table.cpp:65
CSG_TIN * SG_Create_TIN(void)
Definition tin.cpp:63