chenbo007 / svg-edit

Automatically exported from code.google.com/p/svg-edit
0 stars 0 forks source link

Convert Line to Curve Segments in Poly (Path Editing Phase 3) #118

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It should be possible to change a path segment from a line into a bezier
curve and vice versa.

I'm not clear on the UI for this yet, but it is a placeholder

Original issue reported on code.google.com by codedr...@gmail.com on 24 Aug 2009 at 8:38

GoogleCodeExporter commented 9 years ago
Here's some thoughts I had on the UI for this feature:

We currently show the points of the path, letting a user hover and then drag 
them. 
This works ok for straight line segments.

But actually the point is only _part_ of the path segment.  For example, if 
there are
three line segments: A,B,C then the path actually has 3 path segments:  AB, BC, 
CA. 
For more complicated path types, the segment consists of more than just a 
point.  If
AB is not a line but a bezier curve, it actually has control points at BOTH 
ends of
the segment.

So how to show this relationship?  My current ideas are as follows:

1) we keep the points shown for ease of dragging them around.  With Issue 117, 
when a
point is clicked on the contextual panel updates for that point (user has 
buttons to
delete or clone that segment)
2) when the user hovers over a segment (i.e. the line AB) then that line gets
highlighted.  If clicked on, the contextual panel shows a control which allows 
the
user to change the type of segment:  line, bezier curve (maybe in a pulldown).  
3) when the highlighted segment is a curve, we show the control points (at both 
ends
of the segment) and give the ability for the user to drag and manipulate the 
curve
4) need a keyboard way of navigating to previous or next segment when the 
segment is
highlighted (maybe re-use Shift-O,P or the arrow keys?) for complicated paths 
that
are hard to click

Zoom (Issue 38) will also help with the ability to fine-grain select a segment 
in
complex/tight paths.

The above makes an artificial distinction between the end points of a segment 
and the
segments themselves.  If you want to change the position of a segment, you would
click on an endpoint and drag the point.  If you want to change the curvature 
of a
segment, you would click on the curve between the two points.

What do others think of this idea?

Original comment by codedr...@gmail.com on 7 Sep 2009 at 4:04

GoogleCodeExporter commented 9 years ago
NOTE: In addition to the above, the contextual panel for path segments would 
have at
least three options:

 * straight line
 * smooth curve (shorthand cubic bezier)
 * cubic bezier

The smooth curve would only have one control point (at the B point, in AB).  The
cubic bezier would have two control points (one at A, one at B).

Original comment by codedr...@gmail.com on 7 Sep 2009 at 4:11

GoogleCodeExporter commented 9 years ago
As mentioned in Issue 117, I think it should be the SEGMENTS that are 
selectable. 
This issue would add some controls to change the segment type from straight 
line to
smooth curve and cubic.

Original comment by codedr...@gmail.com on 13 Sep 2009 at 4:42

GoogleCodeExporter commented 9 years ago
I just totally started work on this without reading anything on this issue 
first. :
( Sorry! Still, since it's just basic stuff for now, it may not matter too much.

Check-in coming soon...

Original comment by adeve...@gmail.com on 25 Sep 2009 at 5:06

GoogleCodeExporter commented 9 years ago
Can we have both, the nodes plus the segments selectable?

I can't work with segments, really :-( I only know nodes, and changing their 
handles.

Original comment by worms_...@yahoo.com on 25 Sep 2009 at 5:19

GoogleCodeExporter commented 9 years ago
@adeveria: Like i'm going to yell at you for doing work :)  These are just 
ideas in
the issue, not necessary to do it.  Looking forward to your checkin.

Original comment by codedr...@gmail.com on 25 Sep 2009 at 5:23

GoogleCodeExporter commented 9 years ago
As of r714 there is now a very basic implementation of curved segments. Go into 
poly 
editing mode and double-click one of the grips to toggle the adjoining segment 
from 
a straight to a curved line.

What works: 
  * Any segment in a poly can be toggled like this
  * The two control handles can be moved around as desired
  * Moving/rotating/scaling the polygon after editing

What doesn't work yet:
  * Editing the poly after de-selecting and then re-selecting a curved poly
  * Editing curves while zoomed in or out
  * Editing curves on a rotated poly
  * Using any other type of curve
  * Probably more. :)

Original comment by adeve...@gmail.com on 25 Sep 2009 at 6:22

GoogleCodeExporter commented 9 years ago
Another bug:  moving a point does not move the control point grips and lines

Original comment by codedr...@gmail.com on 25 Sep 2009 at 8:13

GoogleCodeExporter commented 9 years ago
Fixed in r716: Re-selecting after de-selecting, as long as the poly hasn't been 
moved first.

If it has been moved, for now the only way to edit the nodes again is by 
reverting 
the curve back to a straight line, then back to a curve again.

Also still doesn't work: 
  * Moving nodes from a segment with a curve.

Original comment by adeve...@gmail.com on 25 Sep 2009 at 8:20

GoogleCodeExporter commented 9 years ago
Another bug: stray poly control grips can be made visible

Suggestion:  Since only two point grips can be visible at a time, only create 
two and
just re-position them upon selection of a new poly point.

Original comment by codedr...@gmail.com on 25 Sep 2009 at 8:34

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
1) re. issue 118#c10 : I'm seeing multiple control grips at a time. Is it 
normal? (at
r716)
I think the user should be able to see all the grips he has edited on a 
polyline at
once (so, not as suggested in issue 118 comment 10). 

2) sometimes the grip goes outside the canvas, and the only way to reach its 
end is
to resize the canvas. Is this the expected behavior ? (It can be... just 
checking)

3) After moving a node, sometimes it gets "doubled" and the new (supplementary)
segment appears with no stroke. It _think_, but I'm not sure, that this only 
happens
to the nodes marked with a green/red dot, not to the ones with blue dots.
It's certainly not normal. Maybe the path wasn't really closed?

See screenshot http://imgh.us/svg-edit_polyline_nodes_edit_01.jpg

4) Another thing: after having edited nodes to get curves, if I move a point, 
all
segments become straight again.

Original comment by worms_...@yahoo.com on 26 Sep 2009 at 9:02

GoogleCodeExporter commented 9 years ago
Issue 238 has been merged into this issue.

Original comment by codedr...@gmail.com on 26 Sep 2009 at 12:30

GoogleCodeExporter commented 9 years ago
Making good progress, but don't want to checkin just yet. Hopefully tomorrow.

Original comment by adeve...@gmail.com on 28 Sep 2009 at 8:34

GoogleCodeExporter commented 9 years ago
oooo, i'm on pins-and-needles! :)

Original comment by codedr...@gmail.com on 28 Sep 2009 at 8:35

GoogleCodeExporter commented 9 years ago
Known issues as of r729:

  * undo/redo does not work with changing from lines/curves
  * rotating polys with curves does not work when you try to edit the poly
  * dragging the first node if the last node is a curve creates a new node (though
the poly is no longer connected)
  * Rotating polys and the control grips are not in the correct place anymore

Original comment by codedr...@gmail.com on 29 Sep 2009 at 4:27

GoogleCodeExporter commented 9 years ago
Oh, and probably the most severe bug left:

  * if you serialize a SVG with a curved path to text, the path vanishes

Original comment by codedr...@gmail.com on 29 Sep 2009 at 4:36

GoogleCodeExporter commented 9 years ago
The control nodes are very persistent now, and so are the grips.
1) Draw a polyline (with or without making it curved)
2) Hit "New file"
--> The control nodes (and the grips if they were present) are still there

Original comment by worms_...@yahoo.com on 29 Sep 2009 at 4:40

GoogleCodeExporter commented 9 years ago
This last bug is definitely because of the clearPoly(remove) function.  If you 
draw
two polys, make one of them curved then select the other one, then click "Edit
Source", both paths make it through the svgCanvasToString() function.

Original comment by codedr...@gmail.com on 29 Sep 2009 at 4:40

GoogleCodeExporter commented 9 years ago
About undo/redo:  draw a poly, turn one of its segments into a curve then click 
Undo:
 the poly goes back to being straight - so some command is making it onto the undo
stack.  However, if you click 'Redo', nothing happens.

Original comment by codedr...@gmail.com on 29 Sep 2009 at 4:43

GoogleCodeExporter commented 9 years ago
Sorry, in my comment #19 the 'last bug' I was referring to was the one listed in
comment #17 (path vanishing when serializing to text).

Original comment by codedr...@gmail.com on 29 Sep 2009 at 4:53

GoogleCodeExporter commented 9 years ago
Addressed the problem mentioned in comment #18 in r730.

Original comment by codedr...@gmail.com on 29 Sep 2009 at 5:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Fixed problem in comment #17 (if you serialize a SVG with a curved path to 
text, the
path vanishes) and editing while zoomed in r736.

Original comment by adeve...@gmail.com on 29 Sep 2009 at 6:18

GoogleCodeExporter commented 9 years ago
Fixed undo/redo bugs in r737.

Remaining bugs:

  * Editing a rotated poly
  * Dragging the first node if the last node is a curve creates a new node (though
the poly is no longer connected)
  * Poly curve handles can appear on one poly while editing another
  * Editing control points that lie outside the canvas (should be another issue)

Original comment by adeve...@gmail.com on 29 Sep 2009 at 7:38

GoogleCodeExporter commented 9 years ago
r741 fixes the error when dragging a polypoint in polyedit mode.  This does not 
fix
the curve issues (control points are not rotated properly).

Original comment by codedr...@gmail.com on 29 Sep 2009 at 9:07

GoogleCodeExporter commented 9 years ago
Fixed the bug where a new node is accidentally created. See the detailed 
comment at 
r751 for more info.

Original comment by adeve...@gmail.com on 2 Oct 2009 at 3:20

GoogleCodeExporter commented 9 years ago
Currently, you can't edit a polyline which has two nodes:
- Draw a line with the polyline tool
- Enter in polyedit mode
- Click one or the other node (same effect will happen)
----> The segment disappears

Original comment by worms_...@yahoo.com on 5 Oct 2009 at 8:37

GoogleCodeExporter commented 9 years ago
Problems with open polylines:

1) Can't edit a polyline with 3 nodes:

- Draw a "triangle" without closing the path
- Enter in polyedit mode
a) If you click the first drawn node, you can edit the segment normally. Make 
it a curve.
b) If you click the last drawn node, the curve of the first segment is made 
straight
again. So, curve the first segment again (see a) )
c) Click on the second node in the polyline ---> The path is closed and you get 
a
polyline with 2 nodes, which is certainly not what you want.

Another problem I see if that if you have several open polylines on the same 
layer,
editing one will also make handles of others appear/change, but this is hard to
reproduce with steps (the effects are obvious, though).

Attaching a SVG with 3-node-open-polylines which can also be seen here:

http://imgh.us/svg-edit-3nodeOpenPoly.svg

Original comment by worms_...@yahoo.com on 5 Oct 2009 at 9:07

Attachments:

GoogleCodeExporter commented 9 years ago
Yeah, the latest change to the poly editing has probably caused the open poly
problem. Definitely aware of it, though, and will be addressed.

Original comment by adeve...@gmail.com on 5 Oct 2009 at 1:24

GoogleCodeExporter commented 9 years ago
Some small issues still seem to remain, but I'm delighted to report that you 
can now 
move poly nodes after rotating as of r802!

Original comment by adeve...@gmail.com on 12 Oct 2009 at 2:32

GoogleCodeExporter commented 9 years ago
Great work - it's really been fun to watch the steady progress here on a 
complex feature.

One bug I noticed this morning when playing with it:

  * when you move a poly point (node) on a rotated path, the control points of that
segment seem to stretch in an odd way - not a deal breaker, but odd

What other bugs remain for this?  I'm happy enough to close this issue and open
smaller bugs for the remaining if you are.

Original comment by codedr...@gmail.com on 12 Oct 2009 at 2:42

GoogleCodeExporter commented 9 years ago
Ah, another bug:

1) Draw a poly
2) Create a curved segment
3) Rotate the poly
4) Move one of the poly points
5) Click undo 

What happens:  the poly un-rotates

Original comment by codedr...@gmail.com on 12 Oct 2009 at 2:44

GoogleCodeExporter commented 9 years ago
Another issue:

1) Draw a rough square using the poly tool
2) Rotate the path 45 degrees clockwise
3) Double-click the top point of the diamond (i.e. the top-left point of the 
square
before its rotation)

What happens: the control points are in the previously unrotated position.  
This can
be fixed by moving the point a little and mousing up.

Original comment by codedr...@gmail.com on 12 Oct 2009 at 3:00

GoogleCodeExporter commented 9 years ago
To further clarify the issue mentioned in comment 32:

1) Draw a rough square using the poly tool starting in the top-left and moving
clockwise (last point should be the bottom-left point before closing the square
2) Double-click the top-left and bottom-left points to turn them both into 
curves
3) Rotate the path clockwise 45 degrees (the shape should look vaguely like a 
heart now)
4) Move the top point (the one that's between two curves)

What happens: the control points to the left of the top point (the control 
points
controlling the last segment in the path) move oddly.

Original comment by codedr...@gmail.com on 12 Oct 2009 at 3:06

GoogleCodeExporter commented 9 years ago
Got c#32 and c#33 fixed, and c#34 fixed slightly...now instead it moves the 
poly 
slightly off from where it was.

Original comment by adeve...@gmail.com on 12 Oct 2009 at 6:42

GoogleCodeExporter commented 9 years ago
Marked as fixed, any new bugs can become their own issue.

Original comment by adeve...@gmail.com on 12 Oct 2009 at 7:16

GoogleCodeExporter commented 9 years ago
woohoo!

Original comment by codedr...@gmail.com on 12 Oct 2009 at 7:20