added anchor and displacement to text_symbolizer
This commit is contained in:
parent
cba1063346
commit
89cad86d8e
4 changed files with 148 additions and 67 deletions
|
@ -21,8 +21,6 @@
|
||||||
#ifndef LINE_SYMBOLIZER_HPP
|
#ifndef LINE_SYMBOLIZER_HPP
|
||||||
#define LINE_SYMBOLIZER_HPP
|
#define LINE_SYMBOLIZER_HPP
|
||||||
|
|
||||||
|
|
||||||
//#include "symbolizer.hpp"
|
|
||||||
#include "stroke.hpp"
|
#include "stroke.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
#ifndef TEXT_SYMBOLIZER_HPP
|
#ifndef TEXT_SYMBOLIZER_HPP
|
||||||
#define TEXT_SYMBOLIZER_HPP
|
#define TEXT_SYMBOLIZER_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
#include "color.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
enum label_placement_e {
|
enum label_placement_e {
|
||||||
|
@ -28,72 +32,26 @@ namespace mapnik
|
||||||
line_placement=2
|
line_placement=2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef boost::tuple<double,double> position;
|
||||||
|
|
||||||
struct text_symbolizer
|
struct text_symbolizer
|
||||||
{
|
{
|
||||||
text_symbolizer(std::string const& name,unsigned size,Color const& fill)
|
text_symbolizer(std::string const& name,unsigned size,Color const& fill);
|
||||||
: name_(name),
|
text_symbolizer(text_symbolizer const& rhs);
|
||||||
size_(size),
|
text_symbolizer& operator=(text_symbolizer const& rhs);
|
||||||
fill_(fill),
|
std::string const& get_name() const;
|
||||||
halo_fill_(Color(255,255,255)),
|
unsigned get_text_size() const;
|
||||||
halo_radius_(0),
|
Color const& get_fill() const;
|
||||||
label_p_(point_placement) {}
|
void set_halo_fill(Color const& fill);
|
||||||
|
Color const& get_halo_fill() const;
|
||||||
text_symbolizer(text_symbolizer const& rhs)
|
void set_halo_radius(unsigned radius);
|
||||||
: name_(rhs.name_),
|
unsigned get_halo_radius() const;
|
||||||
size_(rhs.size_),
|
void set_label_placement(label_placement_e label_p);
|
||||||
fill_(rhs.fill_),
|
label_placement_e get_label_placement() const;
|
||||||
halo_fill_(rhs.halo_fill_),
|
void set_anchor(double x, double y);
|
||||||
halo_radius_(rhs.halo_radius_),
|
position const& get_anchor() const;
|
||||||
label_p_(rhs.label_p_) {}
|
void set_displacement(double x, double y);
|
||||||
|
position const& get_displacement() const;
|
||||||
~text_symbolizer()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
std::string const& get_name() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned get_text_size() const
|
|
||||||
{
|
|
||||||
return size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color const& get_fill() const
|
|
||||||
{
|
|
||||||
return fill_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_halo_fill(Color const& fill)
|
|
||||||
{
|
|
||||||
halo_fill_ = fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color const& get_halo_fill() const
|
|
||||||
{
|
|
||||||
return halo_fill_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_halo_radius(unsigned radius)
|
|
||||||
{
|
|
||||||
halo_radius_ = radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned get_halo_radius() const
|
|
||||||
{
|
|
||||||
return halo_radius_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_label_placement(label_placement_e label_p)
|
|
||||||
{
|
|
||||||
label_p_ = label_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
label_placement_e get_label_placement() const
|
|
||||||
{
|
|
||||||
return label_p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name_;
|
std::string name_;
|
||||||
|
@ -102,6 +60,8 @@ namespace mapnik
|
||||||
Color halo_fill_;
|
Color halo_fill_;
|
||||||
unsigned halo_radius_;
|
unsigned halo_radius_;
|
||||||
label_placement_e label_p_;
|
label_placement_e label_p_;
|
||||||
|
position anchor_;
|
||||||
|
position displacement_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,11 @@ source = Split(
|
||||||
point_symbolizer.cpp
|
point_symbolizer.cpp
|
||||||
polygon_pattern_symbolizer.cpp
|
polygon_pattern_symbolizer.cpp
|
||||||
line_pattern_symbolizer.cpp
|
line_pattern_symbolizer.cpp
|
||||||
|
text_symbolizer.cpp
|
||||||
font_engine_freetype.cpp
|
font_engine_freetype.cpp
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
#render.cpp
|
|
||||||
#line_symbolizer.cpp
|
#line_symbolizer.cpp
|
||||||
# line_pattern_symbolizer.cpp
|
# line_pattern_symbolizer.cpp
|
||||||
# polygon_symbolizer.cpp
|
# polygon_symbolizer.cpp
|
||||||
|
|
122
src/text_symbolizer.cpp
Normal file
122
src/text_symbolizer.cpp
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#include "text_symbolizer.hpp"
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
text_symbolizer::text_symbolizer(std::string const& name,unsigned size,Color const& fill)
|
||||||
|
: name_(name),
|
||||||
|
size_(size),
|
||||||
|
fill_(fill),
|
||||||
|
halo_fill_(Color(255,255,255)),
|
||||||
|
halo_radius_(0),
|
||||||
|
label_p_(point_placement),
|
||||||
|
anchor_(0.0,0.5),
|
||||||
|
displacement_(0.0,0.0) {}
|
||||||
|
|
||||||
|
text_symbolizer::text_symbolizer(text_symbolizer const& rhs)
|
||||||
|
: name_(rhs.name_),
|
||||||
|
size_(rhs.size_),
|
||||||
|
fill_(rhs.fill_),
|
||||||
|
halo_fill_(rhs.halo_fill_),
|
||||||
|
halo_radius_(rhs.halo_radius_),
|
||||||
|
label_p_(rhs.label_p_),
|
||||||
|
anchor_(rhs.anchor_),
|
||||||
|
displacement_(rhs.displacement_) {}
|
||||||
|
|
||||||
|
text_symbolizer& text_symbolizer::operator=(text_symbolizer const& other)
|
||||||
|
{
|
||||||
|
if (this == &other)
|
||||||
|
return *this;
|
||||||
|
name_ = other.name_;
|
||||||
|
size_ = other.size_;
|
||||||
|
fill_ = other.fill_;
|
||||||
|
halo_fill_ = other.halo_fill_;
|
||||||
|
label_p_ = other.label_p_;
|
||||||
|
anchor_ = other.anchor_;
|
||||||
|
displacement_ = other.displacement_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const& text_symbolizer::get_name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned text_symbolizer::get_text_size() const
|
||||||
|
{
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color const& text_symbolizer::get_fill() const
|
||||||
|
{
|
||||||
|
return fill_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text_symbolizer::set_halo_fill(Color const& fill)
|
||||||
|
{
|
||||||
|
halo_fill_ = fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color const& text_symbolizer::get_halo_fill() const
|
||||||
|
{
|
||||||
|
return halo_fill_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text_symbolizer::set_halo_radius(unsigned radius)
|
||||||
|
{
|
||||||
|
halo_radius_ = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned text_symbolizer::get_halo_radius() const
|
||||||
|
{
|
||||||
|
return halo_radius_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text_symbolizer::set_label_placement(label_placement_e label_p)
|
||||||
|
{
|
||||||
|
label_p_ = label_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
label_placement_e text_symbolizer::get_label_placement() const
|
||||||
|
{
|
||||||
|
return label_p_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text_symbolizer::set_anchor(double x, double y)
|
||||||
|
{
|
||||||
|
anchor_ = boost::make_tuple(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
position const& text_symbolizer::get_anchor () const
|
||||||
|
{
|
||||||
|
return anchor_;
|
||||||
|
}
|
||||||
|
void text_symbolizer::set_displacement(double x, double y)
|
||||||
|
{
|
||||||
|
displacement_ = boost::make_tuple(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
position const& text_symbolizer::get_displacement() const
|
||||||
|
{
|
||||||
|
return displacement_;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue