Improved Dragging on gEDA PCB

Over the past 12 months I have done quite a bit of design work with gEDA PCB, including some telephony designs and the BlackfinOne project.

During this work I developed an itch that needs scratching – I would like to improve the way tracks are dragged in PCB.

At present, when dragging tracks 45 degree angles are not maintained. This means that after the drag operation a lot of manual clean up is required. This consumes a lot of time, especially near the end of a board layout where moving one track may mean moving a bunch of other things out of the way. This sort of manual rework is something the computer should be able to do for me. In fact many (expensive and proprietary) PCB layout programs do just this sort of thing automatically.

Here is an example of the proposed change. Each stage is annotated with text:

So about a week ago I downloaded the PCB source and started looking into the proposed changes. Actually this was a lot of fun for me – I usually do embedded and DSP work so I found working on a x86 C application quite refreshing. The development environment is much nicer and my head doesn’t hurt as much!

Dragging Tracks

First I messed around with PCB to try and make dragging (moving) lines in rubber band mode a little easier to use, here is a video that demonstrates where I am at.

The first drag is how PCB currently works. I then switch off “All Directions Rubber Band”, which enables the new mode I am working on. Note how dragging horizontal and vertical lines maintains the 45 degree angles. This can save a lot of time when editing tracks that is currently spent in fiddly manual rework (I speak from experience).

BTW I really like the PCB source, lots of clean intuitive code. Thanks to all the various authors for their great work.

I find the process of discovery when working on new code exciting (sorry – that’s a very Geeky thing to say!). I first do a lot of ‘grep’-ing and ‘more’-ing, then sprinkle printfs here and there so I can work out what bit of code I need to work on. When I finally start to “get it” it’s a real “AH HA” experience :-) The first mod that you make that actually does something is very rewarding – you have grappled with the beast and have it under control. Well, sort of. Until the next bug at least.

Anyway the current status is that it works OK for vertical and horizontal lines (tracks), but doesn’t handle dragging components or diagonal lines yet. So it’s still early days.

Object Dragging

Of course it didn’t stop there. As the track dragging was working well I dreamed up a way I could drag an object (component) and have the tracks follow at nice 45 degrees. This required different code to dragging one track segment connected to another.

The prototype object-dragging sometimes works quite well, here is the latest video showing a mixture of components being dragged about.

Sometimes it works like magic.

It also has many cases where it makes a real mess :-) However I think its heading in the right direction, I am now going to test these dragging mods on some real PCB work for the next few weeks and see how it goes.

Trying it Out

I have developed some patches against the latest (at the time of writing) PCB snapshot: pcb-20070208p1. It’s not particularly stable and has been known to segfault at embarrassing times. Use it at your own risk!

Get a copy of pcb-20070208p1.tar.gz from Sourceforge (, then:
$ wget
$ tar xvzf pcb-20070208p1.tar.gz
$ tar xvzf pcb-0.1.diff.tgz
$ patch -p0 < pcb-0.1.diff
$ cd pcb-20070208p1
$ ./configure && make
$ cd src
$ / t.pcb&

The PCB files t1.pcb and t2.pcb are the demo files I have been using
for testing.

You can get a feel for where it works and the current limitations, like
dragging diagonal lines, and dragging horizontal or vertical lines too

Further Work

This work is far from finished, here some TODOs:

  • Ability drag diagonal lines and maintain 45 degrees.
  • Ability to drag points and maintain 45 degrees.
  • Sensible thing should happen when dragging past ends.
  • Handling T junctions, dragging cross should drag stem.
  • Why don’t selections rubber band drag?

First Impressions

After I wrote the post above I worked until 2:30am on my new IP04 four port IP-PBX design. I was working on routing the data bus which is quite tight as it needs to be kept short (133MHz bus on a 2 layer board):

My first impressions of the new features:

  • If I try to move a complex component with many tracks attached I get a segfault. Need to run PCB inside gdb to check this out. Autosave is my friend, but it would be nice if it saved a sequence of files (actually I think PCB did do this in past versions).
  • The track drag doesn’t do sensible things when you drag past the point where attached tracks go to zero length, this limits its usefulness. They should flip around and go in the other direction (this is hard to explain, sorry).
  • In the image above imagine trying to squeeze a new track right in the middle of the area to the left of C21. At the moment you need to delete and redraw lots of tracks. What I really need is a feature to push tracks out of the way without shorting any tracks. For example dragging one track should move all the others out of the way, intelligently rerouting as I drag.
  • The component dragging chose dumb positions (like on top of other tracks) most of the time in practice. In many cases it was easier to delete and re-draw. Sigh.
  • Overall they new routines were only useful in about 10% of the routing I did. I still find I am doing fiddly manual rip up and reroute most of the time. When they did work it was like magic – it’s far quicker to drag one track then delete three tracks and re-draw them.

So still plenty to do to make this work truly useful. It’s a humbling experience to use what you code, especially after a solid week of working on it :-) Anyway, now that I know a little about the PCB code I am getting lots of ideas on how to make these features truly useful. Thinking about coding and more itch-scratching while I lay out this PCB!

5 thoughts on “Improved Dragging on gEDA PCB”

  1. Hi David,

    Any plan to submit your patches to upstream developers?

    They appear very useful and hence important.


  2. Hi Bill,

    I am very keen on contributing a patch to improve PCB, however I feel the current modifications I have made are not really stable enough. I might do some more work later this year.



  3. Upstreaming this work would be amazing, as it would really help PCB’s usability. I’ve taken David’s initial patch and rebased it against git HEAD for a start. I’ve sent that back to David, so either he can continue with the work, or I will file it in PCB’s bug tracker until someone finds time to take a look.

    Best wishes,


  4. Hi,

    After manually upgrading and removing the bit rot caused by ongoing pcb development, I just pushed a topic branch “improved_dragging” containing your code to the upstream pcb repository.

    Kind regards,

    Bert Timmerman.

    1. Hi Bert,

      Well that code was written a long time ago and was never working properly. However would be great if PCB had a working drag feature. I have heard Kicad recently added some dragging.



Comments are closed.