Class Reference symbol

A symbol of a component use for the schematic. More...

Member

sElement* addArc(pointArray p,int red, int green, int blue)
sElement* addBusport(point p,string text)
sElement* addCircle(point p1,QPoint p2,int red, int green, int blue)
sElement* addPort(point p,string text)
sElement* addPolyline(pointArray p,int red, int green, int blue)
sElement* addPolygon(pointArray p,int red, int green, int blue)
sElement* addRect(point p1,QPoint p2,int red, int green, int blue)
sElement* addText(point p,int red, int green, int blue, string textt)
void deleteElement( sElement* element)
sElementList* firstElement

Detailed Description

graph LR co(component)--getSymbol-->sy(symbol) sy--firstElement-->el(sElementList) el--thisElement-->e(sElement) click co "/layoutscript/api/component" click sy "/layoutscript/api/symbol" click el "/layoutscript/api/selementlist" click e "/layoutscript/api/selement" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class sy thisClas class co,el,e clas

A symbol is the drawing of a component: ports, bus ports and the non-functional shapes that make the icon. You get it from component->getSymbol(); you do not construct a symbol yourself. The graphics live in firstElement, the same linked sElementList as on a sheet. The add… methods append shapes and ports; deleteElement removes one. Colour of drawing shapes is set on each sElement with setColor. A typical edit loop walks thisElement / nextElement and then adds a polygon or a port.

Example:

component *comp = schematic->drawing->currentSheet->getSheetComponent();
if (comp == NULL)
 return 1;
symbol *sym = comp->getSymbol();
if (sym == NULL)
 return 1;
sElementList *sl = sym->firstElement;
while (sl != NULL) {
 if (sl->thisElement != NULL)
 sl->thisElement->setColor(255, 0, 50);
 sl = sl->nextElement;
}
pointArray pa;
pa.attach(0, 0);
pa.attach(30, 0);
pa.attach(0, 30);
sym->addPolygon(pa, 0, 155, 255);

Member Function Documentation


sElement* symbol::addArc(pointArray p,int red, int green, int blue)

Adds an arc on this symbol. p holds the points of the arc. red, green and blue are the colour channels from 0 to 255.

Parameter:
p points of the arc
red red colour channel
green green colour channel
blue blue colour channel

Returns: a pointer to the new sElement.


sElement* symbol::addBusport(point p,string text)

Adds a bus port at p. text is the port name.

Returns: a pointer to the new sElement.

Parameter:
p p
text text

sElement* symbol::addCircle(point p1,QPoint p2,int red, int green, int blue)

Adds a circle whose bounding box runs from p1 to p2. red, green and blue set the colour.

Parameter:
p1 first corner of the bounding box
p2 opposite corner of the bounding box
red red colour channel
green green colour channel
blue blue colour channel

Returns: a pointer to the new sElement.


sElement* symbol::addPort(point p,string text)

Adds a port at p. text is the port name shown on the symbol.

Returns: a pointer to the new sElement.

Parameter:
p p
text text

sElement* symbol::addPolyline(pointArray p,int red, int green, int blue)

Adds a polyline along p. red, green and blue set the colour.

Parameter:
p vertices of the polyline
red red colour channel
green green colour channel
blue blue colour channel

Returns: a pointer to the new sElement.


sElement* symbol::addPolygon(pointArray p,int red, int green, int blue)

Adds a polygon with vertices p. red, green and blue set the colour.

Parameter:
p vertices of the polygon
red red colour channel
green green colour channel
blue blue colour channel

Returns: a pointer to the new sElement.


sElement* symbol::addRect(point p1,QPoint p2,int red, int green, int blue)

Adds a rectangle with opposite corners p1 and p2. red, green and blue set the colour.

Parameter:
p1 first corner
p2 opposite corner
red red colour channel
green green colour channel
blue blue colour channel

Returns: a pointer to the new sElement.


sElement* symbol::addText(point p,int red, int green, int blue, string textt)

Adds a text textt at p. red, green and blue set the colour.

Parameter:
p origin of the text
red red colour channel
green green colour channel
blue blue colour channel
textt the text string

Returns: a pointer to the new sElement.


void symbol::deleteElement( sElement* element)

Deletes element from this symbol. The pointer is then invalid.


sElementList* symbol::firstElement

Head of the linked list of all elements in this symbol. See sElementList.