All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VisitorUtils.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 VisitorUtils.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "VisitorUtils.h"
30 #include "../../enum/AbstractType.h"
31 #include "../mvc/ItemObserver.h"
32 #include "../../../item/MapModel.h"
33 #include "../../enum/Enums.h"
34 #include "AbstractVisitor.h"
35 
36 // STL
37 #include <stddef.h> // defines NULL
38 
39 // Boost
40 #include <boost/foreach.hpp>
41 
43 {
44 
45 }
46 
48 {
49 
50 }
51 
52 bool te::layout::VisitorUtils::changeMapVisitable( QList<QGraphicsItem*> graphicsItems, Visitable* visitable )
53 {
54  bool result = true;
55  te::layout::MapModel* mpModel = dynamic_cast<te::layout::MapModel*>(visitable);
56 
57  if(!mpModel)
58  return false;
59 
60  foreach( QGraphicsItem *it, graphicsItems)
61  {
62  if(!it)
63  continue;
64 
65  te::layout::ItemObserver* lIt = dynamic_cast<te::layout::ItemObserver*>(it);
66  if(!lIt)
67  continue;
68 
70  if(!model)
71  continue;
72 
73  AbstractVisitor* visit = dynamic_cast<AbstractVisitor*>(model);
74  if(!visit)
75  {
76  result = false;
77  break;
78  }
79 
80  mpModel->acceptVisitor(visit);
81  }
82 
83  return result;
84 }
Class to represent a visitable. All classes representing a visitable must inherit from this class...
Definition: Visitable.h:45
VisitorUtils()
Constructor.
virtual ~VisitorUtils()
Destructor.
Abstract class to represent a visitor. All classes representing a visitor must inherit from this clas...
Utility class for visitor.
Abstract class to represent an observable. "Model" part of MVC component. All classes representing th...
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
Definition: ItemObserver.h:52
virtual void acceptVisitor(AbstractVisitor *visitor)
Adds the specified visitor to the set of visitors for this object.
Definition: Visitable.cpp:32
Abstract class to represent a visitor. All classes representing a visitor must inherit from this clas...
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
Definition: MapModel.h:61
virtual Observable * getModel()
Returns the "Model" part of the MVC.
bool changeMapVisitable(QList< QGraphicsItem * > graphicsItems, Visitable *visitable)
Sets the other map (MapModel) for visitable.