All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Context.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 Context.h
22 
23  \brief Singleton class responsible for keeping active objects while the plugin is loaded in memory
24  and make them available for access anywhere in the plugin or layout module.
25  Ex .: factories objects, canvas, class of utility functions, proxy to access the project, etc.
26 
27  \ingroup layout
28 */
29 
30 #ifndef __TERRALIB_LAYOUT_INTERNAL_CONTEXT_H
31 #define __TERRALIB_LAYOUT_INTERNAL_CONTEXT_H
32 
33 // TerraLib
34 #include "../../enum/AbstractType.h"
35 #include "../../Utils.h"
36 #include "../factory/AbstractOutsideFactory.h"
37 #include "../../../../maptools/Canvas.h"
38 #include "../../../../geometry/Envelope.h"
39 #include "../../Config.h"
40 #include "../../../../common/Singleton.h"
41 #include "../../SystematicScaleConfig.h"
42 #include "../../PaperConfig.h"
43 #include "../mvc/ItemObserver.h"
44 
45 namespace te
46 {
47  namespace layout
48  {
49  class AbstractScene;
50  class AbstractItemFactory;
51  class AbstractOutsideFactory;
52  class AbstractTemplateFactory;
53  class AbstractBuildGraphicsItem;
54  class EnumType;
55  class AbstractProxyProject;
56  class ItemUtils;
57  class AbstractBuildGraphicsOutside;
58 
59  /*!
60  \brief Singleton class responsible for keeping active objects while the plugin is loaded in memory
61  and make them available for access anywhere in the plugin or layout module.
62  Ex .: factories objects, canvas, class of utility functions, proxy to access the project, etc.
63 
64  \ingroup layout
65 
66  \sa te::common::Singleton
67  */
69  {
71 
72  protected:
73 
74  /*!
75  \brief Constructor
76  */
77  Context();
78 
79  public:
80 
81  /*!
82  \brief Destructor
83  */
84  virtual ~Context();
85 
86  /*!
87  \brief Returns value of the enumeration of mode type.
88 
89  \return value of the enumeration of mode type
90  */
91  EnumType* getMode();
92 
93  /*!
94  \brief Change value of the enumeration of mode type. Ex.: select, pan, create text, etc.
95  The type of mode is used by the context to know what should be done. The mode in context could be modified by the user interaction.
96 
97  \param value of the enumeration of mode type
98  */
99  void setMode(EnumType* mode);
100 
101  LayoutUnitsMetrics getUnitMetric();
102 
103  void setUnitMetric(LayoutUnitsMetrics unit);
104 
105  /*!
106  \brief Returns abstract scene for QGraphicsScene class, part of Graphics View Framework.
107 
108  \return scene
109  */
110  AbstractScene* getScene();
111 
112  /*!
113  \brief Change scene, QGraphicsScene class, part of Graphics View Framework.
114 
115  \param scene
116  */
117  void setScene(AbstractScene* scene);
118 
119  /*!
120  \brief Returns current zoom factor. Ex.: 0.5 (50%)
121 
122  \return current zoom factor
123  */
124  double getZoomFactor();
125 
126  /*!
127  \brief Change current zoom factor. Ex.: 0.5 (50%)
128 
129  \param zoomFactor current zoom factor
130  */
131  void setZoomFactor(double zoomFactor);
132 
133  /*!
134  \brief Default zoom factor. Ex.: 0.5 (50%)
135 
136  \return default zoom factor
137  */
138  double getDefaultZoomFactor();
139 
140  /*!
141  \brief Change default zoom factor. Ex.: 0.5 (50%)
142 
143  \param zoomFactor default zoom factor
144  */
145  void setDefaultZoomFactor(double zoomFactor);
146 
147  /*!
148  \brief Returns previous zoom factor. Ex.: 0.5 (50%)
149 
150  \return previous zoom factor
151  */
152  double getOldZoomFactor();
153 
154  /*!
155  \brief Change previous zoom factor. Ex.: 0.5 (50%)
156 
157  \param zoomFactor previous zoom factor
158  */
159  void setOldZoomFactor(double zoomFactor);
160 
161  /*!
162  \brief Returns Abstract Factory that provide an interface for creating families of related or dependent graphic objects (MVC components).
163 
164  \return factory for creating families of related or dependent graphic objects (MVC components)
165  */
166  AbstractItemFactory* getItemFactory();
167 
168  /*!
169  \brief Change factory for creating families of related or dependent graphic objects (MVC components).
170 
171  \param factory for creating families of related or dependent graphic objects (MVC components)
172  */
173  void setItemFactory(AbstractItemFactory* factory);
174 
175  /*!
176  \brief Returns Abstract Factory provide an interface for creating families of related or dependent graphic widgets (MVC widgets).
177 
178  \return factory provide an interface for creating families of related or dependent graphic widgets (MVC widgets)
179  */
180  AbstractOutsideFactory* getOutsideFactory();
181 
182  /*!
183  \brief Change factory provide an interface for creating families of related or dependent graphic widgets (MVC widgets).
184 
185  \param factory provide an interface for creating families of related or dependent graphic widgets (MVC widgets)
186  */
187  void setOutsideFactory(AbstractOutsideFactory* factory);
188 
189  /*!
190  \brief Returns Abstract Factory provide an interface for creating families of related or dependent templates.
191 
192  \return factory provide an interface for creating families of related or dependent templates.
193  */
194  AbstractTemplateFactory* getTemplateFactory();
195 
196  /*!
197  \brief Change factory provide an interface for creating families of related or dependent templates.
198 
199  \param factory provide an interface for creating families of related or dependent templates.
200  */
201  void setTemplateFactory(AbstractTemplateFactory* factory);
202 
203  /*!
204  \brief Returns abstraction of a drawing area.
205 
206  \return abstraction of a drawing area
207  */
208  te::map::Canvas* getCanvas();
209 
210  /*!
211  \brief Change abstraction of a drawing area.
212 
213  \param abstraction of a drawing area
214  */
215  void setCanvas(te::map::Canvas* canvas);
216 
217  /*!
218  \brief Returns pointer with functions to manipulate the canvas and conversion between projections.
219 
220  \return A te::layout::Utils pointer
221  */
222  Utils* getUtils();
223 
224  /*!
225  \brief Change pointer with functions to manipulate the canvas and conversion between projections.
226 
227  \param A te::layout::Utils pointer
228  */
229  void setUtils(Utils* utils);
230 
231  double getDpiX();
232 
233  void setDpiX(double dpiX);
234 
235  double getDpiY();
236 
237  void setDpiY(double dpiY);
238 
239  /*!
240  \brief Template structure version.
241 
242  \param version
243  */
244  std::string getVersion();
245 
246  /*!
247  \brief Returns paper setting.
248 
249  \return A te::layout::PaperConfig pointer
250  */
251  PaperConfig* getPaperConfig() const;
252 
253  /*!
254  \brief Change paper setting.
255 
256  \param A te::layout::PaperConfig pointer
257  */
258  void setPaperConfig(PaperConfig* config);
259 
260  /*!
261  \brief Returns pointer for build graphics MVC components.
262 
263  \return a AbstractBuildGraphicsItem pointer
264  */
265  AbstractBuildGraphicsItem* getAbstractBuildGraphicsItem();
266 
267  /*!
268  \brief Change a pointer for build graphics MVC components.
269 
270  \param a AbstractBuildGraphicsItem pointer
271  */
272  void setAbstractBuildGraphicsItem(AbstractBuildGraphicsItem* build);
273 
274  EnumType* getLineIntersectionMouseMode();
275 
276  void setLineIntersectionMouseMode(EnumType* mode);
277 
278  SystematicScaleConfig* getSystematicScaleConfig();
279 
280  void setSystematicScaleConfig(SystematicScaleConfig* scale);
281 
282  /*!
283  \brief Change the proxy to provide a surrogate or placeholder for te::qt::af::Project to control access to it
284 
285  \param proxy for te::qt::af::Project
286  */
287  void setProxyProject(AbstractProxyProject* project);
288 
289  /*!
290  \brief Returns proxy to provide a surrogate or placeholder for te::qt::af::Project to control access to it
291 
292  \return proxy for te::qt::af::Project
293  */
294  AbstractProxyProject* getProxyProject();
295 
296  /*!
297  \brief Change pointer for manipulating items in the scene and vectorization of text and legend.
298 
299  \param A te::layout::ItemUtils pointer
300  */
301  void setItemUtils(ItemUtils* utils);
302 
303  /*!
304  \brief Returns pointer for manipulating items in the scene and vectorization of text and legend.
305 
306  \return A te::layout::ItemUtils pointer
307  */
308  ItemUtils* getItemUtils();
309 
310  EnumType* getWait();
311 
312  void setWait(EnumType* wait);
313 
314  ItemObserver* getItem();
315 
316  void setItem(ItemObserver* item);
317 
318  /*!
319  \brief Returns pointer for build graphics MVC components.
320 
321  \return a AbstractBuildGraphicsItem pointer
322  */
323  AbstractBuildGraphicsOutside* getAbstractBuildGraphicsOutside();
324 
325  /*!
326  \brief Change a pointer for build graphics MVC components.
327 
328  \param a AbstractBuildGraphicsItem pointer
329  */
330  void setAbstractBuildGraphicsOutside(AbstractBuildGraphicsOutside* build);
331 
332  private:
333 
334  /*!
335  \brief Copy constructor not allowed.
336 
337  \param rhs The right-hand-side copy that would be used to copy from.
338  */
339  Context(const Context& rhs);
340 
341  /*!
342  \brief Assignment operator not allowed.
343 
344  \param rhs The right-hand-side copy that would be used to copy from.
345 
346  \return A reference to this object.
347  */
348  Context& operator=(const Context& rhs);
349 
350  protected:
351 
352  EnumType* m_mode; //!< value of the enumeration of mode type
354  LayoutUnitsMetrics m_unitMetric; //!<
355  AbstractScene* m_scene; //!< abstract scene for QGraphicsScene class, part of Graphics View Framework.
356  double m_zoomFactor; //!< current zoom factor. Ex.: 0.5 (50%)
357  double m_defaultZoomFactor; //!< default zoom factor. Ex.: 0.5 (50%)
358  double m_oldZoomFactor; //!< previous zoom factor. Ex.: 0.5 (50%)
359  te::map::Canvas* m_canvas; //!< abstraction of a drawing area
360  AbstractItemFactory* m_itemFactory; //!< factory that provide an interface for creating families of related or dependent graphic objects (MVC components)
361  AbstractOutsideFactory* m_outsideFactory; //!< factory provide an interface for creating families of related or dependent graphic widgets (MVC widgets)
362  AbstractTemplateFactory* m_templateFactory; //!< factory provide an interface for creating families of related or dependent templates
363  Utils* m_utils; //!< pointer with functions to manipulate the canvas and conversion between projections
364  double m_dpiX; //!<
365  double m_dpiY; //!<
366  std::string m_version; //!< template structure version
367  PaperConfig* m_paperConfig; //!< paper settings
368  AbstractBuildGraphicsItem* m_buildGraphicsItem; //!< build graphics MVC components.
370  AbstractProxyProject* m_proxyProject; //!< provide a surrogate or placeholder for te::qt::af::Project to control access to it
371  ItemUtils* m_itemUtils; //!< pointer for manipulating items in the scene and vectorization of text and legend
375  };
376  }
377 }
378 
379 #endif
double m_zoomFactor
current zoom factor. Ex.: 0.5 (50%)
Definition: Context.h:356
AbstractScene * m_scene
abstract scene for QGraphicsScene class, part of Graphics View Framework.
Definition: Context.h:355
Abstract Factory provide an interface for creating families of related or dependent graphic objects (...
AbstractBuildGraphicsOutside * m_buildGraphicsOutside
build MVC widgets.
Definition: Context.h:374
AbstractBuildGraphicsItem * m_buildGraphicsItem
build graphics MVC components.
Definition: Context.h:368
Class responsible for paper setting. Size, orientation, custom size, etc.
Definition: PaperConfig.h:45
LayoutUnitsMetrics m_unitMetric
Definition: Context.h:354
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
Utils * m_utils
pointer with functions to manipulate the canvas and conversion between projections ...
Definition: Context.h:363
ItemUtils * m_itemUtils
pointer for manipulating items in the scene and vectorization of text and legend
Definition: Context.h:371
Abstract Factory provide an interface for creating families of related or dependent templates without...
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
Definition: ItemObserver.h:52
double m_oldZoomFactor
previous zoom factor. Ex.: 0.5 (50%)
Definition: Context.h:358
EnumType * m_wait
Definition: Context.h:372
PaperConfig * m_paperConfig
paper settings
Definition: Context.h:367
double m_defaultZoomFactor
default zoom factor. Ex.: 0.5 (50%)
Definition: Context.h:357
Abstract class for build MVC widgets.
EnumType * m_mode
value of the enumeration of mode type
Definition: Context.h:352
std::string m_version
template structure version
Definition: Context.h:366
ItemObserver * m_item
Definition: Context.h:373
Utility class for manipulating items in the scene and vectorization of text and legend.
Definition: ItemUtils.h:62
EnumType * m_lineIntersectionMouseMode
Definition: Context.h:353
te::map::Canvas * m_canvas
abstraction of a drawing area
Definition: Context.h:359
Abstract scene for Scene, a QGraphicsScene class, part of Graphics View Framework.
Definition: AbstractScene.h:48
SystematicScaleConfig * m_systematicConfig
Definition: Context.h:369
Abstract class to provide a surrogate or placeholder for te::qt::af::Project to control access to it...
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:91
AbstractTemplateFactory * m_templateFactory
factory provide an interface for creating families of related or dependent templates ...
Definition: Context.h:362
AbstractProxyProject * m_proxyProject
provide a surrogate or placeholder for te::qt::af::Project to control access to it ...
Definition: Context.h:370
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
AbstractOutsideFactory * m_outsideFactory
factory provide an interface for creating families of related or dependent graphic widgets (MVC widge...
Definition: Context.h:361
Abstract Factory provide an interface for creating families of related or dependent graphic widgets (...
AbstractItemFactory * m_itemFactory
factory that provide an interface for creating families of related or dependent graphic objects (MVC ...
Definition: Context.h:360
Singleton class responsible for keeping active objects while the plugin is loaded in memory and make ...
Definition: Context.h:68
Abstract class for build graphics MVC components.
Utility class with functions to manipulate the canvas and conversion between projections.
Definition: Utils.h:61
Template support for singleton pattern.
Definition: Singleton.h:100