X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdocument.cpp;h=6a862913918df20a543d9386c93180eaf30261c3;hp=65a07ec9b625399521f9077306d2510f0372d997;hb=da646c739f87bf28c5a7af2bc180b93b3444321b;hpb=53579b1a949fa3e4e193f8dfba2064edbb123f57 diff --git a/src/document.cpp b/src/document.cpp index 65a07ec..6a86291 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -272,8 +272,26 @@ void Document::Load(const string & filename) unsigned Document::AddGroup(unsigned start_index, unsigned end_index) { - //TODO: Set bounds rect? - unsigned result = Add(GROUP, Rect(0,0,1,1),0); + Real xmin = 0; Real ymin = 0; + Real xmax = 0; Real ymax = 0; + + for (unsigned i = start_index; i <= end_index; ++i) + { + Rect & objb = m_objects.bounds[i]; + + if (i == start_index || objb.x < xmin) + xmin = objb.x; + if (i == start_index || (objb.x+objb.w) > xmax) + xmax = (objb.x+objb.w); + + if (i == start_index || objb.y < ymin) + ymin = objb.y; + if (i == start_index || (objb.y+objb.h) > ymax) + ymax = (objb.y+objb.h); + } + + Rect bounds(xmin,ymin, xmax-xmin, ymax-ymin); + unsigned result = Add(GROUP, bounds,0); m_objects.groups[m_count-1].first = start_index; m_objects.groups[m_count-1].second = end_index; return result;