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) 2001-2014 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 "AbstractType.h"
31 #include "LegendModel.h"
32 #include "ItemObserver.h"
33 #include "MapModel.h"
34 #include "ScaleModel.h"
35 
36 // STL
37 #include <stddef.h> // defines NULL
38 
39 // Boost
40 #include "boost\foreach.hpp"
41 
42 TELAYOUTEXPORT bool te::layout::changeMapVisitable( QList<QGraphicsItem*> graphicsItems, te::layout::Visitable* visitable )
43 {
44  te::layout::MapModel* mpModel = dynamic_cast<te::layout::MapModel*>(visitable);
45 
46  if(!mpModel)
47  return false;
48 
49  te::layout::LegendModel* legModel = 0;
50  te::layout::ScaleModel* scaleModel = 0;
51 
52  foreach( QGraphicsItem *it, graphicsItems)
53  {
54  if(!it)
55  continue;
56 
57  te::layout::ItemObserver* lIt = dynamic_cast<te::layout::ItemObserver*>(it);
58  if(!lIt)
59  continue;
60 
62  if(!model)
63  continue;
64 
65  switch(model->getType())
66  {
67  case TPLegendItem:
68  legModel = dynamic_cast<te::layout::LegendModel*>(model);
69  if(legModel)
70  mpModel->acceptVisitor(legModel);
71  break;
72  case TPScaleItem:
73  scaleModel = dynamic_cast<te::layout::ScaleModel*>(model);
74  if(scaleModel)
75  mpModel->acceptVisitor(scaleModel);
76  break;
77  default:
78  continue;
79  }
80  }
81 
82  return true;
83 }
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
virtual void acceptVisitor(AbstractVisitor *visitor)
Definition: Visitable.cpp:43
virtual LayoutAbstractObjectType getType()
virtual Observable * getModel()
TELAYOUTEXPORT bool changeMapVisitable(QList< QGraphicsItem * > graphicsItems, Visitable *visitable)