private void GraphRedrawn(GroupedLines profileLines, int sessionId, bool update, List <int> linesIds = null)
        {
            if (update)
            {
                GraphicsLayerManager
                .UpdateGraphicLine(profileLines, sessionId);

                var profile = _workingProfiles.FirstOrDefault(p => p.SessionId == sessionId);
                //Save Profile if it was recalculated
                if (profile != null)
                {
                    SaveProfileSet(profile);
                }
            }
            else
            {
                if (profileLines.LineId == 1)
                {
                    GraphicsLayerManager.RemoveGraphic(sessionId, linesIds);
                }

                GraphicsLayerManager
                .AddLinesToWorkingGraphics(profileLines.Polylines, sessionId, profileLines);
            }
        }
Beispiel #2
0
        private void UpdateGraphicLine(GroupedLines groupedLines, int profileId,
                                       MilSpaceGraphicsTypeEnum graphicsType, bool selectionRemove = false)
        {
            RemoveLineFromSessionGraphicsByLineId(profileId, groupedLines.LineId, graphicsType);

            int elementId  = 0;
            int lineNumber = 0;
            int width;

            if (selectionRemove)
            {
                width = 2;
            }
            else
            {
                width = (groupedLines.IsSelected) ? 4 : 2;
            }

            foreach (var line in groupedLines.Polylines)
            {
                var ge = new GraphicElement()
                {
                    Source    = line,
                    ElementId = ++elementId,
                    ProfileId = profileId,
                    LineId    = groupedLines.LineId
                };

                var color = (groupedLines.Lines[lineNumber].Visible) ? groupedLines.VisibleColor
                                                                     : groupedLines.InvisibleColor;

                var pointFrom = groupedLines.Lines[lineNumber].PointFrom;
                var isVertex  = groupedLines.IsPrimitive && groupedLines.Vertices.Exists(point => point.X == pointFrom.X && point.Y == pointFrom.Y);

                LineType lineType;

                if (groupedLines.Lines.Count() == 1)
                {
                    lineType = LineType.DefaultLine;
                }
                else if (groupedLines.Lines.First() == groupedLines.Lines[lineNumber])
                {
                    lineType = LineType.Point;
                }
                else if (groupedLines.Lines.Last() == groupedLines.Lines[lineNumber])
                {
                    lineType = (!isVertex) ? LineType.Arrow : LineType.DefaultLine;
                }
                else
                {
                    lineType = (!isVertex) ? LineType.Line : LineType.Point;
                }

                AddPolyline(ge, graphicsType, color, lineType, false, false, width);

                lineNumber++;
            }

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        private void SelectedProfileChanged(GroupedLines oldSelectedLines, GroupedLines newSelectedLines, int profileId)
        {
            GraphicsLayerManager.ChangeSelectProfileOnGraph(oldSelectedLines, newSelectedLines, profileId);

            if (oldSelectedLines != null)
            {
                oldSelectedLines.IsSelected = false;
            }
        }
Beispiel #4
0
        public void ChangeSelectProfileOnGraph(GroupedLines oldSelectedLines, GroupedLines newSelectedLines, int profileId)
        {
            if (oldSelectedLines != null && oldSelectedLines.Polylines != null)
            {
                UpdateGraphicLine(oldSelectedLines, profileId, MilSpaceGraphicsTypeEnum.Session, true);
            }

            if (newSelectedLines != null && newSelectedLines.Polylines != null)
            {
                newSelectedLines.IsSelected = true;
                UpdateGraphicLine(newSelectedLines, profileId, MilSpaceGraphicsTypeEnum.Session, false);
            }
        }
Beispiel #5
0
        public static List <GroupedLines> GetSegmentsFromProfileLine(ProfileSurface[] profileSurfaces, ISpatialReference spatialReference)
        {
            var polylines = new List <IPolyline>();

            foreach (var surface in profileSurfaces)
            {
                polylines.AddRange(ConvertLineToPrimitivePolylines(surface, spatialReference));
            }
            var lines = new GroupedLines()
            {
                Polylines   = polylines,
                Lines       = ConvertEsriPolylineToLine(polylines),
                LineId      = 1,
                IsPrimitive = true
            };

            lines.Vertices = lines.Lines.Select(line => line.PointFrom).ToList();

            return(new List <GroupedLines>()
            {
                lines
            });
        }
        internal void AddInvisibleZone(double observerHeight, ProfileSurface profileSurface,
                                       Color visibleColor, Color invisibleColor, bool update = true,
                                       List <int> linesIds = null)
        {
            var invisibleSurface       = new ProfileSurface();
            var invisibleSurfacePoints = new List <ProfileSurfacePoint>();
            var groupedLinesSegments   = new List <ProfileLine>();
            var isPrimitive            = true;
            var surfaceSegments        = GetLineSegments(profileSurface.LineId);

            if (surfaceSegments == null)
            {
                surfaceSegments = new List <ProfileSurface> {
                    profileSurface
                };
                isPrimitive = false;
            }

            foreach (var segment in surfaceSegments)
            {
                var firstPointDistance      = segment.ProfileSurfacePoints[0].Distance;
                var sightLineKoef           = 0.0;
                var isInvisibleZone         = false;
                var observerFullHeight      = observerHeight + segment.ProfileSurfacePoints[0].Z;
                var invisibleSurfaceSegment = new ProfileSurface();
                var invisiblePoints         = new List <ProfileSurfacePoint>();

                invisibleSurfaceSegment.LineId = profileSurface.LineId;

                for (var i = 0; i < segment.ProfileSurfacePoints.Length; i++)
                {
                    var currPoint = segment.ProfileSurfacePoints[i];
                    if (!isInvisibleZone)
                    {
                        if (i < segment.ProfileSurfacePoints.Length - 1)
                        {
                            if (CalcAngleOfVisibility(observerFullHeight, segment.ProfileSurfacePoints[i],
                                                      segment.ProfileSurfacePoints[i + 1], firstPointDistance) < 0)
                            {
                                var firstInvisiblePoint = segment.ProfileSurfacePoints[i + 1];

                                if (!invisiblePoints.Exists(point => point == firstInvisiblePoint))
                                {
                                    invisiblePoints.Add(firstInvisiblePoint);
                                }

                                isInvisibleZone = true;
                                sightLineKoef   = (firstInvisiblePoint.Z - observerFullHeight) / (firstInvisiblePoint.Distance - firstPointDistance);
                                i++;
                            }
                        }
                    }
                    else
                    {
                        if (FindY(observerFullHeight, sightLineKoef, segment.ProfileSurfacePoints[i].Distance - firstPointDistance)
                            < segment.ProfileSurfacePoints[i].Z)
                        {
                            isInvisibleZone = false;
                            invisiblePoints.Add(segment.ProfileSurfacePoints[i]);

                            i++;
                        }
                        else
                        {
                            invisiblePoints.Add(segment.ProfileSurfacePoints[i]);
                        }
                    }

                    currPoint.Visible = !isInvisibleZone;
                }

                invisibleSurfaceSegment.ProfileSurfacePoints = invisiblePoints.ToArray();
                groupedLinesSegments.AddRange(GetLines(segment, invisibleSurfaceSegment, _profileSession.SessionId));

                invisibleSurfacePoints.AddRange(invisiblePoints);
            }

            invisibleSurface.ProfileSurfacePoints = invisibleSurfacePoints.ToArray();
            invisibleSurface.LineId = profileSurface.LineId;

            _surfaceProfileChart.AddInvisibleLine(invisibleSurface);
            CalcProfilesVisiblePercents(invisibleSurface, profileSurface);

            var profileLines = new GroupedLines
            {
                LineId         = profileSurface.LineId,
                Lines          = groupedLinesSegments,
                VisibleColor   = ColorToEsriRgb(visibleColor),
                InvisibleColor = ColorToEsriRgb(invisibleColor)
            };

            profileLines.Polylines = ProfileLinesConverter
                                     .ConvertLineToEsriPolyline(profileLines.Lines,
                                                                ArcMap.Document.FocusMap.SpatialReference);
            if (isPrimitive)
            {
                var spatialReference = _profileSession.ProfileLines.First(line => line.Id == profileLines.LineId).SpatialReference;
                profileLines.Vertices = surfaceSegments.Select(surface =>
                {
                    var point = surface.ProfileSurfacePoints.First();

                    return(new ProfilePoint {
                        X = point.X, Y = point.Y, SpatialReference = spatialReference
                    });
                }
                                                               ).ToList();

                profileLines.IsPrimitive = true;
            }

            if (_profileSession.Segments.Count < profileSurface.LineId - 1)
            {
                _profileSession.Segments.Add(profileLines);
            }
            else
            {
                profileLines.IsSelected = _profileSession.Segments[profileSurface.LineId - 1].IsSelected;
                _profileSession.Segments[profileSurface.LineId - 1] = profileLines;
            }

            InvisibleZonesChanged?.Invoke(profileLines, _profileSession.SessionId, update, linesIds);
        }
Beispiel #7
0
        private void AddLinesToGraphics(IEnumerable <IPolyline> profileLines, int profileId,
                                        MilSpaceGraphicsTypeEnum graphicsType, GroupedLines profileColorLines = null)
        {
            var curList    = allGraphics[graphicsType];
            int elementId  = 0;
            var lineNumber = 0;
            int width      = 2;

            if (profileColorLines != null)
            {
                RemoveLineFromSessionGraphicsByLineId(profileId, profileColorLines.LineId, graphicsType);
                width = (profileColorLines.IsSelected) ? 4 : 2;
            }

            foreach (var line in profileLines)
            {
                elementId++;

                if (profileColorLines != null)
                {
                    var ge = new GraphicElement()
                    {
                        Source = line, ElementId = elementId, ProfileId = profileId, LineId = profileColorLines.LineId
                    };
                    var color = (profileColorLines.Lines[lineNumber].Visible) ? profileColorLines.VisibleColor
                                                                              : profileColorLines.InvisibleColor;
                    var pointFrom = profileColorLines.Lines[lineNumber].PointFrom;
                    var isVertex  = profileColorLines.IsPrimitive && profileColorLines.Vertices.Exists(point => point.X == pointFrom.X && point.Y == pointFrom.Y);

                    LineType lineType;

                    if (profileColorLines.Lines.Count() == 1)
                    {
                        lineType = LineType.DefaultLine;
                    }
                    else if (profileColorLines.Lines.First() == profileColorLines.Lines[lineNumber])
                    {
                        lineType = LineType.Point;
                    }
                    else if (profileColorLines.Lines.Last() == profileColorLines.Lines[lineNumber])
                    {
                        lineType = (!isVertex) ? LineType.Arrow: LineType.DefaultLine;
                    }
                    else
                    {
                        lineType = (!isVertex) ? LineType.Line : LineType.Point;
                    }


                    AddPolyline(ge, graphicsType, color, lineType, false, false, width);

                    lineNumber++;
                }
                else
                {
                    var graphic = curList.FirstOrDefault(g => g.ProfileId == profileId && g.ElementId == elementId);
                    if (graphic != null)
                    {
                        DeleteGraphicsElement(graphic);
                        curList.Remove(graphic);
                    }

                    var ge = new GraphicElement()
                    {
                        Source = line, ElementId = elementId, ProfileId = profileId, LineId = elementId
                    };
                    AddPolyline(ge, graphicsType);
                }
            }
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #8
0
 public void UpdateGraphicLine(GroupedLines groupedLines, int profileId)
 {
     UpdateGraphicLine(groupedLines, profileId, MilSpaceGraphicsTypeEnum.Session);
 }
Beispiel #9
0
 public void AddLinesToWorkingGraphics(IEnumerable <IPolyline> profileLines, int profileId,
                                       GroupedLines profileColorLines = null)
 {
     AddLinesToGraphics(profileLines, profileId, MilSpaceGraphicsTypeEnum.Session, profileColorLines);
 }
Beispiel #10
0
 public void ShowLineOnWorkingGraphics(int profileId, GroupedLines groupedLines)
 {
     AddLinesToGraphics(groupedLines.Polylines, profileId, MilSpaceGraphicsTypeEnum.Session, groupedLines);
 }
 private void InvokeInvisibleZonesChanged(GroupedLines profileLines, int sessionId, bool update,
                                          List <int> linesIds)
 {
     ProfileRedrawn?.Invoke(profileLines, sessionId, update, linesIds);
 }
 internal void InvokeSelectedProfileChanged(GroupedLines oldSelectedLines, GroupedLines newSelectedLines, int profileId)
 {
     SelectedProfileChanged?.Invoke(oldSelectedLines, newSelectedLines, profileId);
 }