label::pdraw("Some text",2*MM,3*CM).xalign(sym::center); // draw a label into the current pad label::direction(sym::up); // set direction for subsequent labels label::pdraw("Above previous text"); // draw another label above previous one
A label provides the following member functions to modify its properties:
x(const length &) y(const length &) x(const length &, int xalign) y(const length &, int yalign)
label l; l.text("text").textcolor(blue).x(2*CM, sym::center).angle(45);
It provides the static functions cdraw(...),pdraw(...),fdraw(...) (see the design concepts). All of these 3 functions accept 3 argument: the first argument is the text to be drawn, the 2nd and 3rd argument is a length, specifying the coordinates of the text. These are those values, which are absolutely necessary for any text label to be drawn. These functions create a new object, place it into the current canvas (cdraw), pad (pdraw) or frame (fdraw), and return a reference to the newly created object. Any other attributes can be set using member functions on the returned reference:
// draw a label centered within a pad label::pdraw("text",0.5,0.5).align(sym::center,sym::center).textcolor(blue);Or, if you want to access this object later, remember a reference:
// draw a label centered within a pad label &l = label::pdraw("text",0.5,0.5).align(sym::center,sym::center).textcolor(blue); .... do something else l.angle(45); // rotate by 45 degrees
The pdraw, fdraw and cdraw functions have also a version without positions. In this case the label is positioned with respect to the last previously placed label, depending on a direction flag, which one can set via the static function label::direction(...) function, see below. (The label is left-aligned with the last label, but this might change in the future to allow right-alignment)
label::fdraw("First label",0.2,0.2); // place first label label::direction(sym::up); // change the default placement direction to 'upwards' // the default is 'down' label::fdraw("Second label above the first"); label::fdraw("third label above the 2nd"); label::fdraw(".... etc");
Souce files: label.h label.cc