All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ItemObserver.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 ItemObserver.h
22 
23  \brief Abstract class to represent an observer. "View" part of MVC component. All classes representing the graphics component must inherit from this class.
24 
25  \ingroup layout
26 */
27 
28 #ifndef __TERRALIB_LAYOUT_INTERNAL_ITEM_OBSERVER_H
29 #define __TERRALIB_LAYOUT_INTERNAL_ITEM_OBSERVER_H
30 
31 // TerraLib
32 #include "Observer.h"
33 #include "../../../../geometry/Coord2D.h"
34 #include "../../../../color/RGBAColor.h"
35 #include "../../Config.h"
36 
37 namespace te
38 {
39  namespace layout
40  {
41  class Observable;
42  class ItemController;
43  class Properties;
44 
45  /*!
46  \brief Abstract class to represent an observer. "View" part of MVC component. All classes representing the graphics component must inherit from this class.
47 
48  \ingroup layout
49 
50  \sa te::layout::Observer
51  */
53  {
54  public:
55 
56  /*!
57  \brief Constructor
58 
59  \param controller "Controller" part of MVC component
60  \param o "Model" part of MVC component
61  */
62  ItemObserver(ItemController* controller = 0, Observable* o = 0);
63 
64  /*!
65  \brief Destructor
66  */
67  virtual ~ItemObserver();
68 
69  /*!
70  \brief Reimplemented from Observer
71  */
72  virtual void updateObserver(ContextItem context) = 0;
73 
74  /*!
75  \brief Method that returns the class name.
76 
77  \return class name
78  */
79  virtual std::string getNameClass();
80 
81  /*!
82  \brief Method that returns the position llx, lly
83  Reimplement this function in a ItemObserver subclass to provide the item's getPosition implementation.
84 
85  \return coordinate
86  */
87  virtual te::gm::Coord2D getPosition() = 0;
88 
89  /*!
90  \brief Redraws the graphic component.
91  */
92  virtual void redraw(bool bRefresh = true);
93 
94  /*!
95  \brief Modifies the state of the graphic component to be or not printable.
96 
97  \param print true if printable, false otherwise
98  */
99  virtual void setPrintable(bool print);
100 
101  /*!
102  \brief Returns whether the graphic component is printable.
103 
104  \return true if printable, false otherwise
105  */
106  virtual bool isPrintable();
107 
108  /*!
109  \brief Change the state of the graphic component to be or not send to back or bring to front.
110 
111  \param canChange true if send to back or bring to front, false otherwise
112  */
113  virtual void setCanChangeGraphicOrder(bool canChange);
114 
115  /*!
116  \brief Returns whether the graphic component to be or not send to back or bring to front.
117 
118  \return true if send to back or bring to front, false otherwise
119  */
120  virtual bool isCanChangeGraphicOrder();
121 
122  /*!
123  \brief Returns the "Controller" part of the MVC.
124 
125  \return controller
126  */
127  virtual ItemController* getController();
128 
129  /*!
130  \brief Returns the "Model" part of the MVC.
131 
132  \return model
133  */
134  virtual Observable* getModel();
135 
136  /*!
137  \brief Updated model state.
138 
139  \param true if refresh the current position, false otherwise
140  */
141  virtual void refresh(bool pos = true);
142 
143  /*!
144  \brief Returns whether the graph component has the inverted matrix, otherwise the matrix scene.
145 
146  \return true if inverted, false otherwise
147  */
148  virtual bool isInvertedMatrix();
149 
150  /*!
151  \brief Returns a image of the graphic component.
152  Reimplement this function in a ItemObserver subclass to provide the item's getImage implementation.
153 
154  \param image width
155  \param image height
156 
157  \return image
158  */
159  virtual te::color::RGBAColor** getRGBAColorImage(int &w, int &h) = 0;
160 
161 
162  /*!
163  \brief It is called immediately by the Scene when the zoom factor is changed in the Context.
164 
165  \param currentZoomFactor current zoom factor of the layout module
166  */
167  virtual void changeZoomFactor(double currentZoomFactor);
168 
169  /*!
170  \brief The default implementation does nothing.
171  */
172  virtual void recalculateBoundingRect();
173 
174  protected:
175 
176  /*!
177  \brief The Z value decides the stacking order of drawing.
178 
179  \param drawing order
180  */
181  virtual void setZValueItem(int z);
182 
183  /*!
184  \brief Return the Z value.
185  Reimplement this function in a ItemObserver subclass to provide the item's getZValueItem implementation.
186 
187  \return Z value
188  */
189  virtual int getZValueItem() = 0;
190 
191  /*!
192  \brief Rotates the graphic component.
193  Reimplement this function in a ItemObserver subclass to provide the item's applyImage implementation.
194  */
195  virtual void applyRotation() = 0;
196 
197  te::layout::ItemController* m_controller; //!< "Controller" part of MVC component.
198  te::layout::Observable* m_model; //!< "Model" part of MVC component.
199  bool m_printable; //!< State of the graphic component to be or not printable.
200  bool m_canChangeGraphicOrder; //!< Define if item can send to back or bring to front
201  std::string m_nameClass; //!< Class name
202  bool m_invertedMatrix; //!< true if inverted, false otherwise the matrix scene
203  };
204  }
205 }
206 
207 #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
te::layout::Observable * m_model
"Model" part of MVC component.
Definition: ItemObserver.h:198
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
bool m_printable
State of the graphic component to be or not printable.
Definition: ItemObserver.h:199
Abstract class to represent an observer. "View" part of MVC component.
te::layout::ItemController * m_controller
"Controller" part of MVC component.
Definition: ItemObserver.h:197
bool m_invertedMatrix
true if inverted, false otherwise the matrix scene
Definition: ItemObserver.h:202
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
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Abstract class to represent an observer. "View" part of MVC component.
Definition: Observer.h:48
bool m_canChangeGraphicOrder
Define if item can send to back or bring to front.
Definition: ItemObserver.h:200
std::string m_nameClass
Class name.
Definition: ItemObserver.h:201
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57