12 #ifndef __SBNW_LAYOUT_BOX_H_ 13 #define __SBNW_LAYOUT_BOX_H_ 29 namespace LibsbmlDraw {
37 Box(
const Point& min,
const Point& max)
38 : _min(min), _max(max) { AT(_min.x <= _max.x && _min.y <= _max.y,
"Min/max mismatch"); }
42 : _min(x1,y1), _max(x2,y2) {
43 if(!(_min.x <= _max.x && _min.y <= _max.y)) {
47 AT(_min.x <= _max.x && _min.y <= _max.y,
"Min/max mismatch");
51 const Point& getMin()
const {
return _min; }
52 Real getMinX()
const {
return getMin().x; }
53 Real getMinY()
const {
return getMin().y; }
55 void setMin(
const Point& p) { _min = p; }
57 void setMinX(
const Real x) { _min.x = x; }
58 void setMinY(
const Real y) { _min.y = y; }
61 const Point& getMax()
const {
return _max; }
62 Real getMaxX()
const {
return getMax().x; }
63 Real getMaxY()
const {
return getMax().y; }
65 void setMax(
const Point& p) { _max = p; }
67 void setMaxX(
const Real x) { _max.x = x; }
68 void setMaxY(
const Real y) { _max.y = y; }
70 Point getCenter()
const {
return (getMax() + getMin())/2.; }
72 Point getFirstQuadCorner()
const {
return getMax(); }
73 Point getSecondQuadCorner()
const {
return Point(_min.x, _max.y); }
74 Point getThirdQuadCorner()
const {
return getMin(); }
75 Point getFourthQuadCorner()
const {
return Point(_max.x, _min.y); }
78 Point getDiag()
const {
return getMax() - getMin(); }
82 Real w = _max.x - _min.x;
83 Real h = _max.y - _min.y;
89 Real w = _max.x - _min.x;
90 Real h = _max.y - _min.y;
94 Point getTopRightCorner()
const {
return Point(_max.x, _min.y); }
96 Point getBottomLeftCorner()
const {
return Point(_min.x, _max.y); }
99 Real width()
const {
return _max.x - _min.x; }
102 void setWidth(
const Real w) { _max.x = _min.x+w; }
105 Real height()
const {
return _max.y - _min.y; }
108 void setHeight(
const Real w) { _max.y = _min.y+w; }
112 Real w = _max.x - _min.x;
113 Real h = _max.y - _min.y;
118 bool canShrink(
const Real v)
const {
119 if(_min.x + 2*v <= _max.x && _min.y+2*v <= _max.y)
126 Box shrink(
const Real v)
const {
127 return Box(_min+Point(v,v), _max-Point(v,v));
131 void shrink_(
const Real v) {
139 Box padded(
const Real v)
const {
140 return Box(_min-Point(v,v), _max+Point(v,v));
144 void expandx(
const Box& other) {
145 _min = Point::emin(_min, other._min);
146 _max = Point::emax(_max, other._max);
149 void displace(
const Point& d) {
154 void dump(std::ostream& o)
const {
155 o <<
"[" << getMin() <<
", " << getMax() <<
"]";
164 std::ostream& operator<< (std::ostream& os,
const Box& b);
167 std::pair<bool, Point> intersectBoxLine(
const Box& b,
const Point& u,
const Point& v);
SAGITTARIUS_REAL Real
Make Real visible to C. Consider letting Real lie in top namespace.
Definition: SagittariusCommon.h:112