Qt seems to implement almost the entirety of our polygon, spline and path 
management code
(except from user interaction).

QPainterPath <http://doc.qt.nokia.com/4.7/qpainterpath.html> lets you stack up 
a path from straight line
segments, splines, arcs, and whatnot. Heck, it directly lets you add the closed 
outlines for any text
string if one wants to do that. It also has a handy toReversed() member. It 
also has joining code.

Internally, the painter path consists of an array of path elements. A path 
element is simply a QPointF
(floating-point point) with a type attached to it. The types are MoveToElement, 
LineToElement,
CurveToElement, CurveToDataElement. MoveTo always begins a subpath, it is the 
first point of the
first segment. CurveTos are Bezier splines. When you stumble upon a 
CurveToElement, it is the
coordinate of the first control point; by convention the next two elements that 
follow are
CurveToDataElements that have the second control point and endpoint, in that 
order.

There is a member called setElementPositionAt that is used to modify the 
element positions of a path.

A PainterPath is not meant to be modified other than that, so if/when we want 
to remove things from a path:
you have to copy everything sans the path elements you want to remove. Fair 
enough I think.

It then makes sense to merge splines, wires and paths into one type of an 
element that uses QPainterPath
for its data storage. Incidentally, such a beast exists and is called 
QGraphicsPathItem; one only needs to
augment it with editing functionality (handle drawing, cycling through points, 
etc).

Cheers, Kuba
_______________________________________________
Xcircuit-dev mailing list
[email protected]
http://www.opencircuitdesign.com/mailman/listinfo/xcircuit-dev

Reply via email to