added PenJoin, PenCap and PathSym into our protobuf format, into Pen::Info structure and wrote deserialization code.

This commit is contained in:
rachytski 2013-01-03 15:43:00 +03:00 committed by Alex Zolotarev
parent a5967d3132
commit ce69b03937
11 changed files with 2880 additions and 719 deletions

View file

@ -20,33 +20,45 @@ namespace graphics
m_fastSolidPath(params.m_fastSolidPath)
{}
void PathRenderer::drawPath(m2::PointD const * points, size_t pointsCount, double offset, uint32_t resID, double depth)
void PathRenderer::drawPath(m2::PointD const * pts, size_t ptsCount, double offset, uint32_t resID, double depth)
{
++m_pathCount;
m_pointsCount += pointsCount;
m_pointsCount += ptsCount;
if (!m_drawPathes)
return;
ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
ASSERT_GREATER_OR_EQUAL(ptsCount, 2, ());
ASSERT_NOT_EQUAL(resID, uint32_t(-1), ());
Resource const * res(base_t::fromID(resID));
Resource const * res = base_t::fromID(resID);
if (res == 0)
{
LOG(LINFO, ("drawPath: resID=", resID, " wasn't found on current skin"));
LOG(LINFO, ("drawPath: resID=", resID, "wasn't found on current skin"));
return;
}
ASSERT(res->m_cat == Resource::EPen, ());
Pen const * pen = static_cast<Pen const *>(res);
if (m_fastSolidPath && pen->m_isSolid)
{
drawFastSolidPath(points, pointsCount, resID, depth);
return;
}
if (!pen->m_info.m_symbol.empty())
drawSymbolPath(pts, ptsCount, offset, pen, depth);
else
if (m_fastSolidPath && pen->m_isSolid)
drawSolidPath(pts, ptsCount, offset, pen, depth);
else
drawStipplePath(pts, ptsCount, offset, pen, depth);
}
void PathRenderer::drawSymbolPath(m2::PointD const * pts, size_t ptsCount, double offset, Pen const * pen, double depth)
{
LOG(LINFO, ("drawSymbolPath is unimplemented. symbolName=", pen->m_info.m_symbol));
}
void PathRenderer::drawStipplePath(m2::PointD const * points, size_t pointsCount, double offset, Pen const * pen, double depth)
{
float rawTileStartLen = 0;
float rawTileLen = (float)pen->rawTileLen();
@ -94,7 +106,7 @@ namespace graphics
/// Length of the actual pattern data being tiling(without antialiasing zones).
rawTileLen = 0;
GeometryPipeline & p = pipeline(res->m_pipelineID);
GeometryPipeline & p = pipeline(pen->m_pipelineID);
shared_ptr<gl::BaseTexture> texture = p.texture();
@ -243,14 +255,8 @@ namespace graphics
}
}
void PathRenderer::drawFastSolidPath(m2::PointD const * points, size_t pointsCount, uint32_t resID, double depth)
void PathRenderer::drawSolidPath(m2::PointD const * points, size_t pointsCount, double offset, Pen const * pen, double depth)
{
ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
Resource const * res(base_t::fromID(resID));
ASSERT(res->m_cat == Resource::EPen, ());
Pen const * pen = static_cast<Pen const *>(res);
ASSERT(pen->m_isSolid, ());
for (size_t i = 0; i < pointsCount - 1; ++i)
@ -289,7 +295,7 @@ namespace graphics
nextPt + fDir - fNorm
};
GeometryPipeline & p = pipeline(res->m_pipelineID);
GeometryPipeline & p = pipeline(pen->m_pipelineID);
shared_ptr<gl::BaseTexture> texture = p.texture();

View file

@ -5,6 +5,8 @@
namespace graphics
{
class Pen;
class PathRenderer : public AreaRenderer
{
private:
@ -14,7 +16,9 @@ namespace graphics
bool m_drawPathes;
bool m_fastSolidPath;
void drawFastSolidPath(m2::PointD const * points, size_t pointsCount, uint32_t resID, double depth);
void drawSolidPath(m2::PointD const * pts, size_t ptsCount, double offset, Pen const * pen, double depth);
void drawStipplePath(m2::PointD const * pts, size_t ptsCount, double offset, Pen const * pen, double depth);
void drawSymbolPath(m2::PointD const * pts, size_t ptsCount, double offset, Pen const * pen, double depth);
public:
@ -29,7 +33,7 @@ namespace graphics
PathRenderer(Params const & params);
void drawPath(m2::PointD const * points, size_t pointsCount, double offset, uint32_t resID, double depth);
void drawPath(m2::PointD const * pts, size_t ptsCount, double offset, uint32_t resID, double depth);
void beginFrame();
void endFrame();

View file

@ -11,82 +11,95 @@
namespace graphics
{
Pen::Info::Info()
: Resource::Info(EPen)
{}
Pen::Info::Info(Color const & color,
double w,
double const * pattern,
size_t patternSize,
double offset)
double offset,
char const * symbol,
double step,
ELineJoin join,
ELineCap cap)
: Resource::Info(EPen),
m_color(color),
m_w(w),
m_offset(offset),
m_step(step),
m_join(join),
m_cap(cap),
m_isSolid(false)
{
if (symbol != 0)
m_symbol = string(symbol);
if (m_w < 1.0)
m_w = 1.0;
/// if pattern is solid
if ((pattern == 0 ) || (patternSize == 0))
m_isSolid = true;
if (!m_symbol.empty())
{
m_isSolid = false;
}
else
{
buffer_vector<double, 4> tmpV;
copy(pattern, pattern + patternSize, back_inserter(tmpV));
if (tmpV.size() % 2)
tmpV.push_back(0);
double length = 0;
/// ensuring that a minimal element has a length of 2px
for (size_t i = 0; i < tmpV.size(); ++i)
/// if pattern is solid
if ((pattern == 0 ) || (patternSize == 0))
m_isSolid = true;
else
{
if ((tmpV[i] < 2) && (tmpV[i] > 0))
tmpV[i] = 2;
length += tmpV[i];
}
buffer_vector<double, 4> tmpV;
copy(pattern, pattern + patternSize, back_inserter(tmpV));
int i = 0;
if (tmpV.size() % 2)
tmpV.push_back(0);
buffer_vector<double, 4> vec;
double length = 0;
if ((offset >= length) || (offset < 0))
offset -= floor(offset / length) * length;
double curLen = 0;
/// shifting pattern
while (true)
{
if (curLen + tmpV[i] > offset)
/// ensuring that a minimal element has a length of 2px
for (size_t i = 0; i < tmpV.size(); ++i)
{
//we're inside, let's split the pattern
if (i % 2 == 1)
vec.push_back(0);
vec.push_back(curLen + tmpV[i] - offset);
copy(tmpV.begin() + i + 1, tmpV.end(), back_inserter(vec));
copy(tmpV.begin(), tmpV.begin() + i, back_inserter(vec));
vec.push_back(offset - curLen);
if (i % 2 == 0)
vec.push_back(0);
break;
if ((tmpV[i] < 2) && (tmpV[i] > 0))
tmpV[i] = 2;
length += tmpV[i];
}
else
curLen += tmpV[i++];
}
int periods = max(int((256 - 4) / length), 1);
m_pat.reserve(periods * vec.size());
for (int i = 0; i < periods; ++i)
copy(vec.begin(), vec.end(), back_inserter(m_pat));
int i = 0;
buffer_vector<double, 4> vec;
if ((offset >= length) || (offset < 0))
offset -= floor(offset / length) * length;
double curLen = 0;
/// shifting pattern
while (true)
{
if (curLen + tmpV[i] > offset)
{
//we're inside, let's split the pattern
if (i % 2 == 1)
vec.push_back(0);
vec.push_back(curLen + tmpV[i] - offset);
copy(tmpV.begin() + i + 1, tmpV.end(), back_inserter(vec));
copy(tmpV.begin(), tmpV.begin() + i, back_inserter(vec));
vec.push_back(offset - curLen);
if (i % 2 == 0)
vec.push_back(0);
break;
}
else
curLen += tmpV[i++];
}
int periods = max(int((256 - 4) / length), 1);
m_pat.reserve(periods * vec.size());
for (int i = 0; i < periods; ++i)
copy(vec.begin(), vec.end(), back_inserter(m_pat));
}
}
}
@ -158,6 +171,14 @@ namespace graphics
for (size_t i = 0; i < m_pat.size(); ++i)
if (m_pat[i] != rp->m_pat[i])
return m_pat[i] < rp->m_pat[i];
if (m_join != rp->m_join)
return m_join < rp->m_join;
if (m_cap != rp->m_cap)
return m_cap < rp->m_cap;
if (m_symbol != rp->m_symbol)
return m_symbol < rp->m_symbol;
if (m_step != rp->m_step)
return m_step < rp->m_step;
return false;
}

View file

@ -15,20 +15,39 @@ namespace graphics
/// used as a texture-cache-key
struct Info : public Resource::Info
{
enum ELineJoin
{
ERoundJoin,
EBevelJoin
};
enum ELineCap
{
ERoundCap,
EButtCap
};
typedef buffer_vector<double, 16> TPattern;
Color m_color;
double m_w;
TPattern m_pat;
double m_offset;
string m_symbol;
double m_step;
ELineJoin m_join;
ELineCap m_cap;
bool m_isSolid;
Info();
Info(Color const & color,
double width,
double const * pattern,
size_t patternSize,
double offset);
Info(Color const & color = Color(0, 0, 0, 255),
double width = 1.0,
double const * pattern = 0,
size_t patternSize = 0,
double offset = 0,
char const * symbol = 0,
double step = 0,
ELineJoin join = ERoundJoin,
ELineCap cap = ERoundCap);
double firstDashOffset() const;
bool atDashOffset(double offset) const;

View file

@ -184,6 +184,12 @@ namespace
m_line.set_width(r.width());
if (r.has_dashdot())
*(m_line.mutable_dashdot()) = r.dashdot();
if (r.has_pathsym())
*(m_line.mutable_pathsym()) = r.pathsym();
if (r.has_join())
m_line.set_join(r.join());
if (r.has_cap())
m_line.set_cap(r.cap());
}
virtual LineDefProto const * GetLine() const { return &m_line; }

File diff suppressed because it is too large Load diff

View file

@ -31,6 +31,7 @@ void protobuf_AssignDesc_drules_5fstruct_2eproto();
void protobuf_ShutdownFile_drules_5fstruct_2eproto();
class DashDotProto;
class PathSymProto;
class LineRuleProto;
class LineDefProto;
class AreaRuleProto;
@ -43,6 +44,44 @@ class DrawElementProto;
class ClassifElementProto;
class ContainerProto;
enum LineJoin {
ROUNDJOIN = 0,
BEVELJOIN = 1
};
bool LineJoin_IsValid(int value);
const LineJoin LineJoin_MIN = ROUNDJOIN;
const LineJoin LineJoin_MAX = BEVELJOIN;
const int LineJoin_ARRAYSIZE = LineJoin_MAX + 1;
const ::google::protobuf::EnumDescriptor* LineJoin_descriptor();
inline const ::std::string& LineJoin_Name(LineJoin value) {
return ::google::protobuf::internal::NameOfEnum(
LineJoin_descriptor(), value);
}
inline bool LineJoin_Parse(
const ::std::string& name, LineJoin* value) {
return ::google::protobuf::internal::ParseNamedEnum<LineJoin>(
LineJoin_descriptor(), name, value);
}
enum LineCap {
ROUNDCAP = 0,
BUTTCAP = 1
};
bool LineCap_IsValid(int value);
const LineCap LineCap_MIN = ROUNDCAP;
const LineCap LineCap_MAX = BUTTCAP;
const int LineCap_ARRAYSIZE = LineCap_MAX + 1;
const ::google::protobuf::EnumDescriptor* LineCap_descriptor();
inline const ::std::string& LineCap_Name(LineCap value) {
return ::google::protobuf::internal::NameOfEnum(
LineCap_descriptor(), value);
}
inline bool LineCap_Parse(
const ::std::string& name, LineCap* value) {
return ::google::protobuf::internal::ParseNamedEnum<LineCap>(
LineCap_descriptor(), name, value);
}
// ===================================================================
class DashDotProto : public ::google::protobuf::Message {
@ -140,6 +179,112 @@ class DashDotProto : public ::google::protobuf::Message {
};
// -------------------------------------------------------------------
class PathSymProto : public ::google::protobuf::Message {
public:
PathSymProto();
virtual ~PathSymProto();
PathSymProto(const PathSymProto& from);
inline PathSymProto& operator=(const PathSymProto& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const PathSymProto& default_instance();
void Swap(PathSymProto* other);
// implements Message ----------------------------------------------
PathSymProto* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const PathSymProto& from);
void MergeFrom(const PathSymProto& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// required string name = 1;
inline bool has_name() const;
inline void clear_name();
static const int kNameFieldNumber = 1;
inline const ::std::string& name() const;
inline void set_name(const ::std::string& value);
inline void set_name(const char* value);
inline void set_name(const char* value, size_t size);
inline ::std::string* mutable_name();
inline ::std::string* release_name();
// required double step = 2;
inline bool has_step() const;
inline void clear_step();
static const int kStepFieldNumber = 2;
inline double step() const;
inline void set_step(double value);
// optional double offset = 3;
inline bool has_offset() const;
inline void clear_offset();
static const int kOffsetFieldNumber = 3;
inline double offset() const;
inline void set_offset(double value);
// @@protoc_insertion_point(class_scope:PathSymProto)
private:
inline void set_has_name();
inline void clear_has_name();
inline void set_has_step();
inline void clear_has_step();
inline void set_has_offset();
inline void clear_has_offset();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::std::string* name_;
double step_;
double offset_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void protobuf_AddDesc_drules_5fstruct_2eproto();
friend void protobuf_AssignDesc_drules_5fstruct_2eproto();
friend void protobuf_ShutdownFile_drules_5fstruct_2eproto();
void InitAsDefaultInstance();
static PathSymProto* default_instance_;
};
// -------------------------------------------------------------------
class LineRuleProto : public ::google::protobuf::Message {
public:
LineRuleProto();
@ -223,6 +368,28 @@ class LineRuleProto : public ::google::protobuf::Message {
inline ::google::protobuf::int32 priority() const;
inline void set_priority(::google::protobuf::int32 value);
// optional .PathSymProto pathsym = 5;
inline bool has_pathsym() const;
inline void clear_pathsym();
static const int kPathsymFieldNumber = 5;
inline const ::PathSymProto& pathsym() const;
inline ::PathSymProto* mutable_pathsym();
inline ::PathSymProto* release_pathsym();
// optional .LineJoin join = 6;
inline bool has_join() const;
inline void clear_join();
static const int kJoinFieldNumber = 6;
inline LineJoin join() const;
inline void set_join(LineJoin value);
// optional .LineCap cap = 7;
inline bool has_cap() const;
inline void clear_cap();
static const int kCapFieldNumber = 7;
inline LineCap cap() const;
inline void set_cap(LineCap value);
// @@protoc_insertion_point(class_scope:LineRuleProto)
private:
inline void set_has_width();
@ -233,6 +400,12 @@ class LineRuleProto : public ::google::protobuf::Message {
inline void clear_has_dashdot();
inline void set_has_priority();
inline void clear_has_priority();
inline void set_has_pathsym();
inline void clear_has_pathsym();
inline void set_has_join();
inline void clear_has_join();
inline void set_has_cap();
inline void clear_has_cap();
::google::protobuf::UnknownFieldSet _unknown_fields_;
@ -240,9 +413,12 @@ class LineRuleProto : public ::google::protobuf::Message {
::DashDotProto* dashdot_;
::google::protobuf::uint32 color_;
::google::protobuf::int32 priority_;
::PathSymProto* pathsym_;
int join_;
int cap_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(7 + 31) / 32];
friend void protobuf_AddDesc_drules_5fstruct_2eproto();
friend void protobuf_AssignDesc_drules_5fstruct_2eproto();
@ -329,6 +505,28 @@ class LineDefProto : public ::google::protobuf::Message {
inline ::DashDotProto* mutable_dashdot();
inline ::DashDotProto* release_dashdot();
// optional .PathSymProto pathsym = 4;
inline bool has_pathsym() const;
inline void clear_pathsym();
static const int kPathsymFieldNumber = 4;
inline const ::PathSymProto& pathsym() const;
inline ::PathSymProto* mutable_pathsym();
inline ::PathSymProto* release_pathsym();
// optional .LineJoin join = 6;
inline bool has_join() const;
inline void clear_join();
static const int kJoinFieldNumber = 6;
inline LineJoin join() const;
inline void set_join(LineJoin value);
// optional .LineCap cap = 7;
inline bool has_cap() const;
inline void clear_cap();
static const int kCapFieldNumber = 7;
inline LineCap cap() const;
inline void set_cap(LineCap value);
// @@protoc_insertion_point(class_scope:LineDefProto)
private:
inline void set_has_width();
@ -337,15 +535,24 @@ class LineDefProto : public ::google::protobuf::Message {
inline void clear_has_color();
inline void set_has_dashdot();
inline void clear_has_dashdot();
inline void set_has_pathsym();
inline void clear_has_pathsym();
inline void set_has_join();
inline void clear_has_join();
inline void set_has_cap();
inline void clear_has_cap();
::google::protobuf::UnknownFieldSet _unknown_fields_;
double width_;
::DashDotProto* dashdot_;
::google::protobuf::uint32 color_;
int join_;
::PathSymProto* pathsym_;
int cap_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
friend void protobuf_AddDesc_drules_5fstruct_2eproto();
friend void protobuf_AssignDesc_drules_5fstruct_2eproto();
@ -1376,6 +1583,112 @@ inline void DashDotProto::set_offset(double value) {
// -------------------------------------------------------------------
// PathSymProto
// required string name = 1;
inline bool PathSymProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void PathSymProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
inline void PathSymProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
inline void PathSymProto::clear_name() {
if (name_ != &::google::protobuf::internal::kEmptyString) {
name_->clear();
}
clear_has_name();
}
inline const ::std::string& PathSymProto::name() const {
return *name_;
}
inline void PathSymProto::set_name(const ::std::string& value) {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
}
name_->assign(value);
}
inline void PathSymProto::set_name(const char* value) {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
}
name_->assign(value);
}
inline void PathSymProto::set_name(const char* value, size_t size) {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
}
name_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* PathSymProto::mutable_name() {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
}
return name_;
}
inline ::std::string* PathSymProto::release_name() {
clear_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
return NULL;
} else {
::std::string* temp = name_;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
return temp;
}
}
// required double step = 2;
inline bool PathSymProto::has_step() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void PathSymProto::set_has_step() {
_has_bits_[0] |= 0x00000002u;
}
inline void PathSymProto::clear_has_step() {
_has_bits_[0] &= ~0x00000002u;
}
inline void PathSymProto::clear_step() {
step_ = 0;
clear_has_step();
}
inline double PathSymProto::step() const {
return step_;
}
inline void PathSymProto::set_step(double value) {
set_has_step();
step_ = value;
}
// optional double offset = 3;
inline bool PathSymProto::has_offset() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void PathSymProto::set_has_offset() {
_has_bits_[0] |= 0x00000004u;
}
inline void PathSymProto::clear_has_offset() {
_has_bits_[0] &= ~0x00000004u;
}
inline void PathSymProto::clear_offset() {
offset_ = 0;
clear_has_offset();
}
inline double PathSymProto::offset() const {
return offset_;
}
inline void PathSymProto::set_offset(double value) {
set_has_offset();
offset_ = value;
}
// -------------------------------------------------------------------
// LineRuleProto
// required double width = 1;
@ -1473,6 +1786,81 @@ inline void LineRuleProto::set_priority(::google::protobuf::int32 value) {
priority_ = value;
}
// optional .PathSymProto pathsym = 5;
inline bool LineRuleProto::has_pathsym() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void LineRuleProto::set_has_pathsym() {
_has_bits_[0] |= 0x00000010u;
}
inline void LineRuleProto::clear_has_pathsym() {
_has_bits_[0] &= ~0x00000010u;
}
inline void LineRuleProto::clear_pathsym() {
if (pathsym_ != NULL) pathsym_->::PathSymProto::Clear();
clear_has_pathsym();
}
inline const ::PathSymProto& LineRuleProto::pathsym() const {
return pathsym_ != NULL ? *pathsym_ : *default_instance_->pathsym_;
}
inline ::PathSymProto* LineRuleProto::mutable_pathsym() {
set_has_pathsym();
if (pathsym_ == NULL) pathsym_ = new ::PathSymProto;
return pathsym_;
}
inline ::PathSymProto* LineRuleProto::release_pathsym() {
clear_has_pathsym();
::PathSymProto* temp = pathsym_;
pathsym_ = NULL;
return temp;
}
// optional .LineJoin join = 6;
inline bool LineRuleProto::has_join() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void LineRuleProto::set_has_join() {
_has_bits_[0] |= 0x00000020u;
}
inline void LineRuleProto::clear_has_join() {
_has_bits_[0] &= ~0x00000020u;
}
inline void LineRuleProto::clear_join() {
join_ = 0;
clear_has_join();
}
inline LineJoin LineRuleProto::join() const {
return static_cast< LineJoin >(join_);
}
inline void LineRuleProto::set_join(LineJoin value) {
GOOGLE_DCHECK(LineJoin_IsValid(value));
set_has_join();
join_ = value;
}
// optional .LineCap cap = 7;
inline bool LineRuleProto::has_cap() const {
return (_has_bits_[0] & 0x00000040u) != 0;
}
inline void LineRuleProto::set_has_cap() {
_has_bits_[0] |= 0x00000040u;
}
inline void LineRuleProto::clear_has_cap() {
_has_bits_[0] &= ~0x00000040u;
}
inline void LineRuleProto::clear_cap() {
cap_ = 0;
clear_has_cap();
}
inline LineCap LineRuleProto::cap() const {
return static_cast< LineCap >(cap_);
}
inline void LineRuleProto::set_cap(LineCap value) {
GOOGLE_DCHECK(LineCap_IsValid(value));
set_has_cap();
cap_ = value;
}
// -------------------------------------------------------------------
// LineDefProto
@ -1550,6 +1938,81 @@ inline ::DashDotProto* LineDefProto::release_dashdot() {
return temp;
}
// optional .PathSymProto pathsym = 4;
inline bool LineDefProto::has_pathsym() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void LineDefProto::set_has_pathsym() {
_has_bits_[0] |= 0x00000008u;
}
inline void LineDefProto::clear_has_pathsym() {
_has_bits_[0] &= ~0x00000008u;
}
inline void LineDefProto::clear_pathsym() {
if (pathsym_ != NULL) pathsym_->::PathSymProto::Clear();
clear_has_pathsym();
}
inline const ::PathSymProto& LineDefProto::pathsym() const {
return pathsym_ != NULL ? *pathsym_ : *default_instance_->pathsym_;
}
inline ::PathSymProto* LineDefProto::mutable_pathsym() {
set_has_pathsym();
if (pathsym_ == NULL) pathsym_ = new ::PathSymProto;
return pathsym_;
}
inline ::PathSymProto* LineDefProto::release_pathsym() {
clear_has_pathsym();
::PathSymProto* temp = pathsym_;
pathsym_ = NULL;
return temp;
}
// optional .LineJoin join = 6;
inline bool LineDefProto::has_join() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void LineDefProto::set_has_join() {
_has_bits_[0] |= 0x00000010u;
}
inline void LineDefProto::clear_has_join() {
_has_bits_[0] &= ~0x00000010u;
}
inline void LineDefProto::clear_join() {
join_ = 0;
clear_has_join();
}
inline LineJoin LineDefProto::join() const {
return static_cast< LineJoin >(join_);
}
inline void LineDefProto::set_join(LineJoin value) {
GOOGLE_DCHECK(LineJoin_IsValid(value));
set_has_join();
join_ = value;
}
// optional .LineCap cap = 7;
inline bool LineDefProto::has_cap() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void LineDefProto::set_has_cap() {
_has_bits_[0] |= 0x00000020u;
}
inline void LineDefProto::clear_has_cap() {
_has_bits_[0] &= ~0x00000020u;
}
inline void LineDefProto::clear_cap() {
cap_ = 0;
clear_has_cap();
}
inline LineCap LineDefProto::cap() const {
return static_cast< LineCap >(cap_);
}
inline void LineDefProto::set_cap(LineCap value) {
GOOGLE_DCHECK(LineCap_IsValid(value));
set_has_cap();
cap_ = value;
}
// -------------------------------------------------------------------
// AreaRuleProto
@ -2389,6 +2852,14 @@ ContainerProto::mutable_cont() {
namespace google {
namespace protobuf {
template <>
inline const EnumDescriptor* GetEnumDescriptor< LineJoin>() {
return LineJoin_descriptor();
}
template <>
inline const EnumDescriptor* GetEnumDescriptor< LineCap>() {
return LineCap_descriptor();
}
} // namespace google
} // namespace protobuf

View file

@ -6,12 +6,34 @@ message DashDotProto
optional double offset = 2;
}
message PathSymProto
{
required string name = 1;
required double step = 2;
optional double offset = 3;
}
enum LineJoin
{
ROUNDJOIN = 0;
BEVELJOIN = 1;
}
enum LineCap
{
ROUNDCAP = 0;
BUTTCAP = 1;
}
message LineRuleProto
{
required double width = 1;
required uint32 color = 2;
optional DashDotProto dashdot = 3;
required int32 priority = 4;
optional PathSymProto pathsym = 5;
optional LineJoin join = 6;
optional LineCap cap = 7;
}
message LineDefProto
@ -19,6 +41,9 @@ message LineDefProto
required double width = 1;
required uint32 color = 2;
optional DashDotProto dashdot = 3;
optional PathSymProto pathsym = 4;
optional LineJoin join = 6;
optional LineCap cap = 7;
}
message AreaRuleProto

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -23,7 +23,6 @@ namespace
}
}
void ConvertStyle(LineDefProto const * pSrc, double scale, graphics::Pen::Info & dest)
{
double offset = 0.0;
@ -46,6 +45,45 @@ void ConvertStyle(LineDefProto const * pSrc, double scale, graphics::Pen::Info &
ConvertColor(pSrc->color()),
ConvertWidth(pSrc->width(), scale),
v.empty() ? 0 : &v[0], v.size(), offset);
if (pSrc->has_pathsym())
{
PathSymProto const & ps = pSrc->pathsym();
dest.m_step = ps.step();
dest.m_symbol = ps.name();
dest.m_offset = ps.offset();
}
if (pSrc->has_join())
{
switch (pSrc->join())
{
case ROUNDJOIN:
dest.m_join = graphics::Pen::Info::ERoundJoin;
break;
case BEVELJOIN:
dest.m_join = graphics::Pen::Info::EBevelJoin;
break;
default:
break;
}
}
if (pSrc->has_cap())
{
switch (pSrc->cap())
{
case ROUNDCAP:
dest.m_cap = graphics::Pen::Info::ERoundCap;
break;
case BUTTCAP:
dest.m_cap = graphics::Pen::Info::EButtCap;
break;
default:
break;
}
}
}
void ConvertStyle(AreaRuleProto const * pSrc, graphics::Brush::Info & dest)