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 // parameter_data.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
56
57 ///////////////////////////////////////////////////////////
58 // //
59 // //
60 // //
61 ///////////////////////////////////////////////////////////
62
63 //---------------------------------------------------------
SG_Parameter_Type_Get_Name(TSG_Parameter_Type Type)64 CSG_String SG_Parameter_Type_Get_Name(TSG_Parameter_Type Type)
65 {
66 switch( Type )
67 {
68 default : return( _TL("Parameter" ) );
69
70 case PARAMETER_TYPE_Node : return( _TL("Node" ) );
71
72 case PARAMETER_TYPE_Bool : return( _TL("Boolean" ) );
73 case PARAMETER_TYPE_Int : return( _TL("Integer" ) );
74 case PARAMETER_TYPE_Double : return( _TL("Floating point" ) );
75 case PARAMETER_TYPE_Degree : return( _TL("Degree" ) );
76 case PARAMETER_TYPE_Date : return( _TL("Date" ) );
77 case PARAMETER_TYPE_Range : return( _TL("Value range" ) );
78 case PARAMETER_TYPE_Choice : return( _TL("Choice" ) );
79 case PARAMETER_TYPE_Choices : return( _TL("Choices" ) );
80
81 case PARAMETER_TYPE_String : return( _TL("Text" ) );
82 case PARAMETER_TYPE_Text : return( _TL("Long text" ) );
83 case PARAMETER_TYPE_FilePath : return( _TL("File path" ) );
84
85 case PARAMETER_TYPE_Font : return( _TL("Font" ) );
86 case PARAMETER_TYPE_Color : return( _TL("Color" ) );
87 case PARAMETER_TYPE_Colors : return( _TL("Colors" ) );
88 case PARAMETER_TYPE_FixedTable : return( _TL("Static table" ) );
89 case PARAMETER_TYPE_Grid_System : return( _TL("Grid system" ) );
90 case PARAMETER_TYPE_Table_Field : return( _TL("Table field" ) );
91 case PARAMETER_TYPE_Table_Fields : return( _TL("Table fields" ) );
92
93 case PARAMETER_TYPE_DataObject_Output: return( _TL("Data Object" ) );
94 case PARAMETER_TYPE_Grid : return( _TL("Grid" ) );
95 case PARAMETER_TYPE_Grids : return( _TL("Grids" ) );
96 case PARAMETER_TYPE_Table : return( _TL("Table" ) );
97 case PARAMETER_TYPE_Shapes : return( _TL("Shapes" ) );
98 case PARAMETER_TYPE_TIN : return( _TL("TIN" ) );
99 case PARAMETER_TYPE_PointCloud : return( _TL("Point Cloud" ) );
100
101 case PARAMETER_TYPE_Grid_List : return( _TL("Grid list" ) );
102 case PARAMETER_TYPE_Grids_List : return( _TL("Grids list" ) );
103 case PARAMETER_TYPE_Table_List : return( _TL("Table list" ) );
104 case PARAMETER_TYPE_Shapes_List : return( _TL("Shapes list" ) );
105 case PARAMETER_TYPE_TIN_List : return( _TL("TIN list" ) );
106 case PARAMETER_TYPE_PointCloud_List : return( _TL("Point Cloud list") );
107
108 case PARAMETER_TYPE_Parameters : return( _TL("Parameters" ) );
109 }
110 }
111
112 //---------------------------------------------------------
SG_Parameter_Type_Get_Identifier(TSG_Parameter_Type Type)113 CSG_String SG_Parameter_Type_Get_Identifier(TSG_Parameter_Type Type)
114 {
115 switch( Type )
116 {
117 default : return( "parameter" );
118
119 case PARAMETER_TYPE_Node : return( "node" );
120
121 case PARAMETER_TYPE_Bool : return( "boolean" );
122 case PARAMETER_TYPE_Int : return( "integer" );
123 case PARAMETER_TYPE_Double : return( "double" );
124 case PARAMETER_TYPE_Degree : return( "degree" );
125 case PARAMETER_TYPE_Date : return( "date" );
126 case PARAMETER_TYPE_Range : return( "range" );
127 case PARAMETER_TYPE_Choice : return( "choice" );
128 case PARAMETER_TYPE_Choices : return( "choices" );
129
130 case PARAMETER_TYPE_String : return( "text" );
131 case PARAMETER_TYPE_Text : return( "long_text" );
132 case PARAMETER_TYPE_FilePath : return( "file" );
133
134 case PARAMETER_TYPE_Font : return( "font" );
135 case PARAMETER_TYPE_Color : return( "color" );
136 case PARAMETER_TYPE_Colors : return( "colors" );
137 case PARAMETER_TYPE_FixedTable : return( "static_table" );
138 case PARAMETER_TYPE_Grid_System : return( "grid_system" );
139 case PARAMETER_TYPE_Table_Field : return( "table_field" );
140 case PARAMETER_TYPE_Table_Fields : return( "table_fields" );
141
142 case PARAMETER_TYPE_DataObject_Output: return( "data_object" );
143 case PARAMETER_TYPE_Grid : return( "grid" );
144 case PARAMETER_TYPE_Grids : return( "grids" );
145 case PARAMETER_TYPE_Table : return( "table" );
146 case PARAMETER_TYPE_Shapes : return( "shapes" );
147 case PARAMETER_TYPE_TIN : return( "tin" );
148 case PARAMETER_TYPE_PointCloud : return( "points" );
149
150 case PARAMETER_TYPE_Grid_List : return( "grid_list" );
151 case PARAMETER_TYPE_Grids_List : return( "grids_list" );
152 case PARAMETER_TYPE_Table_List : return( "table_list" );
153 case PARAMETER_TYPE_Shapes_List : return( "shapes_list" );
154 case PARAMETER_TYPE_TIN_List : return( "tin_list" );
155 case PARAMETER_TYPE_PointCloud_List : return( "points_list" );
156
157 case PARAMETER_TYPE_Parameters : return( "parameters" );
158 }
159 }
160
161 //---------------------------------------------------------
SG_Parameter_Type_Get_Type(const CSG_String & Identifier)162 TSG_Parameter_Type SG_Parameter_Type_Get_Type(const CSG_String &Identifier)
163 {
164 if( !Identifier.Cmp("node" ) ) { return( PARAMETER_TYPE_Node ); }
165 if( !Identifier.Cmp("boolean" ) ) { return( PARAMETER_TYPE_Bool ); }
166 if( !Identifier.Cmp("integer" ) ) { return( PARAMETER_TYPE_Int ); }
167 if( !Identifier.Cmp("double" ) ) { return( PARAMETER_TYPE_Double ); }
168 if( !Identifier.Cmp("degree" ) ) { return( PARAMETER_TYPE_Degree ); }
169 if( !Identifier.Cmp("date" ) ) { return( PARAMETER_TYPE_Date ); }
170 if( !Identifier.Cmp("range" ) ) { return( PARAMETER_TYPE_Range ); }
171 if( !Identifier.Cmp("choice" ) ) { return( PARAMETER_TYPE_Choice ); }
172 if( !Identifier.Cmp("choices" ) ) { return( PARAMETER_TYPE_Choices ); }
173
174 if( !Identifier.Cmp("text" ) ) { return( PARAMETER_TYPE_String ); }
175 if( !Identifier.Cmp("long_text" ) ) { return( PARAMETER_TYPE_Text ); }
176 if( !Identifier.Cmp("file" ) ) { return( PARAMETER_TYPE_FilePath ); }
177
178 if( !Identifier.Cmp("font" ) ) { return( PARAMETER_TYPE_Font ); }
179 if( !Identifier.Cmp("color" ) ) { return( PARAMETER_TYPE_Color ); }
180 if( !Identifier.Cmp("colors" ) ) { return( PARAMETER_TYPE_Colors ); }
181 if( !Identifier.Cmp("static_table") ) { return( PARAMETER_TYPE_FixedTable ); }
182 if( !Identifier.Cmp("grid_system" ) ) { return( PARAMETER_TYPE_Grid_System ); }
183 if( !Identifier.Cmp("table_field" ) ) { return( PARAMETER_TYPE_Table_Field ); }
184 if( !Identifier.Cmp("table_fields") ) { return( PARAMETER_TYPE_Table_Fields ); }
185
186 if( !Identifier.Cmp("data_object" ) ) { return( PARAMETER_TYPE_DataObject_Output); }
187 if( !Identifier.Cmp("grid" ) ) { return( PARAMETER_TYPE_Grid ); }
188 if( !Identifier.Cmp("grids" ) ) { return( PARAMETER_TYPE_Grids ); }
189 if( !Identifier.Cmp("table" ) ) { return( PARAMETER_TYPE_Table ); }
190 if( !Identifier.Cmp("shapes" ) ) { return( PARAMETER_TYPE_Shapes ); }
191 if( !Identifier.Cmp("tin" ) ) { return( PARAMETER_TYPE_TIN ); }
192 if( !Identifier.Cmp("points" ) ) { return( PARAMETER_TYPE_PointCloud ); }
193
194 if( !Identifier.Cmp("grid_list" ) ) { return( PARAMETER_TYPE_Grid_List ); }
195 if( !Identifier.Cmp("grids_list" ) ) { return( PARAMETER_TYPE_Grids_List ); }
196 if( !Identifier.Cmp("table_list" ) ) { return( PARAMETER_TYPE_Table_List ); }
197 if( !Identifier.Cmp("shapes_list" ) ) { return( PARAMETER_TYPE_Shapes_List ); }
198 if( !Identifier.Cmp("tin_list" ) ) { return( PARAMETER_TYPE_TIN_List ); }
199 if( !Identifier.Cmp("points_list" ) ) { return( PARAMETER_TYPE_PointCloud_List ); }
200
201 if( !Identifier.Cmp("parameters" ) ) { return( PARAMETER_TYPE_Parameters ); }
202
203 return( PARAMETER_TYPE_Undefined );
204 }
205
206
207 ///////////////////////////////////////////////////////////
208 // //
209 // Node //
210 // //
211 ///////////////////////////////////////////////////////////
212
213 //---------------------------------------------------------
CSG_Parameter_Node(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)214 CSG_Parameter_Node::CSG_Parameter_Node(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
215 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
216 {
217 // nop
218 }
219
220
221 ///////////////////////////////////////////////////////////
222 // //
223 // Bool //
224 // //
225 ///////////////////////////////////////////////////////////
226
227 //---------------------------------------------------------
CSG_Parameter_Bool(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)228 CSG_Parameter_Bool::CSG_Parameter_Bool(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
229 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
230 {
231 m_Value = false;
232 }
233
234 //---------------------------------------------------------
_Set_Value(int Value)235 int CSG_Parameter_Bool::_Set_Value(int Value)
236 {
237 bool bValue = Value != 0;
238
239 if( m_Value != bValue )
240 {
241 m_Value = bValue;
242
243 return( SG_PARAMETER_DATA_SET_CHANGED );
244 }
245
246 return( SG_PARAMETER_DATA_SET_TRUE );
247 }
248
_Set_Value(double Value)249 int CSG_Parameter_Bool::_Set_Value(double Value)
250 {
251 return( _Set_Value((int)Value) );
252 }
253
_Set_Value(const CSG_String & Value)254 int CSG_Parameter_Bool::_Set_Value(const CSG_String &Value)
255 {
256 if( !Value.CmpNoCase("true") || !Value.CmpNoCase("yes") )
257 {
258 return( _Set_Value(1) );
259 }
260
261 if( !Value.CmpNoCase("false") || !Value.CmpNoCase("no") )
262 {
263 return( _Set_Value(0) );
264 }
265
266 int i;
267
268 if( Value.asInt(i) )
269 {
270 return( _Set_Value(i) );
271 }
272
273 return( SG_PARAMETER_DATA_SET_FALSE );
274 }
275
276 //---------------------------------------------------------
_Set_String(void)277 void CSG_Parameter_Bool::_Set_String(void)
278 {
279 m_String = m_Value ? _TL("true") : _TL("false");
280 }
281
282 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)283 bool CSG_Parameter_Bool::_Assign(CSG_Parameter *pSource)
284 {
285 m_Value = pSource->asBool();
286
287 return( true );
288 }
289
290 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)291 bool CSG_Parameter_Bool::_Serialize(CSG_MetaData &Entry, bool bSave)
292 {
293 if( bSave )
294 {
295 Entry.Set_Content(m_Value ? "true" : "false");
296 }
297 else
298 {
299 m_Value = Entry.Cmp_Content("true", true);
300 }
301
302 return( true );
303 }
304
305
306 ///////////////////////////////////////////////////////////
307 // //
308 // Value //
309 // //
310 ///////////////////////////////////////////////////////////
311
312 //---------------------------------------------------------
CSG_Parameter_Value(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)313 CSG_Parameter_Value::CSG_Parameter_Value(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
314 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
315 {
316 m_Minimum = 0.;
317 m_bMinimum = false;
318
319 m_Maximum = 0.;
320 m_bMaximum = false;
321 }
322
323 //---------------------------------------------------------
Set_Valid_Range(double Minimum,double Maximum)324 bool CSG_Parameter_Value::Set_Valid_Range(double Minimum, double Maximum)
325 {
326 if( m_bMinimum && m_bMaximum && Minimum > Maximum )
327 {
328 m_Minimum = Maximum;
329 m_Maximum = Minimum;
330 }
331 else
332 {
333 m_Minimum = Minimum;
334 m_Maximum = Maximum;
335 }
336
337 int Result;
338
339 switch( Get_Type() )
340 {
341 case PARAMETER_TYPE_Double:
342 case PARAMETER_TYPE_Degree: Result = _Set_Value(asDouble()); break;
343 case PARAMETER_TYPE_Int : Result = _Set_Value(asInt ()); break;
344 default : return( false );
345 }
346
347 if( Result == SG_PARAMETER_DATA_SET_CHANGED )
348 {
349 has_Changed();
350 }
351
352 return( Result != SG_PARAMETER_DATA_SET_FALSE );
353 }
354
355 //---------------------------------------------------------
Set_Minimum(double Minimum,bool bOn)356 void CSG_Parameter_Value::Set_Minimum(double Minimum, bool bOn)
357 {
358 if( bOn == false )
359 {
360 m_bMinimum = false;
361 }
362 else
363 {
364 m_bMinimum = true;
365
366 if( m_bMaximum && m_Maximum < Minimum )
367 {
368 m_Maximum = Minimum;
369 }
370
371 Set_Valid_Range(Minimum, m_Maximum);
372 }
373 }
374
375 //---------------------------------------------------------
Set_Maximum(double Maximum,bool bOn)376 void CSG_Parameter_Value::Set_Maximum(double Maximum, bool bOn)
377 {
378 if( bOn == false )
379 {
380 m_bMaximum = false;
381 }
382 else
383 {
384 m_bMaximum = true;
385
386 if( m_bMinimum && m_Minimum > Maximum )
387 {
388 m_Minimum = Maximum;
389 }
390
391 Set_Valid_Range(m_Minimum, Maximum);
392 }
393 }
394
395 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)396 bool CSG_Parameter_Value::_Assign(CSG_Parameter *pSource)
397 {
398 m_Minimum = pSource->asValue()->m_Minimum;
399 m_bMinimum = pSource->asValue()->m_bMinimum;
400
401 m_Maximum = pSource->asValue()->m_Maximum;
402 m_bMaximum = pSource->asValue()->m_bMaximum;
403
404 return( true );
405 }
406
407
408 ///////////////////////////////////////////////////////////
409 // //
410 // Int //
411 // //
412 ///////////////////////////////////////////////////////////
413
414 //---------------------------------------------------------
CSG_Parameter_Int(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)415 CSG_Parameter_Int::CSG_Parameter_Int(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
416 : CSG_Parameter_Value(pOwner, pParent, ID, Name, Description, Constraint)
417 {
418 m_Value = 0;
419 }
420
421 //---------------------------------------------------------
_Set_Value(int Value)422 int CSG_Parameter_Int::_Set_Value(int Value)
423 {
424 if( m_bMinimum && Value < (int)m_Minimum )
425 {
426 return( _Set_Value((int)m_Minimum) );
427 }
428
429 if( m_bMaximum && Value > (int)m_Maximum )
430 {
431 return( _Set_Value((int)m_Maximum) );
432 }
433
434 if( m_Value != Value )
435 {
436 m_Value = Value;
437
438 return( SG_PARAMETER_DATA_SET_CHANGED );
439 }
440
441 return( SG_PARAMETER_DATA_SET_TRUE );
442 }
443
_Set_Value(double Value)444 int CSG_Parameter_Int::_Set_Value(double Value)
445 {
446 return( _Set_Value((int)Value) );
447 }
448
_Set_Value(const CSG_String & Value)449 int CSG_Parameter_Int::_Set_Value(const CSG_String &Value)
450 {
451 int i;
452
453 if( Value.asInt(i) )
454 {
455 return( _Set_Value(i) );
456 }
457
458 return( SG_PARAMETER_DATA_SET_FALSE );
459 }
460
461 //---------------------------------------------------------
_Set_String(void)462 void CSG_Parameter_Int::_Set_String(void)
463 {
464 m_String.Printf("%d", m_Value);
465 }
466
467 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)468 bool CSG_Parameter_Int::_Assign(CSG_Parameter *pSource)
469 {
470 CSG_Parameter_Value::_Assign(pSource);
471
472 return( _Set_Value(((CSG_Parameter_Value *)pSource)->asInt()) != 0 );
473 }
474
475 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)476 bool CSG_Parameter_Int::_Serialize(CSG_MetaData &Entry, bool bSave)
477 {
478 if( bSave )
479 {
480 Entry.Set_Content(asString());
481 }
482 else
483 {
484 return( Entry.Get_Content().asInt(m_Value) );
485 }
486
487 return( true );
488 }
489
490
491 ///////////////////////////////////////////////////////////
492 // //
493 // Double //
494 // //
495 ///////////////////////////////////////////////////////////
496
497 //---------------------------------------------------------
CSG_Parameter_Double(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)498 CSG_Parameter_Double::CSG_Parameter_Double(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
499 : CSG_Parameter_Value(pOwner, pParent, ID, Name, Description, Constraint)
500 {
501 m_Value = 0.;
502 }
503
504 //---------------------------------------------------------
_Set_Value(int Value)505 int CSG_Parameter_Double::_Set_Value(int Value)
506 {
507 return( _Set_Value((double)Value) );
508 }
509
_Set_Value(double Value)510 int CSG_Parameter_Double::_Set_Value(double Value)
511 {
512 if( m_bMinimum && Value < m_Minimum )
513 {
514 return( _Set_Value(m_Minimum) );
515 }
516
517 if( m_bMaximum && Value > m_Maximum )
518 {
519 return( _Set_Value(m_Maximum) );
520 }
521
522 if( m_Value != Value )
523 {
524 m_Value = Value;
525
526 return( SG_PARAMETER_DATA_SET_CHANGED );
527 }
528
529 return( SG_PARAMETER_DATA_SET_TRUE );
530 }
531
_Set_Value(const CSG_String & Value)532 int CSG_Parameter_Double::_Set_Value(const CSG_String &Value)
533 {
534 double d;
535
536 if( Value.asDouble(d) )
537 {
538 return( _Set_Value(d) );
539 }
540
541 return( SG_PARAMETER_DATA_SET_FALSE );
542 }
543
544 //---------------------------------------------------------
_Set_String(void)545 void CSG_Parameter_Double::_Set_String(void)
546 {
547 m_String.Printf("%.*f", SG_Get_Significant_Decimals(m_Value, 16), m_Value);
548 }
549
550 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)551 bool CSG_Parameter_Double::_Assign(CSG_Parameter *pSource)
552 {
553 CSG_Parameter_Value::_Assign(pSource);
554
555 return( _Set_Value(pSource->asDouble()) != 0 );
556 }
557
558 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)559 bool CSG_Parameter_Double::_Serialize(CSG_MetaData &Entry, bool bSave)
560 {
561 if( bSave )
562 {
563 Entry.Fmt_Content("%.*f", SG_Get_Significant_Decimals(m_Value, 16), m_Value);
564 }
565 else
566 {
567 return( Entry.Get_Content().asDouble(m_Value) );
568 }
569
570 return( true );
571 }
572
573
574 ///////////////////////////////////////////////////////////
575 // //
576 // Degree //
577 // //
578 ///////////////////////////////////////////////////////////
579
580 //---------------------------------------------------------
CSG_Parameter_Degree(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)581 CSG_Parameter_Degree::CSG_Parameter_Degree(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
582 : CSG_Parameter_Double(pOwner, pParent, ID, Name, Description, Constraint)
583 {
584 // nop
585 }
586
587 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)588 int CSG_Parameter_Degree::_Set_Value(const CSG_String &Value)
589 {
590 return( CSG_Parameter_Double::_Set_Value(SG_Degree_To_Double(Value)) );
591 }
592
593 //---------------------------------------------------------
_Set_String(void)594 void CSG_Parameter_Degree::_Set_String(void)
595 {
596 m_String = SG_Double_To_Degree(asDouble());
597 }
598
599
600 ///////////////////////////////////////////////////////////
601 // //
602 // Date //
603 // //
604 ///////////////////////////////////////////////////////////
605
606 //---------------------------------------------------------
CSG_Parameter_Date(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)607 CSG_Parameter_Date::CSG_Parameter_Date(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
608 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
609 {
610 _Set_Value(CSG_DateTime::Now().Get_JDN());
611 }
612
613 //---------------------------------------------------------
_Set_Value(int Value)614 int CSG_Parameter_Date::_Set_Value(int Value)
615 {
616 return( _Set_Value((double)Value) );
617 }
618
_Set_Value(double Value)619 int CSG_Parameter_Date::_Set_Value(double Value)
620 {
621 Value = 0.5 + floor(Value); // always adjust to high noon, prevents rounding problems (we're not intested in time, just date!)
622
623 if( Value != asDouble() )
624 {
625 m_Date.Set(Value);
626
627 return( SG_PARAMETER_DATA_SET_CHANGED );
628 }
629
630 return( SG_PARAMETER_DATA_SET_TRUE );
631 }
632
_Set_Value(const CSG_String & Value)633 int CSG_Parameter_Date::_Set_Value(const CSG_String &Value)
634 {
635 CSG_DateTime Date;
636
637 if( Date.Parse_ISODate(Value) )
638 {
639 if( !m_Date.is_EqualTo(Date) )
640 {
641 m_Date.Set(Date);
642
643 return( SG_PARAMETER_DATA_SET_CHANGED );
644 }
645
646 return( SG_PARAMETER_DATA_SET_TRUE );
647 }
648
649 if( Date.Parse_Date(Value) )
650 {
651 if( !m_Date.is_EqualTo(Date) )
652 {
653 m_Date.Set(Date);
654
655 return( SG_PARAMETER_DATA_SET_CHANGED );
656 }
657
658 return( SG_PARAMETER_DATA_SET_TRUE );
659 }
660
661 return( SG_PARAMETER_DATA_SET_FALSE );
662 }
663
664 //---------------------------------------------------------
_Set_String(void)665 void CSG_Parameter_Date::_Set_String(void)
666 {
667 m_String = m_Date.Format_ISODate();
668 }
669
670 //---------------------------------------------------------
_asInt(void) const671 int CSG_Parameter_Date::_asInt(void) const
672 {
673 return( (int)asDouble() );
674 }
675
676 //---------------------------------------------------------
_asDouble(void) const677 double CSG_Parameter_Date::_asDouble(void) const
678 {
679 return( m_Date.Get_JDN() );
680 }
681
682 //---------------------------------------------------------
Set_Date(const CSG_DateTime & Date)683 void CSG_Parameter_Date::Set_Date(const CSG_DateTime &Date)
684 {
685 m_Date = Date;
686 }
687
688 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)689 bool CSG_Parameter_Date::_Assign(CSG_Parameter *pSource)
690 {
691 m_Date = ((CSG_Parameter_Date *)pSource)->m_Date;
692
693 return( true );
694 }
695
696 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)697 bool CSG_Parameter_Date::_Serialize(CSG_MetaData &Entry, bool bSave)
698 {
699 if( bSave )
700 {
701 Entry.Set_Content(asString());
702 }
703 else
704 {
705 _Set_Value(Entry.Get_Content());
706 }
707
708 return( true );
709 }
710
711
712 ///////////////////////////////////////////////////////////
713 // //
714 // Range //
715 // //
716 ///////////////////////////////////////////////////////////
717
718 //---------------------------------------------------------
CSG_Parameter_Range(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)719 CSG_Parameter_Range::CSG_Parameter_Range(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
720 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
721 {
722 m_pRange = new CSG_Parameters;
723
724 if( is_Information() )
725 {
726 m_pMin = (CSG_Parameter_Double *)m_pRange->Add_Info_Value(ID, "MIN", "Minimum", Description, PARAMETER_TYPE_Double);
727 m_pMax = (CSG_Parameter_Double *)m_pRange->Add_Info_Value(ID, "MAX", "Maximum", Description, PARAMETER_TYPE_Double);
728 }
729 else
730 {
731 m_pMin = (CSG_Parameter_Double *)m_pRange->Add_Double (ID, "MIN", "Minimum", Description);
732 m_pMax = (CSG_Parameter_Double *)m_pRange->Add_Double (ID, "MAX", "Maximum", Description);
733 }
734 }
735
~CSG_Parameter_Range(void)736 CSG_Parameter_Range::~CSG_Parameter_Range(void)
737 {
738 delete(m_pRange);
739 }
740
741 //---------------------------------------------------------
_Set_String(void)742 void CSG_Parameter_Range::_Set_String(void)
743 {
744 m_String.Printf("%.*f; %.*f",
745 SG_Get_Significant_Decimals(Get_Min(), 16), Get_Min(),
746 SG_Get_Significant_Decimals(Get_Min(), 16), Get_Max()
747 );
748 }
749
750 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)751 int CSG_Parameter_Range::_Set_Value(const CSG_String &Value)
752 {
753 return( Set_Range(Value.BeforeFirst(';').asDouble(), Value.AfterFirst(';').asDouble()) ? SG_PARAMETER_DATA_SET_CHANGED : SG_PARAMETER_DATA_SET_FALSE );
754 }
755
Set_Range(double Min,double Max)756 bool CSG_Parameter_Range::Set_Range(double Min, double Max)
757 {
758 bool bResult;
759
760 if( Min > Max )
761 {
762 bResult = m_pMin->Set_Value(Max);
763 bResult |= m_pMax->Set_Value(Min);
764 }
765 else
766 {
767 bResult = m_pMin->Set_Value(Min);
768 bResult |= m_pMax->Set_Value(Max);
769 }
770
771 return( bResult );
772 }
773
774 //---------------------------------------------------------
Set_Min(double Value)775 bool CSG_Parameter_Range::Set_Min(double Value)
776 {
777 if( m_pMin->Set_Value(Value) )
778 {
779 has_Changed();
780
781 return( true );
782 }
783
784 return( false );
785 }
786
Get_Min(void) const787 double CSG_Parameter_Range::Get_Min(void) const
788 {
789 return( m_pMin->asDouble() );
790 }
791
792 //---------------------------------------------------------
Set_Max(double Value)793 bool CSG_Parameter_Range::Set_Max(double Value)
794 {
795 if( m_pMax->Set_Value(Value) )
796 {
797 has_Changed();
798
799 return( true );
800 }
801
802 return( false );
803 }
804
Get_Max(void) const805 double CSG_Parameter_Range::Get_Max(void) const
806 {
807 return( m_pMax->asDouble() );
808 }
809
810 //---------------------------------------------------------
Restore_Default(void)811 bool CSG_Parameter_Range::Restore_Default(void)
812 {
813 return( m_pMin->Restore_Default() && m_pMax->Restore_Default() );
814 }
815
816 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)817 bool CSG_Parameter_Range::_Assign(CSG_Parameter *pSource)
818 {
819 m_pMin->Assign(pSource->asRange()->m_pMin);
820 m_pMax->Assign(pSource->asRange()->m_pMax);
821
822 return( true );
823 }
824
825 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)826 bool CSG_Parameter_Range::_Serialize(CSG_MetaData &Entry, bool bSave)
827 {
828 if( bSave )
829 {
830 Entry.Fmt_Content("%.*f; %.*f",
831 SG_Get_Significant_Decimals(Get_Min(), 16), Get_Min(),
832 SG_Get_Significant_Decimals(Get_Min(), 16), Get_Max()
833 );
834
835 return( true );
836 }
837 else
838 {
839 CSG_String s(Entry.Get_Content()); double Min, Max;
840
841 if( s.BeforeFirst(';').asDouble(Min) && s.AfterFirst(';').asDouble(Max) )
842 {
843 return( Set_Range(Min, Max) );
844 }
845 }
846
847 return( false );
848 }
849
850
851 ///////////////////////////////////////////////////////////
852 // //
853 // Choice //
854 // //
855 ///////////////////////////////////////////////////////////
856
857 //---------------------------------------------------------
CSG_Parameter_Choice(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)858 CSG_Parameter_Choice::CSG_Parameter_Choice(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
859 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
860 {
861 m_Value = -1;
862 }
863
864 //---------------------------------------------------------
Set_Items(const SG_Char * String)865 void CSG_Parameter_Choice::Set_Items(const SG_Char *String)
866 {
867 m_Items.Clear();
868
869 if( String && *String != '\0' )
870 {
871 m_Items = SG_String_Tokenize(String, "|");
872 }
873
874 if( m_Value < 0 && m_Items.Get_Count() > 0 )
875 {
876 m_Value = 0;
877 }
878
879 if( m_Value >= m_Items.Get_Count() )
880 {
881 m_Value = m_Items.Get_Count() - 1;
882 }
883
884 _Set_String(); // m_Items have changed
885 }
886
887 //---------------------------------------------------------
Get_Items(void) const888 CSG_String CSG_Parameter_Choice::Get_Items(void) const
889 {
890 CSG_String Items;
891
892 for(int i=0; i<m_Items.Get_Count(); i++)
893 {
894 if( i > 0 )
895 {
896 Items += "|";
897 }
898
899 Items += m_Items[i];
900 }
901
902 return( Items );
903 }
904
905 //---------------------------------------------------------
Get_Item(int Index) const906 const SG_Char * CSG_Parameter_Choice::Get_Item(int Index) const
907 {
908 if( Index >= 0 && Index < m_Items.Get_Count() )
909 {
910 const SG_Char *Item = m_Items[Index].c_str();
911
912 if( *Item == '{' )
913 {
914 do { Item++; } while( *Item != '\0' && *Item != '}' );
915
916 if( *Item == '\0' )
917 {
918 return( m_Items[Index].c_str() );
919 }
920
921 Item++;
922 }
923
924 return( Item );
925 }
926
927 return( NULL );
928 }
929
930 //---------------------------------------------------------
Get_Item_Data(int Index) const931 CSG_String CSG_Parameter_Choice::Get_Item_Data(int Index) const
932 {
933 CSG_String Data;
934
935 if( Index >= 0 && Index < m_Items.Get_Count() )
936 {
937 Data = m_Items[Index]; Data.Trim();
938
939 if( Data.Find('{') == 0 ) // data entry within leading curly brackets: '{data} item text'
940 {
941 Data = Data.AfterFirst('{').BeforeFirst('}');
942 }
943 }
944
945 return( Data );
946 }
947
Get_Data(int & Value) const948 bool CSG_Parameter_Choice::Get_Data(int &Value) const
949 {
950 CSG_String String;
951
952 return( Get_Data(String) && String.asInt (Value) );
953 }
954
Get_Data(double & Value) const955 bool CSG_Parameter_Choice::Get_Data(double &Value) const
956 {
957 CSG_String String;
958
959 return( Get_Data(String) && String.asDouble(Value) );
960 }
961
Get_Data(CSG_String & Value) const962 bool CSG_Parameter_Choice::Get_Data(CSG_String &Value) const
963 {
964 Value = Get_Item_Data(m_Value);
965
966 return( !Value.is_Empty() );
967 }
968
Get_Data(void) const969 CSG_String CSG_Parameter_Choice::Get_Data(void) const
970 {
971 return( Get_Item_Data(m_Value) );
972 }
973
974 //---------------------------------------------------------
_Set_Value(int Value)975 int CSG_Parameter_Choice::_Set_Value(int Value)
976 {
977 if( Value >= 0 && Value < m_Items.Get_Count() )
978 {
979 if( m_Value != Value )
980 {
981 m_Value = Value;
982
983 return( SG_PARAMETER_DATA_SET_CHANGED );
984 }
985
986 return( SG_PARAMETER_DATA_SET_TRUE );
987 }
988
989 return( SG_PARAMETER_DATA_SET_FALSE );
990 }
991
992 //---------------------------------------------------------
_Set_Value(double Value)993 int CSG_Parameter_Choice::_Set_Value(double Value)
994 {
995 return( _Set_Value((int)Value) );
996 }
997
998 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)999 int CSG_Parameter_Choice::_Set_Value(const CSG_String &Value)
1000 {
1001 if( !Value.is_Empty() )
1002 {
1003 int Index; // first test, if value string is an integer specifying the index position
1004
1005 if( Value.asInt(Index) && Index >= 0 && Index < m_Items.Get_Count() )
1006 {
1007 return( _Set_Value(Index) );
1008 }
1009
1010 CSG_String _Value(Value[0] == '\"' ? Value.AfterFirst('\"').BeforeFirst('\"') : Value); // quotations can be used to enforce comparison with item's data/name (overpassing index based selection)
1011
1012 for(int i=0; i<m_Items.Get_Count(); i++)
1013 {
1014 if( !_Value.Cmp(Get_Item_Data(i)) || !_Value.Cmp(Get_Item(i)) )
1015 {
1016 return( _Set_Value(i) );
1017 }
1018 }
1019 }
1020
1021 return( SG_PARAMETER_DATA_SET_FALSE );
1022 }
1023
1024 //---------------------------------------------------------
_Set_String(void)1025 void CSG_Parameter_Choice::_Set_String(void)
1026 {
1027 m_String = m_Value >= 0 && m_Value < m_Items.Get_Count() ? Get_Item(m_Value) : _TL("<no choice available>");
1028 }
1029
1030 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1031 bool CSG_Parameter_Choice::_Assign(CSG_Parameter *pSource)
1032 {
1033 m_Items = pSource->asChoice()->m_Items;
1034 m_Value = pSource->asChoice()->m_Value;
1035
1036 _Set_String(); // m_Items have changed
1037
1038 return( true );
1039 }
1040
1041 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1042 bool CSG_Parameter_Choice::_Serialize(CSG_MetaData &Entry, bool bSave)
1043 {
1044 if( bSave )
1045 {
1046 Entry.Add_Property("index", m_Value);
1047
1048 Entry.Set_Content(asString());
1049
1050 return( true );
1051 }
1052 else
1053 {
1054 int Index;
1055
1056 return( (Entry.Get_Property("index", Index) || Entry.Get_Content().asInt(Index)) && _Set_Value(Index) );
1057 }
1058 }
1059
1060
1061 ///////////////////////////////////////////////////////////
1062 // //
1063 // Choice //
1064 // //
1065 ///////////////////////////////////////////////////////////
1066
1067 //---------------------------------------------------------
CSG_Parameter_Choices(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1068 CSG_Parameter_Choices::CSG_Parameter_Choices(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1069 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
1070 {
1071 // nop
1072 }
1073
1074 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)1075 int CSG_Parameter_Choices::_Set_Value(const CSG_String &Value)
1076 {
1077 CSG_String_Tokenizer Tokens(Value, ";");
1078
1079 m_Selection.Destroy();
1080
1081 while( Tokens.Has_More_Tokens() )
1082 {
1083 int Index;
1084
1085 if( Tokens.Get_Next_Token().asInt(Index) )
1086 {
1087 Select(Index);
1088 }
1089 }
1090
1091 return( SG_PARAMETER_DATA_SET_CHANGED );
1092 }
1093
1094 //---------------------------------------------------------
_Set_String(void)1095 void CSG_Parameter_Choices::_Set_String(void)
1096 {
1097 m_String.Clear();
1098
1099 for(size_t i=0; i<m_Selection.Get_Size(); i++)
1100 {
1101 m_String += CSG_String::Format("%d;", m_Selection[i]);
1102 }
1103 }
1104
1105 //---------------------------------------------------------
Set_Items(const CSG_String & Items)1106 void CSG_Parameter_Choices::Set_Items(const CSG_String &Items)
1107 {
1108 Del_Items();
1109
1110 CSG_String_Tokenizer Tokens(Items, "|");
1111
1112 while( Tokens.Has_More_Tokens() )
1113 {
1114 Add_Item(Tokens.Get_Next_Token());
1115 }
1116 }
1117
1118 //---------------------------------------------------------
Set_Items(const CSG_Strings & Items)1119 void CSG_Parameter_Choices::Set_Items(const CSG_Strings &Items)
1120 {
1121 Del_Items();
1122
1123 for(int i=0; i<Items.Get_Count(); i++)
1124 {
1125 Add_Item(Items[i]);
1126 }
1127 }
1128
1129 //---------------------------------------------------------
Get_Items(void) const1130 CSG_String CSG_Parameter_Choices::Get_Items(void) const
1131 {
1132 CSG_String Items;
1133
1134 for(int i=0; i<m_Items[0].Get_Count(); i++)
1135 {
1136 if( i > 0 )
1137 {
1138 Items += "|";
1139 }
1140
1141 Items += m_Items[0][i];
1142 }
1143
1144 return( Items );
1145 }
1146
1147 //---------------------------------------------------------
Del_Items(void)1148 void CSG_Parameter_Choices::Del_Items(void)
1149 {
1150 m_Items[0].Clear();
1151 m_Items[1].Clear();
1152
1153 m_Selection.Destroy();
1154 }
1155
1156 //---------------------------------------------------------
Add_Item(const CSG_String & Item,const CSG_String & Data)1157 void CSG_Parameter_Choices::Add_Item(const CSG_String &Item, const CSG_String &Data)
1158 {
1159 m_Items[0] += Item;
1160 m_Items[1] += Data;
1161 }
1162
1163 //---------------------------------------------------------
is_Selected(int Index)1164 bool CSG_Parameter_Choices::is_Selected(int Index)
1165 {
1166 for(size_t i=0; i<m_Selection.Get_Size(); i++)
1167 {
1168 if( Index == m_Selection[i] )
1169 {
1170 return( true );
1171 }
1172 }
1173
1174 return( false );
1175 }
1176
1177 //---------------------------------------------------------
Select(int Index,bool bSelect)1178 bool CSG_Parameter_Choices::Select(int Index, bool bSelect)
1179 {
1180 if( Index >= 0 && Index < Get_Item_Count() )
1181 {
1182 if( bSelect && !is_Selected(Index) )
1183 {
1184 m_Selection += Index;
1185 }
1186 else if( !bSelect )
1187 {
1188 for(size_t i=0; i<m_Selection.Get_Size(); i++)
1189 {
1190 if( Index == m_Selection[i] )
1191 {
1192 for(size_t j=i+1; j<m_Selection.Get_Size(); i++, j++)
1193 {
1194 m_Selection[i] = m_Selection[j];
1195 }
1196
1197 m_Selection.Dec_Array();
1198 }
1199 }
1200 }
1201
1202 return( true );
1203 }
1204
1205 return( false );
1206 }
1207
1208 //---------------------------------------------------------
Clr_Selection(void)1209 bool CSG_Parameter_Choices::Clr_Selection(void)
1210 {
1211 m_Selection.Destroy();
1212
1213 return( true );
1214 }
1215
1216 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1217 bool CSG_Parameter_Choices::_Assign(CSG_Parameter *pSource)
1218 {
1219 m_Items[0] = pSource->asChoices()->m_Items[0];
1220 m_Items[1] = pSource->asChoices()->m_Items[1];
1221
1222 m_Selection = pSource->asChoices()->m_Selection;
1223
1224 return( true );
1225 }
1226
1227 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1228 bool CSG_Parameter_Choices::_Serialize(CSG_MetaData &Entry, bool bSave)
1229 {
1230 if( bSave )
1231 {
1232 Entry.Set_Content(asString());
1233
1234 return( true );
1235 }
1236 else
1237 {
1238 return( _Set_Value(Entry.Get_Content()) != 0 );
1239 }
1240 }
1241
1242
1243 ///////////////////////////////////////////////////////////
1244 // //
1245 // String //
1246 // //
1247 ///////////////////////////////////////////////////////////
1248
1249 //---------------------------------------------------------
CSG_Parameter_String(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1250 CSG_Parameter_String::CSG_Parameter_String(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1251 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
1252 {
1253 m_bPassword = false;
1254 }
1255
1256 //---------------------------------------------------------
is_Valid(void) const1257 bool CSG_Parameter_String::is_Valid(void) const
1258 {
1259 return( !m_String.is_Empty() );
1260 }
1261
1262 //---------------------------------------------------------
Set_Password(bool bOn)1263 void CSG_Parameter_String::Set_Password(bool bOn)
1264 {
1265 m_bPassword = bOn;
1266 }
1267
1268 //---------------------------------------------------------
is_Password(void) const1269 bool CSG_Parameter_String::is_Password(void) const
1270 {
1271 return( m_bPassword );
1272 }
1273
1274 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)1275 int CSG_Parameter_String::_Set_Value(const CSG_String &Value)
1276 {
1277 if( m_String.Cmp(Value) )
1278 {
1279 m_String = Value;
1280
1281 return( SG_PARAMETER_DATA_SET_CHANGED );
1282 }
1283
1284 return( SG_PARAMETER_DATA_SET_TRUE );
1285 }
1286
1287 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1288 bool CSG_Parameter_String::_Assign(CSG_Parameter *pSource)
1289 {
1290 m_String = ((CSG_Parameter_String *)pSource)->m_String;
1291 m_bPassword = ((CSG_Parameter_String *)pSource)->m_bPassword;
1292
1293 return( true );
1294 }
1295
1296 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1297 bool CSG_Parameter_String::_Serialize(CSG_MetaData &Entry, bool bSave)
1298 {
1299 if( bSave )
1300 {
1301 Entry.Set_Content(m_String);
1302 }
1303 else
1304 {
1305 m_String = Entry.Get_Content();
1306 }
1307
1308 return( true );
1309 }
1310
1311
1312 ///////////////////////////////////////////////////////////
1313 // //
1314 // Text //
1315 // //
1316 ///////////////////////////////////////////////////////////
1317
1318 //---------------------------------------------------------
CSG_Parameter_Text(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1319 CSG_Parameter_Text::CSG_Parameter_Text(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1320 : CSG_Parameter_String(pOwner, pParent, ID, Name, Description, Constraint)
1321 {
1322 // nop
1323 }
1324
1325
1326 ///////////////////////////////////////////////////////////
1327 // //
1328 // FilePath //
1329 // //
1330 ///////////////////////////////////////////////////////////
1331
1332 //---------------------------------------------------------
CSG_Parameter_File_Name(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1333 CSG_Parameter_File_Name::CSG_Parameter_File_Name(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1334 : CSG_Parameter_String(pOwner, pParent, ID, Name, Description, Constraint)
1335 {
1336 m_Filter.Printf("%s|*.*", _TL("All Files"));
1337
1338 m_bSave = false;
1339 m_bMultiple = false;
1340 m_bDirectory = false;
1341 }
1342
1343 //---------------------------------------------------------
Set_Filter(const SG_Char * Filter)1344 void CSG_Parameter_File_Name::Set_Filter(const SG_Char *Filter)
1345 {
1346 if( Filter )
1347 {
1348 m_Filter = Filter;
1349 }
1350 else
1351 {
1352 m_Filter.Printf("%s|*.*", _TL("All Files"));
1353 }
1354 }
1355
Get_Filter(void) const1356 const SG_Char * CSG_Parameter_File_Name::Get_Filter(void) const
1357 {
1358 return( m_Filter.c_str() );
1359 }
1360
1361 //---------------------------------------------------------
Set_Flag_Save(bool bFlag)1362 void CSG_Parameter_File_Name::Set_Flag_Save(bool bFlag)
1363 {
1364 m_bSave = bFlag;
1365 }
1366
Set_Flag_Multiple(bool bFlag)1367 void CSG_Parameter_File_Name::Set_Flag_Multiple(bool bFlag)
1368 {
1369 m_bMultiple = bFlag;
1370 }
1371
Set_Flag_Directory(bool bFlag)1372 void CSG_Parameter_File_Name::Set_Flag_Directory(bool bFlag)
1373 {
1374 m_bDirectory = bFlag;
1375 }
1376
1377 //---------------------------------------------------------
Get_FilePaths(CSG_Strings & FilePaths) const1378 bool CSG_Parameter_File_Name::Get_FilePaths(CSG_Strings &FilePaths) const
1379 {
1380 FilePaths.Clear();
1381
1382 if( m_String.Length() > 0 )
1383 {
1384 if( !m_bMultiple )
1385 {
1386 FilePaths.Add(m_String);
1387 }
1388 else if( m_String[0] != '\"' )
1389 {
1390 FilePaths.Add(m_String);
1391 }
1392 else
1393 {
1394 CSG_String s(m_String);
1395
1396 while( s.Length() > 2 )
1397 {
1398 s = s.AfterFirst('\"');
1399 FilePaths.Add(s.BeforeFirst('\"'));
1400 s = s.AfterFirst('\"');
1401 }
1402 }
1403 }
1404
1405 return( FilePaths.Get_Count() > 0 );
1406 }
1407
1408 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1409 bool CSG_Parameter_File_Name::_Assign(CSG_Parameter *pSource)
1410 {
1411 CSG_Parameter_String::_Assign(pSource);
1412
1413 Set_Filter(((CSG_Parameter_File_Name *)pSource)->m_Filter.c_str());
1414
1415 m_bSave = pSource->asFilePath()->m_bSave;
1416 m_bMultiple = pSource->asFilePath()->m_bMultiple;
1417 m_bDirectory = pSource->asFilePath()->m_bDirectory;
1418
1419 return( true );
1420 }
1421
1422
1423 ///////////////////////////////////////////////////////////
1424 // //
1425 // Font //
1426 // //
1427 ///////////////////////////////////////////////////////////
1428
1429 //---------------------------------------------------------
CSG_Parameter_Font(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1430 CSG_Parameter_Font::CSG_Parameter_Font(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1431 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
1432 {
1433 Restore_Default();
1434 }
1435
1436 //---------------------------------------------------------
Restore_Default(void)1437 bool CSG_Parameter_Font::Restore_Default(void)
1438 {
1439 m_Color = SG_GET_RGB(0, 0, 0);
1440 m_Font = "0;-13;0;0;0;400;0;0;0;0;3;2;1;34;Arial";
1441 m_String = "Arial";
1442
1443 return( true );
1444 }
1445
1446 //---------------------------------------------------------
_Set_Value(int Value)1447 int CSG_Parameter_Font::_Set_Value(int Value)
1448 {
1449 if( m_Color != Value )
1450 {
1451 m_Color = Value;
1452
1453 return( SG_PARAMETER_DATA_SET_CHANGED );
1454 }
1455
1456 return( SG_PARAMETER_DATA_SET_TRUE );
1457 }
1458
1459 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)1460 int CSG_Parameter_Font::_Set_Value(const CSG_String &Value)
1461 {
1462 if( Value.is_Empty() )
1463 {
1464 Restore_Default();
1465
1466 return( SG_PARAMETER_DATA_SET_CHANGED );
1467 }
1468
1469 m_Font = Value;
1470 m_String = m_Font.AfterLast(';');
1471
1472 return( SG_PARAMETER_DATA_SET_CHANGED );
1473 }
1474
1475 //---------------------------------------------------------
_asInt(void) const1476 int CSG_Parameter_Font::_asInt(void) const
1477 {
1478 return( m_Color );
1479 }
1480
1481 //---------------------------------------------------------
_asPointer(void) const1482 void * CSG_Parameter_Font::_asPointer(void) const
1483 {
1484 return( (void *)m_Font.c_str() );
1485 }
1486
1487 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1488 bool CSG_Parameter_Font::_Assign(CSG_Parameter *pSource)
1489 {
1490 m_Color = ((CSG_Parameter_Font *)pSource)->m_Color;
1491 m_Font = ((CSG_Parameter_Font *)pSource)->m_Font;
1492 m_String = ((CSG_Parameter_Font *)pSource)->m_String;
1493
1494 return( true );
1495 }
1496
1497 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1498 bool CSG_Parameter_Font::_Serialize(CSG_MetaData &Entry, bool bSave)
1499 {
1500 if( bSave )
1501 {
1502 Entry.Add_Child("COLOR", CSG_String::Format("R%03d G%03d B%03d",
1503 SG_GET_R(m_Color),
1504 SG_GET_G(m_Color),
1505 SG_GET_B(m_Color)
1506 ));
1507
1508 Entry.Add_Child("FONT", m_Font);
1509 }
1510 else
1511 {
1512 if( Entry("COLOR") != NULL )
1513 {
1514 _Set_Value((int)SG_GET_RGB(
1515 Entry("COLOR")->Get_Content().AfterFirst('R').asInt(),
1516 Entry("COLOR")->Get_Content().AfterFirst('G').asInt(),
1517 Entry("COLOR")->Get_Content().AfterFirst('B').asInt()
1518 ));
1519 }
1520
1521 if( Entry("FONT") != NULL )
1522 {
1523 _Set_Value(Entry("FONT")->Get_Content());
1524 }
1525 }
1526
1527 return( true );
1528 }
1529
1530
1531 ///////////////////////////////////////////////////////////
1532 // //
1533 // Color //
1534 // //
1535 ///////////////////////////////////////////////////////////
1536
1537 //---------------------------------------------------------
CSG_Parameter_Color(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1538 CSG_Parameter_Color::CSG_Parameter_Color(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1539 : CSG_Parameter_Int(pOwner, pParent, ID, Name, Description, Constraint)
1540 {
1541 // nop
1542 }
1543
1544 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)1545 int CSG_Parameter_Color::_Set_Value(const CSG_String &Value)
1546 {
1547 long l;
1548
1549 if( SG_Color_From_Text(Value, l) )
1550 {
1551 return( CSG_Parameter_Int::_Set_Value((int)l) );
1552 }
1553
1554 int i;
1555
1556 if( Value.asInt(i) )
1557 {
1558 return( CSG_Parameter_Int::_Set_Value(i) );
1559 }
1560
1561 return( SG_PARAMETER_DATA_SET_FALSE );
1562 }
1563
1564 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1565 bool CSG_Parameter_Color::_Serialize(CSG_MetaData &Entry, bool bSave)
1566 {
1567 if( bSave )
1568 {
1569 Entry.Fmt_Content("R%03d G%03d B%03d", SG_GET_R(m_Value), SG_GET_G(m_Value), SG_GET_B(m_Value));
1570 }
1571 else
1572 {
1573 m_Value = SG_GET_RGB(
1574 Entry.Get_Content().AfterFirst('R').asInt(),
1575 Entry.Get_Content().AfterFirst('G').asInt(),
1576 Entry.Get_Content().AfterFirst('B').asInt()
1577 );
1578 }
1579
1580 return( true );
1581 }
1582
1583
1584 ///////////////////////////////////////////////////////////
1585 // //
1586 // Colors //
1587 // //
1588 ///////////////////////////////////////////////////////////
1589
1590 //---------------------------------------------------------
CSG_Parameter_Colors(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1591 CSG_Parameter_Colors::CSG_Parameter_Colors(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1592 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
1593 {
1594 // nop
1595 }
1596
1597 //---------------------------------------------------------
_Set_String(void)1598 void CSG_Parameter_Colors::_Set_String(void)
1599 {
1600 m_String.Printf("%d %s", m_Colors.Get_Count(), _TL("colors"));
1601 }
1602
1603
1604 //---------------------------------------------------------
_asInt(void) const1605 int CSG_Parameter_Colors::_asInt(void) const
1606 {
1607 return( m_Colors.Get_Count() );
1608 }
1609
1610 //---------------------------------------------------------
_asPointer(void) const1611 void * CSG_Parameter_Colors::_asPointer(void) const
1612 {
1613 return( (void *)&m_Colors );
1614 }
1615
1616 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1617 bool CSG_Parameter_Colors::_Assign(CSG_Parameter *pSource)
1618 {
1619 return( m_Colors.Assign(pSource->asColors()) );
1620 }
1621
1622 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1623 bool CSG_Parameter_Colors::_Serialize(CSG_MetaData &Entry, bool bSave)
1624 {
1625 if( bSave )
1626 {
1627 for(int i=0; i<m_Colors.Get_Count(); i++)
1628 {
1629 Entry.Add_Child("COLOR", CSG_String::Format("R%03d G%03d B%03d",
1630 m_Colors.Get_Red (i),
1631 m_Colors.Get_Green(i),
1632 m_Colors.Get_Blue (i))
1633 );
1634 }
1635 }
1636 else
1637 {
1638 if( Entry.Get_Children_Count() <= 1 )
1639 {
1640 return( false );
1641 }
1642
1643 m_Colors.Set_Count(Entry.Get_Children_Count());
1644
1645 for(int i=0; i<m_Colors.Get_Count(); i++)
1646 {
1647 CSG_String s(Entry(i)->Get_Content());
1648
1649 m_Colors.Set_Red (i, s.AfterFirst('R').asInt());
1650 m_Colors.Set_Green(i, s.AfterFirst('G').asInt());
1651 m_Colors.Set_Blue (i, s.AfterFirst('B').asInt());
1652 }
1653 }
1654
1655 return( true );
1656 }
1657
1658
1659 ///////////////////////////////////////////////////////////
1660 // //
1661 // FixedTable //
1662 // //
1663 ///////////////////////////////////////////////////////////
1664
1665 //---------------------------------------------------------
CSG_Parameter_Fixed_Table(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1666 CSG_Parameter_Fixed_Table::CSG_Parameter_Fixed_Table(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1667 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
1668 {
1669 m_Table.Set_Name(_TL("Table"));
1670 }
1671
1672 //---------------------------------------------------------
_Set_String(void)1673 void CSG_Parameter_Fixed_Table::_Set_String(void)
1674 {
1675 m_String.Printf("%s (%s: %d, %s: %d)", m_Table.Get_Name(), _TL("columns"), m_Table.Get_Field_Count(), _TL("rows"), m_Table.Get_Record_Count());
1676 }
1677
1678 //---------------------------------------------------------
_asPointer(void) const1679 void * CSG_Parameter_Fixed_Table::_asPointer(void) const
1680 {
1681 return( (void *)&m_Table );
1682 }
1683
1684 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1685 bool CSG_Parameter_Fixed_Table::_Assign(CSG_Parameter *pSource)
1686 {
1687 return( m_Table.Create(*pSource->asTable()) );
1688 }
1689
1690 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1691 bool CSG_Parameter_Fixed_Table::_Serialize(CSG_MetaData &Entry, bool bSave)
1692 {
1693 int iField;
1694
1695 if( bSave )
1696 {
1697 CSG_MetaData *pNode = Entry.Add_Child("FIELDS");
1698
1699 for(iField=0; iField<m_Table.Get_Field_Count(); iField++)
1700 {
1701 CSG_MetaData *pEntry = pNode->Add_Child("FIELD", m_Table.Get_Field_Name(iField));
1702
1703 pEntry->Set_Property("type", gSG_Data_Type_Identifier[m_Table.Get_Field_Type(iField)]);
1704 }
1705
1706 pNode = Entry.Add_Child("RECORDS");
1707
1708 for(int iRecord=0; iRecord<m_Table.Get_Count(); iRecord++)
1709 {
1710 CSG_MetaData *pEntry = pNode->Add_Child("RECORD");
1711
1712 CSG_Table_Record *pRecord = m_Table.Get_Record(iRecord);
1713
1714 for(iField=0; iField<m_Table.Get_Field_Count(); iField++)
1715 {
1716 pEntry->Add_Child("FIELD", pRecord->asString(iField));
1717 }
1718 }
1719 }
1720 else
1721 {
1722 CSG_MetaData *pNode;
1723
1724 if( (pNode = Entry("FIELDS")) == NULL )
1725 {
1726 return( false );
1727 }
1728
1729 CSG_Table Table;
1730
1731 for(iField=0; iField<pNode->Get_Children_Count(); iField++)
1732 {
1733 TSG_Data_Type type = SG_DATATYPE_String;
1734
1735 CSG_String s;
1736
1737 if( pNode->Get_Child(iField)->Get_Property("type", s) )
1738 {
1739 type = SG_Data_Type_Get_Type(s);
1740 }
1741
1742 Table.Add_Field(pNode->Get_Child(iField)->Get_Content(), type == SG_DATATYPE_Undefined ? SG_DATATYPE_String : type);
1743 }
1744
1745 if( (pNode = Entry("RECORDS")) == NULL )
1746 {
1747 return( false );
1748 }
1749
1750 for(int iRecord=0; iRecord<pNode->Get_Children_Count(); iRecord++)
1751 {
1752 CSG_MetaData *pEntry = pNode->Get_Child(iRecord);
1753
1754 CSG_Table_Record *pRecord = Table.Add_Record();
1755
1756 for(iField=0; iField<pEntry->Get_Children_Count(); iField++)
1757 {
1758 pRecord->Set_Value(iField, pEntry->Get_Child(iField)->Get_Content());
1759 }
1760 }
1761
1762 return( m_Table.Assign_Values(&Table) );
1763 }
1764
1765 return( true );
1766 }
1767
1768
1769 ///////////////////////////////////////////////////////////
1770 // //
1771 // Grid_System //
1772 // //
1773 ///////////////////////////////////////////////////////////
1774
1775 //---------------------------------------------------------
CSG_Parameter_Grid_System(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1776 CSG_Parameter_Grid_System::CSG_Parameter_Grid_System(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1777 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
1778 {
1779 // nop
1780 }
1781
1782 //---------------------------------------------------------
_Set_Value(void * Value)1783 int CSG_Parameter_Grid_System::_Set_Value(void *Value)
1784 {
1785 CSG_Grid_System System;
1786
1787 if( Value != NULL )
1788 {
1789 System.Create(*((CSG_Grid_System *)Value));
1790 }
1791
1792 if( m_System == System )
1793 {
1794 return( SG_PARAMETER_DATA_SET_TRUE );
1795 }
1796
1797 m_System = System;
1798
1799 //-----------------------------------------------------
1800 CSG_Data_Manager *pManager = Get_Manager();
1801
1802 for(int i=0; i<Get_Children_Count(); i++)
1803 {
1804 CSG_Parameter *pParameter = Get_Child(i);
1805
1806 if( pParameter->is_DataObject() )
1807 {
1808 CSG_Data_Object *pObject = pParameter->asDataObject();
1809
1810 bool bInvalid = !m_System.is_Valid() || !(pManager && pManager->Exists(pObject));
1811
1812 if( !bInvalid && pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE )
1813 {
1814 switch( pObject->Get_ObjectType() )
1815 {
1816 case SG_DATAOBJECT_TYPE_Grid : bInvalid = !m_System.is_Equal(((CSG_Grid *)pObject)->Get_System()); break;
1817 case SG_DATAOBJECT_TYPE_Grids: bInvalid = !m_System.is_Equal(((CSG_Grids *)pObject)->Get_System()); break;
1818 default: break;
1819 }
1820 }
1821
1822 if( bInvalid && pObject != DATAOBJECT_CREATE )
1823 {
1824 pParameter->Set_Value(DATAOBJECT_NOTSET);
1825 }
1826 }
1827
1828 //-------------------------------------------------
1829 else if( pParameter->is_DataObject_List() )
1830 {
1831 CSG_Parameter_List *pList = pParameter->asList();
1832
1833 if( !m_System.is_Valid() )
1834 {
1835 pList->Del_Items();
1836 }
1837 else for(int j=pList->Get_Item_Count()-1; j>=0; j--)
1838 {
1839 CSG_Data_Object *pObject = pList->Get_Item(j);
1840
1841 bool bInvalid = !(pManager && pManager->Exists(pObject));
1842
1843 if( !bInvalid && pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE )
1844 {
1845 switch( pObject->Get_ObjectType() )
1846 {
1847 case SG_DATAOBJECT_TYPE_Grid : bInvalid = !m_System.is_Equal(((CSG_Grid *)pObject)->Get_System()); break;
1848 case SG_DATAOBJECT_TYPE_Grids: bInvalid = !m_System.is_Equal(((CSG_Grids *)pObject)->Get_System()); break;
1849 default: break;
1850 }
1851 }
1852
1853 if( bInvalid )
1854 {
1855 pList->Del_Item(j);
1856 }
1857 }
1858
1859 pParameter->has_Changed();
1860 }
1861 }
1862
1863 //-----------------------------------------------------
1864 return( SG_PARAMETER_DATA_SET_CHANGED );
1865 }
1866
1867 //---------------------------------------------------------
_Set_String(void)1868 void CSG_Parameter_Grid_System::_Set_String(void)
1869 {
1870 m_String = m_System.Get_Name();
1871 }
1872
1873 //---------------------------------------------------------
_asPointer(void) const1874 void * CSG_Parameter_Grid_System::_asPointer(void) const
1875 {
1876 return( (void *)&m_System );
1877 }
1878
1879 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)1880 bool CSG_Parameter_Grid_System::_Assign(CSG_Parameter *pSource)
1881 {
1882 m_System = ((CSG_Parameter_Grid_System *)pSource)->m_System;
1883
1884 return( true );
1885 }
1886
1887 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)1888 bool CSG_Parameter_Grid_System::_Serialize(CSG_MetaData &Entry, bool bSave)
1889 {
1890 if( bSave )
1891 {
1892 Entry.Add_Child("CELLSIZE", m_System.Get_Cellsize());
1893 Entry.Add_Child("XMIN" , m_System.Get_Extent().Get_XMin());
1894 Entry.Add_Child("XMAX" , m_System.Get_Extent().Get_XMax());
1895 Entry.Add_Child("YMIN" , m_System.Get_Extent().Get_YMin());
1896 Entry.Add_Child("YMAX" , m_System.Get_Extent().Get_YMax());
1897 }
1898 else
1899 {
1900 double Cellsize;
1901 TSG_Rect Extent;
1902
1903 Cellsize = Entry("CELLSIZE")->Get_Content().asDouble();
1904 Extent.xMin = Entry("XMIN" )->Get_Content().asDouble();
1905 Extent.xMax = Entry("XMAX" )->Get_Content().asDouble();
1906 Extent.yMin = Entry("YMIN" )->Get_Content().asDouble();
1907 Extent.yMax = Entry("YMAX" )->Get_Content().asDouble();
1908
1909 m_System.Assign(Cellsize, CSG_Rect(Extent));
1910 }
1911
1912 return( true );
1913 }
1914
1915
1916 ///////////////////////////////////////////////////////////
1917 // //
1918 // Table Field //
1919 // //
1920 ///////////////////////////////////////////////////////////
1921
1922 //---------------------------------------------------------
CSG_Parameter_Table_Field(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)1923 CSG_Parameter_Table_Field::CSG_Parameter_Table_Field(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
1924 : CSG_Parameter_Int(pOwner, pParent, ID, Name, Description, Constraint)
1925 {
1926 m_Default = -1;
1927 m_Value = -1;
1928 }
1929
1930 //---------------------------------------------------------
Add_Default(double Value,double Minimum,bool bMinimum,double Maximum,bool bMaximum)1931 bool CSG_Parameter_Table_Field::Add_Default(double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
1932 {
1933 if( m_Default < 0 && is_Optional() )
1934 {
1935 m_Default = Get_Children_Count();
1936
1937 Get_Parameters()->Add_Double(Get_Identifier(), CSG_String::Format("%s_DEFAULT", Get_Identifier()),
1938 _TL("Default"), _TL("default value if no attribute has been selected"),
1939 Value, Minimum, bMinimum, Maximum, bMaximum
1940 );
1941 }
1942
1943 return( m_Default >= 0 );
1944 }
1945
1946 //---------------------------------------------------------
Get_Table(void) const1947 CSG_Table * CSG_Parameter_Table_Field::Get_Table(void) const
1948 {
1949 CSG_Table *pTable = Get_Parent() ? Get_Parent()->asTable() : NULL;
1950
1951 return( pTable && pTable != DATAOBJECT_CREATE && pTable->Get_Field_Count() > 0 ? pTable : NULL );
1952 }
1953
1954 //---------------------------------------------------------
_Set_Value(int Value)1955 int CSG_Parameter_Table_Field::_Set_Value(int Value)
1956 {
1957 CSG_Table *pTable = Get_Table();
1958
1959 if( pTable != NULL && pTable->Get_Field_Count() > 0 && Value >= 0 )
1960 {
1961 if( Value >= pTable->Get_Field_Count() )
1962 {
1963 Value = !is_Optional() ? pTable->Get_Field_Count() - 1 : -1;
1964 }
1965 }
1966 else
1967 {
1968 Value = -1;
1969 }
1970
1971 if( Get_Child(m_Default) )
1972 {
1973 Get_Child(m_Default)->Set_Enabled(Value < 0);
1974 }
1975
1976 if( m_Value != Value )
1977 {
1978 m_Value = Value;
1979
1980 return( SG_PARAMETER_DATA_SET_CHANGED );
1981 }
1982
1983 return( SG_PARAMETER_DATA_SET_TRUE );
1984 }
1985
1986 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)1987 int CSG_Parameter_Table_Field::_Set_Value(const CSG_String &Value)
1988 {
1989 CSG_Table *pTable = Get_Table();
1990
1991 if( pTable != NULL )
1992 {
1993 int Index;
1994
1995 for(Index=0; Index<pTable->Get_Field_Count(); Index++)
1996 {
1997 if( !Value.CmpNoCase(pTable->Get_Field_Name(Index)) )
1998 {
1999 return( _Set_Value(Index) );
2000 }
2001 }
2002
2003 if( Value.asInt(Index) )
2004 {
2005 return( _Set_Value(Index) );
2006 }
2007 }
2008
2009 return( _Set_Value(-1) );
2010 }
2011
2012 //---------------------------------------------------------
_Set_String(void)2013 void CSG_Parameter_Table_Field::_Set_String(void)
2014 {
2015 CSG_Table *pTable = Get_Table();
2016
2017 if( !pTable || pTable->Get_Field_Count() < 1 )
2018 {
2019 m_String = _TL("<no attributes>");
2020 }
2021 else if( m_Value < 0 || m_Value >= pTable->Get_Field_Count() )
2022 {
2023 m_String = _TL("<not set>");
2024 }
2025 else
2026 {
2027 m_String = pTable->Get_Field_Name(m_Value);
2028 }
2029 }
2030
2031 //---------------------------------------------------------
_asDouble(void) const2032 double CSG_Parameter_Table_Field::_asDouble(void) const
2033 {
2034 return( Get_Child(m_Default) ? Get_Child(m_Default)->asDouble() : CSG_Parameter_Int::asDouble() );
2035 }
2036
2037 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2038 bool CSG_Parameter_Table_Field::_Assign(CSG_Parameter *pSource)
2039 {
2040 m_Value = ((CSG_Parameter_Table_Field *)pSource)->m_Value;
2041 m_Default = ((CSG_Parameter_Table_Field *)pSource)->m_Default;
2042
2043 _Set_String();
2044
2045 return( true );
2046 }
2047
2048 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)2049 bool CSG_Parameter_Table_Field::_Serialize(CSG_MetaData &Entry, bool bSave)
2050 {
2051 if( bSave )
2052 {
2053 Entry.Set_Property("index", asInt());
2054 Entry.Set_Content(asString());
2055
2056 return( true );
2057 }
2058 else
2059 {
2060 int Index;
2061
2062 if( Entry.Get_Property("index", Index) ) // we require this check for backward compatibility, "index" was first introduced with SAGA 2.2.3 (r2671)
2063 {
2064 return( _Set_Value(Index) != 0 );
2065 }
2066
2067 return( _Set_Value(Entry.Get_Content()) != 0 );
2068 }
2069 }
2070
2071
2072 ///////////////////////////////////////////////////////////
2073 // //
2074 // Table Fields //
2075 // //
2076 ///////////////////////////////////////////////////////////
2077
2078 //---------------------------------------------------------
CSG_Parameter_Table_Fields(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2079 CSG_Parameter_Table_Fields::CSG_Parameter_Table_Fields(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2080 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
2081 {
2082 m_nFields = 0;
2083 m_Fields = NULL;
2084 }
2085
2086 //---------------------------------------------------------
~CSG_Parameter_Table_Fields(void)2087 CSG_Parameter_Table_Fields::~CSG_Parameter_Table_Fields(void)
2088 {
2089 SG_FREE_SAFE(m_Fields);
2090 }
2091
2092 //---------------------------------------------------------
_Set_Value(const CSG_String & Value)2093 int CSG_Parameter_Table_Fields::_Set_Value(const CSG_String &Value)
2094 {
2095 CSG_Table *pTable = Get_Table();
2096
2097 if( !pTable || pTable->Get_Field_Count() <= 0 )
2098 {
2099 SG_FREE_SAFE(m_Fields);
2100 m_nFields = 0;
2101 m_String = _TL("<no attributes>");
2102
2103 return( SG_PARAMETER_DATA_SET_CHANGED );
2104 }
2105
2106 m_Fields = (int *)SG_Realloc(m_Fields, pTable->Get_Field_Count() * sizeof(int));
2107
2108 memset(m_Fields, 0, pTable->Get_Field_Count() * sizeof(int));
2109
2110 //-----------------------------------------------------
2111 int iField;
2112
2113 CSG_String List(Value); List.Replace(";", ",");
2114
2115 while( List.Length() > 0 )
2116 {
2117 CSG_String sValue = List.BeforeFirst(',');
2118
2119 if( sValue.asInt(iField) && iField >= 0 && iField < pTable->Get_Field_Count() )
2120 {
2121 m_Fields[iField] = 1;
2122 }
2123 else if( sValue.Length() > 0 )
2124 {
2125 sValue.Trim();
2126
2127 if( sValue[0] == '[' )
2128 {
2129 sValue = sValue.AfterFirst('[').BeforeLast(']');
2130 }
2131
2132 for(iField=0; iField<pTable->Get_Field_Count(); iField++)
2133 {
2134 if( sValue.CmpNoCase(pTable->Get_Field_Name(iField)) == 0 )
2135 {
2136 m_Fields[iField] = 1;
2137
2138 break;
2139 }
2140 }
2141 }
2142
2143 List = List.AfterFirst(',');
2144 }
2145
2146 //-----------------------------------------------------
2147 m_String.Clear();
2148
2149 for(iField=0, m_nFields=0; iField<pTable->Get_Field_Count(); iField++)
2150 {
2151 if( m_Fields[iField] != 0 )
2152 {
2153 m_Fields[m_nFields++] = iField;
2154
2155 m_String += CSG_String::Format(m_String.is_Empty() ? "%d" : ",%d", iField);
2156 }
2157 }
2158
2159 if( m_nFields <= 0 )
2160 {
2161 m_String = _TL("<no attributes>");
2162 }
2163
2164 return( SG_PARAMETER_DATA_SET_CHANGED );
2165 }
2166
2167 //---------------------------------------------------------
_asInt(void) const2168 int CSG_Parameter_Table_Fields::_asInt(void) const
2169 {
2170 return( m_nFields );
2171 }
2172
2173 //---------------------------------------------------------
_asPointer(void) const2174 void * CSG_Parameter_Table_Fields::_asPointer(void) const
2175 {
2176 return( m_Fields );
2177 }
2178
2179 //---------------------------------------------------------
Get_Table(void) const2180 CSG_Table * CSG_Parameter_Table_Fields::Get_Table(void) const
2181 {
2182 CSG_Table *pTable = Get_Parent() ? Get_Parent()->asTable() : NULL;
2183
2184 return( pTable && pTable != DATAOBJECT_CREATE && pTable->Get_Field_Count() > 0 ? pTable : NULL );
2185 }
2186
2187 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2188 bool CSG_Parameter_Table_Fields::_Assign(CSG_Parameter *pSource)
2189 {
2190 return( _Set_Value(pSource->asString()) != 0 );
2191 }
2192
2193 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)2194 bool CSG_Parameter_Table_Fields::_Serialize(CSG_MetaData &Entry, bool bSave)
2195 {
2196 if( bSave )
2197 {
2198 Entry.Set_Content(m_String);
2199 }
2200 else
2201 {
2202 m_String = Entry.Get_Content();
2203 }
2204
2205 return( true );
2206 }
2207
2208
2209 ///////////////////////////////////////////////////////////
2210 // //
2211 // DataObject //
2212 // //
2213 ///////////////////////////////////////////////////////////
2214
2215 //---------------------------------------------------------
CSG_Parameter_Data_Object(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2216 CSG_Parameter_Data_Object::CSG_Parameter_Data_Object(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2217 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
2218 {
2219 m_pDataObject = NULL;
2220 }
2221
2222 //---------------------------------------------------------
is_Valid(void) const2223 bool CSG_Parameter_Data_Object::is_Valid(void) const
2224 {
2225 return( is_Optional() || (m_pDataObject && m_pDataObject->is_Valid()) );
2226 }
2227
2228 //---------------------------------------------------------
_Set_Value(void * Value)2229 int CSG_Parameter_Data_Object::_Set_Value(void *Value)
2230 {
2231 if( m_pDataObject != Value )
2232 {
2233 m_pDataObject = (CSG_Data_Object *)Value;
2234
2235 return( SG_PARAMETER_DATA_SET_CHANGED );
2236 }
2237
2238 return( SG_PARAMETER_DATA_SET_TRUE );
2239 }
2240
2241 //---------------------------------------------------------
_Set_String(void)2242 void CSG_Parameter_Data_Object::_Set_String(void)
2243 {
2244 if( m_pDataObject == DATAOBJECT_NOTSET )
2245 {
2246 m_String = is_Output() && !is_Optional() ? _TL("<create>") : _TL("<not set>");
2247 }
2248 else if( m_pDataObject == DATAOBJECT_CREATE )
2249 {
2250 m_String = _TL("<create>");
2251 }
2252 else
2253 {
2254 m_String = m_pDataObject->Get_Name();
2255 }
2256 }
2257
2258 //---------------------------------------------------------
_asPointer(void) const2259 void * CSG_Parameter_Data_Object::_asPointer(void) const
2260 {
2261 return( m_pDataObject );
2262 }
2263
2264 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2265 bool CSG_Parameter_Data_Object::_Assign(CSG_Parameter *pSource)
2266 {
2267 m_pDataObject = ((CSG_Parameter_Data_Object *)pSource)->m_pDataObject;
2268
2269 return( true );
2270 }
2271
2272 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)2273 bool CSG_Parameter_Data_Object::_Serialize(CSG_MetaData &Entry, bool bSave)
2274 {
2275 if( bSave )
2276 {
2277 if( m_pDataObject == DATAOBJECT_CREATE )
2278 {
2279 Entry.Set_Content("CREATE");
2280
2281 return( true );
2282 }
2283
2284 if( m_pDataObject == DATAOBJECT_NOTSET )//|| !SG_File_Exists(m_pDataObject->Get_File_Name(false)) )
2285 {
2286 Entry.Set_Content("NOT SET");
2287
2288 return( true );
2289 }
2290
2291 if( !m_pDataObject->Get_Owner() )
2292 {
2293 Entry.Set_Content(m_pDataObject->Get_File_Name(false));
2294
2295 return( true );
2296 }
2297
2298 if( m_pDataObject->Get_Owner()->Get_ObjectType() == SG_DATAOBJECT_TYPE_Grids )
2299 {
2300 CSG_Grids *pGrids = m_pDataObject->Get_Owner()->asGrids();
2301
2302 for(int i=0; i<pGrids->Get_NZ(); i++)
2303 {
2304 if( pGrids->Get_Grid_Ptr(i) == m_pDataObject )
2305 {
2306 Entry.Set_Content(m_pDataObject->Get_Owner()->Get_File_Name(false));
2307
2308 Entry.Add_Property("index", i);
2309
2310 return( true );
2311 }
2312 }
2313 }
2314 }
2315 else
2316 {
2317 CSG_Data_Object *pDataObject = NULL; int Index = -1;
2318
2319 if( Entry.Cmp_Content("CREATE") )
2320 {
2321 _Set_Value(DATAOBJECT_CREATE);
2322
2323 return( true );
2324 }
2325
2326 if( Entry.Cmp_Content("NOT SET") || !Get_Manager() || !(pDataObject = Get_Manager()->Find(Entry.Get_Content(), false)) )
2327 {
2328 _Set_Value(DATAOBJECT_NOTSET);
2329
2330 return( true );
2331 }
2332
2333 if( !Entry.Get_Property("index", Index) )
2334 {
2335 _Set_Value(pDataObject);
2336
2337 return( true );
2338 }
2339
2340 if( pDataObject->Get_ObjectType() == SG_DATAOBJECT_TYPE_Grids )
2341 {
2342 _Set_Value(pDataObject->asGrids()->Get_Grid_Ptr(Index));
2343
2344 return( true );
2345 }
2346 }
2347
2348 return( false );
2349 }
2350
2351
2352 ///////////////////////////////////////////////////////////
2353 // //
2354 // DataObject_Output //
2355 // //
2356 ///////////////////////////////////////////////////////////
2357
2358 //---------------------------------------------------------
CSG_Parameter_Data_Object_Output(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2359 CSG_Parameter_Data_Object_Output::CSG_Parameter_Data_Object_Output(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2360 : CSG_Parameter_Data_Object(pOwner, pParent, ID, Name, Description, Constraint)
2361 {
2362 m_Type = SG_DATAOBJECT_TYPE_Undefined;
2363 }
2364
2365 //---------------------------------------------------------
_Set_Value(void * Value)2366 int CSG_Parameter_Data_Object_Output::_Set_Value(void *Value)
2367 {
2368 CSG_Data_Object *pDataObject = (CSG_Data_Object *)Value;
2369
2370 if( pDataObject == DATAOBJECT_CREATE )
2371 {
2372 pDataObject = NULL;
2373 }
2374
2375 if( m_pDataObject != pDataObject && (pDataObject == NULL || pDataObject->Get_ObjectType() == m_Type) )
2376 {
2377 m_pDataObject = pDataObject;
2378
2379 if( Get_Manager() )
2380 {
2381 Get_Manager()->Add(m_pDataObject);
2382
2383 if( Get_Manager() == &SG_Get_Data_Manager() ) // prevent that local data manager send their data objects to gui
2384 {
2385 SG_UI_DataObject_Add(m_pDataObject, false);
2386 }
2387 }
2388 }
2389
2390 return( SG_PARAMETER_DATA_SET_CHANGED );
2391 }
2392
2393 //---------------------------------------------------------
Set_DataObject_Type(TSG_Data_Object_Type Type)2394 bool CSG_Parameter_Data_Object_Output::Set_DataObject_Type(TSG_Data_Object_Type Type)
2395 {
2396 if( m_Type == SG_DATAOBJECT_TYPE_Undefined ) // m_Type should not be changed after set once!!!...
2397 {
2398 switch( Type )
2399 {
2400 case SG_DATAOBJECT_TYPE_Grid :
2401 case SG_DATAOBJECT_TYPE_Grids :
2402 case SG_DATAOBJECT_TYPE_Table :
2403 case SG_DATAOBJECT_TYPE_Shapes :
2404 case SG_DATAOBJECT_TYPE_TIN :
2405 case SG_DATAOBJECT_TYPE_PointCloud:
2406 m_Type = Type;
2407
2408 return( true );
2409
2410 default:
2411 return( false );
2412 }
2413 }
2414
2415 return( false );
2416 }
2417
2418
2419 ///////////////////////////////////////////////////////////
2420 // //
2421 // Grid //
2422 // //
2423 ///////////////////////////////////////////////////////////
2424
2425 //---------------------------------------------------------
CSG_Parameter_Grid(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2426 CSG_Parameter_Grid::CSG_Parameter_Grid(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2427 : CSG_Parameter_Data_Object(pOwner, pParent, ID, Name, Description, Constraint)
2428 {
2429 m_Type = SG_DATATYPE_Undefined;
2430
2431 m_Default = -1;
2432 }
2433
2434 //---------------------------------------------------------
Set_Preferred_Type(TSG_Data_Type Type)2435 void CSG_Parameter_Grid::Set_Preferred_Type(TSG_Data_Type Type)
2436 {
2437 m_Type = Type;
2438 }
2439
2440 //---------------------------------------------------------
Get_System(void) const2441 CSG_Grid_System * CSG_Parameter_Grid::Get_System(void) const
2442 {
2443 if( Get_Parent() && Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System )
2444 {
2445 return( Get_Parent()->asGrid_System() );
2446 }
2447
2448 return( NULL );
2449 }
2450
2451 //---------------------------------------------------------
Add_Default(double Value,double Minimum,bool bMinimum,double Maximum,bool bMaximum)2452 bool CSG_Parameter_Grid::Add_Default(double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
2453 {
2454 if( m_Default < 0 && is_Input() && is_Optional() )
2455 {
2456 m_Default = Get_Children_Count();
2457
2458 Get_Parameters()->Add_Double(Get_Identifier(), CSG_String::Format("%s_DEFAULT", Get_Identifier()),
2459 _TL("Default"), _TL("default value if no grid has been selected"),
2460 Value, Minimum, bMinimum, Maximum, bMaximum
2461 );
2462 }
2463
2464 return( m_Default >= 0 );
2465 }
2466
2467 //---------------------------------------------------------
_Set_Value(void * Value)2468 int CSG_Parameter_Grid::_Set_Value(void *Value)
2469 {
2470 if( Value == m_pDataObject ) // nothing to do
2471 {
2472 return( SG_PARAMETER_DATA_SET_TRUE );
2473 }
2474
2475 //-----------------------------------------------------
2476 if( Value != DATAOBJECT_NOTSET && Value != DATAOBJECT_CREATE && Get_System() )// && Get_Manager()
2477 {
2478 CSG_Grid_System System = Get_Type() == PARAMETER_TYPE_Grid
2479 ? ((CSG_Grid *)Value)->Get_System()
2480 : ((CSG_Grids *)Value)->Get_System();
2481
2482 if( !Get_System()->is_Equal(System) )
2483 {
2484 for(int i=0; i<Get_Parent()->Get_Children_Count(); i++)
2485 {
2486 CSG_Parameter *pChild = Get_Parent()->Get_Child(i);
2487
2488 if( pChild->Get_Type() == PARAMETER_TYPE_Grid
2489 || pChild->Get_Type() == PARAMETER_TYPE_Grids )
2490 {
2491 if( pChild->asDataObject() != DATAOBJECT_NOTSET
2492 && pChild->asDataObject() != DATAOBJECT_CREATE
2493 && pChild->asDataObject() != m_pDataObject )
2494 {
2495 return( false );
2496 }
2497 }
2498
2499 if( pChild->is_DataObject_List() && pChild->asList()->Get_Item_Count() > 0 )
2500 {
2501 if( (pChild->Get_Type() == PARAMETER_TYPE_Grid_List && pChild->asGridList ()->Get_System())
2502 || (pChild->Get_Type() == PARAMETER_TYPE_Grids_List && pChild->asGridsList()->Get_System()) )
2503 {
2504 return( false );
2505 }
2506 }
2507 }
2508
2509 Get_Parent()->Set_Value((void *)&System);
2510 }
2511 }
2512
2513 //-----------------------------------------------------
2514 m_pDataObject = (CSG_Data_Object *)Value;
2515
2516 if( Get_Child(m_Default) )
2517 {
2518 Get_Child(m_Default)->Set_Enabled(m_pDataObject == DATAOBJECT_NOTSET);
2519 }
2520
2521 return( SG_PARAMETER_DATA_SET_CHANGED );
2522 }
2523
2524 //---------------------------------------------------------
_asInt(void) const2525 int CSG_Parameter_Grid::_asInt(void) const
2526 {
2527 return( Get_Child(m_Default) ? Get_Child(m_Default)->asInt() : CSG_Parameter_Data_Object::asInt() );
2528 }
2529
2530 //---------------------------------------------------------
_asDouble(void) const2531 double CSG_Parameter_Grid::_asDouble(void) const
2532 {
2533 return( Get_Child(m_Default) ? Get_Child(m_Default)->asDouble() : CSG_Parameter_Data_Object::asDouble() );
2534 }
2535
2536 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2537 bool CSG_Parameter_Grid::_Assign(CSG_Parameter *pSource)
2538 {
2539 m_Type = ((CSG_Parameter_Grid *)pSource)->m_Type;
2540 m_Default = ((CSG_Parameter_Grid *)pSource)->m_Default;
2541
2542 return( _Set_Value(pSource->asPointer()) != 0 );
2543 }
2544
2545
2546 ///////////////////////////////////////////////////////////
2547 // //
2548 // Grids //
2549 // //
2550 ///////////////////////////////////////////////////////////
2551
2552 //---------------------------------------------------------
CSG_Parameter_Grids(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2553 CSG_Parameter_Grids::CSG_Parameter_Grids(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2554 : CSG_Parameter_Grid(pOwner, pParent, ID, Name, Description, Constraint)
2555 {
2556 // nop
2557 }
2558
2559
2560 ///////////////////////////////////////////////////////////
2561 // //
2562 // Table //
2563 // //
2564 ///////////////////////////////////////////////////////////
2565
2566 //---------------------------------------------------------
CSG_Parameter_Table(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2567 CSG_Parameter_Table::CSG_Parameter_Table(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2568 : CSG_Parameter_Data_Object(pOwner, pParent, ID, Name, Description, Constraint)
2569 {
2570 // nop
2571 }
2572
2573 //---------------------------------------------------------
_Set_Value(void * Value)2574 int CSG_Parameter_Table::_Set_Value(void *Value)
2575 {
2576 if( m_pDataObject == Value )
2577 {
2578 return( SG_PARAMETER_DATA_SET_TRUE );
2579 }
2580
2581 m_pDataObject = (CSG_Data_Object *)Value;
2582
2583 for(int i=0; i<Get_Children_Count(); i++)
2584 {
2585 CSG_Parameter *pChild = Get_Child(i);
2586
2587 if( pChild->Get_Type() == PARAMETER_TYPE_Table_Field )
2588 {
2589 pChild->Set_Value(m_pDataObject && pChild->is_Optional() ? ((CSG_Table *)m_pDataObject)->Get_Field_Count() : 0);
2590 }
2591 else if( pChild->Get_Type() == PARAMETER_TYPE_Table_Fields )
2592 {
2593 pChild->Set_Value(CSG_String(""));
2594 }
2595 }
2596
2597 return( SG_PARAMETER_DATA_SET_CHANGED );
2598 }
2599
2600
2601 ///////////////////////////////////////////////////////////
2602 // //
2603 // Shapes //
2604 // //
2605 ///////////////////////////////////////////////////////////
2606
2607 //---------------------------------------------------------
CSG_Parameter_Shapes(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2608 CSG_Parameter_Shapes::CSG_Parameter_Shapes(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2609 : CSG_Parameter_Data_Object(pOwner, pParent, ID, Name, Description, Constraint)
2610 {
2611 m_Type = SHAPE_TYPE_Undefined;
2612 }
2613
2614 //---------------------------------------------------------
_Set_Value(void * Value)2615 int CSG_Parameter_Shapes::_Set_Value(void *Value)
2616 {
2617 if( Value != DATAOBJECT_NOTSET && Value != DATAOBJECT_CREATE
2618 && m_Type != SHAPE_TYPE_Undefined && m_Type != ((CSG_Shapes *)Value)->Get_Type() )
2619 {
2620 return( SG_PARAMETER_DATA_SET_FALSE );
2621 }
2622
2623 if( m_pDataObject == Value )
2624 {
2625 return( SG_PARAMETER_DATA_SET_TRUE );
2626 }
2627
2628 m_pDataObject = (CSG_Data_Object *)Value;
2629
2630 for(int i=0; i<Get_Children_Count(); i++)
2631 {
2632 CSG_Parameter *pChild = Get_Child(i);
2633
2634 if( pChild->Get_Type() == PARAMETER_TYPE_Table_Field )
2635 {
2636 pChild->Set_Value(m_pDataObject && m_pDataObject != DATAOBJECT_CREATE && pChild->is_Optional() ? ((CSG_Table *)m_pDataObject)->Get_Field_Count() : 0);
2637 }
2638 else if( pChild->Get_Type() == PARAMETER_TYPE_Table_Fields )
2639 {
2640 pChild->Set_Value("");
2641 }
2642 }
2643
2644 return( SG_PARAMETER_DATA_SET_CHANGED );
2645 }
2646
2647 //---------------------------------------------------------
Set_Shape_Type(TSG_Shape_Type Type)2648 void CSG_Parameter_Shapes::Set_Shape_Type(TSG_Shape_Type Type)
2649 {
2650 m_Type = Type;
2651 }
2652
2653 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2654 bool CSG_Parameter_Shapes::_Assign(CSG_Parameter *pSource)
2655 {
2656 m_Type = ((CSG_Parameter_Shapes *)pSource)->m_Type;
2657
2658 return( CSG_Parameter_Data_Object::_Assign(pSource) );
2659 }
2660
2661
2662 ///////////////////////////////////////////////////////////
2663 // //
2664 // TIN //
2665 // //
2666 ///////////////////////////////////////////////////////////
2667
2668 //---------------------------------------------------------
CSG_Parameter_TIN(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2669 CSG_Parameter_TIN::CSG_Parameter_TIN(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2670 : CSG_Parameter_Data_Object(pOwner, pParent, ID, Name, Description, Constraint)
2671 {
2672 // nop
2673 }
2674
2675 //---------------------------------------------------------
_Set_Value(void * Value)2676 int CSG_Parameter_TIN::_Set_Value(void *Value)
2677 {
2678 if( m_pDataObject == Value )
2679 {
2680 return( SG_PARAMETER_DATA_SET_TRUE );
2681 }
2682
2683 m_pDataObject = (CSG_Data_Object *)Value;
2684
2685 for(int i=0; i<Get_Children_Count(); i++)
2686 {
2687 CSG_Parameter *pChild = Get_Child(i);
2688
2689 if( pChild->Get_Type() == PARAMETER_TYPE_Table_Field )
2690 {
2691 pChild->Set_Value(m_pDataObject && pChild->is_Optional() ? ((CSG_Table *)m_pDataObject)->Get_Field_Count() : 0);
2692 }
2693 else if( pChild->Get_Type() == PARAMETER_TYPE_Table_Fields )
2694 {
2695 pChild->Set_Value("");
2696 }
2697 }
2698
2699 return( SG_PARAMETER_DATA_SET_CHANGED );
2700 }
2701
2702
2703 ///////////////////////////////////////////////////////////
2704 // //
2705 // PointCloud //
2706 // //
2707 ///////////////////////////////////////////////////////////
2708
2709 //---------------------------------------------------------
CSG_Parameter_PointCloud(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2710 CSG_Parameter_PointCloud::CSG_Parameter_PointCloud(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2711 : CSG_Parameter_Data_Object(pOwner, pParent, ID, Name, Description, Constraint)
2712 {
2713 // nop
2714 }
2715
2716 //---------------------------------------------------------
_Set_Value(void * Value)2717 int CSG_Parameter_PointCloud::_Set_Value(void *Value)
2718 {
2719 if( m_pDataObject == Value )
2720 {
2721 return( SG_PARAMETER_DATA_SET_TRUE );
2722 }
2723
2724 m_pDataObject = (CSG_Data_Object *)Value;
2725
2726 for(int i=0; i<Get_Children_Count(); i++)
2727 {
2728 CSG_Parameter *pChild = Get_Child(i);
2729
2730 if( pChild->Get_Type() == PARAMETER_TYPE_Table_Field )
2731 {
2732 pChild->Set_Value(m_pDataObject && pChild->is_Optional() ? ((CSG_Table *)m_pDataObject)->Get_Field_Count() : 0);
2733 }
2734 else if( pChild->Get_Type() == PARAMETER_TYPE_Table_Fields )
2735 {
2736 pChild->Set_Value("");
2737 }
2738 }
2739
2740 return( SG_PARAMETER_DATA_SET_CHANGED );
2741 }
2742
2743 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2744 bool CSG_Parameter_PointCloud::_Assign(CSG_Parameter *pSource)
2745 {
2746 return( CSG_Parameter_Data_Object::_Assign(pSource) );
2747 }
2748
2749
2750 ///////////////////////////////////////////////////////////
2751 // //
2752 // List //
2753 // //
2754 ///////////////////////////////////////////////////////////
2755
2756 //---------------------------------------------------------
CSG_Parameter_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2757 CSG_Parameter_List::CSG_Parameter_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2758 : CSG_Parameter(pOwner, pParent, ID, Name, Description, Constraint)
2759 {
2760 // nop
2761 }
2762
2763 //---------------------------------------------------------
Add_Item(CSG_Data_Object * pObject)2764 bool CSG_Parameter_List::Add_Item(CSG_Data_Object *pObject)
2765 {
2766 if( pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE && m_Objects.Add(pObject) )
2767 {
2768 _Set_String();
2769
2770 return( true );
2771 }
2772
2773 return( false );
2774 }
2775
Del_Item(CSG_Data_Object * pObject,bool bUpdateData)2776 bool CSG_Parameter_List::Del_Item(CSG_Data_Object *pObject, bool bUpdateData)
2777 {
2778 if( m_Objects.Del(pObject) > 0 )
2779 {
2780 if( bUpdateData )
2781 {
2782 _Set_String();
2783 }
2784
2785 return( true );
2786 }
2787
2788 return( false );
2789 }
2790
Del_Item(int Index,bool bUpdateData)2791 bool CSG_Parameter_List::Del_Item(int Index, bool bUpdateData)
2792 {
2793 if( m_Objects.Del(Index) )
2794 {
2795 if( bUpdateData )
2796 {
2797 _Set_String();
2798 }
2799
2800 return( true );
2801 }
2802
2803 return( false );
2804 }
2805
Del_Items(void)2806 bool CSG_Parameter_List::Del_Items(void)
2807 {
2808 if( m_Objects.Set_Array(0) )
2809 {
2810 _Set_String();
2811
2812 return( true );
2813 }
2814
2815 return( false );
2816 }
2817
2818 //---------------------------------------------------------
_Set_String(void)2819 void CSG_Parameter_List::_Set_String(void)
2820 {
2821 if( Get_Item_Count() > 0 )
2822 {
2823 m_String.Printf("%d %s (", Get_Item_Count(), Get_Item_Count() == 1 ? _TL("object") : _TL("objects"));
2824
2825 for(int i=0; i<Get_Item_Count(); i++)
2826 {
2827 if( i > 0 )
2828 {
2829 m_String += ", ";
2830 }
2831
2832 m_String += Get_Item(i)->Get_Name();
2833 }
2834
2835 m_String += ")";
2836 }
2837 else
2838 {
2839 m_String = _TL("No objects");
2840 }
2841 }
2842
2843 //---------------------------------------------------------
_asInt(void) const2844 int CSG_Parameter_List::_asInt(void) const
2845 {
2846 return( Get_Item_Count() );
2847 }
2848
2849 //---------------------------------------------------------
_asPointer(void) const2850 void * CSG_Parameter_List::_asPointer(void) const
2851 {
2852 return( m_Objects.Get_Array() );
2853 }
2854
2855 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)2856 bool CSG_Parameter_List::_Assign(CSG_Parameter *pSource)
2857 {
2858 Del_Items();
2859
2860 for(int i=0; i<((CSG_Parameter_List *)pSource)->Get_Item_Count(); i++)
2861 {
2862 if( Get_Manager() != &SG_Get_Data_Manager() || SG_Get_Data_Manager().Exists(((CSG_Parameter_List *)pSource)->Get_Item(i)) )
2863 {
2864 Add_Item(((CSG_Parameter_List *)pSource)->Get_Item(i));
2865 }
2866 }
2867
2868 return( true );
2869 }
2870
2871 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)2872 bool CSG_Parameter_List::_Serialize(CSG_MetaData &Entry, bool bSave)
2873 {
2874 if( bSave )
2875 {
2876 for(int i=0; i<Get_Item_Count(); i++)
2877 {
2878 CSG_String File = Get_Item(i)->Get_File_Name(false);
2879
2880 if( File.BeforeFirst(':').Cmp("PGSQL") || SG_File_Exists(File) )
2881 {
2882 Entry.Add_Child("DATA", File);
2883 }
2884 }
2885 }
2886 else
2887 {
2888 Del_Items();
2889
2890 for(int i=0; i<Entry.Get_Children_Count(); i++)
2891 {
2892 CSG_Data_Object *pObject = Get_Manager() ? Get_Manager()->Find(Entry.Get_Content(i), false) : NULL;
2893
2894 if( pObject )
2895 {
2896 Add_Item(pObject);
2897 }
2898 }
2899 }
2900
2901 return( true );
2902 }
2903
2904
2905 ///////////////////////////////////////////////////////////
2906 // //
2907 // Grid_List //
2908 // //
2909 ///////////////////////////////////////////////////////////
2910
2911 //---------------------------------------------------------
CSG_Parameter_Grid_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)2912 CSG_Parameter_Grid_List::CSG_Parameter_Grid_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
2913 : CSG_Parameter_List(pOwner, pParent, ID, Name, Description, Constraint)
2914 {
2915 // nop
2916 }
2917
2918 //---------------------------------------------------------
Get_System(void) const2919 CSG_Grid_System * CSG_Parameter_Grid_List::Get_System(void) const
2920 {
2921 if( Get_Parent() && Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System )
2922 {
2923 return( Get_Parent()->asGrid_System() );
2924 }
2925
2926 return( NULL );
2927 }
2928
2929 //---------------------------------------------------------
Add_Item(CSG_Data_Object * pObject)2930 bool CSG_Parameter_Grid_List::Add_Item(CSG_Data_Object *pObject)
2931 {
2932 if( pObject == DATAOBJECT_NOTSET || pObject == DATAOBJECT_CREATE
2933 || (pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_Grid
2934 && pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_Grids) )
2935 {
2936 return( false );
2937 }
2938
2939 //-----------------------------------------------------
2940 CSG_Grid_System *pSystem = Get_System();
2941
2942 if( pSystem ) // check grid system compatibility
2943 {
2944 CSG_Grid_System System = pObject->Get_ObjectType() == SG_DATAOBJECT_TYPE_Grid
2945 ? ((CSG_Grid *)pObject)->Get_System()
2946 : ((CSG_Grids *)pObject)->Get_System();
2947
2948 if( !pSystem->is_Valid() )
2949 {
2950 Get_Parent()->Set_Value((void *)&System);
2951 }
2952 else if( !pSystem->is_Equal(System) )
2953 {
2954 for(int i=0; i<Get_Parent()->Get_Children_Count(); i++)
2955 {
2956 CSG_Parameter *pChild = Get_Parent()->Get_Child(i);
2957
2958 if( pChild->Get_Type() == PARAMETER_TYPE_Grid
2959 || pChild->Get_Type() == PARAMETER_TYPE_Grids )
2960 {
2961 if( pChild->asDataObject() != DATAOBJECT_NOTSET
2962 && pChild->asDataObject() != DATAOBJECT_CREATE )
2963 {
2964 return( false );
2965 }
2966 }
2967
2968 if( pChild->is_DataObject_List() && pChild->asList()->Get_Item_Count() > 0 )
2969 {
2970 if( (pChild->Get_Type() == PARAMETER_TYPE_Grid_List && pChild->asGridList ()->Get_System())
2971 || (pChild->Get_Type() == PARAMETER_TYPE_Grids_List && pChild->asGridsList()->Get_System()) )
2972 {
2973 return( false );
2974 }
2975 }
2976 }
2977
2978 Get_Parent()->Set_Value((void *)&System);
2979 }
2980 }
2981
2982 return( CSG_Parameter_List::Add_Item(pObject) && Update_Data() );
2983 }
2984
2985 //---------------------------------------------------------
Del_Item(CSG_Data_Object * pItem,bool bUpdateData)2986 bool CSG_Parameter_Grid_List::Del_Item(CSG_Data_Object *pItem, bool bUpdateData)
2987 {
2988 return( CSG_Parameter_List::Del_Item(pItem, bUpdateData) );
2989 }
2990
2991 //---------------------------------------------------------
Del_Item(int Index,bool bUpdateData)2992 bool CSG_Parameter_Grid_List::Del_Item(int Index, bool bUpdateData)
2993 {
2994 return( CSG_Parameter_List::Del_Item(Index, bUpdateData) );
2995 }
2996
2997 //---------------------------------------------------------
Del_Items(void)2998 bool CSG_Parameter_Grid_List::Del_Items(void)
2999 {
3000 return( CSG_Parameter_List::Del_Items() && Update_Data() );
3001 }
3002
3003 //---------------------------------------------------------
Update_Data(void)3004 bool CSG_Parameter_Grid_List::Update_Data(void)
3005 {
3006 m_Grids.Set_Array(0);
3007
3008 for(int i=0; i<Get_Item_Count(); i++)
3009 {
3010 switch( Get_Item(i)->Get_ObjectType() )
3011 {
3012 case SG_DATAOBJECT_TYPE_Grid: {
3013 m_Grids.Add(Get_Item(i));
3014 break; }
3015
3016 case SG_DATAOBJECT_TYPE_Grids: {
3017 CSG_Grids *pGrids = (CSG_Grids *)Get_Item(i);
3018
3019 for(int j=0; j<pGrids->Get_Grid_Count(); j++)
3020 {
3021 m_Grids.Add(pGrids->Get_Grid_Ptr(j));
3022 }
3023 break; }
3024
3025 default: {
3026 break; }
3027 }
3028
3029 }
3030
3031 return( true );
3032 }
3033
3034
3035 ///////////////////////////////////////////////////////////
3036 // //
3037 // Grids_List //
3038 // //
3039 ///////////////////////////////////////////////////////////
3040
3041 //---------------------------------------------------------
CSG_Parameter_Grids_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)3042 CSG_Parameter_Grids_List::CSG_Parameter_Grids_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
3043 : CSG_Parameter_List(pOwner, pParent, ID, Name, Description, Constraint)
3044 {
3045 // nop
3046 }
3047
3048 //---------------------------------------------------------
Get_System(void) const3049 CSG_Grid_System * CSG_Parameter_Grids_List::Get_System(void) const
3050 {
3051 if( Get_Parent() && Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System )
3052 {
3053 return( Get_Parent()->asGrid_System() );
3054 }
3055
3056 return( NULL );
3057 }
3058
3059 //---------------------------------------------------------
Add_Item(CSG_Data_Object * pObject)3060 bool CSG_Parameter_Grids_List::Add_Item(CSG_Data_Object *pObject)
3061 {
3062 if( pObject == NULL || pObject->Get_ObjectType() != SG_DATAOBJECT_TYPE_Grids )
3063 {
3064 return( false );
3065 }
3066
3067 //-----------------------------------------------------
3068 CSG_Grid_System *pSystem = Get_System();
3069
3070 if( pSystem ) // check grid system compatibility
3071 {
3072 CSG_Grid_System System = Get_Type() == PARAMETER_TYPE_Grid_List
3073 ? ((CSG_Grid *)pObject)->Get_System()
3074 : ((CSG_Grids *)pObject)->Get_System();
3075
3076 if( !pSystem->is_Valid() )
3077 {
3078 Get_Parent()->Set_Value((void *)&System);
3079 }
3080 else if( !pSystem->is_Equal(System) )
3081 {
3082 for(int i=0; i<Get_Parent()->Get_Children_Count(); i++)
3083 {
3084 CSG_Parameter *pChild = Get_Parent()->Get_Child(i);
3085
3086 if( pChild->Get_Type() == PARAMETER_TYPE_Grids )
3087 {
3088 if( pChild->asDataObject() != DATAOBJECT_NOTSET
3089 && pChild->asDataObject() != DATAOBJECT_CREATE )
3090 {
3091 return( false );
3092 }
3093 }
3094
3095 if( pChild->is_DataObject_List() && pChild->asList()->Get_Item_Count() > 0 )
3096 {
3097 if( (pChild->Get_Type() == PARAMETER_TYPE_Grids_List && pChild->asGridsList()->Get_System()) )
3098 {
3099 return( false );
3100 }
3101 }
3102 }
3103
3104 Get_Parent()->Set_Value((void *)&System);
3105 }
3106 }
3107
3108 return( CSG_Parameter_List::Add_Item(pObject) );
3109 }
3110
3111
3112 ///////////////////////////////////////////////////////////
3113 // //
3114 // Table_List //
3115 // //
3116 ///////////////////////////////////////////////////////////
3117
3118
3119 //---------------------------------------------------------
CSG_Parameter_Table_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)3120 CSG_Parameter_Table_List::CSG_Parameter_Table_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
3121 : CSG_Parameter_List(pOwner, pParent, ID, Name, Description, Constraint)
3122 {
3123 // nop
3124 }
3125
3126
3127 ///////////////////////////////////////////////////////////
3128 // //
3129 // Shapes_List //
3130 // //
3131 ///////////////////////////////////////////////////////////
3132
3133
3134 //---------------------------------------------------------
CSG_Parameter_Shapes_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)3135 CSG_Parameter_Shapes_List::CSG_Parameter_Shapes_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
3136 : CSG_Parameter_List(pOwner, pParent, ID, Name, Description, Constraint)
3137 {
3138 m_Type = SHAPE_TYPE_Undefined;
3139 }
3140
3141 //---------------------------------------------------------
Set_Shape_Type(TSG_Shape_Type Type)3142 void CSG_Parameter_Shapes_List::Set_Shape_Type(TSG_Shape_Type Type)
3143 {
3144 m_Type = Type;
3145 }
3146
3147 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)3148 bool CSG_Parameter_Shapes_List::_Assign(CSG_Parameter *pSource)
3149 {
3150 m_Type = ((CSG_Parameter_Shapes_List *)pSource)->m_Type;
3151
3152 return( CSG_Parameter_List::_Assign(pSource) );
3153 }
3154
3155
3156 ///////////////////////////////////////////////////////////
3157 // //
3158 // TIN_List //
3159 // //
3160 ///////////////////////////////////////////////////////////
3161
3162
3163 //---------------------------------------------------------
CSG_Parameter_TIN_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)3164 CSG_Parameter_TIN_List::CSG_Parameter_TIN_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
3165 : CSG_Parameter_List(pOwner, pParent, ID, Name, Description, Constraint)
3166 {
3167 // nop
3168 }
3169
3170
3171 ///////////////////////////////////////////////////////////
3172 // //
3173 // PointCloud_List //
3174 // //
3175 ///////////////////////////////////////////////////////////
3176
3177
3178 //---------------------------------------------------------
CSG_Parameter_PointCloud_List(CSG_Parameters * pOwner,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)3179 CSG_Parameter_PointCloud_List::CSG_Parameter_PointCloud_List(CSG_Parameters *pOwner, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
3180 : CSG_Parameter_List(pOwner, pParent, ID, Name, Description, Constraint)
3181 {
3182 // nop
3183 }
3184
3185
3186 ///////////////////////////////////////////////////////////
3187 // //
3188 // Parameters //
3189 // //
3190 ///////////////////////////////////////////////////////////
3191
3192 //---------------------------------------------------------
CSG_Parameter_Parameters(CSG_Parameters * pParameters,CSG_Parameter * pParent,const CSG_String & ID,const CSG_String & Name,const CSG_String & Description,int Constraint)3193 CSG_Parameter_Parameters::CSG_Parameter_Parameters(CSG_Parameters *pParameters, CSG_Parameter *pParent, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint)
3194 : CSG_Parameter(pParameters, pParent, ID, Name, Description, Constraint)
3195 {
3196 m_pParameters = new CSG_Parameters(pParameters->Get_Owner(), Name, Description, ID);
3197 }
3198
~CSG_Parameter_Parameters(void)3199 CSG_Parameter_Parameters::~CSG_Parameter_Parameters(void)
3200 {
3201 delete(m_pParameters);
3202 }
3203
3204 //---------------------------------------------------------
Restore_Default(void)3205 bool CSG_Parameter_Parameters::Restore_Default(void)
3206 {
3207 return( m_pParameters->Restore_Defaults() );
3208 }
3209
3210 //---------------------------------------------------------
_Set_String(void)3211 void CSG_Parameter_Parameters::_Set_String(void)
3212 {
3213 m_String.Printf("%d %s", m_pParameters->Get_Count(), _TL("parameters"));
3214 }
3215
3216 //---------------------------------------------------------
_asPointer(void) const3217 void * CSG_Parameter_Parameters::_asPointer(void) const
3218 {
3219 return( m_pParameters );
3220 }
3221
3222 //---------------------------------------------------------
_Assign(CSG_Parameter * pSource)3223 bool CSG_Parameter_Parameters::_Assign(CSG_Parameter *pSource)
3224 {
3225 m_pParameters->Assign(pSource->asParameters());
3226
3227 return( true );
3228 }
3229
3230 //---------------------------------------------------------
_Serialize(CSG_MetaData & Entry,bool bSave)3231 bool CSG_Parameter_Parameters::_Serialize(CSG_MetaData &Entry, bool bSave)
3232 {
3233 if( m_pParameters->Serialize(Entry, bSave) )
3234 {
3235 if( bSave )
3236 {
3237 Entry.Set_Property("id" , Get_Identifier ());
3238 Entry.Set_Property("type", Get_Type_Identifier());
3239 }
3240
3241 return( true );
3242 }
3243
3244 return( false );
3245 }
3246
3247
3248 ///////////////////////////////////////////////////////////
3249 // //
3250 // //
3251 // //
3252 ///////////////////////////////////////////////////////////
3253
3254 //---------------------------------------------------------
3255