프로젝트

일반

사용자정보

개정판 43e1d368

ID43e1d3684849725d38b5c74b43d4bb593f546d7a
상위 d91efe5c
하위 42d49521

김태성이(가) 약 2년 전에 추가함

issue #0000 코드 정리

Change-Id: I7c8ba4ef6d78a7e4f51b72f226507cddac722939

차이점 보기:

MarkupToPDF/Controls/Polygon/CloudControl.cs
26 26
        public Path Base_CloudPath = null;
27 27
        public Path Base_CloudSubPath = null;
28 28

  
29
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
29
        private const double _CloudArcDepth =0.8;  /// 2018.05.14 added by humkyung
30 30

  
31 31
        static CloudControl()
32 32
        {
......
610 610
            bool reverse = (area > 0);
611 611
            /// up to here
612 612

  
613
            this._pathGeometry = new PathGeometry();
614
            this._pathSubGeometry = new PathGeometry();
615
            int count = this.PointSet.Count;
613
            this._pathGeometry = new PathGeometry { FillRule = FillRule.Nonzero};
614
            this._pathSubGeometry = new PathGeometry { FillRule = FillRule.Nonzero };
616 615

  
617 616
            if (isTransOn) // true라면 클라우드 컨트롤
618 617
            {
619
                for (int i = 0; i < (count - 1); i++)
618
                //PathFigure pathFigure = CloudControl.GeneratePolyWithCloud(this.PointSet, this.ArcLength, reverse);
619
                //_pathGeometry.Figures.Add(pathFigure);
620

  
621
                for (int i = 0; i < this.PointSet.Count - 1; i++)
620 622
                {
621
                    PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse);
623
                    var stPoint = this.PointSet[i];
624

  
625
                    Point edPoint = this.PointSet[i + 1];
626

  
627
                    //if (i < this.PointSet.Count() - 1)
628
                    //{
629
                    //    edPoint = this.PointSet[i + 1];
630
                    //}
631
                    //else
632
                    //{
633
                    //    edPoint = this.PointSet[0];
634
                    //}
635

  
636
                    PathFigure pathFigure = CloudControl.GenerateLineWithCloud(stPoint, edPoint, this.ArcLength, reverse);
622 637
                    _pathGeometry.Figures.Add(pathFigure);
623 638
                }
624 639
            }
......
626 641
            {
627 642
                PathFigure fm = new PathFigure();
628 643
                fm.StartPoint = this.PointSet[0];
629
                for (int i = 0; i < (count - 1); i++)
644
                for (int i = 0; i < this.PointSet.Count() - 2; i++)
630 645
                {
631 646
                    fm.Segments.Add(new LineSegment { Point = this.PointSet[i] });
632 647
                }
......
656 671
            }
657 672
            StartPoint = PointSet[0];
658 673
            this.PathData = this._pathGeometry;
674
        
659 675
            this.OverViewPathData = PathData;
660 676
            this.StrokeColor = StrokeColor;
661 677
            this.LineSize = LineSize;
......
675 691
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
676 692
        {
677 693
            PathFigure pathFigure = new PathFigure();
694

  
695
            var radius = arcLength_;
696
            double overlap = 5.5D / 6D;
697

  
698
            double delta = 2 * radius * overlap;
699

  
700
            pathFigure.StartPoint = p1;
701
            pathFigure.IsClosed = false;
702
            pathFigure.IsFilled = false;
703
            var prev = p2;
704

  
705
            var curr = p1;
706

  
707
            var dx = curr.X - prev.X;
708
            var dy = curr.Y - prev.Y;
709

  
710
            var len = Math.Sqrt(dx * dx + dy * dy);
711

  
712
            dx = dx / len;
713
            dy = dy / len;
714

  
715
            var length = 0D;
716

  
717
            for (int a = 0; a <= Math.Round(len / delta); a++)
718
            {
719
                if (length > len)
720
                {
721
                    length = len;
722
                }
723

  
724
                ArcSegment arcSeg = new ArcSegment();
725

  
726
                var x = prev.X + length * dx;
727
                var y = prev.Y + length * dy;
728

  
729
                if(!double.IsNaN(x) && !double.IsNaN(y))
730
                {
731
                    arcSeg.Point = new Point(x, y);
732
                    arcSeg.Size = new Size(radius, radius);
733
                    arcSeg.IsLargeArc = true;
734

  
735
                    if(reverse)
736
                    {
737
                       arcSeg.SweepDirection = SweepDirection.Counterclockwise;
738
                    }
739
                    else
740
                    {
741
                        arcSeg.SweepDirection = SweepDirection.Clockwise;
742
                    }
743

  
744
                    if (length == 0)
745
                    {
746
                        pathFigure.StartPoint = arcSeg.Point;
747
                    }
748
                    pathFigure.Segments.Add(arcSeg);
749

  
750
                }
751

  
752
                length += delta;
753
            }
754
            pathFigure.IsFilled = false;
755
            return pathFigure;
756
        }
757
       
758
        /// <summary>
759
        /// draw arcs between p1 and p2
760
        /// </summary>
761
        /// <author>humkyung</author>
762
        /// <param name="p1"></param>
763
        /// <param name="p2"></param>
764
        /// <param name="reverse"></param>
765
        /// <returns></returns>
766
        public static PathFigure GeneratePolyWithCloud(List<Point> points,double arcLength_, bool reverse)
767
        {
768
            PathFigure pathFigure = new PathFigure();
769

  
770
            var radius = arcLength_;
771
            double overlap = 5.5D / 6D;
772

  
773
            double delta = 2 * radius * overlap;
774

  
775
            if(points.Count() > 1)
776
            {
777
                pathFigure.StartPoint = points[0];
778
                pathFigure.IsClosed = false;
779
                pathFigure.IsFilled = false;
780
                Point prevArcPoint = points[0];
781

  
782
                for (int i = 0; i < points.Count -1; i++)
783
                {
784
                    Point curr = points[i];
785
                    Point prev = points[i + 1];
786

  
787

  
788
                    var dx = curr.X - prev.X;
789
                    var dy = curr.Y - prev.Y;
790

  
791
                    var len = Math.Sqrt(dx * dx + dy * dy);
792

  
793
                    dx = dx / len;
794
                    dy = dy / len;
795

  
796
                    var length = 0D;
797

  
798
                    for (int a = 0; a <= Math.Round(len / delta); a++)
799
                    {
800
                        if (length > len)
801
                        {
802
                            length = len;
803
                        }
804

  
805
                        ArcSegment arcSeg = new ArcSegment();
806
                       
807
                        var x = prev.X + length * dx;
808
                        var y = prev.Y + length * dy;
809

  
810
                        if (!double.IsNaN(x) && !double.IsNaN(y))
811
                        {
812
                            arcSeg.Point = new Point(x, y);
813
                            arcSeg.Size = new Size(radius, radius);
814
                            arcSeg.IsLargeArc = true;
815

  
816

  
817
                            if (reverse)
818
                            {
819
                                arcSeg.SweepDirection = SweepDirection.Counterclockwise;
820
                            }
821
                            else
822
                            {
823
                                arcSeg.SweepDirection = SweepDirection.Clockwise;
824
                            }
825

  
826
                            //if (length == 0)
827
                            //{
828
                            //    pathFigure.StartPoint = arcSeg.Point;
829
                            //}
830

  
831

  
832
                       
833
                            pathFigure.Segments.Add(arcSeg);
834

  
835
                            System.Diagnostics.Debug.WriteLine($"{prevArcPoint} { arcSeg.Point}");
836
                            prevArcPoint = arcSeg.Point;
837

  
838
                        }
839

  
840
                        length += delta;
841
                    }
842

  
843
                }
844
            }
845

  
846
            pathFigure.IsFilled = false;
847
            return pathFigure;
848
        }
849

  
850
        /// <summary>
851
        /// draw arcs between p1 and p2
852
        /// </summary>
853
        /// <author>humkyung</author>
854
        /// <param name="p1"></param>
855
        /// <param name="p2"></param>
856
        /// <param name="reverse"></param>
857
        /// <returns></returns>
858
        public static PathFigure GenerateLineWithCloudOld(Point p1, Point p2, double arcLength_, bool reverse)
859
        {
860
            PathFigure pathFigure = new PathFigure();
678 861
            pathFigure.StartPoint = p1;
679 862

  
680 863
            double arcLength = arcLength_;
......
695 878
                arcSeg.Size = new Size(arcLength * CloudControl._CloudArcDepth, arcLength * CloudControl._CloudArcDepth);						/// x size and y size of arc
696 879
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
697 880
                lastPt = arcSeg.Point;  /// save last point
698
                arcSeg.RotationAngle = theta + 90;
881
                //arcSeg.RotationAngle = theta + 90;
699 882
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
883

  
700 884
                pathFigure.Segments.Add(arcSeg);
701 885
            }
702 886

  
......
706 890
                arcLength = MathSet.DistanceTo(lastPt, p2);
707 891
                ArcSegment arcSeg = new ArcSegment();
708 892
                arcSeg.Size = new Size(arcLength * CloudControl._CloudArcDepth, arcLength * CloudControl._CloudArcDepth);	/// x size and y size of arc
709
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
710
                arcSeg.RotationAngle = theta;
893
                arcSeg.Point = new Point(p2.X, p2.Y);/// end point of arc
894
                //arcSeg.RotationAngle = theta;
711 895
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
712 896
                pathFigure.Segments.Add(arcSeg);
713 897

  
714 898
            }
715 899

  
716
            pathFigure.IsFilled = true;    
900
            pathFigure.IsFilled = true;
717 901
            return pathFigure;
718 902
        }
719 903

  

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)