SAGA API v9.10
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
123//---------------------------------------------------------
125{
126 Destroy();
127
128 Set_Identifier (Parameters.Get_Identifier ());
129 Set_Name (Parameters.Get_Name ());
130 Set_Description(Parameters.Get_Description());
131
132 m_pOwner = Parameters.m_pOwner;
133 m_pTool = Parameters.m_pTool;
134 m_pManager = Parameters.m_pManager;
135
136 m_Callback = Parameters.m_Callback;
137 m_bCallback = Parameters.m_bCallback;
138
139 for(int i=0; i<Parameters.m_nParameters; i++)
140 {
141 _Add(Parameters.m_Parameters[i]);
142 }
143
144 if( Parameters.m_pGrid_System )
145 {
146 m_pGrid_System = Get_Parameter(Parameters.m_pGrid_System->Get_Identifier());
147 }
148
149 return( m_nParameters == Parameters.m_nParameters );
150}
151
152//---------------------------------------------------------
153bool CSG_Parameters::Create(const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
154{
155 Destroy();
156
157 Set_Identifier (Identifier);
158 Set_Name (Name);
159 Set_Description(Description ? Description : SG_T(""));
160
161 if( bGrid_System )
162 {
164 }
165
166 return( true );
167}
168
169//---------------------------------------------------------
170bool CSG_Parameters::Create(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
171{
172 if( Create(Name, Description, Identifier, bGrid_System) )
173 {
174 m_pOwner = pOwner;
175
176 return( true );
177 }
178
179 return( false );
180}
181
182//---------------------------------------------------------
184{
185 Pop();
186
187 m_pOwner = NULL;
188 m_pTool = NULL;
189 m_pGrid_System = NULL;
190
192
193 m_References.Clear();
194}
195
196
198// //
200
201//---------------------------------------------------------
203{
204 m_pTool = pTool;
205
206 for(int i=0; i<Get_Count(); i++)
207 {
208 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters )
209 {
210 m_Parameters[i]->asParameters()->Set_Tool(pTool);
211 }
212 }
213}
214
215//---------------------------------------------------------
222//---------------------------------------------------------
224{
225 m_pManager = pManager;
226
227 for(int i=0; i<Get_Count(); i++)
228 {
229 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters )
230 {
231 m_Parameters[i]->asParameters()->Set_Manager(pManager);
232 }
233 }
234}
235
236//---------------------------------------------------------
240//---------------------------------------------------------
242{
243 if( !m_pGrid_System )
244 {
245 m_pGrid_System = Add_Grid_System("", "PARAMETERS_GRID_SYSTEM", _TL("Grid System"), _TL(""));
246
247 return( true );
248 }
249
250 return( false );
251}
252
253
254//---------------------------------------------------------
261//---------------------------------------------------------
262bool CSG_Parameters::Push(CSG_Data_Manager *pManager, bool bRestoreDefaults)
263{
264 CSG_Parameters *pStack = m_pStack;
265
266 m_pStack = new CSG_Parameters(*this);
267
268 m_pStack->m_pStack = pStack;
269
270 m_pManager = pManager;
271
272 if( bRestoreDefaults )
273 {
274 Restore_Defaults(true);
275 }
276
277 return( true );
278}
279
280//---------------------------------------------------------
284//---------------------------------------------------------
286{
287 if( m_pStack )
288 {
289 m_pManager = m_pStack->m_pManager;
290
291 Assign_Values(m_pStack);
292
293 CSG_Parameters *pStack = m_pStack->m_pStack;
294
295 delete( m_pStack );
296
297 m_pStack = pStack;
298
299 return( true );
300 }
301
302 return( false );
303}
304
305//---------------------------------------------------------
310//---------------------------------------------------------
312{
313 return( Get_Tool() ? Get_Tool()->has_GUI() : (Get_Owner() && SG_UI_Get_Window_Main()) );
314}
315
316//---------------------------------------------------------
320//---------------------------------------------------------
322{
323 m_Identifier = Identifier;
324}
325
326//---------------------------------------------------------
330//---------------------------------------------------------
331bool CSG_Parameters::Cmp_Identifier(const CSG_String &Identifier) const
332{
333 return( m_Identifier.Cmp(Identifier) == 0 );
334}
335
336//---------------------------------------------------------
340//---------------------------------------------------------
342{
343 m_Name = Name;
344}
345
346//---------------------------------------------------------
350//---------------------------------------------------------
352{
353 m_Description = Description;
354}
355
356//---------------------------------------------------------
360//---------------------------------------------------------
361void CSG_Parameters::Add_Reference(const CSG_String &Authors, const CSG_String &Year, const CSG_String &Title, const CSG_String &Where, const SG_Char *Link, const SG_Char *Link_Text)
362{
363 CSG_String Reference("<b>" + Authors + " (" + Year + "):</b> " + Title + ". " + Where);
364
365 if( Link && *Link )
366 {
367 Reference += CSG_String::Format(" <a href=\"%s\">%s</a>.", Link, Link_Text && *Link_Text ? Link_Text : Link);
368 }
369
370 if( !Reference.is_Empty() )
371 {
372 m_References += Reference;
373 }
374
375 m_References.Sort();
376}
377
378//---------------------------------------------------------
382//---------------------------------------------------------
383void CSG_Parameters::Add_Reference(const CSG_String &Link, const SG_Char *Link_Text)
384{
385 m_References += CSG_String::Format("<a href=\"%s\">%s</a>", Link.c_str(), Link_Text && *Link_Text ? Link_Text : Link.c_str());
386
387 m_References.Sort();
388}
389
390//---------------------------------------------------------
394//---------------------------------------------------------
396{
397 m_References.Clear();
398}
399
400//---------------------------------------------------------
404//---------------------------------------------------------
406{
407 for(int i=0; i<m_nParameters; i++)
408 {
409 m_Parameters[i]->Set_Enabled(bEnabled);
410 }
411}
412
413//---------------------------------------------------------
417//---------------------------------------------------------
418void CSG_Parameters::Set_Enabled(const CSG_String &Identifier, bool bEnabled)
419{
420 CSG_Parameter *pParameter = Get_Parameter(Identifier);
421
422 if( pParameter )
423 {
424 pParameter->Set_Enabled(bEnabled);
425 }
426}
427
428
430// //
432
433//---------------------------------------------------------
435{
436 return( _Add(pParameter) );
437}
438
439//---------------------------------------------------------
440CSG_Parameter * CSG_Parameters::Add_Node(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bCollapsed)
441{
442 return( _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Node, bCollapsed ? PARAMETER_GUI_COLLAPSED|PARAMETER_INFORMATION : PARAMETER_INFORMATION) );
443}
444
445//---------------------------------------------------------
454CSG_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)
455{
456 return( _Add_Value(ParentID, ID, Name, Description, false, Type, Value, Minimum, bMinimum, Maximum, bMaximum) );
457}
458
459CSG_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)
460{
461 return( _Add_Value(ParentID, ID, Name, Description, true, Type, Value, 0.0, false, 0.0, false) );
462}
463
464//---------------------------------------------------------
465CSG_Parameter * CSG_Parameters::Add_Bool (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool Value)
466{
467 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Bool , Value ? 1.0 : 0.0) );
468}
469
470CSG_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)
471{
472 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Int , Value, Minimum, bMinimum, Maximum, bMaximum) );
473}
474
475CSG_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)
476{
477 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Double, Value, Minimum, bMinimum, Maximum, bMaximum) );
478}
479
480CSG_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)
481{
482 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Degree, Value, Minimum, bMinimum, Maximum, bMaximum) );
483}
484
485CSG_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
486{
487 if( !Value )
488 {
489 Value = CSG_DateTime::Now().Get_JDN();
490 }
491
492 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Date , Value) );
493}
494
495CSG_Parameter * CSG_Parameters::Add_Color (const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value)
496{
497 return( Add_Value(ParentID, ID, Name, Description, PARAMETER_TYPE_Color , Value) );
498}
499
500//---------------------------------------------------------
501CSG_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)
502{
503 return( _Add_Range(ParentID, ID, Name, Description, false, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) );
504}
505
506CSG_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)
507{
508 return( _Add_Range(ParentID, ID, Name, Description, true, Range_Min, Range_Max, 0.0, false, 0.0, false) );
509}
510
511//---------------------------------------------------------
520//---------------------------------------------------------
521CSG_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)
522{
523 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Data_Type, 0);
524
525 bool bCallback = Set_Callback(false);
526 pParameter->asDataType()->Set_Data_Types(Data_Types, Default, User);
527 Set_Callback(bCallback);
528
529 return( pParameter );
530}
531
532//---------------------------------------------------------
533CSG_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)
534{
535 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Choice, 0);
536
537 pParameter->asChoice()->Set_Items(Items);
538
539 bool bCallback = Set_Callback(false);
540 pParameter->Set_Value (Default);
541 pParameter->Set_Default(Default);
542 Set_Callback(bCallback);
543
544 return( pParameter );
545}
546
547//---------------------------------------------------------
548CSG_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)
549{
550 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Choices, 0);
551
552 pParameter->asChoices()->Set_Items(Items);
553
554 return( pParameter );
555}
556
557//---------------------------------------------------------
558CSG_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)
559{
560 return( _Add_String(ParentID, ID, Name, Description, false, String, bLongText, bPassword) );
561}
562
563CSG_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)
564{
565 return( _Add_String(ParentID, ID, Name, Description, true, String, bLongText, false) );
566}
567
568//---------------------------------------------------------
569CSG_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)
570{
571 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_FilePath, 0);
572
573 pParameter->asFilePath()->Set_Filter (Filter );
574 pParameter->asFilePath()->Set_Flag_Save (bSave );
575 pParameter->asFilePath()->Set_Flag_Multiple (bMultiple );
576 pParameter->asFilePath()->Set_Flag_Directory(bDirectory);
577
578 bool bCallback = Set_Callback(false);
579 pParameter->Set_Value (Default);
580 pParameter->Set_Default(Default);
581 Set_Callback(bCallback);
582
583 return( pParameter );
584}
585
586//---------------------------------------------------------
587CSG_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)
588{
589 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Colors, 0);
590
591 pParameter->asColors()->Create(nColors, Palette, bRevert);
592
593 return( pParameter );
594}
595
596CSG_Parameter * CSG_Parameters::Add_Colors(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Colors *pInit)
597{
598 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Colors, 0);
599
600 if( pInit )
601 {
602 pParameter->asColors()->Create(*pInit);
603 }
604
605 return( pParameter );
606}
607
608//---------------------------------------------------------
609CSG_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)
610{
611 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Font, 0);
612
613 if( pInit && *pInit )
614 {
615 bool bCallback = Set_Callback(false);
616 pParameter->Set_Value (pInit);
617 pParameter->Set_Default(pInit);
618 Set_Callback(bCallback);
619 }
620
621 return( pParameter );
622}
623
624//---------------------------------------------------------
625CSG_Parameter * CSG_Parameters::Add_FixedTable(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Table *pTemplate)
626{
627 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_FixedTable, 0);
628
629 pParameter->asTable()->Create(pTemplate);
630 pParameter->asTable()->Set_Name(Name);
631 pParameter->asTable()->Assign_Values(pTemplate);
632
633 return( pParameter );
634}
635
636
638// //
640
641//---------------------------------------------------------
642CSG_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)
643{
644 CSG_String Choices; int Choice = 0, nChoices = 0;
645
646 #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++; }
647
653 ADD_METHOD(CSG_Grid_Resampling::Mean_Cells , _TL("Mean Value (cell area weighted)"));
654 ADD_METHOD(CSG_Grid_Resampling::Minimum , _TL("Minimum Value"));
655 ADD_METHOD(CSG_Grid_Resampling::Maximum , _TL("Maximum Value"));
657
658 //-----------------------------------------------------
659 if( nChoices > 0 )
660 {
661 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Choice, 0);
662
663 pParameter->asChoice()->Set_Items(Choices);
664
665 bool bCallback = Set_Callback(false);
666 pParameter->Set_Value (Choice);
667 pParameter->Set_Default(Choice);
668 Set_Callback(bCallback);
669
670 return( pParameter );
671 }
672
673 return( NULL );
674}
675
676//---------------------------------------------------------
677CSG_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)
678{
679 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Grid_System, 0);
680
681 if( pInit )
682 {
683 pParameter->asGrid_System()->Assign(*pInit);
684 }
685
686 return( pParameter );
687}
688
689//---------------------------------------------------------
690CSG_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)
691{
692 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
693
694 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
695 {
696 SystemID = pParent->Get_Identifier();
697 }
698 else if( bSystem_Dependent && m_pGrid_System )
699 {
700 SystemID = m_pGrid_System->Get_Identifier();
701 }
702 else
703 {
704 pParent = Add_Grid_System(pParent ? pParent->Get_Identifier() : SG_T(""), ID + "_GRIDSYSTEM", _TL("Grid system"), "");
705 SystemID = pParent->Get_Identifier();
706 }
707
708 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grid, Constraint);
709
710 ((CSG_Parameter_Grid *)pParameter)->Set_Preferred_Type(Preferred_Type);
711
712 return( pParameter );
713}
714
715//---------------------------------------------------------
716CSG_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)
717{
718 CSG_Parameter *pParameter = Add_Grid(ParentID, ID, Name, Description, PARAMETER_INPUT_OPTIONAL, bSystem_Dependent);
719
720 ((CSG_Parameter_Grid *)pParameter)->Add_Default(Value, Minimum, bMinimum, Maximum, bMaximum);
721
722 return( pParameter );
723}
724
725//---------------------------------------------------------
726CSG_Parameter * CSG_Parameters::Add_Grid_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
727{
728 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
729
730 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Grid);
731
732 return( pParameter );
733}
734
735//---------------------------------------------------------
736CSG_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)
737{
738 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
739
740 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
741 {
742 SystemID = pParent->Get_Identifier();
743 }
744 else if( bSystem_Dependent && m_pGrid_System && !((Constraint & PARAMETER_OUTPUT) && (Constraint & PARAMETER_OPTIONAL)) )
745 {
746 SystemID = m_pGrid_System->Get_Identifier();
747 }
748
749 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grid_List, Constraint);
750
751 return( pParameter );
752}
753
754
756// //
758
759//---------------------------------------------------------
760CSG_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)
761{
762 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
763
764 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
765 {
766 SystemID = pParent->Get_Identifier();
767 }
768 else if( bSystem_Dependent && m_pGrid_System )
769 {
770 SystemID = m_pGrid_System->Get_Identifier();
771 }
772 else
773 {
774 pParent = Add_Grid_System(pParent ? pParent->Get_Identifier() : SG_T(""), ID + "_GRIDSYSTEM", _TL("Grid system"), "");
775 SystemID = pParent->Get_Identifier();
776 }
777
778 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grids, Constraint);
779
780 ((CSG_Parameter_Grids *)pParameter)->Set_Preferred_Type(Preferred_Type);
781
782 return( pParameter );
783}
784
785//---------------------------------------------------------
786CSG_Parameter * CSG_Parameters::Add_Grids_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
787{
788 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
789
790 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Grids);
791
792 return( pParameter );
793}
794
795//---------------------------------------------------------
796CSG_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)
797{
798 CSG_String SystemID; CSG_Parameter *pParent = Get_Parameter(ParentID);
799
800 if( pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System )
801 {
802 SystemID = pParent->Get_Identifier();
803 }
804 else if( bSystem_Dependent && m_pGrid_System && !((Constraint & PARAMETER_OUTPUT) && (Constraint & PARAMETER_OPTIONAL)) )
805 {
806 SystemID = m_pGrid_System->Get_Identifier();
807 }
808
809 CSG_Parameter *pParameter = _Add(SystemID, ID, Name, Description, PARAMETER_TYPE_Grids_List, Constraint);
810
811 return( pParameter );
812}
813
814
816// //
818
819//---------------------------------------------------------
820CSG_Parameter * CSG_Parameters::Add_Table_Field(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bAllowNone)
821{
822 CSG_Parameter *pParent = Get_Parameter(ParentID);
823
824 if( pParent && (
825 pParent->Get_Type() == PARAMETER_TYPE_Table
826 || pParent->Get_Type() == PARAMETER_TYPE_Shapes
827 || pParent->Get_Type() == PARAMETER_TYPE_TIN
828 || pParent->Get_Type() == PARAMETER_TYPE_PointCloud) )
829 {
830 return( _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table_Field, bAllowNone ? PARAMETER_OPTIONAL : 0) );
831 }
832
833 return( NULL );
834}
835
836//---------------------------------------------------------
837CSG_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)
838{
839 CSG_Parameter *pParameter = Add_Table_Field(ParentID, ID, Name, Description, true);
840
841 if( pParameter )
842 {
843 ((CSG_Parameter_Table_Field *)pParameter)->Add_Default(Value, Minimum, bMinimum, Maximum, bMaximum);
844 }
845
846 return( pParameter );
847}
848
849//---------------------------------------------------------
850CSG_Parameter * CSG_Parameters::Add_Table_Fields(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
851{
852 CSG_Parameter *pParent = Get_Parameter(ParentID);
853
854 if( pParent && (
855 pParent->Get_Type() == PARAMETER_TYPE_Table
856 || pParent->Get_Type() == PARAMETER_TYPE_Shapes
857 || pParent->Get_Type() == PARAMETER_TYPE_TIN
858 || pParent->Get_Type() == PARAMETER_TYPE_PointCloud) )
859 {
860 return( _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table_Fields, 0) );
861 }
862
863 return( NULL );
864}
865
866//---------------------------------------------------------
867CSG_Parameter * CSG_Parameters::Add_Table(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
868{
869 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table, Constraint);
870
871 return( pParameter );
872}
873
874//---------------------------------------------------------
875CSG_Parameter * CSG_Parameters::Add_Table_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
876{
877 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
878
879 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Table);
880
881 return( pParameter );
882}
883
884//---------------------------------------------------------
885CSG_Parameter * CSG_Parameters::Add_Table_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
886{
887 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Table_List, Constraint);
888
889 return( pParameter );
890}
891
892
894// //
896
897//---------------------------------------------------------
898CSG_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)
899{
900 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Shapes, Constraint);
901
902 ((CSG_Parameter_Shapes *)pParameter)->Set_Shape_Type(Shape_Type);
903
904 return( pParameter );
905}
906
907//---------------------------------------------------------
908CSG_Parameter * CSG_Parameters::Add_Shapes_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
909{
910 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
911
912 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_Shapes);
913
914 return( pParameter );
915}
916
917//---------------------------------------------------------
918CSG_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)
919{
920 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Shapes_List, Constraint);
921
922 ((CSG_Parameter_Shapes_List *)pParameter)->Set_Shape_Type(Type);
923
924 return( pParameter );
925}
926
927
929// //
931
932//---------------------------------------------------------
933CSG_Parameter * CSG_Parameters::Add_TIN(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
934{
935 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_TIN, Constraint);
936
937 return( pParameter );
938}
939
940//---------------------------------------------------------
941CSG_Parameter * CSG_Parameters::Add_TIN_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
942{
943 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
944
945 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_TIN);
946
947 return( pParameter );
948}
949
950//---------------------------------------------------------
951CSG_Parameter * CSG_Parameters::Add_TIN_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
952{
953 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_TIN_List, Constraint);
954
955 return( pParameter );
956}
957
958
960// //
962
963//---------------------------------------------------------
964CSG_Parameter * CSG_Parameters::Add_PointCloud(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
965{
966 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_PointCloud, Constraint);
967
968 return( pParameter );
969}
970
971//---------------------------------------------------------
972CSG_Parameter * CSG_Parameters::Add_PointCloud_Output(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
973{
974 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
975
976 ((CSG_Parameter_Data_Object_Output *)pParameter)->Set_DataObject_Type(SG_DATAOBJECT_TYPE_PointCloud);
977
978 return( pParameter );
979}
980
981//---------------------------------------------------------
982CSG_Parameter * CSG_Parameters::Add_PointCloud_List(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
983{
984 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_PointCloud_List, Constraint);
985
986 return( pParameter );
987}
988
989
991// //
993
994//---------------------------------------------------------
995CSG_Parameter * CSG_Parameters::Add_Parameters(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description)
996{
997 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Parameters, 0);
998
999 pParameter->asParameters()->m_Callback = m_Callback;
1000 pParameter->asParameters()->m_pTool = m_pTool;
1001
1002 return( pParameter );
1003}
1004
1005
1007// //
1009
1010//---------------------------------------------------------
1011CSG_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)
1012{
1013 switch( Type ) // Check if Type is valid...
1014 {
1015 case PARAMETER_TYPE_Bool :
1016 case PARAMETER_TYPE_Int :
1019 case PARAMETER_TYPE_Date :
1021 break;
1022
1023 default: // if not valid set Type to [double]...
1024 Type = PARAMETER_TYPE_Double;
1025 }
1026
1027 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, Type, bInformation ? PARAMETER_INFORMATION : 0);
1028
1029 bool bCallback = Set_Callback(false);
1030
1031 if( !bInformation )
1032 {
1033 if( Type == PARAMETER_TYPE_Int
1034 || Type == PARAMETER_TYPE_Double
1035 || Type == PARAMETER_TYPE_Degree )
1036 {
1037 pParameter->asValue()->Set_Minimum(Minimum, bMinimum);
1038 pParameter->asValue()->Set_Maximum(Maximum, bMaximum);
1039 }
1040 }
1041
1042 pParameter->Set_Value(Value);
1043
1044 Set_Callback(bCallback);
1045
1046 if( !bInformation )
1047 {
1048 switch( Type )
1049 {
1050 case PARAMETER_TYPE_Bool :
1051 case PARAMETER_TYPE_Int :
1053 pParameter->Set_Default((int)Value);
1054 break;
1055
1056 case PARAMETER_TYPE_Date :
1057 pParameter->Set_Default(pParameter->asString());
1058 break;
1059
1060 default:
1061 pParameter->Set_Default( Value);
1062 }
1063 }
1064
1065 return( pParameter );
1066}
1067
1068//---------------------------------------------------------
1069CSG_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)
1070{
1071 //-----------------------------------------------------
1072 if( Default_Min > Default_Max )
1073 {
1074 double d = Default_Min;
1075 Default_Min = Default_Max;
1076 Default_Max = d;
1077 }
1078
1079 //-----------------------------------------------------
1080 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, PARAMETER_TYPE_Range, bInformation ? PARAMETER_INFORMATION : 0);
1081
1082 pParameter->asRange()->Get_Min_Parameter()->Set_Minimum(Minimum, bMinimum);
1083 pParameter->asRange()->Get_Min_Parameter()->Set_Maximum(Maximum, bMaximum);
1084 pParameter->asRange()->Get_Min_Parameter()->Set_Default(Default_Min);
1085 pParameter->asRange()->Set_Min(Default_Min);
1086
1087 pParameter->asRange()->Get_Max_Parameter()->Set_Minimum(Minimum, bMinimum);
1088 pParameter->asRange()->Get_Max_Parameter()->Set_Maximum(Maximum, bMaximum);
1089 pParameter->asRange()->Get_Max_Parameter()->Set_Default(Default_Max);
1090 pParameter->asRange()->Set_Max(Default_Max);
1091
1092 return( pParameter );
1093}
1094
1095//---------------------------------------------------------
1096CSG_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)
1097{
1098 CSG_Parameter *pParameter = _Add(ParentID, ID, Name, Description, bLongText ? PARAMETER_TYPE_Text : PARAMETER_TYPE_String, bInformation ? PARAMETER_INFORMATION : 0);
1099
1100 bool bCallback = Set_Callback(false);
1101 pParameter->Set_Value (String);
1102 pParameter->Set_Default(String);
1103 Set_Callback(bCallback);
1104
1105 ((CSG_Parameter_String *)pParameter)->Set_Password(bPassword);
1106
1107 return( pParameter );
1108}
1109
1110
1112// //
1114
1115//---------------------------------------------------------
1116#ifdef _DEBUG
1117#include <wx/debug.h>
1118#include <wx/string.h>
1119#endif
1120
1121//---------------------------------------------------------
1122CSG_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)
1123{
1124#ifdef _DEBUG
1125 wxASSERT_MSG(!ID.is_Empty() , wxString::Format("CSG_Parameter::_Add(): Parameter ID is empty!"));
1126 wxASSERT_MSG(!Get_Parameter(ID), wxString::Format("CSG_Parameter::_Add(): Parameter ID \"%s\" is already in use!", ID.c_str()));
1127#endif
1128
1129 CSG_Parameter *pParameter;
1130
1131 switch( Type )
1132 {
1133 default:
1134 return( NULL );
1135
1136 case PARAMETER_TYPE_Node : pParameter = new CSG_Parameter_Node (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1137
1138 case PARAMETER_TYPE_Bool : pParameter = new CSG_Parameter_Bool (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1139 case PARAMETER_TYPE_Int : pParameter = new CSG_Parameter_Int (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1140 case PARAMETER_TYPE_Double : pParameter = new CSG_Parameter_Double (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1141 case PARAMETER_TYPE_Degree : pParameter = new CSG_Parameter_Degree (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1142 case PARAMETER_TYPE_Date : pParameter = new CSG_Parameter_Date (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1143 case PARAMETER_TYPE_Range : pParameter = new CSG_Parameter_Range (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1144 case PARAMETER_TYPE_Data_Type : pParameter = new CSG_Parameter_Data_Type (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1145 case PARAMETER_TYPE_Choice : pParameter = new CSG_Parameter_Choice (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1146 case PARAMETER_TYPE_Choices : pParameter = new CSG_Parameter_Choices (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1147
1148 case PARAMETER_TYPE_String : pParameter = new CSG_Parameter_String (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1149 case PARAMETER_TYPE_Text : pParameter = new CSG_Parameter_Text (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1150 case PARAMETER_TYPE_FilePath : pParameter = new CSG_Parameter_File_Name (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1151
1152 case PARAMETER_TYPE_Font : pParameter = new CSG_Parameter_Font (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1153 case PARAMETER_TYPE_Color : pParameter = new CSG_Parameter_Color (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1154 case PARAMETER_TYPE_Colors : pParameter = new CSG_Parameter_Colors (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1155 case PARAMETER_TYPE_FixedTable : pParameter = new CSG_Parameter_Fixed_Table (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1156 case PARAMETER_TYPE_Grid_System : pParameter = new CSG_Parameter_Grid_System (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1157 case PARAMETER_TYPE_Table_Field : pParameter = new CSG_Parameter_Table_Field (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1158 case PARAMETER_TYPE_Table_Fields : pParameter = new CSG_Parameter_Table_Fields (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1159
1160 case PARAMETER_TYPE_DataObject_Output: pParameter = new CSG_Parameter_Data_Object_Output(this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1161 case PARAMETER_TYPE_Grid : pParameter = new CSG_Parameter_Grid (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1162 case PARAMETER_TYPE_Grids : pParameter = new CSG_Parameter_Grids (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1163 case PARAMETER_TYPE_Table : pParameter = new CSG_Parameter_Table (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1164 case PARAMETER_TYPE_Shapes : pParameter = new CSG_Parameter_Shapes (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1165 case PARAMETER_TYPE_TIN : pParameter = new CSG_Parameter_TIN (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1166 case PARAMETER_TYPE_PointCloud : pParameter = new CSG_Parameter_PointCloud (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1167
1168 case PARAMETER_TYPE_Grid_List : pParameter = new CSG_Parameter_Grid_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1169 case PARAMETER_TYPE_Grids_List : pParameter = new CSG_Parameter_Grids_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1170 case PARAMETER_TYPE_Table_List : pParameter = new CSG_Parameter_Table_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1171 case PARAMETER_TYPE_Shapes_List : pParameter = new CSG_Parameter_Shapes_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1172 case PARAMETER_TYPE_TIN_List : pParameter = new CSG_Parameter_TIN_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1173 case PARAMETER_TYPE_PointCloud_List : pParameter = new CSG_Parameter_PointCloud_List (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1174
1175 case PARAMETER_TYPE_Parameters : pParameter = new CSG_Parameter_Parameters (this, Get_Parameter(ParentID), ID, Name, Description, Constraint); break;
1176 }
1177
1178 m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, (m_nParameters + 1) * sizeof(CSG_Parameter *));
1179 m_Parameters[m_nParameters++] = pParameter;
1180
1181 pParameter->_Set_String();
1182
1183 return( pParameter );
1184}
1185
1186//---------------------------------------------------------
1187CSG_Parameter * CSG_Parameters::_Add(CSG_Parameter *pSource)
1188{
1189 CSG_Parameter *pParameter = !pSource ? NULL : _Add(
1190 pSource->Get_Parent() ? pSource->Get_Parent()->Get_Identifier() : SG_T(""),
1191 pSource->Get_Identifier (),
1192 pSource->Get_Name (),
1193 pSource->Get_Description(),
1194 pSource->Get_Type (),
1195 pSource->m_Constraint
1196 );
1197
1198 if( pParameter )
1199 {
1200 pParameter->Assign(pSource);
1201 }
1202
1203 return( pParameter );
1204}
1205
1206
1208// //
1210
1211//---------------------------------------------------------
1212CSG_Parameter * CSG_Parameters::Get_Parameter(int i, bool MsgOnError) const
1213{
1214 if( i >= 0 && i < m_nParameters )
1215 {
1216 return( m_Parameters[i] );
1217 }
1218
1219 if( MsgOnError )
1220 {
1221 SG_UI_Msg_Add_Error(CSG_String::Format("%s index=[%d]", _TL("Could not find requested parameter!"), i));
1222 }
1223
1224 return( NULL );
1225}
1226
1227//---------------------------------------------------------
1228CSG_Parameter * CSG_Parameters::Get_Parameter(const char *ID, bool MsgOnError) const { return( Get_Parameter(CSG_String(ID), MsgOnError) ); }
1229CSG_Parameter * CSG_Parameters::Get_Parameter(const wchar_t *ID, bool MsgOnError) const { return( Get_Parameter(CSG_String(ID), MsgOnError) ); }
1230CSG_Parameter * CSG_Parameters::Get_Parameter(const CSG_String &ID, bool MsgOnError) const
1231{
1232 if( m_Parameters && !ID.is_Empty() )
1233 {
1234 for(int i=0; i<m_nParameters; i++)
1235 {
1236 if( m_Parameters[i]->Cmp_Identifier(ID) )
1237 {
1238 return( m_Parameters[i] );
1239 }
1240 }
1241
1242 //-------------------------------------------------
1243 if( ID.Find('.') > 0 ) // id not found? check for sub-parameter ('id.id')!
1244 {
1245 CSG_Parameter *pParameter = Get_Parameter(ID.BeforeFirst('.'));
1246
1247 if( pParameter )
1248 {
1249 switch( pParameter->Get_Type() )
1250 {
1252 return( pParameter->asParameters()->Get_Parameter(ID.AfterFirst('.')) );
1253
1255 if( !ID.AfterFirst('.').CmpNoCase("min") || !ID.AfterFirst('.').CmpNoCase("minimum") )
1256 {
1257 return( pParameter->asRange()->Get_Min_Parameter() );
1258 }
1259
1260 if( !ID.AfterFirst('.').CmpNoCase("max") || !ID.AfterFirst('.').CmpNoCase("maximum") )
1261 {
1262 return( pParameter->asRange()->Get_Max_Parameter() );
1263 }
1264 break;
1265
1266 default:
1267 break;
1268 }
1269 }
1270 }
1271
1272 //-------------------------------------------------
1273 if( MsgOnError )
1274 {
1275 SG_UI_Msg_Add_Error(CSG_String::Format("%s id=[%s]", _TL("Could not find requested parameter!"), ID.c_str()));
1276 }
1277 }
1278
1279 return( NULL );
1280}
1281
1282//---------------------------------------------------------
1284{
1285 if( m_Parameters && iParameter >= 0 && iParameter < m_nParameters )
1286 {
1287 CSG_Parameter *pParameter = m_Parameters[iParameter];
1288
1289 for(m_nParameters--; iParameter<m_nParameters; iParameter++)
1290 {
1291 m_Parameters[iParameter] = m_Parameters[iParameter + 1];
1292 }
1293
1294 m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, m_nParameters * sizeof(CSG_Parameter *));
1295
1296 for(iParameter=pParameter->Get_Children_Count()-1; iParameter>=0; iParameter--)
1297 {
1298 Del_Parameter(pParameter->Get_Child(iParameter)->Get_Identifier());
1299 }
1300
1301 CSG_Parameter *pParent = pParameter->Get_Parent();
1302
1303 if( pParent )
1304 {
1305 for(iParameter=0; iParameter<pParent->m_nChildren; iParameter++)
1306 {
1307 if( pParent->m_Children[iParameter] == pParameter )
1308 {
1309 pParent->m_nChildren--;
1310
1311 for( ; iParameter<pParent->m_nChildren; iParameter++)
1312 {
1313 pParent->m_Children[iParameter] = pParent->m_Children[iParameter + 1];
1314 }
1315 }
1316 }
1317
1318 pParent->m_Children = (CSG_Parameter **)SG_Realloc(pParent->m_Children, pParent->m_nChildren * sizeof(CSG_Parameter *));
1319 }
1320
1321 delete(pParameter);
1322
1323 return( true );
1324 }
1325
1326 return( false );
1327}
1328
1329//---------------------------------------------------------
1331{
1332 if( m_Parameters && Identifier.Length() )
1333 {
1334 for(int i=0; i<m_nParameters; i++)
1335 {
1336 if( !m_Parameters[i]->m_Identifier.Cmp(Identifier) )
1337 {
1338 return( Del_Parameter(i) );
1339 }
1340 }
1341 }
1342
1343 return( false );
1344}
1345
1346//---------------------------------------------------------
1348{
1349 if( m_nParameters > 0 )
1350 {
1351 m_pGrid_System = NULL;
1352
1353 for(int i=0; i<m_nParameters; i++)
1354 {
1355 delete(m_Parameters[i]);
1356 }
1357
1358 SG_Free(m_Parameters);
1359
1360 m_Parameters = NULL;
1361 m_nParameters = 0;
1362 }
1363
1364 return( true );
1365}
1366
1367
1369// //
1370// Callback //
1371// //
1373
1374//---------------------------------------------------------
1375// Callback function used to react on parameter changes.
1376// Return value is the previously set callback function.
1378{
1379 TSG_PFNC_Parameter_Changed Previous = m_Callback;
1380
1381 m_Callback = Callback;
1382
1383 for(int i=0; i<m_nParameters; i++)
1384 {
1385 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters)
1386 {
1387 m_Parameters[i]->asParameters()->Set_Callback_On_Parameter_Changed(Callback);
1388 }
1389 }
1390
1391 return( Previous );
1392}
1393
1394//---------------------------------------------------------
1395// If switched off parameter changes will not invoke a
1396// consecutive call to the On_Parameter_Changed function.
1397// Return value is the previous state.
1399{
1400 bool bPrevious = m_bCallback;
1401
1402 m_bCallback = bActive;
1403
1404 for(int i=0; i<m_nParameters; i++)
1405 {
1406 if( m_Parameters[i]->Get_Type() == PARAMETER_TYPE_Parameters)
1407 {
1408 m_Parameters[i]->asParameters()->Set_Callback(bActive);
1409 }
1410 }
1411
1412 return( bPrevious );
1413}
1414
1415//---------------------------------------------------------
1416bool CSG_Parameters::_On_Parameter_Changed(CSG_Parameter *pParameter, int Flags)
1417{
1418 if( m_Callback && m_bCallback )
1419 {
1420 bool bCallback = Set_Callback(false);
1421
1422 m_Callback(pParameter, Flags);
1423
1424 Set_Callback(bCallback);
1425
1426 return( true );
1427 }
1428
1429 return( false );
1430}
1431
1432
1434// //
1436
1437//---------------------------------------------------------
1438bool CSG_Parameters::Set_Parameter(const char *ID, CSG_Parameter *pValue) { return( Set_Parameter(CSG_String(ID), pValue) ); }
1439bool CSG_Parameters::Set_Parameter(const wchar_t *ID, CSG_Parameter *pValue) { return( Set_Parameter(CSG_String(ID), pValue) ); }
1441{
1442 CSG_Parameter *pTarget = Get_Parameter(ID);
1443
1444 return( pTarget && pValue && pTarget->Get_Type() == pValue->Get_Type() && pTarget->Assign(pValue) );
1445}
1446
1447//---------------------------------------------------------
1448bool CSG_Parameters::Set_Parameter(const char *ID, void *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1449bool CSG_Parameters::Set_Parameter(const wchar_t *ID, void *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1450bool CSG_Parameters::Set_Parameter(const CSG_String &ID, void *Value, int Type)
1451{
1452 CSG_Parameter *pTarget = Get_Parameter(ID);
1453
1454 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1455}
1456
1457//---------------------------------------------------------
1458bool CSG_Parameters::Set_Parameter(const char *ID, CSG_Data_Object *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1459bool CSG_Parameters::Set_Parameter(const wchar_t *ID, CSG_Data_Object *Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1461{
1462 CSG_Parameter *pTarget = Get_Parameter(ID);
1463
1464 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1465}
1466
1467//---------------------------------------------------------
1468bool CSG_Parameters::Set_Parameter(const char *ID, int Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1469bool CSG_Parameters::Set_Parameter(const wchar_t *ID, int Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1470bool CSG_Parameters::Set_Parameter(const CSG_String &ID, int Value, int Type)
1471{
1472 CSG_Parameter *pTarget = Get_Parameter(ID);
1473
1474 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1475}
1476
1477//---------------------------------------------------------
1478bool CSG_Parameters::Set_Parameter(const char *ID, double Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1479bool CSG_Parameters::Set_Parameter(const wchar_t *ID, double Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1480bool CSG_Parameters::Set_Parameter(const CSG_String &ID, double Value, int Type)
1481{
1482 CSG_Parameter *pTarget = Get_Parameter(ID);
1483
1484 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1485}
1486
1487//---------------------------------------------------------
1488bool CSG_Parameters::Set_Parameter(const char *ID, const CSG_String &Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1489bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const CSG_String &Value, int Type) { return( Set_Parameter(CSG_String(ID), Value, Type) ); }
1490bool CSG_Parameters::Set_Parameter(const CSG_String &ID, const CSG_String &Value, int Type)
1491{
1492 CSG_Parameter *pTarget = Get_Parameter(ID);
1493
1494 return( pTarget && (Type == PARAMETER_TYPE_Undefined || Type == pTarget->Get_Type()) && pTarget->Set_Value(Value) );
1495}
1496
1497//---------------------------------------------------------
1498bool CSG_Parameters::Set_Parameter(const CSG_String &ID, const char *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1499bool CSG_Parameters::Set_Parameter(const char *ID, const char *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1500bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const char *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1501
1502//---------------------------------------------------------
1503bool CSG_Parameters::Set_Parameter(const CSG_String &ID, const wchar_t *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1504bool CSG_Parameters::Set_Parameter(const char *ID, const wchar_t *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1505bool CSG_Parameters::Set_Parameter(const wchar_t *ID, const wchar_t *Value, int Type) { return( Set_Parameter(ID, CSG_String(Value)) ); }
1506
1507
1509// //
1511
1512//---------------------------------------------------------
1514{
1515 Set_Callback(false);
1516
1517 for(int i=0; i<Get_Count(); i++)
1518 {
1519 m_Parameters[i]->Restore_Default();
1520
1521 if( bClearData )
1522 {
1523 if( m_Parameters[i]->is_DataObject() )
1524 {
1525 m_Parameters[i]->Set_Value(DATAOBJECT_NOTSET);
1526 }
1527 else if( m_Parameters[i]->is_DataObject_List() )
1528 {
1529 m_Parameters[i]->asList()->Del_Items();
1530 }
1531 }
1532 }
1533
1534 Set_Callback(true);
1535
1536 return( true );
1537}
1538
1539
1541// //
1543
1544//---------------------------------------------------------
1546{
1547 return( pSource && pSource != this && Create(*pSource) );
1548}
1549
1550//---------------------------------------------------------
1552{
1553 if( !pSource || pSource == this )
1554 {
1555 return( false );
1556 }
1557
1558 //-----------------------------------------------------
1559 int n = 0;
1560
1561 for(int i=0; i<pSource->Get_Count(); i++)
1562 {
1563 CSG_Parameter *pParameter = Get_Parameter(pSource->Get_Parameter(i)->Get_Identifier());
1564
1565 if( pParameter && pParameter->Get_Type() == pSource->Get_Parameter(i)->Get_Type() )
1566 {
1567 n++; pParameter->Assign(pSource->Get_Parameter(i));
1568 }
1569 }
1570
1571 return( n > 0 );
1572}
1573
1574//---------------------------------------------------------
1576{
1577 if( !pSource || pSource == this )
1578 {
1579 return( false );
1580 }
1581
1583
1584 //-----------------------------------------------------
1585 for(int i=0; i<pSource->m_nParameters; i++)
1586 {
1587 _Add(pSource->m_Parameters[i]);
1588
1589 if( m_Parameters[i]->asParameters() )
1590 {
1591 m_Parameters[i]->asParameters()->Set_Tool(m_pTool);
1592 }
1593 }
1594
1595 if( pSource->m_pGrid_System )
1596 {
1597 m_pGrid_System = Get_Parameter(pSource->m_pGrid_System->Get_Identifier());
1598 }
1599
1600 return( m_nParameters == pSource->m_nParameters );
1601}
1602
1603
1605// //
1607
1608//---------------------------------------------------------
1610{
1611 bool bResult = true; CSG_String sError;
1612
1613 //-----------------------------------------------------
1614 for(int i=0; i<Get_Count(); i++)
1615 {
1616 if( m_Parameters[i]->Check(bSilent) == false )
1617 {
1618 bResult = false;
1619
1620 sError.Append(CSG_String::Format("\n%s: %s", m_Parameters[i]->Get_Type_Name().c_str(), m_Parameters[i]->Get_Name()));
1621 }
1622 }
1623
1624 //-----------------------------------------------------
1625 if( !bResult && !bSilent )
1626 {
1627 SG_UI_Dlg_Message(CSG_String::Format("%s\n%s", _TL("invalid input!"), sError.c_str()), Get_Name() );
1628 }
1629
1630 return( bResult );
1631}
1632
1633//---------------------------------------------------------
1634bool CSG_Parameters::DataObjects_Create(void)
1635{
1636 bool bResult = true;
1637
1638 for(int i=0; bResult && i<Get_Count(); i++)
1639 {
1640 CSG_Parameter &P = *m_Parameters[i];
1641
1642 //-------------------------------------------------
1644 {
1645 if( !P.asParameters()->DataObjects_Create() )
1646 {
1647 bResult = false;
1648 }
1649 }
1650 else if( P.is_Input() )
1651 {
1652 if( P.is_Enabled() && P.Check(true) == false )
1653 {
1654 bResult = false;
1655
1656 SG_UI_Dlg_Message(CSG_String::Format("%s\n[%s]\n%s", _TL("Input Error"), P.Get_Identifier(), P.Get_Name()), Get_Name());
1657 }
1658 }
1659
1660 //-------------------------------------------------
1661 else if( P.is_DataObject_List() )
1662 {
1663 for(int j=P.asList()->Get_Item_Count()-1; j>=0; j--)
1664 {
1665 if( m_pManager && !m_pManager->Exists(P.asList()->Get_Item(j)) )
1666 {
1667 P.asList()->Del_Item(j);
1668 }
1669 }
1670 }
1671
1672 //-------------------------------------------------
1673 else if( P.is_DataObject() && P.is_Enabled() == false && has_GUI() )
1674 {
1675 if( P.asDataObject() != DATAOBJECT_CREATE && (m_pManager && !m_pManager->Exists(P.asDataObject())) )
1676 {
1678 }
1679 }
1680
1681 else if( P.is_DataObject() )
1682 {
1683 CSG_Data_Object *pObject = P.asDataObject();
1684
1685 if( pObject != DATAOBJECT_CREATE )
1686 {
1688 {
1689 pObject = (CSG_Data_Object *)DATAOBJECT_CREATE;
1690 }
1691 else if( m_pManager && !m_pManager->Exists(pObject) )
1692 {
1693 pObject = (CSG_Data_Object *)DATAOBJECT_NOTSET;
1694 }
1695
1696 if( pObject == DATAOBJECT_NOTSET && !P.is_Optional() )
1697 {
1698 pObject = (CSG_Data_Object *)DATAOBJECT_CREATE;
1699 }
1700 }
1701
1702 if( pObject == DATAOBJECT_CREATE )
1703 {
1704 switch( P.Get_DataObject_Type() )
1705 {
1706 case SG_DATAOBJECT_TYPE_Table : pObject = SG_Create_Table (); break;
1707 case SG_DATAOBJECT_TYPE_Shapes : pObject = SG_Create_Shapes (); break;
1708 case SG_DATAOBJECT_TYPE_PointCloud: pObject = SG_Create_PointCloud(); break;
1709 case SG_DATAOBJECT_TYPE_TIN : pObject = SG_Create_TIN (); break;
1710 case SG_DATAOBJECT_TYPE_Grid : pObject = SG_Create_Grid (); break;
1711 case SG_DATAOBJECT_TYPE_Grids : pObject = SG_Create_Grids (); break;
1712 default : pObject = NULL ; break;
1713 }
1714 }
1715
1716 if( pObject )
1717 {
1719 && ((CSG_Parameter_Shapes *)&P)->Get_Shape_Type() != SHAPE_TYPE_Undefined
1720 && ((CSG_Parameter_Shapes *)&P)->Get_Shape_Type() != pObject->asShapes()->Get_Type() )
1721 {
1722 if( has_GUI() && pObject->asShapes()->Get_Type() != SHAPE_TYPE_Undefined )
1723 {
1724 pObject = SG_Create_Shapes (((CSG_Parameter_Shapes *)&P)->Get_Shape_Type());
1725 }
1726 else
1727 {
1728 pObject->asShapes()->Create(((CSG_Parameter_Shapes *)&P)->Get_Shape_Type());
1729 }
1730 }
1731
1733 {
1734 if( P.Get_Parent() && P.Get_Parent()->asGrid_System() && P.Get_Parent()->asGrid_System()->is_Valid() )
1735 {
1736 CSG_Grid_System System(*P.Get_Parent()->asGrid_System());
1737
1738 if( P.Get_Type() == PARAMETER_TYPE_Grid && !System.is_Equal(pObject->asGrid ()->Get_System()) )
1739 {
1740 pObject->asGrid ()->Create(System , ((CSG_Parameter_Grid *)&P)->Get_Preferred_Type());
1741 }
1742
1743 if( P.Get_Type() == PARAMETER_TYPE_Grids && !System.is_Equal(pObject->asGrids()->Get_System()) )
1744 {
1745 pObject->asGrids()->Create(System, 0, 0., ((CSG_Parameter_Grids *)&P)->Get_Preferred_Type());
1746 }
1747 }
1748 }
1749
1750 if( P.Set_Value(pObject) )
1751 {
1752 pObject->Set_Name(P.Get_Name());
1753 pObject->Get_MetaData().Del_Children();
1754
1755 if( m_pManager )
1756 {
1757 m_pManager->Add(pObject);
1758 }
1759 }
1760 else
1761 {
1762 delete(pObject);
1763
1764 bResult = false;
1765
1766 SG_UI_Dlg_Message(CSG_String::Format("%s\n[%s]\n%s", _TL("Output Error"), P.Get_Identifier(), P.Get_Name()), Get_Name());
1767 }
1768 }
1769 else // if( pObject == NULL )
1770 {
1771 if( !P.is_Optional() )
1772 {
1773 bResult = false;
1774
1775 SG_UI_Dlg_Message(CSG_String::Format("%s\n[%s]\n%s", _TL("Output Error"), P.Get_Identifier(), P.Get_Name()), Get_Name());
1776 }
1777 }
1778 }
1779 }
1780
1781 return( bResult );
1782}
1783
1784//---------------------------------------------------------
1785bool CSG_Parameters::DataObjects_Synchronize(void)
1786{
1787 for(int i=0; i<Get_Count(); i++)
1788 {
1789 CSG_Parameter &P = *m_Parameters[i];
1790
1792 {
1793 P.asParameters()->DataObjects_Synchronize();
1794 }
1795
1796 //-------------------------------------------------
1797 else if( P.is_Output() )
1798 {
1799 if( P.is_DataObject() )
1800 {
1801 CSG_Data_Object *pObject = P.asDataObject();
1802
1803 if( pObject == DATAOBJECT_CREATE )
1804 {
1806 }
1807 else if( pObject != DATAOBJECT_NOTSET )
1808 {
1809 if( pObject->asShapes() && pObject->asShapes()->Get_Type() == SHAPE_TYPE_Undefined
1810 && (m_pManager == &SG_Get_Data_Manager() || !SG_Get_Data_Manager().Exists(pObject)) )
1811 {
1812 if( m_pManager && !m_pManager->Delete(pObject) )
1813 {
1814 delete(pObject);
1815 }
1816
1818 }
1819 else
1820 {
1821 if( m_pManager )
1822 {
1823 m_pManager->Add(pObject);
1824
1825 if( m_pManager == &SG_Get_Data_Manager() )
1826 {
1827 SG_UI_DataObject_Add(pObject, 0);
1828 }
1829 }
1830
1832 }
1833 }
1834 }
1835
1836 //---------------------------------------------
1837 else if( P.is_DataObject_List() )
1838 {
1839 for(int j=0; j<P.asList()->Get_Item_Count(); j++)
1840 {
1841 CSG_Data_Object *pObject = P.asList()->Get_Item(j);
1842
1843 if( m_pManager )
1844 {
1845 m_pManager->Add(pObject);
1846
1847 if( m_pManager == &SG_Get_Data_Manager() )
1848 {
1849 SG_UI_DataObject_Add(pObject, 0);
1850 }
1851 }
1852
1854 }
1855 }
1856 }
1857 }
1858
1859 return( true );
1860}
1861
1862//---------------------------------------------------------
1863bool CSG_Parameters::DataObjects_Get_Projection(CSG_Projection &Projection) const
1864{
1865 for(int i=0; i<Get_Count() && !Projection.is_Okay(); i++)
1866 {
1867 CSG_Parameter *p = m_Parameters[i];
1868
1869 if( p->is_Enabled() && !p->ignore_Projection() )
1870 {
1872 {
1873 p->asParameters()->DataObjects_Get_Projection(Projection);
1874 }
1875 else if( p->is_Input() )
1876 {
1877 if( p->is_DataObject()
1879 && p->asDataObject() != DATAOBJECT_CREATE )
1880 {
1882 }
1883 else if( p->is_DataObject_List() )
1884 {
1885 for(int j=0; j<p->asList()->Get_Item_Count() && !Projection.is_Okay(); j++)
1886 {
1888 }
1889 }
1890 }
1891 }
1892 }
1893
1894 return( Projection.is_Okay() );
1895}
1896
1897//---------------------------------------------------------
1898bool CSG_Parameters::DataObjects_Set_Projection(const CSG_Projection &Projection)
1899{
1900 if( !Projection.is_Okay() )
1901 {
1902 return( false );
1903 }
1904
1905 for(int i=0; i<Get_Count(); i++)
1906 {
1907 CSG_Parameter *p = m_Parameters[i];
1908
1909 if( !p->ignore_Projection() )
1910 {
1912 {
1913 p->asParameters()->DataObjects_Set_Projection(Projection);
1914 }
1915 else if( p->is_Output() )
1916 {
1917 if( p->is_DataObject()
1919 && p->asDataObject() != DATAOBJECT_CREATE )
1920 {
1922 }
1923 else if( p->is_DataObject_List() )
1924 {
1925 for(int j=0; j<p->asList()->Get_Item_Count(); j++)
1926 {
1928 }
1929 }
1930 }
1931 }
1932 }
1933
1934 return( true );
1935}
1936
1937
1939// //
1941
1942//---------------------------------------------------------
1943bool CSG_Parameters::Get_String(CSG_String &String, bool bOptionsOnly)
1944{
1945 bool bResult = false;
1946
1947 if( Get_Count() > 0 )
1948 {
1949 if( m_pGrid_System )
1950 {
1951 m_pGrid_System->_Set_String();
1952
1953 String += CSG_String::Format("%s: %s\n", m_pGrid_System->Get_Name(), m_pGrid_System->asString());
1954 }
1955
1956 for(int i=0; i<Get_Count(); i++)
1957 {
1958 CSG_Parameter &P = *m_Parameters[i];
1959
1960 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()) )
1961 {
1962 bResult = true;
1963
1964 P._Set_String(); // forcing update (at scripting level some parameter types can be changed without the Set_Parameter() mechanism)
1965
1966 CSG_String s(P.asString()); if( s.Length() > 256 ) { s = s.Left(256) + "..."; }
1967
1968 String += CSG_String::Format("%s: %s\n", P.Get_Name(), s.c_str());
1969 }
1970 }
1971 }
1972
1973 return( bResult );
1974}
1975
1976//---------------------------------------------------------
1977bool CSG_Parameters::Msg_String(bool bOptionsOnly)
1978{
1979 CSG_String Message;
1980
1981 if( Get_String(Message, bOptionsOnly) )
1982 {
1983 SG_UI_Msg_Add_Execution(CSG_String::Format("\n__________\n[%s] %s:\n", m_Name.c_str(),
1984 bOptionsOnly ? _TL("Options") : _TL("Parameters")),
1986 );
1987
1989
1990 return( true );
1991 }
1992
1993 return( false );
1994}
1995
1996
1998// //
2000
2001//---------------------------------------------------------
2002bool CSG_Parameters::Set_History(CSG_MetaData &MetaData, bool bOptions, bool bDataObjects)
2003{
2004 if( bOptions ) // get options...
2005 {
2006 for(int i=0; i<Get_Count(); i++)
2007 {
2008 CSG_Parameter &P = *m_Parameters[i];
2009
2010 if( P.is_Option() && P.is_Enabled() && !P.is_Information() && !(P.Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)&P)->is_Password()) )
2011 {
2012 P.Serialize(MetaData, true);
2013 }
2014 else if( P.is_Parameters() )
2015 {
2016 P.asParameters()->Set_History(MetaData, true, false);
2017 }
2018 }
2019 }
2020
2021 //-----------------------------------------------------
2022 if( bDataObjects ) // get input with history...
2023 {
2024 for(int i=0; i<Get_Count(); i++)
2025 {
2026 CSG_Parameter &P = *m_Parameters[i];
2027
2028 //---------------------------------------------
2029 if( P.is_Input() )
2030 {
2031 if( P.is_DataObject() && P.asDataObject() )
2032 {
2033 CSG_Data_Object *pObject = P.asDataObject();
2034
2035 CSG_MetaData *pEntry = MetaData.Add_Child("INPUT");
2036
2037 pEntry->Add_Property("type" , P.Get_Type_Identifier());
2038 pEntry->Add_Property("id" , P.Get_Identifier ());
2039 pEntry->Add_Property("name" , P.Get_Name ());
2040 pEntry->Add_Property("parms", Get_Identifier ());
2041
2042 if( P.Get_Type() == PARAMETER_TYPE_Grid
2043 || P.Get_Type() == PARAMETER_TYPE_Grids )
2044 {
2045 pEntry->Add_Property("system", P.Get_Parent()->Get_Identifier());
2046 }
2047
2048 if( pObject->Get_History().Get_Children_Count() > 0 )
2049 {
2050 pEntry->Add_Children(pObject->Get_History());
2051 }
2052 else if( pObject->Get_File_Name() && *pObject->Get_File_Name() )
2053 {
2054 pEntry = pEntry->Add_Child("FILE", pObject->Get_File_Name());
2055 }
2056 }
2057
2058 else if( P.is_DataObject_List() && P.asList()->Get_Item_Count() > 0 )
2059 {
2060 CSG_MetaData *pList = MetaData.Add_Child("INPUT_LIST");
2061
2062 pList->Add_Property("type" , P.Get_Type_Identifier());
2063 pList->Add_Property("id" , P.Get_Identifier ());
2064 pList->Add_Property("name" , P.Get_Name ());
2065 pList->Add_Property("parms", Get_Identifier ());
2066
2068 {
2069 pList->Add_Property("system", P.Get_Parent()->Get_Identifier());
2070 }
2071
2072 for(int j=0; j<P.asList()->Get_Item_Count(); j++)
2073 {
2074 CSG_Data_Object *pObject = P.asList()->Get_Item(j);
2075
2076 CSG_MetaData *pEntry = pList->Add_Child(*pList, false);
2077
2078 pEntry->Set_Name("INPUT");
2079
2081 {
2082 pEntry->Add_Children(pObject->Get_History());
2083 }
2084 else if( pObject->Get_File_Name() && *pObject->Get_File_Name() )
2085 {
2086 pEntry = pEntry->Add_Child("FILE", pObject->Get_File_Name());
2087 }
2088 }
2089 }
2090 }
2091
2092 //---------------------------------------------
2093 else if( P.is_Parameters() )
2094 {
2095 P.asParameters()->Set_History(MetaData, false, true);
2096 }
2097 }
2098 }
2099
2100 return( true );
2101}
2102
2103
2105// //
2106// Grid System //
2107// //
2109
2110//---------------------------------------------------------
2117{
2118 return( m_pGrid_System && m_pGrid_System->asGrid_System() && m_pGrid_System->Set_Value((void *)&System) );
2119}
2120
2121//---------------------------------------------------------
2128{
2129 CSG_Grid_System System;
2130
2131 return( Set_Grid_System(System) );
2132}
2133
2134
2136// //
2137// Serialize //
2138// //
2140
2141//---------------------------------------------------------
2143{
2144 if( Data.Cmp_Name("parameters") )
2145 {
2146 Data.Get_Property("name", m_Name);
2147
2148 for(int i=0; i<Data.Get_Children_Count(); i++)
2149 {
2150 CSG_Parameter *pParameter = Get_Parameter(Data(i)->Get_Property("id"));
2151
2152 if( pParameter && pParameter->Serialize(*Data(i), false) )
2153 {
2154 pParameter->has_Changed();
2155 }
2156 }
2157
2158 return( true );
2159 }
2160
2161 return( false );
2162}
2163
2164//---------------------------------------------------------
2166{
2167 Data.Destroy();
2168
2169 Data.Set_Name("parameters");
2170 Data.Set_Property("name", m_Name);
2171
2172 for(int i=0; i<Get_Count(); i++)
2173 {
2174 m_Parameters[i]->Serialize(Data, true);
2175 }
2176
2177 return( true );
2178}
2179
2180//---------------------------------------------------------
2182{
2183 CSG_MetaData Data; return( Data.Load(File) && Load(Data) );
2184}
2185
2186//---------------------------------------------------------
2187bool CSG_Parameters::Save(const CSG_String &File) const
2188{
2189 CSG_MetaData Data; return( Save(Data) && Data.Save(File) );
2190}
2191
2192//---------------------------------------------------------
2193// SAGA 2.0 compatibility...
2195{
2196 CSG_Parameter *pParameter = NULL;
2197 CSG_String sLine;
2198
2199 if( !Stream.is_Open() )
2200 {
2201 return( false );
2202 }
2203
2204 //-----------------------------------------------------
2205 while( Stream.Read_Line(sLine) && sLine.Cmp("[PARAMETER_ENTRIES_BEGIN]") );
2206
2207 if( sLine.Cmp("[PARAMETER_ENTRIES_BEGIN]") )
2208 {
2209 return( false );
2210 }
2211
2212 //-----------------------------------------------------
2213 while( Stream.Read_Line(sLine) && sLine.Cmp("[PARAMETER_ENTRIES_END]") )
2214 {
2215 if( !sLine.Cmp("[PARAMETER_ENTRY_BEGIN]")
2216 && Stream.Read_Line(sLine) && (pParameter = Get_Parameter(sLine)) != NULL
2217 && Stream.Read_Line(sLine) )
2218 {
2219 int i;
2220 double d;
2221 TSG_Rect r;
2222 CSG_String s;
2223 CSG_Table t;
2224
2225 switch( sLine.asInt() )
2226 {
2227 case 1: // PARAMETER_TYPE_Bool:
2228 case 2: // PARAMETER_TYPE_Int:
2229 case 6: // PARAMETER_TYPE_Choice:
2230 case 11: // PARAMETER_TYPE_Color:
2231 case 15: // PARAMETER_TYPE_Table_Field:
2232 pParameter->Set_Value(Stream.Scan_Int());
2233 break;
2234
2235 case 3: // PARAMETER_TYPE_Double:
2236 case 4: // PARAMETER_TYPE_Degree:
2237 pParameter->Set_Value(Stream.Scan_Double());
2238 break;
2239
2240 case 5: // PARAMETER_TYPE_Range:
2241 pParameter->asRange()->Set_Range(Stream.Scan_Double(), Stream.Scan_Double());
2242 break;
2243
2244 case 7: // PARAMETER_TYPE_String:
2245 case 9: // PARAMETER_TYPE_FilePath:
2246 Stream.Read_Line(sLine);
2247 pParameter->Set_Value(sLine);
2248 break;
2249
2250 case 8: // PARAMETER_TYPE_Text:
2251 s.Clear();
2252 while( Stream.Read_Line(sLine) && sLine.Cmp("[TEXT_ENTRY_END]") )
2253 {
2254 s += sLine + "\n";
2255 }
2256 pParameter->Set_Value(s);
2257 break;
2258
2259 case 10: // PARAMETER_TYPE_Font:
2260 Stream.Read(&i, sizeof(i));
2261 pParameter->Set_Value(i);
2262 break;
2263
2264 case 12: // PARAMETER_TYPE_Colors:
2265 pParameter->asColors()->Serialize(Stream, false, false);
2266 break;
2267
2268 case 13: // PARAMETER_TYPE_FixedTable:
2269 if( t.Serialize(Stream, false) )
2270 {
2271 pParameter->asTable()->Assign_Values(&t);
2272 }
2273 break;
2274
2275 case 14: // PARAMETER_TYPE_Grid_System:
2276 Stream.Read(&d, sizeof(d));
2277 Stream.Read(&r, sizeof(r));
2278 pParameter->asGrid_System()->Assign(d, r);
2279 break;
2280
2281 case 16: // PARAMETER_TYPE_Grid:
2282 case 17: // PARAMETER_TYPE_Table:
2283 case 18: // PARAMETER_TYPE_Shapes:
2284 case 19: // PARAMETER_TYPE_TIN:
2285 case 24: // PARAMETER_TYPE_DataObject_Output:
2286 if( Stream.Read_Line(sLine) )
2287 {
2288 if( !sLine.Cmp("[ENTRY_DATAOBJECT_CREATE]") )
2289 {
2290 pParameter->Set_Value(DATAOBJECT_CREATE);
2291 }
2292 else
2293 {
2294 pParameter->Set_Value(m_pManager ? m_pManager->Find(sLine) : NULL);
2295 }
2296 }
2297 break;
2298
2299 case 20: // PARAMETER_TYPE_Grid_List:
2300 case 21: // PARAMETER_TYPE_Table_List:
2301 case 22: // PARAMETER_TYPE_Shapes_List:
2302 case 23: // PARAMETER_TYPE_TIN_List:
2303 while( Stream.Read_Line(sLine) && sLine.Cmp("[ENTRY_DATAOBJECTLIST_END]") )
2304 {
2305 CSG_Data_Object *pObject = m_pManager ? m_pManager->Find(sLine) : NULL;
2306
2307 if( pObject )
2308 {
2309 pParameter->asList()->Add_Item(pObject);
2310 }
2311 }
2312 break;
2313
2314 case 25: // PARAMETER_TYPE_Parameters:
2315 pParameter->asParameters()->Serialize_Compatibility(Stream);
2316 break;
2317 }
2318 }
2319 }
2320
2321 return( true );
2322}
2323
2324
2326// //
2327// //
2328// //
2330
2331//---------------------------------------------------------
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:1581
@ SG_UI_MSG_STYLE_01
Definition api_core.h:1588
#define SG_T(s)
Definition api_core.h:537
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
@ SG_UI_DATAOBJECT_UPDATE
Definition api_core.h:1597
TSG_Data_Type
Definition api_core.h:997
#define SG_Char
Definition api_core.h:536
#define _TL(s)
Definition api_core.h:1568
bool Serialize(CSG_File &Stream, bool bSave, bool bBinary)
bool Create(void)
void Set_Name(const CSG_String &Name)
CSG_MetaData & Get_MetaData(void) const
Definition dataobject.h:234
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:236
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:411
static CSG_DateTime Now(void)
Definition datetime.cpp:585
bool is_Open(void) const
Definition api_core.h:1149
bool Read_Line(CSG_String &Line) const
Definition api_file.cpp:399
int Scan_Int(void) const
Definition api_file.cpp:557
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:562
bool Assign(const CSG_Grid_System &System)
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:461
bool Save(const CSG_String &File, const SG_Char *Extension=NULL) const
Definition metadata.cpp:879
bool Del_Children(int Depth=0, const SG_Char *Name=NULL)
Definition metadata.cpp:381
int Get_Children_Count(void) const
Definition metadata.h:148
bool Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists=true)
Definition metadata.cpp:615
bool Add_Children(const CSG_MetaData &MetaData)
Definition metadata.cpp:359
const SG_Char * Get_Property(int Index) const
Definition metadata.h:181
void Set_Name(const CSG_String &Name)
Definition metadata.h:130
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:166
bool Load(const CSG_String &File, const SG_Char *Extension=NULL)
Definition metadata.cpp:786
void Destroy(void)
Definition metadata.cpp:140
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition metadata.cpp:559
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:628
CSG_Parameter_Double * Get_Max_Parameter(void) const
Definition parameters.h:632
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
void Set_Minimum(double Minimum, bool bOn=true)
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
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
bool Assign_Values(CSG_Parameters *pSource)
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)
void Del_References(void)
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 Assign(CSG_Parameters *pSource)
bool DataObjects_Check(bool bSilent=false)
bool Del_Parameter(int i)
CSG_Parameter * Add_Node(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bCollapsed=false)
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 Assign_Parameters(CSG_Parameters *pSource)
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
void Add_Reference(const CSG_String &Authors, const CSG_String &Year, const CSG_String &Title, const CSG_String &Where, const SG_Char *Link=NULL, const SG_Char *Link_Text=NULL)
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)
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:806
size_t Length(void) const
CSG_String AfterFirst(char Character) const
int CmpNoCase(const CSG_String &String) const
int Cmp(const CSG_String &String) const
void Clear(void)
CSG_String BeforeFirst(char Character) const
static CSG_String Format(const char *Format,...)
CSG_String & Append(const CSG_String &String)
int Find(char Character, bool fromEnd=false) const
int asInt(void) const
const SG_Char * c_str(void) const
bool is_Empty(void) const
CSG_String Left(size_t count) const
bool Create(void)
Definition table.cpp:153
bool Assign_Values(const CSG_Table &Table)
Definition table.cpp:378
bool Serialize(CSG_File &Stream, bool bSave)
Definition table_io.cpp:690
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