All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Layer.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 Layer.cpp
22 
23  \brief A Layer is a reference to a virtual dataset with/without geometric attributes.
24 */
25 
26 // TerraLib
27 #include "../../geometry/Envelope.h"
28 #include "../../se/FeatureTypeStyle.h"
29 #include "../../se/Style.h"
30 #include "../core/AbstractGraph.h"
31 #include "../core/GraphMetadata.h"
32 #include "Layer.h"
33 #include "LayerRenderer.h"
34 
35 const std::string te::graph::Layer::sm_type("GRAPHLAYER");
36 
37 te::graph::Layer::Layer(const std::string& id, const std::string& title, AbstractLayer* parent) :
38  te::map::AbstractLayer(id, title, parent),
39  m_mbr(0),
40  m_style(0),
41 // m_srid(-1),
42  m_renderer(0)
43 {
44 }
45 
47 {
48 }
49 
50 const std::string& te::graph::Layer::getType() const
51 {
52  return sm_type;
53 }
54 
56 {
57  return true;
58 }
59 
60 void te::graph::Layer::draw(te::map::Canvas* canvas, const te::gm::Envelope& bbox, int srid)
61 {
62  assert(m_renderer.get());
63  m_renderer->draw(this, canvas, bbox, srid);
64 }
65 
67 {
68  return m_graph;
69 }
70 
72 {
73  m_graph = g;
74 
75  //set graph parameters
76  if(m_graph->getMetadata())
77  {
78  //this->setSRID(m_graph->getMetadata()->getSRID());
79  //this->setExtent(m_graph->getMetadata()->getEnvelope());
80  }
81 }
82 
84 {
85  return m_renderer.get();
86 }
87 
89 {
90  m_renderer.reset(renderer);
91 }
virtual void draw(te::map::Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the layer geographic objects in the given canvas using the informed SRS. ...
Definition: Layer.cpp:60
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:56
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: Layer.h:143
void setGraph(te::graph::AbstractGraph *ds)
It sets the graph associated to the layer.
Definition: Layer.cpp:71
virtual bool isValid() const
It returns true if the layer can be drawn, otherwise, it returns false.
Definition: Layer.cpp:55
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:91
Layer(const std::string &id, const std::string &title, AbstractLayer *parent=0)
It initializes a new Layer.
Definition: Layer.cpp:37
It renders the objects associated to a Layer.
~Layer()
Destructor.
Definition: Layer.cpp:46
LayerRenderer * getRenderer() const
It returns the renderer used to paint this layer.
Definition: Layer.cpp:83
void setRenderer(LayerRenderer *renderer)
It sets the renderer used to paint this layer.
Definition: Layer.cpp:88
virtual const std::string & getType() const
It returns the layer type.
Definition: Layer.cpp:50
te::graph::AbstractGraph * getGraph() const
It returns the graph associated to the layer.
Definition: Layer.cpp:66
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
It renders the objects associated to a Layer.
Definition: LayerRenderer.h:54