示例#1
0
        /// <summary>
        /// 获取当前选中ROI的信息
        /// </summary>
        /// <returns></returns>
        protected internal System.Collections.Generic.List <double> smallestActiveROI(out string name, out int index)
        {
            name = "";
            int activeROIIdx = this.getActiveROIIdx();

            index = activeROIIdx;
            if (activeROIIdx > -1)
            {
                ROI  region = this.getActiveROI();
                Type type   = region.GetType();
                name = type.Name;

                HTuple smallest = region.getModelData();
                System.Collections.Generic.List <double> resual = new System.Collections.Generic.List <double>();
                for (int i = 0; i < smallest.Length; i++)
                {
                    resual.Add(smallest[i].D);
                }

                return(resual);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        protected internal ROI smallestActiveROI(out System.Collections.Generic.List <double> data, out int index)
        {
            try
            {
                int activeROIIdx = this.getActiveROIIdx();
                index = activeROIIdx;
                data  = new System.Collections.Generic.List <double>();

                if (activeROIIdx > -1)
                {
                    ROI    region   = this.getActiveROI();
                    Type   type     = region.GetType();
                    HTuple smallest = region.getModelData();

                    //////for (int i = 0; i < smallest.Length; i++)
                    //////{
                    //////    data.Add(smallest[i].D);
                    //////}

                    return(region);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                data  = null;
                index = 0;
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// Clears all variables managing ROI objects
 /// </summary>
 public void reset()
 {
     ROIList.Clear();
     activeROIidx = -1;
     ModelROI     = null;
     roiMode      = null;
     NotifyRCObserver(EVENT_DELETED_ALL_ROIS);
 }
示例#4
0
        protected internal RoiData(int id, ROI roi)
        {
            this._id = id;
            HTuple m_roiData = null;

            m_roiData = roi.getModelData();

            switch (roi.Type)
            {
            case "ROIRectangle1":
                this._name = "Rectangle1";

                if (m_roiData != null)
                {
                    this._rectangle1       = new Rectangle1(m_roiData[0].D, m_roiData[1].D, m_roiData[2].D, m_roiData[3].D);
                    this._rectangle1.Color = roi.Color;
                }
                break;

            case "ROIRectangle2":
                this._name = "Rectangle2";

                if (m_roiData != null)
                {
                    this._rectangle2       = new Rectangle2(m_roiData[0].D, m_roiData[1].D, m_roiData[2].D, m_roiData[3].D, m_roiData[4].D);
                    this._rectangle2.Color = roi.Color;
                }
                break;

            case "ROICircle":
                this._name = "Circle";

                if (m_roiData != null)
                {
                    this._circle       = new Circle(m_roiData[0].D, m_roiData[1].D, m_roiData[2].D);
                    this._circle.Color = roi.Color;
                }
                break;

            case "ROILine":
                this._name = "Line";

                if (m_roiData != null)
                {
                    this._line       = new Line(m_roiData[0].D, m_roiData[1].D, m_roiData[2].D, m_roiData[3].D);
                    this._line.Color = roi.Color;
                }
                break;

            default:
                break;
            }
        }
示例#5
0
        /// <summary>
        /// 在指定位置显示ROI--Line
        /// </summary>
        /// <param name="beginRow"></param>
        /// <param name="beginCol"></param>
        /// <param name="endRow"></param>
        /// <param name="endCol"></param>
        /// <param name="rois"></param>
        public void displayLine(string color, double beginRow, double beginCol, double endRow, double endCol)
        {
            this.setROIShape(new ROILine());

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createLine(beginRow, beginCol, endRow, endCol);
                roiMode.Type  = roiMode.GetType().Name;
                roiMode.Color = color;
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#6
0
        public void displayCircularArc(string color, double row, double col, double radius, double startPhi, double extentPhi)
        {
            setROIShape(new ROICircle());

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createCircularArc(row, col, radius, startPhi, extentPhi, "positive");
                roiMode.Type  = roiMode.GetType().Name;
                roiMode.Color = color;
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#7
0
        /// <summary>
        /// 在指定位置显示ROI--Rectangle2
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="phi"></param>
        /// <param name="length1"></param>
        /// <param name="length2"></param>
        /// <param name="rois"></param>
        public void displayRect2(string color, double row, double col, double phi, double length1, double length2)
        {
            setROIShape(new ROIRectangle2());

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createRectangle2(row, col, phi, length1, length2);
                roiMode.Type  = roiMode.GetType().Name;
                roiMode.Color = color;
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#8
0
        public void displayNurbs(string color, HTuple rows, HTuple cols)
        {
            setROIShape(new ROINurbs());

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createROINurbs(rows, cols);
                roiMode.Type  = roiMode.GetType().Name;
                roiMode.Color = color;
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#9
0
        protected internal void genCircularArc(double row, double col, double radius, double startPhi, double extentPhi, string direct, ref System.Collections.Generic.List <ROI> rois)
        {
            setROIShape(new ROICircularArc());

            if (rois == null)
            {
                rois = new System.Collections.Generic.List <ROI>();
            }

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createCircularArc(row, col, radius, startPhi, extentPhi, direct);
                roiMode.Type = roiMode.GetType().Name;
                rois.Add(roiMode);
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#10
0
        /// <summary>
        /// 在指定位置生成ROI--Rectangle2
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="phi"></param>
        /// <param name="length1"></param>
        /// <param name="length2"></param>
        /// <param name="rois"></param>
        protected internal void genInitRect2(double imageHeight, ref System.Collections.Generic.List <ROI> rois)
        {
            setROIShape(new ROIRectangle2());

            if (rois == null)
            {
                rois = new System.Collections.Generic.List <ROI>();
            }

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createInitRectangle2(imageHeight);
                roiMode.Type = roiMode.GetType().Name;
                rois.Add(roiMode);
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#11
0
        /// <summary>
        /// 在指定位置生成ROI--Line
        /// </summary>
        /// <param name="beginRow"></param>
        /// <param name="beginCol"></param>
        /// <param name="endRow"></param>
        /// <param name="endCol"></param>
        /// <param name="rois"></param>
        protected internal void genLine(double beginRow, double beginCol, double endRow, double endCol, ref System.Collections.Generic.List <ROI> rois)
        {
            this.setROIShape(new ROILine());

            if (rois == null)
            {
                rois = new System.Collections.Generic.List <ROI>();
            }

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createLine(beginRow, beginCol, endRow, endCol);
                roiMode.Type = roiMode.GetType().Name;
                rois.Add(roiMode);
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#12
0
        /// <summary>
        /// 在指定位置生成ROI--Rectangle1
        /// </summary>
        /// <param name="row1"></param>
        /// <param name="col1"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="rois"></param>
        protected internal void genNurbs(HTuple rows, HTuple cols, ref System.Collections.Generic.List <ROI> rois)
        {
            setROIShape(new ROINurbs());

            if (rois == null)
            {
                rois = new System.Collections.Generic.List <ROI>();
            }

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createROINurbs(rows, cols);
                roiMode.Type = roiMode.GetType().Name;
                rois.Add(roiMode);
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
示例#13
0
        public void updateImage(List <object> list)
        {
            //清空显示image
            _hWndControl.clearList(false);
            //清空hobjectList
            _hWndControl.clearHRegionList();
            //清空roi
            _hWndControl.roiManager.reset();

            for (int igg = 0; igg < list.Count / 2; igg++)
            {
                string strDrawType = list[igg * 2] as string;
                if (strDrawType == "message")
                {
                    HWndMessage msg = list[igg * 2 + 1] as HWndMessage;
                    if (msg != null)
                    {
                        _hWndControl.HObjImageList.Add(new HObjectEntry(msg));
                    }
                }
                if (strDrawType == "region")
                {
                    HRegionEntry entry = list[igg * 2 + 1] as HRegionEntry;
                    if (entry != null)
                    {
                        _hWndControl.hRegionList.Add(entry);
                    }
                }
                if (strDrawType == "roi")
                {
                    ROI roi = list[igg * 2 + 1] as ROI;
                    _hWndControl.roiManager.ROIList.Add(roi);
                }
            }

            _hWndControl.repaint();
        }
示例#14
0
 /// <summary>
 /// To create a new ROI object the application class initializes a
 /// 'seed' ROI instance and passes it to the ROIController.
 /// The ROIController now responds by manipulating this new ROI
 /// instance.
 /// </summary>
 /// <param name="r">
 /// 'Seed' ROI object forwarded by the application forms class.
 /// </param>
 public void setROIShape(ROI r)
 {
     roiMode = r;
     roiMode.setOperatorFlag(stateROI);
 }
示例#15
0
 /// <summary>
 /// Deletes this ROI instance if a 'seed' ROI object has been passed
 /// to the ROIController by the application class.
 ///
 /// </summary>
 public void resetROI()
 {
     activeROIidx = -1;
     roiMode      = null;
 }
示例#16
0
        public ROI smallestActiveROI(out List <double> data, out int index)
        {
            ROI roi = this._roiController.smallestActiveROI(out data, out index);

            return(roi);
        }
示例#17
0
        /// <summary>
        /// Reaction of ROI objects to the 'mouse button down' event: changing
        /// the shape of the ROI and adding it to the ROIList if it is a 'seed'
        /// ROI.
        /// </summary>
        /// <param name="imgX">x coordinate of mouse event</param>
        /// <param name="imgY">y coordinate of mouse event</param>
        /// <returns></returns>
        public int mouseDownAction(double imgX, double imgY)
        {
            int    idxROI = -1;
            double max = 10000, dist = 0;
            double epsilon = 35.0;          //maximal shortest distance to one of

            //the handles

            if (roiMode != null)             //either a new ROI object is created
            {
                roiMode.createROI(imgX, imgY);
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
            else if (ROIList.Count > 0)     // ... or an existing one is manipulated
            {
                activeROIidx = -1;

                int activeHandleIndex = -1;

                for (int i = 0; i < ROIList.Count; i++)
                {
                    dist = ((ROI)ROIList[i]).distToClosestHandle(imgX, imgY, out activeHandleIndex);
                    if ((dist < max) && (dist < epsilon))
                    {
                        max    = dist;
                        idxROI = i;
                    }
                }//end of for

                if (idxROI >= 0)
                {
                    activeROIidx = idxROI;
                    NotifyRCObserver(ROIController.EVENT_ACTIVATED_ROI);

                    if (activeHandleIndex > -1)
                    {
                        string name = ROIList[idxROI].GetType().Name;
                        if (name == "ROIRectangle1")
                        {
                            switch (activeHandleIndex)
                            {
                            case 0:    //左上
                                viewController.viewPort.hvppleWindow.SetMshape("Size NWSE");
                                break;

                            case 1:    //右上
                                viewController.viewPort.hvppleWindow.SetMshape("Size NESW");
                                break;

                            case 2:    //右下
                                viewController.viewPort.hvppleWindow.SetMshape("Size NWSE");
                                break;

                            case 3:    //左下
                                viewController.viewPort.hvppleWindow.SetMshape("Size NESW");
                                break;

                            case 4:    //中心
                                viewController.viewPort.hvppleWindow.SetMshape("Size All");
                                break;

                            case 5:    //左中
                                viewController.viewPort.hvppleWindow.SetMshape("Size WE");
                                break;

                            case 6:    //右中
                                viewController.viewPort.hvppleWindow.SetMshape("Size WE");
                                break;

                            case 7:    //上中
                                viewController.viewPort.hvppleWindow.SetMshape("Size S");
                                break;

                            case 8:    //下中
                                viewController.viewPort.hvppleWindow.SetMshape("Size S");
                                break;

                            default:    //
                                viewController.viewPort.hvppleWindow.SetMshape("default");
                                break;
                            }
                        }
                    }
                }
                else
                {
                    viewController.viewPort.hvppleWindow.SetMshape("default");
                }



                viewController.repaint();
            }
            return(activeROIidx);
        }