All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Symbol.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 terralib/qt/widgets/se/Symbol.cpp
22 
23  \brief This class represents a symbol.
24 */
25 
26 // TerraLib
27 #include "../../../common/STLUtils.h"
28 #include "../../../se/Symbolizer.h"
29 #include "Symbol.h"
30 
31 // STL
32 #include <cassert>
33 
35 {
36 }
37 
39 {
40  m_info = rhs.getInfo();
41  for(std::size_t i = 0; i < rhs.m_symbs.size(); ++i)
42  addSymbolizer(rhs.m_symbs[i]->clone());
43 }
44 
46 {
47  te::common::FreeContents(m_symbs);
48 }
49 
51 {
52  return m_info;
53 }
54 
56 {
57  m_info = info;
58 }
59 
61 {
62  return m_symbs.size();
63 }
64 
66 {
67  assert(i < m_symbs.size());
68 
69  return m_symbs[i];
70 }
71 
73 {
74  return getSymbolizer(i);
75 }
76 
77 const std::vector<te::se::Symbolizer*>& te::qt::widgets::Symbol::getSymbolizers() const
78 {
79  return m_symbs;
80 }
81 
83 {
84  assert(symb);
85 
86  m_symbs.push_back(symb);
87 }
88 
90 {
91  assert(symb);
92  assert(i < m_symbs.size());
93 
94  delete m_symbs[i];
95  m_symbs[i] = symb;
96 }
97 
99 {
100  assert(i < m_symbs.size());
101 
102  delete m_symbs[i];
103  m_symbs.erase(m_symbs.begin() + i);
104 }
105 
106 void te::qt::widgets::Symbol::swapSymbolizers(const std::size_t& first, const std::size_t& second)
107 {
108  assert(first < m_symbs.size());
109  assert(second < m_symbs.size());
110 
111  if(first == second)
112  return;
113 
114  // Swapping...
115  te::se::Symbolizer* symb = m_symbs[first];
116  m_symbs[first] = m_symbs[second];
117  m_symbs[second] = symb;
118 }
119 
121 {
122  return new Symbol(*this);
123 }
te::se::Symbolizer * getSymbolizer(const std::size_t &i) const
It returns the n-th Symbolizer.
Definition: Symbol.cpp:65
void setInfo(const SymbolInfo &info)
It sets the information associated to the symbol.
Definition: Symbol.cpp:55
This class represents a symbol.
std::size_t getSymbolizersCount() const
It returns the number of Symbolizers that compose of the symbol.
Definition: Symbol.cpp:60
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
te::se::Symbolizer * operator[](const std::size_t &i) const
It returns the n-th Symbolizer.
Definition: Symbol.cpp:72
const SymbolInfo & getInfo() const
It return the information associated to the symbol.
Definition: Symbol.cpp:50
void setSymbolizer(const std::size_t &i, te::se::Symbolizer *symb)
It sets the given Symbolizer at the given position.
Definition: Symbol.cpp:89
~Symbol()
Destructor.
Definition: Symbol.cpp:45
void removeSymbolizer(const std::size_t &i)
It removes the specified Symbolizer from the list of Symbolizers of the symbol.
Definition: Symbol.cpp:98
void swapSymbolizers(const std::size_t &first, const std::size_t &second)
It swaps the position of the Symbolizers.
Definition: Symbol.cpp:106
Information about a given Symbol.
Definition: SymbolInfo.h:60
This class represents a symbol. TODO: More description!
Definition: Symbol.h:54
Symbol * clone() const
It creates a new copy of this object.
Definition: Symbol.cpp:120
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It returns the list of Symbolizers that compose the symbol.
Definition: Symbol.cpp:77
std::vector< te::se::Symbolizer * > m_symbs
Set of symbolizers that compose the symbol.
Definition: Symbol.h:168
Symbol()
Default constructor.
Definition: Symbol.cpp:34
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
void addSymbolizer(te::se::Symbolizer *symb)
It adds the given Symbolizer to the list of Symbolizers of the symbol.
Definition: Symbol.cpp:82