PolygonUtils.h
Go to the documentation of this file.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* This file is part of the libmspub project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_POLYGONUTILS_H
#define INCLUDED_POLYGONUTILS_H
#include <functional>
#include <memory>
#include <vector>
#include <librevenge/librevenge.h>
#include "Coordinate.h"
#include "ShapeType.h"
namespace libmspub
{
const int PROP_ADJUST_VAL_FIRST = 327;
const int PROP_ADJUST_VAL_LAST = 336;
const int PROP_GEO_LEFT = 320;
const int PROP_GEO_TOP = 321;
const int PROP_GEO_RIGHT = 322;
const int PROP_GEO_BOTTOM = 323;
const int OTHER_CALC_VAL = 0x400;
const int ASPECT_RATIO = 0x600;
class VectorTransformation2D;
struct Color;
struct Line;
typedef struct
{
int m_x;
int m_y;
} Vertex;
typedef struct
{
int m_flags;
int m_argOne;
int m_argTwo;
int m_argThree;
} Calculation;
typedef struct
{
Vertex first;
Vertex second;
} TextRectangle;
struct CustomShape
{
const Vertex *mp_vertices;
unsigned m_numVertices;
const unsigned short *mp_elements;
unsigned m_numElements;
const Calculation *mp_calculations;
unsigned m_numCalculations;
const int *mp_defaultAdjustValues;
unsigned m_numDefaultAdjustValues;
const TextRectangle *mp_textRectangles;
unsigned m_numTextRectangles;
unsigned m_coordWidth;
unsigned m_coordHeight;
const Vertex *mp_gluePoints;
unsigned m_numGluePoints;
unsigned char m_adjustShiftMask;
CustomShape(const Vertex *p_vertices, unsigned numVertices, const unsigned short *p_elements, unsigned numElements, const Calculation *p_calculations, unsigned numCalculations, const int *p_defaultAdjustValues, unsigned numDefaultAdjustValues, const TextRectangle *p_textRectangles, unsigned numTextRectangles, unsigned coordWidth, unsigned coordHeight, const Vertex *p_gluePoints, unsigned numGluePoints, unsigned char adjustShiftMask = 0) :
mp_vertices(p_vertices), m_numVertices(numVertices),
mp_elements(p_elements), m_numElements(numElements),
mp_calculations(p_calculations), m_numCalculations(numCalculations),
mp_defaultAdjustValues(p_defaultAdjustValues), m_numDefaultAdjustValues(numDefaultAdjustValues),
mp_textRectangles(p_textRectangles), m_numTextRectangles(numTextRectangles),
m_coordWidth(coordWidth), m_coordHeight(coordHeight),
mp_gluePoints(p_gluePoints), m_numGluePoints(numGluePoints),
m_adjustShiftMask(adjustShiftMask)
{
}
};
struct DynamicCustomShape
{
std::vector<Vertex> m_vertices;
std::vector<unsigned short> m_elements;
std::vector<Calculation> m_calculations;
std::vector<int> m_defaultAdjustValues;
std::vector<TextRectangle> m_textRectangles;
std::vector<Vertex> m_gluePoints;
unsigned m_coordWidth;
unsigned m_coordHeight;
unsigned char m_adjustShiftMask;
DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
: m_vertices(), m_elements(),
m_calculations(), m_defaultAdjustValues(),
m_textRectangles(), m_gluePoints(),
m_coordWidth(coordWidth), m_coordHeight(coordHeight),
m_adjustShiftMask(0)
{
}
};
std::shared_ptr<const CustomShape> getFromDynamicCustomShape(const DynamicCustomShape &dcs);
const CustomShape *getCustomShape(ShapeType type);
bool isShapeTypeRectangle(ShapeType type);
librevenge::RVNGPropertyList calcClipPath(const std::vector<libmspub::Vertex> &verts, double x, double y, double height, double width, VectorTransformation2D transform, std::shared_ptr<const CustomShape> shape);
void writeCustomShape(ShapeType shapeType, librevenge::RVNGPropertyList &graphicsProps, librevenge::RVNGDrawingInterface *painter, double x, double y, double height, double width, bool closeEverything, VectorTransformation2D transform, std::vector<Line> lines, std::function<double(unsigned index)> calculator, const std::vector<Color> &palette, std::shared_ptr<const CustomShape> shape);
} // libmspub
#endif /* INCLUDED_POLYGONUTILS_H */
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Coordinate.h
ShapeType.h
libmspub::VectorTransformation2D
Definition VectorTransformation2D.h:26
libmspub
Definition Arrow.h:14
libmspub::PROP_GEO_BOTTOM
const int PROP_GEO_BOTTOM
Definition PolygonUtils.h:29
libmspub::PROP_GEO_RIGHT
const int PROP_GEO_RIGHT
Definition PolygonUtils.h:28
libmspub::calcClipPath
librevenge::RVNGPropertyList calcClipPath(const std::vector< Vertex > &verts, double x, double y, double height, double width, VectorTransformation2D transform, std::shared_ptr< const CustomShape > shape)
Definition PolygonUtils.cpp:5870
libmspub::PROP_GEO_TOP
const int PROP_GEO_TOP
Definition PolygonUtils.h:27
libmspub::ShapeType
ShapeType
Definition ShapeType.h:16
libmspub::PROP_ADJUST_VAL_FIRST
const int PROP_ADJUST_VAL_FIRST
Definition PolygonUtils.h:24
libmspub::writeCustomShape
void writeCustomShape(ShapeType shapeType, librevenge::RVNGPropertyList &graphicsProps, librevenge::RVNGDrawingInterface *painter, double x, double y, double height, double width, bool closeEverything, VectorTransformation2D transform, std::vector< Line > lines, std::function< double(unsigned index)> calculator, const std::vector< Color > &palette, std::shared_ptr< const CustomShape > shape)
Definition PolygonUtils.cpp:5895
libmspub::ASPECT_RATIO
const int ASPECT_RATIO
Definition PolygonUtils.h:32
libmspub::isShapeTypeRectangle
bool isShapeTypeRectangle(ShapeType type)
Definition PolygonUtils.cpp:6362
libmspub::getFromDynamicCustomShape
std::shared_ptr< const CustomShape > getFromDynamicCustomShape(const DynamicCustomShape &dcs)
Definition PolygonUtils.cpp:6368
libmspub::PROP_ADJUST_VAL_LAST
const int PROP_ADJUST_VAL_LAST
Definition PolygonUtils.h:25
libmspub::PROP_GEO_LEFT
const int PROP_GEO_LEFT
Definition PolygonUtils.h:26
libmspub::getCustomShape
const CustomShape * getCustomShape(ShapeType type)
Definition PolygonUtils.cpp:5245
libmspub::OTHER_CALC_VAL
const int OTHER_CALC_VAL
Definition PolygonUtils.h:31
libmspub::Calculation
Definition PolygonUtils.h:46
libmspub::Calculation::m_argOne
int m_argOne
Definition PolygonUtils.h:48
libmspub::Calculation::m_argTwo
int m_argTwo
Definition PolygonUtils.h:49
libmspub::Calculation::m_flags
int m_flags
Definition PolygonUtils.h:47
libmspub::Calculation::m_argThree
int m_argThree
Definition PolygonUtils.h:50
libmspub::Color
Definition MSPUBTypes.h:200
libmspub::CustomShape::mp_defaultAdjustValues
const int * mp_defaultAdjustValues
Definition PolygonUtils.h:67
libmspub::CustomShape::m_numDefaultAdjustValues
unsigned m_numDefaultAdjustValues
Definition PolygonUtils.h:68
libmspub::CustomShape::m_coordWidth
unsigned m_coordWidth
Definition PolygonUtils.h:71
libmspub::CustomShape::m_coordHeight
unsigned m_coordHeight
Definition PolygonUtils.h:72
libmspub::CustomShape::CustomShape
CustomShape(const Vertex *p_vertices, unsigned numVertices, const unsigned short *p_elements, unsigned numElements, const Calculation *p_calculations, unsigned numCalculations, const int *p_defaultAdjustValues, unsigned numDefaultAdjustValues, const TextRectangle *p_textRectangles, unsigned numTextRectangles, unsigned coordWidth, unsigned coordHeight, const Vertex *p_gluePoints, unsigned numGluePoints, unsigned char adjustShiftMask=0)
Definition PolygonUtils.h:77
libmspub::CustomShape::mp_vertices
const Vertex * mp_vertices
Definition PolygonUtils.h:61
libmspub::CustomShape::m_numGluePoints
unsigned m_numGluePoints
Definition PolygonUtils.h:74
libmspub::CustomShape::mp_gluePoints
const Vertex * mp_gluePoints
Definition PolygonUtils.h:73
libmspub::CustomShape::m_numElements
unsigned m_numElements
Definition PolygonUtils.h:64
libmspub::CustomShape::m_numVertices
unsigned m_numVertices
Definition PolygonUtils.h:62
libmspub::CustomShape::m_adjustShiftMask
unsigned char m_adjustShiftMask
Definition PolygonUtils.h:75
libmspub::CustomShape::m_numTextRectangles
unsigned m_numTextRectangles
Definition PolygonUtils.h:70
libmspub::CustomShape::mp_elements
const unsigned short * mp_elements
Definition PolygonUtils.h:63
libmspub::CustomShape::mp_calculations
const Calculation * mp_calculations
Definition PolygonUtils.h:65
libmspub::CustomShape::mp_textRectangles
const TextRectangle * mp_textRectangles
Definition PolygonUtils.h:69
libmspub::CustomShape::m_numCalculations
unsigned m_numCalculations
Definition PolygonUtils.h:66
libmspub::DynamicCustomShape::m_defaultAdjustValues
std::vector< int > m_defaultAdjustValues
Definition PolygonUtils.h:95
libmspub::DynamicCustomShape::m_coordHeight
unsigned m_coordHeight
Definition PolygonUtils.h:99
libmspub::DynamicCustomShape::m_adjustShiftMask
unsigned char m_adjustShiftMask
Definition PolygonUtils.h:100
libmspub::DynamicCustomShape::m_vertices
std::vector< Vertex > m_vertices
Definition PolygonUtils.h:92
libmspub::DynamicCustomShape::m_textRectangles
std::vector< TextRectangle > m_textRectangles
Definition PolygonUtils.h:96
libmspub::DynamicCustomShape::m_calculations
std::vector< Calculation > m_calculations
Definition PolygonUtils.h:94
libmspub::DynamicCustomShape::m_elements
std::vector< unsigned short > m_elements
Definition PolygonUtils.h:93
libmspub::DynamicCustomShape::m_gluePoints
std::vector< Vertex > m_gluePoints
Definition PolygonUtils.h:97
libmspub::DynamicCustomShape::m_coordWidth
unsigned m_coordWidth
Definition PolygonUtils.h:98
libmspub::DynamicCustomShape::DynamicCustomShape
DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
Definition PolygonUtils.h:102
libmspub::Line
Definition Line.h:21
libmspub::TextRectangle
Definition PolygonUtils.h:54
libmspub::TextRectangle::second
Vertex second
Definition PolygonUtils.h:56
libmspub::TextRectangle::first
Vertex first
Definition PolygonUtils.h:55
libmspub::Vertex
Definition PolygonUtils.h:40
libmspub::Vertex::m_x
int m_x
Definition PolygonUtils.h:41
libmspub::Vertex::m_y
int m_y
Definition PolygonUtils.h:42