All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ItemModelObservable.h
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 ItemModelObservable.h
22 
23  \brief Abstract class to represent an observable. "Model" part of MVC component. All classes representing the model of a component must inherit from this class.
24 
25  \ingroup layout
26 */
27 
28 #ifndef __TERRALIB_LAYOUT_INTERNAL_ITEM_MODEL_H
29 #define __TERRALIB_LAYOUT_INTERNAL_ITEM_MODEL_H
30 
31 // TerraLib
32 #include "Observable.h"
33 #include "../../Config.h"
34 #include "../../property/Property.h"
35 
36 // STL
37 #include <set>
38 #include <vector>
39 
40 namespace te
41 {
42  namespace layout
43  {
44  class Observer;
45  class SharedProperties;
46  class ItemObserver;
47 
48  /*!
49  \brief Abstract class to represent an observable. "Model" part of MVC component. All classes representing the model of a component must inherit from this class.
50 
51  \ingroup layout
52 
53  \sa te::layout::Observable
54  */
56  {
57  public:
58 
59  /*!
60  \brief Constructor
61  */
63 
64  /*!
65  \brief Destructor
66  */
67  virtual ~ItemModelObservable();
68 
69  /*!
70  \brief Reimplemented from Observable
71  */
72  virtual bool addObserver(Observer* o);
73 
74  /*!
75  \brief Reimplemented from Observable
76  */
77  virtual bool removeObserver(Observer* o);
78 
79  /*!
80  \brief Reimplemented from Observable
81  */
82  virtual Properties* getProperties() const;
83 
84  /*!
85  \brief Reimplemented from Observable
86  */
87  virtual EnumType* getType();
88 
89  /*!
90  \brief Reimplemented from Observable
91  */
92  virtual void setType(EnumType* type);
93 
94  /*!
95  \brief Reimplemented from Observable
96  */
97  virtual te::gm::Envelope getBox();
98 
99  /*!
100  \brief Change the bounding rectangle.
101 
102  \param bounding rectangle
103  */
104  virtual void setBox(te::gm::Envelope box);
105 
106  /*!
107  \brief Change the background color of the MVC component.
108 
109  \param color background color
110  */
111  virtual void setBackgroundColor(te::color::RGBAColor color);
112 
113  /*!
114  \brief Returns the background color of the MVC component.
115 
116  \return background color
117  */
118  virtual te::color::RGBAColor getBackgroundColor();
119 
120  /*!
121  \brief Change the background color of the MVC component.
122 
123  \param color border color
124  */
125  virtual void setBorderColor(te::color::RGBAColor color);
126 
127  /*!
128  \brief Returns the border color of the MVC component.
129 
130  \return border color
131  */
132  virtual te::color::RGBAColor getBorderColor();
133 
134  /*!
135  \brief Change the name of the MVC component.
136 
137  \param name name of the MVC component.
138  */
139  virtual void setName(std::string name);
140 
141  /*!
142  \brief Reimplemented from Observable
143  */
144  virtual std::string getName();
145 
146  /*!
147  \brief Reimplemented from Observable
148  */
149  virtual int getId();
150 
151  /*!
152  \brief Reimplemented from Observable
153  */
154  virtual void setId(int id);
155 
156  /*!
157  \brief Reimplemented from Observable
158  */
159  virtual int getHashCode();
160 
161  /*!
162  \brief Change coordinate llx,lly of the MVC component.
163 
164  \param x llx
165  \param y lly
166  */
167  virtual void setPosition(const double& x, const double& y);
168 
169  /*!
170  \brief Drawing method of the MVC component.
171 
172  \param context maintaining the drawing context of a MVC component
173  */
174  virtual void draw( ContextItem context );
175 
176  /*!
177  \brief Checks if the coordinate is contained within the bounding rectangle.
178 
179  \param coord coordinated to be verified
180  \return true if contains, false otherwise
181  */
182  virtual bool contains(const te::gm::Coord2D &coord) const;
183 
184  /*!
185  \brief Reimplemented from Observable
186  */
187  virtual void updateProperties(te::layout::Properties* properties);
188 
189  /*!
190  \brief Reimplemented from Observable
191  */
192  virtual std::set<ItemObserver*> getChildren() const;
193 
194  /*!
195  \brief Reimplemented from Observable
196  */
197  virtual bool addChildren( ItemObserver* item );
198 
199  /*!
200  \brief Reimplemented from Observable
201  */
202  virtual bool removeChildren(int hashCode);
203 
204  /*!
205  \brief Reimplemented from Observable
206  */
207  virtual te::layout::Properties* getPublicProperties() const;
208 
209  /*!
210  \brief Reimplemented from Observable
211  */
212  virtual int getZValue();
213 
214  /*!
215  \brief Reimplemented from Observable
216  */
217  virtual void setZValue(int zValue);
218 
219  /*!
220  \brief Returns whether the border should be drawn or not.
221 
222  \return true if should be drawn, false otherwise
223  */
224  virtual bool isBorder();
225 
226  /*!
227  \brief Change whether the border should be drawn or not.
228 
229  \param true if should be drawn, false otherwise
230  */
231  virtual void setBorder(bool value);
232 
233  /*!
234  \brief Resize the bounding rectangle of the MVC component.
235 
236  \param true if should be drawn, false otherwise
237  */
238  virtual void resize(double w, double h);
239 
240  /*!
241  \brief Reimplemented from Observable
242  */
243  virtual void setResizable(bool resize);
244 
245  /*!
246  \brief Reimplemented from Observable
247  */
248  virtual bool isResizable();
249 
250  /*!
251  \brief Change the value of rotation of the MVC component.
252 
253  \param value of rotation
254  */
255  virtual void setAngle(double angle);
256 
257  /*!
258  \brief Returns the value of rotation.
259 
260  \return value of rotation
261  */
262  virtual double getAngle();
263 
264  /*!
265  \brief Returns the value of old rotation.
266 
267  \return value of old rotation
268  */
269  virtual double getOldAngle();
270 
271  /*!
272  \brief Returns the value of old position.
273 
274  \return value of old position
275  */
276  virtual te::gm::Coord2D getOldPos();
277 
278  /*!
279  \brief Returns true if MVC component can have children, false otherwise.
280 
281  \return true if MVC component can have children, false otherwise
282  */
283  virtual bool isEnableChildren();
284 
285  /*!
286  \brief Sets true if MVC component can have children, false otherwise.
287 
288  \param true if MVC component can have children, false otherwise
289  */
290  virtual void setEnableChildren(bool value);
291 
292  protected:
293 
294  /*!
295  \brief Reimplemented from Observable
296  */
297  virtual void notifyAll(ContextItem context);
298 
299  virtual int calculateHashCode();
300 
301  /*!
302  \brief Draws the background of the MVC component.
303 
304  \param context maintaining the drawing context of a MVC component
305  */
306  virtual void drawBackground(ContextItem context);
307 
308  virtual void addChildrenProperties(Properties* properties);
309 
310  virtual void updateChildrenProperties(Property prop);
311 
312  protected:
313  std::set<Observer*> m_observers; //!< set of observers of this object
314  int m_id; //!< hashcode
315  te::gm::Envelope m_box; //!< bounding rectangle
316  te::gm::Coord2D m_centerCoordinate; //!< center coordinate of the bounding rectangle
319  Properties* m_properties; //!< properties
320  std::set<ItemObserver*> m_children; //!< children components
321  Properties* m_publicProperties; //!< public properties
322  EnumType* m_type; //!< type of the MVC component
323  int m_zValue; //!< The Z value decides the stacking order of drawing
324  SharedProperties* m_sharedProps; //!< Names of common properties among all MVC components
325  bool m_border; //!< true if should be drawn border, false otherwise
326  std::string m_name; //!< name of the MVC component
327  bool m_resizable; //!< true if resizable, false otherwise
328  double m_angle; //!< value of rotation
330  double m_oldAngle; //!< value of old rotation
331  te::gm::Coord2D m_oldPos; //!< value of old position
332  bool m_enableChildren; //!< true if MVC component can have children, false otherwise
333  };
334  }
335 }
336 
337 #endif
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition: ContextItem.h:49
double m_angle
value of rotation
te::gm::Coord2D m_centerCoordinate
center coordinate of the bounding rectangle
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
bool m_border
true if should be drawn border, false otherwise
Properties * m_publicProperties
public properties
double m_oldAngle
value of old rotation
Abstract class to represent an observable. "Model" part of MVC component.
Abstract class to represent an observable. "Model" part of MVC component. All classes representing th...
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
Definition: ItemObserver.h:52
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
EnumType * m_type
type of the MVC component
std::set< ItemObserver * > m_children
children components
Abstract class to represent an observer. "View" part of MVC component.
Definition: Observer.h:48
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
te::gm::Envelope m_box
bounding rectangle
std::set< Observer * > m_observers
set of observers of this object
std::string m_name
name of the MVC component
bool m_resizable
true if resizable, false otherwise
te::color::RGBAColor m_backgroundColor
background color
Properties * m_properties
properties
bool m_enableChildren
true if MVC component can have children, false otherwise
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
te::color::RGBAColor m_borderColor
border color
te::gm::Coord2D m_oldPos
value of old position
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
int m_zValue
The Z value decides the stacking order of drawing.
SharedProperties * m_sharedProps
Names of common properties among all MVC components.