개정판 d2114d3b
issue #923: add OnMoveCtrlPoint method to interface
Change-Id: If3b10f5b54eaecd8bd8fa299d702e70e05d4b97e
MarkupToPDF/Controls/Etc/SymControlN.cs | ||
---|---|---|
379 | 379 |
} |
380 | 380 |
|
381 | 381 |
/// <summary> |
382 |
/// move control point has same location of given pt along given delta |
|
383 |
/// </summary> |
|
384 |
/// <author>humkyung</author> |
|
385 |
/// <date>2019.06.20</date> |
|
386 |
/// <param name="pt"></param> |
|
387 |
/// <param name="dx"></param> |
|
388 |
/// <param name="dy"></param> |
|
389 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy) |
|
390 |
{ |
|
391 |
IPath path = (this as IPath); |
|
392 |
|
|
393 |
Point selected = MathSet.getNearPoint(path.PointSet, pt); |
|
394 |
selected.X += dx; |
|
395 |
selected.Y += dy; |
|
396 |
int i = 0; |
|
397 |
for (i = 0; i < (this as IPath).PointSet.Count; i++) |
|
398 |
{ |
|
399 |
if (pt.Equals((this as IPath).PointSet[i])) |
|
400 |
{ |
|
401 |
path.PointSet[i] = selected; |
|
402 |
break; |
|
403 |
} |
|
404 |
} |
|
405 |
|
|
406 |
var ReverseP = (i + path.PointSet.Count / 2) % path.PointSet.Count; |
|
407 |
var PreviousP = (i + (path.PointSet.Count - 1)) % path.PointSet.Count; |
|
408 |
var NextP = (i + 1) % path.PointSet.Count; |
|
409 |
|
|
410 |
var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]); |
|
411 |
|
|
412 |
var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]); |
|
413 |
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, |
|
414 |
path.PointSet[i].Y - path.PointSet[ReverseP].Y); |
|
415 |
path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet[ReverseP].Y + PreviousV.Y * l); |
|
416 |
|
|
417 |
var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]); |
|
418 |
l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet |
|
419 |
[i].Y - path.PointSet[ReverseP].Y); |
|
420 |
path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l); |
|
421 |
|
|
422 |
this.updateControl(); |
|
423 |
} |
|
424 |
|
|
425 |
/// <summary> |
|
382 | 426 |
/// return SymControlN's area |
383 | 427 |
/// </summary> |
384 | 428 |
/// <author>humkyung</author> |
내보내기 Unified diff