[PythonCAD] state table details

Russ Nelson nelson at crynwr.com
Thu Jun 8 23:26:23 CEST 2006


I'm trying to avoid working on what I *should* be working on, so I
banged out some details of the proposed state table.  The callbacks
look at the current state's 'input' value to see what they should do.
The motion notify will rubberband from the previously saved point (and
Radius and Angle) if requested.  The click handler will record the
point for the action.  The SavePoint action pushes the point onto an
array of points.  The Add* action takes the various saved values and
Adds the approporiate object.

All of this, of course, is so that I don't have to reinvent the "get a
point" and "get an angle" code for Rotate.

statetable = {
  # Draw/Basic/Point
  21:{ 'input':'point', 'action':AddPoint, 'next': 21 },
  # Draw/Basic/Point
  31:{ 'input':'point', 'action':SavePoint, 'next': 32},
  32:{ 'input':'rubberline', 'action':AddSegment, 'next': 31},
  # Draw/Basic/Rectangle
  41:{ 'input':'point', 'action':SavePoint, 'next':42},
  42:{ 'input':'rubberrect', 'action':AddRectangle, 'next': 41},
  # Draw/Basic/Circle
  51:{ 'input':'point', 'action':SavePoint, 'next':52},
  52:{ 'input':'rubbercircle', 'action':AddCircle, 'next': 51},
  # Draw/Basic/Circle2Pt
  61:{ 'input':'point', 'action':SavePoint, 'next':62},
  62:{ 'input':'rubberdish, 'action':AddCircle2P, 'next': 61},
  # Draw/Basic/Arc
  71:{ 'input':'point', 'action':SavePoint, 'next':72},
  72:{ 'input':'rubbercircle', 'action':SaveRadius, 'next':73, 'nextenter':74},
  73:{ 'input':'rubberarc', 'action':AddArc, 'next':71},
  74:{ 'input':'angle', 'action':SaveAngle, 'next':75},
  75:{ 'input':'angle', 'action':AddArc, 'next':71},
  #
  # Draw/Leader
  151:{ 'input':'point', 'action':SavePoint, 'next': 152},
  152:{ 'input':'rubberline', 'action':SavePoint, 'next': 153},
  153:{ 'input':'rubberline', 'action':AddLeader, 'next': 151},
  # Draw/Polyline
  161:{ 'input':'point', 'action':SavePoint, 'next': 162},
  162:{ 'input':'rubberline', 'action':SavePoint, 'next': 162,'nextshift':163},
  163:{ 'input':'rubberline', 'action':AddLeader, 'next': 161},
  # .....
}

-- 
--my blog is at    http://blog.russnelson.com   | When immigration is
Crynwr sells support for free software  | PGPok | outlawed, only criminals
521 Pleasant Valley Rd. | +1 315-323-1241       | will immigrate.  Illegal
Potsdam, NY 13676-3213  |     Sheepdog          | immigration causes crime.


More information about the PythonCAD mailing list