Exemple #1
0
 public LayoutIntersection(ILayoutLine item1, PointM intersection, bool isStart)
 {
     Item1        = item1;
     Intersection = intersection;
     WorldCoord   = Intersection.ToVector();
     IsStartPoint = isStart;
 }
Exemple #2
0
 /// <summary>
 /// 模拟物流配送。
 /// Simulate the logistics
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_timer_Tick(object sender, EventArgs e)
 {
     try
     {
         int index = m_trackingLayer.IndexOf("playPoint");
         if (index != -1)
         {
             m_trackingLayer.Remove(index);
         }
         if (m_lineM.Length != 0)
         {
             PointM   pointM = m_lineM.GetPart(0)[m_count];
             GeoPoint point  = new GeoPoint(pointM.X, pointM.Y);
             GeoStyle style  = new GeoStyle();
             style.LineColor  = Color.FromArgb(0, 255, 255);
             style.MarkerSize = new Size2D(8, 8);
             point.Style      = style;
             m_trackingLayer.Add(point, "playPoint");
             m_count++;
             if (m_count >= m_lineM.GetPart(0).Count)
             {
                 m_count = 0;
             }
         }
         m_mapControl.Map.Refresh();
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Exemple #3
0
 public LayoutIntersection(ILayoutLine item1, ILayoutLine item2, PointM intersection)
 {
     Item1        = item1;
     Item2        = item2;
     Intersection = intersection;
     WorldCoord   = Intersection.ToVector();
 }
Exemple #4
0
        public void TrimEnd(LayoutLine trimLine, bool extendIfNeeded = false)
        {
            int    interIdx;
            PointM interPt = PointM.Empty;

            if (!Intersects(trimLine, out interPt, out interIdx, extendIfNeeded))
            {
                return;
            }

            var pointsToKeep = new List <PointM>();

            for (int i = 0; i <= interIdx; i++)
            {
                pointsToKeep.Add(Points[i]);

                if (interIdx == i)
                {
                    var ptRel = GetLocationRelativeToSegment(Points[i].ToVector(), Points[i + 1].ToVector(), interPt.ToVector());
                    if (ptRel == PointRelation.After)
                    {
                        pointsToKeep.Add(Points[i + 1]);
                    }
                }
            }

            pointsToKeep.Add(interPt);

            Points.Clear();
            _Points.AddRange(pointsToKeep);

            //remove points that are very close
            MergePoints(0.05);
        }
Exemple #5
0
        }                                          // Предыдущая вершина

        public GraphVertexInfo(PointM vertex)
        {
            Vertex         = vertex;
            IsUnvisited    = true;
            EdgesWeightSum = double.MaxValue;
            PreviousVertex = null;
        }
        private static VectorLayer ReadPointMShapes(BinaryReader br, int shapeNum)
        {
            VectorLayer aLayer = new VectorLayer(ShapeTypes.PointM);
            int         RecordNum, ContentLength, aShapeType;
            double      x, y, m;

            //PointD aPoint;

            for (int i = 0; i < shapeNum; i++)
            {
                //br.ReadBytes(12); //记录头8个字节和一个int(4个字节)的shapetype
                RecordNum     = SwapByteOrder(br.ReadInt32());
                ContentLength = SwapByteOrder(br.ReadInt32());
                aShapeType    = br.ReadInt32();

                x = br.ReadDouble();
                y = br.ReadDouble();
                m = br.ReadDouble();

                PointMShape aP     = new PointMShape();
                PointM      aPoint = new PointM();
                aPoint.X = x;
                aPoint.Y = y;
                aPoint.M = m;
                aP.Point = aPoint;
                aLayer.ShapeList.Add(aP);
            }

            //Create legend scheme
            aLayer.LegendScheme = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Black, 5);
            return(aLayer);
        }
Exemple #7
0
 internal override void FlipHandedness()
 {
     base.FlipHandedness();
     if (!FretZero.IsEmpty)
     {
         FretZero = new PointM(FretZero.X * -1, FretZero.Y);
     }
 }
Exemple #8
0
        public PointM GetRelativePoint(StringLine str, PointM pos)
        {
            //if (!(str == Left || str == Right))
            //    return PointM.Empty;
            var strPosRatio = PointM.Distance(pos, str.P2) / PointM.Distance(str.FretZero, str.P2);
            var dist        = PointM.Distance(P0, P2);

            return(P2 + (Direction * -1 * (dist * strPosRatio)));
        }
Exemple #9
0
 public static void AddPoing(PointM point)
 {
     if (point == null)
     {
         return;
     }
     db.Points.Add(point);
     db.SaveChanges();
 }
Exemple #10
0
 public LayoutMeasure(PointM p1, PointM p2)
 {
     FromPoint = p1;
     ToPoint   = p2;
     Length    = PointM.Distance(p1, p2);
     Width     = Measure.Abs(p2.X - p1.X);
     Height    = Measure.Abs(p2.Y - p1.Y);
     Direction = Angle.FromPoints(p1.ToVector(), p2.ToVector());
 }
Exemple #11
0
        private void PlaceFrets()
        {
            var stringFrets = new Dictionary <int, List <FretPosition> >();

            foreach (var str in Strings)
            {
                stringFrets.Add(str.Index, CalculateFretsForString(str));
            }

            var fretSegments = new List <FretSegment>();

            //create fret "segments"; store each fret position for each strings in a list
            foreach (var str in Strings)
            {
                for (int i = MinimumFret; i <= MaximumFret; i++)
                {
                    if (stringFrets[str.Index].Any(f => f.FretIndex == i))
                    {
                        var fretPos   = stringFrets[str.Index].First(f => f.FretIndex == i);
                        var perpLine  = str.LayoutLine.Equation.GetPerpendicular(fretPos.Position.ToVector());
                        var leftLine  = GetStringBoundaryLine(str, FingerboardSide.Bass);
                        var rightLine = GetStringBoundaryLine(str, FingerboardSide.Treble);
                        var p1        = PointM.FromVector(perpLine.GetIntersection(leftLine.Equation), fretPos.Position.Unit);
                        var p2        = PointM.FromVector(perpLine.GetIntersection(rightLine.Equation), fretPos.Position.Unit);

                        var fretSeg = new FretSegment(i, str, fretPos.Position, p1, p2)
                        {
                            IsVirtual = !str.HasFret(i)
                        };
                        fretSegments.Add(fretSeg);
                    }
                }
            }

            //regroup fret segments that are connected to form a line/curve
            for (int f = MinimumFret; f <= MaximumFret; f++)
            {
                for (int s = 0; s < NumberOfStrings; s++)
                {
                    if (!Strings[s].HasFret(f))
                    {
                        continue;
                    }
                    var followingStrings = Strings.Skip(s).TakeWhile(x => x.HasFret(f));
                    var followingFrets   = fretSegments.Where(fs => fs.FretIndex == f && followingStrings.Contains(fs.String)).ToList();

                    followingFrets.AddRange(fretSegments.Where(fs => fs.IsVirtual && fs.FretIndex == f &&
                                                               (fs.String == followingFrets.Last().String.Next ||
                                                                fs.String == followingFrets.First().String.Previous)).Select(fs => fs.Clone()));

                    var line = AddVisualElement(new FretLine(followingFrets));
                    line.ComputeFretShape();
                    s += followingStrings.Count() - 1;
                }
            }
        }
Exemple #12
0
        public static void RemovePoint(PointM point)
        {
            if (point == null)
            {
                return;
            }
            db.Points.Remove(point);

            db.SaveChanges();
        }
Exemple #13
0
 public void MergePoints(double tolerence = 0.01)
 {
     for (int i = 0; i < Points.Count - 1; i++)
     {
         if (Points.Count - 1 > 3 && PointM.Distance(Points[i + 1], Points[i]).NormalizedValue < tolerence)
         {
             Points.RemoveAt(i--);
         }
     }
 }
Exemple #14
0
        public PointM SnapToLine(PointM pos, LineSnapDirection snapMode = LineSnapDirection.Perpendicular, bool infiniteLine = true)
        {
            var result = SnapToLine(pos.ToVector(), snapMode, infiniteLine);

            if (!result.IsEmpty)
            {
                return(PointM.FromVector(result, pos.Unit ?? P1.Unit ?? P2.Unit));
            }
            return(PointM.Empty);
        }
Exemple #15
0
 public void UpdateInfos()
 {
     _Length = Measure.Zero;
     for (int i = 0; i < Points.Count - 1; i++)
     {
         _Length += PointM.Distance(Points[i], Points[i + 1]);
     }
     _Bounds = RectangleM.BoundingRectangle(_Points);
     isDirty = false;
 }
Exemple #16
0
 GraphVertexInfo GetVertexInfo(PointM v)
 {
     foreach (var i in infos)
     {
         if (i.Vertex.Equals(v))
         {
             return(i);
         }
     }
     return(null);
 }
Exemple #17
0
        public bool Intersects(LayoutLine line, out PointM intersection, out int segmentIndex, bool infiniteLine = true)
        {
            intersection = PointM.Empty;

            if (Intersects(line.Equation, out Vector virtualInter, out segmentIndex, infiniteLine))
            {
                intersection = PointM.FromVector(virtualInter, Points.First().Unit);
                return(true);
            }

            return(false);
        }
Exemple #18
0
        public bool Intersects(LayoutLine line, out PointM intersection, bool infiniteLine = true)
        {
            intersection = PointM.Empty;

            if (Intersects(line.Equation, out Vector inter, infiniteLine))
            {
                intersection = PointM.FromVector(inter, P1.Unit ?? P2.Unit);
                return(true);
            }

            return(false);
        }
Exemple #19
0
 /// <summary>
 /// Проверка,  это ли ребро связывает точки (при преобразовании точек в маршрут)
 /// </summary>
 public bool isThatEdge(PointM first, PointM second)
 {
     if (PointFrom == first && PointTo == second)
     {
         return(true);
     }
     if (PointFrom == second && PointTo == first)
     {
         return(true);
     }
     return(false);
 }
Exemple #20
0
        // Формирование пути
        List <PointM> GetPath(PointM startVertex, PointM endVertex)
        {
            List <PointM> path = new List <PointM>();

            path.Add(endVertex);

            while (startVertex != endVertex)
            {
                endVertex = GetVertexInfo(endVertex).PreviousVertex;
                path.Add(endVertex);
            }
            return(path);
        }
        public SchemePlanPage(Room room) : this() // открытие схемы с фокусом на помещение
        {
            FloorPicker.ItemsSource  = FloorData.Floors;
            FloorData.CurrentFloor   = room.Floor;
            FloorPicker.SelectedItem = FloorData.CurrentFloor;

            // переместить матрицу на координаты помещения
            PointM point  = PointData.Find(room);
            float  height = (float)DeviceDisplay.MainDisplayInfo.Height / 4;
            float  width  = (float)DeviceDisplay.MainDisplayInfo.Width / 2;

            bitmap.Matrix = SKMatrix.MakeTranslation((float)(-point.X + width),
                                                     (float)(-point.Y + height));
        }
Exemple #22
0
        private List <KindaRepository> DBSelectByMainFeatures(int percents, SearchModel whatToSearch)
        {
            List <KindaRepository> firstSelect = new List <KindaRepository>();
            SizeM _3DimensionSize = SomeHelpful.OrderSize(whatToSearch.Size1, whatToSearch.Size2, whatToSearch.Size3);


            decimal allowance          = Allowance(_3DimensionSize.P2, _3DimensionSize.P1);
            decimal percentsCalculated = Percents(percents);


            PointM allowance1 = new PointM {
                LowerBound = allowance - percentsCalculated, UpperBound = allowance + percentsCalculated
            };                                                                                                                           //10% допустимое отклонение

            allowance = Allowance(_3DimensionSize.P3, _3DimensionSize.P2);
            PointM allowance2 = new PointM {
                LowerBound = allowance - percentsCalculated, UpperBound = allowance + percentsCalculated
            };                                                                                                                           //10% допустимое отклонение



            using (dataSearch = new SQLRepositoryDataContext(ConfigurationSettings.SQLConnection1))
            {
                if (dataSearch != null)
                {
                    var table = dataSearch.KindaRepositories.ToList();

                    try
                    {
                        firstSelect = table.Where(
                            x =>
                            (Allowance(x.Size2, x.Size1) >= allowance1.LowerBound && Allowance(x.Size2, x.Size1) <= allowance1.UpperBound &&//поиск деталей соответствующим допустимому отклонению
                             Allowance(x.Size3, x.Size2) >= allowance2.LowerBound && Allowance(x.Size3, x.Size2) <= allowance2.UpperBound

                            )).ToList();
                    }
                    catch (Exception fail)
                    {
                        MessageBox.Show(fail.Message);
                        throw fail;
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Не удалось установить подключение к базе даных. Проверте строку подключения и настройки сети!");
                }
            }

            return(firstSelect);
        }
Exemple #23
0
        public StringCenter(StringLine left, StringLine right)
        {
            Left  = left;
            Right = right;
            P1    = PointM.Average(left.P1, right.P1);
            P2    = PointM.Average(left.P2, right.P2);
            P0    = PointM.Average(left.FretZero, right.FretZero);
            //P1 = PointM.FromVector(Equation.GetPointForY(Math.Min(left.P1.Y.NormalizedValue, right.P1.Y.NormalizedValue)), P1.Unit);

            //P1 = PointM.Average(left.FretZero, right.FretZero);
            //P2 = PointM.Average(left.P2, right.P2);
            //var nutLine = Line.FromPoints((Vector)left.P1, (Vector)right.P1);

            //P1 = PointM.FromVector(Equation.GetIntersection(nutLine), P1.Unit ?? P2.Unit);
        }
Exemple #24
0
        public bool Intersects(LayoutPolyLine line, out PointM intersection)
        {
            intersection = PointM.Empty;
            for (int i = 0; i < line.Points.Count - 1; i++)
            {
                var segLine = Line.FromPoints(line.Points[i].ToVector(), line.Points[i + 1].ToVector());
                if (Intersects(segLine, out Vector virtualInter, false))
                {
                    intersection = PointM.FromVector(virtualInter, UnitOfMeasure.Mm);
                    return(true);
                }
            }

            return(false);
        }
Exemple #25
0
 private SvgLine CreateSvgLine(SvgElement owner, PointM p1, PointM p2, SvgUnit stroke, Color color, SvgUnitCollection dashPattern)
 {
     var svgLine = new SvgLine()
     {
         StartX = GetRelativeUnit(p1.X + OriginOffset.X),
         StartY = GetRelativeUnit(p1.Y * -1 + OriginOffset.Y),
         EndX = GetRelativeUnit(p2.X + OriginOffset.X),
         EndY = GetRelativeUnit(p2.Y * -1 + OriginOffset.Y),
         StrokeWidth = stroke,
         Stroke = new SvgColourServer(color),
         StrokeDashArray = dashPattern
     };
     if (owner != null)
         owner.Children.Add(svgLine);
     return svgLine;
 }
Exemple #26
0
        public StringLine ConstructString(SIString str, Measure nutPos, Measure bridgePos)
        {
            var     opp = Measure.Abs(nutPos - bridgePos);
            Measure adj = str.ScaleLength;

            if (str.LengthCalculationMethod == LengthFunction.AlongString && opp > Measure.Zero)
            {
                var theta = MathP.Asin(opp.NormalizedValue / str.ScaleLength.NormalizedValue);
                adj = MathP.Cos(theta) * str.ScaleLength;
            }

            var p1 = new PointM(nutPos, (adj / 2d));
            var p2 = new PointM(bridgePos, (adj / 2d) * -1d);

            return(AddVisualElement(new StringLine(str, p1, p2)));
        }
Exemple #27
0
        public PointM GetRelativePoint(StringLine str, PointM pos)
        {
            PointM startPt = PointM.Empty;

            if (str.Index == 0)
            {
                startPt = Side == FingerboardSide.Treble ? str.P1 : str.FretZero;
            }
            else if (str.Index == Layout.NumberOfStrings - 1)
            {
                startPt = Side == FingerboardSide.Bass ? str.P1 : str.FretZero;
            }

            var strPosRatio = PointM.Distance(pos, str.P2) / PointM.Distance(startPt, str.P2);
            var endPt       = RealEnd.IsEmpty ? P2 : RealEnd;
            var dist        = PointM.Distance(P1, endPt);

            return(endPt + (Direction * -1 * (dist * strPosRatio)));
        }
Exemple #28
0
        // Поиск кратчайшего пути по вершинам
        public List <PointM> FindShortestPath(PointM startVertex, PointM finishVertex)
        {
            InitInfo();
            var first = GetVertexInfo(startVertex);

            first.EdgesWeightSum = 0;
            while (true)
            {
                var current = FindUnvisitedVertexWithMinSum();
                if (current == null)
                {
                    break;
                }

                SetSumToNextVertex(current);
            }

            return(GetPath(startVertex, finishVertex));
        }
Exemple #29
0
        public PointM GetPerpendicularPoint(PointM pos, Measure dist)
        {
            var posVec = pos.ToVector();

            for (int i = 0; i < Points.Count - 1; i++)
            {
                var p1         = Points[i].ToVector();
                var p2         = Points[i + 1].ToVector();
                var ptRelation = GetLocationRelativeToSegment(p1, p2, posVec);

                if (ptRelation != PointRelation.Invalid)
                {
                    var segLine = Line.FromPoints(p1, p2);
                    var perp    = segLine.GetPerpendicular(posVec);
                    var result  = posVec + (perp.Vector * dist.NormalizedValue);
                    return(PointM.FromVector(result, dist.Unit));
                }
            }

            return(PointM.Empty);
        }
Exemple #30
0
        protected override void InitializeDocument()
        {
            Document = new SvgDocument();

            if (!string.IsNullOrEmpty(Layout.LayoutName))
                Document.CustomAttributes.Add("LayoutName", Layout.LayoutName);

            LayoutBounds = Layout.GetLayoutBounds();

            Document.X = new SvgUnit(0);
            Document.Y = new SvgUnit(0);
            Document.Width = GetDocumentUnit(LayoutBounds.Width);
            Document.Height = GetDocumentUnit(LayoutBounds.Height);

            if (Options.InkscapeCompatible)
            {
                Document.CustomAttributes.Add("xmlns:inkscape", "http://www.inkscape.org/namespaces/inkscape");
                //The Svg library serializes the viewbox with comma and space, but this combination is not handled by the Inkscape DXF exporter
                Document.CustomAttributes.Add("viewBox",
                    string.Format(NumberFormatInfo.InvariantInfo, "0,0,{0},{1}",
                    LayoutBounds.Width[Options.ExportUnit].DoubleValue,
                    LayoutBounds.Height[Options.ExportUnit].DoubleValue));
            }
            else
            {
                Document.ViewBox = new SvgViewBox(0, 0, Document.Width, Document.Height);
            }

            OriginOffset = new PointM(LayoutBounds.Location.X * -1, LayoutBounds.Location.Y);
            OriginOffestVec = OriginOffset.ToVector(Options.ExportUnit);

            LineDashPattern = new SvgUnitCollection
            {
                GetRelativeUnit(6, SvgUnitType.Point),
                GetRelativeUnit(4, SvgUnitType.Point),
                GetRelativeUnit(2, SvgUnitType.Point),
                GetRelativeUnit(4, SvgUnitType.Point)
            };
        }