Class Reference rect

The rect class defines a rectangle. More...

Member

rect( )
rect( rect r )
int bottom()
int left()
int height()
int right()
void set(int left,int bottom, int right, int top)
void set(point p1, point p2)
void setBottom(int bottom)
void setLeft(int left)
void setRight(int right)
void setTop(int top)
int top()
int width()

Detailed Description

graph LR e(element)--getBoundingBox-->r(rect) ce(cell)--cSelect-->r ce--fSelect-->r click e "/layoutscript/api/element" click r "/layoutscript/api/rect" click ce "/layoutscript/api/cell" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class r thisClas class e,ce clas

A rect is an axis-aligned rectangle stored as four 32-bit integers left, bottom, right, and top in database units. Multiply by databaseunits on drawingField to get metres. getBoundingBox on element returns the outline of a shape; cSelect and fSelect on cell take a rect as the rubber-band used to pick cellrefs or full shapes. width and height are the differences of those sides. You construct a rect with set, copy another rect, or fill the four sides one by one. It is a value type, not a box element in the cell: passing it to addBox creates the actual geometry.

Example:

element *e = layout->drawing->currentCell->firstElement->thisElement;
if (e == NULL)
 return 1;
rect r = e->getBoundingBox();
layout->drawing->currentCell->fSelect(r);
rect box;
box.set(0, 0, 1000, 500);
layout->drawing->currentCell->addBox(box, layout->drawing->activeLayer);

Member Function Documentation


rect::rect( )

Creates a rectangle with all sides at zero.


rect::rect( rect r )

Creates a rectangle with copied data from r.


int rect::bottom()

Returns: the bottom coordinate.


int rect::left()

Returns: the left coordinate.


int rect::height()

Returns: the height (top minus bottom).


int rect::right()

Returns: the right coordinate.


void rect::set(int left,int bottom, int right, int top)

Sets all four sides of the rectangle.

Parameter:
left left coordinate
bottom bottom coordinate
right right coordinate
top top coordinate

void rect::set(point p1, point p2)

Sets the rectangle to the axis-aligned box that has p1 and p2 as opposite corners. The smaller x becomes left, the larger x becomes right, and the same for y versus bottom and top.

Parameter:
p1 p1
p2 p2

void rect::setBottom(int bottom)

Sets the bottom side to bottom.


void rect::setLeft(int left)

Sets the left side to left.


void rect::setRight(int right)

Sets the right side to right.


void rect::setTop(int top)

Sets the top side to top.


int rect::top()

Returns: the top coordinate.


int rect::width()

Returns: the width (right minus left).