All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbstractVisitor.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 AbstractVisitor.h
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "AbstractVisitor.h"
30 #include "Visitable.h"
31 #include "../singleton/Context.h"
32 #include "../../../../maptools/Canvas.h"
33 #include "../../Utils.h"
34 
36  m_visitable(0)
37 {
38 
39 }
40 
42 {
43 
44 }
45 
47 {
48  ContextItem context = getContextItem();
49 
50  if(m_visitable)
51  {
52  if(visitable)
53  {
54  if(m_visitable != visitable)
55  {
56  m_visitable->unacceptVisitor(this);
57  m_visitable = visitable;
58  }
59  }
60  visitDependent(context);
61  }
62  else
63  {
64  if(visitable)
65  {
66  m_visitable = visitable;
67  visitDependent(context);
68  }
69  }
70 }
71 
73 {
74  m_visitable = 0;
75 }
76 
78 {
80  Utils* utils = Context::getInstance().getUtils();
81  double zoomFactor = Context::getInstance().getZoomFactor();
82  double dpiX = Context::getInstance().getDpiX();
83  double dpiY = Context::getInstance().getDpiY();
84 
85  ContextItem context;
86  context.setCanvas(canvas);
87  context.setUtils(utils);
88  context.setZoomFactor(zoomFactor);
89  context.setDpiX(dpiX);
90  context.setDpiY(dpiY);
91 
92  return context;
93 }
94 
96 {
97  return m_visitable;
98 }
Class to represent a visitable. All classes representing a visitable must inherit from this class...
Definition: Visitable.h:45
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition: ContextItem.h:49
Class to represent a visitable. All classes representing a visitable must inherit from this class...
virtual void setCanvas(te::map::Canvas *canvas)
Change canvas.
virtual void disassociate()
Separate this object from visitable.
virtual void setUtils(Utils *utils)
virtual ContextItem getContextItem()
Returns context maintaining the drawing context of a MVC component.
static Context & getInstance()
It returns a reference to the singleton instance.
Abstract class to represent a visitor. All classes representing a visitor must inherit from this clas...
virtual void visit(Visitable *visitable)
Constructor.
Utils * getUtils()
Returns pointer with functions to manipulate the canvas and conversion between projections.
Definition: Context.cpp:153
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:91
~AbstractVisitor(void)
Destructor.
virtual void setDpiX(double dpi)
virtual Visitable * getVisitable()
Return the object to be visited.
virtual void setDpiY(double dpi)
double getZoomFactor()
Returns current zoom factor. Ex.: 0.5 (50%)
Definition: Context.cpp:103
Utility class with functions to manipulate the canvas and conversion between projections.
Definition: Utils.h:61
virtual void setZoomFactor(double zoomFactor)
Change current zoom factor.
Definition: ContextItem.cpp:75
te::map::Canvas * getCanvas()
Returns abstraction of a drawing area.
Definition: Context.cpp:143