SAGA API Version 9.14
Loading...
Searching...
No Matches
data_manager.cpp
Go to the documentation of this file.
1
3// //
4// SAGA //
5// //
6// System for Automated Geoscientific Analyses //
7// //
8// Application Programming Interface //
9// //
10// Library: SAGA_API //
11// //
12//-------------------------------------------------------//
13// //
14// data_manager.cpp //
15// //
16// Copyright (C) 2013 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 Hamburg //
44// Germany //
45// //
46// e-mail: oconrad@saga-gis.org //
47// //
49
50//---------------------------------------------------------
51#include "data_manager.h"
52#include "tool_library.h"
53
54
56// //
57// //
58// //
60
61//---------------------------------------------------------
63
64//---------------------------------------------------------
69
70
72// //
73// //
74// //
76
77//---------------------------------------------------------
78CSG_Data_Collection::CSG_Data_Collection(TSG_Data_Object_Type Type)
79{
80 m_Type = Type;
81}
82
83//---------------------------------------------------------
84CSG_Data_Collection::~CSG_Data_Collection(void)
85{
86 Delete();
87}
88
89//---------------------------------------------------------
90CSG_Data_Object * CSG_Data_Collection::Find(const CSG_String &File, bool bNative) const
91{
92 for(size_t i=0; i<Count(); i++)
93 {
94 if( !File.Cmp(Get(i)->Get_File_Name(bNative)) )
95 {
96 return( Get(i) );
97 }
98 }
99
100 return( NULL );
101}
102
103//---------------------------------------------------------
105{
106 for(size_t i=0; i<Count(); i++)
107 {
108 if( pObject == Get(i) )
109 {
110 return( true );
111 }
112 }
113
114 return( false );
115}
116
117//---------------------------------------------------------
118bool CSG_Data_Collection::Add(CSG_Data_Object *pObject)
119{
120 if( pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE )
121 {
122 if( Exists(pObject) )
123 {
124 return( true );
125 }
126
127 if( m_Objects.Inc_Array() )
128 {
129 m_Objects[Count() - 1] = pObject;
130
131 if( m_Type != SG_DATAOBJECT_TYPE_Undefined )
132 {
133 pObject->m_Managed++;
134 }
135
136 return( true );
137 }
138 }
139
140 return( false );
141}
142
143//---------------------------------------------------------
145{
146 for(size_t i=0; i<Count(); i++)
147 {
148 if( pObject == Get(i) )
149 {
150 return( Delete(i, bDetach) );
151 }
152 }
153
154 return( false );
155}
156
157//---------------------------------------------------------
158bool CSG_Data_Collection::Delete(size_t i, bool bDetach)
159{
160 if( i < Count() )
161 {
162 CSG_Data_Object *pObject = Get(i);
163
164 if( m_Type != SG_DATAOBJECT_TYPE_Undefined )
165 {
166 if( pObject->m_Managed > 0 )
167 {
168 pObject->m_Managed--;
169 }
170
171 if( !bDetach && !pObject->m_Managed )
172 {
173 delete(pObject);
174 }
175 }
176
177 CSG_Data_Object **pObjects = (CSG_Data_Object **)m_Objects.Get_Array();
178
179 for(size_t j=i+1; j<Count(); i++, j++)
180 {
181 pObjects[i] = pObjects[j];
182 }
183
184 m_Objects.Dec_Array();
185
186 return( true );
187 }
188
189 return( false );
190}
191
192//---------------------------------------------------------
193bool CSG_Data_Collection::Delete(bool bDetach, bool bUnsaved)
194{
195 for(size_t i=Count(); i>0; i--)
196 {
197 if( !bUnsaved || !SG_File_Exists(Get(i - 1)->Get_File_Name()) )
198 {
199 Delete(i - 1, bDetach);
200 }
201 }
202
203 return( Count() == 0 );
204}
205
206
208// //
209// //
210// //
212
213//---------------------------------------------------------
215{
222
223 m_Grid_Systems.m_pGrid = m_pGrid ;
224 m_Grid_Systems.m_pGrids = m_pGrids;
225}
226
227//---------------------------------------------------------
229{
230 Delete();
231
232 delete(m_pTable );
233 delete(m_pShapes );
234 delete(m_pPointCloud);
235 delete(m_pTIN );
236 delete(m_pGrid );
237 delete(m_pGrids );
238}
239
240
242// //
244
245//---------------------------------------------------------
246CSG_Data_Collection * CSG_Data_Manager::_Get_Collection(CSG_Data_Object *pObject) const
247{
248 if( pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE )
249 {
250 switch( pObject->Get_ObjectType() )
251 {
252 case SG_DATAOBJECT_TYPE_Table : return( m_pTable );
253 case SG_DATAOBJECT_TYPE_Shapes : return( m_pShapes );
254 case SG_DATAOBJECT_TYPE_PointCloud: return( m_pPointCloud );
255 case SG_DATAOBJECT_TYPE_TIN : return( m_pTIN );
256 case SG_DATAOBJECT_TYPE_Grid : return( m_pGrid );
257 case SG_DATAOBJECT_TYPE_Grids : return( m_pGrids );
258
259 default: break;
260 }
261 }
262
263 return( NULL );
264}
265
266
268// //
270
271//---------------------------------------------------------
272CSG_Data_Object * CSG_Data_Manager::Find(const CSG_String &File, bool bNative) const
273{
274 CSG_Data_Object *pObject;
275
276 if( (pObject = Table ().Find(File, bNative)) != NULL ) return( pObject );
277 if( (pObject = Shapes ().Find(File, bNative)) != NULL ) return( pObject );
278 if( (pObject = PointCloud().Find(File, bNative)) != NULL ) return( pObject );
279 if( (pObject = TIN ().Find(File, bNative)) != NULL ) return( pObject );
280 if( (pObject = Grid ().Find(File, bNative)) != NULL ) return( pObject );
281 if( (pObject = Grids ().Find(File, bNative)) != NULL ) return( pObject );
282
283 return( NULL );
284}
285
286//---------------------------------------------------------
288{
289 if( pObject && pObject != DATAOBJECT_CREATE )
290 {
291 if( Table ().Exists(pObject) ) return( true );
292 if( Shapes ().Exists(pObject) ) return( true );
293 if( PointCloud().Exists(pObject) ) return( true );
294 if( TIN ().Exists(pObject) ) return( true );
295 if( Grid ().Exists(pObject) ) return( true );
296 if( Grids ().Exists(pObject) ) return( true );
297
298 for(size_t i=0; i<Grids().Count(); i++)
299 {
300 for(int j=0; j<Grids(i).Get_Grid_Count(); j++)
301 {
302 if( pObject == Grids(i).Get_Grid_Ptr(j) )
303 {
304 return( true );
305 }
306 }
307 }
308 }
309
310 return( false );
311}
312
313
315// //
317
318//---------------------------------------------------------
320{
321 if( pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE )
322 {
323 if( Exists(pObject) )
324 {
325 return( pObject ); // don't add more than once
326 }
327
328 CSG_Data_Collection *pCollection = _Get_Collection(pObject);
329
330 if( pCollection && pCollection->Add(pObject) )
331 {
332 if( this == &g_Data_Manager ) // SAGA API's global data manager ?
333 {
334 SG_UI_DataObject_Add(pObject, SG_UI_DATAOBJECT_UPDATE); // for SAGA GUI !
335 }
336
337 return( pObject );
338 }
339 }
340
341 return( NULL );
342}
343
344//---------------------------------------------------------
345CSG_Data_Object * CSG_Data_Manager::Add(const char *File, TSG_Data_Object_Type Type) { return( Add(CSG_String(File), Type) ); }
346CSG_Data_Object * CSG_Data_Manager::Add(const wchar_t *File, TSG_Data_Object_Type Type) { return( Add(CSG_String(File), Type) ); }
348{
349 if( Type == SG_DATAOBJECT_TYPE_Undefined )
350 {
351 if( SG_File_Cmp_Extension(File, "txt" )
352 || SG_File_Cmp_Extension(File, "csv" )
353 || SG_File_Cmp_Extension(File, "dbf" ) )
354 {
356 }
357
358 if( SG_File_Cmp_Extension(File, "shp" ) )
359 {
361 }
362
363 if( SG_File_Cmp_Extension(File, "sg-pts-z")
364 || SG_File_Cmp_Extension(File, "sg-pts" )
365 || SG_File_Cmp_Extension(File, "spc" ) )
366 {
368 }
369
370 if( SG_File_Cmp_Extension(File, "sg-grd-z")
371 || SG_File_Cmp_Extension(File, "sg-grd" )
372 || SG_File_Cmp_Extension(File, "sgrd" )
373 || SG_File_Cmp_Extension(File, "dgm" )
374 || SG_File_Cmp_Extension(File, "grd" ) )
375 {
377 }
378
379 if( SG_File_Cmp_Extension(File, "sg-gds-z")
380 || SG_File_Cmp_Extension(File, "sg-gds" ) )
381 {
383 }
384 }
385
386 //-----------------------------------------------------
387 CSG_Data_Object *pObject;
388
389 switch( Type )
390 {
391 case SG_DATAOBJECT_TYPE_Table : pObject = new CSG_Table (File); break;
392 case SG_DATAOBJECT_TYPE_Shapes : pObject = new CSG_Shapes (File); break;
393 case SG_DATAOBJECT_TYPE_TIN : pObject = new CSG_TIN (File); break;
394 case SG_DATAOBJECT_TYPE_PointCloud: pObject = new CSG_PointCloud(File); break;
395 case SG_DATAOBJECT_TYPE_Grid : pObject = new CSG_Grid (File); break;
396 case SG_DATAOBJECT_TYPE_Grids : pObject = new CSG_Grids (File); break;
397 default : pObject = NULL ; break;
398 }
399
400 if( pObject )
401 {
402 if( pObject->is_Valid() && Add(pObject) )
403 {
404 return( pObject );
405 }
406
407 delete(pObject);
408 }
409
410 //-----------------------------------------------------
411 return( _Add_External(File) );
412}
413
414//---------------------------------------------------------
415CSG_Data_Object * CSG_Data_Manager::_Add_External(const CSG_String &File)
416{
417 CSG_Data_Object *pData = NULL;
418
419 if( !SG_File_Exists(File) )
420 {
421 return( pData );
422 }
423
424 CSG_Tool *pImport = NULL;
425
426 SG_UI_Msg_Lock(true);
427
428 //-----------------------------------------------------
429 // Image Import
430
431 if( ( SG_File_Cmp_Extension(File, "bmp")
432 || SG_File_Cmp_Extension(File, "gif")
433 || SG_File_Cmp_Extension(File, "pcx")
434 || SG_File_Cmp_Extension(File, "xpm") )
435 && (pImport = SG_Get_Tool_Library_Manager().Create_Tool("io_grid_image", 1)) != NULL
436 && pImport->Set_Parameter("FILE", File, PARAMETER_TYPE_FilePath)
437 && pImport->Set_Parameter("METHOD", 0) ) // => Automatic
438 {
439 pImport->Set_Manager(this);
440
441 if( pImport->Execute() )
442 {
443 pData = pImport->Get_Parameter("OUT_GRID" )->asDataObject();
444 }
445 }
446
448
449 //-----------------------------------------------------
450 // Image Import (True Color)
451
452 if( !pData
453 && ( SG_File_Cmp_Extension(File, "jpg")
454 || SG_File_Cmp_Extension(File, "png") )
455 && (pImport = SG_Get_Tool_Library_Manager().Create_Tool("io_grid_image", 1)) != NULL
456 && pImport->Set_Parameter("FILE", File, PARAMETER_TYPE_FilePath)
457 && pImport->Set_Parameter("METHOD", 3) ) // => RGB Composite
458 {
459 pImport->Set_Manager(this);
460
461 if( pImport->Execute() )
462 {
463 pData = pImport->Get_Parameter("OUT_GRIDS")->asDataObject();
464 }
465 }
466
468
469 //-----------------------------------------------------
470 // GDAL Import
471
472 if( !pData
473 && (pImport = SG_Get_Tool_Library_Manager().Create_Tool("io_gdal", 0)) != NULL
474 && pImport->Set_Parameter("FILES", File, PARAMETER_TYPE_FilePath) )
475 {
476 pImport->Set_Manager(this);
477
478 if( pImport->Execute() )
479 {
480 pData = pImport->Get_Parameter("GRIDS")->asList()->Get_Item(0);
481 }
482 }
483
485
486 //-----------------------------------------------------
487 // OGR Import
488
489 if( !pData
490 && (pImport = SG_Get_Tool_Library_Manager().Create_Tool("io_gdal", 3)) != NULL
491 && pImport->Set_Parameter("FILES", File, PARAMETER_TYPE_FilePath) )
492 {
493 pImport->Set_Manager(this);
494
495 if( pImport->Execute() )
496 {
497 pData = pImport->Get_Parameter("SHAPES")->asList()->Get_Item(0);
498 }
499 }
500
502
503 //-----------------------------------------------------
504 // LAZ Import
505
506 if( !pData && (SG_File_Cmp_Extension(File, "las") || SG_File_Cmp_Extension(File, "laz"))
507 && (pImport = SG_Get_Tool_Library_Manager().Create_Tool("io_pdal", 0)) != NULL
508 && pImport->Set_Parameter("FILES", File, PARAMETER_TYPE_FilePath) )
509 {
510 pImport->Set_Manager(this);
511
512 if( pImport->Execute() )
513 {
514 pData = pImport->Get_Parameter("POINTS")->asList()->Get_Item(0);
515 }
516 }
517
519
520 //-----------------------------------------------------
521 // STL Import
522
523 if( !pData && (SG_File_Cmp_Extension(File, "stl"))
524 && (pImport = SG_Get_Tool_Library_Manager().Create_Tool("io_shapes", 11)) != NULL // Import Stereo Lithography File (STL)
525 && pImport->Set_Parameter("FILE" , File, PARAMETER_TYPE_FilePath)
526 && pImport->Set_Parameter("METHOD", 2) ) // => TIN
527 {
528 CSG_Data_Manager Data; pImport->Set_Manager(&Data);
529
530 if( pImport->Execute() )
531 {
532 Data.Delete(pData = pImport->Get_Parameter("TIN")->asTIN(), true); Add(pData);
533 }
534 }
535
537
538 //-----------------------------------------------------
539 SG_UI_Msg_Lock(false);
540
541 return( pData );
542}
543
544
546// //
548
549//---------------------------------------------------------
552CSG_Table * CSG_Data_Manager::Add_Table(const wchar_t *File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table) ); }
554{
555 CSG_Table *pObject = new CSG_Table();
556
557 if( pObject && !Add(pObject) )
558 {
559 delete(pObject); pObject = NULL;
560 }
561
562 return( pObject );
563}
564
565//---------------------------------------------------------
570{
571 CSG_Shapes *pObject = new CSG_Shapes();
572
573 if( pObject && !Add(pObject) )
574 {
575 delete(pObject); pObject = NULL;
576 }
577
578 return( pObject );
579}
580
581//---------------------------------------------------------
586{
587 CSG_PointCloud *pObject = new CSG_PointCloud();
588
589 if( pObject && !Add(pObject) )
590 {
591 delete(pObject); pObject = NULL;
592 }
593
594 return( pObject );
595}
596
597//---------------------------------------------------------
599CSG_TIN * CSG_Data_Manager::Add_TIN(const char *File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN) ); }
600CSG_TIN * CSG_Data_Manager::Add_TIN(const wchar_t *File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN) ); }
602{
603 CSG_TIN *pObject = new CSG_TIN();
604
605 if( pObject && !Add(pObject) )
606 {
607 delete(pObject); pObject = NULL;
608 }
609
610 return( pObject );
611}
612
613//---------------------------------------------------------
615CSG_Grid * CSG_Data_Manager::Add_Grid(const char *File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid) ); }
616CSG_Grid * CSG_Data_Manager::Add_Grid(const wchar_t *File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid) ); }
618{
619 CSG_Grid *pObject = new CSG_Grid();
620
621 if( pObject && !Add(pObject) )
622 {
623 delete(pObject); pObject = NULL;
624 }
625
626 return( pObject );
627}
628
629//---------------------------------------------------------
632CSG_Grids * CSG_Data_Manager::Add_Grids(const wchar_t *File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids) ); }
634{
635 CSG_Grids *pObject = new CSG_Grids();
636
637 if( pObject && !Add(pObject) )
638 {
639 delete(pObject); pObject = NULL;
640 }
641
642 return( pObject );
643}
644
645
647// //
649
650//---------------------------------------------------------
651bool CSG_Data_Manager::Delete(CSG_Data_Object *pObject, bool bDetach)
652{
653 CSG_Data_Collection *pCollection = _Get_Collection(pObject);
654
655 return( pCollection && pCollection->Delete(pObject, bDetach) );
656}
657
658//---------------------------------------------------------
659bool CSG_Data_Manager::Delete(bool bDetach, bool bUnsaved)
660{
661 Table ().Delete(bDetach, bUnsaved);
662 Shapes ().Delete(bDetach, bUnsaved);
663 PointCloud().Delete(bDetach, bUnsaved);
664 TIN ().Delete(bDetach, bUnsaved);
665 Grid ().Delete(bDetach, bUnsaved);
666 Grids ().Delete(bDetach, bUnsaved);
667
668 return( true );
669}
670
671
673// //
675
676//---------------------------------------------------------
678{
679 CSG_String s;
680
681 //-----------------------------------------------------
682 if( Table().Count() )
683 {
684 s += CSG_String::Format("___\n%s [%zu %s]\n", _TL("Table"), Table().Count(), _TL("objects"));
685
686 for(size_t i=0; i<Table().Count(); i++)
687 {
688 CSG_Table *pObject = Table()[i].asTable();
689
690 s += CSG_String::Format("- [%d %s] %s\n",
691 pObject->Get_Count(), _TL("records"),
692 pObject->Get_Name()
693 );
694 }
695 }
696
697 //-----------------------------------------------------
698 if( Shapes().Count() )
699 {
700 s += CSG_String::Format("___\n%s [%zu %s]\n", _TL("Shapes"), Shapes().Count(), _TL("objects"));
701
702 for(size_t i=0; i<Shapes().Count(); i++)
703 {
704 CSG_Shapes *pObject = Shapes()[i].asShapes();
705
706 s += CSG_String::Format("- [%s; %d %s] %s\n",
707 pObject->Get_Type() == SHAPE_TYPE_Point ? _TL("point" ) :
708 pObject->Get_Type() == SHAPE_TYPE_Points ? _TL("points" ) :
709 pObject->Get_Type() == SHAPE_TYPE_Line ? _TL("line" ) :
710 pObject->Get_Type() == SHAPE_TYPE_Polygon ? _TL("polygon") : _TL("unknown"),
711 pObject->Get_Count(), _TL("records"),
712 pObject->Get_Name()
713 );
714 }
715 }
716
717 //-----------------------------------------------------
718 if( PointCloud().Count() )
719 {
720 s += CSG_String::Format("___\n%s [%zu %s]\n", _TL("Point Cloud"), PointCloud().Count(), _TL("objects"));
721
722 for(size_t i=0; i<PointCloud().Count(); i++)
723 {
724 CSG_PointCloud *pObject = PointCloud()[i].asPointCloud();
725
726 s += CSG_String::Format("- [%d %s] %s\n",
727 pObject->Get_Count(), _TL("records"),
728 pObject->Get_Name()
729 );
730 }
731 }
732
733 //-----------------------------------------------------
734 if( TIN().Count() )
735 {
736 s += CSG_String::Format("___\n%s [%zu %s]\n", _TL("TIN"), TIN().Count(), _TL("objects"));
737
738 for(size_t i=0; i<TIN().Count(); i++)
739 {
740 CSG_TIN *pObject = TIN()[i].asTIN();
741
742 s += CSG_String::Format("- [%d %s] %s\n",
743 pObject->Get_Count(), _TL("nodes"),
744 pObject->Get_Name()
745 );
746 }
747 }
748
749 //-----------------------------------------------------
750 if( Grid().Count() )
751 {
752 s += CSG_String::Format("___\n%s [%zu %s]\n", _TL("Grid"), Grid().Count(), _TL("objects"));
753
754 for(size_t i=0; i<Grid().Count(); i++)
755 {
756 CSG_Grid *pObject = Grid()[i].asGrid ();
757
758 s += CSG_String::Format("- [%f | %dnx %dny | %fx %fy] %s\n",
759 pObject->Get_Cellsize(), pObject->Get_NX(), pObject->Get_NY(), pObject->Get_XMin(), pObject->Get_YMin(),
760 pObject->Get_Name()
761 );
762 }
763 }
764
765 //-----------------------------------------------------
766 if( Grids().Count() )
767 {
768 s += CSG_String::Format("___\n%s [%zu %s]\n", _TL("Grid Collection"), Grids().Count(), _TL("objects"));
769
770 for(size_t i=0; i<Grids().Count(); i++)
771 {
772 CSG_Grids *pObject = Grids()[i].asGrids();
773
774 s += CSG_String::Format("- [%f | %dnx %dny %dnz | %fx %fy] %s\n",
775 pObject->Get_Cellsize(), pObject->Get_NX(), pObject->Get_NY(), pObject->Get_NZ(), pObject->Get_XMin(), pObject->Get_YMin(),
776 pObject->Get_Name()
777 );
778 }
779 }
780
781 //-----------------------------------------------------
782 if( s.is_Empty() )
783 {
784 s += CSG_String::Format("%s - %s\n--- %s ---\n", _TL("Data Manager"), _TL("Summary"), _TL("no data"));
785 }
786 else
787 {
788 s.Prepend(CSG_String::Format("%s - %s\n", _TL("Data Manager"), _TL("Summary")));
789 }
790
791 //-----------------------------------------------------
792 return( s );
793}
794
795
797// //
799
800//---------------------------------------------------------
801CSG_Data_Manager::CSG_Grid_Systems::CSG_Grid_Systems(void)
802{}
803
804//---------------------------------------------------------
805CSG_Data_Manager::CSG_Grid_Systems::~CSG_Grid_Systems(void)
806{
807 Destroy();
808}
809
810//---------------------------------------------------------
812{
813 for(size_t i=0; i<Count(); i++)
814 {
815 delete((CSG_Data_Collection *)m_Systems[i]);
816 }
817
818 m_Systems.Destroy();
819
820 return( true );
821}
822
823//---------------------------------------------------------
825{
826 if( i < Count() && Get_Grids(i).Count() )
827 {
828 if( Get_Grids(i).Get(0)->asGrid () ) { return( Get_Grids(i).Get(0)->asGrid ()->Get_System() ); }
829 if( Get_Grids(i).Get(0)->asGrids() ) { return( Get_Grids(i).Get(0)->asGrids()->Get_System() ); }
830 }
831
832 static CSG_Grid_System System;
833
834 return( System );
835}
836
837//---------------------------------------------------------
839{
840 for(size_t i=0; i<Count(); i++)
841 {
842 if( System == Get_System(i) )
843 {
844 return( (CSG_Data_Collection *)m_Systems[i] );
845 }
846 }
847
848 return( NULL );
849}
850
851//---------------------------------------------------------
852bool CSG_Data_Manager::CSG_Grid_Systems::_Add(CSG_Data_Object *pObject)
853{
854 if( pObject )
855 {
856 CSG_Grid_System System;
857
858 if( pObject->asGrid () ) { System = pObject->asGrid ()->Get_System(); } else
859 if( pObject->asGrids() ) { System = pObject->asGrids()->Get_System(); } else { return( false ); }
860
861 if( System.is_Valid() )
862 {
863 for(size_t i=0; i<Count(); i++)
864 {
865 if( System == Get_System(i) )
866 {
867 return( (*(CSG_Data_Collection *)m_Systems[i]).Add(pObject) );
868 }
869 }
870
871 if( m_Systems.Add(new CSG_Data_Collection(SG_DATAOBJECT_TYPE_Undefined)) )
872 {
873 return( (*(CSG_Data_Collection *)m_Systems[Count() - 1]).Add(pObject) );
874 }
875 }
876 }
877
878 return( false );
879}
880
881//---------------------------------------------------------
883{
884 Destroy();
885
886 if( m_pGrid ) { for(size_t i=0; i<m_pGrid ->Count(); i++) { _Add(m_pGrid ->Get(i)); } }
887 if( m_pGrids ) { for(size_t i=0; i<m_pGrids->Count(); i++) { _Add(m_pGrids->Get(i)); } }
888
889 return( true );
890}
891
892
894// //
895// //
896// //
898
899//---------------------------------------------------------
bool SG_UI_DataObject_Add(CSG_Data_Object *pDataObject, int Show)
int SG_UI_Msg_Lock(bool bOn)
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &File, const CSG_String &Extension)
@ SG_UI_DATAOBJECT_UPDATE
Definition api_core.h:1648
#define _TL(s)
Definition api_core.h:1619
size_t Count(void) const
CSG_Data_Object * Get(size_t i) const
bool Exists(CSG_Data_Object *pObject) const
bool Delete(CSG_Data_Object *pObject, bool bDetach=false)
CSG_Data_Object * Find(const CSG_String &File, bool bNative=true) const
const CSG_Data_Collection & Get_Grids(size_t i) const
const CSG_Grid_System & Get_System(size_t i) const
virtual ~CSG_Data_Manager(void)
CSG_PointCloud * Add_PointCloud(void)
CSG_Data_Collection & Grid(void) const
CSG_Table * Add_Table(void)
CSG_Grid * Add_Grid(void)
CSG_Data_Collection & Grids(void) const
CSG_Data_Collection & PointCloud(void) const
CSG_Data_Collection & TIN(void) const
CSG_Data_Object * Add(CSG_Data_Object *pObject)
CSG_Shapes * Add_Shapes(void)
bool Delete(CSG_Data_Object *pObject, bool bDetach=false)
CSG_TIN * Add_TIN(void)
CSG_Data_Collection & Table(void) const
CSG_Grids * Add_Grids(void)
CSG_Data_Collection & Shapes(void) const
CSG_Data_Object * Find(const CSG_String &File, bool bNative=true) const
bool Exists(CSG_Data_Object *pObject) const
CSG_String Get_Summary(void) const
const SG_Char * Get_Name(void) const
virtual bool is_Valid(void) const =0
class CSG_Grids * asGrids(bool bPolymorph=false) const
virtual TSG_Data_Object_Type Get_ObjectType(void) const =0
Returns the object type as defined by TSG_Data_Object_Type. Used for run time type checking.
class CSG_Grid * asGrid(bool bPolymorph=false) const
bool is_Valid(void) const
int Get_NY(void) const
Definition grid.h:564
double Get_YMin(bool bCells=false) const
Definition grid.h:576
double Get_XMin(bool bCells=false) const
Definition grid.h:572
double Get_Cellsize(void) const
Definition grid.h:567
const CSG_Grid_System & Get_System(void) const
Definition grid.h:559
int Get_NX(void) const
Definition grid.h:563
const CSG_Grid_System & Get_System(void) const
Definition grids.h:184
int Get_NZ(void) const
Definition grids.h:190
double Get_Cellsize(void) const
Definition grids.h:195
double Get_XMin(bool bCells=false) const
Definition grids.h:200
double Get_YMin(bool bCells=false) const
Definition grids.h:204
int Get_NX(void) const
Definition grids.h:188
int Get_NY(void) const
Definition grids.h:189
CSG_Data_Object * Get_Item(int Index) const
CSG_TIN * asTIN(void) const
class CSG_Parameter_List * asList(void) const
CSG_Data_Object * asDataObject(void) const
virtual TSG_Shape_Type Get_Type(void) const
Definition shapes.h:814
int Cmp(const CSG_String &String) const
static CSG_String Format(const char *Format,...)
bool is_Empty(void) const
CSG_String & Prepend(const CSG_String &String)
Definition tin.h:222
sLong Get_Count(void) const
Definition table.h:410
bool Delete_Tool(CSG_Tool *pTool) const
bool Set_Manager(class CSG_Data_Manager *pManager)
Definition tool.cpp:874
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
Definition tool.cpp:1659
CSG_Parameter * Get_Parameter(const CSG_String &ID) const
Definition tool.cpp:1642
bool Execute(bool bAddHistory=false)
Definition tool.cpp:560
CSG_Data_Manager & SG_Get_Data_Manager(void)
static CSG_Data_Manager g_Data_Manager
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_Undefined
Definition dataobject.h:124
@ SG_DATAOBJECT_TYPE_PointCloud
Definition dataobject.h:123
@ SG_DATAOBJECT_TYPE_Grids
Definition dataobject.h:119
@ SG_DATAOBJECT_TYPE_TIN
Definition dataobject.h:122
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
@ SG_DATAOBJECT_TYPE_Grid
Definition dataobject.h:118
@ SG_DATAOBJECT_TYPE_Table
Definition dataobject.h:120
#define DATAOBJECT_NOTSET
Definition dataobject.h:129
#define DATAOBJECT_CREATE
Definition dataobject.h:130
@ PARAMETER_TYPE_FilePath
Definition parameters.h:137
@ SHAPE_TYPE_Polygon
Definition shapes.h:105
@ SHAPE_TYPE_Line
Definition shapes.h:104
@ SHAPE_TYPE_Points
Definition shapes.h:103
@ SHAPE_TYPE_Point
Definition shapes.h:102
CSG_Tool_Library_Manager & SG_Get_Tool_Library_Manager(void)