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 
37 {
38  m_info = rhs.getInfo();
39  for(std::size_t i = 0; i < rhs.m_symbs.size(); ++i)
40  addSymbolizer(rhs.m_symbs[i]->clone());
41 }
42 
44 {
46 }
47 
49 {
50  return m_info;
51 }
52 
54 {
55  m_info = info;
56 }
57 
59 {
60  return m_symbs.size();
61 }
62 
64 {
65  assert(i < m_symbs.size());
66 
67  return m_symbs[i];
68 }
69 
71 {
72  return getSymbolizer(i);
73 }
74 
75 const std::vector<te::se::Symbolizer*>& te::qt::widgets::Symbol::getSymbolizers() const
76 {
77  return m_symbs;
78 }
79 
81 {
82  assert(symb);
83 
84  m_symbs.push_back(symb);
85 }
86 
88 {
89  assert(symb);
90  assert(i < m_symbs.size());
91 
92  delete m_symbs[i];
93  m_symbs[i] = symb;
94 }
95 
97 {
98  assert(i < m_symbs.size());
99 
100  delete m_symbs[i];
101  m_symbs.erase(m_symbs.begin() + i);
102 }
103 
104 void te::qt::widgets::Symbol::swapSymbolizers(const std::size_t& first, const std::size_t& second)
105 {
106  assert(first < m_symbs.size());
107  assert(second < m_symbs.size());
108 
109  if(first == second)
110  return;
111 
112  // Swapping...
113  te::se::Symbolizer* symb = m_symbs[first];
114  m_symbs[first] = m_symbs[second];
115  m_symbs[second] = symb;
116 }
117 
119 {
120  return new Symbol(*this);
121 }
te::se::Symbolizer * getSymbolizer(const std::size_t &i) const
It returns the n-th Symbolizer.
Definition: Symbol.cpp:63
void setInfo(const SymbolInfo &info)
It sets the information associated to the symbol.
Definition: Symbol.cpp:53
This class represents a symbol.
std::size_t getSymbolizersCount() const
It returns the number of Symbolizers that compose of the symbol.
Definition: Symbol.cpp:58
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:70
const SymbolInfo & getInfo() const
It return the information associated to the symbol.
Definition: Symbol.cpp:48
void setSymbolizer(const std::size_t &i, te::se::Symbolizer *symb)
It sets the given Symbolizer at the given position.
Definition: Symbol.cpp:87
~Symbol()
Destructor.
Definition: Symbol.cpp:43
void removeSymbolizer(const std::size_t &i)
It removes the specified Symbolizer from the list of Symbolizers of the symbol.
Definition: Symbol.cpp:96
SymbolInfo m_info
Information about the symbol.
Definition: Symbol.h:167
void swapSymbolizers(const std::size_t &first, const std::size_t &second)
It swaps the position of the Symbolizers.
Definition: Symbol.cpp:104
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:118
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It returns the list of Symbolizers that compose the symbol.
Definition: Symbol.cpp:75
std::vector< te::se::Symbolizer * > m_symbs
Set of symbolizers that compose the symbol.
Definition: Symbol.h:168
Symbol()
Default constructor.
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:80