1 /**********************************************************
2  * Version $Id$
3  *********************************************************/
4 
5 ///////////////////////////////////////////////////////////
6 //                                                       //
7 //                         SAGA                          //
8 //                                                       //
9 //      System for Automated Geoscientific Analyses      //
10 //                                                       //
11 //                    User Interface                     //
12 //                                                       //
13 //                    Program: SAGA                      //
14 //                                                       //
15 //-------------------------------------------------------//
16 //                                                       //
17 //                 WKSP_Grid_System.cpp                  //
18 //                                                       //
19 //          Copyright (C) 2005 by Olaf Conrad            //
20 //                                                       //
21 //-------------------------------------------------------//
22 //                                                       //
23 // This file is part of 'SAGA - System for Automated     //
24 // Geoscientific Analyses'. SAGA is free software; you   //
25 // can redistribute it and/or modify it under the terms  //
26 // of the GNU General Public License as published by the //
27 // Free Software Foundation, either version 2 of the     //
28 // License, or (at your option) any later version.       //
29 //                                                       //
30 // SAGA is distributed in the hope that it will be       //
31 // useful, but WITHOUT ANY WARRANTY; without even the    //
32 // implied warranty of MERCHANTABILITY or FITNESS FOR A  //
33 // PARTICULAR PURPOSE. See the GNU General Public        //
34 // License for more details.                             //
35 //                                                       //
36 // You should have received a copy of the GNU General    //
37 // Public License along with this program; if not, see   //
38 // <http://www.gnu.org/licenses/>.                       //
39 //                                                       //
40 //-------------------------------------------------------//
41 //                                                       //
42 //    contact:    Olaf Conrad                            //
43 //                Institute of Geography                 //
44 //                University of Goettingen               //
45 //                Goldschmidtstr. 5                      //
46 //                37077 Goettingen                       //
47 //                Germany                                //
48 //                                                       //
49 //    e-mail:     oconrad@saga-gis.org                   //
50 //                                                       //
51 ///////////////////////////////////////////////////////////
52 
53 //---------------------------------------------------------
54 
55 
56 ///////////////////////////////////////////////////////////
57 //														 //
58 //														 //
59 //														 //
60 ///////////////////////////////////////////////////////////
61 
62 //---------------------------------------------------------
63 #include "res_commands.h"
64 
65 #include "helper.h"
66 
67 #include "wksp_grid_system.h"
68 #include "wksp_grid.h"
69 #include "wksp_grids.h"
70 
71 
72 ///////////////////////////////////////////////////////////
73 //														 //
74 //														 //
75 //														 //
76 ///////////////////////////////////////////////////////////
77 
78 //---------------------------------------------------------
CWKSP_Grid_System(const CSG_Grid_System & System)79 CWKSP_Grid_System::CWKSP_Grid_System(const CSG_Grid_System &System)
80 {
81 	m_System	= System;
82 
83 	m_Parameters.Add_String(
84 		NULL	, "NAME"	, _TL("Name"),
85 		_TL("Descriptive name for the grid system"),
86 		m_System.Get_Name()
87 	);
88 }
89 
90 
91 ///////////////////////////////////////////////////////////
92 //														 //
93 //														 //
94 //														 //
95 ///////////////////////////////////////////////////////////
96 
97 //---------------------------------------------------------
Get_Name(void)98 wxString CWKSP_Grid_System::Get_Name(void)
99 {
100 	return( m_Parameters("NAME")->asString() );
101 }
102 
103 //---------------------------------------------------------
Get_Description(void)104 wxString CWKSP_Grid_System::Get_Description(void)
105 {
106 	wxString	s;
107 
108 	//-----------------------------------------------------
109 	s	+= wxString::Format("<h4>%s</h4>", _TL("Grid System"));
110 
111 	s	+= "<table border=\"0\">";
112 
113 	DESC_ADD_STR (_TL("Name"             ), Get_Name());
114 	DESC_ADD_INT (_TL("Number of Grids"  ), Get_Count());
115 	DESC_ADD_STR (_TL("West"             ), SG_Get_String(m_System.Get_XMin    (), -CSG_Grid_System::Get_Precision()).c_str());
116 	DESC_ADD_STR (_TL("East"             ), SG_Get_String(m_System.Get_XMax    (), -CSG_Grid_System::Get_Precision()).c_str());
117 	DESC_ADD_STR (_TL("West-East"        ), SG_Get_String(m_System.Get_XRange  (), -CSG_Grid_System::Get_Precision()).c_str());
118 	DESC_ADD_STR (_TL("South"            ), SG_Get_String(m_System.Get_YMin    (), -CSG_Grid_System::Get_Precision()).c_str());
119 	DESC_ADD_STR (_TL("North"            ), SG_Get_String(m_System.Get_YMax    (), -CSG_Grid_System::Get_Precision()).c_str());
120 	DESC_ADD_STR (_TL("South-North"      ), SG_Get_String(m_System.Get_YRange  (), -CSG_Grid_System::Get_Precision()).c_str());
121 	DESC_ADD_STR (_TL("Cell Size"        ), SG_Get_String(m_System.Get_Cellsize(), -CSG_Grid_System::Get_Precision()).c_str());
122 	DESC_ADD_INT (_TL("Number of Columns"), m_System.Get_NX());
123 	DESC_ADD_INT (_TL("Number of Rows"   ), m_System.Get_NY());
124 	DESC_ADD_LONG(_TL("Number of Cells"  ), m_System.Get_NCells());
125 
126 	s	+= "</table>";
127 
128 	//-----------------------------------------------------
129 	return( s );
130 }
131 
132 //---------------------------------------------------------
Get_Menu(void)133 wxMenu * CWKSP_Grid_System::Get_Menu(void)
134 {
135 	wxMenu	*pMenu	= new wxMenu(Get_Name());
136 
137 	CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
138 
139 	return( pMenu );
140 }
141 
142 
143 ///////////////////////////////////////////////////////////
144 //														 //
145 //														 //
146 //														 //
147 ///////////////////////////////////////////////////////////
148 
149 //---------------------------------------------------------
Get_Grid(CSG_Grid * pGrid)150 CWKSP_Grid * CWKSP_Grid_System::Get_Grid(CSG_Grid *pGrid)
151 {
152 	for(int i=0; i<Get_Count(); i++)
153 	{
154 		if( Get_Data(i)->Get_Object() == pGrid )
155 		{
156 			return( (CWKSP_Grid *)Get_Data(i) );
157 		}
158 	}
159 
160 	return( NULL );
161 }
162 
163 //---------------------------------------------------------
Add_Grid(CSG_Grid * pGrid)164 CWKSP_Grid * CWKSP_Grid_System::Add_Grid(CSG_Grid *pGrid)
165 {
166 	CWKSP_Grid	*pItem	= Get_Grid(pGrid);
167 
168 	if( pItem == NULL && pGrid != NULL )
169 	{
170 		Add_Item(pItem = new CWKSP_Grid(pGrid));
171 	}
172 
173 	return( pItem );
174 }
175 
176 //---------------------------------------------------------
Get_Grids(CSG_Grids * pGrids)177 CWKSP_Grids * CWKSP_Grid_System::Get_Grids(CSG_Grids *pGrids)
178 {
179 	for(int i=0; i<Get_Count(); i++)
180 	{
181 		if( Get_Data(i)->Get_Object() == pGrids )
182 		{
183 			return( (CWKSP_Grids *)Get_Data(i) );
184 		}
185 	}
186 
187 	return( NULL );
188 }
189 
190 //---------------------------------------------------------
Add_Grids(CSG_Grids * pGrids)191 CWKSP_Grids * CWKSP_Grid_System::Add_Grids(CSG_Grids *pGrids)
192 {
193 	CWKSP_Grids	*pItem	= Get_Grids(pGrids);
194 
195 	if( pItem == NULL && pGrids != NULL )
196 	{
197 		Add_Item(pItem = new CWKSP_Grids(pGrids));
198 	}
199 
200 	return( pItem );
201 }
202 
203 
204 ///////////////////////////////////////////////////////////
205 //														 //
206 //														 //
207 //														 //
208 ///////////////////////////////////////////////////////////
209 
210 //---------------------------------------------------------
211