SnapManager.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 terralib/edit/SnapManager.h
22 
23  \brief This is a singleton for managing geometries snap.
24 */
25 
26 #ifndef __TERRALIB_EDIT_INTERNAL_SNAPMANAGER_H
27 #define __TERRALIB_EDIT_INTERNAL_SNAPMANAGER_H
28 
29 // TerraLib
30 #include "../common/Singleton.h"
31 #include "Config.h"
32 
33 // Boost
34 #include <boost/function.hpp>
35 
36 // STL
37 #include <map>
38 #include <string>
39 #include <vector>
40 
41 namespace te
42 {
43 // Forward declarations
44  namespace da
45  {
46  class DataSet;
47  }
48 
49  namespace gm
50  {
51  struct Coord2D;
52  class Geometry;
53  }
54 
55  namespace edit
56  {
57 // Forward declaration
58  class Snap;
59 
60  /*!
61  \class SnapManager
62 
63  \brief This is a singleton for managing geometries snap.
64  */
65  class TEEDITEXPORT SnapManager : public te::common::Singleton<SnapManager>
66  {
68 
69  public:
70 
71  typedef boost::function<Snap* (const std::string& source, int srid)> SnapStrategyFnctType;
72  typedef std::map<std::string, SnapStrategyFnctType> SnapStrategies;
73 
74  bool hasSnap(const std::string& source) const;
75 
76  void createSnap(const std::string& source, int srid);
77 
78  void buildSnap(const std::string& source, int srid, te::da::DataSet* dataset);
79 
80  void removeSnap(const std::string& source);
81 
82  const std::map<std::string, Snap*>& getSnaps() const;
83 
84  Snap* getSnap(const std::string& source) const;
85 
86  void clear(const std::string& source);
87 
88  void clearAll();
89 
90  bool search(const te::gm::Coord2D& coord, int srid, te::gm::Coord2D& result);
91 
92  void setWorld(const double& llx, const double& lly,
93  const double& urx, const double& ury,
94  const std::size_t& width, const std::size_t& height);
95 
96  void reg(const std::string& name, const SnapStrategyFnctType& strategy);
97 
98  void clearStrategies();
99 
100  protected:
101 
102  /*! \brief It initializes the singleton instance of the snap manager. */
103  SnapManager();
104 
105  /*! \brief Singleton destructor. */
106  ~SnapManager();
107 
108  private:
109 
110  SnapStrategies m_snapStrategies;
111  std::map<std::string, Snap*> m_snaps;
112  };
113 
114  } // end namespace edit
115 } // end namespace te
116 
117 #endif // __TERRALIB_EDIT_INTERNAL_SNAPMANAGER_H
This class implements geometry snap concept.
Definition: Snap.h:63
This is a singleton for managing geometries snap.
Definition: SnapManager.h:65
#define TEEDITEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:68
std::map< std::string, Snap * > m_snaps
Definition: SnapManager.h:111
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
std::map< std::string, SnapStrategyFnctType > SnapStrategies
Definition: SnapManager.h:72
URI C++ Library.
SnapStrategies m_snapStrategies
Definition: SnapManager.h:110
Configuration flags for the TerraLib Edit module.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
boost::function< Snap *(const std::string &source, int srid)> SnapStrategyFnctType
Definition: SnapManager.h:71
Template support for singleton pattern.
Definition: Singleton.h:100