Example #1
0
        /// <summary>
        /// Draws the point plot on a GDI+ surface against the provided x and y axes.
        /// </summary>
        /// <param name="g">The GDI+ surface on which to draw.</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        public virtual void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
        {
            SequenceAdapter data_ =
                new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData );

            float leftCutoff_ = xAxis.PhysicalMin.X - marker_.Size;
            float rightCutoff_ = xAxis.PhysicalMax.X + marker_.Size;

            for (int i=0; i<data_.Count; ++i)
            {
                if ( !Double.IsNaN(data_[i].X) && !Double.IsNaN(data_[i].Y) )
                {
                    PointF xPos = xAxis.WorldToPhysical( data_[i].X, false);
                    if (xPos.X < leftCutoff_ || rightCutoff_ < xPos.X)
                        continue;

                    PointF yPos = yAxis.WorldToPhysical( data_[i].Y, false);
                    marker_.Draw( g, (int)xPos.X, (int)yPos.Y );
                    if (marker_.DropLine)
                    {
                        PointD yMin = new PointD( data_[i].X, Math.Max( 0.0f, yAxis.Axis.WorldMin ) );
                        PointF yStart = yAxis.WorldToPhysical( yMin.Y, false );
                        g.DrawLine( marker_.Pen, (int)xPos.X,(int)yStart.Y, (int)xPos.X,(int)yPos.Y );
                    }
                }
            }
        }
Example #2
0
        private void MainForm_MouseDown(object sender, MouseEventArgs e)
        {
            if (checkBoxAddPoint.Checked)
            {
                scene.DataPoints.Add(new PointD(e.X, e.Y));
                this.Invalidate();
                return;
            }

            mouse_start = e.Location;
            this.Text = mouse_start.ToString();
            capture = scene.HitTest(e.X, e.Y);
            switch (capture)
            {
                case 1:
                    point_start = scene.CurrentBezier.Point1;
                    break;

                case 2:
                    point_start = scene.CurrentBezier.Point2;
                    break;

                case 3:
                    point_start = scene.CurrentBezier.Point3;
                    break;

                case 4:
                    point_start = scene.CurrentBezier.Point4;
                    break;

                default:
                    break;
            }
        }
Example #3
0
        /// <summary>
        /// Returns a list of regular polygon's vertices, which has a 
        /// specified amount of sides and is inscribed into
        /// a circle of certain radius and center point.
        /// 
        /// The first vertice will be located at specified angle (counting counterclockwise)
        /// from the circle's rightmost point.
        /// </summary>
        /// <param name="sideCount">The total amount of polygon's sides. May be equal to 2 (then the resulting vertices will make up a line).</param>
        /// <param name="circleCenter">The center of the surrounding circle.</param>
        /// <param name="circleRadius">The radius of the surrounding circle.</param>
        /// <param name="initialAngle">The angle (in radians, counting counterclockwise from the circle's rightmost point) at which the first vertice will be located.</param>
        /// <returns>The list of regular polygon's vertices.</returns>
        public static List<PointD> RegularPolygonInscribedIntoCircle(int sideCount, PointD circleCenter, double circleRadius, double initialAngle = 0)
        {
            // Вектор в ноль градусов.
            VectorD initialVector = new VectorD(circleCenter, new PointD(circleCenter.X + circleRadius, circleCenter.Y));

            List<PointD> points = new List<PointD>(sideCount);

            // Вектор установлен на начальный угол.
            
            if(initialAngle != 0)
                initialVector = initialVector.VectorRotatedNewStartPoint(initialAngle, initialVector.StartPoint);
    
            points.Add(initialVector.EndPoint);

            double rotationAngle = 2 * Math.PI / sideCount;

            VectorD currentVector;

            for(int i=1; i<sideCount; i++)
            {
                currentVector = initialVector.VectorRotatedNewStartPoint(i * rotationAngle, initialVector.StartPoint);
                points.Add(currentVector.EndPoint);
            }

            return points;
        }
 public override void DrawRegionRepresentation(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
 {
     if (m_Param.Path.IsVisible((System.Drawing.Point)mousePosition))
     {
         gc.DrawString(ToString(), r.FontType, new System.Drawing.SolidBrush(r.RegionGuides.Color), new System.Drawing.PointF((float)mousePosition.X, (float)mousePosition.Y - 15));
     }
 }
Example #5
0
 public TooltipEventArgs(int shapeIndex, int recordIndex, Point mousePt, PointD gisPoint)
 {
     this.shape = shapeIndex;
     this.record = recordIndex;
     this.mousePos = mousePt;
     this.gisLocation = gisPoint;
 }
Example #6
0
 public Effect(Bitmap image, PointD worldorpod, ImagePasteMode imagepastemode, EffectDock effectdock, Rectangle region = default(Rectangle))
     : base(null, image, default(Point), imagepastemode, region)
 {
     if (effectdock == EffectDock.Screen) throw new ArgumentException("Can't handle this parameter : effectdock");
     LOC = worldorpod;
     EFFECT_DOCK = effectdock;
 }
Example #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="position">The position the arrow points to.</param>
 /// <param name="angle">angle of arrow with respect to x axis.</param>
 /// <param name="text">The text associated with the arrow.</param>
 public ArrowItem( PointD position, double angle, string text )
 {
     to_ = position;
     angle_ = -angle;
     text_ = text;
     Init();
 }
 public static void DrawTemplates(List<Tools.IToolFilter> templates, System.Drawing.Graphics gc, Tools.Render.RenderParameter rp, Tools.Render.RenderHint state, Tools.Render.IDrawVisitor drawMethods, PointD mousePosition)
 {
     foreach (Tools.IToolFilter filter in templates)
     {
         filter.Draw(gc, rp, state, drawMethods, mousePosition);
     }
 }
 public MoveHandleAction(Handle handle, Session session, PointD oldLocation)
 {
     this.handle = handle;
       this.session = session;
       this.oldLocation = oldLocation;
       this.newLocation = handle.Location;
 }
Example #10
0
 static void ProduceIMAGE()
 {
     BitmapData data_bac = IMAGE.GetBitmapData();
     PointD p = data_bac.Half();
     PointD vector;
     double angle;
     for (int i = 0; i < 50; i++)
     {
         angle = i * 0.04 * Math.PI;
         vector = new PointD(Math.Sin(angle), -Math.Cos(angle));
         data_bac.DrawLine(Color.FromArgb(255, 255, 0), p.Add(vector, i % 5 == 0 ? 35 : 45), p.Add(vector, i % 5 == 0 ? 25 : 40));
     }
     for (int i = 0; i < 10; i++)
     {
         angle = i * 0.2 * Math.PI;
         vector = new PointD(Math.Sin(angle), -Math.Cos(angle));
         data_bac.Paste(i.ToString(),
             p.Add(vector, 40.0),
             Color.FromArgb(255, 255, 255),
             FONT_FOR_INITIALIZE,
             StringAlign.Middle,
             StringRowAlign.Middle);
     }
     data_bac.Multiply_A(0.5);
     IMAGE.UnlockBits(data_bac);
 }
Example #11
0
 public static double distance(PointD a, PointD b)
 {
     double xCuadrado = (a.X - b.X) * (a.X - b.X);
     double yCuadrado = (a.Y - b.Y) * (a.Y - b.Y);
     double distancia = Math.Sqrt(xCuadrado + yCuadrado);
     return distancia;
 }
 public void AddPoint(PointD p)
 {
     lock (tempRoute)
     {
         tempRoute.Add(p);
     }
 }
Example #13
0
        public override bool DoMouseWheel(MouseEventArgs e, Control ctr, KeyEventArgs lastKeyEventArgs)
        {
            NPlot.PlotSurface2D ps = ((NPlot.Windows.PlotSurface2D)ctr).Inner;

            ((NPlot.Windows.PlotSurface2D)ctr).CacheAxes();

            double delta = e.Delta / (double)SystemInformation.MouseWheelScrollDelta;

            double zoomFactor = Math.Pow(sensitivity_, delta);

            PointD pMin = new PointD((double)ps.PhysicalXAxis1Cache.PhysicalMin.X, (double)ps.PhysicalYAxis1Cache.PhysicalMin.Y);
            PointD pMax = new PointD((double)ps.PhysicalXAxis1Cache.PhysicalMax.X, (double)ps.PhysicalYAxis1Cache.PhysicalMax.Y);

            PointD pMinRelative = new PointD(pMin.X - e.X, pMin.Y - e.Y);
            PointD pMaxRelative = new PointD(pMax.X - e.X, pMax.Y - e.Y);

            Point pMinZoomed = new Point((int)Math.Round((pMinRelative.X * zoomFactor) + e.X, 0), (int)Math.Round((pMinRelative.Y * zoomFactor) + e.Y, 0));
            Point pMaxZoomed = new Point((int)Math.Round((pMaxRelative.X * zoomFactor) + e.X, 0), (int)Math.Round((pMaxRelative.Y * zoomFactor) + e.Y, 0));

            ps.XAxis1.WorldMin = ps.PhysicalXAxis1Cache.PhysicalToWorld(pMinZoomed, false);
            ps.XAxis1.WorldMax = ps.PhysicalXAxis1Cache.PhysicalToWorld(pMaxZoomed, false);
            ps.YAxis1.WorldMin = ps.PhysicalYAxis1Cache.PhysicalToWorld(pMinZoomed, false);
            ps.YAxis1.WorldMax = ps.PhysicalYAxis1Cache.PhysicalToWorld(pMaxZoomed, false);

            return true;
        }
Example #14
0
        public override string ActivateScript(CandleChartControl chart, PointD worldCoords)
        {
            if (!AccountStatus.Instance.isAuthorized)
            {
                MessageBox.Show("Не авторизован");
                return "Не авторизован";
            }

            var accountId = AccountStatus.Instance.accountID;
            var numStepsMax = (VolumeMax - VolumeMin) / VolumeStep;
            var rand = new Random();
            var sb = new StringBuilder();

            // закрытые сделки
            var closedOrders = MakeClosedOrders(chart, accountId, rand, numStepsMax);

            // SQL по закрытым сделкам
            MakeClosedOrdersSQL(closedOrders, accountId, sb);

            // найти все отметки на графике
            // и по ним сбацать "сделки"
            var positions = MakeMarketOrders(chart, accountId, rand, numStepsMax);

            // слепить SQL по открытым позам
            MakeMarketOrdersSQL(positions, accountId, sb);

            if (sb.Length > 0)
                Clipboard.SetText(sb.ToString());
            return (positions.Count + closedOrders.Count) + " сделок скопировано в буфер обмена";
        }
Example #15
0
 public Map(PointU16 mapSize, Orientation orientation, PointD cellSize, PointD origin, MapShapes mapShape = MapShapes.Rectangle)
 {
     _mapSize = mapSize;
     _shape = mapShape;
     mapLayout = new Layout(orientation, cellSize, origin);
     hexes = new List<Hex>();
 }
Example #16
0
 /// <summary>Returns a new BoundingBox bounding a single point.</summary>
 public static BoundingBoxD FromPoint(ref PointD pt)
 {
     BoundingBoxD box = new BoundingBoxD();
     box.Xmin = box.Xmax = pt.X;
     box.Ymin = box.Ymax = pt.Y;
     return box;
 }
Example #17
0
 public Point toPoint(PointD pD)
 {
     Point p = new Point(0, 0);
     p.X = Convert.ToInt32(pD.X + 0.5);
     p.Y = Convert.ToInt32(pD.Y + 0.5);
     return p;
 }
 public RectangleD(PointD location, SizeD size)
 {
     x = location.X;
     y = location.Y;
     width = size.Width;
     height = size.Height;
 }
 public static PointD normalized2Pixels(PointD normalized)
 {
     double posX = normalized.X * (double)(Screen.PrimaryScreen.Bounds.Size.Width + Screen.PrimaryScreen.Bounds.X);
     double posY = normalized.Y * (double)(Screen.PrimaryScreen.Bounds.Size.Height + Screen.PrimaryScreen.Bounds.Y);
     PointD posicionMousePx = new PointD(posX, posY);
     return posicionMousePx;
 }
Example #20
0
        /// <summary>
        /// Vector with new start point
        /// with the length scaled by specified double factor.
        /// </summary>
        /// <param name="coefficient">Should be from 0 to 1.</param>
        /// <param name="newStartPoint">New start point.</param>
        public VectorD VectorScaledNewStartPoint(double coefficient, PointD newStartPoint)
        {
            double newX = this.X * coefficient;
            double newY = this.Y * coefficient;

            return new VectorD(newStartPoint, new PointD(newStartPoint.X + newX, newStartPoint.Y + newY));
        }
Example #21
0
        public Line(DataRecordRow row)
            : this()
        {
            ID = LoadAttributeID( row.Fields, DirectoryDataType.LINE );
            PolygonIDLeft = LoadAttributeID( row.Fields, DirectoryDataType.PIDL );
            PolygonIDRight = LoadAttributeID( row.Fields, DirectoryDataType.PIDR );
            StartNodeID = LoadAttributeID( row.Fields, DirectoryDataType.SNID );
            EndNodeID = LoadAttributeID( row.Fields, DirectoryDataType.ENID );

            AttributeIDs = new List<KeyValuePair<string, int>>();
            var attr = row.Fields.Where( field => field.FieldDefinition.Directory.Tag == DirectoryDataType.ATID );
            if( attr.Any() )
            {
                for( int i = 0; i < attr.Count(); i += 2 )
                    AttributeIDs.Add( new KeyValuePair<string,int>(attr.ElementAt( i ).AsString, attr.ElementAt( i + 1 ).AsInt) );
            }

            var firstX = row.Fields.First( field => field.FieldDefinition.Name == "X" );
            var startIndex = row.Fields.IndexOf( firstX );
            for( int i = startIndex; i < row.Fields.Count; i += 2 )
            {
                var point = new PointD { X = row.Fields[ i ].AsInt / 100.0, Y = row.Fields[ i + 1 ].AsInt / 100.0 };
                Points.Add( point );
            }

            DataRow = row;
        }
Example #22
0
 public Effect(Bitmap image, Point screenpos, ImagePasteMode imagepastemode, EffectDock effectdock, Rectangle region = default(Rectangle))
     : base(null, image, screenpos, imagepastemode, region)
 {
     if (effectdock != EffectDock.Screen) throw new ArgumentException("Can't handle this parameter : effectdock");
     LOC = new PointD(screenpos);
     EFFECT_DOCK = effectdock;
 }
Example #23
0
 public MapTransform(PointD center, double resolution, double width, double height)
 {
     _center = center;
     _resolution = resolution;
     _width = width;
     _height = height;
     UpdateExtent();
 }
		public override void doTransform(PointD p0, PointD p1)
		{
			double num = p0.x * p0.x;
			double num2 = p0.x * p0.y;
			double num3 = p0.y * p0.y;
			p1.x = this.c[0] + this.c[1] * p0.y + this.c[2] * num3 + this.c[3] * p0.x + this.c[4] * num2 + this.c[5] * num;
			p1.y = this.c[6] + this.c[7] * p0.y + this.c[8] * num3 + this.c[9] * p0.x + this.c[10] * num2 + this.c[11] * num;
		}
Example #25
0
        public CarModelState(PointD position, PointD orientation)
        {
            this.position = new PointD(0, 0);
            this.orientation = new PointD(1, 0);

            this.Position = position;
            this.Orientation = orientation;
        }
Example #26
0
 public MapTransform(PointD center, double unitsPerPixel, double width, double height)
 {
     _center = center;
     _unitsPerPixel = unitsPerPixel;
     _width = width;
     _height = height;
     UpdateExtent();
 }
Example #27
0
 private Win8Message(string text, Color color, double period)
     : base(text.ToBitmap(Width, FONT_FOR_INITIALIZE, color.RGBsum() >= byte.MaxValue * 3 / 2 ? Color.FromArgb(color.A, 0, 0, 0) : Color.FromArgb(color.A, 255, 255, 255), StringAlign.Left, color)
     , new Point(Background.Size.Width, NOW_HEIGHT), ImagePasteMode.Gradient, EffectDock.Screen)
 {
     TARGET = LOC.AddX(-Width);
     VISABLE = false;
     PERIOD = period;
 }
        public PointD start; //flightline start (geodetic degrees)

        #endregion Fields

        #region Constructors

        public endPoints(int _FlightLineNumber, PointD _start, PointD _end, double _FLLengthMeters, int _photoCenterOffset)
        {
            FlightLineNumber = _FlightLineNumber;
            start = _start;
            end = _end;
            FLLengthMeters = _FLLengthMeters;
            photoCenterOffset = _photoCenterOffset;
        }
Example #29
0
        public Line(PointD tstartpnt, PointD tendpnt, Color tcolor, float twidth)
        {
            this.Color = tcolor;
            this.LineWidth = twidth;

            this.p1 = tstartpnt.Clone() as PointD;
            this.p2 = tendpnt.Clone() as PointD;
        }
Example #30
0
        public PointD GetOptimalWayPointDestination()
        {
            PointD optimalPosition = WayPointHeatMap.GetOptimalPosition();

            return(optimalPosition);
        }
 /// <summary>
 /// Returns the current port location since we don't want to change the port location.
 /// </summary>
 protected override IPortLocationModelParameter GetNewParameter(IPort port, IPortLocationModel model,
                                                                PointD newLocation)
 {
     return(port.LocationParameter);
 }
Example #32
0
        public void Test_Drawables()
        {
            PointD[] coordinates = new PointD[3];
            coordinates[0] = new PointD(0, 0);
            coordinates[1] = new PointD(50, 50);
            coordinates[2] = new PointD(99, 99);

            using (var image = new MagickImage(MagickColors.Transparent, 100, 100))
            {
                image.Draw(new DrawableAffine(0, 0, 1, 1, 2, 2));
                image.Draw(new DrawableAlpha(0, 0, PaintMethod.Floodfill));
                image.Draw(new DrawableArc(0, 0, 10, 10, 45, 90));

                var bezier = new DrawableBezier(coordinates.ToList());
                Assert.Equal(3, bezier.Coordinates.Count());
                image.Draw(bezier);

                image.Draw(new DrawableBorderColor(MagickColors.Fuchsia));
                image.Draw(new DrawableCircle(0, 0, 50, 50));
                image.Draw(new DrawableClipPath("foo"));
                image.Draw(new DrawableClipRule(FillRule.Nonzero));
                image.Draw(new DrawableClipUnits(ClipPathUnit.UserSpaceOnUse));
                image.Draw(new DrawableColor(0, 0, PaintMethod.Floodfill));

                using (var compositeImage = new MagickImage(new MagickColor("red"), 50, 50))
                {
                    image.Draw(new DrawableComposite(0, 0, compositeImage));
                    image.Draw(new DrawableComposite(0, 0, CompositeOperator.Over, compositeImage));
                    image.Draw(new DrawableComposite(new MagickGeometry(50, 50, 10, 10), compositeImage));
                    image.Draw(new DrawableComposite(new MagickGeometry(50, 50, 10, 10), CompositeOperator.Over, compositeImage));
                }

                image.Draw(new DrawableDensity(97));
                image.Draw(new DrawableEllipse(10, 10, 4, 4, 0, 360));
                image.Draw(new DrawableFillColor(MagickColors.Red));
                image.Draw(new DrawableFillOpacity(new Percentage(50)));
                image.Draw(new DrawableFillRule(FillRule.EvenOdd));
                image.Draw(new DrawableFont("Arial.ttf"));
                image.Draw(new DrawableFont("Arial"));
                image.Draw(new DrawableGravity(Gravity.Center));
                image.Draw(new DrawableLine(20, 20, 40, 40));
                image.Draw(new DrawablePoint(60, 60));
                image.Draw(new DrawableFontPointSize(5));
                image.Draw(new DrawablePolygon(coordinates));
                image.Draw(new DrawablePolygon(coordinates.ToList()));
                image.Draw(new DrawablePolyline(coordinates));
                image.Draw(new DrawablePolyline(coordinates.ToList()));
                image.Draw(new DrawableRectangle(30, 30, 70, 70));
                image.Draw(new DrawableRotation(180));
                image.Draw(new DrawableRoundRectangle(30, 30, 50, 50, 70, 70));
                image.Draw(new DrawableScaling(15, 15));
                image.Draw(new DrawableSkewX(90));
                image.Draw(new DrawableSkewY(90));
                image.Draw(new DrawableStrokeAntialias(true));
                image.Draw(new DrawableStrokeColor(MagickColors.Purple));
                image.Draw(new DrawableStrokeDashArray(new double[2] {
                    10, 20
                }));
                image.Draw(new DrawableStrokeDashOffset(2));
                image.Draw(new DrawableStrokeLineCap(LineCap.Square));
                image.Draw(new DrawableStrokeLineJoin(LineJoin.Bevel));
                image.Draw(new DrawableStrokeMiterLimit(5));
                image.Draw(new DrawableStrokeOpacity(new Percentage(80)));
                image.Draw(new DrawableStrokeWidth(4));
                image.Draw(new DrawableText(0, 60, "test"));
                image.Draw(new DrawableTextAlignment(TextAlignment.Center));
                image.Draw(new DrawableTextAntialias(true));
                image.Draw(new DrawableTextDecoration(TextDecoration.LineThrough));
                image.Draw(new DrawableTextDirection(TextDirection.RightToLeft));
                image.Draw(new DrawableTextEncoding(Encoding.ASCII));
                image.Draw(new DrawableTextInterlineSpacing(4));
                image.Draw(new DrawableTextInterwordSpacing(6));
                image.Draw(new DrawableTextKerning(2));
                image.Draw(new DrawableTextUnderColor(MagickColors.Yellow));
                image.Draw(new DrawableTranslation(65, 65));
                image.Draw(new DrawableViewbox(0, 0, 100, 100));

                image.Draw(new DrawablePushClipPath("#1"), new DrawablePopClipPath());
                image.Draw(new DrawablePushGraphicContext(), new DrawablePopGraphicContext());
                image.Draw(new DrawablePushPattern("test", 30, 30, 10, 10), new DrawablePopPattern(), new DrawableFillPatternUrl("#test"), new DrawableStrokePatternUrl("#test"));
            }
        }
 /// <summary>指定されたワールド座標がこのバーチャル図形に含まれているかどうかを判定します。DoesGlobalScaleがfalseなら常にfalse。(IVirtualShapeの実装)</summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public override bool ContainPoint(PointD p)
 {
     return(DoesGlobalScale && Math.Pow((p.X - Center.X) / Radius.W, 2) + Math.Pow((p.Y - Center.Y) / Radius.H, 2) < 1);
 }
Example #34
0
 /// <summary>
 /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
 /// </summary>
 /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
 /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
 /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
 public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
 {
     // do nothing.
 }
Example #35
0
 /// <summary>
 /// A wrapper class for a PointD with knowledge of its previous ControlPoint.
 /// </summary>
 /// <param name="passedPosition">The position of the PointD on the Canvas.</param>
 /// <param name="passedControlPointIndex">The index of the previous ControlPoint to the new GeneratedPoint.</param>
 public GeneratedPoint(PointD passedPosition, int passedControlPointIndex)
 {
     Position          = passedPosition;
     ControlPointIndex = passedControlPointIndex;
 }
 protected override void OnInitialized(IInputModeContext context, PointD originalLocation)
 {
     // we remember the item in the collection when the drag is initialized.
     movedNodes.Add(item);
 }
Example #37
0
 public PointF ToPointF(PointD pointD)
 {
     return(new PointF((float)pointD.X, (float)pointD.Y));
 }
Example #38
0
        public PolarCoordinate ToPolarCoordinate(PointF point)
        {
            PointD pointD = new PointD((double)point.X, (double)point.Y);

            return(ToPolarCoordinate(pointD));
        }
Example #39
0
        /// <summary>Converts a polar coordinate to a pixel coordinate.</summary>
        public Point ToPoint(PolarCoordinate coordinate)
        {
            PointD point = ToPointD(coordinate);

            return(new Point((int)point.X, (int)point.Y));
        }
 /// <summary>指定されたワールド座標がこのバーチャル図形に含まれているかどうかを判定します。(IVirtualShapeの実装)</summary>
 /// <param name="p"></param>
 /// <returns>常にfalse。</returns>
 public override bool ContainPoint(PointD p)
 {
     return(false);
 }
 /// <summary>指定されたワールド座標がこのバーチャル図形に含まれているかどうかを判定します。</summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public abstract bool ContainPoint(PointD p);
 /// <summary>
 /// Translates the specified point by the specified vector and returns the resulting point.
 /// </summary>
 /// <param name="vector">The amount to translate the specified point.</param>
 /// <param name="point">The point to translate.</param>
 /// <returns>The result of translating point by vector.</returns>
 public static PointD Add(VectorD vector, PointD point)
 {
     return(vector + point);
 }
        /// <summary>
        /// Adjusts the node location and size according to the new handle location.
        /// </summary>
        public void HandleMove(IInputModeContext inputModeContext, PointD originalLocation, PointD newLocation)
        {
            // calculate how much the handle was moved
            var upNormal = new PointD(-initialLayout.UpY, initialLayout.UpX);
            var deltaW   = GetWidthDelta(originalLocation, newLocation, upNormal);
            var up       = initialLayout.GetUp();
            var deltaH   = GetHeightDelta(originalLocation, newLocation, up);

            // add one or two times delta to the width to expand the node right and left
            dummySize = new SizeD(
                initialLayout.Width + deltaW * (symmetricResize ? 2 : 1),
                initialLayout.Height + deltaH * (symmetricResize ? 2 : 1));

            // Calculate the new location.
            // Depending on our handle position, a different corner of the node should stay fixed.
            if (symmetricResize)
            {
                var dx = upNormal.X * deltaW + up.X * deltaH;
                var dy = upNormal.Y * deltaW + up.Y * deltaH;
                dummyLocation = initialLayout.GetAnchorLocation() - new PointD(dx, dy);
            }
            else
            {
                var w = dummySize.Width - initialLayout.Width;
                var h = dummySize.Height - initialLayout.Height;
                switch (position)
                {
                case HandlePositions.NorthWest:
                    dummyLocation = initialLayout.GetAnchorLocation()
                                    - new PointD(-up.Y * w, up.X * w);
                    break;

                case HandlePositions.South:
                case HandlePositions.SouthWest:
                case HandlePositions.West:
                    dummyLocation = initialLayout.GetAnchorLocation()
                                    - new PointD(up.X * h - up.Y * w, up.Y * h + up.X * w);
                    break;

                case HandlePositions.SouthEast:
                    dummyLocation = initialLayout.GetAnchorLocation()
                                    - new PointD(up.X * h, up.Y * h);
                    break;

                // case HandlePositions.North:
                // case HandlePositions.NorthEast:
                // case HandlePositions.East:
                default:
                    dummyLocation = initialLayout.GetAnchorLocation();
                    break;
                }
            }

            var newLayout = SetNodeLocationAndSize(inputModeContext, dummyLocation, dummySize);

            var portContext = new DelegatingContext(inputModeContext);

            foreach (var portHandle in portHandles)
            {
                portHandle.HandleMove(portContext, dummyLocation, newLocation);
            }
            if (reshapeHandler != null)
            {
                // if there is a reshape handler:
                // ensure proper handling of a parent group node
                reshapeHandler.HandleReshape(inputModeContext, initialRect, newLayout);
            }
        }
 public override string ActivateScript(CandleChartControl chart, PointD worldCoords)
 {
     this.chart = chart;
     CalcStatistics();
     return(string.Empty);
 }
Example #45
0
        public void DrawPolyline(ref Page refPage, DrawPinModel pinModel)
        {
            Logger.WriteLine(JsonConvert.SerializeObject(pinModel));

            string symbolName = "";

            PointD[] PinTextPos         = new PointD[2];
            PointD   DescriptionTextPos = new PointD();

            PointD[] PinOutline = new PointD[5];
            PointD[] points     = new PointD[10];
            int      index      = 0;

            string[] pinDefs        = pinModel.Number.Split(new string[] { "(", ")" }, StringSplitOptions.None);
            string[] pinName        = new string[pinDefs.Length];
            string[] pinNum         = new string[pinDefs.Length];
            string[] pinDescription = pinModel.FunctionDescription.Split(new string[] { "," }, StringSplitOptions.None);

            foreach (var item in pinDefs)
            {
                string[] temp = item.Split(new string[] { "," }, StringSplitOptions.None);
                if (temp.Length >= 2)
                {
                    pinName[index] = temp[1];
                    pinNum[index]  = temp[0];
                    index++;
                }
            }

            int pinMarkSize = (int)pinModel.Font.Size;
            int offset      = Math.Max(pinModel.DimensionX, pinModel.DimensionY) + pinMarkSize;

            offset = offset + pinModel.PolylineOffset;

            switch (pinModel.LocationSide)
            {
            case EplDrawPosition.Left:
                symbolName    = "LeftConnectionPoint";
                PinOutline[0] = new PointD(pinModel.PositionX + pinMarkSize, pinModel.PositionY);
                PinOutline[1] = new PointD(pinModel.PositionX + pinMarkSize, pinModel.PositionY + pinModel.PinDistance);

                points[0] = new PointD(PinOutline[0].X, PinOutline[0].Y + pinModel.DimensionY / 2);
                points[1] = new PointD(PinOutline[0].X + offset, PinOutline[0].Y + pinModel.DimensionY / 2);
                points[2] = new PointD(PinOutline[0].X + offset, PinOutline[0].Y + pinModel.PinDistance - pinModel.DimensionY / 2);;
                points[3] = new PointD(PinOutline[0].X, PinOutline[0].Y + pinModel.PinDistance - pinModel.DimensionY / 2);

                PinTextPos[0] = new PointD(points[0].X, points[0].Y + offset);
                PinTextPos[1] = new PointD(points[3].X, points[0].Y - offset);

                DescriptionTextPos = new PointD(points[0].X + 5, points[0].Y + pinModel.PinDistance / 2);
                break;

            case EplDrawPosition.Right:
                symbolName    = "RightConnectionPoint";
                PinOutline[0] = new PointD(pinModel.PositionX - pinMarkSize, pinModel.PositionY);
                PinOutline[1] = new PointD(pinModel.PositionX - pinMarkSize, pinModel.PositionY + pinModel.PinDistance);

                points[0] = new PointD(PinOutline[0].X, PinOutline[0].Y + pinModel.DimensionY / 2);
                points[1] = new PointD(PinOutline[0].X - offset, PinOutline[0].Y + pinModel.DimensionY / 2);
                points[2] = new PointD(PinOutline[0].X - offset, PinOutline[0].Y + pinModel.PinDistance - pinModel.DimensionY / 2);;
                points[3] = new PointD(PinOutline[0].X, PinOutline[0].Y + pinModel.PinDistance - pinModel.DimensionY / 2);

                PinTextPos[0] = new PointD(points[0].X, points[0].Y + offset);
                PinTextPos[1] = new PointD(points[3].X, points[0].Y - offset);

                DescriptionTextPos = new PointD(points[0].X - 5, points[0].Y + pinModel.PinDistance / 2);
                break;

            case EplDrawPosition.Bottom:
                symbolName    = "BottomConnectionPoint";
                PinOutline[0] = new PointD(pinModel.PositionX, pinModel.PositionY + pinMarkSize);
                PinOutline[1] = new PointD(pinModel.PositionX + pinModel.PinDistance, pinModel.PositionY + pinMarkSize);

                points[0] = new PointD(PinOutline[0].X + pinModel.DimensionY / 2, PinOutline[0].Y);
                points[1] = new PointD(PinOutline[0].X + pinModel.DimensionY / 2, PinOutline[0].Y + offset);
                points[2] = new PointD(PinOutline[0].X + pinModel.PinDistance - pinModel.DimensionY / 2, PinOutline[0].Y + offset);;
                points[3] = new PointD(PinOutline[0].X + pinModel.PinDistance - pinModel.DimensionY / 2, PinOutline[0].Y);

                PinTextPos[0] = new PointD(points[0].X + offset, points[0].Y);
                PinTextPos[1] = new PointD(points[3].X - offset, points[0].Y);

                DescriptionTextPos = new PointD(points[0].X + pinModel.PinDistance / 2, points[0].Y + 5);
                break;

            case EplDrawPosition.Top:
                symbolName    = "TopConnectionPoint";
                PinOutline[0] = new PointD(pinModel.PositionX, pinModel.PositionY - pinMarkSize);
                PinOutline[1] = new PointD(pinModel.PositionX + pinModel.PinDistance, pinModel.PositionY - pinMarkSize);

                points[0] = new PointD(PinOutline[0].X + pinModel.DimensionY / 2, PinOutline[0].Y);
                points[1] = new PointD(PinOutline[0].X + pinModel.DimensionY / 2, PinOutline[0].Y - offset);
                points[2] = new PointD(PinOutline[0].X + pinModel.PinDistance - pinModel.DimensionY / 2, PinOutline[0].Y - offset);
                points[3] = new PointD(PinOutline[0].X + pinModel.PinDistance - pinModel.DimensionY / 2, PinOutline[0].Y);

                PinTextPos[0] = new PointD(points[0].X + offset, points[0].Y);
                PinTextPos[1] = new PointD(points[3].X - offset, points[0].Y);

                DescriptionTextPos = new PointD(points[0].X + pinModel.PinDistance / 2, points[0].Y - 5);
                break;

            default:
                break;
            }

            Rectangle(ref refPage, pinModel, PinOutline[0]);
            Rectangle(ref refPage, pinModel, PinOutline[1]);

            refPage.InsertConnectingPoint("MY_LIB_K", symbolName, PinOutline[0]);
            refPage.InsertConnectingPoint("MY_LIB_K", symbolName, PinOutline[1]);

            Text text1 = new Text();

            text1.Create(refPage, pinName[0], pinModel.Font.Height);
            Text text2 = new Text();

            text2.Create(refPage, pinName[1], pinModel.Font.Height);
            text1.Location = PinTextPos[0];
            text2.Location = PinTextPos[1];
            PolyLine polyLine = new PolyLine();

            polyLine.Create(refPage);
            polyLine.Pen.Width = pinModel.OutlineWidthVal;
            for (int i = 0; i < 4; i++)
            {
                polyLine.SetPointAt(i, ref points[i]);
            }

            Text text3 = new Text();

            switch (pinModel.Function)
            {
            case EplDrawPinFunction.POWER_AC:

                text3.Create(refPage, "PWR AC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.POWER_DC:
                text3.Create(refPage, "PWR DC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.SIGNAL_PIN:
                break;

            case EplDrawPinFunction.INPUT_AC_V:
                text3.Create(refPage, "Input\nV-AC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.INPUT_AC_A:
                text3.Create(refPage, "Input\nA-AC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.INPUT_DC_V:
                text3.Create(refPage, "Input\nV-DC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.INPUT_DC_A:
                text3.Create(refPage, "Input\nA-DC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.OUPUT_AC_V:
                text3.Create(refPage, "Output\nV-AC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.OUPUT_AC_A:
                text3.Create(refPage, "Output\nV-AC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.OUPUT_DC_V:
                text3.Create(refPage, "Output\nV-DC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.OUPUT_DC_A:
                text3.Create(refPage, "Output\nA-DC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.CONTACT_NO:
                text3.Create(refPage, "NO", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.CONTACT_NC:
                text3.Create(refPage, "NC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.CONTACT_NOC:
                text3.Create(refPage, "NO-NC", pinModel.Font.Height);
                text3.Location = DescriptionTextPos;
                break;

            case EplDrawPinFunction.SHILED:
                break;

            case EplDrawPinFunction.EARTH:
                break;

            case EplDrawPinFunction.RECTANGLE:
                break;

            case EplDrawPinFunction.CIRCLE:
                break;

            case EplDrawPinFunction.TEXT:
                break;

            default:
                break;
            }
        }
Example #46
0
 public override Result FluidArc(SvValveFludLineParam svValveArcParam, PointD center, short clockwize, double acc)
 {
     throw new NotImplementedException();
 }
 protected override PointD ConstrainNewLocation(IInputModeContext context, PointD originalLocation, PointD newLocation)
 {
     // we do not really constrain the location - this is just a convenience class
     return(newLocation);
 }
Example #48
0
        public override Result FluidLine(PointD accStartPos, PointD lineStartPos, PointD lineEndPos, PointD decEndPos, double vel, PointD[] points, double intervalSec, double acc)
        {
            if (Machine.Instance.Robot.IsSimulation)
            {
                return(Result.OK);
            }

            if (points == null)
            {
                return(Result.FAILED);
            }

            if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet || Machine.Instance.Valve1.RunMode == ValveRunMode.Dry)
            {
                accStartPos  = accStartPos.ToNeedle(this.valve1.Key);
                lineStartPos = lineStartPos.ToNeedle(this.valve1.Key);
                lineEndPos   = lineEndPos.ToNeedle(this.valve1.Key);
                decEndPos    = decEndPos.ToNeedle(this.valve1.Key);
                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = points[i].ToNeedle(this.valve1.Key);
                }
            }

            double interval = 0;

            if (points.Length >= 2)
            {
                interval = points[0].DistanceTo(points[1]);
            }

            //计算加速段时间,用于启动时间控制打胶
            double accTime = this.CalcAccTime(accStartPos, lineStartPos, vel, acc * 1000);

            //连续插补
            List <ICrdable> crdList = new List <ICrdable>();
            //加速段
            CrdLnXY crdAcc = new CrdLnXY()
            {
                EndPosX = lineStartPos.X,
                EndPosY = lineStartPos.Y,
                Vel     = vel,
                Acc     = acc,
                VelEnd  = vel
            };

            crdList.Add(crdAcc);
            //匀速段
            for (int i = 1; i < points.Length; i++)
            {
                CrdLnXY crdLn = new CrdLnXY()
                {
                    EndPosX = points[i].X,
                    EndPosY = points[i].Y,
                    Vel     = vel,
                    Acc     = acc,
                    VelEnd  = vel
                };
                crdList.Add(crdLn);
            }
            //减速段
            CrdLnXY crdDec = new CrdLnXY()
            {
                EndPosX = decEndPos.X,
                EndPosY = decEndPos.Y,
                Vel     = vel,
                Acc     = acc,
                VelEnd  = 0
            };

            crdList.Add(crdDec);

            DateTime t1           = DateTime.Now;
            DateTime t2           = DateTime.Now;
            Result   rtn          = Result.OK;
            int      intervalTime = (int)(intervalSec * 1000000);

            //时间控制函数
            Action timeCtrlAction = () =>
            {
                ICommandable command = null;
                if (this.jtValve1.Prm.MoveMode == ValveMoveMode.单次插补)
                {//单次插补
                    CrdLnXY crd = new CrdLnXY()
                    {
                        EndPosX = decEndPos.X,
                        EndPosY = decEndPos.Y,
                        Vel     = vel,
                        Acc     = acc,
                        VelEnd  = vel
                    };
                    command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crd,
                        () =>
                    {
                        t1 = DateTime.Now;
                        ValveSprayServer.Instance.StartSprayEvent.Set();
                    })
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                }
                else
                {//多次插补
                    command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crdList,
                        () =>
                    {
                        t1 = DateTime.Now;
                        ValveSprayServer.Instance.StartSprayEvent.Set();
                    })
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                }

                //设置打胶线程启动时间
                ValveSprayServer.Instance.SleepSpan = TimeSpan.FromSeconds(accTime);
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    ValveSprayServer.Instance.SprayAction = () =>
                    {
                        t2 = DateTime.Now;
                        this.SprayCycle((short)points.Count(), (short)(intervalTime - this.jtValve1.Prm.OnTime));
                    };
                }
                else
                {
                    ValveSprayServer.Instance.SprayAction = null;
                }

                Log.Dprint(string.Format("Fluid Line[time ctrl]-> accTime:{0}, intervalTime:{1}, onTime:{2}, offTime{3}.",
                                         accTime, intervalTime, this.jtValve1.Prm.OnTime, this.jtValve1.Prm.OffTime));
                Machine.Instance.Robot.Fire(command);
                rtn = Machine.Instance.Robot.WaitCommandReply(command);

                Debug.WriteLine(t1.ToString("HH::mm::ss::fff"));
                Debug.WriteLine(t2.ToString("HH::mm::ss::fff"));
            };

            //2d比较控制函数
            Action cmp2dAction = () =>
            {
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    CmpStop();
                    SimulCmp2dStart((short)Cmp2dSrcType.编码器, (short)this.jtValve1.Prm.Cmp2dMaxErr, points);
                }

                if (this.jtValve1.Prm.MoveMode == ValveMoveMode.单次插补)
                {
                    rtn = Machine.Instance.Robot.MovePosXYAndReply(decEndPos, vel, acc);
                }
                else
                {
                    CommandMoveTrc command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crdList)
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                    Log.Dprint(string.Format("Fluid Line[2d ctrl]-> maxErr:{0}, interval:{1}", this.jtValve1.Prm.Cmp2dMaxErr, interval));
                    Machine.Instance.Robot.Fire(command);
                    rtn = Machine.Instance.Robot.WaitCommandReply(command);
                }

                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    //Cmp2dStop();
                }
            };

            //一维比较控制函数
            Action cmp1dAction = () =>
            {
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    SimulCmp2dStop();
                    CmpStart((short)Cmp2dSrcType.编码器, points);
                }

                if (this.jtValve1.Prm.MoveMode == ValveMoveMode.单次插补)
                {
                    rtn = Machine.Instance.Robot.MovePosXYAndReply(decEndPos, vel, acc);
                }
                else
                {
                    CommandMoveTrc command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crdList)
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                    Log.Dprint(string.Format("Fluid Line[2d ctrl]-> maxErr:{0}, interval:{1}", this.jtValve1.Prm.Cmp2dMaxErr, interval));
                    Machine.Instance.Robot.Fire(command);
                    rtn = Machine.Instance.Robot.WaitCommandReply(command);
                }

                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    //CmpStop();
                }
            };

            switch (this.jtValve1.Prm.FluidMode)
            {
            case ValveFluidMode.一维比较优先:
                cmp1dAction();
                break;

            case ValveFluidMode.二维比较优先:
                if (interval * 1000 > this.jtValve1.Prm.Cmp2dMaxErr || points.Length < 2)
                {
                    cmp2dAction();
                }
                else
                {
                    //timeCtrlAction();
                    cmp1dAction();
                }
                break;

            case ValveFluidMode.时间控制优先:
                if (intervalTime - this.jtValve1.Prm.OnTime < short.MaxValue)
                {    //判断脉宽是否short类型溢出,
                    timeCtrlAction();
                }
                else
                {    //溢出:位置比较模式
                    //cmp2dAction();
                    cmp1dAction();
                }
                break;
            }


            return(rtn);
        }
Example #49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PathSmoothCurveToRel"/> class.
 /// </summary>
 /// <param name="controlPoint">Coordinate of second point</param>
 /// <param name="end">Coordinate of final point</param>
 public PathSmoothCurveToRel(PointD controlPoint, PointD end)
 {
     _controlPoint = controlPoint;
     _end          = end;
 }
Example #50
0
        public override Result FluidArc(PointD accStartPos, PointD arcStartPos, PointD arcEndPos, PointD decEndPos, PointD center, short clockwize, double vel, PointD[] points, double intervalSec, double acc)
        {
            if (Machine.Instance.Robot.IsSimulation)
            {
                return(Result.OK);
            }

            if (points == null)
            {
                return(Result.FAILED);
            }

            if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet || Machine.Instance.Valve1.RunMode == ValveRunMode.Dry)
            {
                accStartPos = accStartPos.ToNeedle(this.valve1.Key);
                arcStartPos = arcStartPos.ToNeedle(this.valve1.Key);
                arcEndPos   = arcEndPos.ToNeedle(this.valve1.Key);
                decEndPos   = decEndPos.ToNeedle(this.valve1.Key);
                center      = center.ToNeedle(this.valve1.Key);
                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = points[i].ToNeedle(this.valve1.Key);
                }
            }

            double interval = 0;

            if (points.Length >= 2)
            {
                interval = points[0].DistanceTo(points[1]);
            }
            double accTime = this.CalcAccTime(accStartPos, arcStartPos, vel, acc * 1000);

            //连续差补
            List <ICrdable> crdList = new List <ICrdable>();
            //加速段-直线
            CrdLnXY crdAcc = new CrdLnXY()
            {
                EndPosX = arcStartPos.X,
                EndPosY = arcStartPos.Y,
                Vel     = vel,
                Acc     = acc,
                VelEnd  = vel
            };

            crdList.Add(crdAcc);
            //匀速段-圆
            for (int i = 1; i < points.Length; i++)
            {
                CrdArcXYC crdArc = new CrdArcXYC()
                {
                    EndPosX   = points[i].X,
                    EndPosY   = points[i].Y,
                    CenterX   = center.X - points[i - 1].X,
                    CenterY   = center.Y - points[i - 1].Y,
                    Clockwise = clockwize,
                    Vel       = vel,
                    Acc       = acc,
                    VelEnd    = vel
                };
                crdList.Add(crdArc);
            }
            //减速段-直线
            CrdLnXY crdDec = new CrdLnXY()
            {
                EndPosX = decEndPos.X,
                EndPosY = decEndPos.Y,
                Vel     = vel,
                Acc     = acc,
                VelEnd  = 0
            };

            crdList.Add(crdDec);
            Result rtn          = Result.OK;
            int    intervalTime = (int)(intervalSec * 1000000);

            Action timeCtrlAction = () =>
            {
                CommandMoveTrc command = new CommandMoveTrc(
                    Machine.Instance.Robot.AxisX,
                    Machine.Instance.Robot.AxisY,
                    Machine.Instance.Robot.TrcPrm,
                    crdList);
                command.Starting += () =>
                {
                    ValveSprayServer.Instance.StartSprayEvent.Set();
                };

                ValveSprayServer.Instance.SleepSpan = TimeSpan.FromSeconds(accTime);
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    ValveSprayServer.Instance.SprayAction = () =>
                    {
                        this.SprayCycle((short)points.Count(), (short)(intervalTime - this.jtValve1.Prm.OnTime));
                    };
                }
                else
                {
                    ValveSprayServer.Instance.SprayAction = null;
                }

                Log.Dprint(string.Format("Fluid Line[time ctrl]-> accTime:{0}, intervalTime:{1}, onTime:{2}, offTime{3}.",
                                         accTime, intervalTime, this.jtValve1.Prm.OnTime, this.jtValve1.Prm.OffTime));
                Machine.Instance.Robot.Fire(command);
                rtn = Machine.Instance.Robot.WaitCommandReply(command);
            };

            Action cmp2dAction = () =>
            {
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    SimulCmp2dStart((short)Cmp2dSrcType.编码器, (short)this.jtValve1.Prm.Cmp2dMaxErr, points);
                }
                CommandMoveTrc command = new CommandMoveTrc(
                    Machine.Instance.Robot.AxisX,
                    Machine.Instance.Robot.AxisY,
                    Machine.Instance.Robot.TrcPrm,
                    crdList);
                Log.Dprint(string.Format("Fluid Line[2d ctrl]-> maxErr:{0}, interval:{1}", this.jtValve1.Prm.Cmp2dMaxErr, interval));
                Machine.Instance.Robot.Fire(command);
                rtn = Machine.Instance.Robot.WaitCommandReply(command);
                //if (this.RunMode == ValveRunMode.Wet)
                //{
                //    Cmp2dStop();
                //}
            };

            if (this.jtValve1.Prm.FluidMode == ValveFluidMode.时间控制优先)
            {
                if (intervalTime - this.jtValve1.Prm.OnTime < short.MaxValue)
                {//判断脉宽是否short类型溢出,
                    timeCtrlAction();
                }
                else
                {//溢出:位置比较模式
                    cmp2dAction();
                }
            }
            else
            {
                if (interval * 1000 > this.jtValve1.Prm.Cmp2dMaxErr || points.Length < 2)
                {
                    cmp2dAction();
                }
                else
                {
                    timeCtrlAction();
                }
            }

            return(rtn);
        }
 /// <summary>デフォルトコンストラクタ。</summary>
 public VirtualEllipse()
 {
     Center = new PointD();
     Radius = new SizeD();
 }
 /// <summary>デフォルトコンストラクタ。</summary>
 public VirtualRectangle()
 {
     Location = new PointD();
     Size     = new SizeD();
 }
 /// <summary>コピーコンストラクタ。</summary>
 /// <param name="previous"></param>
 public VirtualLine(VirtualLine previous)
     : base(previous)
 {
     Vertices = new PointD[previous.Vertices.Length];
     previous.Vertices.CopyTo(Vertices, 0);
 }
Example #54
0
 public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
 {
     foreach (SymbolLine symbolLine in this.symbols)
     {
         symbolLine.Correct(patternOldOrigin, coordinateTransformer, patternNewOrigin);
     }
 }
 /// <summary>指定されたワールド座標がこのバーチャル図形に含まれているかどうかを判定します。DoesGlobalScaleがfalseなら常にfalse。</summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public override bool ContainPoint(PointD p)
 {
     return(DoesGlobalScale && Location.X < p.X && p.X < Location.X + Size.W && Location.Y < p.Y && p.Y < Location.Y + Size.H);
 }
Example #56
0
        /// <summary>Calculate the bezier points</summary>
        private void CalcBezPoints()
        {
            bezPoints.Clear();
            if (sourceNode == null || targetNode == null)
            {
                return;
            }
            PointD ep1 = new PointD();
            PointD ep2 = new PointD();

            if (sourceNode != targetNode)
            {
                ep1 = sourceNode.Location;
                ep2 = targetNode.Location;
            }
            else
            {
                double d = sourceNode.Width / 4;
                double m;
                if ((sourceNode.Location.X - Location.X) != 0)
                {
                    m = Math.Atan((sourceNode.Location.Y - Location.Y) / (double)(sourceNode.Location.X - Location.X));
                }
                else
                if (sourceNode.Location.Y > Location.Y)
                {
                    m = Math.PI * 0.5;
                }
                else
                {
                    m = Math.PI * 1.5;
                }
                double m1 = m - Math.PI / 2;
                double m2 = m + Math.PI / 2;
                ep1.X = sourceNode.Location.X + (int)(d * Math.Cos(m1));
                ep1.Y = sourceNode.Location.Y + (int)(d * Math.Sin(m1));
                ep2.X = sourceNode.Location.X + (int)(d * Math.Cos(m2));
                ep2.Y = sourceNode.Location.Y + (int)(d * Math.Sin(m2));
            }

            int start   = (int)Math.Min(ep1.X, ep2.X);
            int end     = (int)Math.Max(ep1.X, ep2.X);
            int xPoints = end - start;

            start = (int)Math.Min(ep1.Y, ep2.Y);
            end   = (int)Math.Max(ep1.Y, ep2.Y);
            int yPoints = end - start;

            //will calc a min of 100 points
            int points = Math.Max(Math.Max(xPoints, yPoints), 50) * 2;

            double[] output = new double[points];
            bezParameters[0] = ep1.X;
            bezParameters[1] = ep1.Y;
            bezParameters[2] = Location.X;
            bezParameters[3] = Location.Y;
            bezParameters[4] = Location.X;
            bezParameters[5] = Location.Y;
            bezParameters[6] = ep2.X;
            bezParameters[7] = ep2.Y;

            bezCurve.Bezier2D(bezParameters, (points) / 2, output);
            for (int i = 0; i < points - 2; i += 2)
            {
                bezPoints.Add(new PointD((int)output[i], (int)output[i + 1]));
            }
        }
Example #57
0
        public PointD GetOptimalStrategyDestination()
        {
            PointD optimalPosition = strategyHeatMap.GetOptimalPosition();

            return(optimalPosition);
        }
        /// <summary>
        /// Applies the new node layout.
        /// </summary>
        public void DragFinished(IInputModeContext inputModeContext, PointD originalLocation, PointD newLocation)
        {
            var newLayout   = SetNodeLocationAndSize(inputModeContext, dummyLocation, dummySize);
            var portContext = new DelegatingContext(inputModeContext);

            foreach (var portHandle in portHandles)
            {
                portHandle.DragFinished(portContext, originalLocation, newLocation);
            }
            portHandles.Clear();
            if (reshapeHandler != null)
            {
                // if there is a reshape handler:
                // ensure proper handling of a parent group node
                reshapeHandler.ReshapeFinished(inputModeContext, initialRect, newLayout);
            }
        }
Example #59
0
 public override void doTransform(PointD p0, PointD p1)
 {
     p1.x = this.c0 * p0.x + this.c1 * p0.y + this.c2;
     p1.y = this.c3 * p0.x + this.c4 * p0.y + this.c5;
 }
        private PointLatLng getLatLong(PointD i_location)
        {
            PointLatLng coordinates;
            coordinates = new PointLatLng(i_location.X, i_location.Y);

            return coordinates;
        }