コード例 #1
0
        private void InitPanelShapes(PreferencesPanel panel)
        {
            foreach (Control c in panel.Controls)
            {
                if (c is ShapeContainer)
                {
                    foreach (var shape in (c as ShapeContainer).Shapes)
                    {
                        if (shape is LineShape)
                        {
                            LineShape line = (shape as LineShape);

                            line.X1          = 0;
                            line.X2          = _PanelGeneral.ClientSize.Width;                    // we can use this as a gauge since theyre all the same size.
                            line.BorderColor = SystemColors.ControlLight;

                            if (panel is AccountPanel)
                            {
                                line.X1  = 8;
                                line.X2 -= 12;                                 // account panels have no padding, 10 - 2 for the borders. yeah yeah, it's not dynamic. PPFTTT.
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: JTextBox.cs プロジェクト: javier1905/FABRICA
 public void CargaCordenadasLinea(LineShape linea)
 {
     linea.X1 = this.Location.X;
     linea.Y1 = this.Location.Y + this.Height + 1;
     linea.X2 = linea.X1 + this.Width;
     linea.Y2 = this.Location.Y + this.Height + 1;
 }
コード例 #3
0
ファイル: PolyLineTool.cs プロジェクト: thedeveus/Core2D
        private void PointInternal(IToolContext context, double x, double y, Modifier modifier)
        {
            Filters?.Any(f => f.Process(context, ref x, ref y));

            context.Renderer.SelectedShapes.Remove(_line.Point);
            _line.Point = context.GetNextPoint(x, y, Settings?.ConnectPoints ?? false, Settings?.HitTestRadius ?? 7.0);
            _points[_points.Count - 1] = _line.Point;

            if (!context.Renderer.SelectedShapes.Contains(_line.Point))
            {
                context.Renderer.SelectedShapes.Add(_line.Point);
            }

            context.WorkingContainer.Shapes.Remove(_line);
            context.CurrentContainer.Shapes.Add(_line);

            _line = new LineShape()
            {
                StartPoint = _points.Last(),
                Point      = context.GetNextPoint(x, y, false, 0.0),
                Style      = context.CurrentStyle
            };
            _points.Add(_line.Point);
            context.WorkingContainer.Shapes.Add(_line);
            context.Renderer.SelectedShapes.Add(_line.Point);

            Intersections?.ForEach(i => i.Clear(context));
            Filters?.ForEach(f => f.Clear(context));

            context.Invalidate?.Invoke();
        }
コード例 #4
0
        private void DrawLineArrowsInternal(SKCanvas canvas, LineShape line, double dx, double dy, out SKPoint pt1, out SKPoint pt2)
        {
            using (SKPaint fillStartArrow = ToSKPaintBrush(line.Style.StartArrowStyle.Fill))
                using (SKPaint strokeStartArrow = ToSKPaintPen(line.Style.StartArrowStyle, _scaleToPage, _sourceDpi, _targetDpi))
                    using (SKPaint fillEndArrow = ToSKPaintBrush(line.Style.EndArrowStyle.Fill))
                        using (SKPaint strokeEndArrow = ToSKPaintPen(line.Style.EndArrowStyle, _scaleToPage, _sourceDpi, _targetDpi))
                        {
                            double _x1 = line.Start.X + dx;
                            double _y1 = line.Start.Y + dy;
                            double _x2 = line.End.X + dx;
                            double _y2 = line.End.Y + dy;

                            line.GetMaxLength(ref _x1, ref _y1, ref _x2, ref _y2);

                            float x1 = _scaleToPage(_x1);
                            float y1 = _scaleToPage(_y1);
                            float x2 = _scaleToPage(_x2);
                            float y2 = _scaleToPage(_y2);

                            var    sas = line.Style.StartArrowStyle;
                            var    eas = line.Style.EndArrowStyle;
                            double a1  = Math.Atan2(y1 - y2, x1 - x2);
                            double a2  = Math.Atan2(y2 - y1, x2 - x1);

                            // Draw start arrow.
                            pt1 = DrawLineArrowInternal(canvas, strokeStartArrow, fillStartArrow, x1, y1, a1, sas);

                            // Draw end arrow.
                            pt2 = DrawLineArrowInternal(canvas, strokeEndArrow, fillEndArrow, x2, y2, a2, eas);
                        }
        }
コード例 #5
0
        private void PointInternal(IToolContext context, double x, double y, Modifier modifier)
        {
            Filters?.Any(f => f.Process(context, ref x, ref y));

            CurrentState = State.StartPoint;

            context.Renderer.SelectedShapes.Remove(_line.StartPoint);
            context.Renderer.SelectedShapes.Remove(_line.Point);
            context.WorkingContainer.Shapes.Remove(_line);

            _line.Point = context.GetNextPoint(x, y, Settings?.ConnectPoints ?? false, Settings?.HitTestRadius ?? 0.0);

            Intersections?.ForEach(i => i.Clear(context));
            Intersections?.ForEach(i => i.Find(context, _line));

            if ((Settings?.SplitIntersections ?? false) && (Intersections?.Any(i => i.Intersections.Count > 0) ?? false))
            {
                LineHelper.SplitByIntersections(context, Intersections, _line);
            }
            else
            {
                context.CurrentContainer.Shapes.Add(_line);
            }

            _line = null;

            Intersections?.ForEach(i => i.Clear(context));
            Filters?.ForEach(f => f.Clear(context));

            context.Release?.Invoke();
            context.Invalidate?.Invoke();
        }
コード例 #6
0
        public CommonDecorator()
        {
            _strokeStyleId = "Decorator-Stroke";
            _fillStyleId   = "Decorator-Fill";

            _line = new LineShape(new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>()
            };
            _line.StartPoint.Owner = _line;
            _line.Point.Owner      = _line;

            _ellipse = new EllipseShape(new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>(),
            };
            _ellipse.StartPoint.Owner = _ellipse;
            _ellipse.Point.Owner      = _ellipse;

            _rectangle = new RectangleShape(new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>(),
            };
            _rectangle.StartPoint.Owner = _rectangle;
            _rectangle.Point.Owner      = _rectangle;

            _text = new TextShape(new Text(), new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>(),
            };
            _text.StartPoint.Owner = _text;
            _text.Point.Owner      = _text;
        }
        private void CreateChartByLine(LineShape line, int pointNumber)
        {
            Collection <Feature> lineFeatures = GetElevationByLine(line, pointNumber);

            ShowElevationOnChart(lineFeatures);
            DrawElevationLineOnMap(lineFeatures);
        }
コード例 #8
0
        public void drawRoute(int fromX, int fromY, int toX, int toY, List <LineShape> drawedRoutes, Panel parent)
        {
            ShapeContainer canvas = new ShapeContainer();
            LineShape      line   = new LineShape();

            canvas.Parent = parent;
            line.Parent   = canvas;

            switch (direction)
            {
            case "uni":
                line.BorderColor = System.Drawing.Color.Orange;
                break;

            case "1_2":
                line.BorderColor = System.Drawing.Color.Blue;
                break;

            case "2_1":
                line.BorderColor = System.Drawing.Color.Blue;
                break;

            default:
                line.BorderColor = System.Drawing.Color.Green;
                break;
            }

            line.BorderWidth = 3;
            line.StartPoint  = new System.Drawing.Point(fromX, fromY);
            line.EndPoint    = new System.Drawing.Point(toX, toY);

            line.Click += new EventHandler(routeClick);

            drawedRoutes.Add(line);
        }
        private void ShowElevationOnChart(Collection <Feature> features)
        {
            ChartAxisLabels.Clear();
            ChartData.Clear();

            double     distance  = 0.0;
            int        index     = 0;
            PointShape lastPoint = new PointShape();

            foreach (var feature in features)
            {
                PointShape point = new PointShape(feature.ColumnValues["point"]);
                if (index++ != 0)
                {
                    LineShape line = new LineShape(new Collection <Vertex> {
                        new Vertex(lastPoint), new Vertex(point)
                    });
                    distance += line.GetAccurateLength(4326, DistanceUnit.Meter, DistanceCalculationMode.Haversine);
                }

                double tmpDistance = Math.Round(distance / 1000.0, 2);
                double value       = Math.Round(double.Parse(feature.ColumnValues["elevation"]), 2);
                ChartAxisLabels.Add(tmpDistance);
                ChartData.Add(new ChartInformation(value, point.X, point.Y, tmpDistance));

                lastPoint = point;
            }

            var mapper = Mappers.Xy <ChartInformation>().X(value => value.Distance).Y(value => value.Elevation);

            Charting.For <ChartInformation>(mapper);
            DataContext = this;
        }
コード例 #10
0
ファイル: UDPCanvas.cs プロジェクト: ys60123in/CSharpNetWork
 //本機繪圖中
 private void UDPCanvas_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         LineShape L = new LineShape(); //建立線段物件
         L.StartPoint = stP;            //線段起點
         L.EndPoint   = e.Location;     //線段終點
         if (radioButton_Red.Checked)
         {
             L.BorderColor = Color.Red;
         }                                                          //紅筆
         if (radioButton_Green.Checked)
         {
             L.BorderColor = Color.Lime;
         }                                                              //亮綠色筆
         if (radioButton_Blue.Checked)
         {
             L.BorderColor = Color.Blue;
         }                                                             //藍筆
         if (radioButton_Black.Checked)
         {
             L.BorderColor = Color.Black;
         }                                                           //黑筆
         L.Parent = C;                                               //線段加入畫布C
         stP      = e.Location;                                      //終點變起點
         p       += "/" + stP.X.ToString() + "," + stP.Y.ToString(); //持續記錄座標
     }
 }
        private void DrawElevationLineOnMap(Collection <Feature> lineFeatures)
        {
            PointShape endPoint = lineFeatures[lineFeatures.Count - 1].GetShape() as PointShape;

            endMarker.Position = new Point(endPoint.X, endPoint.Y);

            // Draw the line
            var elevationlayer = ((LayerOverlay)wpfMap1.Overlays["elevationLayerOverlay"]).Layers["elevationLayer"] as InMemoryFeatureLayer;
            var pointlayer     = ((LayerOverlay)wpfMap1.Overlays["elevationLayerOverlay"]).Layers["pointFeatureLayer"] as InMemoryFeatureLayer;

            pointlayer.InternalFeatures.Clear();

            LineShape lineshape = new LineShape();

            foreach (Feature feature in lineFeatures)
            {
                lineshape.Vertices.Add(new Vertex(feature.GetShape() as PointShape));
                pointlayer.InternalFeatures.Add(new Feature(feature.GetShape() as PointShape));
            }
            elevationlayer.InternalFeatures.Clear();
            elevationlayer.InternalFeatures.Add(new Feature(lineshape));

            wpfMap1.Overlays["markOverlay"].Refresh();
            wpfMap1.Overlays["elevationLayerOverlay"].Refresh();
        }
コード例 #12
0
        private void DrawLineArrowsInternal(AM.DrawingContext dc, LineShape line, double dx, double dy, out A.Point pt1, out A.Point pt2)
        {
            AM.IBrush fillStartArrow   = ToBrush(line.Style.StartArrowStyle.Fill);
            AM.Pen    strokeStartArrow = ToPen(line.Style.StartArrowStyle, _scaleToPage);

            AM.IBrush fillEndArrow   = ToBrush(line.Style.EndArrowStyle.Fill);
            AM.Pen    strokeEndArrow = ToPen(line.Style.EndArrowStyle, _scaleToPage);

            double _x1 = line.Start.X + dx;
            double _y1 = line.Start.Y + dy;
            double _x2 = line.End.X + dx;
            double _y2 = line.End.Y + dy;

            line.GetMaxLength(ref _x1, ref _y1, ref _x2, ref _y2);

            float x1 = _scaleToPage(_x1);
            float y1 = _scaleToPage(_y1);
            float x2 = _scaleToPage(_x2);
            float y2 = _scaleToPage(_y2);

            var    sas = line.Style.StartArrowStyle;
            var    eas = line.Style.EndArrowStyle;
            double a1  = Math.Atan2(y1 - y2, x1 - x2);
            double a2  = Math.Atan2(y2 - y1, x2 - x1);

            // Draw start arrow.
            pt1 = DrawLineArrowInternal(dc, strokeStartArrow, fillStartArrow, x1, y1, a1, sas);

            // Draw end arrow.
            pt2 = DrawLineArrowInternal(dc, strokeEndArrow, fillEndArrow, x2, y2, a2, eas);
        }
コード例 #13
0
        /// <inheritdoc/>
        public override void Draw(object dc, LineShape line, double dx, double dy, object db, object r)
        {
            var _gfx = dc as Graphics;

            Pen strokeLine = ToPen(line.Style, _scaleToPage);

            DrawLineArrowsInternal(line, dx, dy, _gfx, out PointF pt1, out PointF pt2);

            if (line.Style.LineStyle.IsCurved)
            {
                DrawLineCurveInternal(
                    _gfx,
                    strokeLine, line.IsStroked,
                    ref pt1, ref pt2,
                    line.Style.LineStyle.Curvature,
                    line.Style.LineStyle.CurveOrientation,
                    line.Start.Alignment,
                    line.End.Alignment);
            }
            else
            {
                DrawLineInternal(_gfx, strokeLine, line.IsStroked, ref pt1, ref pt2);
            }

            strokeLine.Dispose();
        }
コード例 #14
0
        private void RenderRoadInformation(ShapeFileFeatureLayer featureLayer, RouteSegment road)
        {
            InMemoryFeatureLayer currentRoadLayer = ((LayerOverlay)winformsMap1.Overlays["currentRoadOverlay"]).Layers["currentRoadLayer"] as InMemoryFeatureLayer;
            string  featureId          = road.FeatureId;
            Feature currentRoadFeature = featureLayer.FeatureSource.GetFeatureById(featureId, ReturningColumnsType.AllColumns);

            currentRoadLayer.InternalFeatures.Clear();
            currentRoadLayer.InternalFeatures.Add(currentRoadFeature);

            txtStartPoint.Text = String.Format("{0}, {1}", road.StartPoint.X.ToString("F4", CultureInfo.InvariantCulture), road.StartPoint.Y.ToString("F4", CultureInfo.InvariantCulture));
            txtEndPoint.Text   = String.Format("{0}, {1}", road.EndPoint.X.ToString("F4", CultureInfo.InvariantCulture), road.EndPoint.Y.ToString("F4", CultureInfo.InvariantCulture));
            LineShape line = ((MultilineShape)currentRoadFeature.GetShape()).Lines[0];

            txtLength.Text = Math.Round(line.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter), 4).ToString(CultureInfo.InvariantCulture);

            switch (road.RouteSegmentType)
            {
            case 0:
                txtRoadType.Text = "Local Road";
                break;

            case 1:
                txtRoadType.Text = "Major Road";
                break;

            case 2:
                txtRoadType.Text = "High Way";
                break;

            default:
                break;
            }
        }
コード例 #15
0
        private void DrawLineArrowsInternal(XGraphics gfx, LineShape line, double dx, double dy, out XPoint pt1, out XPoint pt2)
        {
            XSolidBrush fillStartArrow   = ToXSolidBrush(line.Style.StartArrowStyle.Fill);
            XPen        strokeStartArrow = ToXPen(line.Style.StartArrowStyle, _scaleToPage, _sourceDpi, _targetDpi);

            XSolidBrush fillEndArrow   = ToXSolidBrush(line.Style.EndArrowStyle.Fill);
            XPen        strokeEndArrow = ToXPen(line.Style.EndArrowStyle, _scaleToPage, _sourceDpi, _targetDpi);

            double _x1 = line.Start.X + dx;
            double _y1 = line.Start.Y + dy;
            double _x2 = line.End.X + dx;
            double _y2 = line.End.Y + dy;

            LineShapeExtensions.GetMaxLength(line, ref _x1, ref _y1, ref _x2, ref _y2);

            double x1 = _scaleToPage(_x1);
            double y1 = _scaleToPage(_y1);
            double x2 = _scaleToPage(_x2);
            double y2 = _scaleToPage(_y2);

            var    sas = line.Style.StartArrowStyle;
            var    eas = line.Style.EndArrowStyle;
            double a1  = Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI;
            double a2  = Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI;

            // Draw start arrow.
            pt1 = DrawLineArrowInternal(gfx, strokeStartArrow, fillStartArrow, x1, y1, a1, sas);

            // Draw end arrow.
            pt2 = DrawLineArrowInternal(gfx, strokeEndArrow, fillEndArrow, x2, y2, a2, eas);
        }
コード例 #16
0
        public void DrawLine(DrawingContext dc, LineShape lineShape)
        {
            if (lineShape.Stroke == null)
            {
                return;
            }

            var brush = new SolidColorBrush(ToColor(lineShape.Stroke));

            brush.Freeze();

            var pen = new Pen(brush, lineShape.StrokeThickness)
            {
                Brush        = brush,
                Thickness    = lineShape.StrokeThickness,
                StartLineCap = ToPenLineCap(lineShape.LineCap),
                EndLineCap   = ToPenLineCap(lineShape.LineCap)
            };

            pen.Freeze();

            var point0 = new Point(lineShape.Point1.X, lineShape.Point1.Y);
            var point1 = new Point(lineShape.Point2.X, lineShape.Point2.Y);

            dc.DrawLine(pen, point0, point1);
        }
コード例 #17
0
        /// <inheritdoc/>
        public override void Draw(object dc, LineShape line, double dx, double dy, object db, object r)
        {
            if (!line.IsStroked)
            {
                return;
            }

            var _gfx = dc as XGraphics;

            XPen strokeLine = ToXPen(line.Style, _scaleToPage, _sourceDpi, _targetDpi);

            DrawLineArrowsInternal(_gfx, line, dx, dy, out XPoint pt1, out XPoint pt2);

            if (line.Style.LineStyle.IsCurved)
            {
                DrawLineCurveInternal(
                    _gfx,
                    strokeLine, line.IsStroked,
                    ref pt1, ref pt2,
                    line.Style.LineStyle.Curvature,
                    line.Style.LineStyle.CurveOrientation,
                    line.Start.Alignment,
                    line.End.Alignment);
            }
            else
            {
                DrawLineInternal(_gfx, strokeLine, line.IsStroked, ref pt1, ref pt2);
            }
        }
コード例 #18
0
 private void Delete(LineShape line, IHistory history)
 {
     if (line.Owner != null && line.Owner is Layer)
     {
         (line.Owner as Layer).Shapes.RemoveWithHistory(line, history);
     }
 }
コード例 #19
0
 //本機端繪圖中
 private void metroPanel2_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         LineShape Line = new LineShape(); //建立線段物件
         Line.StartPoint = stP;            //線段起點
         Line.EndPoint   = e.Location;     //線段終點
         if (RadioButton1.Checked)
         {
             Line.BorderColor = Color.Red;
         }                                                          //紅筆
         if (RadioButton2.Checked)
         {
             Line.BorderColor = Color.Lime;
         }                                                           //亮綠色筆
         if (RadioButton3.Checked)
         {
             Line.BorderColor = Color.Blue;
         }                                                           //藍筆
         if (RadioButton4.Checked)
         {
             Line.BorderColor = Color.Black;
         }                                                              //黑筆
         Line.Parent = C;                                               //線段加入畫布C
         stP         = e.Location;                                      //終點變起點
         p          += "/" + stP.X.ToString() + "," + stP.Y.ToString(); //持續紀錄座標
     }
 }
コード例 #20
0
 public IconicLineShapeHelper(LineShape line, IconShape icon)
 {
     _container            = line.Parent;
     _line                 = line;
     _icon                 = icon;
     _container.MouseMove += new MouseEventHandler(_container_MouseMove);
 }
コード例 #21
0
        /// <inheritdoc/>
        public override void Draw(object dc, LineShape line, double dx, double dy, object db, object r)
        {
            var canvas = dc as SKCanvas;

            using (SKPaint strokeLine = ToSKPaintPen(line.Style, _scaleToPage, _sourceDpi, _targetDpi))
            {
                DrawLineArrowsInternal(canvas, line, dx, dy, out SKPoint pt1, out SKPoint pt2);

                if (line.Style.LineStyle.IsCurved)
                {
                    DrawLineCurveInternal(
                        canvas,
                        strokeLine, line.IsStroked,
                        ref pt1, ref pt2,
                        line.Style.LineStyle.Curvature,
                        line.Style.LineStyle.CurveOrientation,
                        line.Start.Alignment,
                        line.End.Alignment);
                }
                else
                {
                    DrawLineInternal(canvas, strokeLine, line.IsStroked, ref pt1, ref pt2);
                }
            }
        }
コード例 #22
0
        /// <summary>
        /// リレーションを追加
        /// </summary>
        private LineShape addRelation(ChildForm relatinoFromForm, ChildForm relatinoToForm)
        {
            LineShape ls = new LineShape();

            ls.Name = "lineShape";

            //線分From座標を設定
            ls.X1 = relatinoFromForm.Location.X + relatinoFromForm.Width / 2;
            ls.Y1 = relatinoFromForm.Location.Y + relatinoFromForm.Height / 2;
            //線分To座標を設定
            ls.X2 = relatinoToForm.Location.X + relatinoToForm.Width / 2;
            ls.Y2 = relatinoToForm.Location.Y + relatinoToForm.Height / 2;

            //線分スタイルを定義
            ls.BorderColor    = Color.Blue;
            ls.SelectionColor = Color.Red;
            ls.BorderWidth    = 8;
            ls.BorderStyle    = System.Drawing.Drawing2D.DashStyle.Solid;

            //アクション追加
            ls.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lineShape_MouseClick);

            //線分コンテナに追加
            this.shapeContainer1.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] { ls });

            //フォームにリレーションのインスタンスを設定
            relatinoFromForm.addRelationFromLineShape(ls);
            relatinoToForm.addRelationToLineShape(ls);

            return(ls);
        }
コード例 #23
0
        protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
        {
            // Override the base method and modify the logic for resizing if the shape is the "custom"
            if (sourceFeature.ColumnValues.ContainsKey("Edit") && sourceFeature.ColumnValues["Edit"] == "rectangle")
            {
                PolygonShape polygonShape = sourceFeature.GetShape() as PolygonShape;

                if (polygonShape != null)
                {
                    // If the rectangle is horizontal or vertical, it will use the custom method.
                    if (string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText()))
                    {
                        int fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint);

                        PointShape fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]);

                        RectangleShape newRectangleShape = new LineShape(new Vertex[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox();

                        return(new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues));
                    }
                }
            }

            return(base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint));
        }
コード例 #24
0
        /// <summary>
        /// Get the road which is cross the input road. The return road should have the biggest angle compared with input road.
        /// </summary>
        private static Feature GetCrossRoad(Feature currentRoad, bool isOnLeftSide, Collection <Feature> intersectedFeatures)
        {
            // Loop to find the road which has the biggest angle with current road
            double    smallestAngle    = double.MaxValue;
            Feature   smallestFeature  = null;
            LineShape currentLineShape = GetLineShape(currentRoad);

            foreach (Feature feature in intersectedFeatures)
            {
                if (feature.ColumnValues["ROAD_NAME"] != currentRoad.ColumnValues["ROAD_NAME"])
                {
                    LineShape lineShape = GetLineShape(feature);      // Get the line segment of current feature.
                    double    angle     = GetAngleBetweenTwoLines(currentLineShape, lineShape);

                    // If the searched result is on the left, we just need to check the angle which is nagtive.
                    double offsetAngle = Math.Abs(angle - 90) * (isOnLeftSide ? 1 : -1);

                    if (offsetAngle < smallestAngle)
                    {
                        smallestAngle   = offsetAngle;
                        smallestFeature = feature;
                    }
                }
            }

            return(smallestFeature);
        }
コード例 #25
0
        private void timer_Tick(object sender, EventArgs e)
        {
            InMemoryFeatureLayer bitmapLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("BitmapLayer");
            PointShape           pointShape  = bitmapLayer.InternalFeatures[0].GetShape() as PointShape;
            LineShape            airLine     = ((MultilineShape)bitmapLayer.InternalFeatures[1].GetShape()).Lines[0];

            index += 30;
            if (index < airLine.Vertices.Count)
            {
                Vertex newPosition = airLine.Vertices[index];
                pointShape.X  = newPosition.X;
                pointShape.Y  = newPosition.Y;
                pointShape.Id = "Plane";

                bitmapLayer.Open();
                bitmapLayer.EditTools.BeginTransaction();
                bitmapLayer.EditTools.Update(pointShape);
                bitmapLayer.EditTools.CommitTransaction();
                bitmapLayer.Close();
            }
            else
            {
                index = 0;
            }

            winformsMap1.Refresh(winformsMap1.Overlays["PlaneOverlay"]);
        }
コード例 #26
0
		public void CheckLastPointFromLine()
		{
			LineShape ls = new LineShape();
			Point from = new Point (1,1);
			Point to = new Point (10,10);
			GraphicsPath p = ls.CreatePath(from,to);
			PointF last = p.GetLastPoint();
			Assert.AreEqual(to,Point.Truncate(last));
		}
コード例 #27
0
		public void CheckGraphicsPathBounds()
		{
			LineShape ls = new LineShape();
			Point from = new Point (1,1);
			Point to = new Point (10,10);
			GraphicsPath p = ls.CreatePath(from,to);
			RectangleF r = p.GetBounds();
			Assert.AreEqual(from.X,r.Location.X);
			Assert.AreEqual(from.Y,r.Location.Y);
			Assert.AreEqual(to.X - from.X, r.Width);
			Assert.AreEqual(to.Y - from.Y,r.Height);
		}
コード例 #28
0
 //dikey çizgiler oluşturuluyor
 public void DikeyLineShapeOlustur()
 {
     for (int i = 1; i < 45; i++)
     {
         LineShape yeniLineShape1 = new LineShape();
         yeniLineShape1.X1 = i * 20;
         yeniLineShape1.X2 = i * 20;
         yeniLineShape1.Y1 = 560;
         yeniLineShape1.Y2 = 0;
         yeniLineShape1.BorderColor = Color.Black;
         yeniLineShape1.BorderWidth = 2;
         Form1.frm.shapeContainer1.Shapes.Add(yeniLineShape1);
     }
 }
コード例 #29
0
 //yatay çizgiler oluşturuluyor
 public void YatayLineShapeOlustur()
 {
     for (int i = 1; i < 29; i++)
     {
         LineShape yeniLineShape = new LineShape();
         yeniLineShape.X1 = 0;
         yeniLineShape.X2 = 880;
         yeniLineShape.Y1 = i * 20;
         yeniLineShape.Y2 = i * 20;
         yeniLineShape.BorderColor = Color.Black;
         yeniLineShape.BorderWidth = 2;
         Form1.frm.shapeContainer1.Shapes.Add(yeniLineShape);
     }
 }
コード例 #30
0
        public void Constructor()
        {
            Assert.AreEqual(new Vector3F(), new LineShape().PointOnLine);
              Assert.AreEqual(new Vector3F(1, 0, 0), new LineShape().Direction);

              Vector3F pointOnLine = new Vector3F(1, 2, 3);
              var direction = new Vector3F(4, 5, 6).Normalized;
              LineShape line = new LineShape(pointOnLine, direction);
              Assert.AreEqual(pointOnLine, line.PointOnLine);
              Assert.AreEqual(direction, line.Direction);

              line = new LineShape(new Line(pointOnLine, direction));
              Assert.AreEqual(pointOnLine, line.PointOnLine);
              Assert.AreEqual(direction, line.Direction);
        }
コード例 #31
0
ファイル: TestDrawing.cs プロジェクト: bvssvni/csharp-utils
        public void TestDrawLine()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/line.png");
            image.Dispose ();
        }
コード例 #32
0
ファイル: TestDrawing.cs プロジェクト: bvssvni/csharp-utils
        public void TestBranchIteration()
        {
            var a = new EllipseShape ();
            var b = new RectangleShape ();
            var c = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, a);
            op.AddChild (look, b).AddChild (look, c);

            // Iterate through each member of the branch.
            var list = new List<ShapeBase> ();
            foreach (var item in op) {
                list.Add (item);
            }

            Assert.True (list[0] == b);
            Assert.True (list[1] == c);
        }
コード例 #33
0
 protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
 {
     // Override the base method and modify the logic for resizing if the shape is the "custom"
     var polygonShape = sourceFeature.GetShape() as PolygonShape;
     if (polygonShape != null)
     {
         // If the rectangle is horizontal or vertical, it will use the custom method.
         if (string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText()))
         {
             var fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint);
             var fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]);
             var newRectangleShape = new LineShape(new[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox();
             return base.ResizeFeatureCore(new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues),
                                           targetControlPoint,
                                           targetControlPoint);
         }
     }
     return base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint);
 }
コード例 #34
0
ファイル: RelationshipView.cs プロジェクト: Etlay/DB_cursovoy
        public RelationshipView(Control.ControlCollection collection, Essenishial one, Essenishial two, 
            ErRelationshipConnectType firsType, ErRelationshipConnectType secType,
            ErDiagram Diagram
            )
        {
            targetDiagram = Diagram;
            ErConnectEssencePair firstPair = new ErConnectEssencePair(one.Essence, firsType);
            ErConnectEssencePair secondPair = new ErConnectEssencePair(two.Essence, secType);
            targetRelationship = new ErRelationship(firstPair, secondPair);
            targetDiagram.AddRelationship(targetRelationship);

            oneEssenishial = one;
            twoEssenishial = two;
            one.OneOrTwoList.Add(1);
            two.OneOrTwoList.Add(2);
            OnePoint = one.GetCentralPoint();
            TwoPoint = two.GetCentralPoint();
            one.RelationshipViewList.Add(this);
            two.RelationshipViewList.Add(this);

            MiddlePoint = new Point((OnePoint.X + TwoPoint.X) / 2, (OnePoint.Y + TwoPoint.Y) / 2);
            containerOne = new ShapeContainer();
            OneToMiddleLine = new LineShape(OnePoint.X, OnePoint.Y, MiddlePoint.X, MiddlePoint.Y);
            OneToMiddleLine.DoubleClick += OpenRelationshipEditorWindow;
            OneToMiddleLine.BorderWidth = 3;
            OneToMiddleLine.BorderStyle = GetLineStyle(firsType.ModalType);
            MiddelToTwoLine = new LineShape(MiddlePoint.X, MiddlePoint.Y, TwoPoint.X, TwoPoint.Y);
            MiddelToTwoLine.BorderWidth = 3;
            MiddelToTwoLine.DoubleClick += OpenRelationshipEditorWindow;
            MiddelToTwoLine.BorderStyle = GetLineStyle(secType.ModalType);

            containerOne.Shapes.Add(OneToMiddleLine);
            containerOne.Shapes.Add(MiddelToTwoLine);
            //shape.
            collection.Add(containerOne);
        }
コード例 #35
0
        private RoadDirection CalculateRoadDirection(Feature feature, LineShape lineShape, Vertex startVertex)
        {
            int index = 0;  // Given the vertex is the first of input line shape.
            if (!GeometryHelper.IsSamePoint(lineShape.Vertices[0], startVertex, Tolerance))
            {
                index = lineShape.Vertices.Count - 1;
            }

            RoadDirection direction = RoadDirection.Noway;
            if (index == 0)
            {
                if (IsRoadDirectionAccessable(feature, RoadDirection.Forward))
                {
                    direction = RoadDirection.Forward;
                }
            }
            else
            {
                if (IsRoadDirectionAccessable(feature, RoadDirection.Backward))
                {
                    direction = RoadDirection.Backward;
                }
            }

            return direction;
        }
コード例 #36
0
 private void AddDataTbLineSequence(string ObIn, LineShape lineAdd, string ObOut)
 {
     DataRow row = tbLineSequence.NewRow();
     row["ObjectIn"] = ObIn;
     row["Line"] = lineAdd;
     row["ObjectOut"] = ObOut;
     TbLineSequence.Rows.Add(row);
 }
コード例 #37
0
        public void SerializationXml()
        {
            var a = new LineShape(new Vector3F(1, 2, 3), new Vector3F(2, 3, 4).Normalized);

              // Serialize object.
              var stream = new MemoryStream();
              var serializer = new XmlSerializer(typeof(Shape));
              serializer.Serialize(stream, a);

              // Output generated xml. Can be manually checked in output window.
              stream.Position = 0;
              var xml = new StreamReader(stream).ReadToEnd();
              Trace.WriteLine("Serialized Object:\n" + xml);

              // Deserialize object.
              stream.Position = 0;
              var deserializer = new XmlSerializer(typeof(Shape));
              var b = (LineShape)deserializer.Deserialize(stream);

              Assert.AreEqual(a.PointOnLine, b.PointOnLine);
              Assert.AreEqual(a.Direction, b.Direction);
        }
コード例 #38
0
ファイル: LineShapeArray.cs プロジェクト: nodoid/PointOfSale
 public bool ShouldSerializeIndex(LineShape o)
 {
     return BaseShouldSerializeIndex(o);
 }
コード例 #39
0
ファイル: LineShapeArray.cs プロジェクト: nodoid/PointOfSale
 public void ResetIndex(LineShape o)
 {
     BaseResetIndex(o);
 }
コード例 #40
0
        internal static Collection<FlagedVertex> AddCrossingPointToLine(LineShape line, Collection<PointShape> crossingPoints)
        {
            Collection<FlagedVertex> orderedPoints = new Collection<FlagedVertex>();
            for (int i = 0; i < line.Vertices.Count - 1; i++)
            {
                // Add the first vertex of segment.
                if (!HasExists(orderedPoints, line.Vertices[i]))
                {
                    orderedPoints.Add(new FlagedVertex() { Vertex = line.Vertices[i] , Flag = true});
                }

                Dictionary<PointShape, double> pointsOnSegement = new Dictionary<PointShape, double>();
                foreach (PointShape crossingPoint in crossingPoints)
                {
                    // Add the crossing point if it's on the segment.
                    bool isIntermiate = IsIntermediatePoint(line.Vertices[i], line.Vertices[i + 1], crossingPoint);
                    if (isIntermiate)
                    {
                        double pointDistance = GetEvaluatedDistance(line.Vertices[i], crossingPoint);
                        pointsOnSegement.Add(crossingPoint, pointDistance);
                    }
                }

                if (pointsOnSegement.Count > 0)
                {
                    pointsOnSegement.OrderBy(v => v.Value);
                    foreach (var pointOnSegment in pointsOnSegement)
                    {
                        Vertex vertex = new Vertex(pointOnSegment.Key.X, pointOnSegment.Key.Y);
                        if (!HasExists(orderedPoints, vertex))
                        {
                            bool isOnTheLine = false;
                            foreach (var item in line.Vertices)
                            {
                                if(vertex.X == item.X && vertex.Y == item.Y)
                                {
                                    isOnTheLine = true;
                                    break;
                                }
                            }

                            if(isOnTheLine)
                            {
                                orderedPoints.Add(new FlagedVertex() { Vertex = vertex, Flag = true });
                            }
                            else
                            {
                                orderedPoints.Add(new FlagedVertex() { Vertex = vertex, Flag = false });
                            }
                        }
                        crossingPoints.Remove(pointOnSegment.Key);
                    }
                }
            }

            if(line.Vertices.Count > orderedPoints.Count)
            {
                bool isLoop = false;
                foreach (var item in orderedPoints)
                {
                    if (line.Vertices[line.Vertices.Count - 1].X == item.Vertex.X && line.Vertices[line.Vertices.Count - 1].Y == item.Vertex.Y)
                    {
                        isLoop = true;
                        break;
                    }
                }

                if(isLoop)
                {
                    orderedPoints.Add(new FlagedVertex() { Vertex = new Vertex(line.Vertices[line.Vertices.Count - 1].X, line.Vertices[line.Vertices.Count - 1].Y), Flag = true });
                }
            }

            return orderedPoints;
        }
コード例 #41
0
        protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
        {
            var currentExtent = canvas.CurrentWorldExtent;
            var currentMinX = currentExtent.UpperLeftPoint.X;
            var currentMaxX = currentExtent.UpperRightPoint.X;
            var currentMaxY = currentExtent.UpperLeftPoint.Y;
            var currentMinY = currentExtent.LowerLeftPoint.Y;

            //Gets the increment according to the current extent of the map and the graticule density set 
            //by the GraticuleDensity property
            var increment = GetIncrement(currentExtent.Width, _graticuleDensity);

            //Collections of GraticuleLabel for labeling the different lines.
            var meridianGraticuleLabels = new Collection<GraticuleLabel>();
            var parallelGraticuleLabels = new Collection<GraticuleLabel>();

            //Loop for displaying the meridians (lines of common longitude).
            double x;
            for (x = CeilingNumber(currentExtent.UpperLeftPoint.X, increment);
                 x <= currentExtent.UpperRightPoint.X;
                 x += increment)
            {
                var lineShapeMeridian = new LineShape();
                lineShapeMeridian.Vertices.Add(new Vertex(x, currentMaxY));
                lineShapeMeridian.Vertices.Add(new Vertex(x, currentMinY));
                canvas.DrawLine(lineShapeMeridian, new GeoPen(_graticuleColor, 0.5F), DrawingLevel.LevelFour);

                //Gets the label and screen position of each meridian.
                var meridianLabelPosition = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, x,
                                                                                     currentMaxY, canvas.Width,
                                                                                     canvas.Height);
                meridianGraticuleLabels.Add(new GraticuleLabel(FormatLatLong(x, LineType.Meridian, increment),
                                                               meridianLabelPosition));
            }

            //Loop for displaying the parallels (lines of common latitude).
            double y;
            for (y = CeilingNumber(currentExtent.LowerLeftPoint.Y, increment);
                 y <= currentExtent.UpperRightPoint.Y;
                 y += increment)
            {
                var lineShapeParallel = new LineShape();
                lineShapeParallel.Vertices.Add(new Vertex(currentMaxX, y));
                lineShapeParallel.Vertices.Add(new Vertex(currentMinX, y));
                canvas.DrawLine(lineShapeParallel, new GeoPen(_graticuleColor, 0.5F), DrawingLevel.LevelFour);

                //Gets the label and screen position of each parallel.
                ScreenPointF parallelLabelPosition = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent,
                                                                                     currentMinX, y, canvas.Width,
                                                                                     canvas.Height);
                parallelGraticuleLabels.Add(new GraticuleLabel(FormatLatLong(y, LineType.Parallel, increment),
                                                               parallelLabelPosition));
            }


            //Loop for displaying the label for the meridians.
            foreach (var meridianGraticuleLabel in meridianGraticuleLabels)
            {
                var locations = new Collection<ScreenPointF> {new ScreenPointF(meridianGraticuleLabel.Location.X, meridianGraticuleLabel.Location.Y + 6)};

                canvas.DrawText(meridianGraticuleLabel.Label, new GeoFont("Arial", 10),
                                new GeoSolidBrush(GeoColor.StandardColors.Navy),
                                new GeoPen(GeoColor.StandardColors.White, 2), locations, DrawingLevel.LevelFour, 8, 0, 0);
            }

            //Loop for displaying the label for the parallels.
            foreach (var parallelGraticuleLabel in parallelGraticuleLabels)
            {
                var locations = new Collection<ScreenPointF> {new ScreenPointF(parallelGraticuleLabel.Location.X, parallelGraticuleLabel.Location.Y)};

                canvas.DrawText(parallelGraticuleLabel.Label, new GeoFont("Arial", 10),
                                new GeoSolidBrush(GeoColor.StandardColors.Navy),
                                new GeoPen(GeoColor.StandardColors.White, 2), locations, DrawingLevel.LevelFour, 8, 0,
                                90);
            }
        }
コード例 #42
0
 public virtual float CalculateRoadCost(LineShape lineShape)
 {
     return (float)lineShape.GetLength(DataUnit, DistanceUnit);
 }
コード例 #43
0
ファイル: LineShapeArray.cs プロジェクト: nodoid/PointOfSale
 public short GetIndex(LineShape o)
 {
     return BaseGetIndex(o);
 }
コード例 #44
0
ファイル: Form1.cs プロジェクト: ahmadmujtaba/BMC
        public void DrawLines(GroupControl objGroupbox, int groupBoxName, int level, int column, string currentRunningLabelValue,string docOpenClose)
        {
            if (level != 1)
            {
                Canvas.Parent = this;
                Canvas.Name = "LinesContain";
                foreach (var c in this.Controls)
                {
                    if (c is GroupControl)
                    {
                        var x = (GroupControl)c;
                        string findLebelName = x.Name.Remove(0, 12);
                        Control[] controls = x.Controls.Find("Label2" + findLebelName, true);
                        if (controls.Length == 1)
                        {
                            Label control = controls[0] as Label;
                            if (control != null)
                            {
                                var labelValue = control.Text;
                                if (Convert.ToInt32(labelValue) + 1 == level)
                                {
                                    Control[] cntl = x.Controls.Find("Label1" + findLebelName, true);
                                    if (cntl.Length == 1)
                                    {
                                        Label cntrls = cntl[0] as Label;
                                        if (cntrls != null)
                                        {
                                            var groupBoxIdValaue = cntrls.Text;
                                            Char[] arrayLabelValue = { ':' };
                                            var labelsplitValues = groupBoxIdValaue.Split(arrayLabelValue).ToList();
                                            groupBoxIdValaue = labelsplitValues[1].ToString();
                                            if (this.ConformationFromDataTable(column, currentRunningLabelValue, groupBoxIdValaue))
                                            {
                                                _theLine = new LineShape
                                                {
                                                    Parent = Canvas,
                                                    Name = "Line" + _lineNo,
                                                    BorderWidth = 4,
                                                    X1 = objGroupbox.Location.X,
                                                    Y1 = objGroupbox.Size.Height/2 + objGroupbox.Location.Y,
                                                    X2 = x.Width + x.Location.X,
                                                    Y2 = x.Size.Height/2 + x.Location.Y
                                                };
                                                DataRow row1 = _dtMovingLines.NewRow();
                                                row1["groupBoxName"] = objGroupbox.Name;
                                                row1["Lines"] = _theLine.Name;
                                                row1["Direction"] = "X";
                                                _dtMovingLines.Rows.Add(row1);

                                                DataRow row2 = _dtMovingLines.NewRow();
                                                row2["groupBoxName"] = x.Name;
                                                row2["Lines"] = _theLine.Name;
                                                row2["Direction"] = "Y";
                                                _dtMovingLines.Rows.Add(row2);
                                                row1 = null;
                                                row2 = null;

                                                _theLine.SelectionColor.GetBrightness();

                                                //_theLine.BorderColor = docOpenClose.Equals("Open")
                                                //    ? Color.SkyBlue
                                                //    : Color.SkyBlue;
                                                _theLine.BorderColor = Color.SkyBlue;

                                                 Canvas.Shapes.Add(_theLine);
                                                _lineNo++;
                                                _theLine = null;

                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
コード例 #45
0
ファイル: LineShapeArray.cs プロジェクト: nodoid/PointOfSale
 public void SetIndex(LineShape o, short Index)
 {
     BaseSetIndex(o, Index);
 }
コード例 #46
0
 private void DeleteLineShape(LineShape lShapeDelete)
 {
     shapeContainer.Shapes.Remove(lShapeDelete);
 }
コード例 #47
0
        public void SerializationBinary()
        {
            var a = new LineShape(new Vector3F(1, 2, 3), new Vector3F(2, 3, 4).Normalized);

              // Serialize object.
              var stream = new MemoryStream();
              var formatter = new BinaryFormatter();
              formatter.Serialize(stream, a);

              // Deserialize object.
              stream.Position = 0;
              var deserializer = new BinaryFormatter();
              var b = (LineShape)deserializer.Deserialize(stream);

              Assert.AreEqual(a.PointOnLine, b.PointOnLine);
              Assert.AreEqual(a.Direction, b.Direction);
        }
コード例 #48
0
 private void ConnectSequence()
 {
     LineShape lineShape = new LineShape(centerOfGravity.X, centerOfGravity.Y, sequenceSource.centerOfGravity.X, sequenceSource.centerOfGravity.Y);
     sequenceSource.lineShapeList.Add(lineShape);
     lineShapeList.Add(lineShape);
     shapeContainer.Shapes.Add(lineShapeList[lineShapeList.Count - 1]);
     shapeContainer.SendToBack();
     lineShapeList[lineShapeList.Count - 1].SendToBack();
     CheckExistingSequenceOutput(this);
     AddDataTbLineSequence(sequenceSource.controlName, lineShape, this.controlName);
 }
コード例 #49
0
        public void TestProperties()
        {
            LineShape l = new LineShape();
              Assert.AreEqual(new Vector3F(), l.PointOnLine);
              Assert.AreEqual(new Vector3F(1, 0, 0), l.Direction);

              Vector3F pointOnLine = new Vector3F(1, 2, 3);
              l.PointOnLine = pointOnLine;
              Assert.AreEqual(pointOnLine, l.PointOnLine);
              Assert.AreEqual(new Vector3F(1, 0, 0), l.Direction);

              var direction = new Vector3F(4, 5, 6).Normalized;
              l.Direction = direction;
              Assert.AreEqual(pointOnLine, l.PointOnLine);
              Assert.AreEqual(direction, l.Direction);
        }
コード例 #50
0
        private void WriteFeaturesIntoQueue(Collection<Feature> features, FeatureSource featureSource)
        {
            foreach (Feature feature in features)
            {
                Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
                // Get the lineshape of the processing feature.
                foreach (LineShape processingLineShape in processingLineShapes)
                {
                    // Define a variable to save the points where the adjacent lines intersect with current processing line.
                    Collection<PointShape> crossingPoints = new Collection<PointShape>();

                    // Get all the lines in current processing shape bounds.
                    Collection<Feature> adjacentFeatures = featureSource.GetFeaturesInsideBoundingBox(processingLineShape.GetBoundingBox(), ReturningColumnsType.NoColumns);

                    // Loop and see if the queried shape is intersected with processing shape.
                    foreach (Feature adjacentFeature in adjacentFeatures)
                    {
                        LineBaseShape adjacentLineShape = adjacentFeature.GetShape() as LineBaseShape;
                        MultipointShape tempCrossingPoints = processingLineShape.GetCrossing(adjacentLineShape);

                        // The queried shape is intersected with processing shape.
                        foreach (PointShape point in tempCrossingPoints.Points)
                        {
                            bool hasAdded = false;
                            foreach (var item in crossingPoints)
                            {
                                if (point.X == item.X && point.Y == item.Y)
                                {
                                    hasAdded = true;
                                    break;
                                }
                            }
                            if (!hasAdded)
                            {
                                crossingPoints.Add(point);
                            }
                        }
                    }

                    // Order the crossing points following the sequence of line vertex.
                    Collection<FlagedVertex> vertecesOfNewLine = GeometryHelper.AddCrossingPointToLine(processingLineShape, crossingPoints);
                    Collection<Vertex> verteces = new Collection<Vertex>();
                    Collection<Feature> lineFeatures = new Collection<Feature>();
                    foreach (var vertex in vertecesOfNewLine)
                    {
                        verteces.Add(vertex.Vertex);
                        if (vertex.Flag)
                        {
                            if (verteces.Count >= 2)
                            {
                                LineShape segment = new LineShape(verteces);
                                lineFeatures.Add(new Feature(segment, feature.ColumnValues));
                                verteces.RemoveAt(0);
                            }
                        }
                    }
                    if (lineFeatures.Count > 0)
                    {
                        queue.Enqueue(lineFeatures);
                    }
                }

            #if DEBUG
                Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, features.Count));
            #endif
            }
        }
コード例 #51
0
 public void InnerPoint()
 {
     Vector3F pointOnLine = new Vector3F(1, 2, 3);
       var direction = new Vector3F(3, 2, 1).Normalized;
       LineShape line = new LineShape(pointOnLine, direction);
       Assert.AreEqual(pointOnLine, line.InnerPoint);
 }
コード例 #52
0
		public void CreateLineShape()
		{
			LineShape ls = new LineShape();
			Assert.NotNull(ls);
		}
コード例 #53
0
 public void DirectionException()
 {
     LineShape l = new LineShape();
       l.Direction = new Vector3F();
 }
コード例 #54
0
 public void GetMesh()
 {
     var l = new LineShape(new Vector3F(1, 2, 3), Vector3F.UnitY);
       LineShape.MeshSize = 10;
       var m = l.GetMesh(0, 1);
       Assert.AreEqual(1, m.NumberOfTriangles);
       Triangle t = m.GetTriangle(0);
       Assert.IsTrue(l.PointOnLine - LineShape.MeshSize / 2 * Vector3F.UnitY == t.Vertex0);
       Assert.IsTrue(l.PointOnLine + LineShape.MeshSize / 2 * Vector3F.UnitY == t.Vertex2);
 }
コード例 #55
-1
 public void Clone()
 {
     LineShape line = new LineShape(new Vector3F(1, 2, 3), new Vector3F(2, 3, 4).Normalized);
       LineShape clone = line.Clone() as LineShape;
       Assert.IsNotNull(clone);
       Assert.AreEqual(line.PointOnLine, clone.PointOnLine);
       Assert.AreEqual(line.Direction, clone.Direction);
       Assert.AreEqual(line.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
       Assert.AreEqual(line.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
 }