All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ItemUtils.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 ItemUtils.h
22 
23  \brief Utility class for manipulating items in the scene and vectorization of text and legend.
24 
25  \ingroup layout
26 */
27 
28 #ifndef __TERRALIB_LAYOUT_INTERNAL_ITEM_UTILS_H
29 #define __TERRALIB_LAYOUT_INTERNAL_ITEM_UTILS_H
30 
31 // TerraLib
32 #include "../../core/Config.h"
33 #include "../../../geometry/Point.h"
34 #include "../../core/property/Properties.h"
35 
36 // STL
37 #include <vector>
38 #include <string>
39 #include <map>
40 
41 // Qt
42 #include <QList>
43 
44 class QGraphicsItem;
45 class QGraphicsScene;
46 class QFont;
47 
48 namespace te
49 {
50  namespace layout
51  {
52  class MapItem;
53  class EnumType;
54  class MapModel;
55  class GridMapItem;
56 
57  /*!
58  \brief Utility class for manipulating items in the scene and vectorization of text and legend.
59 
60  \ingroup layout
61  */
63  {
64  public:
65 
66  /*!
67  \brief Constructor
68  */
69  ItemUtils( QGraphicsScene* scene );
70 
71  /*!
72  \brief Destructor
73  */
74  virtual ~ItemUtils();
75 
76  /*!
77  \brief MVC components list of type te::layout::MapItem
78 
79  \param selected true if only selected te::layout::MapItem, false otherwise.
80  \return MVC components list of type te::layout::MapItem
81  */
82  virtual std::vector<MapItem*> getMapItemList(bool selected = false);
83 
84  /*!
85  \brief Search for te::layout::MapItem by name
86 
87  \param name of te::layout::MapItem
88  \return MapItem found
89  */
90  virtual MapItem* getMapItem(std::string name);
91 
92  /*!
93  \brief List of names te::layout::MapItem
94 
95  \param selected true if only selected te::layout::MapItem, false otherwise.
96  \return list of names
97  */
98  virtual std::vector<std::string> mapNameList(bool selected = false);
99 
100  /*!
101  \brief Returns the number of items added to the scene with the type
102 
103  \param type type to search
104  \return number of items
105  */
106  virtual int countType(te::layout::EnumType* type);
107 
108  /*!
109  \brief Search max id for a type.
110 
111  \param type type to search
112  \return max id
113  */
114  virtual int maxTypeId(te::layout::EnumType* type);
115 
116  /*!
117  \brief Indicates whether there is a tool active for object te::layout::MapItem.
118 
119  \return true if tool active, false otherwise
120  */
121  virtual bool isCurrentMapTools();
122 
123  /*!
124  \brief Changes the active tool of te::layout::MapItem.
125 
126  \param type of tool
127  */
128  virtual void setCurrentToolInSelectedMapItems(EnumType* mode);
129 
130  /*!
131  \brief Vectorizes grid text of selected MapItem. (generates te::layout::TextItem objects)
132  */
133  virtual void createTextGridAsObject();
134 
135  /*!
136  \brief Vectorizes inside text of selected MapItem. (generates te::layout::TextItem objects)
137  */
138  virtual void createTextMapAsObject();
139 
140  /*!
141  \brief Vectorizes selected LegendItem. (generates te::layout::TextItem objects)
142  */
143  virtual void createLegendChildAsObject();
144 
145  /*!
146  \brief Get properties of all GridMapItem, children of a MapItem.
147 
148  \param
149  \return properties of all GridMapItem, children of a MapItem.
150  */
151  virtual std::vector<Properties*> getGridMapProperties();
152 
153  /*!
154  \brief Get all GridMapItem, children of a MapItem.
155 
156  \param
157  \return all GridMapItem, children of a MapItem.
158  */
159  virtual std::vector<GridMapItem*> getMapChildren();
160 
161  /*!
162  \brief Checks whether the coordinated intersects an item and returns.
163 
164  \param x axis x coordinate
165  \param y axis y coordinate
166 
167  \return
168  */
169  virtual QGraphicsItem* intersectionSelectionItem(int x, int y);
170 
171  protected:
172 
173  /*!
174  \brief Returns the list of items added to a scene.
175 
176  \param selected true if only selected items, false otherwise.
177  \return list of items
178  */
179  virtual QList<QGraphicsItem*> getItems(bool selected = false);
180 
181  /*!
182  \brief Vectorizes grid text of selected MapItem. (generates te::layout::TextItem objects)
183 
184  \param map coordinate and text
185  \param ft font
186  */
187  virtual void createTextItemFromObject(std::map<te::gm::Point*, std::string> map, QFont* ft = 0);
188 
189  /*!
190  \brief Vectorizes grid text of selected MapItem. (generates te::layout::TextItem objects)
191 
192  \param map coordinate and text
193  \param visitable MapItem model associated
194  */
195  virtual void createLegendChildItemFromLegend(std::map<te::gm::Point*, std::string> map, MapModel* visitable);
196 
197  protected:
198 
199  QGraphicsScene* m_scene; //!< A pointer to scene
200  };
201  }
202 }
203 
204 #endif
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
QGraphicsScene * m_scene
A pointer to scene.
Definition: ItemUtils.h:199
Utility class for manipulating items in the scene and vectorization of text and legend.
Definition: ItemUtils.h:62
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
Definition: MapModel.h:61
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...
Definition: MapItem.h:74