示例#1
0
 /// <summary>
 /// 匹配人员坐标
 /// </summary>
 /// <param name="SubjectString"></param>
 private void MatchPerson(string SubjectString)
 {
     try
     {
         string strPosition = Regex.Match(SubjectString, "\\|[0-9]*\\|-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*").Value;
         if (!string.IsNullOrEmpty(strPosition))
         {
             FramePosition position = FramePosition.Parse(strPosition.Substring(1, strPosition.LastIndexOf("|") - 1), strPosition.Substring(strPosition.LastIndexOf("|") + 1));
             if (position != null)
             {
                 if (Rmode == Runmode.Match)
                 {
                     Cmatch?.AddPosition(position);
                 }
                 else if (rmode == Runmode.Train)
                 {
                     Ctrain?.AddPosition(position);
                 }
             }
         }
     }
     catch (ArgumentException ex)
     {
         LogText.Error("MatchPerson", ex.Message);
     }
 }
示例#2
0
            public FramePosition ReadPosition(int positionOffset, FramePosition.PositionType positionType)
            {
                FramePosition Position;

                if (positions.TryGetValue(positionOffset, out Position))
                {
                    return(Position);
                }

                reader.Seek(positionOffset);
                var position = new FramePosition();

                position.CellIndex = reader.ReadUInt16();

                switch (positionType)
                {
                case FramePosition.PositionType.Index:
                    break;

                case FramePosition.PositionType.IndexRotationScaleTranslation:
                    throw new NotImplementedException();

                case FramePosition.PositionType.IndexTranslation:
                    reader.Skip(2);
                    var tx = reader.ReadInt16();
                    var ty = reader.ReadInt16();
                    break;
                }
                positions.Add(positionOffset, position);
                return(position);
            }
示例#3
0
        /// <summary>
        /// 找到该轨迹的发起人
        /// </summary>
        /// <param name="newTrack"></param>
        /// <returns></returns>
        public bool SetTrackOwner(Track newTrack)
        {
            //轨迹的所属人
            User u = Players.First(o => o.Userinfo.Direction * newTrack.Direction > 0);

            if (u != null)
            {
                //估计的所属人
                newTrack.Owner = u;

                FramePosition position = newTrack.Owner.AllPositions.LastOrDefault(o => o.FrameNumber <= newTrack.FirstPosition.FrameNumber);
                if (position != null)
                {
                    newTrack.OwnerStartPosition = position;
                    LogText.Info("SetTrackOwner01", "轨迹起始坐标:{0},人的坐标{1},人的场地{2}", newTrack.FirstPosition, position, u.Userinfo.Direction > 0?"A":"B");
                }
                else
                {
                    //设置人的最后一个坐标为当前轨迹起始时,人的轨迹坐标
                    newTrack.OwnerStartPosition = newTrack.Owner.AllPositions.LastOrDefault();
                    LogText.Info("SetTrackOwner02", "将当前轨迹所有人的最后一个坐标点设置为轨迹起始时,对应的人的坐标,可能会导致左右手判断出错");
                    LogText.Info("SetTrackOwner01", "轨迹起始坐标:{0},人的坐标{1},人的场地{2}", newTrack.FirstPosition, position, u.Userinfo.Direction > 0 ? "A" : "B");
                }
                return(true);
            }
            else
            {
                LogText.Error("SetTrackOwner03", "没有找到该轨迹对应的人员的同帧号坐标,轨迹起始帧号:" + newTrack.FirstPosition.FrameNumber);
            }
            return(false);
        }
示例#4
0
 /// <summary>
 /// 添加坐标
 /// </summary>
 /// <param name="p"></param>
 public void AddPosition(FramePosition p)
 {
     if (Contain(p))
     {
         allPositions.Add(p);
     }
 }
示例#5
0
        public static IBCoordinate ToCoordinate(this FramePosition position)
        {
            IBCoordinate coordinate = new IBCoordinate();

            coordinate.Left   = position.leftTop.X;
            coordinate.Top    = position.leftTop.Y;
            coordinate.Right  = position.rightBottom.X;
            coordinate.Bottom = position.rightBottom.Y;

            return(coordinate);
        }
示例#6
0
        /// <summary>
        /// 添加运动员的坐标
        /// </summary>
        /// <param name="fr"></param>
        public void AddPosition(FramePosition fr)
        {
            //为坐标点设置方向
            fr.Direction = fr.Position.Y > Court.Height / 2 ? 1 : -1;

            Parallel.ForEach(Players, (n) => { n.AddPosition(fr); });

            ///记录该场比赛的起始帧号
            if (StartFrameNumber == 0)
            {
                StartFrameNumber = fr.FrameNumber;
            }
        }
示例#7
0
 public ImageBox()
 {
     referencedSOPInstanceUID = new List <string>();
     Position                       = new FramePosition();
     RowPosition                    = -1;
     ColumnPosition                 = -1;
     ImageBoxNumber                 = -1;
     ImageBoxLayoutType             = ImageBoxLayoutType.Single;
     WindowWidth                    = -1;
     WindowCenter                   = -1;
     ReferencedPresentationStateSOP = string.Empty;
     HorizontalJustification        = HorizontalJustification.Center;
     VerticalJustification          = VerticalJustification.Center;
     ImageBoxSmallScrollType        = ScrollType.None;
     ImageBoxLargeScrollType        = ScrollType.None;
 }
        Vector3 GetFramePosition(FramePosition framePositionTag)
        {
            switch (framePositionTag)
            {
            case FramePosition.Right:
                return(m_framePositions[0]);

            case FramePosition.Center:
                return(m_framePositions[1]);

            case FramePosition.Left:
                return(m_framePositions[2]);

            default:
                throw new ArgumentException();
            }
        }
示例#9
0
 /// <summary>
 /// 匹配人员坐标
 /// </summary>
 /// <param name="SubjectString"></param>
 private void MatchPerson(string SubjectString)
 {
     try
     {
         string strPosition = Regex.Match(SubjectString, "\\|[0-9]*\\|-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*").Value;
         if (!string.IsNullOrEmpty(strPosition))
         {
             FramePosition position = FramePosition.Parse(strPosition);
             if (position != null)
             {
                 AddPosition(position);
             }
         }
     }
     catch (ArgumentException ex)
     {
         LogText.Error("MatchPerson", ex.Message);
     }
 }
        /// <summary>
        /// パネルフレームを引数に応じたフレームポジションへなめらかに移動させる
        /// </summary>
        /// <param name="framePosition">移動したい先のポジション</param>
        /// <returns></returns>
        public IEnumerator MovingFrame(FramePosition framePosition)
        {
            if (isMoving)
            {
                yield break;
            }
            isMoving = true;
            var toPos = new Vector3();

            switch (framePosition)
            {
            case FramePosition.Right:
                toPos = GetFramePosition(FramePosition.Right);
                break;

            case FramePosition.Center:
                toPos = GetFramePosition(FramePosition.Center);
                break;

            case FramePosition.Left:
                toPos = GetFramePosition(FramePosition.Left);
                break;

            default:
                break;
            }

            iTween.ValueTo(gameObject, iTween.Hash(
                               "from", gameObject.transform.localPosition,
                               "to", toPos,
                               "time", animationTime,
                               "easetype", easeType,
                               "onupdate", "SyncPosition",
                               "onpudatetarget", gameObject,
                               "ignoretimescale", false
                               ));
            yield return(new WaitForSeconds(animationTime)); // 移動してる間重複呼び出しを止める

            m_framePosition = framePosition;                 // panelFrameの位置情報を更新する
            isMoving        = false;
            OnMovingFrame();
        }
    /// <summary>
    /// Gets the next position to which the frame will move.
    /// </summary>
    /// <param name="position">Current position of the frame.</param>
    /// <param name="moveModifier">Modifier that determines how many position
    /// the frame will move.</param>
    /// <returns></returns>
    private FramePosition GetNextFramePosition(FramePosition position,
                                               int moveModifier)
    {
        if (moveModifier == 1)
        {
            if (position == FramePosition.Mid)
            {
                return(FramePosition.Left);
            }

            if (position == FramePosition.Left)
            {
                return(FramePosition.Right);
            }

            else
            {
                return(FramePosition.Mid);
            }
        }
        else
        {
            if (position == FramePosition.Mid)
            {
                return(FramePosition.Right);
            }

            if (position == FramePosition.Left)
            {
                return(FramePosition.Mid);
            }

            else
            {
                return(FramePosition.Left);
            }
        }
    }
示例#12
0
        /// <summary>
        /// 从字符串中解析出对象
        /// </summary>
        /// <param name="strValue"></param>
        /// <returns></returns>
        public static Track Parse(string strValue)
        {
            Track t = new RigourTech.Service.Track();

            if (string.IsNullOrEmpty(strValue))
            {
                return(null);
            }

            t.TraceString = strValue;

            string[] items = strValue.Split('|');
            if (items.Length != 6)
            {
                LogText.Error("Track.pase", "数据格式错误:" + strValue);
            }


            MatchCollection results = Regex.Matches(items[1], "[0-9]*,-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*");

            foreach (System.Text.RegularExpressions.Match m in results)
            {
                t.Trace.Add(
                    FramePosition.Parse(
                        m.Value.Substring(0, m.Value.IndexOf(",")),
                        m.Value.Substring(m.Value.IndexOf(",") + 1)
                        )
                    );
            }
            MatchCollection mtouchdownpoints = Regex.Matches(items[2], "-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*,-?[0-9]*\\.[0-9]*");

            if (mtouchdownpoints.Count == 2)
            {
                t.Touchdown_P1 = Point3D.Prase(mtouchdownpoints[0].Value);
                t.Touchdown_P2 = Point3D.Prase(mtouchdownpoints[1].Value);
            }
            else
            {
                LogText.Error("Track.pase", "数据格式错误:" + items[2]);
            }
            MatchCollection mtimes = Regex.Matches(items[3], "[0-9]");

            if (mtimes.Count == 2)
            {
                t.BeginTime = long.Parse(mtimes[0].Value);
                t.Endtime   = long.Parse(mtimes[1].Value);
            }
            else
            {
                LogText.Error("Track.pase", "数据格式错误:" + items[3]);
            }

            string[] vls = items[4].Split(';');
            if (vls.Length == 2)
            {
                t.TouchdonwMarkNumber = vls[0];

                t.Radius = double.Parse(vls[1]);
            }

            t.MaxRotateSpeed = double.Parse(items[5]);

            t.Direction = Convert.ToInt32(t.FirstPosition?.Position.Y - t.EndPosition?.Position.Y);

            LogText.Info("Track.prase", "成功解析出一条轨迹:方向{0},旋转速度{1},落地区域{2},半径{3}", t.direction, t.MaxRotateSpeed, t.TouchdonwMarkNumber, t.radius);
            return(t);
        }
示例#13
0
 private void AddPosition(FramePosition fr)
 {
     Parallel.ForEach(Users, (n) => { n.AddPosition(fr); });
 }
        public List <Template> GetAllTemplates()
        {
            List <Template> templates = new List <Template>();

            using (var command = DatabaseProvider.DbProviderFactory.CreateCommand())
            {
                InitializeGetAllTemplates(command);
                using (var reader = DatabaseProvider.ExecuteReader(command))
                {
                    while (reader.Read())
                    {
                        Template template = new Template();

                        using (var frameCommand = DatabaseProvider.DbProviderFactory.CreateCommand())
                        {
                            template.Id           = reader.GetColumnValue <string>("Id");
                            template.Name         = reader.GetColumnValue <string>("Name");
                            template.Modality     = reader.GetColumnValue <string>("Modality");
                            template.Created      = reader.GetColumnValue <DateTime?>("Created");
                            template.Hidden       = reader.GetColumnValue <bool>("Hidden");
                            template.AutoMatching = reader.GetColumnValue <string>("AutoMatching");
                            template.BuiltIn      = reader.GetColumnValue <bool>("BuiltIn");
                            template.Comments     = reader.GetColumnValue <string>("Comments");
                            template.Availability = reader.GetColumnValue <AvailabilityLevel>("Availability");

                            InitializeGetTemplateFrames(frameCommand, template.Id);
                            using (var frameReader = DatabaseProvider.ExecuteReader(frameCommand))
                            {
                                while (frameReader.Read())
                                {
                                    TemplateFrame frame;
                                    FramePosition position = new FramePosition();

                                    position.leftTop     = new LeadPointD(frameReader.GetColumnValue <double>("Left"), frameReader.GetColumnValue <double>("Top"));
                                    position.rightBottom = new LeadPointD(frameReader.GetColumnValue <double>("Right"), frameReader.GetColumnValue <double>("Bottom"));
                                    frame                         = new TemplateFrame(position);
                                    frame.Id                      = frameReader.GetColumnValue <string>("Id");
                                    frame.FrameNumber             = frameReader.GetColumnValue <int>("FrameNumber");
                                    frame.SequenceNumber          = frameReader.GetColumnValue <int>("SequenceNumber");
                                    frame.ImageComments           = frameReader.GetColumnValue <string>("Comments");
                                    frame.Rotation                = frameReader.GetColumnValue <FrameRotation>("FrameRotation");
                                    frame.HorizontalJustification = frameReader.GetColumnValue <FrameHorizontalJustication>("HorizontalJustification");
                                    frame.VerticalJustification   = frameReader.GetColumnValue <FrameVerticalJustification>("VerticalJustification");
                                    frame.PresentationSizeMode    = frameReader.GetColumnValue <PresentationSizeMode>("PresentationSizeMode");
                                    frame.Magnification           = frameReader.GetColumnValue <double>("Magnification");
                                    //frame.AnatomicDescription = anatomicDescriptions.Where(a => a.Id == frameReader.GetColumnValue<string>("AnatomicDescriptionId")).FirstOrDefault();
                                    frame.Script  = frameReader.GetColumnValue <string>("Script");
                                    frame.Flip    = frameReader.GetColumnValue <bool>("Flip");
                                    frame.Reverse = frameReader.GetColumnValue <bool>("Reverse");
                                    frame.Invert  = frameReader.GetColumnValue <bool>("Invert");
                                    template.Frames.Add(frame);
                                }
                            }
                        }

                        templates.Add(template);
                    }
                }
            }

            return(templates);
        }
    /// <summary>
    /// Responisble for moving the given frame to its next position based on
    /// the given mode modifier.
    /// </summary>
    /// <param name="frameToMove">Frame to be moved.</param>
    /// <param name="moveModifier">Modifier that determines how many position
    /// the frame will move.</param>
    /// <returns></returns>
    private IEnumerator Translation(
        Frame frameToMove,
        int moveModifier)
    {
        float elapsedTime = 0f;
        float timeLimit   = 0.25f;

        // Verification to avoid click spam
        if (elapsedTime < timeLimit && onInteraction)
        {
            yield break;
        }

        // Disables the possibility of interaction with the other frames while
        // the resulting interactions of this frame is happening
        for (int i = 0; i < Frame.LinkedFrames.Length; i++)
        {
            Frame.LinkedFrames[i].GetComponent <FrameTranslationInteraction>().
            CanInteract = false;
        }

        // Point to which the frame will move
        Vector3 desiredPoint;

        // Position that the frame will be after being moved
        FramePosition nextPosition =
            GetNextFramePosition(frameToMove.CurrentPosition, moveModifier);

        // Defines the exact position of the desired point
        switch (nextPosition)
        {
        case FramePosition.Right:
            desiredPoint =
                frameToMove.transform.position -
                (frameToMove.transform.position -
                 framePointParent.FramePoints[0].position);
            break;

        case FramePosition.Mid:
            desiredPoint =
                frameToMove.transform.position -
                (frameToMove.transform.position -
                 framePointParent.FramePoints[1].position);
            break;

        case FramePosition.Left:
            desiredPoint =
                frameToMove.transform.position -
                (frameToMove.transform.position -
                 framePointParent.FramePoints[2].position);
            break;

        default:
            desiredPoint =
                frameToMove.transform.position -
                (frameToMove.transform.position -
                 framePointParent.FramePoints[0].position);
            break;
        }

        // Changes the Z and Y coordenates of the desiredPoint so it only moves
        // on the X axis.
        desiredPoint.z = frameToMove.transform.position.z;
        desiredPoint.y = frameToMove.transform.position.y;
        onInteraction  = true;
        SoundManager.PlaySound(SoundClip.WoodDragging);
        while (elapsedTime < timeLimit)
        {
            // Moves the frame
            frameToMove.transform.position = Vector3.MoveTowards(
                frameToMove.transform.position,
                desiredPoint,
                10 * Time.deltaTime);

            elapsedTime += Time.deltaTime;
            yield return(null);
        }
        onInteraction = false;

        // Changes the position of the frame
        switch (frameToMove.CurrentPosition)
        {
        case FramePosition.Right:
            frameToMove.CurrentPosition = FramePosition.Mid;
            break;

        case FramePosition.Mid:
            frameToMove.CurrentPosition = FramePosition.Left;
            break;

        case FramePosition.Left:
            frameToMove.CurrentPosition = FramePosition.Right;
            break;
        }
        frameToMove.CurrentPosition = nextPosition;
        moveFrame = null;

        // Moves the frames linked to this one
        if (executeChainReaction)
        {
            frameCount++;
            if (frameCount == 1)
            {
                moveFrame =
                    StartCoroutine(Translation(Frame.LinkedFrames[0], 2));
                yield break;
            }
            else if (frameCount == 2)
            {
                moveFrame =
                    StartCoroutine(Translation(Frame.LinkedFrames[1], 1));
                frameCount           = 0;
                executeChainReaction = false;
                yield break;
            }
        }

        // Enables the possibility of interaction with the other frames
        for (int i = 0; i < Frame.LinkedFrames.Length; i++)
        {
            Frame.LinkedFrames[i].GetComponent <FrameTranslationInteraction>().
            CanInteract = true;
        }

        // Fires the FramesChanged event
        OnFramesChanged();
    }
示例#16
0
 /// <summary>
 /// 判断是否属于当前用户
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 private bool Contain(FramePosition p)
 {
     return(p.Direction * this.Userinfo.Direction > 0);
 }