Define for Transformations on Path only, also fixed segfault due to GraphicsBuffer
[ipdf/code.git] / src / path.cpp
index f12e2a7..04e537c 100644 (file)
@@ -5,7 +5,7 @@ using namespace std;
 namespace IPDF
 {
 
-Path::Path(const Objects & objects, unsigned start, unsigned end, const Colour & fill, const Colour & stroke)
+Path::Path(Objects & objects, unsigned start, unsigned end, const Colour & fill, const Colour & stroke)
        : m_start(start), m_end(end), m_fill(fill), m_stroke(stroke)
 {
        Real xmin = 0; Real ymin = 0; 
@@ -53,6 +53,16 @@ Path::Path(const Objects & objects, unsigned start, unsigned end, const Colour &
        m_bottom = objects.beziers[objects.data_indices[bottom]].ToAbsolute(objects.bounds[bottom]).GetBottom();
        m_left = objects.beziers[objects.data_indices[left]].ToAbsolute(objects.bounds[left]).GetLeft();
        m_right = objects.beziers[objects.data_indices[right]].ToAbsolute(objects.bounds[right]).GetRight();    
+       
+       #ifdef TRANSFORM_BEZIERS_TO_PATH
+       Rect bounds = SolveBounds(objects);
+       for (unsigned i = m_start; i <= m_end; ++i)
+       {
+               //Debug("Transform %s -> %s", objects.bounds[i].Str().c_str(), bounds.Str().c_str());
+               objects.bounds[i] = TransformRectCoordinates(bounds, objects.bounds[i]);
+               //Debug("-> %s", objects.bounds[i].Str().c_str());
+       }
+       #endif
 }
 
 
@@ -183,7 +193,12 @@ vector<Vec2> & Path::FillPoints(const Objects & objects, const View & view)
 
 Rect Path::SolveBounds(const Objects & objects) const
 {
-               return Rect(m_left.x, m_top.y, m_right.x-m_left.x, m_bottom.y-m_top.y);
+       return Rect(m_left.x, m_top.y, m_right.x-m_left.x, m_bottom.y-m_top.y);
+}
+
+Rect & Path::GetBounds(Objects & objects) 
+{
+       return objects.bounds[m_index];
 }
 
 }

UCC git Repository :: git.ucc.asn.au