All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Graphic.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/se/Graphic.cpp
22 
23  \brief A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "AnchorPoint.h"
29 #include "Displacement.h"
30 #include "ExternalGraphic.h"
31 #include "Graphic.h"
32 #include "Mark.h"
33 #include "ParameterValue.h"
34 
35 // STL
36 #include <cassert>
37 
39  : m_opacity(0),
40  m_size(0),
41  m_rotation(0),
42  m_anchorPoint(0),
43  m_displacement(0)
44 {
45 }
46 
48 {
49  te::common::FreeContents(m_externalGraphics);
50  te::common::FreeContents(m_marks);
51 
52  delete m_opacity;
53  delete m_size;
54  delete m_rotation;
55  delete m_anchorPoint;
56  delete m_displacement;
57 }
58 
60 {
61  assert(g);
62  m_externalGraphics.push_back(g);
63 }
64 
66 {
67  assert(index < m_externalGraphics.size());
68 
69  assert(g);
70 
71  delete m_externalGraphics[index];
72 
73  m_externalGraphics[index] = g;
74 }
75 
76 const std::vector<te::se::ExternalGraphic*> te::se::Graphic::getExternalGraphics() const
77 {
78  return m_externalGraphics;
79 }
80 
82 {
83  assert(m);
84  m_marks.push_back(m);
85 }
86 
87 void te::se::Graphic::setMark(std::size_t index, Mark* m)
88 {
89  assert(index < m_marks.size());
90 
91  assert(m);
92 
93  delete m_marks[index];
94 
95  m_marks[index] = m;
96 }
97 
98 const std::vector<te::se::Mark*> te::se::Graphic::getMarks() const
99 {
100  return m_marks;
101 }
102 
104 {
105  delete m_opacity;
106  m_opacity = value;
107 }
108 
110 {
111  return m_opacity;
112 }
113 
115 {
116  delete m_size;
117  m_size = value;
118 }
119 
121 {
122  return m_size;
123 }
124 
126 {
127  delete m_rotation;
128  m_rotation = value;
129 }
130 
132 {
133  return m_rotation;
134 }
135 
137 {
138  delete m_anchorPoint;
139  m_anchorPoint = value;
140 }
141 
143 {
144  return m_anchorPoint;
145 }
146 
148 {
149  delete m_displacement;
150  m_displacement = value;
151 }
152 
154 {
155  return m_displacement;
156 }
157 
159 {
160  te::common::FreeContents(m_externalGraphics);
161  m_externalGraphics.clear();
162 
163  te::common::FreeContents(m_marks);
164  m_marks.clear();
165 }
166 
168 {
169  Graphic* graphic = new Graphic;
170 
171  for(std::size_t i = 0; i < m_externalGraphics.size(); ++i)
172  {
173  const ExternalGraphic* eg = m_externalGraphics[i];
174  if(eg)
175  graphic->add(eg->clone());
176  }
177 
178  for(std::size_t i = 0; i < m_marks.size(); ++i)
179  {
180  const Mark* m = m_marks[i];
181  if(m)
182  graphic->add(m->clone());
183  }
184 
185  if(m_opacity)
186  graphic->setOpacity(new ParameterValue(*m_opacity));
187 
188  if(m_size)
189  graphic->setSize(new ParameterValue(*m_size));
190 
191  if(m_rotation)
192  graphic->setRotation(new ParameterValue(*m_rotation));
193 
194  if(m_anchorPoint)
195  graphic->setAnchorPoint(m_anchorPoint->clone());
196 
197  if(m_displacement)
198  graphic->setDisplacement(m_displacement->clone());
199 
200  return graphic;
201 }
const ParameterValue * getRotation() const
Definition: Graphic.cpp:131
void setDisplacement(Displacement *value)
Definition: Graphic.cpp:147
void setRotation(ParameterValue *value)
The Rotation element gives the rotation of a graphic in the clockwise direction about its center poin...
Definition: Graphic.cpp:125
void setOpacity(ParameterValue *value)
The Opacity element gives the opacity to use for rendering the graphic. It has the same semantics as ...
Definition: Graphic.cpp:103
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
void setMark(std::size_t index, Mark *m)
Definition: Graphic.cpp:87
A Displacement gives X and Y offset displacements to use for rendering a text label, graphic or other Symbolizer near a point.
Definition: Displacement.h:58
const std::vector< ExternalGraphic * > getExternalGraphics() const
Definition: Graphic.cpp:76
void setSize(ParameterValue *value)
The Size element gives the absolute size of the graphic in uoms encoded as a floating-point number...
Definition: Graphic.cpp:114
void clear()
Clears the marks and the external graphics of this graphic.
Definition: Graphic.cpp:158
The ParameterValueType uses WFS-Filter expressions to give values for SE graphic parameters.
Graphic()
It initializes a new Graphic.
Definition: Graphic.cpp:38
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
void setExternalGraphic(std::size_t index, ExternalGraphic *g)
Definition: Graphic.cpp:65
const AnchorPoint * getAnchorPoint() const
Definition: Graphic.cpp:142
~Graphic()
Destructor.
Definition: Graphic.cpp:47
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
void add(ExternalGraphic *g)
Graphics can either be referenced from an external URL in a common format (such as GIF or SVG)...
Definition: Graphic.cpp:59
An AnchorPoint identifies the location inside of a text label to use an 'anchor' for positioning it r...
Definition: AnchorPoint.h:63
The ExternalGraphic allows a reference to be made to an external graphic file with a Web URL or to in...
Graphic * clone() const
It creates a new copy of this object.
Definition: Graphic.cpp:167
ExternalGraphic * clone() const
It creates a new copy of this object.
A Mark specifies a geometric shape and applies coloring to it.
const Displacement * getDisplacement() const
Definition: Graphic.cpp:153
const std::vector< Mark * > getMarks() const
Definition: Graphic.cpp:98
A Displacement gives X and Y offset displacements to use for rendering a text label, graphic or other Symbolizer near a point.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
An AnchorPoint identifies the location inside of a text label to use an 'anchor' for positioning it r...
Mark * clone() const
It creates a new copy of this object.
Definition: Mark.cpp:130
void setAnchorPoint(AnchorPoint *value)
Definition: Graphic.cpp:136
The ExternalGraphic allows a reference to be made to an external graphic file with a Web URL or to in...
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
const ParameterValue * getSize() const
Definition: Graphic.cpp:120
const ParameterValue * getOpacity() const
Definition: Graphic.cpp:109