OutputShape.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*
3 * This file is part of the libpagemaker project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef __LIBPAGEMAKER_OUTPUTSHAPE_H__
11#define __LIBPAGEMAKER_OUTPUTSHAPE_H__
12
13#include <memory>
14#include <string>
15#include <utility>
16#include <vector>
17
18#include "PMDExceptions.h"
19#include "PMDTypes.h"
20#include "geometry.h"
21#include "libpagemaker_utils.h"
22
23namespace libpagemaker
24{
25
27{
29 uint8_t m_shapeType;
30 std::vector<InchPoint> m_points;
31 double m_rotation;
32 double m_skew;
36 std::string m_text;
37 std::vector<PMDCharProperties> m_charProps;
38 std::vector<PMDParaProperties> m_paraProps;
39 librevenge::RVNGBinaryData m_bitmap;
41
42public:
43 OutputShape(bool isClosed, int shape, double rotation, double skew, const PMDFillProperties &fillProps, const PMDStrokeProperties &strokeProps)
44 : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
46 { }
47
48 OutputShape(bool isClosed, int shape, double rotation, double skew, std::string text, std::vector<PMDCharProperties> charProps, std::vector<PMDParaProperties> paraProps)
49 : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
53 m_text(std::move(text)), m_charProps(std::move(charProps)), m_paraProps(std::move(paraProps)), m_bitmap(), m_width(), m_height()
54 { }
55
56 OutputShape(bool isClosed, int shape, double rotation, double skew, librevenge::RVNGBinaryData bitmap)
57 : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
62 { }
63
64 unsigned numPoints() const
65 {
66 return m_points.size();
67 }
68
69 InchPoint getPoint(unsigned i) const
70 {
71 return (m_points.size() > i) ? m_points[i] : InchPoint(0, 0);
72 }
73
74 bool getIsClosed() const
75 {
76 return m_isClosed;
77 }
78
79 uint8_t shapeType() const
80 {
81 return m_shapeType;
82 }
83
85 {
86 return m_fillProps;
87 }
88
90 {
91 return m_strokeProps;
92 }
93
94 double getRotation() const
95 {
96 return m_rotation;
97 }
98
99 double getSkew() const
100 {
101 return m_skew;
102 }
103
104 std::string getText() const
105 {
106 return m_text;
107 }
108
109 std::vector<PMDCharProperties> getCharProperties() const
110 {
111 return m_charProps;
112 }
113
114 std::vector<PMDParaProperties> getParaProperties() const
115 {
116 return m_paraProps;
117 }
118
119 librevenge::RVNGBinaryData getBitmap() const
120 {
121 return m_bitmap;
122 }
123
124 std::pair<InchPoint, InchPoint> getBoundingBox() const
125 {
126 if (m_points.empty() && m_bitmap.empty())
127 {
128 throw EmptyLineSetException();
129 }
130 return std::make_pair(InchPoint(m_bboxLeft, m_bboxTop), InchPoint(m_bboxRight, m_bboxBot));
131 }
132
133 void setBoundingBox(InchPoint bboxTopLeft, InchPoint bboxBotRight)
134 {
135 m_bboxLeft = bboxTopLeft.m_x;
136 m_bboxTop = bboxTopLeft.m_y;
137 m_bboxRight = bboxBotRight.m_x;
138 m_bboxBot = bboxBotRight.m_y;
139 }
140
141 void addPoint(InchPoint point)
142 {
143 m_points.push_back(InchPoint(point.m_x, point.m_y));
144 }
145
146 void setDimensions(double width, double height)
147 {
148 m_width = width,
149 m_height = height;
150 }
151
152 double getWidth() const
153 {
154 return m_width;
155 }
156
157 double getHeight() const
158 {
159 return m_height;
160 }
161};
162
163
164std::shared_ptr<OutputShape> newOutputShape(
165 const std::shared_ptr<const PMDLineSet> &lineSet, const InchPoint &translate);
166
167}
168
169#endif /* __LIBPAGEMAKER_OUTPUTSHAPE_H__ */
170
171/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
const PMDStrokeProperties & getStrokeProperties() const
Definition OutputShape.h:89
double m_bboxLeft
Definition OutputShape.h:33
OutputShape(bool isClosed, int shape, double rotation, double skew, std::string text, std::vector< PMDCharProperties > charProps, std::vector< PMDParaProperties > paraProps)
Definition OutputShape.h:48
void setBoundingBox(InchPoint bboxTopLeft, InchPoint bboxBotRight)
Definition OutputShape.h:133
double m_height
Definition OutputShape.h:40
InchPoint getPoint(unsigned i) const
Definition OutputShape.h:69
uint8_t m_shapeType
Definition OutputShape.h:29
double m_bboxTop
Definition OutputShape.h:33
double getSkew() const
Definition OutputShape.h:99
void setDimensions(double width, double height)
Definition OutputShape.h:146
double m_rotation
Definition OutputShape.h:31
librevenge::RVNGBinaryData getBitmap() const
Definition OutputShape.h:119
librevenge::RVNGBinaryData m_bitmap
Definition OutputShape.h:39
double m_skew
Definition OutputShape.h:32
double getHeight() const
Definition OutputShape.h:157
OutputShape(bool isClosed, int shape, double rotation, double skew, librevenge::RVNGBinaryData bitmap)
Definition OutputShape.h:56
unsigned numPoints() const
Definition OutputShape.h:64
bool getIsClosed() const
Definition OutputShape.h:74
std::string getText() const
Definition OutputShape.h:104
std::vector< PMDCharProperties > getCharProperties() const
Definition OutputShape.h:109
std::vector< InchPoint > m_points
Definition OutputShape.h:30
double m_bboxRight
Definition OutputShape.h:33
std::vector< PMDParaProperties > m_paraProps
Definition OutputShape.h:38
bool m_isClosed
Definition OutputShape.h:28
std::vector< PMDCharProperties > m_charProps
Definition OutputShape.h:37
PMDStrokeProperties m_strokeProps
Definition OutputShape.h:35
PMDFillProperties m_fillProps
Definition OutputShape.h:34
const PMDFillProperties & getFillProperties() const
Definition OutputShape.h:84
double getWidth() const
Definition OutputShape.h:152
double getRotation() const
Definition OutputShape.h:94
OutputShape(bool isClosed, int shape, double rotation, double skew, const PMDFillProperties &fillProps, const PMDStrokeProperties &strokeProps)
Definition OutputShape.h:43
std::string m_text
Definition OutputShape.h:36
double m_bboxBot
Definition OutputShape.h:33
double m_width
Definition OutputShape.h:40
void addPoint(InchPoint point)
Definition OutputShape.h:141
std::vector< PMDParaProperties > getParaProperties() const
Definition OutputShape.h:114
uint8_t shapeType() const
Definition OutputShape.h:79
std::pair< InchPoint, InchPoint > getBoundingBox() const
Definition OutputShape.h:124
Definition geometry.h:25
Point< double > InchPoint
Definition geometry.h:36
std::shared_ptr< OutputShape > newOutputShape(const std::shared_ptr< const PMDLineSet > &lineSet, const InchPoint &translate)
Definition OutputShape.cpp:19
Definition PMDExceptions.h:57
Definition PMDTypes.h:47
Definition PMDTypes.h:57
Unit m_y
Definition geometry.h:29
Unit m_x
Definition geometry.h:28

Generated for libpagemaker by doxygen 1.18.0