cdelker / schemdraw

MIT License
103 stars 20 forks source link

Handling long pin names in Ic elements #29

Closed abradd closed 5 months ago

abradd commented 6 months ago

With the following example code:

import schemdraw
import schemdraw.elements as elm

with schemdraw.Drawing(file="test.svg") as d:
    d.config(fontsize=12)
    axi_uart = elm.Ic(pins=list(reversed([
                     elm.IcPin(name='pin1', side='left'),
                     elm.IcPin(name='pin2', side='left'),
                     elm.IcPin(name='pin3', side='left'),
                     elm.IcPin(name='pin4', side='left'),
                     elm.IcPin(name='pin5', side='left'),
                     elm.IcPin(name='pin6', side='left'),
                     elm.IcPin(name='pin7', side='left'),
                     elm.IcPin(name='pin8_with_long_name', side='left'),
                     ])),
                pinspacing=0.5,
                leadlen=1,
                #size=[8,10],
                label='TEST_IC')

I get the following image:

pinspacing_nosize

There are two concerns with this image:

If I uncomment the the size parameter to produce an element with the necessary width I get:

nopinspcaing_size

where the pinspacing parameter is ignored and pins are evenly distributed along the left side.

Thanks

cdelker commented 6 months ago

In ae1abbb, Ic was fixed to respect pinspacing when size is also provided. It also adds a pinspacing attribute to the Ic element, so that you can use this to get them to line up, even when pinspacing is set automatically:

ic = Ic(...)
BusConnect(dy=ic.pinspacing)

It should be possible to have the size automatically determined based on labels too - just like the flowchart elements can do now. But that will be another commit.

cdelker commented 5 months ago

Autosize based on labels added: e66a7cb67bccd4b419794bfddae23b0a3097493a