Esempio n. 1
0
 public bool IntersectsWith(TitleBufferElement element)
 {
     if (_isSimple && element.IsSimple)
         return PlanimetryAlgorithms.AreRectanglesIntersect(_box, element._box);
     else 
     if (!_isSimple && !element.IsSimple)
     {
         return complexTitlesIntersect(this, element);
     }
     else
     if (!_isSimple && element.IsSimple)
         return element.intersectsWithComplexTitle(this);
     else
         return intersectsWithComplexTitle(element);
 }
Esempio n. 2
0
            private bool intersectsWithComplexTitle(TitleBufferElement complexOne)
            {
                if (!PlanimetryAlgorithms.AreRectanglesIntersect(_box, complexOne._box)) 
                    return false;

                Segment[] segments = new Segment[4]
                {
                    new Segment(_box.V1, PlanimetryEnvironment.NewCoordinate(_box.V1.X, _box.V2.Y)),
                    new Segment(PlanimetryEnvironment.NewCoordinate(_box.V1.X, _box.V2.Y), _box.V2),
                    new Segment(_box.V2, PlanimetryEnvironment.NewCoordinate(_box.V2.X, _box.V1.Y)),
                    new Segment(PlanimetryEnvironment.NewCoordinate(_box.V2.X, _box.V1.Y), _box.V1)
                };

                ICoordinate pointStub = null;
                Segment segmentStub = new Segment();

                foreach (Contour c in complexOne._followingTitle.EnvelopePolygon.Contours)
                {
                    Segment segment1 = new Segment(c.Vertices[0], c.Vertices[1]);
                    Segment segment2 = new Segment(c.Vertices[2], c.Vertices[3]);
                    for(int i = 0; i < 4; i++)
                        if (PlanimetryAlgorithms.SegmentsIntersection(segment1, segments[i], out pointStub, out segmentStub) != Dimension.None ||
                            PlanimetryAlgorithms.SegmentsIntersection(segment2, segments[i], out pointStub, out segmentStub) != Dimension.None)
                            return true;
                }

                return false;
            }
Esempio n. 3
0
            private static bool complexTitlesIntersect(TitleBufferElement element1, TitleBufferElement element2)
            {
                if (!PlanimetryAlgorithms.AreRectanglesIntersect(element1.Box, element2.Box))
                    return false;

                foreach (Contour c1 in element1.FollowingTitle.EnvelopePolygon.Contours)
                    foreach (Contour c2 in element1.FollowingTitle.EnvelopePolygon.Contours)
                        if (contoursIntersect(c1, c2))
                            return true;

                return false;
            }
Esempio n. 4
0
        private static void drawTitle(Graphics g, TitleBufferElement title, double scaleFactor, BoundingRectangle viewBox)
        {
            using (Font f = title.Style.GetFont())
                using (SolidBrush fontBrush = new SolidBrush(title.Style.Color))
                {
                    SizeF size = g.MeasureString(title.Title, f, new PointF(0, 0), _titleStringFormat);
                    ICoordinate originPoint = PlanimetryEnvironment.NewCoordinate((title.Box.V1.X + title.Box.V2.X) / 2, title.Box.V2.Y);

                    using (GraphicsPath path = new GraphicsPath())
                    {
                        if (title.IsSimple)
                        {
                            path.AddString(title.Title,
                                           f.FontFamily,
                                           (int)f.Style,
                                           f.Size,
                                           new PointF((float)((originPoint.X - viewBox.MinX) * scaleFactor),
                                                      (float)((viewBox.MaxY - originPoint.Y) * scaleFactor)),
                                           _titleStringFormat);

                            if (title.Style.UseOutline)
                                using (Pen pen = new Pen(_titleOutlineColor, title.Style.OutlineSize))
                                {
                                    pen.MiterLimit = 1;
                                    g.DrawPath(pen, path);
                                }
                            g.FillPath(fontBrush, path);
                        }
                        else
                        {
                            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                            if (title.Style.UseOutline)
                                using (Pen pen = new Pen(_titleOutlineColor, title.Style.OutlineSize))
                                {
                                    pen.MiterLimit = 1;
                                    foreach (FollowingTitleElement element in title.FollowingTitle.Elements)
                                    {
                                        g.TranslateTransform(element.TranslationPoint.X, element.TranslationPoint.Y);
                                        g.RotateTransform(element.RotationAngle);

                                        path.Reset();
                                        path.AddString(element.Substring, f.FontFamily, (int)f.Style, f.Size, element.TitleOrigin, StringFormat.GenericTypographic);
                                        g.DrawPath(pen, path);
                                        g.ResetTransform();
                                    }
                                }

                            using (Brush b = new SolidBrush(title.Style.Color))
                                foreach (FollowingTitleElement element in title.FollowingTitle.Elements)
                                {
                                    g.TranslateTransform(element.TranslationPoint.X, element.TranslationPoint.Y);
                                    g.RotateTransform(element.RotationAngle);

                                    path.Reset();
                                    path.AddString(element.Substring, f.FontFamily, (int)f.Style, f.Size, element.TitleOrigin, StringFormat.GenericTypographic);
                                    g.FillPath(fontBrush, path);
                                    g.ResetTransform();
                                }
                        }
                    }
                }
        }