All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OutsideModelObservable.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 OutsideModelObservable.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "OutsideModelObservable.h"
30 #include "Observer.h"
31 #include "Property.h"
32 #include "Properties.h"
33 
35  m_color(0),
36  m_type(TPObjectUnknown),
37  m_name("unknown"),
38  m_id(0)
39 {
40  m_properties = new Properties("Unknown");
41 }
42 
44 {
45 
46 }
47 
49 {
50  std::pair<std::set<Observer*>::iterator,bool> p = m_observers.insert(o);
51 
52  if(p.second == true)
53  return true;
54 
55  return false;
56 }
57 
59 {
60  int num = m_observers.erase(o);
61 
62  if(num == 1)
63  return true;
64 
65  return false;
66 }
67 
69 {
70  std::set<Observer*>::iterator it;
71  for(it = m_observers.begin(); it != m_observers.end(); ++it)
72  {
73  (*it)->updateObserver(context);
74  }
75 }
76 
78 {
79  return m_box;
80 }
81 
83 {
84  m_box = box;
85 }
86 
88 {
89  return m_color;
90 }
91 
93 {
94  m_color = color;
95 }
96 
97 void te::layout::OutsideModelObservable::setPosition( const double& x, const double& y )
98 {
99  //Initial point to draw is : x1, y2, that corresponds 0,0 of local coordinate of a item
100  double x1 = x;
101  double y1 = y - m_box.getHeight();
102 
103  double x2 = x + m_box.getWidth();
104  double y2 = y;
105 
106  m_box = te::gm::Envelope(x1, y1, x2, y2);
107 
108 }
109 
111 {
112  m_properties->clear();
113 
114  Property pro_name;
115  pro_name.setName("Oi");
116  Property pro_label;
117  //pro_label.setLabel("SHOW");
118 
119  m_properties->addProperty(pro_name);
120  m_properties->addProperty(pro_label);
121 
122  m_properties->setTypeObj(m_type);
123  return m_properties;
124 }
125 
127 {
128  return m_type;
129 }
130 
132 {
133  m_type = type;
134 }
135 
137 {
138  return m_zValue;
139 }
140 
142 {
143  m_zValue = zValue;
144 }
145 
147 {
148  Properties* vectorProps = const_cast<Properties*>(properties);
149 
150  std::vector<Property> vProps = vectorProps->getProperties();
151  Property pro_name = vProps[0];
152  //m_name = pro_name.getName();
153 }
154 
156 {
157  return m_name;
158 }
159 
161 {
162  return m_id;
163 }
164 
166 {
167  m_id = id;
168 }
virtual void updateProperties(te::layout::Properties *properties)
virtual std::vector< Property > getProperties()
Definition: Properties.h:116
virtual LayoutAbstractObjectType getType()
virtual Properties * getProperties() const
virtual void setType(LayoutAbstractObjectType type)
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual void setPosition(const double &x, const double &y)
virtual void setBox(te::gm::Envelope box)
LayoutAbstractObjectType
Enum TdkAbstractComponentType. This is the enumeration of the components types.
Definition: AbstractType.h:38
virtual void notifyAll(ContextItem context)
virtual bool clear()
Definition: Properties.h:121
void setName(std::string name)
Definition: Property.cpp:54