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.
On 8/31/06, Redefined Horizons <redefined.horizons@...400...> wrote:
[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:
About six months ago, I had to learn a CAD system (TurboCAD) for the first time. Since my only experience with vector editing was in Inkscape, I had a difficult time with the transition. The trouble is that the two programs have different work-styles. In Inkscape, the basic approach is to draw a shape in the rough position you are interested in, then refine it until it looks correct. CAD systems, on the other hand, require users to draw shapes perfectly the first time, and provide little ability to edit them after the fact.
Since Inkscape's approach is different than that of a CAD system, it might make sense to work within the current system of doing things. Instead of adding ways to draw individual shapes precisely, for example, consider enhancing the node editor with those features instead. All shapes then benefit, and you preserve the Inkscape approach of drawing first and refining later. While I use CAD software every day and understand that its approach is faster for engineering, Inkscape is an art program, not a CAD program. Any added CAD features should follow the artistic philosophy of gradual refinement rather than the engineering approach of instant perfection.
Of course, this is just my own thinking based on my experience with both types of software. Feel free to ignore me if you like.
-William Swanson
Let me know what you think of this plan, and let me know how I can get to those geometry classes.
CAD systems, on the other hand, require users to draw shapes perfectly the first time, and provide little ability to edit them after the fact.
I've only had some experience with Unigraphics in an engeneering class, but I don't recal it being hard to reposition pieces at all. It was my first time with a CAD program, so maybe I just got proficient at fixing my mistakes, or maybe it depends a lot on which program you're using.
I'd just like to have exact positioning features, even for doing art type things in Inkscape, it'd be nice to be able to precicely position things. I end up using snap-to-grid, and the alignment tools a lot right now, but if there were a way to precicely position things, I'd only have to draw some of my shapes once.
As for where the geometry is, I'm pretty new to the code, but in src/, sp-shape.h says "Base class for shapes, including <path> element", and sp-item.h says "Some things pertinent to all visible shapes".
Also, there are sp-spiral.cpp, sp-star.cpp, sp-rect.cpp etc. and sp-object-edit.cpp includes all the shapes .h files
Hope that helps. I'm new too,
Scott, If I understand your previous posts, I think you are trying to create some useful GIS cad tools (which is a great idea). Maybe you've already thought about this, but one of Inkscape's strengths is the SVG data format and there may be some great synergies with the GIS oriented GML data formats and Google Earth's KML since all of these are XML based. Perhaps a first step might be to have a process of importing/exporting necessary data between these formats. This might help in creating whatever data object class extensions might be needed in Inkscape (most likely new GIS CAD classes that inherit existing classes). I think the precision drawing techniques you're describing will be methods in these new classes or even the more base classes. John
Redefined Horizons wrote:
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.
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&da... _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
The current geometry stuff is rather imprecise, slow, and inflexible. If I've got my history right, various replacements have been proposed, yet none accepted (perhaps code was used from them), yet this stuff has its ancestry in sodipodi.
To finally come up with an end-all-be-all solution, the 2geom project was started by a few inkscape developers. http://sourceforge.net/projects/lib2geom . It's going along nicely, but will still be a while until completion. There's some really nice stuff already, and advanced algorithms in planning. It'll certainly be a more elegant, fast, capable, and precise solution.
There's definitely room for more developers, though. Njh, resident math genius, is working on his phd. Mental, programming guru, is working on his comic. I, code janitor, am currently preparing for highschool (about 1200 pages of reading for language arts...).
If you'd like to actually get something functioning, and do it on inkscape's current stuff, that's cool - 2geom might be a while. However, once it's at a decent point of functionality, the current stuff will be torn out and 2geom placed in its stead. Everything that uses geometry stuff will have to be signifigantly adapted. I'd suggest putting effort towards 2geom - your CAD stuff will probably be easier and more elegant for it. You can add features particularly required by your CAD stuff.
Stop by the jabber lib2geom@...132... if you'd like to help but don't know what to do.
On 8/31/06, Redefined Horizons <redefined.horizons@...400...> wrote:
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.)
On 8/31/06, Redefined Horizons <redefined.horizons@...400...> wrote:
Where can I find the classes used to represent Inkscape's geometries?
I'm not entirely sure what you mean by "geometries". Inkscape has different kinds of objects, and their code is mostly in sp-*.cpp, for example sp-rect, sp-path etc. Of course these files use many other parts of the code. The purely geometric code is mostly in libnr/ and in livarot/.
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...)
Yes, all shapes except rectangles are represented as paths in Inkscape. But they nevertheless are separate classes each with its own behavior and controls.
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.)
Excellent idea, and the natural place for these precise controls is on each tool's controls bar. For example, for rectangles, we already have numeric boxes for width, height, and rounding radii; you can add another couple of boxes for x/y origin. For the Pen tool, we currently have no controls at all, but you can add them for setting precise coordinates of the next point.
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 that we already have the Paste size family of commands. You can propose other commands along the same lines.
(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.)
This is much easier achieved by snapping, and is already mostly possible. Open Document properties, Snap tab, and turn on "snap nodes to objects" and "snap to object nodes" below it. After that the Pen tool and Node tool will snap nodes e.g. to the corners of a rectangle (though not to its center yet, but this is easy to add).
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.)
Again, this is a matter of making the controls in the bar smart enough, so that others change their values accordingly when you change the value of one of them. Perhaps you'll need some locks and option buttons as well to modify this behavior.
So, to summarize, from your use cases I don't see a need for any new tools or concepts. Everything is achievable with what we already have or with a logical extension of it.
[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:
I'm not sure what you mean by "coordinate selector". Can you describe step-by-step how it would work? Is this a new tool? Where would it put the selected coordinates? etc.
participants (6)
-
Bot Builder
-
bulia byak
-
jtaber
-
Michael Moore
-
Redefined Horizons
-
William Swanson