I've got an hour or two at the end of this work to get started on my CAD tools for Inkscape. (I checked out a couple of books on C++ from my local library in case I get stuck on something.) :]
First let me ask a question, and then I'll explain my plan. (You guys can let me know if the plan is feasible with Inkscape's architecture.)
Where can I find the classes used to represent Inkscape's geometries? (I'm assuming that each geometry type is represented by a separate class file. Let me know if this is incorrect.)
I've dowloaded the source code for Inkscape 0.44, but I couldn't find a "geometry" folder in the "src" folder of the distribution. I imagine there would be a class file for rectangles, circles, elipses, lines, polylines and polygons. (Unless rectangles are represented as polylines and elipses as modified circles...)
Now, for my plan of attack...
Here is a basic description of my goal for the CAD tools:
Tools that allow the user to create the basic Inkscape geometries using precise coordinate entry. (For example, the user could enter coordinates into a dialog box for the two endpoints of a line and then create that line, or they might enter the coordinate for the start point of the line, and then an angle and distance that would be used to compute the endpoint of the line.) Or the user might use other tools to select the precise coodinates of existing geometries as the input for such a tool, instead of entering the coordinates directly. (For example, selecting the coordinate at the midpoint of a line and the node of a polygon, and drawing the line with these exact coordinates as the two endpoints.) These tools will also allow the user to precisely modify existing geometries. (For example, move a polygon by precisely selecting two coorinates on existing geometries to compute the change in X and change in Y for the translation.)
Here is what I need to do:
[1] Design and implement what I call "coordinate selectors". These are tools that allow very precise selection of points on the canvas. Typically these points will be selected from existing geometries.I would like to implement the following coordinate selectors for Inkscape:
End Point (The coordinate at the end point of a line or polyline.)
Mid Point (The coordinate at the mid point of a line, polyline segment, or polygon segment.)
Nearest Node (The coordinate at the node nearest to center of selection window created by a mouse drag on the canvas.)
All Nodes (The coordinates of all nodes within a selection window created by a mouse drag on the canvas.)
Perpendicular (The coordinate at point on a line, polyline segment, polygon segment, or projection of any of these segments that is perpendicular to another selected point.)
Intersection (The coordinate of the point at the intersection of two or more lines, polyline segments, or polygon segments.)
Offset (The coordinate of a point created by projecting an offset along the alignment or direction of two other points and a fixed distance.)
Projected Intersection (The coordinate of a point located at the projected intersection of any two lines, polyline segments, or polygon segments.)
I'll get started by examing the geometry classes, which I will need to use in my calculations for the coordinate tools. But I will also need to figure out how to add a tool to Inkscapes user interface that allows the user to drag a window on the canvas and then programatically access the geometries or shapes that are contained by or intersect that window. (Perhaps I can use the exisitng pointer/selection tool in Inkscape?)
Let me know what you think of this plan, and let me know how I can get to those geometry classes.
Scott Huey
P.S. - I can program the coordinate selectors in a way that allows them to be used by other developer's tools, not just the ones I design. For example, in OpenJUMP I am building coordinate selectors that can store there selected coordinates on a "Coordinate Clipboard" that can be accessed by the user or programatically.