| 214 | } |
| 215 | |
| 216 | RectF Drawable::boundBox(bool cropImages) const { |
| 217 | RectF boundBox = RectF::null(); |
| 218 | if (auto line = part.ptr<LinePart>()) { |
| 219 | boundBox.combine(line->line.min()); |
| 220 | boundBox.combine(line->line.max()); |
| 221 | |
| 222 | } else if (auto poly = part.ptr<PolyPart>()) { |
| 223 | boundBox.combine(poly->poly.boundBox()); |
| 224 | |
| 225 | } else if (auto image = part.ptr<ImagePart>()) { |
| 226 | auto imageMetadata = Root::singleton().imageMetadataDatabase(); |
| 227 | RectF imageRegion = RectF::null(); |
| 228 | if (cropImages) { |
| 229 | RectU nonEmptyRegion = imageMetadata->nonEmptyRegion(image->image); |
| 230 | if (!nonEmptyRegion.isNull()) |
| 231 | imageRegion = RectF(nonEmptyRegion); |
| 232 | } else { |
| 233 | imageRegion = RectF::withSize(Vec2F(), Vec2F(imageMetadata->imageSize(image->image))); |
| 234 | } |
| 235 | |
| 236 | if (!imageRegion.isNull()) { |
| 237 | boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMin(), imageRegion.yMin()))); |
| 238 | boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMax(), imageRegion.yMin()))); |
| 239 | boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMin(), imageRegion.yMax()))); |
| 240 | boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMax(), imageRegion.yMax()))); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | if (!boundBox.isNull()) |
| 245 | boundBox.translate(position); |
| 246 | |
| 247 | return boundBox; |
| 248 | } |
| 249 | |
| 250 | DataStream& operator>>(DataStream& ds, Drawable::LinePart& line) { |
| 251 | ds >> line.line; |
no test coverage detected