예제 #1
0
        private PointF CalculateCenterPoint(ISvgBoundable boundable, PointF origin)
        {
            var deviceCenterX          = origin.X + CenterX.ToDeviceValue(boundable);
            var deviceCenterY          = origin.Y + CenterY.ToDeviceValue(boundable, true);
            var transformedCenterPoint = TransformPoint(new PointF(deviceCenterX, deviceCenterY));

            return(transformedCenterPoint);
        }
예제 #2
0
        private PointF CalculateCenterPoint(SvgRenderer renderer, PointF origin)
        {
            var deviceCenterX          = origin.X + CenterX.ToDeviceValue(renderer, UnitRenderingType.HorizontalOffset, this);
            var deviceCenterY          = origin.Y + CenterY.ToDeviceValue(renderer, UnitRenderingType.VerticalOffset, this);
            var transformedCenterPoint = TransformPoint(new PointF(deviceCenterX, deviceCenterY));

            return(transformedCenterPoint);
        }
예제 #3
0
        public override string ToString()
        {
            var ci = System.Globalization.CultureInfo.InvariantCulture;

            return(string.Format("{{ CenterX={0}, CenterY={1}, Width={2}, Height={3}, Angle={4} }}",
                                 CenterX.ToString("r", ci), CenterY.ToString("r", ci),
                                 Width.ToString("r", ci), Height.ToString("r", ci),
                                 Angle.ToString("r", ci)));
        }
예제 #4
0
 /// <summary>
 /// A hash code produced out of hash codes of Radius and center.
 /// </summary>
 /// <returns>
 /// A hash code produced out of hash codes of Radius and center.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Radius.GetHashCode();
         hashCode = (hashCode * 397) ^ CenterX.GetHashCode();
         hashCode = (hashCode * 397) ^ CenterY.GetHashCode();
         return(hashCode);
     }
 }
예제 #5
0
        public override int GetHashCode() // переопределение метода GetHashCode()
        {
            var hash = 19;

            hash = hash * 37 + CenterX.GetHashCode();
            hash = hash * 37 + CenterY.GetHashCode();
            hash = hash * 37 + SizeArea.GetHashCode();
            hash = hash * 37 + FractalType.GetHashCode();

            return(hash);
        }
예제 #6
0
        public override void DrawControls()
        {
            Name      = "Rectangle";
            rectColor = EditorGUILayout.ColorField("Color", rectColor);
            CenterX   = float.Parse(EditorGUILayout.TextField("X Position", CenterX.ToString()));
            CenterY   = float.Parse(EditorGUILayout.TextField("Y Position", CenterY.ToString()));
            Width     = float.Parse(EditorGUILayout.TextField("Width", Width.ToString()));
            Height    = float.Parse(EditorGUILayout.TextField("Height", Height.ToString()));


            base.DrawControls();
        }
예제 #7
0
        public override void DrawControls()
        {
            Name         = "RoundedRect";
            rectColor    = EditorGUILayout.ColorField("Color", rectColor);
            CenterX      = float.Parse(EditorGUILayout.TextField("X Position", CenterX.ToString()));
            CenterY      = float.Parse(EditorGUILayout.TextField("Y Position", CenterY.ToString()));
            Width        = float.Parse(EditorGUILayout.TextField("Width", Width.ToString()));
            Height       = float.Parse(EditorGUILayout.TextField("Height", Height.ToString()));
            CornerRadius = float.Parse(EditorGUILayout.TextField("Corner Radius", CornerRadius.ToString()));
            Smoothness   = float.Parse(EditorGUILayout.TextField("Smoothness", Smoothness.ToString()));


            base.DrawControls();
        }
예제 #8
0
        private void WindowRefresh_Tick(object sender, EventArgs e)
        {
            this.either_Light.LeftPress = GlobalVar.c_Modbus.Coils.CCDLightStatus.Value;  //相机光源
            this.either_Press.LeftPress = !GlobalVar.c_Modbus.Coils.Cylinder12.Value;     //相机汽缸

            double RealLocation = 0d;                                                     //Y轴实际位置

            RealLocation  = GlobalVar.c_Modbus.HoldingRegisters.AxisY_RealLocation.Value; //Y轴实际位置
            RealLocation /= GlobalVar.ConverRate;                                         //Y轴实际位置
            this.label_RealLocation.Text = string.Format("当前位置:{0}", RealLocation.ToString("#0.00"));
            RealLocation  = GlobalVar.c_Modbus.HoldingRegisters.CCD_RealLocation.Value;   //CCD轴实际位置[2018.4.16 lqz]
            RealLocation *= GlobalVar.ConverRate_CCD;                                     //CCD轴实际位置
            this.label_RealLocation_CCD.Text = string.Format("当前位置:{0}", RealLocation.ToString("#0.00"));

            try
            {
                if (!this.AutoFind || ShowBitmap.Count == 0)
                {
                    return;
                }
                Bitmap bitmap = ShowBitmap[0];
                GlobalVar.FindModel.ShapeFind(ref bitmap);
                EFoundPattern[] positioninfo = GlobalVar.FindModel.m_FindResult;
                //DrawMatchResult(positioninfo);
                this.pictureBox_CCD.Image = bitmap;
                this.pictureBox_CCD.Update();

                if (ShowBitmap.Count > 0)
                {
                    ShowBitmap.RemoveAt(0);
                }

                if (positioninfo.Length > 0)
                {
                    score   = positioninfo[0].Score;
                    CenterX = positioninfo[0].Center.X;
                    CenterY = positioninfo[0].Center.Y;
                    UpdateText(CenterX.ToString("#.000"), CenterY.ToString("#.000"), (score * 100).ToString("#.0"));
                }
                else
                {
                    ShowBitmap.Clear();
                    UpdateText("---", "---", "--");
                }
            }
            catch (Exception ex) { Console.WriteLine("Grab Image err:" + ex.Message); }
            finally
            { GC.Collect(); }
        }
예제 #9
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine
            {
                // http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode/263416#263416
                int hash = 17;
                hash = hash * 23 + CenterX.GetHashCode();
                hash = hash * 23 + CenterY.GetHashCode();
                hash = hash * 23 + Width.GetHashCode();
                hash = hash * 23 + Height.GetHashCode();
                hash = hash * 23 + Angle.GetHashCode();

                return(hash);
            }
        }
예제 #10
0
        public override void WriteGroupCodes()
        {
            WriteGroupCodeValue(2, ViewportName.Trim());

            WriteGroupCodeValue(10, LowerLeftX.ToString().Trim());
            WriteGroupCodeValue(20, LowerLeftY.ToString().Trim());

            WriteGroupCodeValue(11, UpperRightX.ToString().Trim());
            WriteGroupCodeValue(21, UpperRightY.ToString().Trim());

            WriteGroupCodeValue(12, CenterX.ToString().Trim());
            WriteGroupCodeValue(22, CenterY.ToString().Trim());

            WriteGroupCodeValue(13, SnapBaseX.ToString().Trim());
            WriteGroupCodeValue(23, SnapBaseY.ToString().Trim());

            WriteGroupCodeValue(14, SnapSpacingX.ToString().Trim());
            WriteGroupCodeValue(24, SnapSpacingY.ToString().Trim());

            WriteGroupCodeValue(15, GridSpacingX.ToString().Trim());
            WriteGroupCodeValue(25, GridSpacingY.ToString().Trim());

            WriteGroupCodeValue(16, ViewDirectionX.ToString().Trim());
            WriteGroupCodeValue(26, ViewDirectionY.ToString().Trim());
            WriteGroupCodeValue(36, ViewDirectionZ.ToString().Trim());

            WriteGroupCodeValue(17, ViewTargetX.ToString().Trim());
            WriteGroupCodeValue(27, ViewTargetY.ToString().Trim());
            WriteGroupCodeValue(37, ViewTargetZ.ToString().Trim());

            WriteGroupCodeValue(40, ViewHeight.ToString().Trim());

            WriteGroupCodeValue(41, ViewportAspectRatio.ToString().Trim());

            WriteGroupCodeValue(42, LensLength.ToString().Trim());

            WriteGroupCodeValue(43, FrontClippingPlaneOffset.ToString().Trim());
            WriteGroupCodeValue(44, BackClippingPlaneOffset.ToString().Trim());

            WriteGroupCodeValue(50, SnapRotationAngle.ToString().Trim());

            WriteGroupCodeValue(51, TwistAngle.ToString().Trim());

            WriteGroupCodeValue(70, GetStandardFlags().ToString().Trim());
        }
예제 #11
0
        //#region Temporary Field

        //private Point2D _tempTeoricaFinalPnt = null;
        //private Point2D _prevTeoricalPnt = null;

        //#endregion
        protected override void Reset()
        {
            // resetto i valori non UserInputed
            if (!X.IsUserInputed)
            {
                X.SetValue(false, null);
            }

            if (!DeltaX.IsUserInputed)
            {
                DeltaX.SetValue(false, null);
            }

            if (!Y.IsUserInputed)
            {
                Y.SetValue(false, null);
            }

            if (!DeltaY.IsUserInputed)
            {
                DeltaY.SetValue(false, null);
            }

            if (!CenterX.IsUserInputed)
            {
                CenterX.SetValue(false, null);
            }

            if (!CenterY.IsUserInputed)
            {
                CenterY.SetValue(false, null);
            }

            if (!Radius.IsUserInputed)
            {
                Radius.SetValue(false, null);
            }
        }
예제 #12
0
 public override int GetHashCode()
 {
     return(CenterX.GetHashCode() ^ CenterY.GetHashCode());
 }
예제 #13
0
 public override string ToString()
 {
     return(CenterX.ToString() + ", " + CenterY.ToString() + ", " + SizeX.ToString() + ", " + SizeY.ToString() + ", " +
            NodeIndex.ToString() + ", " + NodeCount.ToString() + ", " + Short7.ToString() + ", " + Short8.ToString() + ", " +
            FloatUtil.ToString(Float1) + ", " + Byte1.ToString() + ", " + Byte2.ToString() + ", " + Byte3.ToString() + ", " + Byte4.ToString());
 }
예제 #14
0
        //public override bool SetFinalX(double value)
        //{
        //    throw new NotImplementedException();
        //}

        //public override bool SetFinalY(double value)
        //{
        //    throw new NotImplementedException();
        //}

        internal override bool SolveElement()
        {
            Reset();
            // update direction enum
            // update isdefined.

            if (Profile == null)
            {
                return(false);
            }

            double?endX = null;
            double?endY = null;

            var prevMove = Profile.GetPrev(this);

            double?prevX = null, prevY = null;


            if (prevMove != null)
            {
                endY = prevY = prevMove.GetFinalY();
                endX = prevX = prevMove.GetFinalX();
            }

            /*
             * Definisco punto finale.
             */
            if (X.IsUserInputed && X.Value.HasValue)
            {
                endX = X.Value.Value;
            }
            else
            {
                if (DeltaX.IsUserInputed && DeltaX.Value.HasValue)
                {
                    if (prevX != null)
                    {
                        endX = DeltaX.Value.Value + prevX;

                        X.SetValue(false, endX);
                    }
                }

                else if (endX != null)
                {
                    X.SetValue(false, endX);
                }
            }

            if (Y.IsUserInputed && Y.Value.HasValue)
            {
                endY = Y.Value.Value;
            }
            else
            {
                if (DeltaY.IsUserInputed && DeltaY.Value.HasValue)
                {
                    if (prevY != null)
                    {
                        endY = DeltaY.Value.Value + prevY;
                        Y.SetValue(false, endY);
                    }
                }

                else if (endY != null)
                {
                    Y.SetValue(false, endY);
                }
            }

            if (endX.HasValue && endY.HasValue)
            {
                _endPnt = new Point2D(endX.Value, endY.Value);
            }
            else
            {
                _endPnt = null;
            }


            if (prevX.HasValue && prevY.HasValue)
            {
                _prevTeoricalPnt = new Point2D(prevX.Value, prevY.Value);
            }
            else
            {
                _prevTeoricalPnt = null;
            }

            /* Fino qui ho punto iniziale e punto finale ,
            *   continuo con la definizione dell'elemento ..*/
            /*
             * Definito punto finale posso avere :
             *  1 ) raggio e non centro definito
             *  2 )centro e non raggio definito
             *  3) centro x non cy e raggio
             *  4) centro y non cx e raggio ""
             *  5)raggio e centro (probabile overdefined )
             */
            if (_endPnt != null && _prevTeoricalPnt != null && !_endPnt.Equals(_prevTeoricalPnt))
            {
                // 1 ) raggio e non centro definito
                if (!CenterX.Value.HasValue && !CenterY.Value.HasValue && Radius.Value.HasValue)
                {
                    var center = GeometryHelper.GetCenterFromTwoPointsAndRadius(_prevTeoricalPnt, _endPnt, Radius.Value.Value,
                                                                                AlternateArc);

                    CenterX.SetValue(false, center.X);
                    CenterY.SetValue(false, center.Y);
                }

                // 2) centro definito e non raggio definito
                else if (CenterX.Value.HasValue && CenterY.Value.HasValue && !Radius.Value.HasValue)
                {
                    var raggio = GeometryHelper.Distance(new Point2D(CenterX.Value.Value, CenterY.Value.Value), _endPnt);
                    if (raggio != null)
                    {
                        Radius.SetValue(false, raggio.Value);
                    }
                }
                // *  3) centro x non cy e raggio
                else if (CenterX.Value.HasValue && !CenterY.Value.HasValue && Radius.Value.HasValue)
                {
                    /* Qui provo a cambiare alternate arc , ovvero se ho una quota ( x o y ) del centro del arco prendo il valore di alternate arc che coincide */

                    var center1 = GeometryHelper.GetCenterFromTwoPointsAndRadius(_prevTeoricalPnt, _endPnt, Radius.Value.Value,
                                                                                 false);

                    var center2 = GeometryHelper.GetCenterFromTwoPointsAndRadius(_prevTeoricalPnt, _endPnt, Radius.Value.Value,
                                                                                 true);

                    if (center1.X == CenterX.Value.Value)
                    {
                        AlternateArc = false;

                        CenterY.SetValue(false, center1.Y);
                    }
                    else if (center2.X == CenterX.Value.Value)
                    {
                        AlternateArc = true;

                        CenterY.SetValue(false, center2.Y);
                    }
                }

                // *  4) centro y non cx e raggio ""
                else if (!CenterX.Value.HasValue && CenterY.Value.HasValue && Radius.Value.HasValue)
                {
                    /* Qui provo a cambiare alternate arc , ovvero se ho una quota ( x o y ) del centro del arco prendo il valore di alternate arc che coincide */

                    var center1 = GeometryHelper.GetCenterFromTwoPointsAndRadius(_prevTeoricalPnt, _endPnt, Radius.Value.Value,
                                                                                 false);

                    var center2 = GeometryHelper.GetCenterFromTwoPointsAndRadius(_prevTeoricalPnt, _endPnt, Radius.Value.Value,
                                                                                 true);

                    if (center1.Y == CenterY.Value.Value)
                    {
                        AlternateArc = false;

                        CenterX.SetValue(false, center1.X);
                    }
                    else if (center2.Y == CenterY.Value.Value)
                    {
                        AlternateArc = true;

                        CenterX.SetValue(false, center2.X);
                    }
                }
            }

            /*
             * Ora al termine della definizione dell'elemento se ho tutti i dati necessari lo setto come definito , altrimento non è definito
             */
            if (Radius.Value.HasValue && CenterX.Value.HasValue && CenterY.Value.HasValue && X.Value.HasValue && Y.Value.HasValue)
            {
                var valoreRaggioCorretto = GeometryHelper.ValutateRadiusCorrectness(Radius.Value.Value,
                                                                                    CenterX.Value.Value,
                                                                                    CenterY.Value.Value,
                                                                                    X.Value.Value,
                                                                                    Y.Value.Value);
                if (valoreRaggioCorretto)
                {
                    IsDefined = true;
                }
                else
                {
                    IsDefined = false;
                }
            }
            else
            {
                IsDefined = false;
            }

            /*
             * Per essere definito devo avere raggio (corretto ), centro, Piniziale e Pfinale
             */
            /*
             * Controllo se arco è definito o meno
             * Devo avere
             * - raggio
             * - centro
             * - punto Iniziale
             * - punto finale
             */



            UpdateGeometry();
            // todo : implementare raggio, se raggio non è diametro corretto non definire.


            return(IsDefined);
        }
예제 #15
0
 public override void Draw(Graphics g, PictureBoxScale scale)
 {
     if (IsComplete())
     {
         Pen  pen    = new Pen(mColor);
         long radius = Radius.ValueAsLong();
         g.DrawEllipse(pen, ((CenterX.ValueAsLong() - radius) * scale.XScale) + scale.XOffset, ((CenterY.ValueAsLong() - radius) * scale.YScale) + scale.YOffset, 2 * radius * scale.XScale, 2 * radius * scale.YScale);
         pen.Dispose();
     }
 }
예제 #16
0
 public string ToString(string format, IFormatProvider provider)
 {
     return($"CenterX={CenterX.ToString(format, provider)} CenterY={CenterY.ToString(format, provider)} RadiusX={RadiusX.ToString(format, provider)} RadiusY={RadiusY.ToString(format, provider)}");
 }
예제 #17
0
 /// <summary>
 /// Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return('(' + CenterX.ToString() + ',' + CenterY.ToString() + ';' + Radius.ToString() + ')');
 }
예제 #18
0
 public bool Equals(Circle other)
 {
     return(CenterX.Equals(other.CenterX) && CenterY.Equals(other.CenterY) && Radius.Equals(other.Radius));
 }
예제 #19
0
파일: SvgRotate.cs 프로젝트: xprl-gjf/SVG
 public override string WriteToString()
 {
     return($"rotate({Angle.ToSvgString()}, {CenterX.ToSvgString()}, {CenterY.ToSvgString()})");
 }