private void UpdateArrows()
        {
            Vector3D dim = Dimensions;

            if (-1 != SelectedIndex)
            {
                // allow translations
                Arrows = Enumerable.Repeat(false, 4).ToArray();
                for (int i = 0; i < 4; ++i)
                {
                    double distance = 0.0;
                    if ((!BoxInteraction.MinDistance(Layer.Positions, dim, SelectedIndex, Directions[i], ref distance) || distance > 0.1) &&
                        BoxInteraction.BoxCanMoveInside(Layer.Positions[SelectedIndex], dim, PtMin, PtMax, Directions[i]))
                    {
                        Arrows[i] = true;
                    }
                }
                // allow rotations
                ArrowRotate = !BoxInteraction.HaveIntersection(Layer.Positions, dim, SelectedIndex, Layer.Positions[SelectedIndex].RotateZ90(dim));
            }
            bool allBoxesInside = BoxInteraction.BoxesAreInside(Layer.Positions, dim, Vector2D.Zero, Layer.DimContainer);

            if (AllBoxesInside != allBoxesInside)
            {
                AllBoxesInside = allBoxesInside;
                SaveEnabled?.Invoke(AllBoxesInside);
            }
        }
        private void OnTimerTick(object sender, EventArgs e)
        {
            if (-1 == SelectedIndex)
            {
                return;
            }
            BoxPosition bpos    = Layer.Positions[SelectedIndex];
            BoxPosition bposNew = bpos.Translate(MoveDir, StepMove);

            if (!BoxInteraction.HaveIntersection(Layer.Positions, Dimensions, SelectedIndex, bposNew) &&
                BoxInteraction.BoxCanMoveInside(Layer.Positions[SelectedIndex], Dimensions, PtMin, PtMax, MoveDir))
            {
                Layer.Positions[SelectedIndex] = bposNew;
            }

            else
            {
                double distance = 0;
                if (BoxInteraction.MinDistance(Layer.Positions, Dimensions, SelectedIndex, MoveDir, ref distance))
                {
                    bposNew = bpos.Translate(MoveDir, distance);
                    Layer.Positions[SelectedIndex] = bposNew;
                }
                EndMove();
            }
            CountMove++;

            UpdateArrows();
            Invalidate();
        }
Пример #3
0
        public void Move(HalfAxis.HAxis moveDir, double stepMove)
        {
            // sanity check
            if (!IsSelectionValid)
            {
                return;
            }
            // update position
            BoxPosition bpos    = Positions[SelectedIndex];
            BoxPosition bposNew = bpos.Translate(moveDir, stepMove);

            if (!BoxInteraction.HaveIntersection(Positions, DimCase, SelectedIndex, bposNew) &&
                BoxInteraction.BoxCanMoveInside(Positions[SelectedIndex], DimCase, PtMin, PtMax, moveDir))
            {
                Positions[SelectedIndex] = bposNew;
            }
            else
            {
                double distance = 0;
                if (BoxInteraction.MinDistance(Positions, DimCase, SelectedIndex, moveDir, ref distance))
                {
                    bposNew = bpos.Translate(moveDir, distance);
                    Positions[SelectedIndex] = bposNew;
                }
            }
        }
Пример #4
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "Box")
     {
         boxInteraction = null;
     }
 }
Пример #5
0
        public void Insert()
        {
            BoxPosition bPosNew = new BoxPosition(new Vector3D(0.0, -DimCase.Y, 0.0), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P);

            if (!BoxInteraction.HaveIntersection(Positions, DimCase, -1, bPosNew))
            {
                Positions.Add(bPosNew);
            }
        }
 private void EnableDisableAddRemoveButtons()
 {
     tsbAdd.Enabled = !BoxInteraction.HaveIntersection(
         Layer.Positions,
         Dimensions,
         -1,
         new BoxPosition(new Vector3D(PtMin.X, PtMin.Y, 0.0), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P)
         );
     tsbRemove.Enabled = (-1 != SelectedIndex);
 }
Пример #7
0
    private void OnTriggerStay(Collider other)
    {
        boxInteraction = other.GetComponent <BoxInteraction>();

        if (other.tag == "Box")
        {
            boxState = boxInteraction.GetBoxState();

            PlayerComand();

            boxInteraction.SetBoxState(boxState);
        }
    }
Пример #8
0
        public void Rotate()
        {
            if (!IsSelectionValid)
            {
                return;
            }

            var boxPositionRotated = Positions[SelectedIndex].RotateZ90(DimCase);

            if (!BoxInteraction.HaveIntersection(Positions, DimCase, SelectedIndex, boxPositionRotated))
            {
                Positions[SelectedIndex] = boxPositionRotated;
            }
        }
        private void OnItemAdd(object sender, EventArgs e)
        {
            BoxPosition bPosNew = new BoxPosition(new Vector3D(PtMin.X, PtMin.Y, 0.0), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P);

            if (!BoxInteraction.HaveIntersection(Layer.Positions, Dimensions, SelectedIndex, bPosNew))
            {
                Layer.AddPosition(bPosNew);
                SelectedIndex = Layer.Positions.Count - 1;
                Invalidate();
            }
            else
            {
                MessageBox.Show(Resources.ID_CANNOTADD);
            }
        }
Пример #10
0
        public void MoveMax(HalfAxis.HAxis moveDir)
        {
            // sanity check
            if (!IsSelectionValid)
            {
                return;
            }
            // update position
            BoxPosition bpos     = Positions[SelectedIndex];
            double      distance = 0;

            if (BoxInteraction.MinDistance(Positions, DimCase, SelectedIndex, moveDir, ref distance))
            {
            }
            if (distance > 0)
            {
                Positions[SelectedIndex] = bpos.Translate(moveDir, distance);
            }
            ;
        }
        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (Moving)
            {
                EndMove();
                Moving = false;
            }
            else
            {
                Vector2D pt = Graphics.ReverseTransform(e.Location);
                // selected index
                int initialIndex = SelectedIndex;
                SelectedIndex = BoxInteraction.SelectedPosition(Layer.Positions, Dimensions, pt);
                if (initialIndex != SelectedIndex)
                {
                    SelectionChanged();
                }
            }

            UpdateArrows();
            Invalidate();
        }
Пример #12
0
 public int GetPickedIndex(Point pt)
 {
     return(BoxInteraction.SelectedPosition(Positions, DimCase, ReverseTransform(pt, DimCase, DimContainer)));
 }