Exemple #1
0
        private bool IsWithinVisibilityRange(AxisInfo axis, int distance)
        {
            int rangeMin = axis.RangeMin + m_diffCachedVisibleRange;
            int rangeMax = axis.RangeMax - m_diffCachedVisibleRange;

            return(distance >= rangeMin && distance <= rangeMax);
        }
Exemple #2
0
        public AxisInfo[] GetAxisInfo()
        {
            Type type = this.GetType();

            System.Reflection.PropertyInfo[] pis = type.GetProperties();
            List <AxisInfo> infos = new List <AxisInfo>();

            string sComponentOrder = type.Name.ToUpper().Replace("COLOR", "");

            foreach (System.Reflection.PropertyInfo pi in pis)
            {
                object[] cust = pi.GetCustomAttributes(true);

                AxisInfo info  = new AxisInfo();
                bool     addIt = false;
                foreach (object attr in cust)
                {
                    if (attr is System.ComponentModel.CategoryAttribute)
                    {
                        if (((System.ComponentModel.CategoryAttribute)attr).Category == "Axis")
                        {
                            info.Ordinal      = sComponentOrder.IndexOf(pi.Name.ToUpper());
                            info.Name         = pi.Name;
                            info.PropertyInfo = pi;
                            addIt             = true;
                        }
                    }
                    else if (attr is System.ComponentModel.DefaultValueAttribute)
                    {
                        info.Min = 0;
                        info.Max = Convert.ToSingle(((System.ComponentModel.DefaultValueAttribute)attr).Value);
                    }
                    else if (attr is ColorInfoAttribute)
                    {
                        ColorInfoAttribute ciattr = (ColorInfoAttribute)attr;
                        info.Min    = ciattr.MinValue;
                        info.Max    = ciattr.MaxValue;
                        info.UIMin  = ciattr.UIMinValue;
                        info.UIMax  = ciattr.UIMaxValue;
                        info.UIName = ciattr.Name;
                    }
                }

                if (addIt)
                {
                    infos.Add(info);
                }
            }

            AxisInfo[] result = new AxisInfo[infos.Count];
            int        i      = 0;

            foreach (AxisInfo info in infos)
            {
                result[info.Ordinal] = info;
                i++;
            }

            return(result);
        }
        /// <summary>
        /// 加载数据
        /// </summary>
        protected override async void OnViewLoaded(bool isFirstLoaded)
        {
            base.OnViewLoaded(isFirstLoaded);
            IsBusy = true;
            _axisInfos.Clear();
            _spaceLevels.Clear();
            var records = await _axisData.GetAllAxisAsync();

            foreach (var record in records)
            {
                var axisInfo = new AxisInfo(record);
                _axisInfos.Add(axisInfo);
            }
            var spaceLevels = new List <LevelInfo>();
            var recordList  = await _axisData.GetAllLevelAsync();

            foreach (var record in recordList)
            {
                var levelInfo = new LevelInfo(record)
                {
                    AxisData = _axisData
                };
                spaceLevels.Add(levelInfo);
            }
            spaceLevels = spaceLevels.OrderByDescending(t => t.StartElevation).ToList();
            _spaceLevels.AddRange(spaceLevels);
            WeakEventManager <AxisData, StatusChangedEventArgs> .AddHandler(_axisData, "AxisRecordStatusChanged",
                                                                            OnAxisRecordStatusChanged);

            WeakEventManager <AxisData, StatusChangedEventArgs> .AddHandler(_axisData, "LevelRecordStatusChanged",
                                                                            OnLevelRecordStatusChanged);

            IsBusy = false;
        }
 private void OnAxisRecordStatusChanged(object sender, StatusChangedEventArgs e)
 {
     if (e == null)
     {
         return;
     }
     if (e.Action == StatusChangedAction.Added)
     {
         var records  = e.Records;
         var existIds = _axisInfos.Select(t => t.Id).ToList();
         for (var i = 0; i < records.Count; i++)
         {
             var record = records[i];
             if (!existIds.Contains((int)record[Axis.ColId]))
             {
                 var axisInfo = new AxisInfo(record);
                 _axisInfos.Add(axisInfo);
             }
         }
     }
     else if (e.Action == StatusChangedAction.Deleted)
     {
         var delItems = _axisInfos.Where(t => e.Records.Contains(t.AxisRecord)).ToList();
         delItems.ForEach(t => _axisInfos.Remove(t));
     }
     else if (e.Action == StatusChangedAction.Reset)
     {
         AxisInfos.Clear();
     }
 }
Exemple #5
0
 private void UpdateDebugAxes()
 {
     // Debug info
     if (debug)
     {
         // Show debug vectors for this part itselft
         if (axisAttachNode == null)
         {
             axisAttachNode = new AxisInfo(part.transform);
         }
         if (axisWorld == null)
         {
             axisWorld = new AxisInfo(null);
         }
     }
     else
     {
         if (axisAttachNode != null)
         {
             axisAttachNode = null;
         }
         if (axisWorld != null)
         {
             axisWorld = null;
         }
     }
 }
Exemple #6
0
 private void AddGridLines(AxisInfo axis)
 {
     for (double n = axis.First; n <= axis.Last; n += axis.Delta)
     {
         byte lightness     = (byte)(Math.Round(n, 1) == 0 ? 150 : 240);
         var  gridLineColor = new SolidColorBrush(Color.FromRgb(lightness, lightness, lightness));
         var  p             = PointToCanvas(0, n, ViewRegion);
         AddLine(0, p.Y, ParentChart.AvailableWidth, p.Y, gridLineColor);
     }
 }
Exemple #7
0
    protected bool GetAxisDown(AxisInfo axis)
    {
        if (axis.State == AxisState.Down)
        {
            axis.Take();
            return(true);
        }

        return(false);
    }
		AxisInfo(AxisInfo old)
		{
			HideEmpty = old.HideEmpty;
			if (old.MeasuresSort != null)
				MeasuresSort = old.MeasuresSort.Clone();

			foreach (var cont in old.Actions)
			{
				Actions.Add(cont.Clone());
			}
		}
Exemple #9
0
    public Xbox360Input(int joypadId)
    {
        JoypadId  = joypadId;
        Threshold = 0.2f;

        LeftStickYInfo   = new AxisInfo(string.Format("360LeftStickY_{0}", JoypadId), true);
        LeftStickXInfo   = new AxisInfo(string.Format("360LeftStickX_{0}", JoypadId));
        DPadYInfo        = new AxisInfo(string.Format("360DPadY_{0}", JoypadId));
        DPadXInfo        = new AxisInfo(string.Format("360DPadX_{0}", JoypadId));
        RightTriggerInfo = new AxisInfo(string.Format("360RightTrigger_{0}", JoypadId));
    }
        void SetCircles(AxisInfo axisInfo, AxisVectors axisVectors)
        {
            axisVectors.Clear();

            if (type == TransformType.Rotate)
            {
                float circleLength = handleLength * GetDistanceMultiplier();
                AddCircle(_target.position, axisInfo.xDirection, circleLength, axisVectors.x);
                AddCircle(_target.position, axisInfo.yDirection, circleLength, axisVectors.y);
                AddCircle(_target.position, axisInfo.zDirection, circleLength, axisVectors.z);
                AddCircle(_target.position, (_target.position - transform.position).normalized, circleLength, axisVectors.all, false);
            }
        }
        private static IAxisInfo ReadAxisInfo(WktStreamTokenizer tokenizer)
        {
            //AXIS["Geodetic longitude","EAST"]
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            string orientationString = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken("]");
            AxisOrientation orientation = (AxisOrientation)Enum.Parse(typeof(AxisOrientation), orientationString, true);
            IAxisInfo       axis        = new AxisInfo(name, orientation);

            return(axis);
        }
Exemple #12
0
        /// <summary>
        /// Return the title info split by the ";" to remove axis info.
        /// </summary>
        /// <param name="htitle"></param>
        /// <returns></returns>
        internal static AxisInfo ExtractHistoTitleInfo(this string htitle)
        {
            var info = new AxisInfo()
            {
                Title = htitle, AxisTitle = ""
            };
            var semi = htitle.IndexOf(";");

            if (semi >= 0)
            {
                info.Title     = htitle.Substring(0, semi).Trim();
                info.AxisTitle = htitle.Substring(semi + 1).Trim();
            }
            return(info);
        }
Exemple #13
0
        private static IAxisInfo ReadAxisInfo(XmlTextReader reader)
        {
            //<IAxisInfo Name="Up" Orientation="UP"/>

            if (!(reader.NodeType == XmlNodeType.Element || reader.Name == "CS_Info"))
            {
                throw new ParseException(String.Format("Expected a IInfo but got a {0} at line {1} col {2}", reader.Name, reader.LineNumber, reader.LinePosition));
            }

            string          orientationString = reader.GetAttribute("Orientation");
            AxisOrientation orientation       = (AxisOrientation)Enum.Parse(typeof(AxisOrientation), orientationString, true);
            IAxisInfo       axis = new AxisInfo(reader.GetAttribute("Name"), orientation);

            return(axis);
        }
Exemple #14
0
        private void InitAxis(int axis, int forceLOD, float coefLOD)
        {
            AxisInfo axisInfo = axes[axis];

            for (int distance = axisInfo.rangeMin; distance <= axisInfo.rangeMax; distance++)
            {
                int  lod = DetermineLOD(distance, forceLOD, coefLOD);
                bool isInVisibilityRange = IsInVisibilityRange(axisInfo, distance);

                axisInfo.map[distance + VisibleRange] = new ClipmapItem
                {
                    lod = lod,
                    isInVisibleRange = isInVisibilityRange
                };
            }
        }
Exemple #15
0
        public static short initBoard()//初始化办卡  返回值:-1:没有卡号   0:正常
        {
            short m = RFIDControl.dmc_board_init();

            if (m <= 0)  //控制卡的初始化操作
            {
                //未找到控制卡
                Console.WriteLine("未找到控制卡");
                return(-1);
            }
            for (int i = 0; i < AXIS_NUM; ++i)
            {
                mAxis[i]                  = new AxisInfo();
                mAxis[i].m_card_num       = 0;
                mAxis[i].m_axis_num       = (ushort)i;
                mAxis[i].m_home_mode      = 1; //一次回零加回找
                mAxis[i].m_home_flag      = 0;
                mAxis[i].m_acc_time       = 0.4;
                mAxis[i].m_dcc_time       = 0.4;
                mAxis[i].m_home_dir       = MoveDir.FOR_WORD;
                mAxis[i].m_speed_max      = 10000; //dispenser_para.motor_speed;
                mAxis[i].m_speed_max_home = 2000;  //dispenser_para.go_home_speed;
                mAxis[i].m_pulse_mode     = 3;
                mAxis[i].m_speed_min      = 0;
                mAxis[i].m_speed_min_home = 0;
                mAxis[i].m_run_status     = STOP;//停止状态
                if (i < 2)
                {
                    RFIDControl.dmc_set_inp_mode(mAxis[i].m_card_num, mAxis[i].m_axis_num, HIGH, LOW);
                    RFIDControl.dmc_set_alm_mode(mAxis[i].m_card_num, mAxis[i].m_axis_num, HIGH, HIGH, 0); //设置 伺服ALM 高电平有效   松下伺服正常情况下输出低电平
                    RFIDControl.dmc_set_counter_inmode(mAxis[i].m_card_num, mAxis[i].m_axis_num, 1);       //设置编码器的计数方式   1倍频
                    RFIDControl.dmc_set_encoder(mAxis[i].m_card_num, mAxis[i].m_axis_num, 0);              //设置初始值为0
                }
            }

            //两轴查补
            mInpterplaType.axis_cout   = 2;                     //2个轴查补
            mInpterplaType.car_num     = 0;                     //坐标系号
            mInpterplaType.card_num    = 0;                     //卡号
            mInpterplaType.line_type   = 0;                     //线型
            mInpterplaType.posi_mode   = PositionMode.ABS_MODE; //位置模式
            mInpterplaType.m_acc_time  = 3;
            mInpterplaType.m_dcc_time  = 3;
            mInpterplaType.m_speed_max = X_AXIS_MAX_SPEED;
            mInpterplaType.arc_dir     = CCW;
            return(0);
        }
Exemple #16
0
        void OnPostRender()
        {
            if (isEnabled)
            {
                if (target == null)
                {
                    return;
                }

                lineMaterial.SetPass(0);

                Color xColor   = (selectedAxis == Axis.X) ? selectedColor : this.xColor;
                Color yColor   = (selectedAxis == Axis.Y) ? selectedColor : this.yColor;
                Color zColor   = (selectedAxis == Axis.Z) ? selectedColor : this.zColor;
                Color allColor = (selectedAxis == Axis.Any) ? selectedColor : this.allColor;

                DrawLines(handleLines.x, xColor);
                DrawLines(handleLines.y, yColor);
                DrawLines(handleLines.z, zColor);

                DrawTriangles(handleTriangles.x, xColor);
                DrawTriangles(handleTriangles.y, yColor);
                DrawTriangles(handleTriangles.z, zColor);

                DrawSquares(handleSquares.x, xColor);
                DrawSquares(handleSquares.y, yColor);
                DrawSquares(handleSquares.z, zColor);
                DrawSquares(handleSquares.all, allColor);

                AxisVectors rotationAxisVector = circlesLines;
                if (isTransforming && space == TransformSpace.Global && type == TransformType.Rotate)
                {
                    rotationAxisVector = drawCurrentCirclesLines;

                    AxisInfo axisInfo = new AxisInfo();
                    axisInfo.xDirection = totalRotationAmount * Vector3.right;
                    axisInfo.yDirection = totalRotationAmount * Vector3.up;
                    axisInfo.zDirection = totalRotationAmount * Vector3.forward;
                    SetCircles(axisInfo, drawCurrentCirclesLines);
                }

                DrawCircles(rotationAxisVector.x, xColor);
                DrawCircles(rotationAxisVector.y, yColor);
                DrawCircles(rotationAxisVector.z, zColor);
                DrawCircles(rotationAxisVector.all, allColor);
            }
        }
Exemple #17
0
        private IAxisBandInfo GetAxisBandInfo(IAxis axis, Point hitTestPt, out AxisInfo axisInfo)
        {
            IAxisBandInfo bandInfo = null;

            axisInfo = null;

            if (axis is AxisBase axisBase &&
                axisBase.AxisBandsProvider is IAxisBandsProviderBase bandsProvider)
            {
                axisInfo = axis.HitTest(hitTestPt);
                var res = axisInfo.DataValue;

                bandInfo = bandsProvider.AxisBands.FirstOrDefault(bi =>
                                                                  bi.BandRange.Min.CompareTo(res) <= 0 && bi.BandRange.Max.CompareTo(res) >= 0);
            }

            return(bandInfo);
        }
Exemple #18
0
        void AddVerticalAxis(AxisInfo axis)
        {
            var    axisColor  = Brushes.Black;
            double xOffset    = ParentChart.AvailableWidth;
            double tickOffset = xOffset + 1;
            double edgeOffset = xOffset + 5;
            double textOffset = xOffset + 7;

            AddLine(edgeOffset, 0, edgeOffset, GraphCanvas.ActualHeight, axisColor);
            for (double n = axis.First; n <= axis.Last; n += axis.Delta)
            {
                var p = PointToCanvas(0, n, ViewRegion);
                AddLine(tickOffset, p.Y, edgeOffset, p.Y, axisColor);

                var textY  = p.Y - 7.5;
                var weight = n == 0 ? "bold" : "normal";
                AddText(Humanize(n, axis.RoundingPower), textOffset, textY, weight, 10);
            }
        }
Exemple #19
0
        public static short singleAxisMove(ref AxisInfo axisInfo, long pos, ushort positionMode)
        {
            short m = 0;

            if (axisInfo.m_run_status == RUN)
            {
                return(-1);
            }
            RFIDControl.dmc_set_pulse_outmode(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_pulse_mode);

            RFIDControl.dmc_set_profile(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_speed_min, axisInfo.m_speed_max, axisInfo.m_acc_time, axisInfo.m_dcc_time, 100);
            //设定S段时间
            RFIDControl.dmc_set_s_profile(axisInfo.m_card_num, axisInfo.m_axis_num, 0, 0.4);
            m = RFIDControl.dmc_pmove(axisInfo.m_card_num, axisInfo.m_axis_num, pos, positionMode);

            checkDmcMessage(m);
            axisInfo.m_run_status = RUN;
            return(m);
        }
Exemple #20
0
        public void Test_Constructor()
        {
            ICoordinateSystemFactory csFactory   = new CoordinateSystemFactory();
            IAngularUnit             angularUnit = new AngularUnit(1);
            ILinearUnit         linearUnit       = new LinearUnit(1);
            IEllipsoid          ellipsoid        = csFactory.CreateFlattenedSphere("test", 1, 2, linearUnit);
            IAxisInfo           axis0            = new AxisInfo("axis0name", AxisOrientation.Up);
            IAxisInfo           axis1            = new AxisInfo("axis1name", AxisOrientation.Up);
            WGS84ConversionInfo wgs = new WGS84ConversionInfo();

            IPrimeMeridian              primeMeridian   = csFactory.CreatePrimeMeridian("name", angularUnit, 2.0);
            IHorizontalDatum            horizontalDatum = csFactory.CreateHorizontalDatum("datum", DatumType.IHD_Geocentric, ellipsoid, wgs);
            IGeographicCoordinateSystem gcs             = csFactory.CreateGeographicCoordinateSystem("name", angularUnit, horizontalDatum, primeMeridian, axis0, axis1);

            //PrimeMeridian primeMeridian = new PrimeMeridian("name", angularUnit, 0.5);
            IAxisInfo[] axisArray = new IAxisInfo[2];
            axisArray[0] = axis0;
            axisArray[1] = axis1;

            ProjectionParameter[] paramList = new ProjectionParameter[1];
            paramList[0].Name  = "test";
            paramList[0].Value = 2.2;

            Projection projection = new Projection("mercator", paramList, "class", "remarks", "authority", "authoritycode");

            ProjectedCoordinateSystem pjc = new ProjectedCoordinateSystem(horizontalDatum,
                                                                          axisArray, gcs, linearUnit, projection,
                                                                          "remarks", "authority", "authorityCode", "name", "alias", "abbreviation");

            Assertion.AssertEquals("Test 1", linearUnit, pjc.LinearUnit);
            Assertion.AssertEquals("Test 2", horizontalDatum, pjc.HorizontalDatum);
            Assertion.AssertEquals("Test 3", axis0, pjc.GetAxis(0));
            Assertion.AssertEquals("Test 4", axis1, pjc.GetAxis(1));
            Assertion.AssertEquals("Test 5", gcs, pjc.GeographicCoordinateSystem);

            Assertion.AssertEquals("Test 6", "abbreviation", pjc.Abbreviation);
            Assertion.AssertEquals("Test 7", "alias", pjc.Alias);
            Assertion.AssertEquals("Test 8", "authority", pjc.Authority);
            Assertion.AssertEquals("Test 9", "authorityCode", pjc.AuthorityCode);
            Assertion.AssertEquals("Test 10", "name", pjc.Name);
            Assertion.AssertEquals("Test 11", "remarks", pjc.Remarks);
        }
Exemple #21
0
        private static Dictionary <string, AxisInfo> MakeAxisOptions(PlotConfig plot)
        {
            var res = new Dictionary <string, AxisInfo>();

            res["y"] = new AxisInfo()
            {
                independentTicks = true,
                drawGrid         = true,
                includeZero      = plot.LeftAxisStartFromZero,
                gridLinePattern  = null
            };
            res["y2"] = new AxisInfo()
            {
                independentTicks = true,
                drawGrid         = true,
                includeZero      = plot.RightAxisStartFromZero,
                gridLinePattern  = new int[] { 2, 2 }
            };
            return(res);
        }
Exemple #22
0
        private void Awake()
        {
            _controlCount = InputButtons.Length;
            _buttons = new string[_controlCount];
            _axes = new AxisInfo[_controlCount];
            
            for (var i = 0; i < _controlCount; i++)
            {
                if (!string.IsNullOrEmpty(InputButtons[i]))
                {
                    _buttons[i] = string.Concat(ButtonPrefix, InputButtons[i]);
                }

                if (InputAxes[i] != null && !string.IsNullOrEmpty(InputAxes[i].Name))
                {
                    var axisName = string.Concat(AxisPrefix, InputAxes[i].Name);
                    _axes[i] = new AxisInfo(axisName, InputAxes[i].Positive);
                }
            }
        }
Exemple #23
0
        public void Test_Constructor()
        {
            ICoordinateSystemFactory csFactory   = new CoordinateSystemFactory();
            IAngularUnit             angularUnit = new AngularUnit(1);
            ILinearUnit         linearUnit       = new LinearUnit(1);
            IEllipsoid          ellipsoid        = csFactory.CreateFlattenedSphere("test", 1, 2, linearUnit);
            IAxisInfo           axis0            = new AxisInfo("axis0name", AxisOrientation.Up);
            IAxisInfo           axis1            = new AxisInfo("axis1name", AxisOrientation.Up);
            WGS84ConversionInfo wgs = new WGS84ConversionInfo();

            IPrimeMeridian              primeMeridian   = csFactory.CreatePrimeMeridian("name", angularUnit, 2.0);
            IHorizontalDatum            horizontalDatum = csFactory.CreateHorizontalDatum("datum", DatumType.IHD_Geocentric, ellipsoid, wgs);
            IGeographicCoordinateSystem gcs             = csFactory.CreateGeographicCoordinateSystem("name", angularUnit, horizontalDatum, primeMeridian, axis0, axis1);

            Assertion.AssertEquals("ctor 1", "name", gcs.Name);
            Assertion.AssertEquals("ctor 2", angularUnit, gcs.AngularUnit);
            Assertion.AssertEquals("ctor 3", horizontalDatum, gcs.HorizontalDatum);
            Assertion.AssertEquals("ctor 4", primeMeridian, gcs.PrimeMeridian);
            Assertion.AssertEquals("ctor 5", axis0, gcs.GetAxis(0));
            Assertion.AssertEquals("ctor 5", axis1, gcs.GetAxis(1));
        }
Exemple #24
0
        private IProjectedCoordinateSystem createExpectedCoordinateSystem()
        {
            ICoordinateSystemFactory factory = new CoordinateSystemFactory <BufferedCoordinate2D>(
                _geoFactory.CoordinateFactory, _geoFactory);

            IEllipsoid grs80 = Ellipsoid.Grs80;

            IHorizontalDatum harn = factory.CreateHorizontalDatum(
                DatumType.HorizontalGeocentric, grs80, null,
                "D_North_American_1983_HARN");

            IPrimeMeridian greenwich = PrimeMeridian.Greenwich;

            IAxisInfo axis0 = new AxisInfo(AxisOrientation.East, "Lon");
            IAxisInfo axis1 = new AxisInfo(AxisOrientation.North, "Lat");

            // Made the first parameter - the IExtents - null, which should be improved
            IGeographicCoordinateSystem gcs = factory.CreateGeographicCoordinateSystem(null,
                                                                                       AngularUnit.Degrees, harn, greenwich, axis0, axis1, "GCS_North_American_1983_HARN");

            IProjection prj = factory.CreateProjection(
                "Lambert_Conformal_Conic",
                new ProjectionParameter[]
            {
                new ProjectionParameter("False_Easting", 8202099.737532808),
                new ProjectionParameter("False_Northing", 0),
                new ProjectionParameter("Central_Meridian", -120.5),
                new ProjectionParameter("Standard_Parallel_1", 44.33333333333334),
                new ProjectionParameter("Standard_Parallel_2", 46.0),
                new ProjectionParameter("Latitude_Of_Origin", 43.66666666666666)
            },
                "Lambert_Conformal_Conic");

            IProjectedCoordinateSystem expected = factory.CreateProjectedCoordinateSystem(
                gcs, prj, LinearUnit.Foot, axis0, axis1, "NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601");

            // TODO: Check if this is correct, since on line 184 of CoorindateSystemFactory.cs,
            // HorizontalDatum is passed in as null
            return(expected);
        }
Exemple #25
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(value);
            }

            AxisInfo      axis     = (AxisInfo)value;
            AxisAlignment aligment = axis.AxisAlignment;

            if (aligment == AxisAlignment.Right)
            {
                return(axis.AxisFormattedDataValue);
            }
            else if (aligment == AxisAlignment.Left)
            {
                return(axis.AxisFormattedDataValue);
            }

            Type type = axis.DataValue.GetType();

            if (type.Name.Equals("DateTime"))
            {
                DateTime t = (DateTime)axis.DataValue;

                String formatedT = string.Format("{0:yyyy-MM-dd HH:mm}", t).ToString();
                return(formatedT);
            }
            else if (type.Name.Equals("Double"))
            {
                Double t         = (Double)axis.DataValue;
                Double formatedT = ((int)(t * 10000)) / 10000.0;
                return(formatedT);
            }

            return(axis.DataValue);
        }
Exemple #26
0
        public AxisInfo[] GetAxisInfo()
        {
            Type type = this.GetType();
            System.Reflection.PropertyInfo[] pis = type.GetProperties();
            List<AxisInfo> infos = new List<AxisInfo>();

            string sComponentOrder = type.Name.ToUpper().Replace("COLOR", "");

            foreach (System.Reflection.PropertyInfo pi in pis)
            {
                object[] cust = pi.GetCustomAttributes(true);

                AxisInfo info = new AxisInfo();
                bool addIt = false;
                foreach (object attr in cust)
                {
                    if (attr is System.ComponentModel.CategoryAttribute)
                    {
                        if (((System.ComponentModel.CategoryAttribute)attr).Category == "Axis")
                        {
                            info.Ordinal = sComponentOrder.IndexOf(pi.Name.ToUpper());
                            info.Name = pi.Name;
                            info.PropertyInfo = pi;
                            addIt = true;
                        }
                    }
                    else if (attr is System.ComponentModel.DefaultValueAttribute)
                    {
                        info.Min = 0;
                        info.Max = Convert.ToSingle(((System.ComponentModel.DefaultValueAttribute)attr).Value);
                    }
                    else if (attr is ColorInfoAttribute)
                    {
                        ColorInfoAttribute ciattr = (ColorInfoAttribute)attr;
                        info.Min = ciattr.MinValue;
                        info.Max = ciattr.MaxValue;
                        info.UIMin = ciattr.UIMinValue;
                        info.UIMax = ciattr.UIMaxValue;
                        info.UIName = ciattr.Name;
                    }
                }

                if (addIt)
                    infos.Add(info);
            }

            AxisInfo[] result = new AxisInfo[infos.Count];
            int i = 0;
            foreach (AxisInfo info in infos)
            {
                result[info.Ordinal] = info;
                i++;
            }

            return result;
        }
 // Methods
 public ProjectedCoordinateSystem(string name, string authority, string authorityCode, string alias, string info, GeographicCoordinateSystem gcs, IProjection projection, ILinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1) => throw null;
        public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string code)
        {
            var consulta = from geodeticCRS in GIGSDataSet.geodeticCRS
                           where geodeticCRS.Code == int.Parse(code)
                           select geodeticCRS;

            if (0 == consulta.Count())
                throw new ArgumentException(string.Format("No existe ningún sistema de coordenadas geográfico con el código {0}", code));

            var crs = consulta.First();

            IHorizontalDatum datum = CreateHorizontalDatum(crs.DatumCode.ToString());
            int? códigoPrimeMeridian = GIGSDataSet.datum.GetPrimeMeridianCodeFromDatumCode(crs.DatumCode);
            if (null == códigoPrimeMeridian)
                return null;

            IPrimeMeridian primeMeridian = CreatePrimeMeridian(códigoPrimeMeridian.Value.ToString());

            AxisInfo axis0, axis1;

            if (crs.AxesChanged.HasValue && crs.AxesChanged.Value)
            {
                axis0 = new AxisInfo("Long", AxisOrientationEnum.East);
                axis1 = new AxisInfo("Lat", AxisOrientationEnum.North);
            }
            else
            {
                axis0 = new AxisInfo("Lat", AxisOrientationEnum.North);
                axis1 = new AxisInfo("Long", AxisOrientationEnum.East);
            }

#if DEFINE_GIGS_AS_AUTHORITY
            return new GeographicCoordinateSystem(
                crs.Name, 
                "GIGS",
                code,
                "",
                "",
                primeMeridian.AngularUnit, 
                datum, 
                primeMeridian, 
                axis0, 
                axis1);
#else
            return fábrica.CreateGeographicCoordinateSystem(crs.Name, primeMeridian.AngularUnit, datum, primeMeridian, axis0, axis1);
#endif
        }
Exemple #29
0
 private bool IsInVisibilityRange(AxisInfo axis, int distance)
 {
     return(distance >= axis.RangeMin && distance <= axis.RangeMax);
 }
        private IProjectedCoordinateSystem createExpectedCoordinateSystem()
        {
            ICoordinateSystemFactory factory = new CoordinateSystemFactory<BufferedCoordinate2D>(
                _geoFactory.CoordinateFactory, _geoFactory);

            IEllipsoid grs80 = Ellipsoid.Grs80;

            IHorizontalDatum harn = factory.CreateHorizontalDatum(
                DatumType.HorizontalGeocentric, grs80, null, 
                "D_North_American_1983_HARN");

            IPrimeMeridian greenwich = PrimeMeridian.Greenwich;

            IAxisInfo axis0 = new AxisInfo(AxisOrientation.East, "Lon");
            IAxisInfo axis1 = new AxisInfo(AxisOrientation.North, "Lat");

            // Made the first parameter - the IExtents - null, which should be improved
            IGeographicCoordinateSystem gcs = factory.CreateGeographicCoordinateSystem(null,
                AngularUnit.Degrees, harn, greenwich, axis0, axis1, "GCS_North_American_1983_HARN");

            IProjection prj = factory.CreateProjection(
                "Lambert_Conformal_Conic",
                new ProjectionParameter[]
                    {
                        new ProjectionParameter("False_Easting", 8202099.737532808),
                        new ProjectionParameter("False_Northing", 0),
                        new ProjectionParameter("Central_Meridian", -120.5),
                        new ProjectionParameter("Standard_Parallel_1", 44.33333333333334),
                        new ProjectionParameter("Standard_Parallel_2", 46.0),
                        new ProjectionParameter("Latitude_Of_Origin", 43.66666666666666)
                    },
                "Lambert_Conformal_Conic");

            IProjectedCoordinateSystem expected = factory.CreateProjectedCoordinateSystem(
                gcs, prj, LinearUnit.Foot, axis0, axis1, "NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601");

            // TODO: Check if this is correct, since on line 184 of CoorindateSystemFactory.cs, 
            // HorizontalDatum is passed in as null
            return expected;
        }
 void DrawAxis(AxisInfo info, Vector3 axis)
 {
     Gizmos.color = info;
     Gizmos.DrawLine(infoToDisplay.localPosition, infoToDisplay.localPosition + axis * info);
 }
 public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, IGeographicCoordinateSystem gcs,
                                                                   IProjection projection, ILinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1)
 {
     throw new NotImplementedException();
 }
 public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit,
                                                                     IHorizontalDatum datum, IPrimeMeridian primeMeridian, AxisInfo axis0, AxisInfo axis1)
 {
     throw new NotImplementedException();
 }
Exemple #34
0
 protected abstract AxisMapping convertAxisInfoToMapping(AxisInfo info);
		/// <summary>
		/// Creates a <see cref="ProjectedCoordinateSystem"/> using a projection object.
		/// </summary>
		/// <param name="name">Name of projected coordinate system</param>
		/// <param name="gcs">Geographic coordinate system</param>
		/// <param name="projection">Projection</param>
		/// <param name="linearUnit">Linear unit</param>
		/// <param name="axis0">Primary axis</param>
		/// <param name="axis1">Secondary axis</param>
		/// <returns>Projected coordinate system</returns>
		public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, IGeographicCoordinateSystem gcs, IProjection projection, ILinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1)
		{
			if (string.IsNullOrEmpty(name))
				throw new ArgumentException("Invalid name");
			if (gcs == null)
				throw new ArgumentException("Geographic coordinate system was null");
			if (projection == null)
				throw new ArgumentException("Projection was null");
			if (linearUnit == null)
				throw new ArgumentException("Linear unit was null");
			List<AxisInfo> info = new List<AxisInfo>(2);
			info.Add(axis0);
			info.Add(axis1);
			return new ProjectedCoordinateSystem(null, gcs, linearUnit, projection, info, name, String.Empty, -1, String.Empty, String.Empty, String.Empty);
		}
Exemple #36
0
        public void UpdateAttachments(State flightState, bool debug, bool debugPeriodic)
        {
            // If the is no actual part attached to the attach node, then we can bail out.
            // Part attachedPart = GetAttachedPart();

            if (debugPeriodic)
            {
                printf("UA: %s %s %s %s",
                       attachedPart != null ? attachedPart.name : null,
                       nodeType,
                       stackAttachNode != null ? stackAttachNode.id : "null",
                       stackAttachNode != null ? stackAttachNode.attachedPartId.ToString() : "null");
            }

            // We don't want to mess with the joint attaching this part to its parent.
            // Also, take of the special case where they are both null, otherwise we
            // will incorrectly get a match between them, resulting in loss of function
            // if the animated part is the root part.
            if ((attachedPart == animatedAttachment.part.parent) &&
                (attachedPart != null))
            {
                if (debugPeriodic)
                {
                    printf("Skipping parent");
                }

                return;
            }

            switch (nodeType)
            {
            case AttachNode.NodeType.Surface:
                if (collider == null)
                {
                    SetCollider();

                    if (debug)
                    {
                        printf("Setting collider to %s",
                               collider.name);
                    }
                }
                break;

            case AttachNode.NodeType.Stack:
                if (stackAttachNode == null)
                {
                    stackAttachNode = animatedAttachment.part.FindAttachNodeByPart(attachedPart);

                    // Sometimes life throws lemons at you, like when the user actvated attachments in flight
                    if (stackAttachNode == null)
                    {
                        // Try again as surface attached
                        nodeType = AttachNode.NodeType.Surface;
                        return;
                    }

                    if (debug)
                    {
                        printf("Setting attach node to %s",
                               stackAttachNode.id);
                    }
                }
                break;
            }

            Transform referenceTransform = GetReferenceTransform();

            // If this attach node is defined in the cfg, then bail out now, it will not be movable
            if (referenceTransform == null)
            {
                if (debugPeriodic)
                {
                    printf("Skipping cfg based node: %s", stackAttachNode.id);
                }
                return;
            }

            // Get the position and rotation of the node transform relative to the part.
            // The nodeTransform itself will only contain its positions and rotation
            // relative to the immediate parent in the model
            PosRot referencePosRot = PosRot.GetPosRot(referenceTransform, animatedAttachment.part);

            // We can't animate decoupling shrouds
            if (referencePosRot == null)
            {
                if (debugPeriodic)
                {
                    printf("Skipping decoupler shroud");
                }
                return;
            }

            bool active = animatedAttachment.activated;

            if (EditorLogic.fetch && (EditorLogic.fetch.EditorConstructionMode != ConstructionMode.Place))
            {
                active = false;
            }

            // Take note of newly attached parts, including at initial ship load
            if (attachedPart == null || !active)
            {
                if (debugPeriodic)
                {
                    if (attachedPart == null)
                    {
                        printf("No part attached");
                    }
                }

                attachedPartOffset = null;
                return;
            }

            if (attachedPartOffset == null || attachedPartOriginal == null)
            {
                // Get attached part position relative to this part
                PosRot localPosRot = new PosRot();

                Transform parent = attachedPart.transform.parent;

                // Let the engine calculate the local position instead of doing the calculation ourselves..
                attachedPart.transform.parent = animatedAttachment.part.transform;
                localPosRot.position          = attachedPart.transform.localPosition;
                localPosRot.rotation          = attachedPart.transform.localRotation;
                attachedPart.transform.parent = parent;

                // We could do parenting trick for this too, but seems we loose the scaling
                if (attachedPartOffset == null)
                {
                    printf("Recording attachedPartOffset");

                    attachedPartOffset = new PosRot();

                    attachedPartOffset.rotation =
                        referencePosRot.rotation.Inverse() *
                        localPosRot.rotation;

                    attachedPartOffset.position =
                        referencePosRot.rotation.Inverse() *
                        (localPosRot.position -
                         referencePosRot.position);
                }

                if (attachedPartOriginal == null)
                {
                    printf("Recording attachedPartOriginal");

                    attachedPartOriginal          = new PosRot();
                    attachedPartOriginal.rotation = localPosRot.rotation;
                }
            }

            // Calculate the attached parts position in the frame of reference of this part
            PosRot attachedPartPosRot = new PosRot
            {
                rotation = referencePosRot.rotation * attachedPartOffset.rotation,
                position = referencePosRot.position + referencePosRot.rotation * attachedPartOffset.position
            };

            /* A sub part can either be connected directly by their transform having a parent transform,
             * or be connected through a joint. In the first case, the sub part will directly move with
             * their parent as their position is in in the reference frame of the parent local space.
             * In the latter case, the sub part lacks a parent transform, and the position is in the vessel
             * space instead, and parts are held together by forces working through the joints.
             * The first case occurs in two situations. In the VAB editor, all parts are connected by
             * parent transforms. And, during flight, a physicsless part will also be connected to the parent
             * this way - for example some science parts.
             * Joints are used for normal physics based parts during flight.
             */

            if (attachedPart.transform.parent != null)
            {
                // If a parent was found, we will just update the position of the part directly since no physics is involved
                attachedPart.transform.localRotation = attachedPartPosRot.rotation;
                attachedPart.transform.localPosition = attachedPartPosRot.position;

                if (debugPeriodic)
                {
                    printf("Updated pos without physics");
                }

                // There is nothing more to do, so bail out
                return;
            }

            // In the editor, while changing action groups, the parent will be null for some reason.
            // We can catch that here by making sure there exists a joint
            if (attachedPart.attachJoint == null)
            {
                if (debugPeriodic)
                {
                    printf("No attach joint found");
                }
                return;
            }

            // Things get tricker if the parts are connected by joints. We need to setup the joint
            // to apply forces to the sub part.
            ConfigurableJoint joint = attachedPart.attachJoint.Joint;

            // It is not possible to change values of a JointDrive after creation, so we must create a
            // new one and apply it to the joint. Seems we can't only create it at startup either.
            switch (joint.name)
            {
            case "AnimatedAttachment":
                if (joint.xMotion != ConfigurableJointMotion.Free && flightState == State.STARTED)
                {
                    animatedAttachment.initJointDrive = true;
                }
                break;

            case "MechanicsToolkit":
                break;

            default:
                animatedAttachment.initJointDrive = true;
                break;
            }

            if (animatedAttachment.initJointDrive)
            {
                animatedAttachment.initJointDrive = false;
                joint.name = "AnimatedAttachment";

                jointDrive = new JointDrive();
                printf("Creating a new drive mode. Previous: %s, %s, %s, %s, %s",
                       joint.name,
                       joint.xDrive.positionSpring,
                       animatedAttachment.part.name,
                       animatedAttachment.part.started,
                       joint.angularXMotion);

                /*
                 * printf(string.Format("maximumForce: {0}", animatedAttachment.maximumForce));
                 * printf(string.Format("positionDamper: {0}", animatedAttachment.positionDamper));
                 * printf(string.Format("positionSpring: {0}", animatedAttachment.positionSpring));
                 */

                // The joint will not respond to changes to targetRotation/Position in locked mode,
                // so change it to free in all directions
                joint.xMotion        = ConfigurableJointMotion.Free;
                joint.yMotion        = ConfigurableJointMotion.Free;
                joint.zMotion        = ConfigurableJointMotion.Free;
                joint.angularXMotion = ConfigurableJointMotion.Free;
                joint.angularYMotion = ConfigurableJointMotion.Free;
                joint.angularZMotion = ConfigurableJointMotion.Free;

                // Create a new joint with settings from the cfg file or user selection
                jointDrive.maximumForce   = animatedAttachment.maximumForce;
                jointDrive.positionDamper = animatedAttachment.positionDamper;
                jointDrive.positionSpring = animatedAttachment.positionSpring;

                // Same drive in all directions.. is there benefits of separating them?
                joint.angularXDrive  = jointDrive;
                joint.angularYZDrive = jointDrive;
                joint.xDrive         = jointDrive;
                joint.yDrive         = jointDrive;
                joint.zDrive         = jointDrive;
                //}
                if (debug)
                {
                    printf("%s", joint);
                }
            }

            if (debug)
            {
                printf("%s", attachedPartPosRot);
            }
            if (debug)
            {
                printf("%s", attachedPartOriginal);
            }

            // Update the joint.targetRotation using this convenience function, since the joint
            // reference frame has weird axes. Arguments are current and original rotation.
            joint.SetTargetRotationLocal(
                attachedPartPosRot.rotation,
                attachedPartOriginal.rotation);

            /* Move the attached part by updating the connectedAnchor instead of the joint.targetPosition.
             * This is easier since the anchor is in the reference frame of this part, and we already have the
             * position in that reference frame. It also makes sense from the view that since it really is the
             * attachment point of the attached part that is moving. There might be benefits of using the targetPosition
             * though, and should be possible to calculate it fairly easily if needed.
             */
            joint.connectedAnchor = referencePosRot.position;

            // Make sure the target position is zero
            joint.targetPosition = Vector3.zero;

            // This scaling and rotation is to convert to joint space... maybe?
            // Determined by random tinkering and is magical as far as I am concerned
            joint.anchor = attachedPartOffset.rotation.Inverse() *
                           Vector3.Scale(
                new Vector3(-1, -1, -1),
                attachedPartOffset.position);

            if (debugPeriodic)
            {
                printf("%s; %s; %s -> %s; %s -> %s; %s",
                       referencePosRot,
                       attachedPartPosRot,
                       attachedPartOffset,
                       attachedPartOriginal.rotation.eulerAngles,
                       joint.targetRotation.eulerAngles,
                       joint.anchor,
                       joint.connectedAnchor
                       );
            }

            // Debug info
            if (debug)
            {
                // Show debug vectors for the child part
                if (axisJoint == null)
                {
                    axisJoint = new AxisInfo(joint.transform);
                }

                if (lineAnchor == null)
                {
                    lineAnchor = new LineInfo(animatedAttachment.part.transform, Color.cyan);
                }
                lineAnchor.Update(Vector3.zero, joint.connectedAnchor);

                if (lineNodeToPart == null)
                {
                    lineNodeToPart = new LineInfo(animatedAttachment.part.transform, Color.magenta);
                }
                lineNodeToPart.Update(
                    referencePosRot.position,
                    attachedPartPosRot.position);
            }
            else
            {
                if (axisJoint != null)
                {
                    axisJoint = null;
                }
            }

            // Debug info
            if (debug)
            {
                // Show debug vectors for the attachNodes
                if (orientationAttachNode == null)
                {
                    orientationAttachNode = new OrientationInfo(animatedAttachment.part.transform, referencePosRot.position, referencePosRot.position + attachedPartOffset.orientation);
                }

                if (stackAttachNode != null)
                {
                    orientationAttachNode.Update(referencePosRot.position, referencePosRot.position + stackAttachNode.orientation);
                }
            }
            else
            {
                if (orientationAttachNode != null)
                {
                    orientationAttachNode = null;
                }
            }
        }
		/// <summary>
		/// Creates a <see cref="GeographicCoordinateSystem"/>, which could be Lat/Lon or Lon/Lat.
		/// </summary>
		/// <param name="name">Name of geographical coordinate system</param>
		/// <param name="angularUnit">Angular units</param>
		/// <param name="datum">Horizontal datum</param>
		/// <param name="primeMeridian">Prime meridian</param>
		/// <param name="axis0">First axis</param>
		/// <param name="axis1">Second axis</param>
		/// <returns>Geographic coordinate system</returns>
		public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit, IHorizontalDatum datum, IPrimeMeridian primeMeridian, AxisInfo axis0, AxisInfo axis1)
		{
			if (string.IsNullOrEmpty(name))
				throw new ArgumentException("Invalid name");
			List<AxisInfo> info = new List<AxisInfo>(2);
			info.Add(axis0);
			info.Add(axis1);			
			return new GeographicCoordinateSystem(angularUnit, datum, primeMeridian,info, name, String.Empty, -1, String.Empty, String.Empty, String.Empty);
		}
		/// <summary>
		/// Creates a <see cref="IVerticalCoordinateSystem"/> from a <see cref="IVerticalDatum">datum</see> and <see cref="LinearUnit">linear units</see>.
		/// </summary>
		/// <param name="name">Name of vertical coordinate system</param>
		/// <param name="datum">Vertical datum</param>
		/// <param name="verticalUnit">Unit</param>
		/// <param name="axis">Axis info</param>
		/// <returns>Vertical coordinate system</returns>
		public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, IVerticalDatum datum, ILinearUnit verticalUnit, AxisInfo axis)
		{
			throw new NotImplementedException();
		}