Esempio n. 1
0
        public override AuxiliaryLineParameter GetNewAuxiliaryLineParameterBaseHeight(int changeSizeWidth, int changeSizeHeight)
        {
            AuxiliaryLineParameter newParameter = AC.CloneParameter();

            // 左下点の操作なら右側と上側は変わらない
            int changeWidth  = changeSizeWidth;
            int changeHeight = changeSizeHeight;
            int newLeft      = AC.AuxiliaryLeft - CalcWidthChangeSize(changeSizeWidth, changeSizeHeight);
            int newBottom    = AC.AuxiliaryBottom + changeSizeHeight;
            int minLeft      = GetMinLeft();
            int maxBottom    = GetMaxBottom();

            if (newBottom > maxBottom)
            {
                changeHeight = maxBottom - AC.AuxiliaryBottom;
                newLeft      = AC.AuxiliaryLeft - CalcWidthChangeSize(changeWidth, changeHeight);
                newBottom    = maxBottom;
            }
            if (newLeft < minLeft)
            {
                newLeft   = minLeft;
                newBottom = AC.AuxiliaryBottom + CalcHeightChangeSize(AC.AuxiliaryLeft - newLeft, changeHeight);
            }

            newParameter.ReplacePoint(new Point(newLeft, AC.AuxiliaryTop),
                                      new Point(newLeft, newBottom),
                                      new Point(AC.AuxiliaryRight, AC.AuxiliaryTop),
                                      new Point(AC.AuxiliaryRight, newBottom));

            return(newParameter);
        }
        public override AuxiliaryLineParameter GetNewAuxiliaryLineParameterBaseHeight(int changeSizeWidth, int changeSizeHeight)
        {
            AuxiliaryLineParameter newParameter = AC.CloneParameter();

            // 右上点の操作なら左側や下側は変わらない
            int changeWidth  = changeSizeWidth;
            int changeHeight = changeSizeHeight;
            int newTop       = AC.AuxiliaryTop - changeSizeHeight;
            int newRight     = AC.AuxiliaryRight + CalcWidthChangeSize(changeSizeWidth, changeSizeHeight);
            int maxRight     = GetMaxRight();
            int minTop       = GetMinTop();

            if (newTop < minTop)
            {
                changeHeight = AC.AuxiliaryTop - minTop;
                newRight     = AC.AuxiliaryRight + CalcWidthChangeSize(changeWidth, changeHeight);
                newTop       = minTop;
            }
            if (newRight > maxRight)
            {
                newRight = maxRight;
                newTop   = AC.AuxiliaryTop - CalcHeightChangeSize(newRight - AC.AuxiliaryRight, changeHeight);
            }

            newParameter.ReplacePoint(new Point(AC.AuxiliaryLeft, newTop),
                                      new Point(AC.AuxiliaryLeft, AC.AuxiliaryBottom),
                                      new Point(newRight, newTop),
                                      new Point(newRight, AC.AuxiliaryBottom));

            return(newParameter);
        }
        public AuxiliaryLineTestData ChangeSize(int changeSizeWidthPixel,
                                                int changeSizeHeightPixel,
                                                bool isChangeSizeWidthMuchLongerThanChangeSizeHeight)
        {
            // 操作前の値を保持
            AuxiliaryLineParameter now            = AC.CloneParameter();
            AuxiliaryLineParameter afterParameter = null;

            // 矩形操作前にサイズ変更後の各種パラメーターを求め、テストデータとする
            if (isChangeSizeWidthMuchLongerThanChangeSizeHeight)
            {
                afterParameter = GetNewAuxiliaryLineParameterBaseWidth(changeSizeWidthPixel, changeSizeHeightPixel);
            }
            else
            {
                afterParameter = GetNewAuxiliaryLineParameterBaseHeight(changeSizeWidthPixel, changeSizeHeightPixel);
            }

            // 原点が変わるようなサイズ変更が要求されても、サイズ変更しない
            if (WillChangeAuxiliaryOrigin(afterParameter.Left, afterParameter.Top, afterParameter.Right, afterParameter.Bottom))
            {
                afterParameter = now;
            }

            // 操作
            double mouseUpX  = (double)GetMouseUpX(AC, changeSizeWidthPixel);
            double mouseUpY  = (double)GetMouseUpY(AC, changeSizeHeightPixel);
            Point  mouseDown = GetMouseDownPoint(AC);
            Point  mouseUp   = new Point(mouseUpX, mouseUpY);

            AC.SetEvent(mouseDown);
            AC.PublishEvent(mouseUp);

            return(new AuxiliaryLineTestData(afterParameter));
        }
Esempio n. 4
0
        public override AuxiliaryLineParameter GetNewAuxiliaryLineParameterBaseHeight(int changeSizeWidth, int changeSizeHeight)
        {
            AuxiliaryLineParameter newParameter = AC.CloneParameter();

            // 右下点の操作なら左側や上側は変わらない
            int changeWidth  = changeSizeWidth;
            int changeHeight = changeSizeHeight;
            int newRight     = AC.AuxiliaryRight + CalcWidthChangeSize(changeSizeWidth, changeSizeHeight);
            int newBottom    = AC.AuxiliaryBottom + changeSizeHeight;
            int maxRight     = GetMaxRight();
            int maxBottom    = GetMaxBottom();

            if (newBottom > maxBottom)
            {
                changeHeight = maxBottom - AC.AuxiliaryBottom;
                newRight     = AC.AuxiliaryRight + CalcWidthChangeSize(changeWidth, changeHeight);
                newBottom    = maxBottom;
            }
            if (newRight > maxRight)
            {
                newRight  = maxRight;
                newBottom = AC.AuxiliaryBottom + CalcHeightChangeSize(maxRight - AC.AuxiliaryRight, changeHeight);
            }

            SetNewParameter(newParameter, newRight - AC.AuxiliaryRight, newBottom - AC.AuxiliaryBottom);

            return(newParameter);
        }
Esempio n. 5
0
        public AuxiliaryLineTestData Execute(AuxiliaryController ac, int degree)
        {
            Point leftTop     = ac.AuxiliaryLeftTop;
            Point leftBottom  = ac.AuxiliaryLeftBottom;
            Point rightTop    = ac.AuxiliaryRightTop;
            Point rightBottom = ac.AuxiliaryRightBottom;
            int   centerX     = CalcCenterX(leftTop, rightBottom);
            int   centerY     = CalcCenterY(leftBottom, rightTop);

            // テストデータ作成
            Point newLeftTop     = CalcRotatePoint(leftTop, centerX, centerY, degree);
            Point newLeftBottom  = CalcRotatePoint(leftBottom, centerX, centerY, degree);
            Point newRightTop    = CalcRotatePoint(rightTop, centerX, centerY, degree);
            Point newRightBottom = CalcRotatePoint(rightBottom, centerX, centerY, degree);

            AuxiliaryLineParameter before   = ac.CloneParameter();
            AuxiliaryLineTestData  testData = new AuxiliaryLineTestData(newLeftTop, newLeftBottom, newRightTop, newRightBottom, degree);

            if (IsOutOfRangeImagePoint(newLeftTop, ac) ||
                IsOutOfRangeImagePoint(newLeftBottom, ac) ||
                IsOutOfRangeImagePoint(newRightTop, ac) ||
                IsOutOfRangeImagePoint(newRightBottom, ac))
            {
                testData = new AuxiliaryLineTestData(before);
            }

            // 回転実施
            ac.SetEvent(degree);
            ac.PublishEvent(null);

            return(testData);
        }
Esempio n. 6
0
 public AuxiliaryLineTestData(AuxiliaryLineParameter param)
 {
     ExpectLeftTop     = param.LeftTop;
     ExpectLeftBottom  = param.LeftBottom;
     ExpectRightTop    = param.RightTop;
     ExpectRightBottom = param.RightBottom;
     ExpectDegree      = param.Degree;
 }
Esempio n. 7
0
 private void AreParameterEqual(AuxiliaryLineParameter expected, AuxiliaryController actual)
 {
     Assert.AreEqual(expected.LeftTop, actual.AuxiliaryLeftTop);
     Assert.AreEqual(expected.LeftBottom, actual.AuxiliaryLeftBottom);
     Assert.AreEqual(expected.RightTop, actual.AuxiliaryRightTop);
     Assert.AreEqual(expected.RightBottom, actual.AuxiliaryRightBottom);
     Assert.AreEqual(expected.Degree, actual.AuxiliaryDegree);
 }
 public AuxiliaryController(ImageController ic,
                            AuxiliaryLineParameter.RatioType ratioType = AuxiliaryLineParameter.RatioType.W16H9,
                            int auxiliaryLineThickness = 1)
 {
     Parameter = new AuxiliaryLineParameter(ic.DisplayImageWidth,
                                            ic.DisplayImageHeight,
                                            ratioType,
                                            auxiliaryLineThickness);
     AuxiliaryLineCommandList = new AuxiliaryLineCommandList();
 }
Esempio n. 9
0
        public void TestAuxiliaryLineNoRotateIfAuxiliaryLineOutOfRangeAfterRotate()
        {
            // 回転すると画像からはみ出る場合は回転しない
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            // 縮小&移動して回転できそうなスペースを作る(実際には回転させたくない)
            ChangeAuxiliaryLineSizeWhereBottomRight(ac, -100, -5, true);
            MoveAuxiliaryLine(ac, 100, 80);

            AuxiliaryLineParameter before = ac.CloneParameter();
            AuxiliaryLineTestData  testData
                = new AuxiliaryLineRotate().Execute(ac, 20);

            AreParameterEqual(before, ac);
        }
Esempio n. 10
0
        private void SetNewParameter(AuxiliaryLineParameter param, int changeSizeRight, int changeSizeBottom)
        {
            param.ReplacePoint(AC.AuxiliaryLeftTop,
                               new Point(AC.AuxiliaryLeftBottom.X, AC.AuxiliaryLeftBottom.Y + changeSizeBottom),
                               new Point(AC.AuxiliaryRightTop.X + changeSizeRight, AC.AuxiliaryRightTop.Y),
                               new Point(AC.AuxiliaryRightBottom.X + changeSizeRight, AC.AuxiliaryRightBottom.Y + changeSizeBottom));
            return;

            //if (AC.AuxiliaryDegree == 0)
            //{
            //    param.ReplacePoint(AC.AuxiliaryLeftTop,
            //                       new Point(AC.AuxiliaryLeftBottom.X, AC.AuxiliaryLeftBottom.Y + changeSizeBottom),
            //                       new Point(AC.AuxiliaryRightTop.X + changeSizeRight, AC.AuxiliaryRightTop.Y),
            //                       new Point(AC.AuxiliaryRightBottom.X + changeSizeRight, AC.AuxiliaryRightBottom.Y + changeSizeBottom));
            //    return;
            //}

            //Point newRightBottom = GetNewRightBottom(changeSizeRight, changeSizeBottom);
            //Point newRightTop = GetNewRightTop(newRightBottom);
            //Point newLeftBottom = GetNewLeftBottom(newRightBottom);

            //param.ReplacePoint(AC.AuxiliaryLeftTop, newLeftBottom, newRightTop, newRightBottom);
            //return;
        }
 public AuxiliaryLineParameter Execute(object operation)
 {
     BeforeParameter = AC.CloneParameter();
     AfterParameter  = ExecuteCore(operation);
     return(AfterParameter);
 }