Esempio n. 1
0
        /// <summary>
        /// Recalculates the shape of the ROI instance. Translation is
        /// performed at the active handle of the ROI object
        /// for the image coordinate (x,y)
        /// </summary>
        /// <param name="newX">x mouse coordinate</param>
        /// <param name="newY">y mouse coordinate</param>
        public override void moveByHandle(double newX, double newY, HWindowControl window)
        {
            double vX, vY, x = 0, y = 0;

            switch (activeHandleIdx)
            {
            case 0:
            case 1:
            case 2:
            case 3:

                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);

                length2 = Math.Abs(y);
                length1 = Math.Abs(x);

                checkForRange(x, y);
                window.Cursor = System.Windows.Forms.Cursors.Hand;
                break;

            case 4:
                midC          = newX;
                midR          = newY;
                window.Cursor = System.Windows.Forms.Cursors.SizeAll;
                break;

            case 5:
                vY            = newY - rows[4].D;
                vX            = newX - cols[4].D;
                phi           = Math.Atan2(vY, vX);
                window.Cursor = System.Windows.Forms.Cursors.Hand;
                break;

            case 7:
            case 9:
                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);



                length2 = Math.Abs(y);

                checkForRange(x, y);
                window.Cursor = System.Windows.Forms.Cursors.Hand;
                break;

            case 6:
            case 8:
                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);


                length1 = Math.Abs(x);
                checkForRange(x, y);
                window.Cursor = System.Windows.Forms.Cursors.Hand;
                break;
            }
            updateHandlePos();
        }        //end of method
Esempio n. 2
0
        public override void resize(double newX, double newY)
        {
            double vX, vY, x = 0, y = 0;

            switch (activeHandleIdx)
            {
            case 0:
            case 1:
            case 2:
            case 3:

                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);

                length2 = Math.Abs(y);
                length1 = Math.Abs(x);

                checkForRange(x, y);
                break;

            case 4:
                midC = newX;
                midR = newY;
                break;

            case 5:
                vY  = newY - rows[4].D;
                vX  = newX - cols[4].D;
                phi = Math.Atan2(vY, vX);
                break;

            case 7:
            case 9:
                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);



                length2 = Math.Abs(y);

                checkForRange(x, y);
                break;

            case 6:
            case 8:
                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);


                length1 = Math.Abs(x);
                checkForRange(x, y);
                break;
            }
            updateHandlePos();
        }        //end of method
        public void ReverseTransPoint2d(HTuple x, HTuple y, out HTuple tx, out HTuple ty)
        {
            HHomMat2D mat2D = matrix.HomMat2dInvert();

            Debug.Assert((x != null) && (y != null));
            Debug.Assert(x.Length == y.Length, string.Format("输入参数长度错误:x={0},Y={1}", x.Length, y.Length));
            HOperatorSet.AffineTransPoint2d(mat2D, x, y, out tx, out ty);
        }
Esempio n. 4
0
        /// <summary>
        /// Recalculates the shape of the ROI instance. Translation is
        /// performed at the active handle of the ROI object
        /// for the image coordinate (x,y)
        /// </summary>
        /// <param name="newX">x mouse coordinate</param>
        /// <param name="newY">y mouse coordinate</param>
        public override void moveByHandle(double newX, double newY)
        {
            double vX, vY, x = 0, y = 0;

            switch (activeHandleIdx)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                tmp = hom2D.HomMat2dInvert();
                x   = tmp.AffineTransPoint2d(newX, newY, out y);

                length2 = Math.Abs(y);
                length1 = Math.Abs(x);

                checkForRange(x, y);
                break;

            case 4:
                midC = newX;
                midR = newY;
                break;

            case 5:
                //20180315
                vY  = newY - rows[4].D;
                vX  = newX - cols[4].D;
                phi = Math.Atan2(vY, vX);

                //HTuple rad = null;
                //HOperatorSet.TupleRad(90.0, out rad);
                //vY = -(newY - rows[4].D);
                //vX = newX - cols[4].D;
                //phi = Math.Atan2(vY, vX);

                //if (vX<0)
                //{
                //    phi = phi + 2.0 * rad.D;
                //}

                //double m_vY = newY - rows[4].D;
                //double m_vX = newX - cols[4].D;
                //vY =Math.Abs(m_vY);
                //vX = Math.Abs(m_vX);
                //double m_phi = Math.Atan2(vY, vX);



                //if (m_vY == 0 || m_vX == 0)
                //{
                //    if (m_vY == 0)
                //    {
                //        if (m_vX<0)
                //        {
                //            phi = 2.0 * rad.D;
                //        }
                //        else
                //        {
                //            phi = m_phi;
                //        }
                //    }
                //    else
                //    {
                //        if (m_vY<0)
                //        {
                //            phi = rad.D;
                //        }
                //        else
                //        {
                //            phi = 3.0 * rad.D;
                //        }
                //    }
                //}
                //else
                //{
                //    if (m_vY<0)
                //    {
                //        if (m_vX>0)
                //        {
                //            phi = m_phi;
                //        }
                //        else
                //        {
                //            phi = 2.0 * rad.D - m_phi;
                //        }
                //    }
                //    else
                //    {
                //        if (m_vX > 0)
                //        {
                //            phi = 4.0 * rad.D - m_phi;
                //        }
                //        else
                //        {
                //            phi = 20 * rad.D + m_phi;
                //        }
                //    }
                //}

                Console.WriteLine("yyyyyyyyyyyy {0} , {1} , {2}", vY, vX, phi);

                break;
            }
            updateHandlePos();
        }        //end of method
Esempio n. 5
0
        /// <summary>
        /// 设置点位
        /// </summary>
        /// <param name="col_x"></param>
        /// <param name="row_y"></param>
        public override void setOpoint(double col_x, double row_y)
        {
            double vX, vY, x = 0, y = 0;

            switch (this._operationing)
            {
            case 0:
                #region  无用代码
                //_tmp = _hom2D.HomMat2dInvert();
                //x = _tmp.AffineTransPoint2d(col_x, row_y, out y);

                //this._len2 = Math.Abs(y);
                //this._len1 = Math.Abs(x);
                #region  无用代码
                //col_x = col_x - this._mid_col_x;
                //row_y = row_y - this._mid_row_y;
                //checkForRange(col_x, row_y);
                #endregion
                //break;
                #endregion

            case 1:
                #region  无用代码
                //_tmp = _hom2D.HomMat2dInvert();
                //x = _tmp.AffineTransPoint2d(col_x, row_y, out y);

                //this._len2 = Math.Abs(y);
                //this._len1 = Math.Abs(x);
                #region  无用代码
                //col_x = col_x - this._mid_col_x;
                //row_y = row_y - this._mid_row_y;

                //checkForRange(col_x, row_y);
                #endregion

                //break;
                #endregion
            case 2:
                #region  无用代码
                //_tmp = _hom2D.HomMat2dInvert();
                //x = _tmp.AffineTransPoint2d(col_x, row_y, out y);
                //this._len2 = Math.Abs(y);
                //this._len1 = Math.Abs(x);
                #region  无用代码
                //col_x = col_x - this._mid_col_x;
                //row_y = row_y - this._mid_row_y;

                //checkForRange(col_x, row_y);
                #endregion
                //break;
                #endregion
            case 3:
                _tmp = _hom2D.HomMat2dInvert();
                x    = _tmp.AffineTransPoint2d(col_x, row_y, out y);

                this._len2 = Math.Abs(y);
                this._len1 = Math.Abs(x);

                //checkForRange(x,y);
                #region  无用代码
                //col_x = col_x - this._mid_col_x;
                //row_y = row_y - this._mid_row_y;

                //checkForRange(col_x, row_y);
                #endregion
                break;

            case 4:
                this._mid_col_x = col_x;
                this._mid_row_y = row_y;
                break;

            case 5:
                vY        = row_y - _rows_y[4].D;
                vX        = col_x - _cols_x[4].D;
                this._phi = Math.Atan2(vY, vX);
                break;

            default:

                break;
            }
            updateHandlePos();
        }