-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompositeGraphics.cpp
More file actions
25 lines (22 loc) · 923 Bytes
/
CompositeGraphics.cpp
File metadata and controls
25 lines (22 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <algorithm>
#include <math.h>
#include "CompositeGraphics.h"
void CompositeGraphics::add(Graphics* graphic){
_graphics.push_back(graphic);
calculateBoundingBox();
}
void CompositeGraphics::calculateBoundingBox(){
//_boundingBox = BoundingBox(0, 0, 0, 0);
for (vector<Graphics*>::iterator iterator = _graphics.begin(); iterator != _graphics.end(); iterator++){
if (_boundingBox.area() == 0){
_boundingBox = (*iterator)->getBoundingBox();
}
double newllx = min(_boundingBox.llx(), (*iterator)->getBoundingBox().llx());
double newlly = min(_boundingBox.lly(), (*iterator)->getBoundingBox().lly());
double newurx = max(_boundingBox.urx(), (*iterator)->getBoundingBox().urx());
double newury = max(_boundingBox.urx(), (*iterator)->getBoundingBox().ury());
double newW = fabs(newury - newlly);
double newL = fabs(newurx - newllx);
_boundingBox = BoundingBox(newllx, newlly, newL, newW);
}
}