Hi all,
now that my recent changes are committed to trunk (which was a bit delayed because the LPE stacking forced me to rewrite some things), here is a little update on the status of my GSoC project. Caution, it's slightly lengthy! But even if you're not interested in most of it, I'd appreciate any comments on the questions/ideas mentioned (you may want to skip the first few paragraphs in this case).
I started by writing three very simple LPEs for various geometric constructions. These are: circle-with-cadius, perpendicular-bisector and tangent-to-curve (in the following abbreviated CwR, PB and TtC). They were mainly chosen for the different kinds of user interaction they require so that I can use them as an indicator of what is still missing.
Although LPE parameters can already be adapted using the LPE dialog, it is clear that for a user friendly interface we need knotholder handles for LPE items. I first added these in a quick-and-dirty way but it quickly became apparent that for a "correct" and more powerful solution the knotholder-related classes needed to be converted to C++. So this is what I did next (see my recent email for details). This also made it possible to add on-canvas handles for LPEs in a semi-automatic fashion similar to how parameters are added. I will put a description of how this works on the wiki soon. It works pretty well, but perhaps the mechanism can still be improved or made more elegant. Please let me know if you have any comments.
Note that there already existed a PointParam parameter class for LPEs but the new handles do *not* duplicate their functionality since the latter can be used to alter _any_ kind of parameter, analogously to how handles for regular SPItems are used (e.g., with TtC there are handles to adjust the length of the tangent which is controlled by *scalar* parameters, not PointParams). Unfortunately, PointParams are currently broken due to the C++ification process but once I fix this, handles will also be added automatically for them. This will render the inconvenient "edit on canvas" button obsolete and make them much more comfortable to use (I'm looking forward to seeing the new lattice deformation in action then :)).
One of the main remaining issues with handles is that we must eventually be able to simultaneously allow KnotHolders and NodePaths for LPE items. E.g., for PB and TtC it is essential to be able to edit the original path while at the same time adjusting the parameters on canvas. Currently this is not possible because an item can only have either a knotholder or a nodepath but not both. My first decent attempts to simply enable both for certain items consistently resulted in crashes. Since I'm not very familiar with the shape-editor code I'd appreciate any hints or even guidelines how this can be done. For instance, which parts of the code rely on the assumption that only one of knotholder/nodepath is active? Bulia, you said that you did some decent work in this direction. Do you have special advice how to proceed?
Another simple recent change was to allow LPEs to either suppress the red helper path (which indicates the original path) or to display it permanently while the item is selected. E.g., for spiro splines it is suppressed while for PB and TtC it makes sense to know how the perpendicular bisector or the tangent are located with respect to the original curve so the helper path is displayed. BTW, I noticed a bug in my code - sometimes the helper curve does not disappear when the item is deselected. I will investigate this. What's the correct way to make the item disappear, anyway? The function remove_temporary_canvasitem() doesn't seem to work.
IMO, the next big step to improve user interaction is to get rid of the "first draw a shape, then apply LPE" scheme. Most, if not all, of the planned LPEs only require very simple paths to which the LPE is applied. For example, CwR and PB only need a straight line, for a future angular bisector and circle-through-3-points we would need a path consisting of just three nodes, etc. My idea is this: Let's have a special mode in the pen and/or pencil tool which waits for a given number (say N) mouse clicks, then converts these into a polyline consiting of N nodes and (N-1) straight line segments (no curved paths are possible) and finally automatically applies a specified LPE to this polyline. This would be very similar to how the Spiro spline mode of the pen/pencil tool works now, only that arbitrary LPEs could be applied and that (optionally?) only polylines are allowed. As soon as we have a toolbar for the new geometric LPEs in place, the new "LPE mode" in the pen tool would be activated by pressing the corresponding button. Does this make sense? Any suggestions for details of the workflow?
After this is done, I'm going to write the remaining planned LPEs (which I haven't done yet because I considered it favorable to have the on-canvas machinery in place in order to avoid major rewritings). This should be very quick (I already have drafts for a couple of them on my hard drive).
Then I'd like to start tackling automatic toolbar integration of LPE parameters. I don't have a clear idea yet of what is needed for this so if you have any suggestions, I'd love to hear them. Johan, can you comment on this? Can I simply integrate RegisteredWidgets into existing toolbars or what kind of groundwork is needed to achieve this?
Many thanks for reading thus far and for any comments you may have! Max