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