All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EnumUtils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2014 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file EnumUtils.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "EnumUtils.h"
30 #include "AbstractType.h"
31 #include "../../../../maptools/Enums.h"
32 
33 // STL
34 #include <algorithm>
35 
36 
37 static std::string EnumLayoutGridStyle[] = {
38  "None", "Continuous", "Cross"
39 };
40 
41 static std::string EnumLayoutDashStyle[] = {
42  "No Line",
43  "Solid Line",
44  "Dash Line",
45  "Dot Line",
46  "Dash Dot Line",
47  "Dash Dot Dot Line",
48  "Custom Dash Line"
49 };
50 
51 std::string te::layout::getLayoutGridStyle( int enumVal )
52 {
53  return EnumLayoutGridStyle[enumVal];
54 }
55 
57 {
58  int size = EnumLayoutGridStyle->size();
59  int index = std::distance(EnumLayoutGridStyle, std::find(EnumLayoutGridStyle, EnumLayoutGridStyle + (size-1), val));
60 
61  return getLayoutEnumGridStyle(index);
62 }
63 
65 {
66  switch(enumVal)
67  {
68  case 2:
69  return StyleContinuous;
70  break;
71  case 3:
72  return StyleCross;
73  break;
74  default:
75  return StyleNone;
76  }
77 
78  return StyleNone;
79 }
80 
81 std::string te::layout::getLayoutDashStyle( int enumVal )
82 {
83  return EnumLayoutDashStyle[enumVal];
84 }
85 
87 {
88  int size = EnumLayoutDashStyle->size();
89  int index = std::distance(EnumLayoutDashStyle, std::find(EnumLayoutDashStyle, EnumLayoutDashStyle + (size-1), val));
90  return getLayoutEnumDashStyle(index);
91 }
92 
94 {
95  switch(enumVal)
96  {
97  case te::map::SolidLine:
98  return te::map::SolidLine;
99  break;
100  case te::map::DashLine:
101  return te::map::DashLine;
102  break;
103  case te::map::DotLine:
104  return te::map::DotLine;
105  break;
107  return te::map::DashDotLine;
108  break;
111  break;
112  default:
113  return te::map::NoLine;
114  }
115 
116  return te::map::NoLine;
117 }
118 
119 std::string te::layout::getLayoutPropertyDataType( int enumVal )
120 {
121  std::string s_val = "DataTypeNone";
122 
123  switch(enumVal)
124  {
125  case DataTypeInt:
126  s_val = "DataTypeInt";
127  break;
128  case DataTypeDouble:
129  s_val = "DataTypeDouble";
130  break;
131  case DataTypeLong:
132  s_val = "DataTypeLong";
133  break;
134  case DataTypeFloat:
135  s_val = "DataTypeFloat";
136  break;
137  case DataTypeString:
138  s_val = "DataTypeString";
139  break;
140  case DataTypeBool:
141  s_val = "DataTypeBool";
142  break;
143  case DataTypeColor:
144  s_val = "DataTypeColor";
145  break;
147  s_val = "DataTypeGridSettings";
148  break;
149  case DataTypeStringList:
150  s_val = "DataTypeStringList";
151  break;
152  default:
153  s_val = "DataTypeNone";
154  }
155 
156  return s_val;
157 }
158 
160 {
162 
163  if(val.compare("DataTypeInt") == 0)
164  {
165  type = DataTypeInt;
166  }
167  if(val.compare("DataTypeDouble") == 0)
168  {
169  type = DataTypeDouble;
170  }
171  if(val.compare("DataTypeLong") == 0)
172  {
173  type = DataTypeLong;
174  }
175  if(val.compare("DataTypeFloat") == 0)
176  {
177  type = DataTypeFloat;
178  }
179  if(val.compare("DataTypeString") == 0)
180  {
181  type = DataTypeString;
182  }
183  if(val.compare("DataTypeBool") == 0)
184  {
185  type = DataTypeBool;
186  }
187  if(val.compare("DataTypeColor") == 0)
188  {
189  type = DataTypeColor;
190  }
191  if(val.compare("DataTypeGridSettings") == 0)
192  {
193  type = DataTypeGridSettings;
194  }
195  if(val.compare("DataTypeStringList") == 0)
196  {
197  type = DataTypeStringList;
198  }
199 
200  return type;
201 }
202 
203 std::string te::layout::getLayoutAbstractObjectType( int enumVal )
204 {
205  std::string s_val = "TPObjectUnknown";
206 
207  switch(enumVal)
208  {
209  case TPRetangleItem:
210  s_val = "TPRetangleItem";
211  break;
212  case TPMapItem:
213  s_val = "TPMapItem";
214  break;
215  case TPMapGridItem:
216  s_val = "TPMapGridItem";
217  break;
218  case TPPaperItem:
219  s_val = "TPPaperItem";
220  break;
221  case TPLegendItem:
222  s_val = "TPLegendItem";
223  break;
224  case TPPropertiesWindow:
225  s_val = "TPPropertiesWindow";
226  break;
227  case TPDisplayWindow:
228  s_val = "TPDisplayWindow";
229  break;
231  s_val = "TPObjectInspectorWindow";
232  break;
233  case TPToolbar:
234  s_val = "TPToolbar";
235  break;
236  case TPGridSettings:
237  s_val = "TPGridSettings";
238  break;
239  case TPGrid:
240  s_val = "TPGrid";
241  break;
242  case TPGridPlanar:
243  s_val = "TPGridPlanar";
244  break;
245  case TPGridGeodesic:
246  s_val = "TPGridGeodesic";
247  break;
248  case TPHorizontalRuler:
249  s_val = "TPHorizontalRuler";
250  break;
251  case TPVerticalRuler:
252  s_val = "TPVerticalRuler";
253  break;
254  case TPText:
255  s_val = "TPText";
256  break;
257  case TPItemGroup:
258  s_val = "TPItemGroup";
259  break;
260  case TPScaleItem:
261  s_val = "TPScaleItem";
262  break;
263  default:
264  s_val = "TPObjectUnknown";
265  }
266 
267  return s_val;
268 }
269 
271 {
273 
274  if(val.compare("TPRetangleItem") == 0)
275  {
276  type = TPRetangleItem;
277  }
278  if(val.compare("TPMapItem") == 0)
279  {
280  type = TPMapItem;
281  }
282  if(val.compare("TPMapGridItem") == 0)
283  {
284  type = TPMapGridItem;
285  }
286  if(val.compare("TPPaperItem") == 0)
287  {
288  type = TPPaperItem;
289  }
290  if(val.compare("TPLegendItem") == 0)
291  {
292  type = TPLegendItem;
293  }
294  if(val.compare("TPPropertiesWindow") == 0)
295  {
296  type = TPPropertiesWindow;
297  }
298  if(val.compare("TPDisplayWindow") == 0)
299  {
300  type = TPDisplayWindow;
301  }
302  if(val.compare("TPObjectInspectorWindow") == 0)
303  {
305  }
306  if(val.compare("TPToolbar") == 0)
307  {
308  type = TPToolbar;
309  }
310  if(val.compare("TPGridSettings") == 0)
311  {
312  type = TPGridSettings;
313  }
314  if(val.compare("TPGrid") == 0)
315  {
316  type = TPGrid;
317  }
318  if(val.compare("TPGridPlanar") == 0)
319  {
320  type = TPGridPlanar;
321  }
322  if(val.compare("TPGridGeodesic") == 0)
323  {
324  type = TPGridGeodesic;
325  }
326  if(val.compare("TPHorizontalRuler") == 0)
327  {
328  type = TPHorizontalRuler;
329  }
330  if(val.compare("TPVerticalRuler") == 0)
331  {
332  type = TPVerticalRuler;
333  }
334  if(val.compare("TPText") == 0)
335  {
336  type = TPText;
337  }
338  if(val.compare("TPItemGroup") == 0)
339  {
340  type = TPItemGroup;
341  }
342  if(val.compare("TPScaleItem") == 0)
343  {
344  type = TPScaleItem;
345  }
346 
347  return type;
348 }
std::string getLayoutAbstractObjectType(int enumVal)
Definition: EnumUtils.cpp:203
continuos line grid
Definition: AbstractType.h:157
static std::string EnumLayoutDashStyle[]
Definition: EnumUtils.cpp:41
te::layout::LayoutGridStyle getLayoutEnumGridStyle(std::string val)
Definition: EnumUtils.cpp:56
std::string getLayoutGridStyle(int enumVal)
Definition: EnumUtils.cpp:51
std::string getLayoutPropertyDataType(int enumVal)
Definition: EnumUtils.cpp:119
LayoutAbstractObjectType
Enum TdkAbstractComponentType. This is the enumeration of the components types.
Definition: AbstractType.h:38
static std::string EnumLayoutGridStyle[]
Definition: EnumUtils.cpp:37
LineDashStyle
This enum encodes enumerated values telling how lines should be drawn. e.g. as a plain line or dash l...
Definition: Enums.h:55
te::map::LineDashStyle getLayoutEnumDashStyle(std::string val)
Definition: EnumUtils.cpp:86
LayoutPropertyDataType
Enum LayoutPropertyDataType.
Definition: AbstractType.h:131
std::string getLayoutDashStyle(int enumVal)
Definition: EnumUtils.cpp:81