OutputShape.h Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 "geometry.h"
14 #include "PMDExceptions.h"
15 #include <boost/shared_ptr.hpp>
16 #include <vector>
17 #include "libpagemaker_utils.h"
18 namespace libpagemaker
19 {
20
21 class OutputShape
22 {
23 bool m_isClosed;
24 uint8_t m_shapeType;
25 std::vector<InchPoint> m_points;
26 double m_rotation;
27 double m_skew;
28 double m_bboxLeft, m_bboxTop, m_bboxRight, m_bboxBot;
29 PMDFillProperties m_fillProps;
30 PMDStrokeProperties m_strokeProps;
31 std::string m_text;
32 std::vector<PMDCharProperties> m_charProps;
33 std::vector<PMDParaProperties> m_paraProps;
34 librevenge::RVNGBinaryData m_bitmap;
35 double m_width,m_height;
36
37 public:
38 OutputShape(bool isClosed, int shape, double rotation, double skew, const PMDFillProperties &fillProps, const PMDStrokeProperties &strokeProps)
39 : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
40 m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(), m_fillProps(fillProps), m_strokeProps(strokeProps), m_text(), m_charProps(), m_paraProps(), m_bitmap(), m_width(), m_height()
41 { }
42
43 OutputShape(bool isClosed, int shape, double rotation, double skew, std::string text, std::vector<PMDCharProperties> charProps, std::vector<PMDParaProperties> paraProps)
44 : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
45 m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(),
46 m_fillProps(PMDFillProperties(0,0,0,0)),
47 m_strokeProps(PMDStrokeProperties(0,0,0,0,0)),
48 m_text(text), m_charProps(charProps), m_paraProps(paraProps), m_bitmap(), m_width(), m_height()
49 { }
50
51 OutputShape(bool isClosed, int shape, double rotation, double skew, librevenge::RVNGBinaryData bitmap)
52 : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
53 m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(),
54 m_fillProps(PMDFillProperties(0,0,0,0)),
55 m_strokeProps(PMDStrokeProperties(0,0,0,0,0)),
56 m_text(), m_charProps(), m_paraProps(), m_bitmap(bitmap), m_width(), m_height()
57 { }
58
59 unsigned numPoints() const
60 {
61 return m_points.size();
62 }
63
64 InchPoint getPoint(unsigned i) const
65 {
66 return (m_points.size() > i) ? m_points[i] : InchPoint(0, 0);
67 }
68
69 bool getIsClosed() const
70 {
71 return m_isClosed;
72 }
73
74 uint8_t shapeType() const
75 {
76 return m_shapeType;
77 }
78
79 const PMDFillProperties &getFillProperties() const
80 {
81 return m_fillProps;
82 }
83
84 const PMDStrokeProperties &getStrokeProperties() const
85 {
86 return m_strokeProps;
87 }
88
89 double getRotation() const
90 {
91 return m_rotation;
92 }
93
94 double getSkew() const
95 {
96 return m_skew;
97 }
98
99 std::string getText() const
100 {
101 return m_text;
102 }
103
104 std::vector<PMDCharProperties> getCharProperties() const
105 {
106 return m_charProps;
107 }
108
109 std::vector<PMDParaProperties> getParaProperties() const
110 {
111 return m_paraProps;
112 }
113
114 librevenge::RVNGBinaryData getBitmap() const
115 {
116 return m_bitmap;
117 }
118
119 std::pair<InchPoint, InchPoint> getBoundingBox() const
120 {
121 if (m_points.empty() && m_bitmap.empty())
122 {
123 throw EmptyLineSetException();
124 }
125 return std::make_pair(InchPoint(m_bboxLeft, m_bboxTop), InchPoint(m_bboxRight, m_bboxBot));
126 }
127
128 void setBoundingBox(InchPoint bboxTopLeft, InchPoint bboxBotRight)
129 {
130 m_bboxLeft = bboxTopLeft.m_x;
131 m_bboxTop = bboxTopLeft.m_y;
132 m_bboxRight = bboxBotRight.m_x;
133 m_bboxBot = bboxBotRight.m_y;
134 }
135
136 void addPoint(InchPoint point)
137 {
138 m_points.push_back(InchPoint(point.m_x, point.m_y));
139 }
140
141 void setDimensions(double width, double height)
142 {
143 m_width = width,
144 m_height = height;
145 }
146
147 double getWidth() const
148 {
149 return m_width;
150 }
151
152 double getHeight() const
153 {
154 return m_height;
155 }
156 };
157
158
159 boost::shared_ptr<OutputShape> newOutputShape(
160 const boost::shared_ptr<const PMDLineSet> &lineSet, const InchPoint &translate);
161
162 }
163
164 #endif /* __LIBPAGEMAKER_OUTPUTSHAPE_H__ */
165
166 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libpagemaker::newOutputShape
boost::shared_ptr< OutputShape > newOutputShape(const boost::shared_ptr< const PMDLineSet > &lineSet, const InchPoint &translate)
Definition: OutputShape.cpp:14
libpagemaker::OutputShape::m_text
std::string m_text
Definition: OutputShape.h:31
libpagemaker::OutputShape::m_bboxBot
double m_bboxBot
Definition: OutputShape.h:28
PMDExceptions.h
libpagemaker::OutputShape::m_fillProps
PMDFillProperties m_fillProps
Definition: OutputShape.h:29
libpagemaker::OutputShape::getPoint
InchPoint getPoint(unsigned i) const
Definition: OutputShape.h:64
libpagemaker::OutputShape::OutputShape
OutputShape(bool isClosed, int shape, double rotation, double skew, const PMDFillProperties &fillProps, const PMDStrokeProperties &strokeProps)
Definition: OutputShape.h:38
libpagemaker::OutputShape::getWidth
double getWidth() const
Definition: OutputShape.h:147
libpagemaker::OutputShape::m_height
double m_height
Definition: OutputShape.h:35
libpagemaker::OutputShape::getStrokeProperties
const PMDStrokeProperties & getStrokeProperties() const
Definition: OutputShape.h:84
libpagemaker::OutputShape::getCharProperties
std::vector< PMDCharProperties > getCharProperties() const
Definition: OutputShape.h:104
libpagemaker::OutputShape::shapeType
uint8_t shapeType() const
Definition: OutputShape.h:74
libpagemaker::Point
Definition: geometry.h:22
libpagemaker::OutputShape::m_isClosed
bool m_isClosed
Definition: OutputShape.h:23
libpagemaker::OutputShape::getIsClosed
bool getIsClosed() const
Definition: OutputShape.h:69
libpagemaker::OutputShape::getFillProperties
const PMDFillProperties & getFillProperties() const
Definition: OutputShape.h:79
libpagemaker::OutputShape::m_rotation
double m_rotation
Definition: OutputShape.h:26
libpagemaker::OutputShape::addPoint
void addPoint(InchPoint point)
Definition: OutputShape.h:136
libpagemaker::OutputShape::m_shapeType
uint8_t m_shapeType
Definition: OutputShape.h:24
libpagemaker::OutputShape::getSkew
double getSkew() const
Definition: OutputShape.h:94
libpagemaker::OutputShape::numPoints
unsigned numPoints() const
Definition: OutputShape.h:59
libpagemaker::Point::m_x
Unit m_x
Definition: geometry.h:24
libpagemaker::OutputShape::m_points
std::vector< InchPoint > m_points
Definition: OutputShape.h:25
libpagemaker::OutputShape::getText
std::string getText() const
Definition: OutputShape.h:99
libpagemaker::Point::m_y
Unit m_y
Definition: geometry.h:25
libpagemaker::OutputShape::OutputShape
OutputShape(bool isClosed, int shape, double rotation, double skew, librevenge::RVNGBinaryData bitmap)
Definition: OutputShape.h:51
libpagemaker::OutputShape::OutputShape
OutputShape(bool isClosed, int shape, double rotation, double skew, std::string text, std::vector< PMDCharProperties > charProps, std::vector< PMDParaProperties > paraProps)
Definition: OutputShape.h:43
libpagemaker::OutputShape::getBoundingBox
std::pair< InchPoint, InchPoint > getBoundingBox() const
Definition: OutputShape.h:119
libpagemaker::OutputShape::setBoundingBox
void setBoundingBox(InchPoint bboxTopLeft, InchPoint bboxBotRight)
Definition: OutputShape.h:128
libpagemaker::OutputShape::m_width
double m_width
Definition: OutputShape.h:35
libpagemaker::OutputShape
Definition: OutputShape.h:21
libpagemaker::InchPoint
Point< double > InchPoint
Definition: geometry.h:32
libpagemaker::OutputShape::m_bboxTop
double m_bboxTop
Definition: OutputShape.h:28
libpagemaker::EmptyLineSetException
Definition: PMDExceptions.h:53
libpagemaker::OutputShape::setDimensions
void setDimensions(double width, double height)
Definition: OutputShape.h:141
libpagemaker::OutputShape::m_bitmap
librevenge::RVNGBinaryData m_bitmap
Definition: OutputShape.h:34
libpagemaker::PMDFillProperties
Definition: PMDTypes.h:40
libpagemaker::PMDStrokeProperties
Definition: PMDTypes.h:52
libpagemaker::OutputShape::m_paraProps
std::vector< PMDParaProperties > m_paraProps
Definition: OutputShape.h:33
libpagemaker::OutputShape::m_charProps
std::vector< PMDCharProperties > m_charProps
Definition: OutputShape.h:32
libpagemaker_utils.h
libpagemaker::OutputShape::getBitmap
librevenge::RVNGBinaryData getBitmap() const
Definition: OutputShape.h:114
libpagemaker
Definition: geometry.h:20
libpagemaker::OutputShape::m_bboxLeft
double m_bboxLeft
Definition: OutputShape.h:28
libpagemaker::OutputShape::getHeight
double getHeight() const
Definition: OutputShape.h:152
geometry.h
libpagemaker::OutputShape::m_strokeProps
PMDStrokeProperties m_strokeProps
Definition: OutputShape.h:30
libpagemaker::OutputShape::getParaProperties
std::vector< PMDParaProperties > getParaProperties() const
Definition: OutputShape.h:109
libpagemaker::OutputShape::m_bboxRight
double m_bboxRight
Definition: OutputShape.h:28
libpagemaker::OutputShape::getRotation
double getRotation() const
Definition: OutputShape.h:89
libpagemaker::OutputShape::m_skew
double m_skew
Definition: OutputShape.h:27