All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GridSettingsModel.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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 GridSettingsModel.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "GridSettingsModel.h"
30 #include "../core/property/Property.h"
31 #include "../core/property/Properties.h"
32 #include "../core/property/PlanarGridSettingsConfigProperties.h"
33 #include "../core/property/GeodesicGridSettingsConfigProperties.h"
34 #include "../core/enum/Enums.h"
35 
37 {
38  m_type = Enums::getInstance().getEnumObjectType()->getGridSettings();
39 
40  m_box = te::gm::Envelope(0., 0., 200., 200.);
41 }
42 
44 {
45 
46 }
47 
48 void te::layout::GridSettingsModel::setProperties(std::vector<te::layout::Properties*> properties)
49 {
50  m_properties = properties;
51 }
52 
54 {
55  Property prop;
56 
57  Properties* props = containsGrid(enumType);
58  if(!props)
59  {
60  return prop;
61  }
62 
63  prop = props->contains(name);
64  return prop;
65 }
66 
68 {
69  Properties* props = containsGrid(enumType);
70 
71  if(!props)
72  {
73  return false;
74  }
75 
76  bool result = props->contains(prop);
77  if(!result)
78  {
79  return result;
80  }
81 
82  if(props->removeProperty(prop.getName()))
83  {
84  props->addProperty(prop);
85  }
86  return result;
87 }
88 
90 {
91  Properties* properties = 0;
92 
93  std::vector<Properties*>::iterator it = m_properties.begin();
94  for(it ; it != m_properties.end() ; ++it)
95  {
96  Properties* props = (*it);
97  if(props)
98  {
99  if(props->getTypeObj() == enumType)
100  {
101  properties = props;
102  break;
103  }
104  }
105  }
106 
107  return properties;
108 }
109 
110 
111 
112 
std::string getName()
Method that returns the name of this property.
Definition: Property.cpp:57
virtual bool addProperty(Property property)
Adds the specified property to the set of properties for this object.
Definition: Properties.h:193
virtual bool updateProperty(Property prop, EnumType *enumType)
EnumType * m_type
type of the MVC widget
virtual bool removeProperty(std::string name)
Removes a property from the set of properties of this object.
Definition: Properties.h:204
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
virtual te::layout::Property containsProperty(std::string name, EnumType *enumType)
static Enums & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual EnumType * getTypeObj()
Returns object type that owns these properties.
Definition: Properties.h:241
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
virtual void setProperties(std::vector< te::layout::Properties * > properties)
virtual te::layout::Properties * containsGrid(EnumType *enumType)
virtual bool contains(Property property)
Checks if the property is contained within the set of properties.
Definition: Properties.h:251
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
Definition: Property.h:47
te::gm::Envelope m_box
bounding rectangle