OutputShape.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libpagemaker project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __LIBPAGEMAKER_OUTPUTSHAPE_H__
00011 #define __LIBPAGEMAKER_OUTPUTSHAPE_H__
00012 
00013 #include "geometry.h"
00014 #include "PMDExceptions.h"
00015 #include <boost/shared_ptr.hpp>
00016 #include <vector>
00017 #include "libpagemaker_utils.h"
00018 namespace libpagemaker
00019 {
00020 
00021 class OutputShape
00022 {
00023   bool m_isClosed;
00024   uint8_t m_shapeType;
00025   std::vector<InchPoint> m_points;
00026   double m_rotation;
00027   double m_skew;
00028   double m_bboxLeft, m_bboxTop, m_bboxRight, m_bboxBot;
00029   PMDFillProperties m_fillProps;
00030   PMDStrokeProperties m_strokeProps;
00031   std::string m_text;
00032   std::vector<PMDCharProperties> m_charProps;
00033   std::vector<PMDParaProperties> m_paraProps;
00034   librevenge::RVNGBinaryData m_bitmap;
00035   double m_width,m_height;
00036 
00037 public:
00038   OutputShape(bool isClosed, int shape, double rotation, double skew, const PMDFillProperties &fillProps, const PMDStrokeProperties &strokeProps)
00039     : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
00040       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()
00041   { }
00042 
00043   OutputShape(bool isClosed, int shape, double rotation, double skew, std::string text, std::vector<PMDCharProperties> charProps, std::vector<PMDParaProperties> paraProps)
00044     : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
00045       m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(),
00046       m_fillProps(PMDFillProperties(0,0,0,0)),
00047       m_strokeProps(PMDStrokeProperties(0,0,0,0,0)),
00048       m_text(text), m_charProps(charProps), m_paraProps(paraProps), m_bitmap(), m_width(), m_height()
00049   { }
00050 
00051   OutputShape(bool isClosed, int shape, double rotation, double skew, librevenge::RVNGBinaryData bitmap)
00052     : m_isClosed(isClosed), m_shapeType(shape), m_points(), m_rotation(rotation), m_skew(skew),
00053       m_bboxLeft(), m_bboxTop(), m_bboxRight(), m_bboxBot(),
00054       m_fillProps(PMDFillProperties(0,0,0,0)),
00055       m_strokeProps(PMDStrokeProperties(0,0,0,0,0)),
00056       m_text(), m_charProps(), m_paraProps(), m_bitmap(bitmap), m_width(), m_height()
00057   { }
00058 
00059   unsigned numPoints() const
00060   {
00061     return m_points.size();
00062   }
00063 
00064   InchPoint getPoint(unsigned i) const
00065   {
00066     return (m_points.size() > i) ? m_points[i] : InchPoint(0, 0);
00067   }
00068 
00069   bool getIsClosed() const
00070   {
00071     return m_isClosed;
00072   }
00073 
00074   uint8_t shapeType() const
00075   {
00076     return m_shapeType;
00077   }
00078 
00079   const PMDFillProperties &getFillProperties() const
00080   {
00081     return m_fillProps;
00082   }
00083 
00084   const PMDStrokeProperties &getStrokeProperties() const
00085   {
00086     return m_strokeProps;
00087   }
00088 
00089   double getRotation() const
00090   {
00091     return m_rotation;
00092   }
00093 
00094   double getSkew() const
00095   {
00096     return m_skew;
00097   }
00098 
00099   std::string getText() const
00100   {
00101     return m_text;
00102   }
00103 
00104   std::vector<PMDCharProperties> getCharProperties() const
00105   {
00106     return m_charProps;
00107   }
00108 
00109   std::vector<PMDParaProperties> getParaProperties() const
00110   {
00111     return m_paraProps;
00112   }
00113 
00114   librevenge::RVNGBinaryData getBitmap() const
00115   {
00116     return m_bitmap;
00117   }
00118 
00119   std::pair<InchPoint, InchPoint> getBoundingBox() const
00120   {
00121     if (m_points.empty() && m_bitmap.empty())
00122     {
00123       throw EmptyLineSetException();
00124     }
00125     return std::make_pair(InchPoint(m_bboxLeft, m_bboxTop), InchPoint(m_bboxRight, m_bboxBot));
00126   }
00127 
00128   void setBoundingBox(InchPoint bboxTopLeft, InchPoint bboxBotRight)
00129   {
00130     m_bboxLeft = bboxTopLeft.m_x;
00131     m_bboxTop = bboxTopLeft.m_y;
00132     m_bboxRight = bboxBotRight.m_x;
00133     m_bboxBot = bboxBotRight.m_y;
00134   }
00135 
00136   void addPoint(InchPoint point)
00137   {
00138     m_points.push_back(InchPoint(point.m_x, point.m_y));
00139   }
00140 
00141   void setDimensions(double width, double height)
00142   {
00143     m_width = width,
00144     m_height = height;
00145   }
00146 
00147   double getWidth() const
00148   {
00149     return m_width;
00150   }
00151 
00152   double getHeight() const
00153   {
00154     return m_height;
00155   }
00156 };
00157 
00158 
00159 boost::shared_ptr<OutputShape> newOutputShape(
00160   const boost::shared_ptr<const PMDLineSet> &lineSet, const InchPoint &translate);
00161 
00162 }
00163 
00164 #endif /* __LIBPAGEMAKER_OUTPUTSHAPE_H__ */
00165 
00166 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */